Skip to content

Commit 9b5bf70

Browse files
authored
Merge branch 'main' into fix/test-daemon-bootstrap-sync-spawn
2 parents da4bd25 + 5958f54 commit 9b5bf70

20 files changed

Lines changed: 1061 additions & 51 deletions

‎.github/workflows/pr.yml‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,29 @@ jobs:
6464
run: |
6565
# The full .diff endpoint rejects large-but-valid PRs at 20k lines.
6666
# The paginated files endpoint remains filename-only for this gate.
67-
FILES=$(gh api --paginate "repos/$REPO/pulls/$PR/files?per_page=100" --jq '.[].filename')
67+
if FILES=$(gh api --paginate "repos/$REPO/pulls/$PR/files?per_page=100" --jq '.[].filename'); then
68+
echo "file list: pulls/files API"
69+
else
70+
# The files endpoint renders the diff server-side too, and answers
71+
# 422 "this diff is taking too long to generate" for a PR that
72+
# regenerates a vendored parser (#2246: a 42 MB sql/parser.c) --
73+
# so does the compare endpoint. The PR merge ref's first parent is
74+
# the base, so a name-only diff across it is the same file list.
75+
# depth 2 + blob:none fetches commits and trees only (well under
76+
# 1 MB, under a second); nothing from the PR is checked out or run.
77+
echo "::notice::pulls/files API failed; file list taken from refs/pull/$PR/merge"
78+
CHANGES_GIT="$RUNNER_TEMP/changes.git"
79+
git init -q --bare "$CHANGES_GIT"
80+
git --git-dir="$CHANGES_GIT" fetch -q --depth=2 --filter=blob:none \
81+
"https://github.com/$REPO" "refs/pull/$PR/merge"
82+
FILES=$(git --git-dir="$CHANGES_GIT" diff --name-only --no-renames FETCH_HEAD^1 FETCH_HEAD)
83+
fi
6884
printf '%s\n' "$FILES"
69-
if printf '%s\n' "$FILES" | grep -qE '^(src/|internal/|install\.(sh|ps1)|scripts/build\.sh|scripts/smoke-test\.sh|scripts/smoke-local\.sh|scripts/smoke-fixture-server\.py|scripts/gen-third-party-notices\.sh|scripts/env\.sh|test-infrastructure/vm/(vm-smoke\.sh|windows-user-path-guard\.ps1)|Makefile\.cbm)'; then
85+
# A here-string, not a pipe: under this shell's pipefail, grep -q
86+
# exits on its first match, printf dies of SIGPIPE once the list
87+
# outgrows the pipe buffer, and the MATCH is then reported as a
88+
# failure -- product=false, smoke skipped, on the largest PRs.
89+
if grep -qE '^(src/|internal/|install\.(sh|ps1)|scripts/build\.sh|scripts/smoke-test\.sh|scripts/smoke-local\.sh|scripts/smoke-fixture-server\.py|scripts/gen-third-party-notices\.sh|scripts/env\.sh|test-infrastructure/vm/(vm-smoke\.sh|windows-user-path-guard\.ps1)|Makefile\.cbm)' <<<"$FILES"; then
7090
echo "product=true" >> "$GITHUB_OUTPUT"
7191
else
7292
echo "product=false" >> "$GITHUB_OUTPUT"

‎CONTRIBUTING.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ src/
5555
foundation/ Arena allocator, hash table, string utils, platform compat
5656
store/ SQLite graph storage (WAL mode, FTS5)
5757
cypher/ Cypher query → SQL translation
58-
mcp/ MCP server (JSON-RPC 2.0 over stdio, 14 tools)
58+
mcp/ MCP server (JSON-RPC 2.0 over stdio, 17 tools)
5959
pipeline/ Multi-pass indexing pipeline
6060
pass_*.c Individual pipeline passes (definitions, calls, usages, etc.)
6161
httplink.c HTTP route extraction (Go/Express/Laravel/Ktor/Python)
@@ -149,6 +149,25 @@ If in doubt, open an issue and ask.
149149
- Run `scripts/test.sh` and `scripts/lint.sh` before submitting
150150
- Keep PRs focused — avoid unrelated reformatting or refactoring
151151

152+
## AI-assisted and AI-authored contributions
153+
154+
Contributions written with the help of an AI tool, or written by an AI agent acting for a person, are welcome here on the same terms as any other. What we review is the change, not who or what typed it. Three things make that work:
155+
156+
- **Say so.** If an agent wrote the PR or is answering in the thread, disclose it — a line in the PR description or at the top of a comment is enough ("written with X", "this account is operated by an AI agent on behalf of Y"). Disclosure is never held against a contribution. Finding out later is.
157+
- **A person is accountable.** The [DCO sign-off](#license-and-sign-off-dco--required-on-every-commit) is a legal certification, and only a person can make it. The human behind the account certifies every commit, answers for it, and is who we talk to if something goes wrong. An agent may carry the conversation; it cannot carry the responsibility.
158+
- **The bar does not move.** Every claim in a PR must be something a reviewer can check: the failing test, the command that was run, the numbers and the machine they came from. "The model says it works" is not evidence, and a confident description does not replace a test that fails without the fix. We read AI-written PRs exactly as carefully as human-written ones — no more suspiciously, and no less.
159+
160+
Two practical notes:
161+
162+
- `Co-authored-by:` trailers naming a tool are fine. Links to private chat or agent sessions are not — they are dead to everyone else and do not belong in permanent history; we will ask you to remove them.
163+
- High-volume, low-effort submissions — many near-identical PRs, changes nobody ran, replies that do not engage with the review — will be closed, whoever or whatever produced them. One careful PR is worth more than twenty generated ones.
164+
165+
### Who speaks for the project
166+
167+
Only the maintainer account ([@DeusData](https://github.com/DeusData)) speaks for this project. A review, an approval, a "this will be merged" or a "this is a duplicate" from any other account is that person's opinion, however official it sounds — helpful reviews from the community are very welcome, and that is what they are.
168+
169+
**Impersonating a maintainer is not acceptable**, by a person or by an agent: presenting yourself as part of the maintainer team, posting approvals or change requests styled as maintainer decisions, or telling other contributors what the project has decided. We dismiss such reviews, hide the comments, say publicly in the affected threads that they were not ours, and report and block the account. If you are unsure whether a response you received is from the project, check the account name — and ask.
170+
152171
## Security
153172

154173
We take security seriously. All PRs go through:

‎README.md‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
**The fastest and most efficient code intelligence engine for AI coding agents.** Full-indexes an average repository in milliseconds, the Linux kernel (28M LOC, 75K files) in 3 minutes. Answers structural queries in under 1ms. Ships as a native executable with a small verified runtime-asset set for macOS, Linux, and Windows — download, run `install`, done.
1818

19-
High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 162 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, and Perl — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 15 MCP tools. No language runtime, hosted service, or API key. Plug and play across 45 supported automatic/conditional client surfaces.
19+
High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-sitter/) AST analysis across all 162 languages, enhanced with [**Hybrid LSP** semantic type resolution](#hybrid-lsp) for Python, TypeScript / JavaScript / JSX / TSX, PHP, C#, Go, C, C++, Java, Kotlin, Rust, and Perl — producing a persistent knowledge graph of functions, classes, call chains, HTTP routes, and cross-service links. 17 MCP tools. No language runtime, hosted service, or API key. Plug and play across 45 supported automatic/conditional client surfaces.
2020

2121
> **Research** — The design and benchmarks behind this project are described in the preprint [*Codebase-Memory: Tree-Sitter-Based Knowledge Graphs for LLM Code Exploration via MCP*](https://arxiv.org/abs/2603.27277) (arXiv:2603.27277). Evaluated across 31 real-world repositories: 83% answer quality, 10× fewer tokens, 2.1× fewer tool calls vs. file-by-file exploration.
2222
@@ -37,7 +37,7 @@ High-quality parsing through [tree-sitter](https://tree-sitter.github.io/tree-si
3737
- **45 supported automatic/conditional client surfaces** — `install` configures detected clients and safely activates conditional clients only when their documented platform, marker, or explicit existing config path is present. See [Multi-Agent Support](#multi-agent-support) for the complete matrix and manual/UI-only boundaries.
3838
- **Built-in graph visualization** — 3D interactive UI at `localhost:9749`, served from the binary itself.
3939
- **Infrastructure-as-code indexing** — Dockerfiles, Kubernetes manifests, and Kustomize overlays indexed as graph nodes with cross-references. `Resource` nodes for K8s kinds, `Module` nodes for Kustomize overlays with `IMPORTS` edges to referenced resources.
40-
- **15 MCP tools** — search, trace, architecture, impact analysis, targeted index-coverage checks, Cypher queries, dead code detection, cross-service HTTP linking, ADR management, and more.
40+
- **17 MCP tools** — search, trace, architecture, impact analysis, targeted index-coverage checks, Cypher queries, dead code detection, cross-service HTTP linking, ADR management, and more.
4141

4242
## Quick Start
4343

@@ -461,7 +461,7 @@ Add to `~/.claude.json` (user scope) or project `.mcp.json`:
461461
}
462462
```
463463

464-
Restart your agent. Verify with `/mcp` — you should see `codebase-memory-mcp` with 15 tools.
464+
Restart your agent. Verify with `/mcp` — you should see `codebase-memory-mcp` with 17 tools.
465465

466466
</details>
467467

@@ -673,6 +673,7 @@ JSON arguments can also be piped on stdin, for tools that take arguments. A tool
673673
| `list_projects` | List all indexed projects with node/edge counts. |
674674
| `delete_project` | Remove a project and all its graph data. |
675675
| `index_status` | Check indexing status of a project. |
676+
| `check_index_coverage` | Check whether exact paths or a scope are indexed and fresh. A clean result means no recorded gap, not proof of completeness. |
676677

677678
### Querying
678679

@@ -683,7 +684,9 @@ JSON arguments can also be piped on stdin, for tools that take arguments. A tool
683684
| `detect_changes` | Map git diff to affected symbols + blast radius with risk classification. |
684685
| `query_graph` | Execute Cypher-like graph queries (read-only). |
685686
| `get_graph_schema` | Node/edge counts, relationship patterns, property definitions per label. Run this first. |
687+
| `compare_graphs` | Compare two indexed snapshots: node/edge additions and removals between a base and a target. |
686688
| `get_code_snippet` | Read source code for a function by qualified name. |
689+
| `get_file_outline` | Declaration outline of one repository-relative file in source order, with optional label filter and paging. |
687690
| `get_architecture` | Codebase overview: languages, packages, routes, hotspots, clusters, ADR. |
688691
| `search_code` | Grep-like text search within indexed project files. |
689692
| `manage_adr` | CRUD for Architecture Decision Records (`get` reads, `update` replaces the whole document, `set_sections` rewrites only the named sections and leaves every other byte untouched, `sections` lists headings). Query modes do not wait behind a same-project reindex; writes remain serialized. |
@@ -849,7 +852,7 @@ Also supported (not yet benchmarked): Ada, Agda, Apex, Assembly (NASM), Astro, A
849852
src/
850853
main.c Entry point (MCP stdio server + CLI + install/update/config)
851854
daemon/ Per-account session coordination, IPC, lifecycle, shared jobs/watchers
852-
mcp/ MCP server (15 tools, JSON-RPC 2.0, session detection, auto-index)
855+
mcp/ MCP server (17 tools, JSON-RPC 2.0, session detection, auto-index)
853856
cli/ Install/uninstall/update/config (45 client surfaces, hooks, instructions)
854857
store/ SQLite graph storage (nodes, edges, traversal, search, Louvain)
855858
pipeline/ Multi-pass indexing (structure → definitions → calls → HTTP links → config → tests)

‎docs/index.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"featureList": [
5757
"Indexes 158 programming languages via vendored tree-sitter grammars",
5858
"Hybrid LSP semantic type resolution for Python, TypeScript/JavaScript, PHP, C#, Go, C/C++, Java, Kotlin, and Rust",
59-
"15 MCP tools for structural search, call-path tracing, targeted coverage checks, and Cypher graph queries",
59+
"17 MCP tools for structural search, call-path tracing, targeted coverage checks, and Cypher graph queries",
6060
"Semantic vector code search via bundled nomic-embed-code embeddings (no API key, fully local)",
6161
"Semantic graph edges (SEMANTICALLY_RELATED) and near-clone detection (SIMILAR_TO, MinHash + LSH)",
6262
"Cross-service linking for HTTP, gRPC, GraphQL, tRPC, and pub/sub channels with confidence scoring",
@@ -739,8 +739,8 @@ <h3>3D graph visualization</h3>
739739
<p>The optional UI variant adds one verified, content-addressed frontend pack and serves an interactive 3D graph at <code>localhost:9749</code> to explore nodes, edges, and clusters visually.</p>
740740
</div>
741741
<div class="feature">
742-
<h3>15 MCP tools</h3>
743-
<p><code>search_graph</code>, <code>trace_path</code>, <code>detect_changes</code>, <code>query_graph</code> (Cypher), <code>get_architecture</code>, <code>get_code_snippet</code>, <code>check_index_coverage</code>, <code>manage_adr</code>, and 7 more.</p>
742+
<h3>17 MCP tools</h3>
743+
<p><code>search_graph</code>, <code>trace_path</code>, <code>detect_changes</code>, <code>query_graph</code> (Cypher), <code>get_architecture</code>, <code>get_code_snippet</code>, <code>check_index_coverage</code>, <code>manage_adr</code>, and 9 more.</p>
744744
</div>
745745
<div class="feature">
746746
<h3>Cypher graph queries</h3>

‎internal/cbm/extract_calls.c‎

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,61 @@ static const char *extract_binary_concat_suffix(CBMExtractCtx *ctx, TSNode node)
22802280
}
22812281

22822282
// Try to extract URL/topic from a positional argument (string or constant).
2283+
/* Swift names its call arguments, so each one is a value_argument that may lead
2284+
* with a value_argument_label — the `from:` in `data(from: url)`. Return the
2285+
* value itself, and leave any other node exactly as it came in. */
2286+
static TSNode swift_argument_value(TSNode arg) {
2287+
if (strcmp(ts_node_type(arg), "value_argument") != 0 || ts_node_named_child_count(arg) == 0) {
2288+
return arg;
2289+
}
2290+
TSNode val = ts_node_named_child(arg, 0);
2291+
if (strcmp(ts_node_type(val), "value_argument_label") == 0 &&
2292+
ts_node_named_child_count(arg) > 1) {
2293+
val = ts_node_named_child(arg, 1);
2294+
}
2295+
return val;
2296+
}
2297+
2298+
/* Swift has no URL literal, so almost no real code passes a bare string to a
2299+
* request. It writes `URL(string: "https://…")!` instead, and the literal then
2300+
* sits two levels down: past the trailing `!`, which the grammar models as a
2301+
* postfix_expression, and inside the constructor's own argument list.
2302+
*
2303+
* Unwrap both so that literal is as reachable as a bare one. Only the three
2304+
* Foundation types that take a URL string are unwrapped — any other call keeps
2305+
* its own meaning, and a non-literal argument such as `URL(string: base + path)`
2306+
* falls through to the ordinary handling unchanged. */
2307+
static TSNode swift_unwrap_url_constructor(CBMExtractCtx *ctx, TSNode arg) {
2308+
/* Step past a trailing "!" or "?". */
2309+
if (strcmp(ts_node_type(arg), "postfix_expression") == 0) {
2310+
TSNode target = ts_node_child_by_field_name(arg, TS_FIELD("target"));
2311+
if (!ts_node_is_null(target)) {
2312+
arg = target;
2313+
}
2314+
}
2315+
if (strcmp(ts_node_type(arg), "call_expression") != 0) {
2316+
return arg;
2317+
}
2318+
TSNode callee = ts_node_named_child(arg, 0);
2319+
if (ts_node_is_null(callee) || strcmp(ts_node_type(callee), "simple_identifier") != 0) {
2320+
return arg;
2321+
}
2322+
const char *name = cbm_node_text(ctx->arena, callee, ctx->source);
2323+
if (!name || (strcmp(name, "URL") != 0 && strcmp(name, "URLComponents") != 0 &&
2324+
strcmp(name, "URLRequest") != 0)) {
2325+
return arg;
2326+
}
2327+
TSNode suffix = cbm_find_child_by_kind(arg, "call_suffix");
2328+
if (ts_node_is_null(suffix)) {
2329+
return arg;
2330+
}
2331+
TSNode inner = cbm_find_child_by_kind(suffix, "value_arguments");
2332+
if (ts_node_is_null(inner) || ts_node_named_child_count(inner) == 0) {
2333+
return arg;
2334+
}
2335+
return swift_argument_value(ts_node_named_child(inner, 0));
2336+
}
2337+
22832338
static const char *extract_positional_url(CBMExtractCtx *ctx, TSNode arg, const char *ak) {
22842339
/* JS/TS template literals: `/things/${id}` normalizes to "/things/{}" so the
22852340
* client URL joins the server route's canonical placeholder (issue #1006). */
@@ -2323,15 +2378,12 @@ static const char *extract_url_or_topic_arg(CBMExtractCtx *ctx, TSNode args) {
23232378
}
23242379
/* Swift wraps each argument in a value_argument that may lead with its
23252380
* label, so `data(from: url)` would otherwise yield the label `from`
2326-
* rather than the value. Step past a leading value_argument_label. */
2327-
if (strcmp(ts_node_type(arg), "value_argument") == 0 &&
2328-
ts_node_named_child_count(arg) > 0) {
2329-
TSNode val = ts_node_named_child(arg, 0);
2330-
if (strcmp(ts_node_type(val), "value_argument_label") == 0 &&
2331-
ts_node_named_child_count(arg) > 1) {
2332-
val = ts_node_named_child(arg, 1);
2333-
}
2334-
arg = val;
2381+
* rather than the value. */
2382+
arg = swift_argument_value(arg);
2383+
/* A Swift URL is usually built rather than written bare, and the
2384+
* literal then sits inside that constructor. */
2385+
if (ctx->language == CBM_LANG_SWIFT) {
2386+
arg = swift_unwrap_url_constructor(ctx, arg);
23352387
}
23362388
const char *ak = ts_node_type(arg);
23372389

0 commit comments

Comments
 (0)