| description | Add support for new programming languages to Code-Graph-RAG using Tree-sitter grammars. |
|---|
Code-Graph-RAG makes it easy to add support for any language that has a Tree-sitter grammar. The system automatically handles grammar compilation and integration.
!!! warning While you can add languages yourself, we recommend waiting for official full support to ensure optimal parsing quality, comprehensive feature coverage, and robust integration. Submit a language request if you need a specific language supported.
Use the built-in language management tool:
cgr language add-grammar <language-name>Examples:
cgr language add-grammar c-sharp
cgr language add-grammar php
cgr language add-grammar ruby
cgr language add-grammar kotlinFor languages hosted outside the standard tree-sitter organisation:
cgr language add-grammar --grammar-url https://github.com/custom/tree-sitter-mylangWhen you add a language, the tool automatically:
- Downloads the Grammar: Clones the tree-sitter grammar repository as a git submodule
- Detects Configuration: Auto-extracts language metadata from
tree-sitter.json - Analyses Node Types: Automatically identifies AST node types for functions/methods, classes/structs, modules/files, and function calls from
node-types.json - Updates Configuration: Adds the language to
codebase_rag/language_spec.py - Enables Parsing: Makes the language available for codebase analysis (the grammar itself is compiled on first use by the parser loader)
$ cgr language add-grammar c-sharp
Search: Using default tree-sitter URL: https://github.com/tree-sitter/tree-sitter-c-sharp
OK Submodule added at: grammars/tree-sitter-c-sharp
Auto-detected extensions: ['.cs']
Functions: ['destructor_declaration', 'method_declaration', 'constructor_declaration']
Classes: ['struct_declaration', 'enum_declaration', 'interface_declaration', 'class_declaration']
Modules: ['compilation_unit', 'file_scoped_namespace_declaration', 'namespace_declaration']
Calls: ['invocation_expression']
OK Language 'c-sharp' added
Note: Updated codebase_rag/language_spec.pycgr language list-languages
cgr language remove-language <language-name>Each language is defined in the LANGUAGE_SPECS dict in codebase_rag/language_spec.py:
"language-name": LanguageSpec(
language="language-name",
file_extensions=[".ext1", ".ext2"],
function_node_types=["function_declaration", "method_declaration"],
class_node_types=["class_declaration", "struct_declaration"],
module_node_types=["compilation_unit", "source_file"],
call_node_types=["call_expression", "method_invocation"],
),Grammar not found: Use a custom URL if the automatic URL doesn't work:
cgr language add-grammar --grammar-url https://github.com/custom/tree-sitter-mylangVersion incompatibility: If you get "Incompatible Language version" errors:
uv add tree-sitter@latestMissing node types: The tool automatically detects common node patterns, but you can manually adjust the configuration in language_spec.py if needed.