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,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ensureFreshGraph` — the pre-query gate that keeps retrieval honest.
|
|
3
|
+
*
|
|
4
|
+
* A graph is a set of `file:line` spans for one working tree, so an answer drawn
|
|
5
|
+
* from it is only as honest as its freshness. That cannot be somebody else's job:
|
|
6
|
+
* an edit made outside the agent (your editor, a branch switch, a stash, a merge)
|
|
7
|
+
* sets no flag anywhere. So freshness lives in the query path: every retrieval
|
|
8
|
+
* call probes the working tree (`fingerprint.ts`, ~3ms) and, when something moved,
|
|
9
|
+
* repairs the structural graph. Properties worth keeping:
|
|
10
|
+
*
|
|
11
|
+
* - **$0 and offline.** Tier-1 only — never a summarizer, never `--deep`. Anything
|
|
12
|
+
* that runs without being asked must not spend money.
|
|
13
|
+
* - **Never fatal.** A failed refresh degrades to answering from the graph on
|
|
14
|
+
* disk. A query that works today must not start failing because a rebuild did.
|
|
15
|
+
* - **Never a stampede.** It takes the same `.cache/.sync.lock` a background build
|
|
16
|
+
* takes, so concurrent MCP calls and the rebuild they trigger can't pile up.
|
|
17
|
+
* - **Bounded.** Up to `DRIFT_INLINE_MAX` changed files are re-extracted before
|
|
18
|
+
* answering; more than that is handed to a background rebuild and the answer
|
|
19
|
+
* carries `[stale: N files changed, rebuilding in background]`. A branch switch
|
|
20
|
+
* never blocks a query.
|
|
21
|
+
* - **Writes only what a query reads** (`graphOnly`): the graph, the `ask` sidecar,
|
|
22
|
+
* the freshness record. Not the markdown cards, not `INDEX.md`, not `.gitignore`.
|
|
23
|
+
* Those belong to an explicit `trail build`, so retrieval stays cheap and a read
|
|
24
|
+
* stays a read. `stats.json` is left alone too.
|
|
25
|
+
* - **Lexical here, semantic elsewhere.** The inline repair updates the graph only.
|
|
26
|
+
* The vector index loads an ONNX model, so it refreshes in a detached process
|
|
27
|
+
* (`build-run.ts`) and never on the path that answers.
|
|
28
|
+
*
|
|
29
|
+
* One case is not drift but absence: inside a git worktree there is no graph at all,
|
|
30
|
+
* because `.trail/`/`graft/` is gitignored and so was never checked out. The gate
|
|
31
|
+
* covers that too — it copies the parent checkout's graph in (`./seed.ts`) and then
|
|
32
|
+
* treats the difference between the two checkouts as ordinary drift, which is
|
|
33
|
+
* exactly what it is.
|
|
34
|
+
*
|
|
35
|
+
* The other absence is a repo this machine never built: `trail init` ran somewhere
|
|
36
|
+
* else, or the clone is new. Its queries find no code and the agent goes back to
|
|
37
|
+
* grep for the rest of the session. So the first query there starts a full build in
|
|
38
|
+
* the background and waits a while for it (`buildMissingMap`).
|
|
39
|
+
*/
|
|
40
|
+
import { spawn } from "node:child_process";
|
|
41
|
+
import { existsSync } from "node:fs";
|
|
42
|
+
import { join, resolve } from "node:path";
|
|
43
|
+
import { fileURLToPath } from "node:url";
|
|
44
|
+
import { contextDirFor } from "../context/node-file.js";
|
|
45
|
+
import { isTrailMapDir } from "../context/map-dir.js";
|
|
46
|
+
import { homeFolderRefusal } from "../init-guard.js";
|
|
47
|
+
import { acquireLockIn, lockHeldIn, releaseLockIn } from "../util/state.js";
|
|
48
|
+
import { CACHE_DIR } from "../context/node-file.js";
|
|
49
|
+
import { buildGraph } from "./build.js";
|
|
50
|
+
import { BACKGROUND_TIMEOUT_MS, embeddingsDbPath } from "./build-run.js";
|
|
51
|
+
import { driftCount, isClean, probeDrift, readFingerprint } from "./fingerprint.js";
|
|
52
|
+
import { invalidateGraphCaches } from "./load.js";
|
|
53
|
+
import { seedGraph } from "./seed.js";
|
|
54
|
+
import { wiringPath } from "./write.js";
|
|
55
|
+
import { cmd, tag } from "../brand.js";
|
|
56
|
+
/**
|
|
57
|
+
* Most files a query will re-extract before answering, instead of handing the
|
|
58
|
+
* rebuild to a background process.
|
|
59
|
+
*
|
|
60
|
+
* A constant, not a flag: a merge or an ordinary edit of a handful of files stays
|
|
61
|
+
* well under it and gets answered from a current graph; a branch switch or a fresh
|
|
62
|
+
* clone blows past it, and blocking that query to re-parse hundreds of files is
|
|
63
|
+
* exactly the cost this gate exists to avoid. See design decision 5.
|
|
64
|
+
*/
|
|
65
|
+
export const DRIFT_INLINE_MAX = 50;
|
|
66
|
+
/** How long to wait for another process's in-flight rebuild before giving up and
|
|
67
|
+
* answering from the current graph. Long enough to ride out a small repo's build,
|
|
68
|
+
* short enough that a tool call never feels hung. */
|
|
69
|
+
const LOCK_WAIT_MS = 2000;
|
|
70
|
+
const LOCK_POLL_MS = 50;
|
|
71
|
+
/** How long a query waits for a repo's first build before answering without code.
|
|
72
|
+
* A big repo (8k files) builds in about 75s, and the agent's shell gives a command
|
|
73
|
+
* two minutes; a reply with code in it on the first try is worth the wait, once. */
|
|
74
|
+
const FIRST_BUILD_WAIT_MS = 90_000;
|
|
75
|
+
const FIRST_BUILD_POLL_MS = 250;
|
|
76
|
+
/** The first build's own time limit, well past the end-of-turn rebuild's two minutes. */
|
|
77
|
+
const FIRST_BUILD_TIMEOUT_MS = 10 * 60_000;
|
|
78
|
+
const CLEAN = { refreshed: false };
|
|
79
|
+
/** Env kill switch, for CI or anyone who wants queries to never write. */
|
|
80
|
+
function envDisabled() {
|
|
81
|
+
const v = process.env.GRAFT_NO_REFRESH;
|
|
82
|
+
return v !== undefined && v !== "" && v !== "0" && v !== "false";
|
|
83
|
+
}
|
|
84
|
+
function sleep(ms) {
|
|
85
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
86
|
+
}
|
|
87
|
+
/** The wait for a first build: the option, else `GRAFT_FIRST_BUILD_WAIT_MS` (the hooks
|
|
88
|
+
* set 0, since their own budget is seconds), else the default. */
|
|
89
|
+
function firstBuildWait(opts) {
|
|
90
|
+
if (opts.firstBuildWaitMs !== undefined)
|
|
91
|
+
return opts.firstBuildWaitMs;
|
|
92
|
+
const v = process.env.GRAFT_FIRST_BUILD_WAIT_MS;
|
|
93
|
+
const ms = v === undefined || v === "" ? NaN : Number(v);
|
|
94
|
+
return Number.isFinite(ms) && ms >= 0 ? ms : FIRST_BUILD_WAIT_MS;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The detached rebuild runner: the compiled sibling this module ships with, or a
|
|
98
|
+
* test's stand-in. Null when neither is on disk — the caller then answers from
|
|
99
|
+
* whatever graph it has, which is the behaviour that predates all of this.
|
|
100
|
+
*/
|
|
101
|
+
function runnerPath() {
|
|
102
|
+
const overridden = process.env.GRAFT_TEST_BUILD_RUN;
|
|
103
|
+
if (overridden)
|
|
104
|
+
return existsSync(overridden) ? overridden : null;
|
|
105
|
+
const run = fileURLToPath(new URL("./build-run.js", import.meta.url));
|
|
106
|
+
return existsSync(run) ? run : null;
|
|
107
|
+
}
|
|
108
|
+
/** Start `build-run` detached. The caller owns the lock contract (see below). */
|
|
109
|
+
function spawnJob(dir, outDir, mode, timeoutMs) {
|
|
110
|
+
const run = runnerPath();
|
|
111
|
+
if (!run)
|
|
112
|
+
return false;
|
|
113
|
+
const child = spawn(process.execPath, [run, mode, dir, outDir, String(timeoutMs)], {
|
|
114
|
+
detached: true,
|
|
115
|
+
stdio: "ignore",
|
|
116
|
+
windowsHide: true,
|
|
117
|
+
});
|
|
118
|
+
child.on("error", () => { });
|
|
119
|
+
child.unref();
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Hand a rebuild to a background process, under the same lock every other rebuild
|
|
124
|
+
* takes. False when nothing was started (no runner on disk, someone else already
|
|
125
|
+
* rebuilding, or a `full` job whose lock we could not take).
|
|
126
|
+
*
|
|
127
|
+
* `graph` and `full` take the lock and the child releases it; `embed` takes none —
|
|
128
|
+
* it only reads the graph and writes the vector index, and a query that answered
|
|
129
|
+
* a moment ago is not going to race it for the graph.
|
|
130
|
+
*
|
|
131
|
+
* `embed` also refuses to create an index that isn't there: a repo that never ran
|
|
132
|
+
* a semantic build must not start downloading a 400 MB model because someone
|
|
133
|
+
* edited a file. It refreshes what exists, nothing more.
|
|
134
|
+
*/
|
|
135
|
+
function startBackgroundJob(dir, outDir, mode) {
|
|
136
|
+
if (mode === "embed") {
|
|
137
|
+
if (!existsSync(embeddingsDbPath(outDir)))
|
|
138
|
+
return false;
|
|
139
|
+
return spawnJob(dir, outDir, mode, BACKGROUND_TIMEOUT_MS);
|
|
140
|
+
}
|
|
141
|
+
const lockCache = join(outDir, CACHE_DIR);
|
|
142
|
+
if (lockHeldIn(lockCache))
|
|
143
|
+
return true; // someone is already rebuilding
|
|
144
|
+
if (!acquireLockIn(lockCache))
|
|
145
|
+
return false;
|
|
146
|
+
if (!spawnJob(dir, outDir, mode, mode === "full" ? FIRST_BUILD_TIMEOUT_MS : BACKGROUND_TIMEOUT_MS)) {
|
|
147
|
+
releaseLockIn(lockCache);
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Start a full `full` build of `dir`, for a repo on trail that has no map yet. The
|
|
154
|
+
* caller holds the lock; the child releases it when the build ends, however it ends.
|
|
155
|
+
*/
|
|
156
|
+
function startFirstBuild(dir, outDir) {
|
|
157
|
+
if (lockHeldIn(join(outDir, CACHE_DIR)))
|
|
158
|
+
return true;
|
|
159
|
+
if (!acquireLockIn(join(outDir, CACHE_DIR)))
|
|
160
|
+
return false;
|
|
161
|
+
if (!spawnJob(dir, outDir, "full", FIRST_BUILD_TIMEOUT_MS)) {
|
|
162
|
+
releaseLockIn(join(outDir, CACHE_DIR));
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* No graph here and none to copy in. A repo on trail gets one built: its team
|
|
169
|
+
* committed `.trail/` and this person installed trail, so a build is what they
|
|
170
|
+
* asked for, and answering "no matching nodes" sends the agent back to grep for
|
|
171
|
+
* good. Anywhere else (a graft repo, a `--dir` map, the home folder) nothing is
|
|
172
|
+
* built behind the user's back, as before.
|
|
173
|
+
*
|
|
174
|
+
* The first query to get here starts the build and waits up to `firstBuildWait`;
|
|
175
|
+
* queries arriving meanwhile wait on the same lock. Returns a note when the map
|
|
176
|
+
* is now there and the query should go on, or what to answer with when it isn't.
|
|
177
|
+
*/
|
|
178
|
+
async function buildMissingMap(dir, outDir, opts, busy) {
|
|
179
|
+
const own = !opts.contextDir && !process.env.GRAFT_DIR && isTrailMapDir(dir, outDir) && homeFolderRefusal(dir) === null;
|
|
180
|
+
if (!own) {
|
|
181
|
+
return busy
|
|
182
|
+
? { refreshed: false, note: "another process is still copying the graph into this worktree — retry the query in a moment" }
|
|
183
|
+
: CLEAN;
|
|
184
|
+
}
|
|
185
|
+
const lockCache = join(outDir, CACHE_DIR);
|
|
186
|
+
const started = Date.now();
|
|
187
|
+
// The lock free and still no map: nobody is building it, so this query starts it.
|
|
188
|
+
// Taken here, released by the child.
|
|
189
|
+
if (!startFirstBuild(dir, outDir)) {
|
|
190
|
+
// Nothing to start, and nothing running either: say so below rather than waiting.
|
|
191
|
+
}
|
|
192
|
+
const deadline = started + firstBuildWait(opts);
|
|
193
|
+
while (lockHeldIn(lockCache) && Date.now() < deadline)
|
|
194
|
+
await sleep(FIRST_BUILD_POLL_MS);
|
|
195
|
+
if (existsSync(wiringPath(outDir))) {
|
|
196
|
+
invalidateGraphCaches(outDir);
|
|
197
|
+
return `built this repo's code map for the first time (${Math.round((Date.now() - started) / 1000)}s)`;
|
|
198
|
+
}
|
|
199
|
+
if (lockHeldIn(lockCache)) {
|
|
200
|
+
return {
|
|
201
|
+
refreshed: false,
|
|
202
|
+
note: "no code map here yet: building one in the background (about a minute on a big repo). Until it's done the answer has no code in it — run the same command again in a minute instead of rewording it",
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return { refreshed: false, note: `couldn't build this repo's code map — run \`${cmd("graft build")}\` to see why` };
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Release the lock if this process is asked to die while holding it. Returns the
|
|
209
|
+
* un-hook.
|
|
210
|
+
*
|
|
211
|
+
* Not hypothetical: the Claude Code prompt hook runs `graft ask` with a timeout, and
|
|
212
|
+
* `execFileSync` enforces it with SIGTERM. Node's default disposition for SIGTERM is
|
|
213
|
+
* to exit without unwinding, so the `finally` below never runs and the lock outlives
|
|
214
|
+
* the process — after which the background sync is blocked and every query waits and
|
|
215
|
+
* then answers stale until the lock ages out. Ctrl-C on a CLI query is the same story
|
|
216
|
+
* with SIGINT.
|
|
217
|
+
*
|
|
218
|
+
* Adding a listener replaces that default disposition, so re-raise it explicitly
|
|
219
|
+
* afterwards: remove ourselves, then `process.kill(process.pid, sig)`, so the exit
|
|
220
|
+
* status still says "terminated by signal" for whoever is waiting on us.
|
|
221
|
+
*/
|
|
222
|
+
export function releaseOnSignal(cache) {
|
|
223
|
+
const signals = ["SIGTERM", "SIGINT"];
|
|
224
|
+
const onSignal = (sig) => {
|
|
225
|
+
releaseLockIn(cache);
|
|
226
|
+
for (const s of signals)
|
|
227
|
+
process.removeListener(s, onSignal);
|
|
228
|
+
process.kill(process.pid, sig);
|
|
229
|
+
};
|
|
230
|
+
for (const s of signals)
|
|
231
|
+
process.once(s, onSignal);
|
|
232
|
+
return () => {
|
|
233
|
+
for (const s of signals)
|
|
234
|
+
process.removeListener(s, onSignal);
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Wait out someone else's rebuild, then take the lock. False when we couldn't. */
|
|
238
|
+
async function waitForLock(cache) {
|
|
239
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
240
|
+
for (;;) {
|
|
241
|
+
if (acquireLockIn(cache))
|
|
242
|
+
return true;
|
|
243
|
+
if (Date.now() >= deadline)
|
|
244
|
+
return false;
|
|
245
|
+
await sleep(LOCK_POLL_MS);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Copy a parent checkout's graph in, holding the same lock a rebuild would.
|
|
250
|
+
*
|
|
251
|
+
* Two MCP tool calls in a fresh worktree arrive here at the same moment, and an 8 MB
|
|
252
|
+
* copy is long enough for both to start one. The loser waits, then finds the graph
|
|
253
|
+
* already there and reports nothing — which is why the caller re-checks the file
|
|
254
|
+
* rather than trusting this return value.
|
|
255
|
+
*/
|
|
256
|
+
async function seedUnderLock(dir, outDir, contextDir) {
|
|
257
|
+
const lockCache = join(outDir, CACHE_DIR);
|
|
258
|
+
// `busy` matters: with no graph on disk there is nothing to fall back to, so a
|
|
259
|
+
// caller that stayed silent here would emit the bare "no matching nodes" this whole
|
|
260
|
+
// mechanism exists to remove. Say what happened instead.
|
|
261
|
+
if (!(await waitForLock(lockCache)))
|
|
262
|
+
return { seeded: false, busy: true };
|
|
263
|
+
const unhook = releaseOnSignal(lockCache);
|
|
264
|
+
try {
|
|
265
|
+
return seedGraph(dir, { contextDir });
|
|
266
|
+
}
|
|
267
|
+
finally {
|
|
268
|
+
unhook();
|
|
269
|
+
releaseLockIn(lockCache);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Rebuild `root`'s structural graph if the working tree has moved since the last
|
|
274
|
+
* build. Cheap and side-effect-free when nothing changed, which is the usual case.
|
|
275
|
+
*
|
|
276
|
+
* `root` is the repository root (the same value the query itself is given), not
|
|
277
|
+
* the context dir.
|
|
278
|
+
*/
|
|
279
|
+
export async function ensureFreshGraph(root, opts = {}) {
|
|
280
|
+
if (opts.disabled || envDisabled())
|
|
281
|
+
return CLEAN;
|
|
282
|
+
try {
|
|
283
|
+
const dir = resolve(root);
|
|
284
|
+
const outDir = contextDirFor(dir, opts.contextDir);
|
|
285
|
+
let seededFrom;
|
|
286
|
+
let builtNote;
|
|
287
|
+
if (!existsSync(wiringPath(outDir))) {
|
|
288
|
+
// One case has a graph to work with even though this checkout has none: a git
|
|
289
|
+
// worktree, whose parent checkout's `graft/` git could not check out. Copy it
|
|
290
|
+
// in and carry on — the drift below is then exactly the diff between the two
|
|
291
|
+
// checkouts, and repairing it is what makes the copied graph honest here.
|
|
292
|
+
const seed = await seedUnderLock(dir, outDir, opts.contextDir);
|
|
293
|
+
seededFrom = seed.from;
|
|
294
|
+
// Still nothing (not a worktree, parent never built, or a concurrent seed or
|
|
295
|
+
// first build we lost the race for): a repo on trail gets its map built; any
|
|
296
|
+
// other repo gets the caller's own "no graph — run graft build" message.
|
|
297
|
+
if (!existsSync(wiringPath(outDir))) {
|
|
298
|
+
const built = await buildMissingMap(dir, outDir, opts, seed.busy);
|
|
299
|
+
if (typeof built !== "string")
|
|
300
|
+
return built;
|
|
301
|
+
builtNote = built;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const seedNote = seededFrom ? `copied the graph from the main checkout (${seededFrom})` : builtNote;
|
|
305
|
+
// null = no fingerprint at all: a graph built before this mechanism existed,
|
|
306
|
+
// or by a different extractor build. Rebuild once — that lays the fingerprint
|
|
307
|
+
// down, so it costs exactly one build, not one per query.
|
|
308
|
+
const drift = probeDrift(dir, outDir);
|
|
309
|
+
if (drift && isClean(drift))
|
|
310
|
+
return seedNote ? { refreshed: false, note: seedNote } : CLEAN;
|
|
311
|
+
// Too much to patch before answering: a branch switch, a fresh checkout, a
|
|
312
|
+
// merge of somebody else's work. Answer from the graph that is on disk, say it
|
|
313
|
+
// is stale, and let a background process repair it — blocking here is what made
|
|
314
|
+
// a query after `git switch` feel like a hang. The next query, once that build
|
|
315
|
+
// lands, answers fresh with no note at all.
|
|
316
|
+
//
|
|
317
|
+
// Only when the handoff actually happened: if no background runner is on disk
|
|
318
|
+
// (a half-installed CLI) the note would promise a rebuild that nobody is doing,
|
|
319
|
+
// so the slower inline repair below is the honest answer.
|
|
320
|
+
if (drift && driftCount(drift) > DRIFT_INLINE_MAX && startBackgroundJob(dir, outDir, "graph")) {
|
|
321
|
+
return { refreshed: false, drift, stale: driftCount(drift) };
|
|
322
|
+
}
|
|
323
|
+
// The lock every rebuild takes, so two queries and a background build can never
|
|
324
|
+
// rebuild the same graph at the same time.
|
|
325
|
+
const lockCache = join(outDir, CACHE_DIR);
|
|
326
|
+
if (!(await waitForLock(lockCache))) {
|
|
327
|
+
const busy = "a graph rebuild is already in flight — answering from the current graph";
|
|
328
|
+
return {
|
|
329
|
+
refreshed: false,
|
|
330
|
+
drift: drift ?? undefined,
|
|
331
|
+
note: seedNote ? `${seedNote}; ${busy}` : busy,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const unhook = releaseOnSignal(lockCache);
|
|
335
|
+
try {
|
|
336
|
+
// We may have queued behind another process's rebuild for up to LOCK_WAIT_MS,
|
|
337
|
+
// and that rebuild very likely fixed the same drift we saw. Re-probe rather
|
|
338
|
+
// than rebuild on the strength of a stale observation: without this, four
|
|
339
|
+
// parallel MCP tool calls on one edited file produce four full rebuilds, three
|
|
340
|
+
// of them pure waste, and the last tool call pays for all of it. A null drift
|
|
341
|
+
// means "no fingerprint" and still has to build.
|
|
342
|
+
const now = drift ? probeDrift(dir, outDir) : null;
|
|
343
|
+
if (now && isClean(now)) {
|
|
344
|
+
invalidateGraphCaches(outDir);
|
|
345
|
+
return seedNote ? { refreshed: false, note: seedNote } : CLEAN;
|
|
346
|
+
}
|
|
347
|
+
// Tier-1 only: no summarizer, so no LLM call and no network, ever. And
|
|
348
|
+
// `graphOnly`: write the graph, the ask sidecar and the fingerprint, nothing
|
|
349
|
+
// else. The markdown projections under `graft/` stay the `Stop` hook's job —
|
|
350
|
+
// a query has no business rewriting the repo's `.gitignore` or churning every
|
|
351
|
+
// card's mtime, and skipping them is most of what keeps this cheap.
|
|
352
|
+
// A `--only-dir` build recorded its whitelist in the fingerprint; re-apply it
|
|
353
|
+
// here so an auto-rebuild keeps the same limited file set instead of silently
|
|
354
|
+
// widening to the whole tree.
|
|
355
|
+
const onlyDirs = readFingerprint(outDir)?.onlyDirs;
|
|
356
|
+
await buildGraph(dir, { contextDir: opts.contextDir, graphOnly: true, onlyDirs });
|
|
357
|
+
invalidateGraphCaches(outDir);
|
|
358
|
+
// The vector index is the one thing that stays behind: loading the ONNX model
|
|
359
|
+
// costs seconds and this was a lexical query. It refreshes out of process —
|
|
360
|
+
// and only if the repo has an index to refresh (`startBackgroundJob`).
|
|
361
|
+
startBackgroundJob(dir, outDir, "embed");
|
|
362
|
+
return { refreshed: true, drift: drift ?? undefined, note: seedNote };
|
|
363
|
+
}
|
|
364
|
+
finally {
|
|
365
|
+
unhook();
|
|
366
|
+
releaseLockIn(lockCache);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
catch (err) {
|
|
370
|
+
// Answering from a slightly stale graph beats failing the query.
|
|
371
|
+
return { refreshed: false, note: `graph refresh skipped: ${err instanceof Error ? err.message : String(err)}` };
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Workspace variant: refresh each child repo's own graph (a workspace parent holds
|
|
376
|
+
* an index, never nodes). Children are independent, but they're refreshed in
|
|
377
|
+
* sequence — a fan-out of concurrent tree-sitter builds would spike CPU on the
|
|
378
|
+
* very path that's supposed to feel free.
|
|
379
|
+
*/
|
|
380
|
+
export async function ensureFreshChildren(root, children, opts = {}) {
|
|
381
|
+
if (opts.disabled || envDisabled())
|
|
382
|
+
return CLEAN;
|
|
383
|
+
const refreshedIn = [];
|
|
384
|
+
let files = 0;
|
|
385
|
+
let staleFiles = 0;
|
|
386
|
+
for (const child of children) {
|
|
387
|
+
// Deliberately NOT `opts`: `contextDirFor` returns an override verbatim and
|
|
388
|
+
// ignores the root it's handed, so forwarding the parent's `--dir` would point
|
|
389
|
+
// every child at the *parent's* context dir — which holds a workspace index and
|
|
390
|
+
// no wiring.json, so every child would silently be skipped. (And if it did hold
|
|
391
|
+
// one, each child would build into that single shared dir in turn, the last
|
|
392
|
+
// clobbering the rest.) A child's graph always lives in its own `<child>/graft`,
|
|
393
|
+
// which is exactly how `loadWorkspaceGraphs` reads them back.
|
|
394
|
+
const r = await ensureFreshGraph(resolve(root, child), { disabled: opts.disabled });
|
|
395
|
+
if (r.stale !== undefined)
|
|
396
|
+
staleFiles += r.stale;
|
|
397
|
+
if (!r.refreshed)
|
|
398
|
+
continue;
|
|
399
|
+
refreshedIn.push(child);
|
|
400
|
+
files += r.drift ? driftCount(r.drift) : 0;
|
|
401
|
+
}
|
|
402
|
+
// A workspace is as stale as its stalest child: the warning has to survive the
|
|
403
|
+
// ranking, or an answer that cites some other child's fresh graph looks sound
|
|
404
|
+
// while the one the user cares about is a branch behind.
|
|
405
|
+
if (staleFiles > 0)
|
|
406
|
+
return { refreshed: refreshedIn.length > 0, stale: staleFiles };
|
|
407
|
+
if (!refreshedIn.length)
|
|
408
|
+
return CLEAN;
|
|
409
|
+
return {
|
|
410
|
+
refreshed: true,
|
|
411
|
+
note: `refreshed ${refreshedIn.join(", ")} (${files || "?"} file${files === 1 ? "" : "s"} changed) before answering`,
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
/** The one-line note a CLI/MCP surface prints when a refresh actually happened.
|
|
415
|
+
* Null when there's nothing to say (the overwhelmingly common case). */
|
|
416
|
+
export function refreshNote(r) {
|
|
417
|
+
// Stale first: it is a warning about the answer, not a report of work done.
|
|
418
|
+
if (r.stale !== undefined) {
|
|
419
|
+
return `[stale: ${r.stale} files changed, rebuilding in background]`;
|
|
420
|
+
}
|
|
421
|
+
if (!r.refreshed)
|
|
422
|
+
return r.note ? `${tag()} ${r.note}` : null;
|
|
423
|
+
const n = r.drift ? driftCount(r.drift) : 0;
|
|
424
|
+
const built = `refreshed the graph (${n || "?"} file${n === 1 ? "" : "s"} changed) before answering`;
|
|
425
|
+
// Both facts, when a worktree was seeded *and* the copy needed repairing: the
|
|
426
|
+
// count is the interesting half (it's the branch diff), the provenance explains
|
|
427
|
+
// where a graph came from in a directory the user knows they never built.
|
|
428
|
+
return r.note ? `${tag()} ${built} — ${r.note}` : `${tag()} ${built}`;
|
|
429
|
+
}
|
|
430
|
+
//# sourceMappingURL=refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../src/graph/refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAc,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,SAAS,EAAmB,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC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AC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,4BAA4B;KACrH,CAAC;AACJ,CAAC;AAED;wEACwE;AACxE,MAAM,UAAU,WAAW,CAAC,CAAgB;IAC1C,4EAA4E;IAC5E,IAAI,CAAC,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,WAAW,CAAC,CAAC,KAAK,2CAA2C,CAAC;IACvE,CAAC;IACD,IAAI,CAAC,CAAC,CAAC,SAAS;QAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9D,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,4BAA4B,CAAC;IACrG,8EAA8E;IAC9E,gFAAgF;IAChF,0EAA0E;IAC1E,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,KAAK,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edges that carry dependency meaning for a graph walk/rank: `calls`,
|
|
3
|
+
* `references`, `imports`, `implements`, `extends`. `contains` is deliberately
|
|
4
|
+
* excluded — a file "contains" every symbol defined in it, so walking it
|
|
5
|
+
* would make every same-file symbol a neighbour and let a file act as a false
|
|
6
|
+
* hub, flooding a walk that must stay confined to genuine dependency wiring.
|
|
7
|
+
*
|
|
8
|
+
* Shared by `traverse.ts` (callers/callees/impact edge walks), `graphrank.ts`
|
|
9
|
+
* (personalized PageRank), and `search/grep.ts` (in-degree ranking) so every
|
|
10
|
+
* surface agrees on what counts as a dependency edge.
|
|
11
|
+
*/
|
|
12
|
+
import type { Relation } from "./types.js";
|
|
13
|
+
export declare const WALK_RELATIONS: ReadonlySet<Relation>;
|
|
14
|
+
//# sourceMappingURL=relations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/graph/relations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,QAAQ,CAM/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../src/graph/relations.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,cAAc,GAA0B,IAAI,GAAG,CAAW;IACrE,OAAO;IACP,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,SAAS;CACV,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EdgeV1, NodeV1 } from "./types.js";
|
|
2
|
+
import { type RawEdge } from "./extract.js";
|
|
3
|
+
/** A Go module discovered in the repo: its `module` path from `go.mod` and the repo
|
|
4
|
+
* directory that `go.mod` lives in (posix, `.` for the repo root). A monorepo may hold
|
|
5
|
+
* several — e.g. `backend/go.mod`, `tools/go.mod`. */
|
|
6
|
+
export interface GoModule {
|
|
7
|
+
module: string;
|
|
8
|
+
dir: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ResolveOptions {
|
|
11
|
+
/** The Go modules found in the repo. Enables mapping Go import package paths
|
|
12
|
+
* (`example.com/app/pkg/util`) to the in-repo directory they name, relative to the
|
|
13
|
+
* owning module's `go.mod` location. Empty/absent → Go imports stay external strings. */
|
|
14
|
+
goModules?: GoModule[];
|
|
15
|
+
}
|
|
16
|
+
export declare function resolveEdges(nodes: NodeV1[], rawEdges: RawEdge[], opts?: ResolveOptions): EdgeV1[];
|
|
17
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/graph/resolve.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,EAAY,MAAM,YAAY,CAAC;AACjE,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAoExD;;sDAEsD;AACtD,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC7B;;6FAEyF;IACzF,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,GAAE,cAAmB,GACxB,MAAM,EAAE,CAiQV"}
|