Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

Merge origin/main into feat/java-language-support

Daniel6a34aff9ca3d
diff --cc README.md
index c5f72811,0add266b..bc6b43ca
--- a/README.md
+++ b/README.md
@@@ -184,6 -185,32 +185,32 @@@ Alongside the markdown graph, `graft bu
---
+ ## Supported languages
+
+ Graft parses with tree-sitter at two levels of fidelity, plus an optional
+ compiler-grade layer — all `$0` and deterministic (no model, no key):
+
+ - **Full-fidelity** — hand-written extractors with scope-aware, cross-file call
+ and import resolution:
- **TypeScript / JavaScript** (incl. JSX & TSX), **Python**, **Go**.
++ **TypeScript / JavaScript** (incl. JSX & TSX), **Python**, **Go**, **Java**.
+
+ - **Broad** — symbols (functions, classes, methods, types, …) plus name-resolved
+ call edges via a generic tree-sitter extractor, one grammar per language:
- **Rust, Java, C, C++, C#, Ruby, PHP, Kotlin, Scala, Swift, Elixir, Solidity,
++ **Rust, C, C++, C#, Ruby, PHP, Kotlin, Scala, Swift, Elixir, Solidity,
+ OCaml, Zig, Dart**.
+
+ - **Compiler-grade edges (opt-in)** — `graft build --lsp` adds precise
+ `lsp_resolved` call edges (member calls the static pass can't type) when a
+ language server is on your `PATH`: **rust-analyzer** (Rust), **clangd** (C/C++),
+ **gopls** (Go), **pyright** (Python), **typescript-language-server** (TS/JS).
+ It's best-effort — with no server installed the graph is unchanged.
+
+ Twenty languages in total. A file whose language isn't listed is skipped, not
+ indexed. Adding a broad-tier language is a small contribution — see
+ [CREDITS.md](CREDITS.md) for the folks who added the current set.
+
+ ---
+
## What's in a node
A node is a single markdown file. Most code maps stop at an address: this thing lives in that file, on that line. That tells an agent where to look, not what it will find, so it still has to open the source and read. A Graft node holds the meaning inline, so the agent learns what it needs up front and opens the file only when it wants more.
diff --cc package-lock.json
index 5f9d55b0,aa85630f..18e7de23
--- a/package-lock.json
+++ b/package-lock.json
@@@ -17,9 -17,12 +17,13 @@@
"openai": "^6.45.0",
"tree-sitter": "^0.21.1",
"tree-sitter-go": "^0.23.4",
+ "tree-sitter-java": "^0.23.5",
"tree-sitter-python": "^0.21.0",
- "tree-sitter-typescript": "^0.23.2"
+ "tree-sitter-typescript": "^0.23.2",
+ "tree-sitter-wasms": "^0.1.13",
+ "vscode-jsonrpc": "^8.2.1",
+ "vscode-languageserver-protocol": "^3.18.2",
+ "web-tree-sitter": "^0.25.10"
},
"bin": {
"graft": "dist/cli.js"
diff --cc package.json
index 02565a52,e569ff79..762e07c8
--- a/package.json
+++ b/package.json
@@@ -62,9 -62,12 +62,13 @@@
"openai": "^6.45.0",
"tree-sitter": "^0.21.1",
"tree-sitter-go": "^0.23.4",
+ "tree-sitter-java": "^0.23.5",
"tree-sitter-python": "^0.21.0",
- "tree-sitter-typescript": "^0.23.2"
+ "tree-sitter-typescript": "^0.23.2",
+ "tree-sitter-wasms": "^0.1.13",
+ "vscode-jsonrpc": "^8.2.1",
+ "vscode-languageserver-protocol": "^3.18.2",
+ "web-tree-sitter": "^0.25.10"
},
"devDependencies": {
"@types/d3-force": "^3.0.10",
diff --cc src/graph/resolve.ts
index 4002ddb2,32048071..7aa24f62
--- a/src/graph/resolve.ts
+++ b/src/graph/resolve.ts
@@@ -131,17 -117,20 +131,29 @@@ export function resolveEdges
if (hit === "ambiguous") continue; // drop — never guess past an ambiguous owner
if (hit) add(e.source, hit.id, "calls", hit.confidence);
// No owner-qualified match means the call is unresolved. A unique bare
- // method name is not evidence that this receiver has that method.
+ // method name is not evidence that this receiver has that method — a
+ // name-fallback here was measured to HALVE call-edge precision (73%→37%
+ // vs a compiler-grade oracle) for a 3x count inflation, i.e. noise. See #35.
continue;
}
- // Java emits only one kind of non-member call: `new Foo()`, whose target is a
- // TYPE, not a function (Java has no free functions — an implicit-`this` call is
- // spelled as a member call in extract.ts). Resolving it against the function
- // index would drop every constructor edge.
- const kinds: Kind[] = e.file.endsWith(".java")
- ? ["class", "struct", "enum", "interface"]
- : ["function"];
- const hit = resolveName(e.name!, e.file, kinds, perFileName, globalName);
- // Depth-tier bare calls are function calls (method calls arrive as viaMember
- // with a receiver type). The generic breadth tier can't type receivers, so its
- // tags.scm @reference.call/@reference.send capture ALL calls as bare names —
- // in method-heavy languages (Java, Ruby, C#) those target methods. Widen the
- // candidate kinds to methods ONLY for generic-origin sources, so depth-tier
- // precision is untouched (an ambiguous function-vs-method name still drops).
++ // Three cases, because "a bare call" means something different per tier:
++ //
++ // - generic (breadth tier): tags.scm captures ALL calls as bare names, since it
++ // cannot type a receiver. In method-heavy languages those target methods, so
++ // widen to methods — ONLY here, leaving depth-tier precision untouched (an
++ // ambiguous function-vs-method name still drops).
++ // - Java (depth tier): an implicit-`this` call is spelled as a member call in
++ // extract.ts, so the only bare call reaching here is `new Foo()`, whose target
++ // is a TYPE. Against the function index every constructor edge would drop.
++ // - everything else: functions, exactly as before.
+ const srcOrigin = byId.get(e.source)?.origin;
- const callKinds: Kind[] = srcOrigin === "generic" ? ["function", "method"] : ["function"];
++ const callKinds: Kind[] =
++ srcOrigin === "generic"
++ ? ["function", "method"]
++ : e.file.endsWith(".java")
++ ? ["class", "struct", "enum", "interface"]
++ : ["function"];
+ const hit = resolveName(e.name!, e.file, callKinds, perFileName, globalName);
if (hit) add(e.source, hit.id, "calls", hit.confidence); // drop unresolved calls (too noisy)
}
}