What Are the Optional Dependencies for Code-Graph-RAG? Complete Installation Guide
Code-Graph-RAG provides five optional dependency groups—test, treesitter-full, semantic, milvus, and ast-grep—that extend the core library with testing utilities, multi-language parsers, semantic search capabilities, and AST pattern matching.
Code-Graph-RAG is a Python library designed for constructing code-aware retrieval-augmented generation (RAG) systems. While the core installation includes essential components like loguru, mcp, and basic Tree-Sitter bindings, the project defines optional dependencies in pyproject.toml to support advanced features without bloating the base package. These extras allow you to tailor the installation to specific use cases, from parsing multiple programming languages to enabling vector-based semantic search.
Available Optional Dependency Groups
The optional dependencies are declared in the [project.optional-dependencies] table of pyproject.toml (lines 87–131). Each group serves a distinct purpose and can be installed independently.
Test Dependencies
The test extra provides the complete toolchain needed to run the library’s test suite and generate coverage reports. This includes pytest, pytest-asyncio, pytest-cov, pytest-xdist, and testcontainers, along with supporting libraries like libclang, filelock, ast-grep-py, and pyyaml.
Full Tree-Sitter Language Support
The treesitter-full extra installs comprehensive Tree-Sitter grammars for deep code-graph construction across multiple languages. This group includes parsers for Python, JavaScript, TypeScript, Rust, Go, Scala, Java, C, C++, Lua, PHP, C#, and Dart (declared in pyproject.toml lines 100–114).
Semantic Search Capabilities
The semantic extra enables embedding-based semantic search and RAG functionality. It installs qdrant-client for vector database interaction, along with torch and transformers for running local embedding models.
Milvus Vector Database Integration
The milvus extra adds support for the Milvus vector database through the pymilvus[milvus-lite] package, offering an alternative backend to Qdrant for vector storage and retrieval.
AST Pattern Matching
The ast-grep extra provides utilities for structural code search using the ast-grep-py library, complemented by pyyaml for configuration file parsing.
How to Install Code-Graph-RAG with Optional Dependencies
Install the core library alone for minimal footprint:
pip install code-graph-rag
Add specific functionality using bracket notation:
# Testing and development tools
pip install "code-graph-rag[test]"
# Comprehensive language parsing support
pip install "code-graph-rag[treesitter-full]"
# Semantic search with Qdrant and ML embeddings
pip install "code-graph-rag[semantic]"
# Milvus vector database support
pip install "code-graph-rag[milvus]"
# AST-based pattern matching utilities
pip install "code-graph-rag[ast-grep]"
Combine multiple extras for complete functionality:
pip install "code-graph-rag[semantic,treesitter-full]"
Conditional Imports and Lazy Loading
The library implements lazy imports to handle missing optional dependencies gracefully. In codebase_rag/cli.py, the CLI entry point conditionally imports modules based on which extras are present. The codebase_rag/semantic/ directory contains modules that require the semantic extra, while codebase_rag/parsers/ houses Tree-Sitter wrappers that leverage the treesitter-full extra for additional language support. The test suite located in codebase_rag/tests/ strictly requires the test extra to execute properly.
Summary
- Five optional groups are available:
test,treesitter-full,semantic,milvus, andast-grep. - Install via extras using
pip install "code-graph-rag[extra-name]"syntax. - Test extra provides pytest, coverage tools, and integration testing frameworks.
- Treesitter-full adds support for 13+ programming languages beyond the core grammars.
- Semantic extra enables Qdrant vector search with PyTorch and Hugging Face Transformers.
- Implementation uses conditional imports in
codebase_rag/cli.pyto maintain modularity.
Frequently Asked Questions
How do I install all optional dependencies at once?
You must specify each extra individually, as there is no single "all" meta-package defined in pyproject.toml. Install the most common combination for full functionality: pip install "code-graph-rag[treesitter-full,semantic,ast-grep]".
What happens if I try to use semantic search without installing the semantic extra?
The code will raise an ImportError or ModuleNotFoundError when attempting to import qdrant-client, torch, or transformers. The library is designed to fail fast when required optional dependencies are missing for specific features.
Can I use Milvus instead of Qdrant for vector storage?
Yes. Install the milvus extra (pip install "code-graph-rag[milvus]") to use pymilvus[milvus-lite] as an alternative vector backend. Note that the semantic extra installs Qdrant by default, so you should install only the extras corresponding to your preferred backend.
Are the Tree-Sitter grammars in treesitter-full required for basic functionality?
No. The core library includes basic Tree-Sitter support, but the treesitter-full extra is required for parsing languages like Rust, Go, Java, C/C++, and others beyond Python and JavaScript. Without this extra, the parser will fail to build syntax trees for unsupported languages.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →