Skip to content

Commit 62fc4f9

Browse files
authored
Merge branch 'main' into upstream-pr/elixir-channels
2 parents f8b6a1a + fceb25d commit 62fc4f9

68 files changed

Lines changed: 11844 additions & 1223 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Makefile.cbm‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ PIPELINE_SRCS = \
537537
src/pipeline/pass_compile_commands.c \
538538
src/pipeline/pass_infrascan.c \
539539
src/pipeline/pass_k8s.c \
540+
src/pipeline/helm_template.c \
540541
src/pipeline/pass_operator.c \
541542
src/pipeline/pass_shell.c \
542543
src/pipeline/pass_terraform.c \

‎README.md‎

Lines changed: 73 additions & 29 deletions
Large diffs are not rendered by default.

‎docs/index.html‎

Lines changed: 377 additions & 776 deletions
Large diffs are not rendered by default.

‎docs/llms.txt‎

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
11
# codebase-memory-mcp
22

3-
> An open-source Model Context Protocol (MCP) server that indexes a codebase into a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. AI coding agents query the graph instead of reading files one by one, answering structural questions with roughly 120x fewer tokens (~3,400 vs ~412,000 across five structural queries). Parses 162 languages via vendored tree-sitter grammars, with Hybrid LSP semantic type resolution for Python, TypeScript/JavaScript, PHP, C#, Go, C/C++, Java, Kotlin, and Rust. It also generates semantic graph edges (SEMANTICALLY_RELATED for vocabulary-mismatch matches, SIMILAR_TO for near-clone detection) and supports semantic vector search via bundled nomic-embed-code embeddings compiled into the native executable — no API key, no Ollama, no Docker. Ships a native executable with an authenticated integration asset; the UI variant adds one content-addressed frontend pack. All processing is local — the embeddings run on-device; there is no embedded LLM and no API key.
4-
5-
## Key facts
6-
7-
- License: MIT, open source.
8-
- Languages: 158 (158 vendored tree-sitter grammars compiled into the binary).
9-
- Hybrid LSP type resolution: 9 language families (Python, TypeScript/JavaScript/JSX/TSX, PHP, C#, Go, C/C++, Java, Kotlin, Rust) — a lightweight C implementation of language type-resolution algorithms, structurally inspired by and compatible with major language servers including tsserver, pyright, gopls, Roslyn, Eclipse JDT, and rust-analyzer.
10-
- MCP tools: 15 (search_graph incl. semantic_query vector search, trace_path (alias: trace_call_path), check_index_coverage, query_graph (Cypher), detect_changes, get_architecture, get_code_snippet, manage_adr, and more).
11-
- Semantic search: natural-language code discovery via bundled nomic-embed-code embeddings (768-dim, compiled into the binary); 11-signal combined scoring; fully local, no API key.
12-
- Semantic & similarity edges: SEMANTICALLY_RELATED (vocabulary-mismatch matches) and SIMILAR_TO (MinHash + LSH near-clone / duplicate detection).
13-
- Cross-repo intelligence: CROSS_* edges link nodes across multiple repos indexed in one store; multi-galaxy 3D layout and cross-repo architecture summary.
14-
- Cross-service linking: HTTP route ↔ call-site matching, plus gRPC/GraphQL/tRPC detection and pub/sub channels (EMITS/LISTENS_ON for Socket.IO, EventEmitter, generic buses).
3+
> Local code intelligence for developers and AI agents. Connect code, documentation, configuration, and infrastructure in a persistent knowledge graph. Search for a feature, follow callers and dependencies, trace services and deployments, inspect change impact, and explore the evidence in CBM Lens. Access the same backend through MCP or the CLI. Indexing, graph queries, and semantic embeddings run locally without a hosted service or API key; Lens optionally downloads a browser model after opt-in for on-device code chat.
4+
5+
## Capabilities
6+
7+
- Code exploration: symbol and structural search, BM25 text search, semantic search, source snippets and file outlines, call paths, data flow, architecture summaries, hotspots, cycles, and coverage diagnostics. The server registers 17 MCP tools.
8+
- Semantic and similarity relationships: bundled embeddings support natural-language discovery; SEMANTICALLY_RELATED edges connect vocabulary-mismatch matches, and SIMILAR_TO edges expose near-clone candidates.
9+
- Languages and formats: vendored parsers cover source, documentation, and configuration formats. Hybrid LSP adds semantic type resolution for Python, TypeScript/JavaScript/JSX/TSX, PHP, C#, Go, C/C++, Java, Kotlin, Rust, and Perl. Support and resolution depth differ by language; use the README language matrix and check_index_coverage for the indexed project.
10+
- Documentation connected to code: Markdown, reStructuredText, and AsciiDoc sections; PDF text pages (no OCR); supported document and language doc-comment references to code; ADR metadata and supersession. Supported diagrams and OpenAPI descriptions contribute entities, with format-specific reference-resolution limits.
11+
- Infrastructure and deployment: Docker/Compose, Kubernetes, Helm, Kustomize, Terraform/OpenTofu, Terragrunt, Ansible, shell, Make, and supported CI relationships. Trace deployments, images, entrypoints, configuration keys, and environment-variable access back to source when inputs can be resolved statically.
12+
- Cross-service and cross-repository relationships: supported HTTP, asynchronous messaging, gRPC, GraphQL, and tRPC links. Cross-repo analysis explicitly links projects indexed in the same store; missing links do not prove that no runtime relationship exists.
13+
- Change impact: detect_changes maps diffs to affected symbols and investigates related tests with scope: "tests"; compare_graphs compares indexed snapshots.
14+
- Smart CI (experimental): repository-specific changed-file rules select CI jobs; test-impact select combines static reachability, changed tests, and admitted per-test coverage to select tests. Narrowing supports C/C++ family code with supported test-harness conventions and an explicitly configured runner. Missing or doubtful evidence broadens the selection or runs all tests. Other indexed languages are not automatically supported for test narrowing. test-impact publish creates the baseline graph-and-coverage bundle. Start in shadow mode; consult the guide for version requirements.
15+
- Architecture decisions and runtime evidence: manage_adr stores the project's decision record; ingest_traces adds separately collected observed call relationships alongside static analysis.
16+
- CBM Lens Beta: local browser interface with source exploration, Galaxy graph navigation, architecture and behavior views, ADR editing, index-coverage diagnostics, daemon/system information, and optional local code chat. Static graph animations are not live execution traces. Activity overlays are experimental source-build features, not a standard-release promise.
17+
- Agent integrations: 45 automatic or conditional client surfaces. Installation configures supported MCP entries, durable instructions, skills, Scout/Verify/Auditor profiles, and applicable session, compaction, search, and read hooks. Coverage and activation vary by client and platform. Hooks provide context without blocking or replacing the user's tool call; some clients require trust or use parent-agent handoff instead.
18+
- Persistent operation: a per-account daemon coordinates sessions and indexing. Existing indexes can stay synchronized during eligible active MCP sessions; initial auto-indexing is separately opt-in. Optional team graph artifacts share a baseline while each user keeps a local query database.
19+
- Distribution: native C backend, MIT license, standard native releases for macOS, Linux, and Windows include CBM Lens; Linux portable archives provide static builds. Nix and development source builds can omit the UI. Package-manager options and release verification are documented in the README.
20+
21+
## Client coverage
22+
1523
- Supported agents: 45 automatic/conditional client surfaces (39 automatically detected + 6 conditional/explicit): Claude Code, Codex CLI, Gemini CLI, Zed, OpenCode, Antigravity, Aider, KiloCode, VS Code, Cursor, Windsurf, Augment / Auggie, OpenClaw, Kiro, Junie, Hermes, OpenHands, Cline, Warp, Qwen Code, GitHub Copilot CLI, Factory Droid, Crush, Goose, Mistral Vibe, Grok Build, Qoder CLI, Kimi Code CLI, GitLab Duo CLI, Rovo Dev CLI, Amp, Devin CLI / Local, Tabnine, Continue / cn, Visual Studio, TRAE, Roo Code, Amazon Q Developer IDE, CodeBuddy Code CLI, IBM Bob IDE, IBM Bob Shell, Pochi, Pi, Oh My Pi (omp), and Sourcegraph Cody.
16-
- Agent profiles: documented custom-agent formats receive Scout (fast/provisional), Verify (default/task-directed), and Auditor (bounded/full verification) definitions. Every direct tier checks exact path/scope coverage with check_index_coverage and falls back to source for flagged gaps; unsafe child-MCP formats use explicit parent handoff. Kiro and Junie use positive-allowlist Scout/Analysis server profiles (7/11 tools); Qoder combines named-server selection with exact tier-specific MCP tool IDs, while Factory uses exact registered IDs without additive whole-server exposure. Foreign Junie aliases are preserved and force parent handoff.
17-
- Performance: Linux kernel (28M LOC, 75K files) full index in 3 minutes → 4.81M nodes, 7.72M edges; Cypher queries in under 1ms.
18-
- Distribution: verified runtime set (native executable plus authenticated release-owned assets); fully static Linux builds are available in the `-portable` archives. Also available through npm, PyPI, Homebrew, Scoop, AUR, and `go install`.
24+
25+
## Measurement and limits
26+
27+
Published performance and token comparisons apply to specific workloads, hardware, and agent setups, not a universal percentage saving. The README Performance section preserves the historical comparison and research quality tradeoff. Check index generation, freshness, and exact path/scope coverage before relying on graph results, especially absence claims; read source when coverage is partial, skipped, excluded, stale, or unknown. Infrastructure relationships are static, and test-selection support is narrower than language-indexing support.
1928

2029
## Links
2130

2231
- Homepage: https://deusdata.github.io/codebase-memory-mcp/
23-
- Source code (GitHub): https://github.com/DeusData/codebase-memory-mcp
32+
- Source and feature reference: https://github.com/DeusData/codebase-memory-mcp
2433
- Latest release: https://github.com/DeusData/codebase-memory-mcp/releases/latest
34+
- Quick start and installation: https://github.com/DeusData/codebase-memory-mcp#quick-start
35+
- Documentation indexing: https://github.com/DeusData/codebase-memory-mcp#documentation-connected-to-code
36+
- Infrastructure and deployment: https://github.com/DeusData/codebase-memory-mcp#infrastructure-and-deployment
37+
- CBM Lens: https://github.com/DeusData/codebase-memory-mcp#cbm-lens-beta-code-visualization-and-source-navigation
38+
- Agent integrations: https://github.com/DeusData/codebase-memory-mcp#multi-agent-support
39+
- Smart CI guide: https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/SMART_CI.md
40+
- Configuration: https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/CONFIGURATION.md
41+
- MCP tools: https://github.com/DeusData/codebase-memory-mcp#mcp-tools
42+
- Performance and research limits: https://github.com/DeusData/codebase-memory-mcp#performance
2543
- Benchmark report: https://github.com/DeusData/codebase-memory-mcp/blob/main/docs/BENCHMARK.md
2644
- Research paper: https://arxiv.org/abs/2603.27277
45+
- Security and release verification: https://github.com/DeusData/codebase-memory-mcp#security

‎internal/cbm/cbm.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,9 @@ typedef struct {
734734
* from the URL `name`; a HelmRelease whose chartRef names it deploys the
735735
* chart there.
736736
* CBM_K8S_FACT_IMAGE: object def_index runs its container `container`
737-
* (NULL: unnamed) from image `name` (a literal reference); via "container".
737+
* (NULL: unnamed) from image `name` (a literal reference, or a Helm
738+
* template's placeholder `<...>`, which names none); via "container";
739+
* `line` the image's line, start_line / end_line the container's.
738740
* CBM_K8S_FACT_ENV: object def_index sets environment variable `name` in
739741
* its container `container` (NULL: unnamed) at `line`; via = where the
740742
* value comes from ("value", or the valueFrom kind) -- never the value.
@@ -773,6 +775,8 @@ typedef struct {
773775
const char *url; /* DEPLOY (kustomize): the chart repository */
774776
const char *release; /* DEPLOY (kustomize): the release name */
775777
int line;
778+
int start_line; /* IMAGE: the container mapping's first line */
779+
int end_line; /* IMAGE: its last line */
776780
} CBMK8sFact;
777781

778782
typedef struct {

‎internal/cbm/doclink_go.c‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
* drops these lines and so carries no line number
4444
* at all.
4545
* G path go.mod: the module path
46-
* w says who keeps the node. A Go method node has a FLAT qualified name
47-
* (<dir>.<Method>), so a function, the methods of every receiver, a type and
48-
* a value of one name all claim the node <dir>.<name>, and within a file the
49-
* declaration on the LAST line keeps it (cbm_gbuf_upsert_node). w is 1 for
46+
* w says who keeps the node <dir>.<name>. A function, a type and a value of
47+
* one name all claim it, and within a file the declaration on the LAST line
48+
* keeps it (cbm_gbuf_upsert_node). A method claims nothing: its node is
49+
* receiver-qualified (<dir>.<Recv>.<Method>, #1913), and its w is `-`. w is 1 for
5050
* that declaration, 0 for the others of that name, x when two of them start
5151
* on that last line, and - for a value the extractor gives no node at all
5252
* (it gives one to the first name of a constant spec and of a parenthesis-
@@ -1511,9 +1511,11 @@ static void go_scan_method(go_scan_t *s, TSNode m) {
15111511
recv = "?";
15121512
recv_len = SKIP_ONE;
15131513
}
1514-
go_push_claim(s,
1515-
cbm_arena_sprintf(s->tmp, "M\t%.*s\t%.*s", (int)recv_len, recv, (int)len, name),
1516-
name, len, m);
1514+
/* #1913: a Go method node is receiver-qualified (<dir>.<Recv>.<Method>),
1515+
* so a method claims no flat name: w is `-`, and the method is found
1516+
* through its receiver (the member table), never through <dir>.<name>. */
1517+
(void)go_push_rec(
1518+
s, cbm_arena_sprintf(s->tmp, "M\t%.*s\t%.*s\t-", (int)recv_len, recv, (int)len, name));
15171519
}
15181520

15191521
/* The implied name of an embedded field: the type's own name, without

‎internal/cbm/extract_calls.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4493,6 +4493,24 @@ CBMInvocationDescriptor handle_calls(CBMExtractCtx *ctx, TSNode node, const CBML
44934493
}
44944494
}
44954495
}
4496+
// Go receiver-aware guard (same direction as the TS/JS flag above).
4497+
// Flag a selector call x.foo(). The Go AST cannot separate a method
4498+
// call on a value from a package-qualified call — but every selector
4499+
// call the Go LSP or the import/qualified registry strategies CAN
4500+
// place never reaches the weak short-name guards, so the flag only
4501+
// bites on unresolvable receivers (`f.Close()` on an os.File,
4502+
// `sha256.New()` behind an unindexed import), where a project-wide
4503+
// short-name match fabricates an edge to an unrelated project
4504+
// symbol sharing the name. Bare calls (helper()) keep
4505+
// is_method=false and resolve same-module/import paths as before.
4506+
if (ctx->language == CBM_LANG_GO &&
4507+
strcmp(ts_node_type(node), "call_expression") == 0) {
4508+
TSNode gofn = ts_node_child_by_field_name(node, TS_FIELD("function"));
4509+
if (!ts_node_is_null(gofn) &&
4510+
strcmp(ts_node_type(gofn), "selector_expression") == 0) {
4511+
call.is_method = true;
4512+
}
4513+
}
44964514

44974515
TSNode args = ts_node_child_by_field_name(node, TS_FIELD("arguments"));
44984516
/* tree-sitter-elixir attaches NO field name to a call's arguments

‎internal/cbm/extract_defs.c‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5772,7 +5772,7 @@ static void set_def_complexity(CBMDefinition *def, TSNode body, const CBMLangSpe
57725772
* Walks to the parameter_declaration's `type` field, unwrapping pointer_type
57735773
* and generic_type, and returns the type_identifier text (e.g. "OrderService").
57745774
* Returns NULL if no type_identifier is found. */
5775-
static char *go_receiver_type_name(CBMArena *a, TSNode recv, const char *source) {
5775+
char *cbm_go_receiver_type_name(CBMArena *a, TSNode recv, const char *source) {
57765776
uint32_t nc = ts_node_child_count(recv);
57775777
for (uint32_t i = 0; i < nc; i++) {
57785778
TSNode child = ts_node_child(recv, i);
@@ -7006,12 +7006,27 @@ static void extract_func_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
70067006
* (and downstream Go IMPLEMENTS/OVERRIDE) link the method to its owning
70077007
* struct/type node. The parent QN must match the type's node QN, which
70087008
* is computed the same way (cbm_fqn_compute on the type name). */
7009-
char *recv_type = go_receiver_type_name(a, recv, ctx->source);
7009+
char *recv_type = cbm_go_receiver_type_name(a, recv, ctx->source);
70107010
if (recv_type && recv_type[0]) {
70117011
/* Must match the Go type node QN (directory-based module) so the
70127012
* DEFINES_METHOD edge links the method to its owning type. */
70137013
def.parent_class = cbm_fqn_compute_source_lang(a, ctx->project, ctx->rel_path,
70147014
recv_type, ctx->language);
7015+
/* Receiver-qualify the method QN (proj.pkg.Recv.method) — same
7016+
* shape as the C++ out-of-line path below and Go interface
7017+
* members. With the flat proj.pkg.method QN every same-name
7018+
* method in a package collided in the graph upsert: one body
7019+
* survived and the twins' call edges accreted onto it. The
7020+
* call-scope side (compute_func_qn in extract_unified.c) mirrors
7021+
* this formula, and go_lsp consumers read the def QN and
7022+
* parent_class (receiver_type) verbatim, so resolution joins
7023+
* stay exact. Go only: templ's Go-derived grammar reaches this
7024+
* branch too, but its call-scope QN (compute_func_qn) stays flat,
7025+
* and a def QN the calls do not share would orphan every call
7026+
* inside a templ method. */
7027+
if (ctx->language == CBM_LANG_GO && def.parent_class) {
7028+
def.qualified_name = cbm_arena_sprintf(a, "%s.%s", def.parent_class, name);
7029+
}
70157030
}
70167031
}
70177032

0 commit comments

Comments
 (0)