multi-language ast parsing and entity extraction with tree-sitter
Parses source code in 66 languages using tree-sitter grammar bindings (vendored C components) to extract structural entities: function/method definitions, class hierarchies, variable declarations, imports, and type annotations. The parsing engine operates as the first pass in a 7-pass indexing pipeline, converting raw source text into an intermediate AST representation that feeds downstream semantic analysis. Uses tree-sitter's incremental parsing to avoid re-parsing unchanged file regions during incremental reindexing.
Unique: Uses vendored tree-sitter C bindings compiled into a single static binary, enabling 66-language support without external dependencies or grammar downloads. Integrates incremental parsing to avoid re-parsing unchanged regions during content-hash-based reindexing, achieving ~4× faster incremental updates than full-scan approaches.
vs alternatives: Supports 66 languages in a single binary with zero external dependencies, whereas LSP-based approaches require per-language server installations and Regex-based tools are limited to 5-10 languages with poor structural accuracy.
persistent sqlite knowledge graph with cypher query engine
Builds and maintains a queryable knowledge graph stored in SQLite WAL mode at ~/.cache/codebase-memory-mcp/codebase-memory.db. The graph schema models code entities (functions, classes, modules) as nodes and relationships (calls, inheritance, imports, type references) as edges. Exposes a Cypher query engine (src/store/store.c) for graph traversal, enabling sub-millisecond queries for structural patterns like 'find all callers of function X' or 'trace inheritance chain for class Y'. Supports incremental updates via content-hash-based change detection — only modified files trigger re-parsing and graph updates.
Unique: Implements a Cypher query engine in C within a single static binary, achieving sub-millisecond query latency on graphs with thousands of nodes. Uses content-hash-based incremental indexing to detect file changes and update only affected graph regions, enabling ~4× faster re-indexing than full-scan approaches. Stores graph in SQLite WAL mode for ACID compliance and concurrent read access.
vs alternatives: Delivers sub-millisecond Cypher queries on local graphs without network latency, whereas cloud-based code intelligence services (GitHub Copilot, Tabnine) incur 100-500ms round-trip latency and require sending code to external servers.
community detection and architectural clustering
Performs community detection on the code graph to identify clusters of related entities (functions, classes, modules) that form logical architectural components. The indexing pipeline (Pass 6) uses graph clustering algorithms to group entities based on call frequency, shared dependencies, and module boundaries. Results are stored in the graph as 'BELONGS_TO_COMMUNITY' relationships, queryable via tools like 'find_communities' and 'find_community_members'. Useful for understanding codebase architecture, identifying tightly coupled components, and visualizing system structure.
Unique: Uses graph clustering algorithms on the call graph to automatically identify architectural components without manual configuration or domain knowledge. Results are stored in the graph for efficient querying and visualization.
vs alternatives: Automatic community detection requires no manual configuration or domain knowledge, whereas manual architecture documentation is often outdated. Faster and more objective than manual architectural analysis.
test coverage mapping and test-to-code linking
Identifies test functions and links them to the code they test by analyzing test file naming conventions, test decorators, and assertion patterns. The indexing pipeline (Pass 7) detects test functions (e.g., functions starting with 'test_', methods in classes ending with 'Test', functions decorated with @test or @pytest.mark) and attempts to link them to the functions they test based on naming patterns and call graph analysis. Results are stored in the graph as 'TESTS' relationships, queryable via tools like 'find_tests_for_function' and 'find_tested_functions'.
Unique: Automatically links test functions to code under test using naming patterns and call graph analysis, without requiring explicit test annotations or coverage instrumentation. Works across multiple testing frameworks (pytest, unittest, Jest, Go testing, etc.) in a single indexing pass.
vs alternatives: Automatic test linking requires no instrumentation or coverage tools, whereas coverage tools (pytest-cov, Istanbul) require test execution and only measure line coverage. Faster than manual test discovery and works for untested code.
file content access and code snippet retrieval
Provides direct access to source code files and code snippets via tools like 'get_file_content' and 'get_code_snippet'. Supports retrieving entire files or specific line ranges, with optional syntax highlighting and context expansion. Useful for AI agents that need to read actual code after identifying relevant functions via graph queries. Integrates with graph queries to provide seamless navigation from structural queries (find_callers) to actual code inspection.
Unique: Provides direct file access integrated with graph queries, enabling seamless navigation from structural queries (find_callers) to actual code inspection. Supports line-range retrieval and context expansion for efficient code reading.
vs alternatives: Integrated file access eliminates separate file reading steps and enables efficient context expansion, whereas separate file reading tools require manual path construction and context management.
configuration file and dependency link detection
Detects references to configuration files, environment variables, and external dependencies by analyzing code patterns, imports, and config file references. The indexing pipeline (Pass 5) identifies config file paths (e.g., 'config.yaml', 'settings.json'), environment variable references (e.g., 'os.getenv("DATABASE_URL")'), and external dependencies (e.g., 'import requests', 'require("express")') and links them to the code that references them. Results are stored in the graph as 'REFERENCES_CONFIG', 'USES_ENV_VAR', and 'DEPENDS_ON' relationships.
Unique: Automatically detects configuration file, environment variable, and dependency references using pattern matching and AST analysis, linking them to code locations in the graph. Works across multiple languages and frameworks without requiring explicit annotations.
vs alternatives: Automatic detection of config and dependency references requires no manual configuration, whereas dependency analysis tools (npm audit, pip-audit) only check for known vulnerabilities and don't link to code locations. Faster than manual dependency tracking.
polyglot codebase indexing with language-specific semantics
Indexes codebases containing multiple programming languages (Python, Go, TypeScript, Rust, Java, C++, C#, Kotlin, Lua, Haskell, OCaml, Swift, Dart, MATLAB, Lean 4, Wolfram, and 48 more) in a single unified indexing pass. Each language is parsed using language-specific tree-sitter grammars, and semantic analysis (call resolution, type inference, HTTP route detection) is adapted to each language's semantics. Results are stored in a unified graph that enables cross-language queries (e.g., 'find all Python functions that call Go functions').
Unique: Indexes 66 languages in a single unified graph with language-specific semantic analysis, enabling cross-language queries without separate per-language tools. Each language's semantics (Python type hints, Go explicit types, TypeScript annotations) are respected in a unified indexing pipeline.
vs alternatives: Single unified indexing pass for 66 languages eliminates the need for per-language tool setup, whereas LSP-based approaches require separate server configuration for each language. Cross-language queries are impossible with language-specific tools.
7-pass semantic indexing pipeline with call resolution and type inference
Executes a multi-stage indexing pipeline (src/pipeline/pipeline.c) that progressively enriches the graph: Pass 1 extracts structure (definitions, imports), Pass 2 resolves calls to their definitions, Pass 3 infers types and inheritance, Pass 4 detects HTTP links and routes, Pass 5 identifies config file references, Pass 6 performs community detection (clustering related entities), Pass 7 indexes test coverage. Each pass operates on the graph built by previous passes, enabling sophisticated analyses like 'find all functions that handle HTTP POST requests' or 'identify dead code by tracing reachability from entry points'. Type inference uses language-specific heuristics (e.g., Python type hints, Go explicit types, TypeScript annotations) to build a best-effort type map.
Unique: Implements a 7-pass pipeline that progressively enriches the graph with semantic information (calls, types, HTTP routes, communities, tests) in a single indexing run. Each pass operates on the graph state from previous passes, enabling sophisticated cross-cutting analyses without re-parsing. Uses language-specific heuristics for call resolution and type inference, adapting to each language's semantics (Python type hints, Go explicit types, TypeScript annotations).
vs alternatives: Provides call resolution and type inference in a single indexing pass without requiring LSP servers or language-specific analysis tools, whereas LSP-based approaches require per-language server setup and multiple round-trips for semantic information.
+7 more capabilities