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,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `graph` — build `.context/graph.json` from a code repository.
|
|
3
|
+
*
|
|
4
|
+
* M1 pipeline (Tier-1 only, deterministic, no LLM):
|
|
5
|
+
* 1. Walk the repo for TS/Python source files.
|
|
6
|
+
* 2. Parse each with tree-sitter and emit one NodeV1 per definition.
|
|
7
|
+
* 3. Write a sorted graph.json.
|
|
8
|
+
* Edges (M2) and LLM summary/crux (M3) layer onto this without changing it.
|
|
9
|
+
*
|
|
10
|
+
* Step 2 is memoized per file (`extract-cache.ts`): a file whose bytes haven't
|
|
11
|
+
* moved replays its last parse instead of re-running tree-sitter, so a rebuild
|
|
12
|
+
* costs ~the files that changed. Everything after extraction still runs over the
|
|
13
|
+
* whole node set, so an incremental build's output is byte-identical to a cold
|
|
14
|
+
* one — the invariant `test/graph-incremental.test.ts` pins down.
|
|
15
|
+
*/
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
import { basename, dirname, resolve } from "node:path";
|
|
18
|
+
import { walkDir } from "../ingest/fs.js";
|
|
19
|
+
import { contextDirFor, ensureGitignored, ensureSearchable } from "../context/node-file.js";
|
|
20
|
+
import { extractFile, languageLabelOf, languageOf } from "./extract.js";
|
|
21
|
+
import { extractGeneric, fallbackLangOf, genericLangOf, warmGenericGrammars } from "./generic.js";
|
|
22
|
+
import { containerLangOf, extractContainer, warmContainerGrammars } from "./container.js";
|
|
23
|
+
import { extractMd, isMdFile } from "./markdown.js";
|
|
24
|
+
import { depthReady, missingDepthPackages, warmDepthGrammars } from "./depth-parser.js";
|
|
25
|
+
import { contentHash } from "../util/id.js";
|
|
26
|
+
import { relPosix } from "../util/paths.js";
|
|
27
|
+
import { readSourceFile } from "../util/source.js";
|
|
28
|
+
import { readFollowNestedRepos, readFollowSubmodules, readIncludeDirs } from "../util/state.js";
|
|
29
|
+
import { emptyExtractCache, readExtractCache, writeExtractCache, } from "./extract-cache.js";
|
|
30
|
+
import { writeFingerprint } from "./fingerprint.js";
|
|
31
|
+
import { seedGraph } from "./seed.js";
|
|
32
|
+
import { filterByOnlyDirs, listSourceStats } from "./source-files.js";
|
|
33
|
+
import { resolveEdges } from "./resolve.js";
|
|
34
|
+
import { enrichGraph } from "./enrich.js";
|
|
35
|
+
import { readGraph, writeGraph, wiringPath } from "./write.js";
|
|
36
|
+
import { writeCards, writeIndex, writeCovers } from "./cards.js";
|
|
37
|
+
import { writeAskIndex } from "../ask/index-file.js";
|
|
38
|
+
import { discoverScopes, scopeOf } from "./scopes.js";
|
|
39
|
+
export { listSourceFiles } from "./source-files.js";
|
|
40
|
+
export function tierOf(path) {
|
|
41
|
+
const depth = languageOf(path);
|
|
42
|
+
if (depth) {
|
|
43
|
+
return depthReady(depth)
|
|
44
|
+
? { lang: depth, container: null, generic: null, fellBack: null }
|
|
45
|
+
: { lang: null, container: null, generic: fallbackLangOf(depth), fellBack: depth };
|
|
46
|
+
}
|
|
47
|
+
const container = containerLangOf(path);
|
|
48
|
+
if (container)
|
|
49
|
+
return { lang: null, container, generic: null, fellBack: null };
|
|
50
|
+
return { lang: null, container: null, generic: genericLangOf(path), fellBack: null };
|
|
51
|
+
}
|
|
52
|
+
/** Load every WASM grammar these files need, before a synchronous parse loop can
|
|
53
|
+
* call `extractFile`/`extractGeneric`/`extractContainer`: the depth tier's first
|
|
54
|
+
* (a container's embedded language included), then the breadth tier's, the
|
|
55
|
+
* containers', and the stand-ins for depth languages whose grammar didn't load. */
|
|
56
|
+
export async function warmGrammarsFor(paths) {
|
|
57
|
+
const list = [...paths];
|
|
58
|
+
const depth = new Set();
|
|
59
|
+
for (const path of list) {
|
|
60
|
+
const lang = languageOf(path) ?? containerLangOf(path)?.inner;
|
|
61
|
+
if (lang)
|
|
62
|
+
depth.add(lang);
|
|
63
|
+
}
|
|
64
|
+
await warmDepthGrammars(depth);
|
|
65
|
+
const generic = new Set();
|
|
66
|
+
const containers = new Set();
|
|
67
|
+
for (const path of list) {
|
|
68
|
+
const t = tierOf(path);
|
|
69
|
+
if (t.generic)
|
|
70
|
+
generic.add(t.generic.name);
|
|
71
|
+
if (t.container) {
|
|
72
|
+
containers.add(t.container.name);
|
|
73
|
+
if (!depthReady(t.container.inner))
|
|
74
|
+
generic.add(fallbackLangOf(t.container.inner).name);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
await warmGenericGrammars(generic);
|
|
78
|
+
await warmContainerGrammars(containers);
|
|
79
|
+
}
|
|
80
|
+
/** Minimum non-file node count for a discovered sub-scope to stand on its own
|
|
81
|
+
* (over-split guard 3). A scope with fewer nodes than this is folded into the
|
|
82
|
+
* root scope — node counts aren't known until after the graph is assembled,
|
|
83
|
+
* so this runs here rather than in `discoverScopes`. */
|
|
84
|
+
const MIN_SCOPE_NODES = 5;
|
|
85
|
+
/** Guard 5: merge scopes with too few non-file nodes into the root scope, then
|
|
86
|
+
* re-apply the canonical single-scope collapse (rule 6) if only root is left. */
|
|
87
|
+
function applyMinSubstanceGuard(scopes, nodes) {
|
|
88
|
+
if (scopes.length <= 1)
|
|
89
|
+
return scopes;
|
|
90
|
+
const counts = new Map();
|
|
91
|
+
for (const scope of scopes)
|
|
92
|
+
counts.set(scope.prefix, 0);
|
|
93
|
+
for (const node of nodes) {
|
|
94
|
+
if (node.kind === "file")
|
|
95
|
+
continue;
|
|
96
|
+
const scope = scopeOf(node.path, scopes);
|
|
97
|
+
counts.set(scope.prefix, (counts.get(scope.prefix) ?? 0) + 1);
|
|
98
|
+
}
|
|
99
|
+
const kept = scopes.filter((s) => s.prefix === "" || (counts.get(s.prefix) ?? 0) >= MIN_SCOPE_NODES);
|
|
100
|
+
if (kept.length === 0)
|
|
101
|
+
return [{ prefix: "", label: "", markers: [] }];
|
|
102
|
+
if (kept.length === 1 && kept[0].prefix === "") {
|
|
103
|
+
return [{ prefix: "", label: "", markers: kept[0].markers }];
|
|
104
|
+
}
|
|
105
|
+
return kept;
|
|
106
|
+
}
|
|
107
|
+
/** Every Go module in the repo: each `go.mod`'s declared `module` path and the repo
|
|
108
|
+
* directory it lives in (posix, `.` for the root). Found anywhere in the tree, so a
|
|
109
|
+
* monorepo whose module is in a subdir (e.g. `backend/go.mod`) resolves too. Lets edge
|
|
110
|
+
* resolution map Go import paths to in-repo files.
|
|
111
|
+
*
|
|
112
|
+
* `repoFiles` is buildGraph's single enumeration, which already carries root's
|
|
113
|
+
* persisted `--include-dir` override — so a `go.mod` living under an included
|
|
114
|
+
* dir (e.g. `build/go.mod`) is found here exactly when its `.go` files are
|
|
115
|
+
* indexed, and its intra-module imports resolve. */
|
|
116
|
+
function readGoModules(root, repoFiles) {
|
|
117
|
+
const mods = [];
|
|
118
|
+
for (const f of repoFiles) {
|
|
119
|
+
if (basename(f) !== "go.mod")
|
|
120
|
+
continue;
|
|
121
|
+
try {
|
|
122
|
+
const m = readFileSync(f, "utf8").match(/^\s*module\s+(\S+)/m);
|
|
123
|
+
if (!m)
|
|
124
|
+
continue;
|
|
125
|
+
const rel = relPosix(root, dirname(f));
|
|
126
|
+
mods.push({ module: m[1], dir: rel === "" ? "." : rel });
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
/* unreadable go.mod — skip this module */
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return mods;
|
|
133
|
+
}
|
|
134
|
+
export async function buildGraph(dir, opts = {}) {
|
|
135
|
+
const root = resolve(dir);
|
|
136
|
+
const outDir = contextDirFor(root, opts.contextDir);
|
|
137
|
+
// Enumerate once: source extraction, scope discovery, and Go module
|
|
138
|
+
// resolution must agree on the same Git-ignore-aware working-tree view —
|
|
139
|
+
// including the repo's persisted directory and submodule choices.
|
|
140
|
+
const walked = walkDir(root, readIncludeDirs(root), {
|
|
141
|
+
followSubmodules: readFollowSubmodules(root),
|
|
142
|
+
followNestedRepos: readFollowNestedRepos(root),
|
|
143
|
+
});
|
|
144
|
+
const onlyDirs = opts.onlyDirs && opts.onlyDirs.length > 0 ? new Set(opts.onlyDirs) : undefined;
|
|
145
|
+
const repoFiles = filterByOnlyDirs(walked, root, onlyDirs);
|
|
146
|
+
const files = listSourceStats(root, outDir, repoFiles);
|
|
147
|
+
const discoveredScopes = discoverScopes(root, repoFiles);
|
|
148
|
+
const nodes = [];
|
|
149
|
+
const rawEdges = [];
|
|
150
|
+
const sources = new Map();
|
|
151
|
+
/** Display labels, not grammars — `.mjs` is parsed as typescript but reported as
|
|
152
|
+
* javascript, or the banner claims a repo's JavaScript went unindexed. */
|
|
153
|
+
const langs = new Set();
|
|
154
|
+
const errors = [];
|
|
155
|
+
// In a git worktree there is nothing to reuse *yet* — `graft/` is gitignored, so
|
|
156
|
+
// git never checked it out — but the parent checkout's graph is one directory away.
|
|
157
|
+
// Copy it in before reading the priors below and this build is incremental and
|
|
158
|
+
// keeps its paid-for summaries, instead of being a cold parse of the whole repo.
|
|
159
|
+
// No-ops everywhere else, including on an explicit cold build (`reuse: false`).
|
|
160
|
+
const seed = opts.reuse === false ? { seeded: false } : seedGraph(root, { contextDir: opts.contextDir });
|
|
161
|
+
// Tier-1 memo: unchanged files replay their last parse. `entries` is rebuilt
|
|
162
|
+
// from scratch each run and keyed only by files currently on disk, so deletions
|
|
163
|
+
// fall out of both the cache and the fingerprint with no separate pruning pass.
|
|
164
|
+
const priorExtract = opts.reuse === false ? emptyExtractCache() : readExtractCache(outDir);
|
|
165
|
+
const entries = {};
|
|
166
|
+
let parsed = 0;
|
|
167
|
+
let reused = 0;
|
|
168
|
+
// Every tier's grammars are WASM and load asynchronously, so warm the ones this
|
|
169
|
+
// repo needs ONCE here (buildGraph is async) before the synchronous parse loop
|
|
170
|
+
// below can call extractFile/extractGeneric/extractContainer. A depth grammar
|
|
171
|
+
// that can't load gets its breadth stand-in warmed instead.
|
|
172
|
+
await warmGrammarsFor(files.map((f) => f.abs));
|
|
173
|
+
/** Languages whose files went to a stand-in: grammars for the fix, labels for people. */
|
|
174
|
+
const fellBack = new Set();
|
|
175
|
+
const fellBackLabels = new Set();
|
|
176
|
+
files.forEach((f, i) => {
|
|
177
|
+
const rel = f.rel;
|
|
178
|
+
opts.onProgress?.({ phase: "parse", index: i, total: files.length, file: rel });
|
|
179
|
+
const { lang, container, generic, fellBack: standIn } = tierOf(f.abs);
|
|
180
|
+
const label = isMdFile(f.abs) ? "markdown" : languageLabelOf(f.abs) ?? container?.name ?? generic?.name ?? "unknown";
|
|
181
|
+
// A .vue file's embedded script falls back the same way its language does.
|
|
182
|
+
const inner = container && !depthReady(container.inner) ? container.inner : null;
|
|
183
|
+
if (standIn) {
|
|
184
|
+
fellBack.add(standIn);
|
|
185
|
+
fellBackLabels.add(label);
|
|
186
|
+
}
|
|
187
|
+
if (inner) {
|
|
188
|
+
fellBack.add(inner);
|
|
189
|
+
fellBackLabels.add(inner);
|
|
190
|
+
}
|
|
191
|
+
// Which stand-in parsed this file, if one did. A cached parse is replayed only
|
|
192
|
+
// when the same parser would produce it now: otherwise a file parsed by the
|
|
193
|
+
// stand-in would keep its basic parse after a reinstall restored the native
|
|
194
|
+
// grammar, for as long as its bytes didn't change.
|
|
195
|
+
const via = standIn ? generic.name : inner ? fallbackLangOf(inner).name : undefined;
|
|
196
|
+
const cached = priorExtract.files[rel];
|
|
197
|
+
// Every file is read and hashed, every build — only the *parse* is memoized.
|
|
198
|
+
// The tempting optimization is to trust the probe's `(size, mtimeMs)` and skip
|
|
199
|
+
// the read too, but then `graft build` inherits the probe's blind spot: on a
|
|
200
|
+
// filesystem with coarse mtime granularity, a same-length edit inside the same
|
|
201
|
+
// second is invisible, so `graft check` reports drift (it always re-hashes) and
|
|
202
|
+
// the `graft build` it tells you to run refuses to repair it — forever. A stat
|
|
203
|
+
// may decide whether a *query* bothers rebuilding; it may not decide what the
|
|
204
|
+
// rebuild itself looks at. Reading is ~0.05ms/file against the ~4.6ms parse
|
|
205
|
+
// this still skips.
|
|
206
|
+
let source;
|
|
207
|
+
try {
|
|
208
|
+
source = readSourceFile(f.abs);
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
const message = `${rel}: ${err instanceof Error ? err.message : String(err)}`;
|
|
212
|
+
errors.push(message);
|
|
213
|
+
// Record it anyway (with the stat we do have) so the freshness probe's
|
|
214
|
+
// fast path doesn't report this file as new on every single query.
|
|
215
|
+
entries[rel] = { size: f.size, mtimeMs: f.mtimeMs, hash: "", nodes: [], rawEdges: [], error: message };
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (source === null) {
|
|
219
|
+
// Unsupported encoding (UTF-16BE) — a skip, never an error: recorded with
|
|
220
|
+
// an empty entry so the freshness probe doesn't treat it as new every run.
|
|
221
|
+
entries[rel] = { size: f.size, mtimeMs: f.mtimeMs, hash: "", nodes: [], rawEdges: [] };
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const hash = contentHash(source);
|
|
225
|
+
if (cached && hash === cached.hash && cached.via === via) {
|
|
226
|
+
entries[rel] = { ...cached, size: f.size, mtimeMs: f.mtimeMs };
|
|
227
|
+
sources.set(rel, source);
|
|
228
|
+
reused++;
|
|
229
|
+
if (cached.error) {
|
|
230
|
+
errors.push(cached.error); // this file failed to parse last time too
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
nodes.push(...cached.nodes);
|
|
234
|
+
rawEdges.push(...cached.rawEdges);
|
|
235
|
+
langs.add(label);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
parsed++;
|
|
239
|
+
try {
|
|
240
|
+
const mdNodes = isMdFile(f.abs) ? extractMd(f.abs, rel) : null;
|
|
241
|
+
const { nodes: fileNodes, rawEdges: fileEdges } = mdNodes
|
|
242
|
+
? { nodes: mdNodes, rawEdges: [] }
|
|
243
|
+
: lang
|
|
244
|
+
? extractFile(rel, source, lang)
|
|
245
|
+
: container
|
|
246
|
+
? extractContainer(rel, source, container)
|
|
247
|
+
: extractGeneric(rel, source, generic.name);
|
|
248
|
+
nodes.push(...fileNodes);
|
|
249
|
+
rawEdges.push(...fileEdges);
|
|
250
|
+
sources.set(rel, source);
|
|
251
|
+
langs.add(label);
|
|
252
|
+
entries[rel] = { size: f.size, mtimeMs: f.mtimeMs, hash, nodes: fileNodes, rawEdges: fileEdges, ...(via ? { via } : {}) };
|
|
253
|
+
}
|
|
254
|
+
catch (err) {
|
|
255
|
+
const message = `${rel}: parse failed — ${err instanceof Error ? err.message : String(err)}`;
|
|
256
|
+
errors.push(message);
|
|
257
|
+
entries[rel] = { size: f.size, mtimeMs: f.mtimeMs, hash, nodes: [], rawEdges: [], error: message, ...(via ? { via } : {}) };
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
// Persist the memo BEFORE enrichment, because `enrichGraph` mutates these very
|
|
261
|
+
// node objects (summary/crux/summary_state) and the cache must only ever hold
|
|
262
|
+
// pristine Tier-1 output — otherwise a replayed node would arrive pre-enriched
|
|
263
|
+
// and a cold build and an incremental build could disagree. The meaning layer
|
|
264
|
+
// has its own cache (wiring.json itself, keyed on body_hash); this one is
|
|
265
|
+
// strictly about not re-parsing.
|
|
266
|
+
writeExtractCache(outDir, {
|
|
267
|
+
...emptyExtractCache(),
|
|
268
|
+
files: entries,
|
|
269
|
+
});
|
|
270
|
+
const edges = resolveEdges(nodes, rawEdges, { goModules: readGoModules(root, repoFiles) });
|
|
271
|
+
// Guard 5 (minimum-substance): node counts aren't known until nodes are
|
|
272
|
+
// assembled, so the merge-tiny-scopes-into-root guard runs here.
|
|
273
|
+
const scopes = applyMinSubstanceGuard(discoveredScopes, nodes);
|
|
274
|
+
// Assemble the graph BEFORE the meaning pass, so the crux pass can checkpoint it to
|
|
275
|
+
// disk periodically (#128): crux/summary mutate node objects in place and never
|
|
276
|
+
// change the node/edge SET, so `meta` stays valid; the opt-in LSP pass below is the
|
|
277
|
+
// only thing that adds edges, and it runs before the final write.
|
|
278
|
+
const graph = {
|
|
279
|
+
meta: {
|
|
280
|
+
version: 1,
|
|
281
|
+
nodeCount: nodes.length,
|
|
282
|
+
edgeCount: edges.length,
|
|
283
|
+
languages: [...langs].sort(),
|
|
284
|
+
scopes,
|
|
285
|
+
},
|
|
286
|
+
nodes,
|
|
287
|
+
edges,
|
|
288
|
+
};
|
|
289
|
+
// graph.json is its own Tier-2 cache: fold in the prior meaning layer so an
|
|
290
|
+
// unchanged body is never re-summarized (and a Tier-1-only run never wipes it).
|
|
291
|
+
// Read BEFORE the first checkpoint can overwrite wiring.json.
|
|
292
|
+
const prior = readGraph(wiringPath(outDir));
|
|
293
|
+
const priorById = new Map((prior?.nodes ?? []).map((n) => [n.id, n]));
|
|
294
|
+
const meaning = await enrichGraph(nodes, priorById, sources, {
|
|
295
|
+
summarizer: opts.summarizer,
|
|
296
|
+
concurrency: opts.concurrency,
|
|
297
|
+
onProgress: ({ index, total, node }) => opts.onProgress?.({ phase: "enrich", index, total, file: node }),
|
|
298
|
+
// Periodic durability flush of partial crux; the next run folds it back in by
|
|
299
|
+
// body_hash, so an interrupted --deep run never repays the crux it computed.
|
|
300
|
+
checkpoint: () => writeGraph(graph, outDir),
|
|
301
|
+
});
|
|
302
|
+
errors.push(...meaning.errors);
|
|
303
|
+
// Opt-in compiler-grade enrichment (adds lsp_resolved call edges in place).
|
|
304
|
+
// Runs on the assembled graph so callee positions map back to nodes; never
|
|
305
|
+
// touches the extraction cache (Tier-1 stays pristine, cold==incremental).
|
|
306
|
+
if (opts.lsp) {
|
|
307
|
+
const { enrichWithLsp } = await import("./lsp/enrich.js");
|
|
308
|
+
const r = await enrichWithLsp(graph, root);
|
|
309
|
+
graph.meta.edgeCount = graph.edges.length;
|
|
310
|
+
opts.onProgress?.({ phase: "enrich", index: r.added, total: r.queried, file: `lsp:${r.server ?? "none"}` });
|
|
311
|
+
}
|
|
312
|
+
const graphPath = writeGraph(graph, outDir);
|
|
313
|
+
// `ask`'s token/IDF sidecar — moves per-query corpus tokenization to build
|
|
314
|
+
// time (~45% of query time on a 32k-node graph, profiled). Lives in the
|
|
315
|
+
// cache dir; `ask` falls back to live tokenization when it's absent/stale.
|
|
316
|
+
// Best-effort: wiring.json is already on disk at this point, so a sidecar
|
|
317
|
+
// write failure (e.g. an unwritable cache dir) must not abort cards/index/
|
|
318
|
+
// covers below — record it and keep going, same as other recoverable errors.
|
|
319
|
+
//
|
|
320
|
+
// MUST pass the in-memory `graph` here, never a re-read of wiringPath(outDir):
|
|
321
|
+
// `writeGraph` strips `body_text` from what it serializes (dead weight once
|
|
322
|
+
// this sidecar exists), so the nodes on disk no longer carry it — only this
|
|
323
|
+
// in-memory object, still holding what `extractFile` populated, does.
|
|
324
|
+
try {
|
|
325
|
+
writeAskIndex(outDir, graph);
|
|
326
|
+
}
|
|
327
|
+
catch (err) {
|
|
328
|
+
errors.push(`ask-index: ${err instanceof Error ? err.message : String(err)}`);
|
|
329
|
+
}
|
|
330
|
+
// The fingerprint claims exactly one thing: "the graph on disk was built from
|
|
331
|
+
// these source bytes." Nothing about the projections below — which is why it is
|
|
332
|
+
// safe to write here, and why `graphOnly` builds (the query path, which stops
|
|
333
|
+
// right after this line) are still recorded as fresh.
|
|
334
|
+
writeFingerprint(outDir, entries, opts.onlyDirs);
|
|
335
|
+
// Tier-2 passive surface: project the nodes into per-file markdown cards, and
|
|
336
|
+
// refresh the INDEX roster. Pure projection — no LLM, no network.
|
|
337
|
+
//
|
|
338
|
+
// Skipped entirely on the query path (`graphOnly`). Retrieval answers from
|
|
339
|
+
// wiring.json and the ask sidecar; the markdown surface is for humans and for
|
|
340
|
+
// the agent's own greps, and it is rebuilt by an explicit `graft build` — which
|
|
341
|
+
// is what the Claude Code `Stop` hook already runs at the end of a turn. Keeping
|
|
342
|
+
// it off the query path is what makes a refresh cheap, leaves the repo untouched
|
|
343
|
+
// (`ensureGitignored` writes `.gitignore`, which a read has no business doing),
|
|
344
|
+
// and means a failure here can never be triggered by a query.
|
|
345
|
+
let cardStats = { written: 0, pruned: 0, files: [] };
|
|
346
|
+
if (!opts.graphOnly) {
|
|
347
|
+
// The graph is a local, regenerable cache — make sure git ignores it. Cheap and
|
|
348
|
+
// idempotent, so a fresh clone's first build self-ignores.
|
|
349
|
+
ensureGitignored(root, outDir);
|
|
350
|
+
// …and that gitignoring it doesn't hide the cards from search: ripgrep honours
|
|
351
|
+
// .gitignore, so without this the cards can never be grepped, which is the one
|
|
352
|
+
// way an agent was supposed to stumble onto them.
|
|
353
|
+
ensureSearchable(root, outDir);
|
|
354
|
+
cardStats = writeCards(graph, outDir);
|
|
355
|
+
writeIndex(outDir, cardStats.files);
|
|
356
|
+
// Backfill concept nodes with their `covers:` symbol/file:line list (the
|
|
357
|
+
// OKF↔Wiring link). No-op when there are no concept nodes (a $0 build).
|
|
358
|
+
writeCovers(graph, outDir);
|
|
359
|
+
}
|
|
360
|
+
const byKind = {};
|
|
361
|
+
for (const n of nodes)
|
|
362
|
+
byKind[n.kind] = (byKind[n.kind] ?? 0) + 1;
|
|
363
|
+
const byRelation = {};
|
|
364
|
+
for (const e of edges)
|
|
365
|
+
byRelation[e.relation] = (byRelation[e.relation] ?? 0) + 1;
|
|
366
|
+
return {
|
|
367
|
+
contextDir: outDir,
|
|
368
|
+
graphPath,
|
|
369
|
+
cards: cardStats.written,
|
|
370
|
+
files: files.length,
|
|
371
|
+
parsed,
|
|
372
|
+
reused,
|
|
373
|
+
seededFrom: seed.from,
|
|
374
|
+
nodes: nodes.length,
|
|
375
|
+
edges: edges.length,
|
|
376
|
+
byKind,
|
|
377
|
+
byRelation,
|
|
378
|
+
languages: [...langs].sort(),
|
|
379
|
+
...(fellBack.size > 0
|
|
380
|
+
? { nativeFallback: { languages: [...fellBackLabels].sort(), packages: missingDepthPackages(fellBack) } }
|
|
381
|
+
: {}),
|
|
382
|
+
meaning,
|
|
383
|
+
errors,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/graph/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAA+B,MAAM,cAAc,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AACpH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAsB,MAAM,gBAAgB,CAAC;AAC9G,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB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AK,MAAM,CAAC,IAAI,KAAK;QAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,EAA8B,CAAC;IAClD,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAElF,OAAO;QACL,UAAU,EAAE,MAAM;QAClB,SAAS;QACT,KAAK,EAAE,SAAS,CAAC,OAAO;QACxB,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,MAAM;QACN,MAAM;QACN,UAAU,EAAE,IAAI,CAAC,IAAI;QACrB,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,MAAM;QACN,UAAU;QACV,SAAS,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE;QAC5B,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC;YACnB,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,CAAC,EAAE,EAAE;YACzG,CAAC,CAAC,EAAE,CAAC;QACP,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GraphV1 } from "./types.js";
|
|
2
|
+
export interface CardFileInfo {
|
|
3
|
+
/** Card path relative to the context dir, e.g. "src/ai/providers.md". */
|
|
4
|
+
card: string;
|
|
5
|
+
/** Source path the card mirrors, e.g. "src/ai/providers.ts". */
|
|
6
|
+
path: string;
|
|
7
|
+
symbols: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CardStats {
|
|
10
|
+
written: number;
|
|
11
|
+
pruned: number;
|
|
12
|
+
files: CardFileInfo[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Write one wiring card per source file into `outDir`, mirroring the source tree,
|
|
16
|
+
* and prune cards whose source no longer exists. Returns what changed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function writeCards(graph: GraphV1, outDir: string): CardStats;
|
|
19
|
+
/**
|
|
20
|
+
* Write `graft/INDEX.md` — the roster an agent `cat`s to orient. Lists the concept
|
|
21
|
+
* nodes on disk and the per-file cards. Deterministic order; no timestamps.
|
|
22
|
+
*/
|
|
23
|
+
export declare function writeIndex(outDir: string, files: CardFileInfo[]): void;
|
|
24
|
+
/** One symbol a concept node covers: its name, kind, and `path:span` pointer. */
|
|
25
|
+
export interface CoverRef {
|
|
26
|
+
symbol: string;
|
|
27
|
+
kind: string;
|
|
28
|
+
/** `src/ai/providers.ts:L28-L35` — same vocabulary `graft ask` returns. */
|
|
29
|
+
at: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Backfill each concept node's frontmatter with a `covers:` list — the symbols
|
|
33
|
+
* (and their exact `file:line`) it spans, read from the wiring graph. This is the
|
|
34
|
+
* explicit OKF↔Wiring link: it doubles as grep bait (a `grep <symbol>` lands on
|
|
35
|
+
* the prose node, not just its card) and lets an agent read the span straight
|
|
36
|
+
* from the node without ever opening `wiring.json`.
|
|
37
|
+
*
|
|
38
|
+
* A surgical frontmatter patch: the generated body and every other key are
|
|
39
|
+
* preserved verbatim; only `covers` is added/replaced. Concept nodes are the
|
|
40
|
+
* top-level `.md` files that carry a `slug` (cards live in subdirs, or at the
|
|
41
|
+
* top level without a slug when they mirror a root source; INDEX.md is skipped).
|
|
42
|
+
* On a $0 structure-only build there are no concept nodes, so this is a no-op.
|
|
43
|
+
* Returns the number of nodes enriched.
|
|
44
|
+
*/
|
|
45
|
+
export declare function writeCovers(graph: GraphV1, outDir: string): number;
|
|
46
|
+
//# sourceMappingURL=cards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/graph/cards.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,YAAY,CAAC;AAgBlD,MAAM,WAAW,YAAY;IAC3B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AA6HD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAgCpE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,CA0CtE;AAED,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,2EAA2E;IAC3E,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAuClE"}
|