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,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marker-fenced section upsert. Graft owns exactly the region between the
|
|
3
|
+
* markers; everything else in the file belongs to the user and is preserved.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
6
|
+
import { dirname } from 'node:path';
|
|
7
|
+
export const START = '<!-- graft:start -->';
|
|
8
|
+
export const END = '<!-- graft:end -->';
|
|
9
|
+
/** The same block in a repo wired by trail. */
|
|
10
|
+
export const TRAIL_START = '<!-- trail:start -->';
|
|
11
|
+
export const TRAIL_END = '<!-- trail:end -->';
|
|
12
|
+
/**
|
|
13
|
+
* A brain's rules go in their OWN fenced block, not inside the instruction
|
|
14
|
+
* block above.
|
|
15
|
+
*
|
|
16
|
+
* They have to be separately addressable: the instruction body is static and
|
|
17
|
+
* rewritten by `init`, while rules change whenever the brain does and are
|
|
18
|
+
* refreshed on their own. One pair of markers for both would mean every rules
|
|
19
|
+
* refresh rewrites the instructions too, and `graft uninstall` could not remove
|
|
20
|
+
* one without the other.
|
|
21
|
+
*/
|
|
22
|
+
export const BRAIN_START = '<!-- graft:brain:start -->';
|
|
23
|
+
export const BRAIN_END = '<!-- graft:brain:end -->';
|
|
24
|
+
export const GRAFT_MARKERS = { start: START, end: END };
|
|
25
|
+
export const TRAIL_MARKERS = { start: TRAIL_START, end: TRAIL_END };
|
|
26
|
+
export const BRAIN_MARKERS = { start: BRAIN_START, end: BRAIN_END };
|
|
27
|
+
/** Every managed region graft may own in a user-owned file. */
|
|
28
|
+
export const ALL_MARKERS = [GRAFT_MARKERS, TRAIL_MARKERS, BRAIN_MARKERS];
|
|
29
|
+
/** The instruction block's markers under each name. */
|
|
30
|
+
export function markersFor(name) {
|
|
31
|
+
return name === 'trail' ? TRAIL_MARKERS : GRAFT_MARKERS;
|
|
32
|
+
}
|
|
33
|
+
export function fencedBlock(body, eol = '\n', markers = GRAFT_MARKERS) {
|
|
34
|
+
// Normalize any pre-existing '\r' out of the body first so callers passing
|
|
35
|
+
// a CRLF (or stray-CR) body never get doubled '\r' when eol is '\r\n'.
|
|
36
|
+
const normalizedBody = body.replace(/\r/g, '');
|
|
37
|
+
const block = `${markers.start}\n${normalizedBody.replace(/\s+$/, '')}\n${markers.end}`;
|
|
38
|
+
return eol === '\n' ? block : block.replace(/\n/g, '\r\n');
|
|
39
|
+
}
|
|
40
|
+
/** The file's dominant line ending: CRLF if any '\r\n' is present, else LF. */
|
|
41
|
+
function detectEol(text) {
|
|
42
|
+
return text.includes('\r\n') ? '\r\n' : '\n';
|
|
43
|
+
}
|
|
44
|
+
/** Index of a marker that sits alone on its own line, or -1. */
|
|
45
|
+
function markerLineIndex(lines, marker, from = 0) {
|
|
46
|
+
for (let i = from; i < lines.length; i++) {
|
|
47
|
+
if (lines[i].trim() === marker)
|
|
48
|
+
return i;
|
|
49
|
+
}
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
/** The start and end line of the block fenced by `markers`, or null. */
|
|
53
|
+
function blockSpan(lines, markers) {
|
|
54
|
+
const s = markerLineIndex(lines, markers.start);
|
|
55
|
+
const e = s === -1 ? -1 : markerLineIndex(lines, markers.end, s + 1);
|
|
56
|
+
return s !== -1 && e !== -1 ? { s, e } : null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `lines` without the block at `sp`, and the blank line that set it off: the
|
|
60
|
+
* one after it, or else the one before it. The file's final newline stays.
|
|
61
|
+
*/
|
|
62
|
+
function withoutBlock(lines, sp) {
|
|
63
|
+
const blank = (i) => i >= 0 && i < lines.length && lines[i].trim() === '';
|
|
64
|
+
let { s, e } = sp;
|
|
65
|
+
if (blank(e + 1) && e + 1 < lines.length - 1)
|
|
66
|
+
e++;
|
|
67
|
+
else if (blank(s - 1))
|
|
68
|
+
s--;
|
|
69
|
+
return [...lines.slice(0, s), ...lines.slice(e + 1)];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Write `body` into the block fenced by `markers`, keeping the rest of the file.
|
|
73
|
+
*
|
|
74
|
+
* `replaces` names blocks this one supersedes: a repo moving from graft's
|
|
75
|
+
* names to trail's has a `graft:start` block where the `trail:start` one
|
|
76
|
+
* goes. The block takes the place of its own markers if they're there, or of
|
|
77
|
+
* the first superseded block, and any other superseded block goes, so the
|
|
78
|
+
* file never ends up with both.
|
|
79
|
+
*/
|
|
80
|
+
export function upsertSection(filePath, body, markers = GRAFT_MARKERS, replaces = []) {
|
|
81
|
+
if (!existsSync(filePath)) {
|
|
82
|
+
const block = fencedBlock(body, '\n', markers);
|
|
83
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
84
|
+
writeFileSync(filePath, `${block}\n`);
|
|
85
|
+
return { action: 'created' };
|
|
86
|
+
}
|
|
87
|
+
const text = readFileSync(filePath, 'utf8');
|
|
88
|
+
const eol = detectEol(text);
|
|
89
|
+
// Split on either eol so lines never carry an embedded '\r' — that keeps
|
|
90
|
+
// the marker/content comparison clean and lets us rejoin deliberately with
|
|
91
|
+
// the detected eol instead of relying on '\r' characters riding along
|
|
92
|
+
// inside array elements (which broke down whenever the block-with-no-
|
|
93
|
+
// trailing-'\r' element sat next to a '\n' join, e.g. right after END, or
|
|
94
|
+
// when the block was the entire file).
|
|
95
|
+
const lines = text.split(/\r\n|\n/);
|
|
96
|
+
const s = markerLineIndex(lines, markers.start);
|
|
97
|
+
const e = s === -1 ? -1 : markerLineIndex(lines, markers.end, s + 1);
|
|
98
|
+
const superseded = replaces.map((m) => blockSpan(lines, m)).filter((sp) => sp !== null);
|
|
99
|
+
if (superseded.length > 0) {
|
|
100
|
+
const own = s !== -1 && e !== -1 ? { s, e } : null;
|
|
101
|
+
const at = own ?? superseded[0];
|
|
102
|
+
// Bottom up, so the line numbers of the blocks above stay true.
|
|
103
|
+
let next = lines;
|
|
104
|
+
for (const sp of [...(own ? [own] : []), ...superseded].sort((a, b) => b.s - a.s)) {
|
|
105
|
+
next = sp === at
|
|
106
|
+
? [...next.slice(0, sp.s), ...fencedBlock(body, '\n', markers).split('\n'), ...next.slice(sp.e + 1)]
|
|
107
|
+
: withoutBlock(next, sp);
|
|
108
|
+
}
|
|
109
|
+
writeFileSync(filePath, next.join(eol));
|
|
110
|
+
return { action: 'replaced' };
|
|
111
|
+
}
|
|
112
|
+
if (s !== -1 && e !== -1) {
|
|
113
|
+
const current = lines.slice(s, e + 1).join('\n');
|
|
114
|
+
if (current === fencedBlock(body, '\n', markers))
|
|
115
|
+
return { action: 'unchanged' };
|
|
116
|
+
const block = fencedBlock(body, eol, markers);
|
|
117
|
+
const next = [...lines.slice(0, s), ...block.split(eol), ...lines.slice(e + 1)];
|
|
118
|
+
writeFileSync(filePath, next.join(eol));
|
|
119
|
+
return { action: 'replaced' };
|
|
120
|
+
}
|
|
121
|
+
const block = fencedBlock(body, eol, markers);
|
|
122
|
+
const doubleEol = eol + eol;
|
|
123
|
+
const sep = text.endsWith(doubleEol) ? '' : text.endsWith(eol) ? eol : doubleEol;
|
|
124
|
+
writeFileSync(filePath, `${text}${sep}${block}${eol}`);
|
|
125
|
+
return { action: 'appended' };
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.js","sourceRoot":"","sources":["../../src/hosts/sections.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E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MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACjF,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC;IACvD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graft — public API.
|
|
3
|
+
*
|
|
4
|
+
* The graph is a folder of linked markdown files (`.context/`) committed to the
|
|
5
|
+
* repo. Build it from code, then check it stays in sync.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Graft } from "@nanonets/graft";
|
|
10
|
+
*
|
|
11
|
+
* const engine = new Graft();
|
|
12
|
+
* await engine.init("."); // writes .context/*.md + manifest.json
|
|
13
|
+
*
|
|
14
|
+
* const result = engine.check("."); // { ok: boolean, ...drift }
|
|
15
|
+
* if (!result.ok) process.exitCode = 1;
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { Graft, CODE_EXTENSIONS } from "./engine.js";
|
|
19
|
+
export type { InitOptions, CheckRunOptions, BuildResult, BuildProgress, CheckResult } from "./engine.js";
|
|
20
|
+
export { buildContext } from "./context/build.js";
|
|
21
|
+
export type { BuildOptions } from "./context/build.js";
|
|
22
|
+
export { checkContext, formatCheckReport } from "./context/check.js";
|
|
23
|
+
export type { CheckOptions } from "./context/check.js";
|
|
24
|
+
export { checkGraph, formatGraphCheckReport } from "./graph/check.js";
|
|
25
|
+
export type { GraphCheckResult, GraphCheckOptions } from "./graph/check.js";
|
|
26
|
+
export type { ContextNode, NodeLink, SourceRef, Manifest } from "./context/node-file.js";
|
|
27
|
+
export type { EngineConfig, ResolvedConfig } from "./ai/providers.js";
|
|
28
|
+
export { resolveConfig, DEFAULTS, DEFAULT_MODELS } from "./ai/providers.js";
|
|
29
|
+
export type { ChatModel, ChatRequest, ChatResponse, Message, ToolSpec, ToolCall, Usage } from "./ai/llm/types.js";
|
|
30
|
+
export { createChatModel, type ProviderKind, type ChatModelConfig } from "./ai/llm/factory.js";
|
|
31
|
+
export { OpenAIChatModel } from "./ai/llm/openai.js";
|
|
32
|
+
export { AnthropicChatModel } from "./ai/llm/anthropic.js";
|
|
33
|
+
export { LiteLLMChatModel, listLiteLLMModels, DEFAULT_LITELLM_BASE_URL } from "./ai/llm/litellm.js";
|
|
34
|
+
export { OrcaRouterChatModel, listOrcaRouterModels, DEFAULT_ORCAROUTER_BASE_URL } from "./ai/llm/orcarouter.js";
|
|
35
|
+
export { ChatSynthesizer } from "./ai/synthesize.js";
|
|
36
|
+
export type { Synthesizer, SynthNode, SynthLink, FileSummary } from "./ai/synthesize.js";
|
|
37
|
+
export { ChatSummarizer } from "./ai/summarize.js";
|
|
38
|
+
export type { Summarizer } from "./ai/summarize.js";
|
|
39
|
+
export { ChatCruxSummarizer } from "./ai/crux.js";
|
|
40
|
+
export type { CruxSummarizer, FileCruxInput, NodeCrux, NodeRef } from "./ai/crux.js";
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,MAAM,oBA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AkB,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graft — public API.
|
|
3
|
+
*
|
|
4
|
+
* The graph is a folder of linked markdown files (`.context/`) committed to the
|
|
5
|
+
* repo. Build it from code, then check it stays in sync.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Graft } from "@nanonets/graft";
|
|
10
|
+
*
|
|
11
|
+
* const engine = new Graft();
|
|
12
|
+
* await engine.init("."); // writes .context/*.md + manifest.json
|
|
13
|
+
*
|
|
14
|
+
* const result = engine.check("."); // { ok: boolean, ...drift }
|
|
15
|
+
* if (!result.ok) process.exitCode = 1;
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { Graft, CODE_EXTENSIONS } from "./engine.js";
|
|
19
|
+
export { buildContext } from "./context/build.js";
|
|
20
|
+
export { checkContext, formatCheckReport } from "./context/check.js";
|
|
21
|
+
export { checkGraph, formatGraphCheckReport } from "./graph/check.js";
|
|
22
|
+
export { resolveConfig, DEFAULTS, DEFAULT_MODELS } from "./ai/providers.js";
|
|
23
|
+
export { createChatModel } from "./ai/llm/factory.js";
|
|
24
|
+
export { OpenAIChatModel } from "./ai/llm/openai.js";
|
|
25
|
+
export { AnthropicChatModel } from "./ai/llm/anthropic.js";
|
|
26
|
+
export { LiteLLMChatModel, listLiteLLMModels, DEFAULT_LITELLM_BASE_URL } from "./ai/llm/litellm.js";
|
|
27
|
+
export { OrcaRouterChatModel, listOrcaRouterModels, DEFAULT_ORCAROUTER_BASE_URL } from "./ai/llm/orcarouter.js";
|
|
28
|
+
// Engine ops, for advanced/custom setups.
|
|
29
|
+
export { ChatSynthesizer } from "./ai/synthesize.js";
|
|
30
|
+
export { ChatSummarizer } from "./ai/summarize.js";
|
|
31
|
+
export { ChatCruxSummarizer } from "./ai/crux.js";
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAKtE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAI5E,OAAO,EAAE,eAAe,EAA2C,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAEhH,0CAA0C;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** Directories that are dependency/build output, never source. */
|
|
2
|
+
export declare const SKIP_DIRS: Set<string>;
|
|
3
|
+
/** Files above this size are generated/vendored in practice, not hand-written code. */
|
|
4
|
+
export declare const MAX_FILE_BYTES = 1000000;
|
|
5
|
+
/**
|
|
6
|
+
* Whether a directory named `name` should be skipped when walking a repo tree:
|
|
7
|
+
* any dot-prefixed directory (`.git`, `.github`, `.vscode`, ...) or one of
|
|
8
|
+
* {@link SKIP_DIRS} not named in `includes`. The single source of truth for
|
|
9
|
+
* "is this dir source" — `skippedPath` and `walkFilesystem` below and the
|
|
10
|
+
* git-child discovery in `graph/scopes.ts` share it, so they can never
|
|
11
|
+
* independently drift on what counts as skippable.
|
|
12
|
+
*
|
|
13
|
+
* `includes` is the explicit, per-repo `graft build --include-dir` override
|
|
14
|
+
* (persisted via `util/state.ts`'s `readIncludeDirs`, threaded in by each
|
|
15
|
+
* caller) — a name in it is removed from the effective skip set for THIS
|
|
16
|
+
* repo's walks. Absent/empty ≡ today's default behavior. It lifts only
|
|
17
|
+
* graft's own skip list: in a Git repo, Git's ignore rules stay authoritative
|
|
18
|
+
* (see {@link walkDir}).
|
|
19
|
+
*
|
|
20
|
+
* KNOWN LIMITATION: a dot-directory is skipped WHOLESALE and is NEVER
|
|
21
|
+
* overridable, even via `includes` — unlike `SKIP_DIRS`, there is no path to
|
|
22
|
+
* un-skip one. A repo that keeps real, hand-written source under a
|
|
23
|
+
* dot-prefixed directory is out of scope.
|
|
24
|
+
*/
|
|
25
|
+
export declare function shouldSkipDir(name: string, includes?: ReadonlySet<string>): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Recursively list all files under a directory. Skips dot-directories,
|
|
28
|
+
* dependency/build directories (node_modules, dist, …) not named in
|
|
29
|
+
* `includes`, and files over 1 MB.
|
|
30
|
+
* In a Git worktree, tracked files plus untracked, non-ignored files come from
|
|
31
|
+
* `git ls-files`; this gives indexing exactly Git's nested `.gitignore`,
|
|
32
|
+
* negation, and global-exclude semantics. Non-Git directories retain the plain
|
|
33
|
+
* filesystem walk. `includes` lifts only the built-in skip list — it never
|
|
34
|
+
* overrides Git's ignore rules (un-ignore or `git add -f` a directory to
|
|
35
|
+
* index it, the same contract as tracked-but-ignored files).
|
|
36
|
+
*
|
|
37
|
+
* Two INDEPENDENT opt-ins cross the repository boundary, because Git models two
|
|
38
|
+
* different relationships and only one of them is a dependency the parent pins:
|
|
39
|
+
*
|
|
40
|
+
* - `followSubmodules` follows a GITLINK — an index entry with mode `160000`,
|
|
41
|
+
* a commit the superproject versions.
|
|
42
|
+
* - `followNestedRepos` follows a nested clone the parent's index knows
|
|
43
|
+
* nothing about. Manifest-driven multi-repo tools (west, repo, gclient,
|
|
44
|
+
* tsrc, mr, …) all check dependencies out this way, and so does anyone who
|
|
45
|
+
* clones an upstream into the tree to patch it locally.
|
|
46
|
+
*
|
|
47
|
+
* Both default to false, preserving the historical superproject boundary. Each
|
|
48
|
+
* child keeps its own ignore rules; uninitialized submodules and gitignored
|
|
49
|
+
* nested clones remain absent either way (`--exclude-standard` never emits
|
|
50
|
+
* them, so there is nothing to follow).
|
|
51
|
+
*/
|
|
52
|
+
export interface WalkOptions {
|
|
53
|
+
/** Include initialized Git submodules (gitlinks) recursively. Default false. */
|
|
54
|
+
followSubmodules?: boolean;
|
|
55
|
+
/** Include nested Git clones the parent index does not track. Default false. */
|
|
56
|
+
followNestedRepos?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Directory `walkDir` actually enumerates.
|
|
60
|
+
*
|
|
61
|
+
* `path.resolve` does not follow a symlink, and git discovers the repo from the
|
|
62
|
+
* child cwd. Unwrap a symlink-to-directory once so the walk runs inside the
|
|
63
|
+
* target. Ordinary directories stay as `resolve(dir)` — not `realpath` — so a
|
|
64
|
+
* macOS `/var/folders/…` scratch path is the path the caller handed us.
|
|
65
|
+
*
|
|
66
|
+
* A broken symlink throws instead of the `scandir ENOENT` `readdirSync` would
|
|
67
|
+
* raise after git fails. Internal symlink policy is not decided here.
|
|
68
|
+
*/
|
|
69
|
+
export declare function canonicalWalkRoot(dir: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Recursively list source files under `dir`. A directory symlink as the *input
|
|
72
|
+
* root* is unwrapped once ({@link canonicalWalkRoot}); emitted paths are remapped
|
|
73
|
+
* onto the caller-facing root so `relPosix` stays `src/foo.ts` rather than a
|
|
74
|
+
* `../` escape through the physical path (macOS `/tmp` → `/private/tmp`).
|
|
75
|
+
* Symlinks *inside* the tree are not followed: git still `lstat`s each listed
|
|
76
|
+
* path, and the filesystem walk still requires `Dirent.isFile` / `isDirectory`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function walkDir(dir: string, includes?: ReadonlySet<string>, opts?: WalkOptions): string[];
|
|
79
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/ingest/fs.ts"],"names":[],"mappings":"AAQA,kEAAkE;AAClE,eAAO,MAAM,SAAS,aAgBpB,CAAC;AAEH,uFAAuF;AACvF,eAAO,MAAM,cAAc,UAAY,CAAC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAInF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gFAAgF;IAChF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA0BrD;AAoBD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAC9B,IAAI,GAAE,WAAgB,GACrB,MAAM,EAAE,CAKV"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem walking used by `init`/`check` to enumerate a repo's source files.
|
|
3
|
+
*/
|
|
4
|
+
import { WINHIDE } from "../util/child-process.js";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { existsSync, lstatSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
7
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
|
+
/** Directories that are dependency/build output, never source. */
|
|
9
|
+
export const SKIP_DIRS = new Set([
|
|
10
|
+
"node_modules",
|
|
11
|
+
"dist",
|
|
12
|
+
"build",
|
|
13
|
+
// The underscore spelling that Sphinx, CMake, Jekyll and the OCaml tools all
|
|
14
|
+
// emit. Left out, a materialized build tree lands in the graph as ordinary
|
|
15
|
+
// source: one repo here indexed 4,484 files of vendored WordPress against 121
|
|
16
|
+
// hand-written ones, and queries slowed enough that the prompt hook's budget
|
|
17
|
+
// could no longer fit them. `--include-dir _build` remains the way back in.
|
|
18
|
+
"_build",
|
|
19
|
+
"out",
|
|
20
|
+
"target",
|
|
21
|
+
"vendor",
|
|
22
|
+
"coverage",
|
|
23
|
+
"__pycache__",
|
|
24
|
+
"venv",
|
|
25
|
+
]);
|
|
26
|
+
/** Files above this size are generated/vendored in practice, not hand-written code. */
|
|
27
|
+
export const MAX_FILE_BYTES = 1_000_000;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a directory named `name` should be skipped when walking a repo tree:
|
|
30
|
+
* any dot-prefixed directory (`.git`, `.github`, `.vscode`, ...) or one of
|
|
31
|
+
* {@link SKIP_DIRS} not named in `includes`. The single source of truth for
|
|
32
|
+
* "is this dir source" — `skippedPath` and `walkFilesystem` below and the
|
|
33
|
+
* git-child discovery in `graph/scopes.ts` share it, so they can never
|
|
34
|
+
* independently drift on what counts as skippable.
|
|
35
|
+
*
|
|
36
|
+
* `includes` is the explicit, per-repo `graft build --include-dir` override
|
|
37
|
+
* (persisted via `util/state.ts`'s `readIncludeDirs`, threaded in by each
|
|
38
|
+
* caller) — a name in it is removed from the effective skip set for THIS
|
|
39
|
+
* repo's walks. Absent/empty ≡ today's default behavior. It lifts only
|
|
40
|
+
* graft's own skip list: in a Git repo, Git's ignore rules stay authoritative
|
|
41
|
+
* (see {@link walkDir}).
|
|
42
|
+
*
|
|
43
|
+
* KNOWN LIMITATION: a dot-directory is skipped WHOLESALE and is NEVER
|
|
44
|
+
* overridable, even via `includes` — unlike `SKIP_DIRS`, there is no path to
|
|
45
|
+
* un-skip one. A repo that keeps real, hand-written source under a
|
|
46
|
+
* dot-prefixed directory is out of scope.
|
|
47
|
+
*/
|
|
48
|
+
export function shouldSkipDir(name, includes) {
|
|
49
|
+
if (name.startsWith("."))
|
|
50
|
+
return true;
|
|
51
|
+
if (includes?.has(name))
|
|
52
|
+
return false;
|
|
53
|
+
return SKIP_DIRS.has(name);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Directory `walkDir` actually enumerates.
|
|
57
|
+
*
|
|
58
|
+
* `path.resolve` does not follow a symlink, and git discovers the repo from the
|
|
59
|
+
* child cwd. Unwrap a symlink-to-directory once so the walk runs inside the
|
|
60
|
+
* target. Ordinary directories stay as `resolve(dir)` — not `realpath` — so a
|
|
61
|
+
* macOS `/var/folders/…` scratch path is the path the caller handed us.
|
|
62
|
+
*
|
|
63
|
+
* A broken symlink throws instead of the `scandir ENOENT` `readdirSync` would
|
|
64
|
+
* raise after git fails. Internal symlink policy is not decided here.
|
|
65
|
+
*/
|
|
66
|
+
export function canonicalWalkRoot(dir) {
|
|
67
|
+
const abs = resolve(dir);
|
|
68
|
+
let st;
|
|
69
|
+
try {
|
|
70
|
+
st = lstatSync(abs);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return abs;
|
|
74
|
+
}
|
|
75
|
+
if (!st.isSymbolicLink())
|
|
76
|
+
return abs;
|
|
77
|
+
let real;
|
|
78
|
+
try {
|
|
79
|
+
real = realpathSync(abs);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const code = err && typeof err === "object" && "code" in err ? String(err.code) : "";
|
|
83
|
+
if (code === "ELOOP")
|
|
84
|
+
throw new Error(`symbolic link loop: ${abs}`);
|
|
85
|
+
throw new Error(`broken symbolic link: ${abs}`);
|
|
86
|
+
}
|
|
87
|
+
let realSt;
|
|
88
|
+
try {
|
|
89
|
+
realSt = statSync(real);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
throw new Error(`broken symbolic link: ${abs}`);
|
|
93
|
+
}
|
|
94
|
+
if (!realSt.isDirectory())
|
|
95
|
+
return abs;
|
|
96
|
+
return real;
|
|
97
|
+
}
|
|
98
|
+
function escapedCanonical(canonical, abs) {
|
|
99
|
+
const rel = relative(canonical, abs);
|
|
100
|
+
return rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel);
|
|
101
|
+
}
|
|
102
|
+
/** Keep emitted paths on the requested root so relative paths stay stable. */
|
|
103
|
+
function remapWalkPaths(requested, canonical, files) {
|
|
104
|
+
if (requested === canonical)
|
|
105
|
+
return files;
|
|
106
|
+
const out = [];
|
|
107
|
+
for (const abs of files) {
|
|
108
|
+
if (escapedCanonical(canonical, abs))
|
|
109
|
+
continue;
|
|
110
|
+
const rel = relative(canonical, abs);
|
|
111
|
+
if (rel === "")
|
|
112
|
+
continue;
|
|
113
|
+
out.push(join(requested, rel));
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Recursively list source files under `dir`. A directory symlink as the *input
|
|
119
|
+
* root* is unwrapped once ({@link canonicalWalkRoot}); emitted paths are remapped
|
|
120
|
+
* onto the caller-facing root so `relPosix` stays `src/foo.ts` rather than a
|
|
121
|
+
* `../` escape through the physical path (macOS `/tmp` → `/private/tmp`).
|
|
122
|
+
* Symlinks *inside* the tree are not followed: git still `lstat`s each listed
|
|
123
|
+
* path, and the filesystem walk still requires `Dirent.isFile` / `isDirectory`.
|
|
124
|
+
*/
|
|
125
|
+
export function walkDir(dir, includes, opts = {}) {
|
|
126
|
+
const requested = resolve(dir);
|
|
127
|
+
const root = canonicalWalkRoot(requested);
|
|
128
|
+
const files = gitVisibleFiles(root, includes, opts) ?? walkFilesystem(root, includes);
|
|
129
|
+
return remapWalkPaths(requested, root, files);
|
|
130
|
+
}
|
|
131
|
+
/** Git's canonical working-tree file set, relative to `dir`. Tracked files are
|
|
132
|
+
* deliberately included even when a later ignore rule matches them; `.gitignore`
|
|
133
|
+
* only controls untracked files in Git, and graft follows the same contract. */
|
|
134
|
+
function gitVisibleFiles(dir, includes, opts = {}, traversal) {
|
|
135
|
+
const root = resolve(dir);
|
|
136
|
+
// The recursive path costs an extra `-t --stage` classification, so take it
|
|
137
|
+
// only when at least one boundary-crossing opt-in is on. With both off the
|
|
138
|
+
// walk is byte-for-byte the historical one.
|
|
139
|
+
if (opts.followSubmodules !== true && opts.followNestedRepos !== true) {
|
|
140
|
+
return gitVisibleFilesShallow(root, includes);
|
|
141
|
+
}
|
|
142
|
+
const state = traversal ?? { topRoot: root, activeRoots: new Set() };
|
|
143
|
+
const rootKey = process.platform === "win32" ? root.toLowerCase() : root;
|
|
144
|
+
if (state.activeRoots.has(rootKey))
|
|
145
|
+
return [];
|
|
146
|
+
state.activeRoots.add(rootKey);
|
|
147
|
+
// Following uses `-t --stage` so one process can distinguish gitlinks from
|
|
148
|
+
// tracked and untracked files. `-z` keeps either form safe for unusual paths.
|
|
149
|
+
const result = spawnSync("git", ["ls-files", "-t", "--stage", "--cached", "--others", "--exclude-standard", "-z", "--"], { ...WINHIDE, cwd: root,
|
|
150
|
+
encoding: "utf8",
|
|
151
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
152
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
153
|
+
});
|
|
154
|
+
if (result.status !== 0 || result.error || typeof result.stdout !== "string") {
|
|
155
|
+
state.activeRoots.delete(rootKey);
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
// A path can have multiple stage records during a merge. Collapse those
|
|
159
|
+
// records and remember if any of them identifies the path as a gitlink or as
|
|
160
|
+
// a nested-clone boundary.
|
|
161
|
+
const entries = new Map();
|
|
162
|
+
for (const record of result.stdout.split("\0")) {
|
|
163
|
+
if (!record)
|
|
164
|
+
continue;
|
|
165
|
+
if (record.length < 2 || record[1] !== " ")
|
|
166
|
+
continue;
|
|
167
|
+
const tag = record[0];
|
|
168
|
+
const body = record.slice(2);
|
|
169
|
+
let rel;
|
|
170
|
+
let gitlink = false;
|
|
171
|
+
let nested = false;
|
|
172
|
+
if (tag === "?") {
|
|
173
|
+
rel = body;
|
|
174
|
+
// Git refuses to descend into a repository it does not own, so `--others`
|
|
175
|
+
// collapses a nested clone to ONE trailing-slash directory entry while
|
|
176
|
+
// every other untracked directory is expanded file by file. That slash is
|
|
177
|
+
// the boundary marker — free, since this is the enumeration we already ran.
|
|
178
|
+
if (rel.endsWith("/")) {
|
|
179
|
+
nested = true;
|
|
180
|
+
rel = rel.slice(0, -1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const tab = body.indexOf("\t");
|
|
185
|
+
if (tab === -1)
|
|
186
|
+
continue;
|
|
187
|
+
gitlink = body.startsWith("160000 ");
|
|
188
|
+
rel = body.slice(tab + 1);
|
|
189
|
+
}
|
|
190
|
+
if (!rel)
|
|
191
|
+
continue;
|
|
192
|
+
const prior = entries.get(rel);
|
|
193
|
+
entries.set(rel, {
|
|
194
|
+
gitlink: gitlink || prior?.gitlink === true,
|
|
195
|
+
nested: nested || prior?.nested === true,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const out = new Set();
|
|
199
|
+
for (const [rel, entry] of entries) {
|
|
200
|
+
const abs = resolve(root, rel);
|
|
201
|
+
// Filter against the original superproject path. Otherwise a submodule
|
|
202
|
+
// mounted at vendor/ or build/ would bypass the parent's skip policy when
|
|
203
|
+
// recursion resets its relative root.
|
|
204
|
+
if (skippedPath(relative(state.topRoot, abs), includes))
|
|
205
|
+
continue;
|
|
206
|
+
const followChild = (entry.gitlink && opts.followSubmodules === true) ||
|
|
207
|
+
(entry.nested && opts.followNestedRepos === true);
|
|
208
|
+
if (followChild) {
|
|
209
|
+
// A deinitialized gitlink can resolve upward to the superproject when Git
|
|
210
|
+
// runs inside it, and a nested-looking directory may have no repo at all.
|
|
211
|
+
// Requiring the child's own .git prevents duplicate, mis-prefixed parent
|
|
212
|
+
// files and recursive loops.
|
|
213
|
+
if (!existsSync(join(abs, ".git")))
|
|
214
|
+
continue;
|
|
215
|
+
let childFiles = gitVisibleFiles(abs, includes, opts, state);
|
|
216
|
+
if (childFiles === null) {
|
|
217
|
+
// Do not let one broken child recreate a "healthy but incomplete"
|
|
218
|
+
// graph. Match the top-level fail-soft contract locally: fall back to
|
|
219
|
+
// the filesystem for this child only, preserving the parent repo's Git
|
|
220
|
+
// visibility and every built-in skip/size guard. Child Git ignore rules
|
|
221
|
+
// are unavailable in this exceptional path, just as they are when the
|
|
222
|
+
// top-level Git command fails and walkDir uses its filesystem fallback.
|
|
223
|
+
// Let an unreadable filesystem fallback surface rather than claiming a
|
|
224
|
+
// healthy graph that silently omitted the child again.
|
|
225
|
+
childFiles = walkFilesystem(abs, includes);
|
|
226
|
+
}
|
|
227
|
+
for (const file of childFiles)
|
|
228
|
+
out.add(file);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
const stat = lstatSync(abs);
|
|
233
|
+
if (!stat.isFile() || stat.size > MAX_FILE_BYTES)
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// A tracked file deleted from the working tree is still printed by
|
|
238
|
+
// `--cached`; absence means it is not part of the current source set.
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
out.add(abs);
|
|
242
|
+
}
|
|
243
|
+
state.activeRoots.delete(rootKey);
|
|
244
|
+
return [...out].sort();
|
|
245
|
+
}
|
|
246
|
+
/** The historical, non-recursive Git path. Kept separate so the default does
|
|
247
|
+
* exactly the same command, filtering, ordering, and duplicate handling as it
|
|
248
|
+
* did before submodule support existed. */
|
|
249
|
+
function gitVisibleFilesShallow(root, includes) {
|
|
250
|
+
const result = spawnSync("git", ["ls-files", "--cached", "--others", "--exclude-standard", "-z", "--"], { ...WINHIDE, cwd: root,
|
|
251
|
+
encoding: "utf8",
|
|
252
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
253
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
254
|
+
});
|
|
255
|
+
if (result.status !== 0 || result.error || typeof result.stdout !== "string")
|
|
256
|
+
return null;
|
|
257
|
+
const out = [];
|
|
258
|
+
for (const rel of result.stdout.split("\0")) {
|
|
259
|
+
if (!rel || skippedPath(rel, includes))
|
|
260
|
+
continue;
|
|
261
|
+
const abs = resolve(root, rel);
|
|
262
|
+
try {
|
|
263
|
+
const stat = lstatSync(abs);
|
|
264
|
+
if (!stat.isFile() || stat.size > MAX_FILE_BYTES)
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// A tracked file deleted from the working tree is still printed by
|
|
269
|
+
// `--cached`; absence means it is not part of the current source set.
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
out.push(abs);
|
|
273
|
+
}
|
|
274
|
+
return out;
|
|
275
|
+
}
|
|
276
|
+
/** A path (git-relative, either separator) is skipped when any of its
|
|
277
|
+
* segments is a skippable directory name — the final segment doubles as the
|
|
278
|
+
* dot-FILE check (`.eslintrc.js` and friends are not source either). */
|
|
279
|
+
function skippedPath(path, includes) {
|
|
280
|
+
return path.replace(/\\/g, "/").split("/").some((segment) => shouldSkipDir(segment, includes));
|
|
281
|
+
}
|
|
282
|
+
function walkFilesystem(dir, includes) {
|
|
283
|
+
const out = [];
|
|
284
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
285
|
+
const full = join(dir, entry.name);
|
|
286
|
+
if (entry.isDirectory()) {
|
|
287
|
+
if (shouldSkipDir(entry.name, includes))
|
|
288
|
+
continue;
|
|
289
|
+
out.push(...walkFilesystem(full, includes));
|
|
290
|
+
}
|
|
291
|
+
else if (entry.isFile()) {
|
|
292
|
+
if (entry.name.startsWith("."))
|
|
293
|
+
continue; // dot-files are not source either
|
|
294
|
+
try {
|
|
295
|
+
if (statSync(full).size > MAX_FILE_BYTES)
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
out.push(full);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return out;
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/ingest/fs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErE,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IAC/B,cAAc;IACd,MAAM;IACN,OAAO;IACP,6EAA6E;IAC7E,2EAA2E;IAC3E,8EAA8E;IAC9E,6EAA6E;IAC7E,4EAA4E;IAC5E,QAAQ;IACR,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,aAAa;IACb,MAAM;CACP,CAAC,CAAC;AAEH,uFAAuF;AACvF,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AAExC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAA8B;IACxE,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IA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AAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1B,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,SAAS,CAAC,kCAAkC;YAC5E,IAAI,CAAC;gBACH,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,cAAc;oBAAE,SAAS;YACrD,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why `trail init` won't set up `dir`, or null when it will. Only the home
|
|
3
|
+
* folder is refused: run there, init wired it, mapped every code file under it
|
|
4
|
+
* and said to commit, though nobody shares learnings for a whole home folder.
|
|
5
|
+
*/
|
|
6
|
+
export declare function homeFolderRefusal(dir: string, home?: string): string | null;
|
|
7
|
+
/** Whether `dir` is inside a git work tree, so there is something to commit learnings to. */
|
|
8
|
+
export declare function isGitWorkTree(dir: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* `init --pair` outside git: Trail's page shares a repo with the team, and a
|
|
11
|
+
* folder with none would be set up with nothing to share, so it is refused.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NOT_GIT_PAIR_REFUSAL = "\u2717 this folder isn't a git repo.\n Open your agent inside the repo you want Trail to learn, then run the setup prompt again.";
|
|
14
|
+
/** Said instead of the commit line when init ran outside git: there is nothing to commit to. */
|
|
15
|
+
export declare const NOT_GIT_LINE = "\u00B7 this folder isn't a git repo, so its learnings stay on this machine. Run trail init inside a repo to share them with your team";
|
|
16
|
+
//# sourceMappingURL=init-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-guard.d.ts","sourceRoot":"","sources":["../src/init-guard.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,GAAG,IAAI,CAGtF;AAED,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGlD;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,sIAC+F,CAAC;AAEjI,gGAAgG;AAChG,eAAO,MAAM,YAAY,0IAC2G,CAAC"}
|