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,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-level install for Claude Code: the copy of graft's wiring that lives
|
|
3
|
+
* outside every repo.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists. Everything `graft init` writes for Claude Code lands *in* the
|
|
6
|
+
* repo — `.mcp.json` and `.claude/settings.json`. A `.gitignore` is free to ignore
|
|
7
|
+
* both, and `git worktree add` checks out tracked files only, so a worktree of such
|
|
8
|
+
* a repo starts with graft's shims present and neither of the two files that *point
|
|
9
|
+
* at* them. No settings.json means no SessionStart hook; no `.mcp.json` means no
|
|
10
|
+
* tool server. graft is absent, silently, in a tree that looks correctly wired.
|
|
11
|
+
*
|
|
12
|
+
* graft already carries the repair for exactly that — `reconcileWiring` rewrites
|
|
13
|
+
* both files — and it is unreachable here: `runUpkeep` is called only from the hook
|
|
14
|
+
* and from the MCP server, which are the two things that are missing. Seeding can't
|
|
15
|
+
* help either, since it runs on the query path, which needs the server.
|
|
16
|
+
*
|
|
17
|
+
* So the fix cannot live in the repo. `~/.claude/` is not in anyone's working tree,
|
|
18
|
+
* no `.gitignore` reaches it, and Claude Code reads it for every project — worktrees
|
|
19
|
+
* included. Codex has been installed this way from the start (see ./codex-hooks.ts,
|
|
20
|
+
* whose own note says the entries "fire in every repo opened with Codex, not just
|
|
21
|
+
* this one"); Claude Code was the one host graft wired repo-only. This module closes
|
|
22
|
+
* that gap, and is a deliberate mirror of that file.
|
|
23
|
+
*
|
|
24
|
+
* The repo-level writes stay exactly as they were. A project that has its own
|
|
25
|
+
* `.mcp.json` and settings keeps using them; this is the floor underneath, not a
|
|
26
|
+
* replacement.
|
|
27
|
+
*/
|
|
28
|
+
import { writeFileSync } from 'node:fs';
|
|
29
|
+
import { join } from 'node:path';
|
|
30
|
+
import { readJsonObject } from './config-write.js';
|
|
31
|
+
import { mergeJsonKey, serverEntry } from './mcp-config.js';
|
|
32
|
+
/** The directory the user-level shim lives in — the base every hook command names. */
|
|
33
|
+
export function globalHelpersDir(home) {
|
|
34
|
+
return join(home, '.claude', 'helpers');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The files a user-level install would touch — pure, no writes, so `--dry-run` and
|
|
38
|
+
* the picker can report them up front. All three are scoped 'global': they apply to
|
|
39
|
+
* every project opened with Claude Code, not just this one.
|
|
40
|
+
*
|
|
41
|
+
* `~/.claude.json` holds the *user* MCP scope — the top-level `mcpServers` map, the
|
|
42
|
+
* one `claude mcp add --scope user` writes. Not to be confused with the same file's
|
|
43
|
+
* `projects["<abs path>"].mcpServers`, which is `--scope local` and per-directory:
|
|
44
|
+
* a worktree is its own project entry there, so a local registration would miss it
|
|
45
|
+
* for precisely the same reason the repo file does.
|
|
46
|
+
*/
|
|
47
|
+
export function claudeGlobalTargets(home, brand = 'graft') {
|
|
48
|
+
const g = (id, path, kind, what) => ({ hostId: 'claude', id, path, scope: 'global', kind, what });
|
|
49
|
+
const writes = [
|
|
50
|
+
g('claude-global-shim', join(globalHelpersDir(home), 'graft-hooks.cjs'), 'hook', 'hooks shim (user level)'),
|
|
51
|
+
g('claude-global-hooks', join(home, '.claude', 'settings.json'), 'hook', 'SessionStart / UserPromptSubmit / PreToolUse / PostToolUse / PostToolUseFailure / Stop / SessionEnd'),
|
|
52
|
+
g('claude-global-mcp', join(home, '.claude.json'), 'mcp', `mcpServers.${brand}`),
|
|
53
|
+
];
|
|
54
|
+
// trail registers no server for Claude Code: the hooks and the `trail` command do its work.
|
|
55
|
+
return brand === 'trail' ? writes.slice(0, 2) : writes;
|
|
56
|
+
}
|
|
57
|
+
/** Hooks writing removed in trail-solo-grafo change. Kept as stub for retract compatibility. */
|
|
58
|
+
function upsertGlobalHooks(_id, _path, _helpers) {
|
|
59
|
+
return { id: _id, path: _path, action: 'unchanged' };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Install the user-level copy: only the user-scope MCP registration.
|
|
63
|
+
* Hook shim and settings removed in trail-solo-grafo change.
|
|
64
|
+
*
|
|
65
|
+
* Best-effort by contract: a failure is reported as an action, never raised.
|
|
66
|
+
*/
|
|
67
|
+
export function installClaudeGlobal(home, brand = 'graft') {
|
|
68
|
+
const mcp = { id: 'claude-global-mcp', path: join(home, '.claude.json') };
|
|
69
|
+
const out = [];
|
|
70
|
+
// trail: drop the user server (we don't register trail globally via MCP).
|
|
71
|
+
if (brand === 'trail') {
|
|
72
|
+
out.push(dropUserServer(mcp.id, mcp.path, 'trail', isBrainsServer));
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
out.push(mergeJsonKey(mcp.id, mcp.path, 'mcpServers', serverEntry({ brand }), brand));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
out.push({ id: mcp.id, path: mcp.path, action: 'skipped-unparseable' });
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/** Remove one user-scope server from `~/.claude.json`, leaving everything else; `keep` spares an entry it accepts. */
|
|
84
|
+
function dropUserServer(id, path, name, keep) {
|
|
85
|
+
try {
|
|
86
|
+
const loaded = readJsonObject(path);
|
|
87
|
+
if (loaded === 'unparseable')
|
|
88
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
89
|
+
const servers = loaded.root.mcpServers;
|
|
90
|
+
if (!servers || typeof servers !== 'object' || !(name in servers))
|
|
91
|
+
return { id, path, action: 'unchanged' };
|
|
92
|
+
if (keep?.(servers[name]))
|
|
93
|
+
return { id, path, action: 'unchanged' };
|
|
94
|
+
delete servers[name];
|
|
95
|
+
writeFileSync(path, `${JSON.stringify(loaded.root, null, 2)}\n`);
|
|
96
|
+
return { id, path, action: 'updated' };
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* In a repo wired for trail, Claude Code would list graft's user-level server
|
|
104
|
+
* beside the repo's own `trail` one: the same tools twice. Claude Code keeps a
|
|
105
|
+
* per-folder switch for that, `projects["<folder>"].disabledMcpServers` in
|
|
106
|
+
* `~/.claude.json` (what /mcp sets), so graft goes off for this folder only
|
|
107
|
+
* and keeps serving every repo still wired as graft. Nothing to do when graft
|
|
108
|
+
* has no user-level server. Best-effort, like every writer here.
|
|
109
|
+
*/
|
|
110
|
+
export function disableGraftServerIn(home, folder) {
|
|
111
|
+
const id = 'claude-folder-graft-off';
|
|
112
|
+
const path = join(home, '.claude.json');
|
|
113
|
+
try {
|
|
114
|
+
const loaded = readJsonObject(path);
|
|
115
|
+
if (loaded === 'unparseable')
|
|
116
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
117
|
+
const root = loaded.root;
|
|
118
|
+
if (!root.mcpServers?.graft)
|
|
119
|
+
return { id, path, action: 'unchanged' };
|
|
120
|
+
const projects = (root.projects ??= {});
|
|
121
|
+
const here = (projects[folder] ??= {});
|
|
122
|
+
const off = Array.isArray(here.disabledMcpServers) ? here.disabledMcpServers : [];
|
|
123
|
+
if (off.includes('graft'))
|
|
124
|
+
return { id, path, action: 'unchanged' };
|
|
125
|
+
here.disabledMcpServers = [...off, 'graft'];
|
|
126
|
+
writeFileSync(path, `${JSON.stringify(root, null, 2)}\n`);
|
|
127
|
+
return { id, path, action: 'updated' };
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A repo wired for trail commits `.mcp.json` with a `trail mcp` server. On a
|
|
135
|
+
* teammate's machine that has graft but not the trail command, that server
|
|
136
|
+
* can't start. So this folder gets a server of the same name, in Claude Code's
|
|
137
|
+
* per-folder scope (which wins over the project's), that runs `graft mcp`: the
|
|
138
|
+
* same program. graft's own user-level server goes off here, so the tools
|
|
139
|
+
* aren't listed twice. Once `trail` is installed, the per-folder one goes and
|
|
140
|
+
* the committed one runs. Takes effect from the next session in the folder.
|
|
141
|
+
*/
|
|
142
|
+
export function fitTrailServerToMachine(home, folder, has) {
|
|
143
|
+
const id = 'claude-folder-trail-server';
|
|
144
|
+
const path = join(home, '.claude.json');
|
|
145
|
+
try {
|
|
146
|
+
const loaded = readJsonObject(path);
|
|
147
|
+
if (loaded === 'unparseable')
|
|
148
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
149
|
+
const root = loaded.root;
|
|
150
|
+
const here = root.projects?.[folder];
|
|
151
|
+
const ours = here?.mcpServers?.trail?.command === 'graft';
|
|
152
|
+
if (has.trail) {
|
|
153
|
+
if (!ours)
|
|
154
|
+
return { id, path, action: 'unchanged' };
|
|
155
|
+
delete here.mcpServers.trail;
|
|
156
|
+
}
|
|
157
|
+
else if (has.graft && !ours) {
|
|
158
|
+
const projects = (root.projects ??= {});
|
|
159
|
+
const p = (projects[folder] ??= {});
|
|
160
|
+
p.mcpServers = { ...(p.mcpServers ?? {}), trail: { command: 'graft', args: ['mcp'] } };
|
|
161
|
+
if (root.mcpServers?.graft) {
|
|
162
|
+
const off = Array.isArray(p.disabledMcpServers) ? p.disabledMcpServers : [];
|
|
163
|
+
if (!off.includes('graft'))
|
|
164
|
+
p.disabledMcpServers = [...off, 'graft'];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return { id, path, action: 'unchanged' };
|
|
169
|
+
}
|
|
170
|
+
writeFileSync(path, `${JSON.stringify(root, null, 2)}\n`);
|
|
171
|
+
return { id, path, action: 'updated' };
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/* -------------------------------------------------------------------------- */
|
|
178
|
+
/* the workspace's tools and skills, for Claude Code */
|
|
179
|
+
/* -------------------------------------------------------------------------- */
|
|
180
|
+
/** The flag that makes `trail mcp` serve only the workspace's tools (named before they were more than brains). */
|
|
181
|
+
export const BRAINS_FLAG = '--brains';
|
|
182
|
+
/** Whether a user-scope `trail` entry is the workspace-only server (`trail mcp --brains`). */
|
|
183
|
+
export function isBrainsServer(entry) {
|
|
184
|
+
const args = entry?.args;
|
|
185
|
+
return Array.isArray(args) && args.includes(BRAINS_FLAG);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Once this machine is connected to a Trail workspace, Claude Code gets one
|
|
189
|
+
* `trail` entry at the user MCP scope (`~/.claude.json`, every project): a
|
|
190
|
+
* server that passes the workspace's own MCP server through (its tools,
|
|
191
|
+
* prompts and instructions; see mcp/connector.ts). trail gives Claude
|
|
192
|
+
* Code no repo-tools server (its hooks and the `trail` command do that work),
|
|
193
|
+
* so this one lists the workspace's tools and nothing else. Best-effort.
|
|
194
|
+
*/
|
|
195
|
+
export function installBrainsServer(home) {
|
|
196
|
+
const id = 'claude-global-brains';
|
|
197
|
+
const path = join(home, '.claude.json');
|
|
198
|
+
try {
|
|
199
|
+
const { command, args } = serverEntry({ brand: 'trail' });
|
|
200
|
+
return mergeJsonKey(id, path, 'mcpServers', { command, args: [...args, BRAINS_FLAG] }, 'trail');
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** Take the workspace server out again (`trail logout`). Leaves any other `trail` entry alone. */
|
|
207
|
+
export function removeBrainsServer(home) {
|
|
208
|
+
return dropUserServer('claude-global-brains', join(home, '.claude.json'), 'trail', (e) => !isBrainsServer(e));
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The same workspace-only server for Cursor, in its user-level
|
|
212
|
+
* `~/.cursor/mcp.json`, so every project opened in Cursor has the workspace's
|
|
213
|
+
* tools. A repo's own `.cursor/mcp.json` entry (from `trail init`) wins there.
|
|
214
|
+
*/
|
|
215
|
+
export function installCursorBrainsServer(home) {
|
|
216
|
+
const id = 'cursor-global-brains';
|
|
217
|
+
const path = join(home, '.cursor', 'mcp.json');
|
|
218
|
+
try {
|
|
219
|
+
const { command, args } = serverEntry({ brand: 'trail' });
|
|
220
|
+
return mergeJsonKey(id, path, 'mcpServers', { command, args: [...args, BRAINS_FLAG] }, 'trail');
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return { id, path, action: 'skipped-unparseable' };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/** Take Cursor's workspace server out again (`trail logout`). */
|
|
227
|
+
export function removeCursorBrainsServer(home) {
|
|
228
|
+
return dropUserServer('cursor-global-brains', join(home, '.cursor', 'mcp.json'), 'trail', (e) => !isBrainsServer(e));
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=claude-global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-global.js","sourceRoot":"","sources":["../../src/hosts/claude-global.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,aAAa,EAAa,MAAM,SAAS,CAAC;AACnD,OAAO,EAAW,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAgC,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAO5D,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAA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,IAAI,EAAE,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1D,OAAO,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAClG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IACrD,CAAC;AACH,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,OAAO,cAAc,CAAC,sBAAsB,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACvH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** The result of one config/shim write, reported by every installer and by MCP
|
|
2
|
+
* registration so they speak the same vocabulary. `McpWrite` aliases this. */
|
|
3
|
+
export interface ConfigWrite {
|
|
4
|
+
id: string;
|
|
5
|
+
path: string;
|
|
6
|
+
action: 'created' | 'updated' | 'unchanged' | 'skipped-unparseable';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Write a graft-owned file, idempotently: unchanged when the content already
|
|
10
|
+
* matches (only re-applying `mode` if it drifted), else created/updated. `mode`
|
|
11
|
+
* is applied on POSIX; on Windows the exec bit does not exist and is skipped by
|
|
12
|
+
* the caller's expectations.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeOwned(id: string, path: string, content: string, mode?: number): ConfigWrite;
|
|
15
|
+
/** Whether a hooks-config entry is one graft installed (so an upgrade replaces
|
|
16
|
+
* it in place instead of stacking a second copy next to the stale one). The
|
|
17
|
+
* `?? ''` guards a stray `undefined` entry: `JSON.stringify(undefined)` is
|
|
18
|
+
* `undefined`, whose `.includes` would throw. */
|
|
19
|
+
export declare function isGraftEntry(entry: unknown): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Load a JSON config that graft is about to merge into, distinguishing the three
|
|
22
|
+
* outcomes an installer must treat differently:
|
|
23
|
+
* - missing → `{ root: {}, existed: false }`: start fresh, this is a create.
|
|
24
|
+
* - a plain object → `{ root, existed: true }`: merge into it.
|
|
25
|
+
* - anything else (parse error, or a top-level array/null/primitive) →
|
|
26
|
+
* `'unparseable'`: leave the file exactly as the user left it.
|
|
27
|
+
*
|
|
28
|
+
* Deliberately NOT `readJson` from `util/state.ts`, which returns `null` for both
|
|
29
|
+
* missing and unparseable — collapsing those two would let a create silently
|
|
30
|
+
* clobber a hand-edited broken `hooks.json`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readJsonObject(path: string): {
|
|
33
|
+
root: Record<string, any>;
|
|
34
|
+
existed: boolean;
|
|
35
|
+
} | 'unparseable';
|
|
36
|
+
//# sourceMappingURL=config-write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-write.d.ts","sourceRoot":"","sources":["../../src/hosts/config-write.ts"],"names":[],"mappings":"AAWA;+EAC+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,qBAAqB,CAAC;CACrE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAUhG;AAED;;;kDAGkD;AAClD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAGpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAUjE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helpers for the host config writers. Both the hook installers (Codex,
|
|
3
|
+
* user-level under `~/.codex`; Cursor, repo-local under `.cursor`) and the MCP
|
|
4
|
+
* registration merge graft entries into a JSON config, own a generated shim, and
|
|
5
|
+
* describe the outcome with the same little result record. The file-owning write,
|
|
6
|
+
* the graft-entry test, and the load-or-skip JSON open are identical across them;
|
|
7
|
+
* the merge itself differs per host, so only the genuinely-shared pieces live here.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, chmodSync, statSync } from 'node:fs';
|
|
10
|
+
import { dirname } from 'node:path';
|
|
11
|
+
/**
|
|
12
|
+
* Write a graft-owned file, idempotently: unchanged when the content already
|
|
13
|
+
* matches (only re-applying `mode` if it drifted), else created/updated. `mode`
|
|
14
|
+
* is applied on POSIX; on Windows the exec bit does not exist and is skipped by
|
|
15
|
+
* the caller's expectations.
|
|
16
|
+
*/
|
|
17
|
+
export function writeOwned(id, path, content, mode) {
|
|
18
|
+
const existed = existsSync(path);
|
|
19
|
+
if (existed && readFileSync(path, 'utf8') === content) {
|
|
20
|
+
if (mode !== undefined && (statSync(path).mode & 0o777) !== mode)
|
|
21
|
+
chmodSync(path, mode);
|
|
22
|
+
return { id, path, action: 'unchanged' };
|
|
23
|
+
}
|
|
24
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
25
|
+
writeFileSync(path, content);
|
|
26
|
+
if (mode !== undefined)
|
|
27
|
+
chmodSync(path, mode);
|
|
28
|
+
return { id, path, action: existed ? 'updated' : 'created' };
|
|
29
|
+
}
|
|
30
|
+
/** Whether a hooks-config entry is one graft installed (so an upgrade replaces
|
|
31
|
+
* it in place instead of stacking a second copy next to the stale one). The
|
|
32
|
+
* `?? ''` guards a stray `undefined` entry: `JSON.stringify(undefined)` is
|
|
33
|
+
* `undefined`, whose `.includes` would throw. */
|
|
34
|
+
export function isGraftEntry(entry) {
|
|
35
|
+
const s = JSON.stringify(entry ?? '');
|
|
36
|
+
return s.includes('graft-hooks.cjs') || s.includes('trail-hooks.cjs') || s.includes('/.trail/hook.cjs');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Load a JSON config that graft is about to merge into, distinguishing the three
|
|
40
|
+
* outcomes an installer must treat differently:
|
|
41
|
+
* - missing → `{ root: {}, existed: false }`: start fresh, this is a create.
|
|
42
|
+
* - a plain object → `{ root, existed: true }`: merge into it.
|
|
43
|
+
* - anything else (parse error, or a top-level array/null/primitive) →
|
|
44
|
+
* `'unparseable'`: leave the file exactly as the user left it.
|
|
45
|
+
*
|
|
46
|
+
* Deliberately NOT `readJson` from `util/state.ts`, which returns `null` for both
|
|
47
|
+
* missing and unparseable — collapsing those two would let a create silently
|
|
48
|
+
* clobber a hand-edited broken `hooks.json`.
|
|
49
|
+
*/
|
|
50
|
+
export function readJsonObject(path) {
|
|
51
|
+
if (!existsSync(path))
|
|
52
|
+
return { root: {}, existed: false };
|
|
53
|
+
let root;
|
|
54
|
+
try {
|
|
55
|
+
root = JSON.parse(readFileSync(path, 'utf8'));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return 'unparseable';
|
|
59
|
+
}
|
|
60
|
+
if (typeof root !== 'object' || root === null || Array.isArray(root))
|
|
61
|
+
return 'unparseable';
|
|
62
|
+
return { root: root, existed: true };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=config-write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-write.js","sourceRoot":"","sources":["../../src/hosts/config-write.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,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,CAC5B,IAAY;IAEZ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC3D,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,aAAa,CAAC;IAC3F,OAAO,EAAE,IAAI,EAAE,IAA2B,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Brand } from '../brand.js';
|
|
2
|
+
import { type McpWrite } from './mcp-config.js';
|
|
3
|
+
import type { ConfigWrite } from './config-write.js';
|
|
4
|
+
export interface HostsInitResult {
|
|
5
|
+
written: {
|
|
6
|
+
id: string;
|
|
7
|
+
path: string;
|
|
8
|
+
action: string;
|
|
9
|
+
}[];
|
|
10
|
+
skipped: string[];
|
|
11
|
+
unknown: string[];
|
|
12
|
+
mcp: McpWrite[];
|
|
13
|
+
hooks: ConfigWrite[];
|
|
14
|
+
}
|
|
15
|
+
export declare function runHostsInit(repo: string, opts?: {
|
|
16
|
+
agents?: string[];
|
|
17
|
+
all?: boolean;
|
|
18
|
+
home?: string;
|
|
19
|
+
mcp?: boolean;
|
|
20
|
+
hooks?: boolean;
|
|
21
|
+
/** false → skip every write outside the repo (the ~/.codex/ targets). */
|
|
22
|
+
global?: boolean;
|
|
23
|
+
/** When given, only these hosts write outside the repo (`init --agents auto`: the agents installed here). */
|
|
24
|
+
laptop?: string[];
|
|
25
|
+
/** The name `init` runs under; trail's moves the repo to trail's names (see `hostWiringName`). */
|
|
26
|
+
brand?: Brand;
|
|
27
|
+
}): HostsInitResult;
|
|
28
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/hosts/init.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,EAAE,QAAQ,EAAE,CAAC;IAChB,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AA4BD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IACJ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6GAA6G;IAC7G,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,kGAAkG;IAClG,KAAK,CAAC,EAAE,KAAK,CAAC;CACV,GACL,eAAe,CA6CjB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-host init: write each selected host's instruction file.
|
|
3
|
+
* Selection = explicit ids > all > detected. Claude Code is handled
|
|
4
|
+
* separately by src/claude/init.ts (hooks + statusline + skill).
|
|
5
|
+
*/
|
|
6
|
+
import { statSync, writeFileSync, readFileSync, mkdirSync, existsSync, rmSync, rmdirSync } from 'node:fs';
|
|
7
|
+
import { basename, dirname, join } from 'node:path';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { HOSTS, detectHosts, hostRelPath, hostWiringName } from './registry.js';
|
|
10
|
+
import { GRAFT_MARKERS, markersFor, upsertSection } from './sections.js';
|
|
11
|
+
import { registerMcpConfigs } from './mcp-config.js';
|
|
12
|
+
import { installAntigravitySkill } from './antigravity.js';
|
|
13
|
+
function probeFor(home, repo) {
|
|
14
|
+
return {
|
|
15
|
+
home, repo,
|
|
16
|
+
dirExists: (p) => { try {
|
|
17
|
+
return statSync(p).isDirectory();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
} },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function writeOwned(path, content) {
|
|
25
|
+
if (existsSync(path) && readFileSync(path, 'utf8') === content)
|
|
26
|
+
return 'unchanged';
|
|
27
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
28
|
+
const existed = existsSync(path);
|
|
29
|
+
writeFileSync(path, content);
|
|
30
|
+
return existed ? 'replaced' : 'created';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A graft-named file a host owned, gone now that the repo uses trail's names,
|
|
34
|
+
* with its `graft/` folder when that was all the folder held.
|
|
35
|
+
*/
|
|
36
|
+
function removeGraftCopy(path) {
|
|
37
|
+
rmSync(path, { force: true });
|
|
38
|
+
if (basename(dirname(path)) === 'graft') {
|
|
39
|
+
try {
|
|
40
|
+
rmdirSync(dirname(path));
|
|
41
|
+
}
|
|
42
|
+
catch { /* not empty, or not there */ }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function runHostsInit(repo, opts = {}) {
|
|
46
|
+
const home = opts.home ?? homedir();
|
|
47
|
+
const probe = probeFor(home, repo);
|
|
48
|
+
const name = hostWiringName(repo, opts.brand);
|
|
49
|
+
let selected;
|
|
50
|
+
let unknown = [];
|
|
51
|
+
if (opts.agents !== undefined) {
|
|
52
|
+
const byId = new Map(HOSTS.map((h) => [h.id, h]));
|
|
53
|
+
selected = opts.agents.flatMap((id) => byId.get(id) ?? []);
|
|
54
|
+
unknown = opts.agents.filter((id) => !byId.has(id));
|
|
55
|
+
}
|
|
56
|
+
else if (opts.all) {
|
|
57
|
+
selected = HOSTS;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
selected = detectHosts(probe);
|
|
61
|
+
}
|
|
62
|
+
const written = [];
|
|
63
|
+
for (const host of selected) {
|
|
64
|
+
const path = join(repo, hostRelPath(host, name));
|
|
65
|
+
// Under trail, graft's copy of an owned file goes and graft's fenced
|
|
66
|
+
// block becomes trail's, so the agent reads the instructions once.
|
|
67
|
+
const action = host.kind === 'owned'
|
|
68
|
+
? writeOwned(path, host.content(name))
|
|
69
|
+
: upsertSection(path, host.content(name), markersFor(name), name === 'trail' ? [GRAFT_MARKERS] : []).action;
|
|
70
|
+
if (name === 'trail' && host.kind === 'owned')
|
|
71
|
+
removeGraftCopy(join(repo, host.relPath));
|
|
72
|
+
written.push({ id: host.id, path, action });
|
|
73
|
+
}
|
|
74
|
+
const skipped = HOSTS.filter((h) => !selected.includes(h)).map((h) => h.id);
|
|
75
|
+
// Whether `id` may write outside the repo on this run.
|
|
76
|
+
const outside = (id) => opts.global !== false && (opts.laptop === undefined || opts.laptop.includes(id));
|
|
77
|
+
const mcp = opts.mcp === false
|
|
78
|
+
? []
|
|
79
|
+
: registerMcpConfigs(repo, selected.map((h) => h.id), { home, global: opts.global, name, laptop: opts.laptop });
|
|
80
|
+
// Hooks (Codex/Cursor) removed in trail-solo-grafo change.
|
|
81
|
+
const hooks = [];
|
|
82
|
+
const cursorHooks = [];
|
|
83
|
+
// Antigravity's skill is a global write too, so --no-global suppresses it as well.
|
|
84
|
+
const antigravitySkill = !outside('antigravity') || !selected.some((h) => h.id === 'antigravity')
|
|
85
|
+
? []
|
|
86
|
+
: installAntigravitySkill(home, name);
|
|
87
|
+
return { written, skipped, unknown, mcp, hooks: [...hooks, ...cursorHooks, ...antigravitySkill] };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/hosts/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC1G,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAqC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAU3D,SAAS,QAAQ,CAAC,IAAY,EAAE,IAAY;IAC1C,OAAO;QACL,IAAI,EAAE,IAAI;QACV,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;YAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,OAAO,KAAK,CAAC;QAAC,CAAC,CAAC,CAAC;KACxF,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,OAAe;IAC/C,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC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G,KAAK,EAAE,GAAG,WAAW,EAAE,GAAG,gBAAgB,CAAC,EAAE,CAAC;AACpG,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one canonical Graft instruction block, rendered into each host's
|
|
3
|
+
* native format. Content changes happen HERE only; renderers just wrap it.
|
|
4
|
+
*
|
|
5
|
+
* `name` is the repo's name for the tool (see `hostWiringName`): a repo wired
|
|
6
|
+
* by trail gets the same text in trail's spelling, so an agent on a machine
|
|
7
|
+
* with only `trail` installed is never told to run `graft`.
|
|
8
|
+
*/
|
|
9
|
+
import type { Brand } from '../brand.js';
|
|
10
|
+
export declare function instructionBody(name?: Brand): string;
|
|
11
|
+
export declare function cursorRule(name?: Brand): string;
|
|
12
|
+
export declare function kiroSteering(name?: Brand): string;
|
|
13
|
+
export declare function windsurfRule(name?: Brand): string;
|
|
14
|
+
//# sourceMappingURL=instructions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/hosts/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAOzC,wBAAgB,eAAe,CAAC,IAAI,GAAE,KAAe,GAAG,MAAM,CAE7D;AAuED,wBAAgB,UAAU,CAAC,IAAI,GAAE,KAAe,GAAG,MAAM,CAOxD;AAED,wBAAgB,YAAY,CAAC,IAAI,GAAE,KAAe,GAAG,MAAM,CAM1D;AAED,wBAAgB,YAAY,CAAC,IAAI,GAAE,KAAe,GAAG,MAAM,CAG1D"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { trailSpelling } from '../claude/skill-template.js';
|
|
2
|
+
function inName(text, name) {
|
|
3
|
+
return name === 'trail' ? trailSpelling(text) : text;
|
|
4
|
+
}
|
|
5
|
+
export function instructionBody(name = 'graft') {
|
|
6
|
+
return inName(graftBody(), name);
|
|
7
|
+
}
|
|
8
|
+
function graftBody() {
|
|
9
|
+
return `## Graft — repo context graph
|
|
10
|
+
|
|
11
|
+
This repo is indexed in \`graft/\`: small linked markdown nodes that explain each
|
|
12
|
+
system and carry exact file:line spans, kept in sync with the code through git.
|
|
13
|
+
|
|
14
|
+
For ANY task here — understanding how something works, finding where code lives,
|
|
15
|
+
or scoping a change — get context from the graph before grepping or opening
|
|
16
|
+
source files. Re-ask freely (it's cheap) and reuse literal identifiers you
|
|
17
|
+
already have (symbol, error string, file name) as the query. New to this repo?
|
|
18
|
+
Run \`graft map\` first — a token-budgeted orientation (dir clusters, hubs,
|
|
19
|
+
hotspots), no LLM, no key.
|
|
20
|
+
|
|
21
|
+
- Run \`graft ask "<your question>" --source\` → ranked nodes with the relevant
|
|
22
|
+
code spans inlined (each hit's ≤8-line crux by default; \`--full\` for whole
|
|
23
|
+
definitions when the crux isn't enough). Match the tool to the task shape:
|
|
24
|
+
for understanding or editing, the top node IS the answer — cite its
|
|
25
|
+
\`covers:\` file:line spans and edit straight from \`--source\`. For
|
|
26
|
+
exhaustive tasks ("every occurrence / every caller of this pattern"), ranked
|
|
27
|
+
results are top-N, not complete — run \`graft grep "<literal>"\` instead
|
|
28
|
+
(exhaustive over indexed files, grouped by enclosing symbol), falling back
|
|
29
|
+
to raw \`grep -rn\` only for unindexed files.
|
|
30
|
+
- \`graft skeleton <file>\` → every definition's signature + span, ~10× cheaper
|
|
31
|
+
than reading the file; use it to skim an API surface.
|
|
32
|
+
- \`graft callers <symbol>\` gives precomputed, exact edges — who calls this.
|
|
33
|
+
Add \`--direction out\` for what it calls, or \`--depth N\` to walk
|
|
34
|
+
transitively for the full blast radius. For structural questions, skip
|
|
35
|
+
ranking and use this directly.
|
|
36
|
+
- Or browse: \`graft/INDEX.md\` lists every node; follow the links.
|
|
37
|
+
- Monorepos and folders of multiple repos rank fairly across sub-projects —
|
|
38
|
+
hits carry \`[scope/]\` labels naming which one they're from. Narrow with
|
|
39
|
+
\`graft ask "<task>" --in <scope>/\` once you know where you're working.
|
|
40
|
+
For compound-path repos (e.g. \`default-core/frontend\`) use the full path —
|
|
41
|
+
a partial first segment (\`--in default-core\`) is not a valid scope.
|
|
42
|
+
|
|
43
|
+
If a returned span is truncated ("+N more lines"), open the file at that exact
|
|
44
|
+
range before finalizing. Only open source files when a node genuinely lacks a
|
|
45
|
+
needed detail, and then at the exact file:line the node points to — never
|
|
46
|
+
re-read whole files.
|
|
47
|
+
|
|
48
|
+
**The map keeps itself current.** Every query checks the working tree first and
|
|
49
|
+
re-extracts up to 50 changed files before answering, so an edit you just made is
|
|
50
|
+
already in the graph. More than that (a branch switch, a merge of someone else's
|
|
51
|
+
work) is rebuilt in the background: the answer then starts with
|
|
52
|
+
\`[stale: N files changed, rebuilding in background]\`, which means "this answer
|
|
53
|
+
may predate the change — ask again in a moment". You do not have to run
|
|
54
|
+
\`graft build\` after a merge; run it after a large change when you want the
|
|
55
|
+
markdown cards and \`INDEX.md\` regenerate as well (deterministic, no API key, $0).
|
|
56
|
+
|
|
57
|
+
**Worktrees need no setup.** A linked git worktree (\`.git\` is a file) has no map
|
|
58
|
+
of its own, because the map lives in the git-ignored cache. The first query
|
|
59
|
+
copies the main checkout's graph in and patches the difference between the two
|
|
60
|
+
branches, so \`graft ask\` in a fresh worktree answers about that worktree's code
|
|
61
|
+
— not the branch the main checkout happens to have. Nothing to run first.
|
|
62
|
+
|
|
63
|
+
## Checklist before committing / pushing / opening a PR
|
|
64
|
+
|
|
65
|
+
Run **in this order** before the first push on any branch:
|
|
66
|
+
|
|
67
|
+
\`\`\`bash
|
|
68
|
+
<typecheck> # e.g. tsc -b (TS), go vet, cargo check, mypy
|
|
69
|
+
<lint> # e.g. bun run lint / npm run lint
|
|
70
|
+
<tests> # e.g. npx vitest run <module>
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
The code map is not a gate: it refreshes itself on the query path, so there is no
|
|
74
|
+
\`build\`/\`check\` step to forget before a push.`;
|
|
75
|
+
}
|
|
76
|
+
export function cursorRule(name = 'graft') {
|
|
77
|
+
return inName(`---
|
|
78
|
+
description: Use the Graft context graph in graft/ before exploring source
|
|
79
|
+
alwaysApply: true
|
|
80
|
+
---
|
|
81
|
+
${graftBody()}
|
|
82
|
+
`, name);
|
|
83
|
+
}
|
|
84
|
+
export function kiroSteering(name = 'graft') {
|
|
85
|
+
return inName(`---
|
|
86
|
+
inclusion: always
|
|
87
|
+
---
|
|
88
|
+
${graftBody()}
|
|
89
|
+
`, name);
|
|
90
|
+
}
|
|
91
|
+
export function windsurfRule(name = 'graft') {
|
|
92
|
+
return inName(`${graftBody()}
|
|
93
|
+
`, name);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=instructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/hosts/instructions.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,SAAS,MAAM,CAAC,IAAY,EAAE,IAAW;IACvC,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAc,OAAO;IACnD,OAAO,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,SAAS;IAChB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAiEyC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAc,OAAO;IAC9C,OAAO,MAAM,CAAC;;;;EAId,SAAS,EAAE;CACZ,EAAE,IAAI,CAAC,CAAC;AACT,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAc,OAAO;IAChD,OAAO,MAAM,CAAC;;;EAGd,SAAS,EAAE;CACZ,EAAE,IAAI,CAAC,CAAC;AACT,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAc,OAAO;IAChD,OAAO,MAAM,CAAC,GAAG,SAAS,EAAE;CAC7B,EAAE,IAAI,CAAC,CAAC;AACT,CAAC"}
|