trail-code 0.0.0-stage → 0.28.0-semantic.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +567 -2
- package/dist/ai/crux.d.ts +88 -0
- package/dist/ai/crux.d.ts.map +1 -0
- package/dist/ai/crux.js +219 -0
- package/dist/ai/crux.js.map +1 -0
- package/dist/ai/failure.d.ts +60 -0
- package/dist/ai/failure.d.ts.map +1 -0
- package/dist/ai/failure.js +86 -0
- package/dist/ai/failure.js.map +1 -0
- package/dist/ai/llm/anthropic.d.ts +37 -0
- package/dist/ai/llm/anthropic.d.ts.map +1 -0
- package/dist/ai/llm/anthropic.js +144 -0
- package/dist/ai/llm/anthropic.js.map +1 -0
- package/dist/ai/llm/factory.d.ts +28 -0
- package/dist/ai/llm/factory.d.ts.map +1 -0
- package/dist/ai/llm/factory.js +36 -0
- package/dist/ai/llm/factory.js.map +1 -0
- package/dist/ai/llm/litellm.d.ts +34 -0
- package/dist/ai/llm/litellm.d.ts.map +1 -0
- package/dist/ai/llm/litellm.js +45 -0
- package/dist/ai/llm/litellm.js.map +1 -0
- package/dist/ai/llm/openai.d.ts +145 -0
- package/dist/ai/llm/openai.d.ts.map +1 -0
- package/dist/ai/llm/openai.js +629 -0
- package/dist/ai/llm/openai.js.map +1 -0
- package/dist/ai/llm/orcarouter.d.ts +34 -0
- package/dist/ai/llm/orcarouter.d.ts.map +1 -0
- package/dist/ai/llm/orcarouter.js +45 -0
- package/dist/ai/llm/orcarouter.js.map +1 -0
- package/dist/ai/llm/recover-tool.d.ts +21 -0
- package/dist/ai/llm/recover-tool.d.ts.map +1 -0
- package/dist/ai/llm/recover-tool.js +109 -0
- package/dist/ai/llm/recover-tool.js.map +1 -0
- package/dist/ai/llm/types.d.ts +122 -0
- package/dist/ai/llm/types.d.ts.map +1 -0
- package/dist/ai/llm/types.js +33 -0
- package/dist/ai/llm/types.js.map +1 -0
- package/dist/ai/providers.d.ts +59 -0
- package/dist/ai/providers.d.ts.map +1 -0
- package/dist/ai/providers.js +54 -0
- package/dist/ai/providers.js.map +1 -0
- package/dist/ai/summarize.d.ts +25 -0
- package/dist/ai/summarize.d.ts.map +1 -0
- package/dist/ai/summarize.js +34 -0
- package/dist/ai/summarize.js.map +1 -0
- package/dist/ai/synthesize.d.ts +40 -0
- package/dist/ai/synthesize.d.ts.map +1 -0
- package/dist/ai/synthesize.js +230 -0
- package/dist/ai/synthesize.js.map +1 -0
- package/dist/ask/ask.d.ts +199 -0
- package/dist/ask/ask.d.ts.map +1 -0
- package/dist/ask/ask.js +1291 -0
- package/dist/ask/ask.js.map +1 -0
- package/dist/ask/file-rank.d.ts +72 -0
- package/dist/ask/file-rank.d.ts.map +1 -0
- package/dist/ask/file-rank.js +160 -0
- package/dist/ask/file-rank.js.map +1 -0
- package/dist/ask/file-selection.d.ts +22 -0
- package/dist/ask/file-selection.d.ts.map +1 -0
- package/dist/ask/file-selection.js +66 -0
- package/dist/ask/file-selection.js.map +1 -0
- package/dist/ask/fuse.d.ts +195 -0
- package/dist/ask/fuse.d.ts.map +1 -0
- package/dist/ask/fuse.js +344 -0
- package/dist/ask/fuse.js.map +1 -0
- package/dist/ask/graphrank.d.ts +61 -0
- package/dist/ask/graphrank.d.ts.map +1 -0
- package/dist/ask/graphrank.js +130 -0
- package/dist/ask/graphrank.js.map +1 -0
- package/dist/ask/index-file.d.ts +44 -0
- package/dist/ask/index-file.d.ts.map +1 -0
- package/dist/ask/index-file.js +128 -0
- package/dist/ask/index-file.js.map +1 -0
- package/dist/ask/semantic.d.ts +42 -0
- package/dist/ask/semantic.d.ts.map +1 -0
- package/dist/ask/semantic.js +293 -0
- package/dist/ask/semantic.js.map +1 -0
- package/dist/bin/graft.d.ts +3 -0
- package/dist/bin/graft.d.ts.map +1 -0
- package/dist/bin/graft.js +14 -0
- package/dist/bin/graft.js.map +1 -0
- package/dist/bin/trail.d.ts +3 -0
- package/dist/bin/trail.d.ts.map +1 -0
- package/dist/bin/trail.js +13 -0
- package/dist/bin/trail.js.map +1 -0
- package/dist/blast/blast-cli.d.ts +35 -0
- package/dist/blast/blast-cli.d.ts.map +1 -0
- package/dist/blast/blast-cli.js +155 -0
- package/dist/blast/blast-cli.js.map +1 -0
- package/dist/blast/blast.d.ts +128 -0
- package/dist/blast/blast.d.ts.map +1 -0
- package/dist/blast/blast.js +383 -0
- package/dist/blast/blast.js.map +1 -0
- package/dist/blast/diff.d.ts +53 -0
- package/dist/blast/diff.d.ts.map +1 -0
- package/dist/blast/diff.js +193 -0
- package/dist/blast/diff.js.map +1 -0
- package/dist/blast/evidence.d.ts +51 -0
- package/dist/blast/evidence.d.ts.map +1 -0
- package/dist/blast/evidence.js +162 -0
- package/dist/blast/evidence.js.map +1 -0
- package/dist/blast/modules.d.ts +33 -0
- package/dist/blast/modules.d.ts.map +1 -0
- package/dist/blast/modules.js +83 -0
- package/dist/blast/modules.js.map +1 -0
- package/dist/blast/name.d.ts +74 -0
- package/dist/blast/name.d.ts.map +1 -0
- package/dist/blast/name.js +269 -0
- package/dist/blast/name.js.map +1 -0
- package/dist/blast/owners.d.ts +85 -0
- package/dist/blast/owners.d.ts.map +1 -0
- package/dist/blast/owners.js +272 -0
- package/dist/blast/owners.js.map +1 -0
- package/dist/blast/render.d.ts +46 -0
- package/dist/blast/render.d.ts.map +1 -0
- package/dist/blast/render.js +422 -0
- package/dist/blast/render.js.map +1 -0
- package/dist/blast/viz.d.ts +37 -0
- package/dist/blast/viz.d.ts.map +1 -0
- package/dist/blast/viz.js +180 -0
- package/dist/blast/viz.js.map +1 -0
- package/dist/brand.d.ts +111 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +282 -0
- package/dist/brand.js.map +1 -0
- package/dist/claude/build-progress.d.ts +30 -0
- package/dist/claude/build-progress.d.ts.map +1 -0
- package/dist/claude/build-progress.js +81 -0
- package/dist/claude/build-progress.js.map +1 -0
- package/dist/claude/hermes-skill-template.d.ts +16 -0
- package/dist/claude/hermes-skill-template.d.ts.map +1 -0
- package/dist/claude/hermes-skill-template.js +154 -0
- package/dist/claude/hermes-skill-template.js.map +1 -0
- package/dist/claude/init.d.ts +65 -0
- package/dist/claude/init.d.ts.map +1 -0
- package/dist/claude/init.js +258 -0
- package/dist/claude/init.js.map +1 -0
- package/dist/claude/paths.d.ts +9 -0
- package/dist/claude/paths.d.ts.map +1 -0
- package/dist/claude/paths.js +22 -0
- package/dist/claude/paths.js.map +1 -0
- package/dist/claude/session-metrics.d.ts +73 -0
- package/dist/claude/session-metrics.d.ts.map +1 -0
- package/dist/claude/session-metrics.js +209 -0
- package/dist/claude/session-metrics.js.map +1 -0
- package/dist/claude/settings-merge.d.ts +76 -0
- package/dist/claude/settings-merge.d.ts.map +1 -0
- package/dist/claude/settings-merge.js +283 -0
- package/dist/claude/settings-merge.js.map +1 -0
- package/dist/claude/skill-template.d.ts +13 -0
- package/dist/claude/skill-template.d.ts.map +1 -0
- package/dist/claude/skill-template.js +290 -0
- package/dist/claude/skill-template.js.map +1 -0
- package/dist/claude/state.d.ts +85 -0
- package/dist/claude/state.d.ts.map +1 -0
- package/dist/claude/state.js +88 -0
- package/dist/claude/state.js.map +1 -0
- package/dist/claude/stats.d.ts +5 -0
- package/dist/claude/stats.d.ts.map +1 -0
- package/dist/claude/stats.js +24 -0
- package/dist/claude/stats.js.map +1 -0
- package/dist/cli-epilogue.d.ts +12 -0
- package/dist/cli-epilogue.d.ts.map +1 -0
- package/dist/cli-epilogue.js +72 -0
- package/dist/cli-epilogue.js.map +1 -0
- package/dist/cli-meta.d.ts +82 -0
- package/dist/cli-meta.d.ts.map +1 -0
- package/dist/cli-meta.js +238 -0
- package/dist/cli-meta.js.map +1 -0
- package/dist/cli-picker.d.ts +139 -0
- package/dist/cli-picker.d.ts.map +1 -0
- package/dist/cli-picker.js +439 -0
- package/dist/cli-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1638 -0
- package/dist/cli.js.map +1 -0
- package/dist/context/batches.d.ts +29 -0
- package/dist/context/batches.d.ts.map +1 -0
- package/dist/context/batches.js +130 -0
- package/dist/context/batches.js.map +1 -0
- package/dist/context/build.d.ts +57 -0
- package/dist/context/build.d.ts.map +1 -0
- package/dist/context/build.js +396 -0
- package/dist/context/build.js.map +1 -0
- package/dist/context/check.d.ts +42 -0
- package/dist/context/check.d.ts.map +1 -0
- package/dist/context/check.js +162 -0
- package/dist/context/check.js.map +1 -0
- package/dist/context/map-dir.d.ts +13 -0
- package/dist/context/map-dir.d.ts.map +1 -0
- package/dist/context/map-dir.js +81 -0
- package/dist/context/map-dir.js.map +1 -0
- package/dist/context/node-file.d.ts +109 -0
- package/dist/context/node-file.d.ts.map +1 -0
- package/dist/context/node-file.js +390 -0
- package/dist/context/node-file.js.map +1 -0
- package/dist/context/price.d.ts +49 -0
- package/dist/context/price.d.ts.map +1 -0
- package/dist/context/price.js +83 -0
- package/dist/context/price.js.map +1 -0
- package/dist/context/savings.d.ts +67 -0
- package/dist/context/savings.d.ts.map +1 -0
- package/dist/context/savings.js +125 -0
- package/dist/context/savings.js.map +1 -0
- package/dist/engine.d.ts +85 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +122 -0
- package/dist/engine.js.map +1 -0
- package/dist/graph/bindings.d.ts +64 -0
- package/dist/graph/bindings.d.ts.map +1 -0
- package/dist/graph/bindings.js +713 -0
- package/dist/graph/bindings.js.map +1 -0
- package/dist/graph/build-run.d.ts +25 -0
- package/dist/graph/build-run.d.ts.map +1 -0
- package/dist/graph/build-run.js +121 -0
- package/dist/graph/build-run.js.map +1 -0
- package/dist/graph/build.d.ts +88 -0
- package/dist/graph/build.d.ts.map +1 -0
- package/dist/graph/build.js +386 -0
- package/dist/graph/build.js.map +1 -0
- package/dist/graph/cards.d.ts +46 -0
- package/dist/graph/cards.d.ts.map +1 -0
- package/dist/graph/cards.js +280 -0
- package/dist/graph/cards.js.map +1 -0
- package/dist/graph/check.d.ts +25 -0
- package/dist/graph/check.d.ts.map +1 -0
- package/dist/graph/check.js +192 -0
- package/dist/graph/check.js.map +1 -0
- package/dist/graph/container.d.ts +63 -0
- package/dist/graph/container.d.ts.map +1 -0
- package/dist/graph/container.js +191 -0
- package/dist/graph/container.js.map +1 -0
- package/dist/graph/depth-parser.d.ts +61 -0
- package/dist/graph/depth-parser.d.ts.map +1 -0
- package/dist/graph/depth-parser.js +153 -0
- package/dist/graph/depth-parser.js.map +1 -0
- package/dist/graph/enrich.d.ts +62 -0
- package/dist/graph/enrich.d.ts.map +1 -0
- package/dist/graph/enrich.js +258 -0
- package/dist/graph/enrich.js.map +1 -0
- package/dist/graph/extract-cache.d.ts +101 -0
- package/dist/graph/extract-cache.d.ts.map +1 -0
- package/dist/graph/extract-cache.js +199 -0
- package/dist/graph/extract-cache.js.map +1 -0
- package/dist/graph/extract.d.ts +85 -0
- package/dist/graph/extract.d.ts.map +1 -0
- package/dist/graph/extract.js +2377 -0
- package/dist/graph/extract.js.map +1 -0
- package/dist/graph/fingerprint.d.ts +76 -0
- package/dist/graph/fingerprint.d.ts.map +1 -0
- package/dist/graph/fingerprint.js +160 -0
- package/dist/graph/fingerprint.js.map +1 -0
- package/dist/graph/generic.d.ts +74 -0
- package/dist/graph/generic.d.ts.map +1 -0
- package/dist/graph/generic.js +773 -0
- package/dist/graph/generic.js.map +1 -0
- package/dist/graph/invariants.d.ts +33 -0
- package/dist/graph/invariants.d.ts.map +1 -0
- package/dist/graph/invariants.js +52 -0
- package/dist/graph/invariants.js.map +1 -0
- package/dist/graph/load.d.ts +29 -0
- package/dist/graph/load.d.ts.map +1 -0
- package/dist/graph/load.js +97 -0
- package/dist/graph/load.js.map +1 -0
- package/dist/graph/lsp/client.d.ts +61 -0
- package/dist/graph/lsp/client.d.ts.map +1 -0
- package/dist/graph/lsp/client.js +217 -0
- package/dist/graph/lsp/client.js.map +1 -0
- package/dist/graph/lsp/enrich.d.ts +11 -0
- package/dist/graph/lsp/enrich.d.ts.map +1 -0
- package/dist/graph/lsp/enrich.js +163 -0
- package/dist/graph/lsp/enrich.js.map +1 -0
- package/dist/graph/lsp/registry.d.ts +22 -0
- package/dist/graph/lsp/registry.d.ts.map +1 -0
- package/dist/graph/lsp/registry.js +71 -0
- package/dist/graph/lsp/registry.js.map +1 -0
- package/dist/graph/map.d.ts +107 -0
- package/dist/graph/map.d.ts.map +1 -0
- package/dist/graph/map.js +239 -0
- package/dist/graph/map.js.map +1 -0
- package/dist/graph/markdown.d.ts +22 -0
- package/dist/graph/markdown.d.ts.map +1 -0
- package/dist/graph/markdown.js +143 -0
- package/dist/graph/markdown.js.map +1 -0
- package/dist/graph/native.d.ts +46 -0
- package/dist/graph/native.d.ts.map +1 -0
- package/dist/graph/native.js +169 -0
- package/dist/graph/native.js.map +1 -0
- package/dist/graph/queries/c.scm +13 -0
- package/dist/graph/queries/c_sharp.scm +19 -0
- package/dist/graph/queries/clojure.scm +58 -0
- package/dist/graph/queries/cpp.scm +23 -0
- package/dist/graph/queries/dart.scm +42 -0
- package/dist/graph/queries/elixir.scm +54 -0
- package/dist/graph/queries/gleam.scm +51 -0
- package/dist/graph/queries/java.scm +20 -0
- package/dist/graph/queries/kotlin.scm +43 -0
- package/dist/graph/queries/lua.scm +36 -0
- package/dist/graph/queries/nix.scm +32 -0
- package/dist/graph/queries/php.scm +40 -0
- package/dist/graph/queries/ruby.scm +65 -0
- package/dist/graph/queries/rust.scm +41 -0
- package/dist/graph/queries/scala.scm +66 -0
- package/dist/graph/queries/solidity.scm +43 -0
- package/dist/graph/queries/swift.scm +51 -0
- package/dist/graph/refresh.d.ts +106 -0
- package/dist/graph/refresh.d.ts.map +1 -0
- package/dist/graph/refresh.js +430 -0
- package/dist/graph/refresh.js.map +1 -0
- package/dist/graph/relations.d.ts +14 -0
- package/dist/graph/relations.d.ts.map +1 -0
- package/dist/graph/relations.js +8 -0
- package/dist/graph/relations.js.map +1 -0
- package/dist/graph/resolve.d.ts +17 -0
- package/dist/graph/resolve.d.ts.map +1 -0
- package/dist/graph/resolve.js +716 -0
- package/dist/graph/resolve.js.map +1 -0
- package/dist/graph/root.d.ts +11 -0
- package/dist/graph/root.d.ts.map +1 -0
- package/dist/graph/root.js +40 -0
- package/dist/graph/root.js.map +1 -0
- package/dist/graph/scopes.d.ts +40 -0
- package/dist/graph/scopes.d.ts.map +1 -0
- package/dist/graph/scopes.js +383 -0
- package/dist/graph/scopes.js.map +1 -0
- package/dist/graph/seed.d.ts +38 -0
- package/dist/graph/seed.d.ts.map +1 -0
- package/dist/graph/seed.js +229 -0
- package/dist/graph/seed.js.map +1 -0
- package/dist/graph/source-files.d.ts +46 -0
- package/dist/graph/source-files.d.ts.map +1 -0
- package/dist/graph/source-files.js +118 -0
- package/dist/graph/source-files.js.map +1 -0
- package/dist/graph/traverse-cli.d.ts +55 -0
- package/dist/graph/traverse-cli.d.ts.map +1 -0
- package/dist/graph/traverse-cli.js +189 -0
- package/dist/graph/traverse-cli.js.map +1 -0
- package/dist/graph/traverse.d.ts +112 -0
- package/dist/graph/traverse.d.ts.map +1 -0
- package/dist/graph/traverse.js +192 -0
- package/dist/graph/traverse.js.map +1 -0
- package/dist/graph/types.d.ts +78 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +14 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/graph/wasm-runtime.d.ts +19 -0
- package/dist/graph/wasm-runtime.d.ts.map +1 -0
- package/dist/graph/wasm-runtime.js +38 -0
- package/dist/graph/wasm-runtime.js.map +1 -0
- package/dist/graph/workspace-cli.d.ts +56 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -0
- package/dist/graph/workspace-cli.js +111 -0
- package/dist/graph/workspace-cli.js.map +1 -0
- package/dist/graph/workspace.d.ts +172 -0
- package/dist/graph/workspace.d.ts.map +1 -0
- package/dist/graph/workspace.js +714 -0
- package/dist/graph/workspace.js.map +1 -0
- package/dist/graph/write.d.ts +13 -0
- package/dist/graph/write.d.ts.map +1 -0
- package/dist/graph/write.js +86 -0
- package/dist/graph/write.js.map +1 -0
- package/dist/hosts/antigravity.d.ts +14 -0
- package/dist/hosts/antigravity.d.ts.map +1 -0
- package/dist/hosts/antigravity.js +59 -0
- package/dist/hosts/antigravity.js.map +1 -0
- package/dist/hosts/auto.d.ts +37 -0
- package/dist/hosts/auto.d.ts.map +1 -0
- package/dist/hosts/auto.js +141 -0
- package/dist/hosts/auto.js.map +1 -0
- package/dist/hosts/claude-global.d.ts +72 -0
- package/dist/hosts/claude-global.d.ts.map +1 -0
- package/dist/hosts/claude-global.js +230 -0
- package/dist/hosts/claude-global.js.map +1 -0
- package/dist/hosts/config-write.d.ts +36 -0
- package/dist/hosts/config-write.d.ts.map +1 -0
- package/dist/hosts/config-write.js +64 -0
- package/dist/hosts/config-write.js.map +1 -0
- package/dist/hosts/init.d.ts +28 -0
- package/dist/hosts/init.d.ts.map +1 -0
- package/dist/hosts/init.js +89 -0
- package/dist/hosts/init.js.map +1 -0
- package/dist/hosts/instructions.d.ts +14 -0
- package/dist/hosts/instructions.d.ts.map +1 -0
- package/dist/hosts/instructions.js +95 -0
- package/dist/hosts/instructions.js.map +1 -0
- package/dist/hosts/mcp-config.d.ts +78 -0
- package/dist/hosts/mcp-config.d.ts.map +1 -0
- package/dist/hosts/mcp-config.js +251 -0
- package/dist/hosts/mcp-config.js.map +1 -0
- package/dist/hosts/plan.d.ts +32 -0
- package/dist/hosts/plan.d.ts.map +1 -0
- package/dist/hosts/plan.js +73 -0
- package/dist/hosts/plan.js.map +1 -0
- package/dist/hosts/registry.d.ts +41 -0
- package/dist/hosts/registry.d.ts.map +1 -0
- package/dist/hosts/registry.js +164 -0
- package/dist/hosts/registry.js.map +1 -0
- package/dist/hosts/retract.d.ts +47 -0
- package/dist/hosts/retract.d.ts.map +1 -0
- package/dist/hosts/retract.js +520 -0
- package/dist/hosts/retract.js.map +1 -0
- package/dist/hosts/sections.d.ts +47 -0
- package/dist/hosts/sections.d.ts.map +1 -0
- package/dist/hosts/sections.js +127 -0
- package/dist/hosts/sections.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/fs.d.ts +79 -0
- package/dist/ingest/fs.d.ts.map +1 -0
- package/dist/ingest/fs.js +306 -0
- package/dist/ingest/fs.js.map +1 -0
- package/dist/init-guard.d.ts +16 -0
- package/dist/init-guard.d.ts.map +1 -0
- package/dist/init-guard.js +27 -0
- package/dist/init-guard.js.map +1 -0
- package/dist/mcp/instructions.d.ts +5 -0
- package/dist/mcp/instructions.d.ts.map +1 -0
- package/dist/mcp/instructions.js +64 -0
- package/dist/mcp/instructions.js.map +1 -0
- package/dist/mcp/kept-listing.d.ts +27 -0
- package/dist/mcp/kept-listing.d.ts.map +1 -0
- package/dist/mcp/kept-listing.js +63 -0
- package/dist/mcp/kept-listing.js.map +1 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +147 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-names.d.ts +27 -0
- package/dist/mcp/tool-names.d.ts.map +1 -0
- package/dist/mcp/tool-names.js +47 -0
- package/dist/mcp/tool-names.js.map +1 -0
- package/dist/mcp/tools.d.ts +22 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +440 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/node-version.d.ts +15 -0
- package/dist/node-version.d.ts.map +1 -0
- package/dist/node-version.js +23 -0
- package/dist/node-version.js.map +1 -0
- package/dist/search/grep-cli.d.ts +35 -0
- package/dist/search/grep-cli.d.ts.map +1 -0
- package/dist/search/grep-cli.js +115 -0
- package/dist/search/grep-cli.js.map +1 -0
- package/dist/search/grep.d.ts +60 -0
- package/dist/search/grep.d.ts.map +1 -0
- package/dist/search/grep.js +143 -0
- package/dist/search/grep.js.map +1 -0
- package/dist/search/ignored-code.d.ts +9 -0
- package/dist/search/ignored-code.d.ts.map +1 -0
- package/dist/search/ignored-code.js +73 -0
- package/dist/search/ignored-code.js.map +1 -0
- package/dist/search/user-regexp.d.ts +26 -0
- package/dist/search/user-regexp.d.ts.map +1 -0
- package/dist/search/user-regexp.js +150 -0
- package/dist/search/user-regexp.js.map +1 -0
- package/dist/telemetry/contract.d.ts +117 -0
- package/dist/telemetry/contract.d.ts.map +1 -0
- package/dist/telemetry/contract.js +341 -0
- package/dist/telemetry/contract.js.map +1 -0
- package/dist/telemetry/flush.d.ts +21 -0
- package/dist/telemetry/flush.d.ts.map +1 -0
- package/dist/telemetry/flush.js +85 -0
- package/dist/telemetry/flush.js.map +1 -0
- package/dist/telemetry/gate.d.ts +30 -0
- package/dist/telemetry/gate.d.ts.map +1 -0
- package/dist/telemetry/gate.js +81 -0
- package/dist/telemetry/gate.js.map +1 -0
- package/dist/telemetry/identity.d.ts +40 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/telemetry/identity.js +80 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/index.d.ts +18 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +16 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/key.d.ts +21 -0
- package/dist/telemetry/key.d.ts.map +1 -0
- package/dist/telemetry/key.js +49 -0
- package/dist/telemetry/key.js.map +1 -0
- package/dist/telemetry/notice.d.ts +19 -0
- package/dist/telemetry/notice.d.ts.map +1 -0
- package/dist/telemetry/notice.js +93 -0
- package/dist/telemetry/notice.js.map +1 -0
- package/dist/telemetry/queue.d.ts +35 -0
- package/dist/telemetry/queue.d.ts.map +1 -0
- package/dist/telemetry/queue.js +162 -0
- package/dist/telemetry/queue.js.map +1 -0
- package/dist/telemetry/send.d.ts +19 -0
- package/dist/telemetry/send.d.ts.map +1 -0
- package/dist/telemetry/send.js +84 -0
- package/dist/telemetry/send.js.map +1 -0
- package/dist/telemetry/sessions.d.ts +25 -0
- package/dist/telemetry/sessions.d.ts.map +1 -0
- package/dist/telemetry/sessions.js +104 -0
- package/dist/telemetry/sessions.js.map +1 -0
- package/dist/telemetry/track.d.ts +62 -0
- package/dist/telemetry/track.d.ts.map +1 -0
- package/dist/telemetry/track.js +143 -0
- package/dist/telemetry/track.js.map +1 -0
- package/dist/upkeep-run.d.ts +22 -0
- package/dist/upkeep-run.d.ts.map +1 -0
- package/dist/upkeep-run.js +85 -0
- package/dist/upkeep-run.js.map +1 -0
- package/dist/upkeep.d.ts +127 -0
- package/dist/upkeep.d.ts.map +1 -0
- package/dist/upkeep.js +252 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/util/actions-folder.d.ts +2 -0
- package/dist/util/actions-folder.d.ts.map +1 -0
- package/dist/util/actions-folder.js +9 -0
- package/dist/util/actions-folder.js.map +1 -0
- package/dist/util/browser.d.ts +3 -0
- package/dist/util/browser.d.ts.map +1 -0
- package/dist/util/browser.js +14 -0
- package/dist/util/browser.js.map +1 -0
- package/dist/util/child-process.d.ts +15 -0
- package/dist/util/child-process.d.ts.map +1 -0
- package/dist/util/child-process.js +15 -0
- package/dist/util/child-process.js.map +1 -0
- package/dist/util/front-matter.d.ts +46 -0
- package/dist/util/front-matter.d.ts.map +1 -0
- package/dist/util/front-matter.js +113 -0
- package/dist/util/front-matter.js.map +1 -0
- package/dist/util/id.d.ts +7 -0
- package/dist/util/id.d.ts.map +1 -0
- package/dist/util/id.js +14 -0
- package/dist/util/id.js.map +1 -0
- package/dist/util/paths.d.ts +29 -0
- package/dist/util/paths.d.ts.map +1 -0
- package/dist/util/paths.js +71 -0
- package/dist/util/paths.js.map +1 -0
- package/dist/util/private-file.d.ts +14 -0
- package/dist/util/private-file.d.ts.map +1 -0
- package/dist/util/private-file.js +82 -0
- package/dist/util/private-file.js.map +1 -0
- package/dist/util/source.d.ts +4 -0
- package/dist/util/source.d.ts.map +1 -0
- package/dist/util/source.js +12 -0
- package/dist/util/source.js.map +1 -0
- package/dist/util/spinner.d.ts +15 -0
- package/dist/util/spinner.d.ts.map +1 -0
- package/dist/util/spinner.js +52 -0
- package/dist/util/spinner.js.map +1 -0
- package/dist/util/state.d.ts +120 -0
- package/dist/util/state.d.ts.map +1 -0
- package/dist/util/state.js +264 -0
- package/dist/util/state.js.map +1 -0
- package/dist/vendor/grammars/tree-sitter-go.LICENSE +21 -0
- package/dist/vendor/grammars/tree-sitter-go.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-java.LICENSE +21 -0
- package/dist/vendor/grammars/tree-sitter-java.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-kotlin.LICENSE +9 -0
- package/dist/vendor/grammars/tree-sitter-kotlin.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-php.LICENSE +22 -0
- package/dist/vendor/grammars/tree-sitter-php.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-python.LICENSE +21 -0
- package/dist/vendor/grammars/tree-sitter-python.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-r.LICENSE +9 -0
- package/dist/vendor/grammars/tree-sitter-r.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-swift.LICENSE +21 -0
- package/dist/vendor/grammars/tree-sitter-swift.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-tsx.wasm +0 -0
- package/dist/vendor/grammars/tree-sitter-typescript.LICENSE +21 -0
- package/dist/vendor/grammars/tree-sitter-typescript.wasm +0 -0
- package/dist/viewer/app.js +2 -0
- package/dist/viewer/index.html +49 -0
- package/dist/viewer/style.css +154 -0
- package/dist/viz/assemble.d.ts +83 -0
- package/dist/viz/assemble.d.ts.map +1 -0
- package/dist/viz/assemble.js +101 -0
- package/dist/viz/assemble.js.map +1 -0
- package/dist/viz/export.d.ts +39 -0
- package/dist/viz/export.d.ts.map +1 -0
- package/dist/viz/export.js +98 -0
- package/dist/viz/export.js.map +1 -0
- package/dist/viz/serve.d.ts +13 -0
- package/dist/viz/serve.d.ts.map +1 -0
- package/dist/viz/serve.js +130 -0
- package/dist/viz/serve.js.map +1 -0
- package/package.json +115 -4
- package/scripts/build-grammar-wasm.mjs +112 -0
- package/scripts/build-viewer.mjs +44 -0
- package/scripts/graph-quality.mjs +117 -0
- package/scripts/pack-trail.mjs +53 -0
- package/scripts/postinstall.mjs +65 -0
- package/scripts/run-tests.mjs +72 -0
- package/scripts/stamp-telemetry-key.mjs +56 -0
- package/scripts/tally-audit.mjs +140 -0
- package/scripts/vendor-grammars.mjs +53 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI wiring for `graft callers` and its `--direction` / `--depth` flags.
|
|
3
|
+
*
|
|
4
|
+
* One command, one implementation: resolve a symbol via `resolveSymbol`, walk
|
|
5
|
+
* edges via `edgeWalk` (incoming or outgoing, depth 1 or a BFS), and share the
|
|
6
|
+
* same resolve-or-die flow, human formatter, and --json shape. Kept out of
|
|
7
|
+
* cli.ts so that file stays thin (argument wiring only) and this logic stays
|
|
8
|
+
* unit-testable without shelling out to the CLI on every case.
|
|
9
|
+
*
|
|
10
|
+
* `--direction out` subsumes the old `graft callees`; `--depth N` subsumes the
|
|
11
|
+
* old `graft impact`. Exported formatters are reused by the MCP `graft_trace_calls`
|
|
12
|
+
* tool (`src/mcp/tools.ts`), so both surfaces render identical reports.
|
|
13
|
+
*/
|
|
14
|
+
import { resolve } from "node:path";
|
|
15
|
+
import { fileReader, referenceLine, wordRe } from "../blast/evidence.js";
|
|
16
|
+
import { contextDirFor } from "../context/node-file.js";
|
|
17
|
+
import { withSavings, savingsFor } from "../context/savings.js";
|
|
18
|
+
import { loadGraphCached } from "./load.js";
|
|
19
|
+
import { resolveSymbol, edgeWalk } from "./traverse.js";
|
|
20
|
+
import { cmd } from "../brand.js";
|
|
21
|
+
const ARROW = { in: "←", out: "→" };
|
|
22
|
+
const DEFAULT_DEPTH = 1;
|
|
23
|
+
/** Exported so the MCP `graft_trace_calls` tool (`src/mcp/tools.ts`) can render the
|
|
24
|
+
* same human report format as the CLI, rather than re-implementing it — both
|
|
25
|
+
* surfaces walk the same edges via the same `resolveSymbol` / `edgeWalk` core. */
|
|
26
|
+
export function headerOf(n) {
|
|
27
|
+
return `${n.name} · ${n.kind} · ${n.path}:${n.span}`;
|
|
28
|
+
}
|
|
29
|
+
/** `showDepth` is set for multi-hop walks (depth > 1), matching the old
|
|
30
|
+
* `graft impact` output which tagged every hit with its BFS depth.
|
|
31
|
+
*
|
|
32
|
+
* `quote`, when given, is the call site itself — the line inside the hit where it
|
|
33
|
+
* references the symbol. An edge that says "total calls add" is a claim; the line
|
|
34
|
+
* under it is the evidence, and it saves opening the file to check.
|
|
35
|
+
*/
|
|
36
|
+
export function hitLine(direction, hit, showDepth, quote) {
|
|
37
|
+
const arrow = ARROW[direction];
|
|
38
|
+
const depthTag = showDepth ? ` [depth ${hit.depth}]` : "";
|
|
39
|
+
const label = hit.node ? `${hit.node.name} (${hit.node.path}:${hit.node.span})` : `${hit.id} (unresolved import)`;
|
|
40
|
+
const line = ` ${hit.relation} ${arrow} ${label}${depthTag}`;
|
|
41
|
+
return quote ? `${line}\n ${quote.n}: ${quote.text.trim()}` : line;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The call site for one hit, or nothing.
|
|
45
|
+
*
|
|
46
|
+
* Only for a resolved hit whose span we can read: an unresolved import has no
|
|
47
|
+
* file, and a hit at depth 2+ references something in between rather than the
|
|
48
|
+
* symbol asked about, so quoting it would point at the wrong line.
|
|
49
|
+
*/
|
|
50
|
+
function quoteFor(hit, name, read) {
|
|
51
|
+
if (!hit.node || hit.depth > 1)
|
|
52
|
+
return undefined;
|
|
53
|
+
return referenceLine(hit.node.path, hit.node.span, [wordRe(name)], read) ?? undefined;
|
|
54
|
+
}
|
|
55
|
+
/** Tokens-saved baseline for a callers/callees walk: the files of the matched
|
|
56
|
+
* symbols plus every resolved edge endpoint, read whole — the files you'd open
|
|
57
|
+
* to trace these edges by hand. Shared by the CLI and the MCP tool so both
|
|
58
|
+
* surfaces report the same number. */
|
|
59
|
+
export function callersSavings(graph, results) {
|
|
60
|
+
const paths = [];
|
|
61
|
+
for (const { symbol, hits } of results) {
|
|
62
|
+
paths.push(symbol.path);
|
|
63
|
+
for (const h of hits)
|
|
64
|
+
if (h.node)
|
|
65
|
+
paths.push(h.node.path);
|
|
66
|
+
}
|
|
67
|
+
return savingsFor(graph, paths);
|
|
68
|
+
}
|
|
69
|
+
/** Loud, actionable empty-result note — never a bare empty list. `candidateCount`
|
|
70
|
+
* is how many nodes {@link resolveSymbol} matched for this query (both call
|
|
71
|
+
* sites already hold it as `matches.length`) — when it's >1, the query name is
|
|
72
|
+
* itself ambiguous (several definitions share it), which is exactly the case
|
|
73
|
+
* `resolve.ts` drops a cross-file call/reference for rather than guessing which
|
|
74
|
+
* one it means. Without saying so, a zero-hit result here reads as "nothing
|
|
75
|
+
* calls this" when it may really be "something does, but the edge was dropped". */
|
|
76
|
+
export function looseNoteFor(direction, name, candidateCount) {
|
|
77
|
+
const label = direction === "out" ? "callees" : "callers";
|
|
78
|
+
const dir = direction === "out" ? "outgoing" : "incoming";
|
|
79
|
+
const ambiguity = candidateCount > 1
|
|
80
|
+
? ` ${candidateCount} definitions share the name "${name}"; a cross-file caller of an ambiguous name is dropped rather than guessed, so this may undercount.`
|
|
81
|
+
: "";
|
|
82
|
+
return ` no indexed ${label} — the graph has no ${dir} call/reference edges for this symbol as written.${ambiguity} Check the name (try the bare symbol, or "Type.method"), or find its uses with ${cmd("graft grep")} "${name}". Fall back to raw grep -rn only for unindexed files`;
|
|
83
|
+
}
|
|
84
|
+
function symbolJson(n) {
|
|
85
|
+
return { id: n.id, name: n.name, kind: n.kind, path: n.path, span: n.span };
|
|
86
|
+
}
|
|
87
|
+
function hitJson(hit) {
|
|
88
|
+
const out = { id: hit.id, relation: hit.relation, depth: hit.depth };
|
|
89
|
+
if (hit.node) {
|
|
90
|
+
out.name = hit.node.name;
|
|
91
|
+
out.kind = hit.node.kind;
|
|
92
|
+
out.path = hit.node.path;
|
|
93
|
+
out.span = hit.node.span;
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
/** Parse and validate the raw `--direction` string; exits (code 1) on garbage. */
|
|
98
|
+
function resolveDirection(raw) {
|
|
99
|
+
if (raw === undefined)
|
|
100
|
+
return "in";
|
|
101
|
+
if (raw === "in" || raw === "out")
|
|
102
|
+
return raw;
|
|
103
|
+
console.error(`✗ --direction must be "in" or "out", got "${raw}"`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolve `query` in the graph at `dir` (respecting `--dir`/`--in`), walk edges
|
|
108
|
+
* per `--direction`/`--depth`, and print either the human report or `--json`.
|
|
109
|
+
* Exits the process (code 1) when there's no graph at all or the symbol is
|
|
110
|
+
* unknown — both are caller-facing mistakes, not recoverable states.
|
|
111
|
+
*/
|
|
112
|
+
export function runCallersCommand(query, dir, opts) {
|
|
113
|
+
const root = resolve(dir);
|
|
114
|
+
const contextDir = contextDirFor(root, opts.globalDir);
|
|
115
|
+
const graph = loadGraphCached(contextDir);
|
|
116
|
+
if (!graph) {
|
|
117
|
+
console.error(`✗ no graph found at ${contextDir} — run \`${cmd("graft build")}\` first`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
// `resolveSymbol` throws on an `--in` prefix that matches nothing indexed —
|
|
121
|
+
// a caller mistake, reported in the same shape as the ones around it rather
|
|
122
|
+
// than as a bare stack-trace message from the top-level handler.
|
|
123
|
+
let matches;
|
|
124
|
+
try {
|
|
125
|
+
matches = resolveSymbol(graph, query, opts.in ? { in: opts.in } : {});
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
console.error(`✗ ${err instanceof Error ? err.message : String(err)}`);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (matches.length === 0) {
|
|
133
|
+
console.error(`✗ no symbol "${query}" in the graph — check spelling or run ${cmd("graft build")}`);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
const direction = resolveDirection(opts.direction);
|
|
137
|
+
let depth = DEFAULT_DEPTH;
|
|
138
|
+
if (opts.depth !== undefined) {
|
|
139
|
+
// `all` (aka full/max) = the whole transitive closure: walk until no new
|
|
140
|
+
// node is reached. The BFS's visited-set makes this cycle-safe, and it
|
|
141
|
+
// terminates when the frontier empties. This is the "show me every
|
|
142
|
+
// connected source" mode — the right first move before a multi-file
|
|
143
|
+
// refactor, where stopping at direct edges misses sibling/downstream files.
|
|
144
|
+
if (/^(all|full|max)$/i.test(opts.depth)) {
|
|
145
|
+
depth = Number.POSITIVE_INFINITY;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const d = Number(opts.depth);
|
|
149
|
+
if (!Number.isFinite(d) || d < 1) {
|
|
150
|
+
console.error(`✗ --depth must be a positive number or "all", got "${opts.depth}"`);
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
depth = Math.floor(d);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const showDepth = depth > 1;
|
|
157
|
+
const results = matches.map((symbol) => ({ symbol, hits: edgeWalk(graph, symbol, direction, depth) }));
|
|
158
|
+
const saved = callersSavings(graph, results);
|
|
159
|
+
if (opts.json) {
|
|
160
|
+
const payload = {
|
|
161
|
+
query,
|
|
162
|
+
matches: results.map((r) => {
|
|
163
|
+
const m = { symbol: symbolJson(r.symbol), hits: r.hits.map(hitJson) };
|
|
164
|
+
if (r.hits.length === 0) {
|
|
165
|
+
m.note = looseNoteFor(direction, r.symbol.name, matches.length);
|
|
166
|
+
}
|
|
167
|
+
return m;
|
|
168
|
+
}),
|
|
169
|
+
saved,
|
|
170
|
+
};
|
|
171
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const lines = [];
|
|
175
|
+
// One reader for the whole walk: several hits usually live in the same file.
|
|
176
|
+
const read = fileReader(root);
|
|
177
|
+
for (const { symbol, hits } of results) {
|
|
178
|
+
lines.push(headerOf(symbol));
|
|
179
|
+
if (hits.length === 0)
|
|
180
|
+
lines.push(looseNoteFor(direction, symbol.name, matches.length));
|
|
181
|
+
else
|
|
182
|
+
for (const h of hits)
|
|
183
|
+
lines.push(hitLine(direction, h, showDepth, quoteFor(h, symbol.name, read)));
|
|
184
|
+
lines.push("");
|
|
185
|
+
}
|
|
186
|
+
const body = lines.join("\n").replace(/\n+$/, "\n");
|
|
187
|
+
process.stdout.write(withSavings(body, saved));
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=traverse-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverse-cli.js","sourceRoot":"","sources":["../../src/graph/traverse-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAgB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAgC,MAAM,eAAe,CAAC;AAEtF,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAalC,MAAM,KAAK,GAAiC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAClE,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;kFAEkF;AAClF,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,OAAO,GAAG,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AACv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6E;IAC7E,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC9B,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;;YACnF,KAAK,MAAM,CAAC,IAAI,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACxG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure graph-traversal core shared by `graft callers` (its `--direction`/
|
|
3
|
+
* `--depth` flags), the MCP `graft_trace_calls` tool, and `ask`'s structural
|
|
4
|
+
* intent path.
|
|
5
|
+
*
|
|
6
|
+
* Centralizes the symbol-resolution contract (bare name, qualified id-suffix,
|
|
7
|
+
* last-segment fallback, `--in` narrowing) so all surfaces agree on what a
|
|
8
|
+
* query like `Cache.get` or `hashstructure.Hash` means, and the direction-aware
|
|
9
|
+
* (incoming/outgoing) depth-1 and BFS edge walks over the wiring graph.
|
|
10
|
+
*
|
|
11
|
+
* No I/O here: callers pass in an already-loaded `GraphV1` (via
|
|
12
|
+
* `loadGraphCached`), which keeps this module trivially unit-testable against
|
|
13
|
+
* hand-built fixture graphs.
|
|
14
|
+
*/
|
|
15
|
+
import type { GraphV1, NodeV1, Relation } from "./types.js";
|
|
16
|
+
/** Which way to walk the wiring graph: `in` = incoming edges (who points at
|
|
17
|
+
* the symbol — callers / blast radius), `out` = outgoing edges (what the symbol
|
|
18
|
+
* points at — callees). */
|
|
19
|
+
export type Direction = "in" | "out";
|
|
20
|
+
/** A resolved symbol-search hit. Reserved for future disambiguation metadata
|
|
21
|
+
* (e.g. why a query matched); today it wraps the node 1:1. */
|
|
22
|
+
export interface SymbolMatch {
|
|
23
|
+
node: NodeV1;
|
|
24
|
+
}
|
|
25
|
+
export interface ResolveSymbolOptions {
|
|
26
|
+
/** Narrow candidates to nodes at or under this repo-relative path prefix —
|
|
27
|
+
* the same segment-aware rule `ask --in` and `grep --in` use, so `--in` means
|
|
28
|
+
* one thing across every command. Normalized here, so either separator works. */
|
|
29
|
+
in?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve a query string to every matching node in the graph.
|
|
33
|
+
*
|
|
34
|
+
* Matching, in order:
|
|
35
|
+
* 1. Non-file nodes whose `name` equals the query case-insensitively, OR
|
|
36
|
+
* whose `id` ends with `#<query>` or `.<query>` case-insensitively — this
|
|
37
|
+
* is what makes a qualified name like `Cache.get` resolve against an id
|
|
38
|
+
* like `src/cache.ts#Cache.get`.
|
|
39
|
+
* 2. If that yields nothing and the query contains a `.`, retry with just
|
|
40
|
+
* the last dot-segment as a bare name (`hashstructure.Hash` → `Hash`) —
|
|
41
|
+
* covers package-qualified names (e.g. Go) whose id never contains the
|
|
42
|
+
* package prefix.
|
|
43
|
+
* 3. If *that* still yields nothing and the query looks like a filename
|
|
44
|
+
* (contains `.`, no `#`), fall back to `kind: 'file'` nodes matched by
|
|
45
|
+
* name or path.
|
|
46
|
+
*
|
|
47
|
+
* `opts.in` then filters whichever candidate set was produced, by path
|
|
48
|
+
* substring. Multiple matches are not an error — every match is returned.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveSymbol(graph: GraphV1, query: string, opts?: ResolveSymbolOptions): NodeV1[];
|
|
51
|
+
/** One traversed edge. `node` is null when the edge's other endpoint isn't a
|
|
52
|
+
* real node in the graph (e.g. an unresolved import module string) — such
|
|
53
|
+
* hits are kept, labeled by the raw id, rather than dropped. */
|
|
54
|
+
export interface EdgeHit {
|
|
55
|
+
node: NodeV1 | null;
|
|
56
|
+
id: string;
|
|
57
|
+
relation: Relation;
|
|
58
|
+
depth: number;
|
|
59
|
+
}
|
|
60
|
+
/** Depth-1: nodes with a walk-relation edge whose target is `symbol`. */
|
|
61
|
+
export declare function callersOf(graph: GraphV1, symbol: NodeV1): EdgeHit[];
|
|
62
|
+
/** Depth-1: walk-relation edges whose source is `symbol`. */
|
|
63
|
+
export declare function calleesOf(graph: GraphV1, symbol: NodeV1): EdgeHit[];
|
|
64
|
+
/**
|
|
65
|
+
* BFS over INCOMING walk-relation edges from `symbol`, up to `maxDepth` hops
|
|
66
|
+
* — "who breaks if this changes". Each reached node is deduped by id and
|
|
67
|
+
* reported once, at the depth it was first reached (a diamond-shaped
|
|
68
|
+
* dependency graph counts its convergence node exactly once).
|
|
69
|
+
*/
|
|
70
|
+
export declare function impactOf(graph: GraphV1, symbol: NodeV1, maxDepth?: number): EdgeHit[];
|
|
71
|
+
/**
|
|
72
|
+
* BFS over walk-relation edges from *multiple* seed nodes at once, in the given
|
|
73
|
+
* `direction` (`in` = incoming, the default — "who breaks if this changes";
|
|
74
|
+
* `out` = outgoing — "what this reaches"). The multi-seed generalization of
|
|
75
|
+
* {@link impactOf} (`impactOf(g, n, d)` is exactly `impactOfMany(g, [n], d)`).
|
|
76
|
+
* Used when one logical unit spans several graph node ids — e.g. a file plus
|
|
77
|
+
* every symbol defined in it, since a `calls`/`references`/etc. edge from
|
|
78
|
+
* another file always targets the SYMBOL id, never the FILE id, so walking the
|
|
79
|
+
* file node alone misses dependents that call into it rather than merely
|
|
80
|
+
* importing it.
|
|
81
|
+
*
|
|
82
|
+
* Every seed is pre-marked visited (so a seed can never appear as its own
|
|
83
|
+
* hit, and an edge between two seeds is never reported), then the walk
|
|
84
|
+
* proceeds exactly like `impactOf`'s: each reached node deduped by id and
|
|
85
|
+
* reported once, at the depth it was first reached from *any* seed.
|
|
86
|
+
*/
|
|
87
|
+
export declare function impactOfMany(graph: GraphV1, seeds: NodeV1[], maxDepth?: number, direction?: Direction): EdgeHit[];
|
|
88
|
+
/**
|
|
89
|
+
* `impactOf`, generalized for a `kind: 'file'` seed: aggregates the BFS over
|
|
90
|
+
* the file node AND every symbol node defined in that file (via
|
|
91
|
+
* {@link impactOfMany} — dedup by id, min depth, seeds excluded). Fixes a file
|
|
92
|
+
* query silently dropping dependents that `calls`/`references`/etc. into a
|
|
93
|
+
* symbol the file defines, rather than merely `imports`-ing the file itself —
|
|
94
|
+
* see this module's header and `impactOfMany`'s doc for why. Symbol-kind
|
|
95
|
+
* queries keep using plain `impactOf`; this is only for file-kind matches.
|
|
96
|
+
*/
|
|
97
|
+
export declare function impactOfFile(graph: GraphV1, fileNode: NodeV1, maxDepth?: number, direction?: Direction): EdgeHit[];
|
|
98
|
+
/**
|
|
99
|
+
* The single entry point behind `graft callers` and the MCP `graft_trace_calls`
|
|
100
|
+
* tool, covering all of what were once three commands:
|
|
101
|
+
* - `direction:in, depth:1` → callers (who calls/references this)
|
|
102
|
+
* - `direction:out, depth:1` → callees (what this calls/references)
|
|
103
|
+
* - `direction:in, depth>1` → blast radius (transitive dependents)
|
|
104
|
+
* - `direction:out, depth>1` → transitive dependencies
|
|
105
|
+
*
|
|
106
|
+
* Depth 1 uses the plain single-hop scan ({@link callersOf}/{@link calleesOf})
|
|
107
|
+
* so `graft callers <symbol>` output is unchanged. Depth >1 runs the BFS, and
|
|
108
|
+
* for a `kind: 'file'` seed aggregates over the symbols the file defines (see
|
|
109
|
+
* {@link impactOfMany}) so file-level dependents aren't silently dropped.
|
|
110
|
+
*/
|
|
111
|
+
export declare function edgeWalk(graph: GraphV1, node: NodeV1, direction: Direction, depth: number): EdgeHit[];
|
|
112
|
+
//# sourceMappingURL=traverse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverse.d.ts","sourceRoot":"","sources":["../../src/graph/traverse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKpE;;2BAE2B;AAC3B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC;AAErC;8DAC8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC;;qFAEiF;IACjF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,oBAAyB,GAAG,MAAM,EAAE,CA6BtG;AA4BD;;gEAEgE;AAChE,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CAQnE;AAED,6DAA6D;AAC7D,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CAQnE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAI,GAAG,OAAO,EAAE,CAEhF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,QAAQ,SAAI,EAAE,SAAS,GAAE,SAAgB,GAAG,OAAO,EAAE,CAmClH;AAQD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,SAAS,GAAE,SAAgB,GAAG,OAAO,EAAE,CAEnH;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CAIrG"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { WALK_RELATIONS } from "./relations.js";
|
|
2
|
+
import { assertPrefixIndexed, pathUnderPrefix } from "./scopes.js";
|
|
3
|
+
import { normalizePathPrefix } from "../util/paths.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a query string to every matching node in the graph.
|
|
6
|
+
*
|
|
7
|
+
* Matching, in order:
|
|
8
|
+
* 1. Non-file nodes whose `name` equals the query case-insensitively, OR
|
|
9
|
+
* whose `id` ends with `#<query>` or `.<query>` case-insensitively — this
|
|
10
|
+
* is what makes a qualified name like `Cache.get` resolve against an id
|
|
11
|
+
* like `src/cache.ts#Cache.get`.
|
|
12
|
+
* 2. If that yields nothing and the query contains a `.`, retry with just
|
|
13
|
+
* the last dot-segment as a bare name (`hashstructure.Hash` → `Hash`) —
|
|
14
|
+
* covers package-qualified names (e.g. Go) whose id never contains the
|
|
15
|
+
* package prefix.
|
|
16
|
+
* 3. If *that* still yields nothing and the query looks like a filename
|
|
17
|
+
* (contains `.`, no `#`), fall back to `kind: 'file'` nodes matched by
|
|
18
|
+
* name or path.
|
|
19
|
+
*
|
|
20
|
+
* `opts.in` then filters whichever candidate set was produced, by path
|
|
21
|
+
* substring. Multiple matches are not an error — every match is returned.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveSymbol(graph, query, opts = {}) {
|
|
24
|
+
const lowerQuery = query.toLowerCase();
|
|
25
|
+
const looksLikeFilename = query.includes(".") && !query.includes("#");
|
|
26
|
+
let matches = symbolMatches(graph.nodes, lowerQuery);
|
|
27
|
+
if (matches.length === 0 && query.includes(".")) {
|
|
28
|
+
const lastSegment = query.slice(query.lastIndexOf(".") + 1).toLowerCase();
|
|
29
|
+
if (lastSegment) {
|
|
30
|
+
matches = graph.nodes.filter((n) => n.kind !== "file" && n.name.toLowerCase() === lastSegment);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (matches.length === 0 && looksLikeFilename) {
|
|
34
|
+
matches = graph.nodes.filter((n) => n.kind === "file" &&
|
|
35
|
+
(n.name.toLowerCase() === lowerQuery ||
|
|
36
|
+
n.path.toLowerCase() === lowerQuery ||
|
|
37
|
+
n.path.toLowerCase().endsWith("/" + lowerQuery)));
|
|
38
|
+
}
|
|
39
|
+
if (opts.in) {
|
|
40
|
+
const prefix = normalizePathPrefix(opts.in);
|
|
41
|
+
assertPrefixIndexed(graph, prefix);
|
|
42
|
+
matches = matches.filter((n) => pathUnderPrefix(n.path, prefix));
|
|
43
|
+
}
|
|
44
|
+
return matches;
|
|
45
|
+
}
|
|
46
|
+
/** Strips extract.ts's mint-time disambiguation ordinals (`~2`, `~3`, ...)
|
|
47
|
+
* from segment ends in a dotted id-tail — the same shape extract.ts mints
|
|
48
|
+
* when a document-order duplicate definition would otherwise collide with an
|
|
49
|
+
* already-minted id (see extract.ts's mint-time uniqueness comment). Without
|
|
50
|
+
* this, a qualified query like `C.m` only ever matches the bare id (`#C.m`),
|
|
51
|
+
* silently hiding the `~2` duplicate from callers/ask/MCP lookups. The
|
|
52
|
+
* ordinal can land on any segment, not just the tail (a reopened class shows
|
|
53
|
+
* up as `C~2.m`), so this strips at every segment boundary (`.` or end of
|
|
54
|
+
* string), not just the very end of the string. */
|
|
55
|
+
function stripOrdinals(idTail) {
|
|
56
|
+
return idTail.replace(/~\d+(?=\.|$)/g, "");
|
|
57
|
+
}
|
|
58
|
+
function symbolMatches(nodes, lowerQuery) {
|
|
59
|
+
const suffixHash = "#" + lowerQuery;
|
|
60
|
+
const suffixDot = "." + lowerQuery;
|
|
61
|
+
return nodes.filter((n) => {
|
|
62
|
+
if (n.kind === "file")
|
|
63
|
+
return false;
|
|
64
|
+
if (n.name.toLowerCase() === lowerQuery)
|
|
65
|
+
return true;
|
|
66
|
+
const lowerId = n.id.toLowerCase();
|
|
67
|
+
const hashIdx = lowerId.indexOf("#");
|
|
68
|
+
const candidateId = hashIdx === -1 ? lowerId : lowerId.slice(0, hashIdx + 1) + stripOrdinals(lowerId.slice(hashIdx + 1));
|
|
69
|
+
return candidateId.endsWith(suffixHash) || candidateId.endsWith(suffixDot);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** Depth-1: nodes with a walk-relation edge whose target is `symbol`. */
|
|
73
|
+
export function callersOf(graph, symbol) {
|
|
74
|
+
const byId = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
75
|
+
const hits = [];
|
|
76
|
+
for (const e of graph.edges) {
|
|
77
|
+
if (!WALK_RELATIONS.has(e.relation) || e.target !== symbol.id)
|
|
78
|
+
continue;
|
|
79
|
+
hits.push({ node: byId.get(e.source) ?? null, id: e.source, relation: e.relation, depth: 1 });
|
|
80
|
+
}
|
|
81
|
+
return hits;
|
|
82
|
+
}
|
|
83
|
+
/** Depth-1: walk-relation edges whose source is `symbol`. */
|
|
84
|
+
export function calleesOf(graph, symbol) {
|
|
85
|
+
const byId = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
86
|
+
const hits = [];
|
|
87
|
+
for (const e of graph.edges) {
|
|
88
|
+
if (!WALK_RELATIONS.has(e.relation) || e.source !== symbol.id)
|
|
89
|
+
continue;
|
|
90
|
+
hits.push({ node: byId.get(e.target) ?? null, id: e.target, relation: e.relation, depth: 1 });
|
|
91
|
+
}
|
|
92
|
+
return hits;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* BFS over INCOMING walk-relation edges from `symbol`, up to `maxDepth` hops
|
|
96
|
+
* — "who breaks if this changes". Each reached node is deduped by id and
|
|
97
|
+
* reported once, at the depth it was first reached (a diamond-shaped
|
|
98
|
+
* dependency graph counts its convergence node exactly once).
|
|
99
|
+
*/
|
|
100
|
+
export function impactOf(graph, symbol, maxDepth = 2) {
|
|
101
|
+
return impactOfMany(graph, [symbol], maxDepth);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* BFS over walk-relation edges from *multiple* seed nodes at once, in the given
|
|
105
|
+
* `direction` (`in` = incoming, the default — "who breaks if this changes";
|
|
106
|
+
* `out` = outgoing — "what this reaches"). The multi-seed generalization of
|
|
107
|
+
* {@link impactOf} (`impactOf(g, n, d)` is exactly `impactOfMany(g, [n], d)`).
|
|
108
|
+
* Used when one logical unit spans several graph node ids — e.g. a file plus
|
|
109
|
+
* every symbol defined in it, since a `calls`/`references`/etc. edge from
|
|
110
|
+
* another file always targets the SYMBOL id, never the FILE id, so walking the
|
|
111
|
+
* file node alone misses dependents that call into it rather than merely
|
|
112
|
+
* importing it.
|
|
113
|
+
*
|
|
114
|
+
* Every seed is pre-marked visited (so a seed can never appear as its own
|
|
115
|
+
* hit, and an edge between two seeds is never reported), then the walk
|
|
116
|
+
* proceeds exactly like `impactOf`'s: each reached node deduped by id and
|
|
117
|
+
* reported once, at the depth it was first reached from *any* seed.
|
|
118
|
+
*/
|
|
119
|
+
export function impactOfMany(graph, seeds, maxDepth = 2, direction = "in") {
|
|
120
|
+
const byId = new Map(graph.nodes.map((n) => [n.id, n]));
|
|
121
|
+
// Adjacency keyed for the walk direction, restricted to walk relations:
|
|
122
|
+
// 'in' → key = edge.target, neighbour = edge.source (who points AT key)
|
|
123
|
+
// 'out' → key = edge.source, neighbour = edge.target (what key points TO)
|
|
124
|
+
const adj = new Map();
|
|
125
|
+
for (const e of graph.edges) {
|
|
126
|
+
if (!WALK_RELATIONS.has(e.relation))
|
|
127
|
+
continue;
|
|
128
|
+
const key = direction === "in" ? e.target : e.source;
|
|
129
|
+
const other = direction === "in" ? e.source : e.target;
|
|
130
|
+
const entry = { other, relation: e.relation };
|
|
131
|
+
const arr = adj.get(key);
|
|
132
|
+
if (arr)
|
|
133
|
+
arr.push(entry);
|
|
134
|
+
else
|
|
135
|
+
adj.set(key, [entry]);
|
|
136
|
+
}
|
|
137
|
+
const visited = new Set(seeds.map((s) => s.id));
|
|
138
|
+
const hits = [];
|
|
139
|
+
let frontier = [...visited];
|
|
140
|
+
for (let depth = 1; depth <= maxDepth && frontier.length > 0; depth++) {
|
|
141
|
+
const next = [];
|
|
142
|
+
for (const current of frontier) {
|
|
143
|
+
for (const { other, relation } of adj.get(current) ?? []) {
|
|
144
|
+
if (visited.has(other))
|
|
145
|
+
continue;
|
|
146
|
+
visited.add(other);
|
|
147
|
+
hits.push({ node: byId.get(other) ?? null, id: other, relation, depth });
|
|
148
|
+
next.push(other);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
frontier = next;
|
|
152
|
+
}
|
|
153
|
+
return hits;
|
|
154
|
+
}
|
|
155
|
+
/** Every non-file node whose `path` equals `fileNode.path` — the symbols
|
|
156
|
+
* defined in that file. */
|
|
157
|
+
function symbolsInFile(graph, fileNode) {
|
|
158
|
+
return graph.nodes.filter((n) => n.kind !== "file" && n.path === fileNode.path);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* `impactOf`, generalized for a `kind: 'file'` seed: aggregates the BFS over
|
|
162
|
+
* the file node AND every symbol node defined in that file (via
|
|
163
|
+
* {@link impactOfMany} — dedup by id, min depth, seeds excluded). Fixes a file
|
|
164
|
+
* query silently dropping dependents that `calls`/`references`/etc. into a
|
|
165
|
+
* symbol the file defines, rather than merely `imports`-ing the file itself —
|
|
166
|
+
* see this module's header and `impactOfMany`'s doc for why. Symbol-kind
|
|
167
|
+
* queries keep using plain `impactOf`; this is only for file-kind matches.
|
|
168
|
+
*/
|
|
169
|
+
export function impactOfFile(graph, fileNode, maxDepth = 2, direction = "in") {
|
|
170
|
+
return impactOfMany(graph, [fileNode, ...symbolsInFile(graph, fileNode)], maxDepth, direction);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The single entry point behind `graft callers` and the MCP `graft_trace_calls`
|
|
174
|
+
* tool, covering all of what were once three commands:
|
|
175
|
+
* - `direction:in, depth:1` → callers (who calls/references this)
|
|
176
|
+
* - `direction:out, depth:1` → callees (what this calls/references)
|
|
177
|
+
* - `direction:in, depth>1` → blast radius (transitive dependents)
|
|
178
|
+
* - `direction:out, depth>1` → transitive dependencies
|
|
179
|
+
*
|
|
180
|
+
* Depth 1 uses the plain single-hop scan ({@link callersOf}/{@link calleesOf})
|
|
181
|
+
* so `graft callers <symbol>` output is unchanged. Depth >1 runs the BFS, and
|
|
182
|
+
* for a `kind: 'file'` seed aggregates over the symbols the file defines (see
|
|
183
|
+
* {@link impactOfMany}) so file-level dependents aren't silently dropped.
|
|
184
|
+
*/
|
|
185
|
+
export function edgeWalk(graph, node, direction, depth) {
|
|
186
|
+
if (depth <= 1)
|
|
187
|
+
return direction === "in" ? callersOf(graph, node) : calleesOf(graph, node);
|
|
188
|
+
if (node.kind === "file")
|
|
189
|
+
return impactOfFile(graph, node, depth, direction);
|
|
190
|
+
return impactOfMany(graph, [node], depth, direction);
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=traverse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traverse.js","sourceRoot":"","sources":["../../src/graph/traverse.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnE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
* One node per definition (file, class, function, method, interface, type, enum),
|
|
5
|
+
* wired by edges (contains, imports, calls, ...). Field names follow the LSP
|
|
6
|
+
* vocabulary (`name`, `kind`, ...) rather than any one tool's conventions.
|
|
7
|
+
*
|
|
8
|
+
* Two tiers of data live on a node:
|
|
9
|
+
* - Tier-1 (deterministic, $0): everything from the AST. Rebuilt on every run.
|
|
10
|
+
* - Tier-2 (one LLM call, cached on `body_hash`): `summary` + `crux`.
|
|
11
|
+
* M1 populates Tier-1 only; Tier-2 fields ship as `pending`/null.
|
|
12
|
+
*/
|
|
13
|
+
/** What a node represents. LSP SymbolKind, narrowed to what our extractors produce. */
|
|
14
|
+
export type Kind = "file" | "class" | "function" | "method" | "interface" | "type" | "enum" | "struct" | "trait" | "module" | "constant" | "variable";
|
|
15
|
+
/** How confident we are an edge is true, best-first. The hand-written AST
|
|
16
|
+
* resolver assigns `extracted`/`inferred`; the opt-in LSP enrichment pass
|
|
17
|
+
* (`graft build --lsp`) can promote an edge to compiler-grade `lsp_resolved`
|
|
18
|
+
* (an exact server-confirmed target) or `lsp_dispatch` (an interface/virtual
|
|
19
|
+
* candidate). Order matters: consumers that rank by provenance treat earlier
|
|
20
|
+
* values as stronger. */
|
|
21
|
+
export type Confidence = "lsp_resolved" | "lsp_dispatch" | "extracted" | "inferred";
|
|
22
|
+
/** Whether the LLM meaning-layer has been computed for a node. */
|
|
23
|
+
export type SummaryState = "pending" | "ready" | "stale";
|
|
24
|
+
/** The LLM-chosen business-logic excerpt. `code` is the source of truth; `span`
|
|
25
|
+
* is a best-effort pointer that may drift and is never used to re-slice. */
|
|
26
|
+
export interface Crux {
|
|
27
|
+
code: string;
|
|
28
|
+
span: string;
|
|
29
|
+
}
|
|
30
|
+
export interface NodeV1 {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
kind: Kind;
|
|
34
|
+
owner?: string;
|
|
35
|
+
path: string;
|
|
36
|
+
span: string;
|
|
37
|
+
signature: string | null;
|
|
38
|
+
exported: boolean;
|
|
39
|
+
origin: "ast" | "generic";
|
|
40
|
+
body_hash: string;
|
|
41
|
+
chars?: number;
|
|
42
|
+
body_text?: string;
|
|
43
|
+
arity?: number;
|
|
44
|
+
variadic?: boolean;
|
|
45
|
+
summary_state: SummaryState;
|
|
46
|
+
summary: string | null;
|
|
47
|
+
crux: Crux | null;
|
|
48
|
+
}
|
|
49
|
+
export type Relation = "contains" | "calls" | "imports" | "references" | "implements" | "extends";
|
|
50
|
+
export interface EdgeV1 {
|
|
51
|
+
source: string;
|
|
52
|
+
target: string;
|
|
53
|
+
relation: Relation;
|
|
54
|
+
confidence: Confidence;
|
|
55
|
+
}
|
|
56
|
+
/** A ranking scope: a sub-project discovered by project-marker files (`package.json`,
|
|
57
|
+
* `go.mod`, ...). `prefix` is a posix path relative to the graph root ("" = root scope);
|
|
58
|
+
* `label` is the same value without a trailing slash (also "" for root); `markers` lists
|
|
59
|
+
* which marker file(s) were found in that directory. See `src/graph/scopes.ts`. */
|
|
60
|
+
export interface ScopeV1 {
|
|
61
|
+
prefix: string;
|
|
62
|
+
label: string;
|
|
63
|
+
markers: string[];
|
|
64
|
+
}
|
|
65
|
+
export interface GraphV1 {
|
|
66
|
+
meta: {
|
|
67
|
+
version: 1;
|
|
68
|
+
nodeCount: number;
|
|
69
|
+
edgeCount: number;
|
|
70
|
+
languages: string[];
|
|
71
|
+
/** Ranking scopes: posix path prefixes relative to the graph root, "" = root scope.
|
|
72
|
+
* Absent (old graphs) ≡ [{ prefix: "", label: "" }]. Sorted by prefix length desc. */
|
|
73
|
+
scopes?: ScopeV1[];
|
|
74
|
+
};
|
|
75
|
+
nodes: NodeV1[];
|
|
76
|
+
edges: EdgeV1[];
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/graph/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;A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AAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;mFAGmF;AACnF,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE;QACJ,OAAO,EAAE,CAAC,CAAC;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB;8FACsF;QACtF,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;KACpB,CAAC;IACF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `graph.json` — the code graph schema (v1).
|
|
3
|
+
*
|
|
4
|
+
* One node per definition (file, class, function, method, interface, type, enum),
|
|
5
|
+
* wired by edges (contains, imports, calls, ...). Field names follow the LSP
|
|
6
|
+
* vocabulary (`name`, `kind`, ...) rather than any one tool's conventions.
|
|
7
|
+
*
|
|
8
|
+
* Two tiers of data live on a node:
|
|
9
|
+
* - Tier-1 (deterministic, $0): everything from the AST. Rebuilt on every run.
|
|
10
|
+
* - Tier-2 (one LLM call, cached on `body_hash`): `summary` + `crux`.
|
|
11
|
+
* M1 populates Tier-1 only; Tier-2 fields ship as `pending`/null.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/graph/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type WebTreeSitter = typeof import("web-tree-sitter");
|
|
2
|
+
/** The initialised current runtime, loading and initialising it on the first call. */
|
|
3
|
+
export declare function webTreeSitter(): Promise<WebTreeSitter>;
|
|
4
|
+
/** What the depth tier uses of web-tree-sitter 0.22's API. */
|
|
5
|
+
export interface DepthWasmParser {
|
|
6
|
+
setLanguage(language: unknown): void;
|
|
7
|
+
parse(input: (index: number) => string): {
|
|
8
|
+
rootNode: unknown;
|
|
9
|
+
delete(): void;
|
|
10
|
+
} | null;
|
|
11
|
+
}
|
|
12
|
+
export interface DepthRuntime {
|
|
13
|
+
load(wasm: Uint8Array): Promise<unknown>;
|
|
14
|
+
newParser(): DepthWasmParser;
|
|
15
|
+
}
|
|
16
|
+
/** The depth tier's runtime, initialised on the first call. */
|
|
17
|
+
export declare function depthRuntime(): Promise<DepthRuntime>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=wasm-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-runtime.d.ts","sourceRoot":"","sources":["../../src/graph/wasm-runtime.ts"],"names":[],"mappings":"AAmBA,KAAK,aAAa,GAAG,cAAc,iBAAiB,CAAC,CAAC;AAItD,sFAAsF;AACtF,wBAAgB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAMtD;AAED,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACrC,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,IAAI,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACvF;AAMD,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,SAAS,IAAI,eAAe,CAAC;CAC9B;AAID,+DAA+D;AAC/D,wBAAgB,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC,CAOpD"}
|