Repository navigation
GDScript support, plus two fixes: Windows blast radius and sticky --only-dir - #299
wesleytakatsu wants to merge 4 commits into
Conversation
Godot projects are a large, unserved corpus: a mid-size game is a four-figure count of .gd files, and today every one of them is skipped, so graft indexes the C#/C++/Go edges of a Godot repo and none of the game logic. tree-sitter-wasm already ships the gdscript grammar, so this costs one registry row plus a tags query. The query is deliberately narrow on variables. A bare `(variable_statement)` also matches every local inside a function body — on a real 1,074-file Godot repo that is ~36k extra nodes (66.5k vs 30.5k total), which buries the symbols an agent is searching for. Scoping const/var to `(source ...)` and `(class_body ...)` keeps the class-level API and drops the locals, at the cost of ~1.4k local-to-local call edges. Signals get a name of their own so `graft callers <signal>` finds every emit and connect site — that is the wiring an agent most needs in a Godot codebase and the thing grep is worst at. Measured on a 1,619-file mixed Godot/Go repo: 545 → 1,619 files indexed, 6,323 → 30,480 nodes, 14,816 → 36,906 edges, 86s cold build.
The whitelist was recorded only in the graph fingerprint, and the fingerprint is rewritten by every build. The Claude Code hooks shell a bare `graft build .` (sync-run.ts) that never sees a CLI flag, so the first post-edit rebuild after a `--only-dir` build silently re-indexed the whole repo. On a repo where the excluded directories are vendored reference code, that is not a cosmetic regression: the scope the user set to keep sample code out of their results is gone after one file edit, with no output saying so. Persist the list beside the graph, in `graft/.cache/only-dirs.json`, and read it back when no flag is passed. Keeping it under `graft/` rather than in `.graft/config.json` preserves the property the existing test guards — a `--only-dir` build still leaves no trace in the repo being indexed. `--all-dirs` clears it, since otherwise a sticky whitelist would have no escape hatch short of deleting the graph. Measured on a 1,619-file repo: `--only-dir` build indexes 1,273 files; a subsequent bare `graft build .` used to return to 1,619 and now stays at 1,273.
The post-edit hook forwards `tool_input.file_path` exactly as the host
wrote it. On Windows that is a backslash path; every `node.path` in the
graph is posix by construction. `nodeIdsInFile` compared them with
`filePath.endsWith("/" + n.path)`, which cannot match across separators,
so the lookup returned an empty set and `formatBlastRadius` returned
null — on every edit, in every language, with no error anywhere.
Symptom on a 1,273-file repo: editing a file with eight dependents cost
the hook's full ~9s and printed nothing. Normalizing the incoming path
turns the same edit into the eight-line radius the hook was written to
produce.
Co-Authored-By: Claude Opus 5 <[email protected]>
GDScript has no import statement — a script reaches another script through
`preload("res://...")` or `load(...)`. Without those the breadth tier gave
.gd files symbol-level call edges and no file-level edges at all, so
anything reading incoming edges on a file (blast radius, `graft callers
<file>`) had nothing to report for an entire language.
`res://` is the Godot project root, which sits at an unknown depth under
the repo root and may appear more than once, so the specifier is matched
as a path suffix over an index of every directory boundary — the same
approach already used for Java, C and PHP. Only a unique hit resolves;
an ambiguous or absent one keeps the raw specifier rather than pointing
the edge at a same-named file in a different project.
@reference.import is handled generically rather than as a GDScript
special case: any breadth-tier grammar can now mark a specifier and get
file-level import edges, and the edge is attributed to the file, not to
whatever definition happens to enclose the call.
Measured on a 1,273-file repo: 3,301 import edges, 3,252 of them resolved
to a file (the 49 left are runtime `load()` of computed paths); total
edges 29,166 to 31,204.
Co-Authored-By: Claude Opus 5 <[email protected]>
🌱 graft blast radius4 areas changed → 6 areas can be affected. 15 dependent symbols, depth 2. flowchart TB
A0(("Graph Freshness Check<br/>6 symbols"))
A1(("Pull Request Review<br/>4 symbols"))
A2(("Engine Graph API<br/>2 symbols"))
A3(("Viewer Build Script<br/>1 symbol"))
A4(("MCP Tool Invocation<br/>1 symbol"))
AX(("1 smaller area<br/>1 symbol"))
classDef reached fill:#D9EDF3,stroke:#3AA7C9,stroke-width:1.5px,color:#0E313C;
class A0,A1,A2,A3,A4 reached;
classDef tail fill:#EEF2F3,stroke:#9AA4A9,stroke-width:1px,color:#3A4247;
class AX tail;
Who knows this code — 3 people across 10 areas
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no All 15 dependent symbols, grouped by areaGraph Freshness Check — 6 symbols in 5 files
Pull Request Review — 4 symbols in 4 files
Engine Graph API — 2 symbols in 1 file
Viewer Build Script — 1 symbol in 1 file
MCP Tool Invocation — 1 symbol in 1 file
Synchronous Execution — 1 symbol in 1 file
Test signal per changed area — 1 ✓ · 2 ✗ · 1 –Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
35 test suites also reference this code44 symbols, kept out of the diagram and the table so they cannot crowd out the areas a reviewer has to look at.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
|
#293 also asks for The Windows blast-radius path match and sticky |
|
Thanks! GDScript itself works well: on a small .gd fixture we got both functions and the |
Four changes, found while wiring graft into a 1,619-file Godot + Go game repo. Two are bug fixes that stand on their own; two add GDScript. Happy to split this into separate PRs if you'd rather review them apart — the files don't overlap.
Every claim below is measured on that repo (1,273 files indexed after scoping, 846 of them
.gd).1.
fix(claude): match the edited file on Windows, so blast radius fires(c4f39b9)The post-edit hook forwards
tool_input.file_pathexactly as the host wrote it. On Windows that is a backslash path, while everynode.pathin the graph is posix by construction.nodeIdsInFilecompared them withfilePath.endsWith("/" + n.path), which cannot match across separators — so the lookup returned an empty set andformatBlastRadiusreturnednull.On every edit, in every language, with no error anywhere. Editing a file with eight dependents cost the hook's full ~9s and printed nothing. Normalizing the incoming path turns that same edit into the eight-line radius the hook was written to produce.
This one is independent of the GDScript work and affects every Windows user today.
2.
fix(build): make --only-dir survive a no-flag rebuild(4408ba9)--only-dir's whitelist was recorded only in the graph fingerprint, and the fingerprint is rewritten by every build.sync-run.tsshells a baregraft build .that never sees a CLI flag, so the first post-edit rebuild after a--only-dirbuild silently re-indexed the whole repo.Where the excluded directories are vendored reference code, that is not cosmetic: on this repo an unscoped index put four of six hits for "player movement" in sample FPS templates and none in the actual game. One file edit undid the scope, with nothing in the output saying so.
The list now persists in
graft/.cache/only-dirs.jsonand is read back when no flag is passed. Keeping it undergraft/rather than in.graft/config.jsonpreserves the propertytest/graph-only-dir.test.tsguards — a--only-dirbuild still leaves no trace in the repo being indexed, and that test passes unchanged.--all-dirsclears it, since a sticky whitelist otherwise has no escape hatch short of deleting the graph.Measured:
--only-dirbuild indexes 1,273 files; a subsequent baregraft build .used to return to 1,619 and now stays at 1,273.3.
feat(graph): add GDScript to the breadth tier(c06d6ad)Godot projects are a large unserved corpus — a mid-size game is a four-figure count of
.gdfiles, and today every one is skipped, so graft indexes the C#/C++/Go edges of a Godot repo and none of the game logic.tree-sitter-wasmalready ships the gdscript grammar, so this is one registry row plus a tags query.The query is deliberately narrow on variables. A bare
(variable_statement)also matches every local inside a function body — on this repo that was ~36k extra nodes (66.5k vs 30.5k total), which buries the symbols an agent is searching for. Scoping const/var to(source ...)and(class_body ...)keeps the class-level API and drops the locals, at the cost of ~1.4k local-to-local call edges.Signals get a name of their own so
graft callers <signal>finds every emit and connect site — that is the wiring an agent most needs in a Godot codebase, and the thing grep is worst at.4.
feat(graph): GDScript preload/load become import edges(d1cb17c)GDScript has no import statement; a script reaches another through
preload("res://...")orload(...). Without those,.gdfiles had symbol-level call edges and no file-level edges at all, so anything reading incoming edges on a file — blast radius,graft callers <file>— had nothing to report for an entire language.res://is the Godot project root, which sits at an unknown depth under the repo root and may appear more than once, so the specifier is matched as a path suffix over an index of every directory boundary — the same approach already used for Java, C and PHP. Only a unique hit resolves; an ambiguous or absent one keeps the raw specifier rather than pointing the edge at a same-named file in a different project.@reference.importis handled generically rather than as a GDScript special case: any breadth-tier grammar can now mark a specifier and get file-level import edges, and the edge is attributed to the file, not to whatever definition encloses the call.Measured: 3,301 import edges, 3,252 resolved to a file (the 49 left are runtime
load()of computed paths); total edges 29,166 → 31,204.Tests
New regression tests in
test/generic-extract.test.ts(GDScript symbols, and preload/load import edges including the dedupe and the dangling-specifier case),test/graph-only-dir.test.ts(whitelist survives a no-flag rebuild;--all-dirsclears it), andtest/claude-format.test.ts(a Windows path resolves to the same nodes).npx tsx --testovertest/graph-*.test.tsplusgeneric-extract,covers,regression-single-repo,supported-extensions,util-state,context-only-dir: 377 pass, 0 fail, 5 skipped.Three tests in
claude-formatand four inclaude-hooks/session-metricsfail on my machine, all in the token/dollar accounting paths. They fail identically on a clean checkout ofmain— I verified withgit stash— so they are not from this branch.Docs
README.md's breadth-tier list gains GDScript (23 → 24 languages).🤖 Generated with Claude Code