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,283 @@
|
|
|
1
|
+
import { isGraftEntry } from '../hosts/config-write.js';
|
|
2
|
+
const slCmd = (name = 'graft') => `node "\${CLAUDE_PROJECT_DIR:-.}/.claude/helpers/${name}-statusline.cjs"`;
|
|
3
|
+
/** trail's status line, from the shim in `.trail/` (see claude/init.ts). */
|
|
4
|
+
const TRAIL_SL_CMD = 'node "${CLAUDE_PROJECT_DIR:-.}/.trail/statusline.cjs"';
|
|
5
|
+
/** Stable marker for "this statusLine is Graft's", not the full command string —
|
|
6
|
+
* an older shim path or a GRAFT_DIR wrapper still names this file. Either name. */
|
|
7
|
+
const STATUSLINE_HELPER = /(graft|trail)-statusline\.cjs|\.trail\/statusline\.cjs/;
|
|
8
|
+
const FOOTER = 'graft/[\\w./-]+\\.md';
|
|
9
|
+
// Every form graft is actually invoked as. 'graft:*' covers a global install;
|
|
10
|
+
// the other two cover a repo working on graft itself (or any consumer running it
|
|
11
|
+
// from a checkout), where the binary is not on PATH under that name. A retrieval
|
|
12
|
+
// call that raises a permission prompt loses to grep, which never does.
|
|
13
|
+
const ALLOW_ENTRIES = [
|
|
14
|
+
'Bash(trail:*)',
|
|
15
|
+
'Bash(graft:*)',
|
|
16
|
+
'Bash(npx graft:*)',
|
|
17
|
+
'Bash(graft-dev:*)',
|
|
18
|
+
'Bash(node dist/cli.js:*)',
|
|
19
|
+
];
|
|
20
|
+
/** Where the repo-level install's shims sit, relative to whatever project is open. */
|
|
21
|
+
const REPO_HELPERS = '${CLAUDE_PROJECT_DIR:-.}/.claude/helpers';
|
|
22
|
+
/**
|
|
23
|
+
* `helpers` is the directory holding `graft-hooks.cjs`, and it is a parameter for
|
|
24
|
+
* one reason: the user-level install (see hosts/claude-global.ts) has to name an
|
|
25
|
+
* absolute path. A `${CLAUDE_PROJECT_DIR}` command works only where a previous
|
|
26
|
+
* `graft init` wrote a shim into that project — which is exactly the case the
|
|
27
|
+
* global copy exists to cover, so it cannot reuse the repo form.
|
|
28
|
+
*/
|
|
29
|
+
function hookCmd(arg, helpers = REPO_HELPERS, name = 'graft') {
|
|
30
|
+
return `node "${helpers}/${name}-hooks.cjs" ${arg}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A hook command that exits 0 whatever happens to it (every event since D116 item 6; PreToolUse first, for this). Copilot CLI reads
|
|
34
|
+
* the repo's `.claude/settings.json` and denies the tool call when a
|
|
35
|
+
* PreToolUse hook exits non-zero, so a shim that can't be found (a host
|
|
36
|
+
* started in a subfolder without CLAUDE_PROJECT_DIR, the shim gone after an
|
|
37
|
+
* uninstall) or a missing node would deny every shell command. `|| exit 0`
|
|
38
|
+
* means the same in sh and Windows cmd. The hook's answer travels as JSON on
|
|
39
|
+
* stdout, never as an exit code, so nothing is lost by it.
|
|
40
|
+
*/
|
|
41
|
+
export function failOpen(command) {
|
|
42
|
+
return `${command} || exit 0`;
|
|
43
|
+
}
|
|
44
|
+
/** trail's committed hook, `.trail/hook.cjs`, run for one event. */
|
|
45
|
+
export function trailHookCmd(arg) {
|
|
46
|
+
return `node "\${CLAUDE_PROJECT_DIR:-.}/.trail/hook.cjs" ${arg}`;
|
|
47
|
+
}
|
|
48
|
+
function graftBlocks(helpers, name = 'graft') {
|
|
49
|
+
return hookBlocks((arg) => hookCmd(arg, helpers, name));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Every hook event, each running `command(<event arg>)`.
|
|
53
|
+
*
|
|
54
|
+
* Every `timeout` here is in seconds: Claude Code and Codex read it that way.
|
|
55
|
+
* Versions before 0.23 wrote 8000-15000 meaning milliseconds, which the host
|
|
56
|
+
* read as hours; merging again replaces them. The prompt hook also keeps to a
|
|
57
|
+
* hard budget of its own (prompt-hook.ts PROMPT_BUDGET_MS), well inside this.
|
|
58
|
+
*/
|
|
59
|
+
function hookBlocks(command) {
|
|
60
|
+
// D116 item 6: every event fails open, not only PreToolUse: a `git stash -u` or `git clean` before the wiring is
|
|
61
|
+
// committed takes the untracked shim while settings.json still names it, and a missing shim must stay quiet.
|
|
62
|
+
const hookCmd_ = (arg) => failOpen(command(arg));
|
|
63
|
+
return {
|
|
64
|
+
PostToolUse: [
|
|
65
|
+
{ matcher: 'Write|Edit|MultiEdit', hooks: [{ type: 'command', command: hookCmd_('post-edit'), timeout: 10 }] },
|
|
66
|
+
// Score the usage mix and sum token savings. A graft retrieval (CLI `graft …`
|
|
67
|
+
// via Bash, or the `graft_*` MCP tools) prints a `[graft] tokens saved ≈ N`
|
|
68
|
+
// footer this hook sums into the session total; the same hook classifies
|
|
69
|
+
// Read/Grep/Glob as source reads vs graft as graft reads, which is what feeds
|
|
70
|
+
// `graft stats` and the `session_summary` graft-vs-grep ratio. Broad matcher,
|
|
71
|
+
// but the handler no-ops instantly unless there is something to record, so an
|
|
72
|
+
// unrelated Bash or a plain Read costs only a stdin read. `Skill` is the
|
|
73
|
+
// agent using a skill: one of the repo's goes to the workspace as a run.
|
|
74
|
+
{ matcher: 'Bash|mcp__graft__|mcp__trail__|Read|Grep|Glob|Skill', hooks: [{ type: 'command', command: hookCmd_('tool-savings'), timeout: 8 }] },
|
|
75
|
+
],
|
|
76
|
+
// Longer than the other hooks: its `graft ask` is a real query, and a query
|
|
77
|
+
// brings the graph up to date first (graph/refresh.ts). The hook itself
|
|
78
|
+
// stops at its own total budget (PROMPT_BUDGET_MS) and reads this number
|
|
79
|
+
// back (promptAskTimeout) so its ask child always fits inside it.
|
|
80
|
+
UserPromptSubmit: [{ hooks: [{ type: 'command', command: hookCmd_('prompt'), timeout: 15 }] }],
|
|
81
|
+
// Before every shell command: pre-bash.js, which fails open, behind a
|
|
82
|
+
// command that fails open too (see failOpen). Claude Code reads `timeout`
|
|
83
|
+
// in seconds, so 5 caps the wait a wedged hook could add to one command,
|
|
84
|
+
// after which the command runs anyway.
|
|
85
|
+
PreToolUse: [
|
|
86
|
+
// The learnings on a file, before the agent changes it: while they can still change the edit.
|
|
87
|
+
{ matcher: 'Write|Edit|MultiEdit', hooks: [{ type: 'command', command: hookCmd_('pre-edit'), timeout: 5 }] },
|
|
88
|
+
{ matcher: 'Bash', hooks: [{ type: 'command', command: hookCmd_('pre-bash'), timeout: 5 }] },
|
|
89
|
+
],
|
|
90
|
+
// A Bash call that failed fires this, never PostToolUse (D34): learned
|
|
91
|
+
// skills mark the outcome for the next catch-up. Fails open like
|
|
92
|
+
// PreToolUse, since some hosts read a non-zero exit as a refusal.
|
|
93
|
+
PostToolUseFailure: [{ matcher: 'Bash', hooks: [{ type: 'command', command: hookCmd_('post-bash-fail'), timeout: 5 }] }],
|
|
94
|
+
SessionStart: [{ hooks: [{ type: 'command', command: hookCmd_('session-start'), timeout: 10 }] }],
|
|
95
|
+
Stop: [{ hooks: [{ type: 'command', command: hookCmd_('stop'), timeout: 10 }] }],
|
|
96
|
+
// Sends the telemetry queue in a detached child, so closing Claude isn't
|
|
97
|
+
// slowed. Not fired when the terminal is killed; session start sends what's left.
|
|
98
|
+
SessionEnd: [{ hooks: [{ type: 'command', command: hookCmd_('session-end'), timeout: 5 }] }],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Is this allowlist entry one graft wrote?
|
|
103
|
+
*
|
|
104
|
+
* Scoped to the forms graft is actually invoked as — NOT any rule mentioning
|
|
105
|
+
* "graft". A user who allowlists their own `Bash(graft-mytool:*)` keeps it; only
|
|
106
|
+
* graft's own set is replaced, which is what lets a renamed entry disappear on
|
|
107
|
+
* upgrade instead of accumulating beside its replacement.
|
|
108
|
+
*/
|
|
109
|
+
export function isGraftAllowEntry(entry) {
|
|
110
|
+
return /^Bash\((?:trail|graft|npx graft|graft-dev|node dist\/cli\.js)(?::|\))/.test(String(entry));
|
|
111
|
+
}
|
|
112
|
+
/** Is this footer regex graft's? It points at the card tree, which is graft's alone. */
|
|
113
|
+
export function isGraftFooterRegex(re) {
|
|
114
|
+
return String(re).includes('graft/');
|
|
115
|
+
}
|
|
116
|
+
function envNoStatusline() {
|
|
117
|
+
const v = process.env.GRAFT_NO_STATUSLINE;
|
|
118
|
+
return v !== undefined && v !== '' && v !== '0' && v !== 'false';
|
|
119
|
+
}
|
|
120
|
+
/** True when init should write (or refresh) Graft's Claude Code statusLine. */
|
|
121
|
+
export function statuslineWanted(opts = {}) {
|
|
122
|
+
return opts.statusline !== false && !envNoStatusline();
|
|
123
|
+
}
|
|
124
|
+
function isGraftStatusline(value) {
|
|
125
|
+
if (!value || typeof value !== 'object')
|
|
126
|
+
return false;
|
|
127
|
+
const command = value.command;
|
|
128
|
+
return typeof command === 'string' && STATUSLINE_HELPER.test(command);
|
|
129
|
+
}
|
|
130
|
+
function applyStatusline(merged, key, warnings, wanted, foreignWarning, name = 'graft') {
|
|
131
|
+
const current = merged[key];
|
|
132
|
+
const ours = isGraftStatusline(current);
|
|
133
|
+
if (!wanted) {
|
|
134
|
+
if (!current || ours)
|
|
135
|
+
delete merged[key];
|
|
136
|
+
else
|
|
137
|
+
warnings.push(foreignWarning);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (!current || ours) {
|
|
141
|
+
merged[key] = { type: 'command', command: slCmd(name) };
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
warnings.push(foreignWarning);
|
|
145
|
+
}
|
|
146
|
+
export function mergeGraftSettings(existing, opts = {}) {
|
|
147
|
+
const merged = { ...(existing ?? {}) };
|
|
148
|
+
const name = opts.name ?? 'graft';
|
|
149
|
+
const warnings = [];
|
|
150
|
+
const wanted = statuslineWanted(opts);
|
|
151
|
+
applyStatusline(merged, 'statusLine', warnings, wanted, `Existing statusLine left untouched (a session allows only one). To use ${name === 'trail' ? 'Trail' : 'Graft'}, point it at .claude/helpers/${name}-statusline.cjs.`, name);
|
|
152
|
+
applyStatusline(merged, 'subagentStatusLine', warnings, wanted, 'Existing subagentStatusLine left untouched.', name);
|
|
153
|
+
merged.hooks = { ...(merged.hooks ?? {}) };
|
|
154
|
+
for (const [event, blocks] of Object.entries(graftBlocks(undefined, name))) {
|
|
155
|
+
const prior = Array.isArray(merged.hooks[event]) ? merged.hooks[event] : [];
|
|
156
|
+
const foreign = prior.filter((e) => !isGraftEntry(e)); // drop old Graft entries → idempotent
|
|
157
|
+
merged.hooks[event] = [...foreign, ...blocks];
|
|
158
|
+
}
|
|
159
|
+
// Drop graft's own prior regex before re-adding, so a change to FOOTER replaces
|
|
160
|
+
// the old pattern instead of stacking beside it. The user's regexes are kept.
|
|
161
|
+
const priorFooter = Array.isArray(merged.footerLinksRegexes) ? merged.footerLinksRegexes : [];
|
|
162
|
+
merged.footerLinksRegexes = [...priorFooter.filter((r) => !isGraftFooterRegex(r)), FOOTER];
|
|
163
|
+
// headless/subagent runs hard-deny Bash by default; without an allowlist entry
|
|
164
|
+
// `graft ask`'s own Bash calls (and the skill it installs) can't run out-of-box.
|
|
165
|
+
// Same shape as the hooks merge above: drop graft's prior entries, then add the
|
|
166
|
+
// current set. Append-only left a renamed invocation form in the user's settings
|
|
167
|
+
// forever, with nothing able to remove it.
|
|
168
|
+
merged.permissions = { ...(merged.permissions ?? {}) };
|
|
169
|
+
const priorAllow = Array.isArray(merged.permissions.allow) ? merged.permissions.allow : [];
|
|
170
|
+
merged.permissions.allow = [...priorAllow.filter((e) => !isGraftAllowEntry(e)), ...ALLOW_ENTRIES];
|
|
171
|
+
return { merged, warnings };
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The hook blocks alone, merged into a settings file, with the shims addressed by
|
|
175
|
+
* absolute path — `~/.claude/settings.json`, where a write reaches every project on
|
|
176
|
+
* the machine (see hosts/claude-global.ts for why that copy has to exist).
|
|
177
|
+
*
|
|
178
|
+
* Hooks only, deliberately. `mergeGraftSettings` also claims the statusline, the
|
|
179
|
+
* footer regex and a Bash allowlist, and each of those is a reasonable thing to
|
|
180
|
+
* accept for a repo you ran `graft init` in and an unreasonable thing to impose on
|
|
181
|
+
* every repo you ever open — a statusline especially, since a session allows exactly
|
|
182
|
+
* one and taking it globally would silently outrank the user's own. The hooks are the
|
|
183
|
+
* piece that has to be global, because they are what a worktree loses.
|
|
184
|
+
*
|
|
185
|
+
* Same idempotent shape as the repo merge: graft's prior entries are dropped before
|
|
186
|
+
* the current set is added, so re-running converges instead of stacking.
|
|
187
|
+
*/
|
|
188
|
+
export function mergeGraftHooks(existing, helpers) {
|
|
189
|
+
const merged = { ...(existing ?? {}) };
|
|
190
|
+
merged.hooks = { ...(merged.hooks ?? {}) };
|
|
191
|
+
for (const [event, blocks] of Object.entries(graftBlocks(helpers))) {
|
|
192
|
+
const prior = Array.isArray(merged.hooks[event]) ? merged.hooks[event] : [];
|
|
193
|
+
const foreign = prior.filter((e) => !isGraftEntry(e));
|
|
194
|
+
merged.hooks[event] = [...foreign, ...blocks];
|
|
195
|
+
}
|
|
196
|
+
return { merged };
|
|
197
|
+
}
|
|
198
|
+
/** Drop every fragment graft or trail wrote from a settings object, keeping the user's. */
|
|
199
|
+
function withoutOurs(existing) {
|
|
200
|
+
const merged = { ...(existing ?? {}) };
|
|
201
|
+
for (const key of ['statusLine', 'subagentStatusLine'])
|
|
202
|
+
if (isGraftStatusline(merged[key]))
|
|
203
|
+
delete merged[key];
|
|
204
|
+
if (merged.hooks && typeof merged.hooks === 'object' && !Array.isArray(merged.hooks)) {
|
|
205
|
+
const hooks = {};
|
|
206
|
+
for (const [event, prior] of Object.entries(merged.hooks)) {
|
|
207
|
+
const kept = Array.isArray(prior) ? prior.filter((e) => !isGraftEntry(e)) : prior;
|
|
208
|
+
if (!Array.isArray(kept) || kept.length)
|
|
209
|
+
hooks[event] = kept;
|
|
210
|
+
}
|
|
211
|
+
if (Object.keys(hooks).length)
|
|
212
|
+
merged.hooks = hooks;
|
|
213
|
+
else
|
|
214
|
+
delete merged.hooks;
|
|
215
|
+
}
|
|
216
|
+
if (Array.isArray(merged.footerLinksRegexes)) {
|
|
217
|
+
const kept = merged.footerLinksRegexes.filter((r) => !isGraftFooterRegex(r));
|
|
218
|
+
if (kept.length)
|
|
219
|
+
merged.footerLinksRegexes = kept;
|
|
220
|
+
else
|
|
221
|
+
delete merged.footerLinksRegexes;
|
|
222
|
+
}
|
|
223
|
+
if (merged.permissions && typeof merged.permissions === 'object' && Array.isArray(merged.permissions.allow)) {
|
|
224
|
+
const allow = merged.permissions.allow.filter((e) => !isGraftAllowEntry(e));
|
|
225
|
+
const permissions = { ...merged.permissions };
|
|
226
|
+
if (allow.length)
|
|
227
|
+
permissions.allow = allow;
|
|
228
|
+
else
|
|
229
|
+
delete permissions.allow;
|
|
230
|
+
if (Object.keys(permissions).length)
|
|
231
|
+
merged.permissions = permissions;
|
|
232
|
+
else
|
|
233
|
+
delete merged.permissions;
|
|
234
|
+
}
|
|
235
|
+
return merged;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* trail's part of the committed `.claude/settings.json`: one SessionStart entry
|
|
239
|
+
* running `.trail/hook.cjs`, and nothing else. For a teammate without trail it
|
|
240
|
+
* shows the learnings and offers trail; with trail it hands off to the install.
|
|
241
|
+
* Anything an older init put here (status line, the other hooks, allowlist,
|
|
242
|
+
* footer regex) comes out, so the file a team commits is the same on every machine.
|
|
243
|
+
*/
|
|
244
|
+
export function mergeTrailShared(existing) {
|
|
245
|
+
const merged = withoutOurs(existing);
|
|
246
|
+
merged.hooks = { ...(merged.hooks ?? {}) };
|
|
247
|
+
merged.hooks.SessionStart = [
|
|
248
|
+
...(Array.isArray(merged.hooks.SessionStart) ? merged.hooks.SessionStart : []),
|
|
249
|
+
...hookBlocks(trailHookCmd).SessionStart,
|
|
250
|
+
];
|
|
251
|
+
return merged;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* trail's part of `.claude/settings.local.json`, the person's own: the status
|
|
255
|
+
* line, the footer regex and the allowlist, plus, when `~/.claude` doesn't carry
|
|
256
|
+
* them (`--no-global`), the hooks for every event but session start, which the
|
|
257
|
+
* shared file already runs once.
|
|
258
|
+
*/
|
|
259
|
+
export function mergeTrailLocal(existing, opts = {}) {
|
|
260
|
+
const merged = withoutOurs(existing);
|
|
261
|
+
const warnings = [];
|
|
262
|
+
if (statuslineWanted(opts)) {
|
|
263
|
+
for (const key of ['statusLine', 'subagentStatusLine']) {
|
|
264
|
+
if (!merged[key])
|
|
265
|
+
merged[key] = { type: 'command', command: TRAIL_SL_CMD };
|
|
266
|
+
else if (key === 'statusLine')
|
|
267
|
+
warnings.push('Existing statusLine left untouched (a session allows only one). To use Trail, point it at .trail/statusline.cjs.');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (opts.hooks) {
|
|
271
|
+
merged.hooks = { ...(merged.hooks ?? {}) };
|
|
272
|
+
for (const [event, blocks] of Object.entries(hookBlocks(trailHookCmd))) {
|
|
273
|
+
if (event === 'SessionStart')
|
|
274
|
+
continue;
|
|
275
|
+
merged.hooks[event] = [...(Array.isArray(merged.hooks[event]) ? merged.hooks[event] : []), ...blocks];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
merged.footerLinksRegexes = [...(merged.footerLinksRegexes ?? []), FOOTER];
|
|
279
|
+
merged.permissions = { ...(merged.permissions ?? {}) };
|
|
280
|
+
merged.permissions.allow = [...(merged.permissions.allow ?? []), ...ALLOW_ENTRIES];
|
|
281
|
+
return { merged, warnings };
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=settings-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-merge.js","sourceRoot":"","sources":["../../src/claude/settings-merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0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GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;QACxG,CAAC;IACH,CAAC;IACD,MAAM,CAAC,kBAAkB,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3E,MAAM,CAAC,WAAW,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;IACvD,MAAM,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC;IACnF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Brand } from "../brand.js";
|
|
2
|
+
export declare function skillTemplate(brand?: Brand): string;
|
|
3
|
+
/**
|
|
4
|
+
* Agent-facing graft text in trail's spelling, for every file trail writes
|
|
5
|
+
* for an agent: the commands as trail spells them (`graft stats` is
|
|
6
|
+
* `trail status`, and the freshness gate is `trail build --check`, see `cmd`),
|
|
7
|
+
* and the name in prose. Under trail the
|
|
8
|
+
* code map is in `.trail/cache/` (context/map-dir.ts), so the folder's name
|
|
9
|
+
* changes too; any other `graft` followed by `/` stays, as do `graft-…`
|
|
10
|
+
* names. `graft_…` MCP tool names ARE replaced — the fork exposes them as `trail_*`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function trailSpelling(text: string): string;
|
|
13
|
+
//# sourceMappingURL=skill-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-template.d.ts","sourceRoot":"","sources":["../../src/claude/skill-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAc9C,wBAAgB,aAAa,CAAC,KAAK,GAAE,KAAe,GAAG,MAAM,CAE5D;AAuFD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUlD"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { cmd } from "../brand.js";
|
|
2
|
+
// The graft Claude Code skill, bundled as a string so `graft init` can write it into a
|
|
3
|
+
// consumer repo's .claude/skills/graft/SKILL.md (no network fetch, version-locked to the
|
|
4
|
+
// installed graft). This is the single source of truth for the skill text; graft's own
|
|
5
|
+
// repo copy is regenerated from here when `init` runs in this repo. Mirrors the `.cjs`
|
|
6
|
+
// shim pattern in shim-template.ts.
|
|
7
|
+
//
|
|
8
|
+
// `brand` is the repo's name for the tool, not the machine's: a repo wired by
|
|
9
|
+
// `trail init` gets the trail text, whoever refreshes it, so teammates on graft
|
|
10
|
+
// and trail never flip the committed file back and forth.
|
|
11
|
+
//
|
|
12
|
+
// trail-solo-grafo: the skill describes the code map only. The learnings, skills
|
|
13
|
+
// and pre-review sections are gone with the layers they documented, so every
|
|
14
|
+
// command and tool named below exists in the binary.
|
|
15
|
+
export function skillTemplate(brand = "graft") {
|
|
16
|
+
return brand === "trail" ? trailSkill(graftSkill()) : graftSkill();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* When Claude Code loads the trail skill. It reads only the description up
|
|
20
|
+
* front and opens the body when the description fits the moment, so the
|
|
21
|
+
* description names the moments a trail command belongs to, not just code
|
|
22
|
+
* search. It's also the one line every teammate's Claude sees in a repo where
|
|
23
|
+
* trail is wired, installed or not, so it says how to get the command. A plain
|
|
24
|
+
* YAML scalar: no ": " and no " #".
|
|
25
|
+
*/
|
|
26
|
+
const TRAIL_DESCRIPTION = `Use for ANY task in this repo. Run trail ask before grepping or reading
|
|
27
|
+
source: it returns ranked nodes with exact file:line spans, plus the call
|
|
28
|
+
graph, a semantic search and a repo map for orientation. Works in git
|
|
29
|
+
worktrees with no setup and refreshes itself on every query, so answers
|
|
30
|
+
describe the code as it is right now. If the trail command isn't installed,
|
|
31
|
+
offer once to install it with npm install -g trail-code
|
|
32
|
+
--ignore-scripts and then trail init --no-agents. If npm says EACCES, never
|
|
33
|
+
use sudo; offer to set npm's prefix to ~/.npm-global instead.`;
|
|
34
|
+
/** The same, in the body, before the tool docs. */
|
|
35
|
+
function trailSkill(graft) {
|
|
36
|
+
const text = trailSpelling(graft.replace(/^---\n[\s\S]*?\n---\n/, ""));
|
|
37
|
+
return `---
|
|
38
|
+
name: trail
|
|
39
|
+
description: ${TRAIL_DESCRIPTION}
|
|
40
|
+
---
|
|
41
|
+
${text.trimEnd()}
|
|
42
|
+
|
|
43
|
+
## Worktrees and a working tree that moves
|
|
44
|
+
|
|
45
|
+
- **A linked git worktree needs no setup.** Its \`.git\` is a file, not a
|
|
46
|
+
directory; the map lives in the git-ignored cache, so a fresh worktree has
|
|
47
|
+
none. The first query copies the main checkout's graph in — lexical graph,
|
|
48
|
+
\`ask\` index and the semantic index — and patches the difference between the
|
|
49
|
+
two branches. The answer is about *this* worktree's code, not the branch the
|
|
50
|
+
main checkout happens to be on. Do not run \`trail build\` first.
|
|
51
|
+
- **The map refreshes on the query path.** Up to 50 changed files are
|
|
52
|
+
re-extracted before the answer, so an edit you just made is already in it.
|
|
53
|
+
More than that — a branch switch, a merge of someone else's work — is rebuilt
|
|
54
|
+
in a detached process and the answer begins with
|
|
55
|
+
\`[stale: N files changed, rebuilding in background]\`: it may predate the
|
|
56
|
+
change, so ask again in a moment rather than rewording the question.
|
|
57
|
+
- **The semantic index lags on purpose.** It loads a local embedding model, which
|
|
58
|
+
costs seconds, so it is refreshed in the background and never blocks a lexical
|
|
59
|
+
query. \`trail_check_freshness\` reports the state of both.
|
|
60
|
+
|
|
61
|
+
## The MCP surface
|
|
62
|
+
|
|
63
|
+
When the trail MCP server is connected, the same retrieval is exposed as nine
|
|
64
|
+
tools. Use whichever surface is available; the guidance above is identical.
|
|
65
|
+
|
|
66
|
+
| Tool | When |
|
|
67
|
+
|---|---|
|
|
68
|
+
| \`trail_find_code\` | Code: functions, symbols, variables, classes (lexical, exact names) |
|
|
69
|
+
| \`trail_find_all\` | Every occurrence of a literal, grouped by enclosing symbol |
|
|
70
|
+
| \`trail_trace_calls\` | Blast radius before changing a symbol (\`direction\`, \`depth\`) |
|
|
71
|
+
| \`trail_file_api\` | A file's API surface without reading it |
|
|
72
|
+
| \`trail_repo_map\` | Orientation in an unknown repo or workspace |
|
|
73
|
+
| \`trail_search_semantic\` | Concepts in prose (\`.md\` specs, docs). NOT for code symbols |
|
|
74
|
+
| \`trail_check_freshness\` | Is the map in sync with the working tree? |
|
|
75
|
+
| \`trail_build\` | Rebuild graph + semantic index in the background |
|
|
76
|
+
| \`trail_set_scope\` | Pin every later query to one subtree of the workspace |
|
|
77
|
+
|
|
78
|
+
> **Semantic rule**: \`trail_search_semantic\` embeds natural language, so it earns
|
|
79
|
+
> its keep on \`.md\` (specs, docs, system cards) and adds little for code. For a
|
|
80
|
+
> symbol name use \`trail_find_code\`.
|
|
81
|
+
> Scope it with \`in=\`: \`trail_search_semantic(query="...", in="default-core")\`.
|
|
82
|
+
|
|
83
|
+
## CLI, when the MCP server is not connected
|
|
84
|
+
|
|
85
|
+
\`\`\`bash
|
|
86
|
+
trail ask "<question>" --source # locate + understand (the default)
|
|
87
|
+
trail grep "<literal>" # exhaustive, grouped by enclosing symbol
|
|
88
|
+
trail callers <sym> --depth 2 # who calls it; --direction out for callees
|
|
89
|
+
trail skeleton <file> # a file's API in ~200 tokens
|
|
90
|
+
trail map # orientation: clusters, hubs, hotspots
|
|
91
|
+
trail build # rebuild the map (cards + INDEX.md too)
|
|
92
|
+
trail status # code map, freshness and tokens saved
|
|
93
|
+
trail blast --base origin/main # blast radius of a diff
|
|
94
|
+
trail viz # interactive graph in the browser
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
If \`trail\` isn't installed on this machine but \`graft\` is, it's the same
|
|
98
|
+
command under its old name.
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Agent-facing graft text in trail's spelling, for every file trail writes
|
|
103
|
+
* for an agent: the commands as trail spells them (`graft stats` is
|
|
104
|
+
* `trail status`, and the freshness gate is `trail build --check`, see `cmd`),
|
|
105
|
+
* and the name in prose. Under trail the
|
|
106
|
+
* code map is in `.trail/cache/` (context/map-dir.ts), so the folder's name
|
|
107
|
+
* changes too; any other `graft` followed by `/` stays, as do `graft-…`
|
|
108
|
+
* names. `graft_…` MCP tool names ARE replaced — the fork exposes them as `trail_*`.
|
|
109
|
+
*/
|
|
110
|
+
export function trailSpelling(text) {
|
|
111
|
+
return text
|
|
112
|
+
.replace(/`graft\/`/g, "`.trail/cache/`")
|
|
113
|
+
.replace(/(?<![\w./-])graft\/INDEX\.md/g, ".trail/cache/INDEX.md")
|
|
114
|
+
.replace(/(?<![\w./-])graft\/(?=[\s.,)])/g, ".trail/cache/")
|
|
115
|
+
.replace(/\bgraft check\b(?![\w-])/g, () => cmd("graft build --check", "trail"))
|
|
116
|
+
.replace(/\bgraft stats\b(?![\w-])/g, (m) => cmd(m, "trail"))
|
|
117
|
+
.replace(/\bGraft\b(?![/\w-])/g, "Trail")
|
|
118
|
+
.replace(/\bgraft_(?=[a-z])/g, "trail_")
|
|
119
|
+
.replace(/\bgraft\b(?![/\w-])/g, "trail");
|
|
120
|
+
}
|
|
121
|
+
function graftSkill() {
|
|
122
|
+
return `---
|
|
123
|
+
name: graft
|
|
124
|
+
description: This repo is indexed by graft/. For ANY task here, whether
|
|
125
|
+
understanding how something works, finding where code lives, tracing what
|
|
126
|
+
calls a symbol or what a change breaks, or scoping an edit, get your context
|
|
127
|
+
from graft before grepping or reading source files.
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
# graft
|
|
131
|
+
|
|
132
|
+
\`graft/\` holds a graph of this repo: small markdown nodes that each explain one
|
|
133
|
+
part in prose and name the exact \`file:line\` spans they cover, plus a wiring
|
|
134
|
+
graph of who-calls-what. Querying a node costs a few hundred tokens; rebuilding
|
|
135
|
+
that understanding by reading source costs thousands, and misses the edges.
|
|
136
|
+
|
|
137
|
+
Every command below is \`$0\`, needs no API key, and returns in under a second.
|
|
138
|
+
There are six of them. **Pick the one that fits the task, run it, act on the
|
|
139
|
+
answer; don't chain tools hoping for more. Most tasks need one call.**
|
|
140
|
+
|
|
141
|
+
## The tools
|
|
142
|
+
|
|
143
|
+
### 1 · \`graft ask "<question>" --source\`: locate + understand (the default)
|
|
144
|
+
Ranked retrieval over the graph, routed automatically between prose nodes and
|
|
145
|
+
the wiring graph, returning the top hits with exact \`file:line\`.
|
|
146
|
+
- \`--source\` inlines the code at each hit, the ≤8-line **crux** of each
|
|
147
|
+
definition, so the result IS the code you need, no follow-up file read. Add
|
|
148
|
+
\`--full\` only when the crux is too small to act on.
|
|
149
|
+
- \`--in <path>\` narrows to a subtree before ranking; \`-n N\` caps results (default 8).
|
|
150
|
+
- **Use it when** the question is conceptual or locational: "how does auth
|
|
151
|
+
work", "where is rate-limiting handled", "what assembles the request pipeline".
|
|
152
|
+
- One ask usually answers. A genuinely multi-part question needs one ask per
|
|
153
|
+
distinct sub-aspect, never the same question reworded. Few or weak hits mean
|
|
154
|
+
switch tool (grep / skeleton / callers), don't re-ask.
|
|
155
|
+
|
|
156
|
+
### 2 · \`graft grep "<pattern>"\`: exhaustive find
|
|
157
|
+
Regex (or \`--fixed\` for a literal) over every indexed file, hits **grouped by
|
|
158
|
+
enclosing symbol** and ranked by coupling; it also reports files it couldn't read.
|
|
159
|
+
- **Use it when** you need every occurrence: all call sites, all uses of a
|
|
160
|
+
constant, all providers. \`ask\` is ranked top-N and *will* miss instances;
|
|
161
|
+
grep won't. One grep replaces a spray of asks.
|
|
162
|
+
- Search a **short symbol name or literal**, not a full guessed signature: an
|
|
163
|
+
over-specific regex (\`func (s *Server) GenerateHandler\`) returns nothing even
|
|
164
|
+
when the code is indexed. If a grep misses, **loosen it** (drop the receiver
|
|
165
|
+
and signature, keep the bare name) and retry \`graft grep\`. Do NOT switch to
|
|
166
|
+
raw \`grep -rn\`, which is slower and unranked.
|
|
167
|
+
- \`-i\` case-insensitive; \`--in <path>\` scopes to a subtree. Raw \`grep -rn\` is
|
|
168
|
+
only for files graft genuinely doesn't index (docs, configs, brand-new files).
|
|
169
|
+
|
|
170
|
+
### 3 · \`graft skeleton <file>\`: a file's API at a glance
|
|
171
|
+
Signatures-only view of one file (every function / method / type with its span)
|
|
172
|
+
in ~200 tokens, ~10x cheaper than reading the file.
|
|
173
|
+
- **Use it when** you need "what's in this file / what can I call here" before
|
|
174
|
+
editing or wiring into it. One skeleton is the whole answer for a file; don't
|
|
175
|
+
re-skeleton the same file, and don't skeleton every file \`map\` already named.
|
|
176
|
+
|
|
177
|
+
### 4 · \`graft callers <symbol>\`: the exact edges
|
|
178
|
+
Precomputed call/reference edges, not a text search. Symbol can be bare
|
|
179
|
+
(\`Foo\`), qualified (\`Class.method\`), or package-qualified (\`pkg.Fn\`).
|
|
180
|
+
- default \`--direction in\`: **who calls/references** this; run before you
|
|
181
|
+
rename, delete, or change its signature.
|
|
182
|
+
- \`--direction out\`: **what this symbol itself calls/depends on** (the old \`callees\`).
|
|
183
|
+
- \`--depth N\`: walk transitively N hops for the **full blast radius** (the old
|
|
184
|
+
\`impact\`); \`--depth 2\` is the usual "what breaks if I touch this".
|
|
185
|
+
- \`--depth all\`: the **entire connected closure**: every source reachable
|
|
186
|
+
through the edges. Reach for this before a **refactor, rename, or any
|
|
187
|
+
multi-file change**: it surfaces the sibling and downstream files (platform
|
|
188
|
+
variants, a module you must split out) that a single-file edit would miss.
|
|
189
|
+
|
|
190
|
+
### 5 · \`graft map\`: orientation for an unfamiliar repo or area
|
|
191
|
+
A token-budgeted tour: directory clusters, per-directory hubs, and global
|
|
192
|
+
hotspots, straight from the wiring graph.
|
|
193
|
+
- **Use it when** you land in a repo cold or are asked for "the architecture".
|
|
194
|
+
\`map\` alone is the answer: read the hub cards it names; do NOT then skeleton
|
|
195
|
+
or ask your way through every subsystem it lists. \`--max-dirs N\` widens it.
|
|
196
|
+
|
|
197
|
+
### 6 · Lifecycle: \`graft build\` / \`graft build --check\`
|
|
198
|
+
Every tool above refreshes the graph itself before answering, so what those tools
|
|
199
|
+
return always describes the code as it is right now, including edits you just made
|
|
200
|
+
and have not committed. You do **not** need to run \`build\` after editing.
|
|
201
|
+
|
|
202
|
+
That refresh is bounded: up to 50 changed files are re-extracted before the answer.
|
|
203
|
+
More than that (a branch switch, a merge of someone else's work) is rebuilt in a
|
|
204
|
+
detached process, and the answer opens with
|
|
205
|
+
\`[stale: N files changed, rebuilding in background]\` — ask again in a moment rather
|
|
206
|
+
than rewording the question. A linked git worktree needs no setup at all: the first
|
|
207
|
+
query seeds it from the main checkout and patches the branch difference.
|
|
208
|
+
|
|
209
|
+
One caveat, if you \`grep\` the markdown under \`graft/\` directly: those cards are a
|
|
210
|
+
projection, written by an explicit \`build\` rather than on each query, so after an
|
|
211
|
+
edit they can lag. The tools above never do: prefer them, and treat a card's spans as
|
|
212
|
+
stale if you have edited that file this turn.
|
|
213
|
+
|
|
214
|
+
\`build\` is for the LLM layer (\`--deep\` adds a concept map; skip unless asked);
|
|
215
|
+
\`build --check\` fails when \`graft/\` is stale, for CI.
|
|
216
|
+
|
|
217
|
+
## Scenarios: the shortest path through a coding task
|
|
218
|
+
|
|
219
|
+
| When you're… | Reach for | Calls |
|
|
220
|
+
|---|---|---|
|
|
221
|
+
| Onboarding / "explain this codebase" | \`graft map\`, then read the named hub cards | 1 |
|
|
222
|
+
| Understanding a flow ("how does X work") | \`graft ask "<flow>" --source\` | 1 |
|
|
223
|
+
| Finding where a change belongs | \`graft ask "where is <behavior>" --source\` | 1 |
|
|
224
|
+
| Editing a symbol you can already name | \`graft grep "<symbol>"\`, edit at the \`file:line\` (skip \`ask\`: you know where it is) | 1 |
|
|
225
|
+
| Renaming / deleting / changing a signature | \`graft callers <sym> --depth 2\` first | 1 |
|
|
226
|
+
| Refactor / multi-file change (before editing) | \`graft callers <sym> --depth all\`: map every connected file, don't stop at the first | 1 |
|
|
227
|
+
| "What does this depend on?" | \`graft callers <sym> --direction out\` | 1 |
|
|
228
|
+
| Finding every occurrence of a pattern | \`graft grep "<literal>"\` | 1 |
|
|
229
|
+
| "What's the API of this file?" | \`graft skeleton <file>\` | 1 |
|
|
230
|
+
| Debugging a failure in area X | \`graft ask "<symptom>" --source\`, then \`callers\` on the suspect | 1–2 |
|
|
231
|
+
| Judging a diff's risk before merge | \`graft callers <changed sym> --depth 2\` | 1 / symbol |
|
|
232
|
+
| Working inside one repo of a monorepo | add \`--in <scope>/\` to ask / grep / callers | n/a |
|
|
233
|
+
|
|
234
|
+
In a multi-repo workspace, graft ranks fairly so the biggest repo can't drown
|
|
235
|
+
the rest, and every hit carries a \`[scope/]\` label naming its sub-project; when
|
|
236
|
+
you already know where you're working, narrow with \`graft ask "<task>" --in <scope>/\`.
|
|
237
|
+
For compound-path repos (e.g. \`default-core/frontend\`) use the full path:
|
|
238
|
+
\`graft ask "<task>" --in default-core/frontend/\` — a partial first segment alone
|
|
239
|
+
(\`--in default-core\`) is not a valid scope.
|
|
240
|
+
|
|
241
|
+
## Spend the fewest calls
|
|
242
|
+
- A node's \`covers:\` list already gives exact \`file:line\` for every symbol, so
|
|
243
|
+
cite straight from it. The spans are generated from source and authoritative;
|
|
244
|
+
don't re-open or re-grep files to "double-check".
|
|
245
|
+
- When the task already names the file or symbol to change, go straight there:
|
|
246
|
+
\`graft grep "<symbol>"\` for the exact \`file:line\`, then edit. Reserve
|
|
247
|
+
\`graft ask\` for when you don't yet know where the code lives: an \`ask\`
|
|
248
|
+
round-trip is wasted on a target you can already name.
|
|
249
|
+
- Trust the answer and act. Reach for a second tool only when the first genuinely
|
|
250
|
+
fell short: weak hits, a truncated span, or a need to be exhaustive.
|
|
251
|
+
- If graft names a path that isn't on disk, its index is ahead of your checkout
|
|
252
|
+
(a branch switch or unpulled move). Don't read the missing file: \`graft grep\`
|
|
253
|
+
the symbol to find where it lives now, or run \`graft build\` to refresh.
|
|
254
|
+
|
|
255
|
+
## Report what graft saved, every turn
|
|
256
|
+
Each retrieval tool **opens** its output with a \`[graft] tokens saved ≈ N\` line:
|
|
257
|
+
the estimated tokens that call saved versus reading the files it covers whole.
|
|
258
|
+
Whenever you used any graft tool in a turn, close your reply with a one-line
|
|
259
|
+
tally summing those numbers across every graft call you made, e.g.
|
|
260
|
+
\`🌱 graft saved ~12,400 tokens this turn (3 calls)\`. A call with no such line
|
|
261
|
+
(tiny files, where the pointers cost as much as the source) saved nothing, so
|
|
262
|
+
skip it. This is the per-turn figure; the statusline carries the running
|
|
263
|
+
session total.
|
|
264
|
+
|
|
265
|
+
Once a turn has been billed, each line also states what that call was worth in
|
|
266
|
+
dollars, at the rate this session is actually paying for input tokens; include
|
|
267
|
+
that total alongside the tokens, e.g. \`🌱 graft saved ~12,400 tokens (~$0.04)
|
|
268
|
+
this turn\`. When a line carries no dollar figure, report tokens alone rather
|
|
269
|
+
than pricing them yourself.
|
|
270
|
+
|
|
271
|
+
**Never pipe a graft command through \`head\`, \`tail\`, or \`sed -n\`.** Every tool
|
|
272
|
+
is already capped and states what it dropped; clipping it costs you hits you
|
|
273
|
+
asked for, and it silently drops the savings line the statusline's running
|
|
274
|
+
total is parsed from.
|
|
275
|
+
|
|
276
|
+
## When graft isn't enough
|
|
277
|
+
- Span truncated ("+N more lines"): open the file at that exact range.
|
|
278
|
+
- A node lacks a detail: ask a more specific question; only then read source at
|
|
279
|
+
the exact \`file:line\`, never a whole file to rebuild understanding graft gives.
|
|
280
|
+
- You may also grep / ls / cat inside \`graft/\` directly (plain markdown;
|
|
281
|
+
\`graft/INDEX.md\` indexes the nodes), but the tools above are faster and
|
|
282
|
+
exhaustive where it matters, so reach for them first.
|
|
283
|
+
|
|
284
|
+
When the graft MCP server is connected, these are exposed as tools too:
|
|
285
|
+
\`graft_find_code\`, \`graft_find_all\`, \`graft_file_api\`, \`graft_trace_calls\` (with
|
|
286
|
+
\`direction\` / \`depth\`), \`graft_repo_map\`, \`graft_check_freshness\`. Use whichever surface is
|
|
287
|
+
available; the guidance is identical.
|
|
288
|
+
`;
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=skill-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-template.js","sourceRoot":"","sources":["../../src/claude/skill-template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAc,MAAM,aAAa,CAAC;AAC9C,uFAAuF;AACvF,yFAAyF;AACzF,uFAAuF;AACvF,uFAAuF;AACvF,oCAAoC;AACpC,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,0DAA0D;AAC1D,EAAE;AACF,iFAAiF;AACjF,6EAA6E;AAC7E,qDAAqD;AACrD,MAAM,UAAU,aAAa,CAAC,QAAe,OAAO;IAClD,OAAO,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG;;;;;;;gEAOsC,CAAC;AAEjE,mDAAmD;AACnD,SAAS,UAAU,CAAC,KAAa;IAC/B,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,CAAC;IACvE,OAAO;;eAEM,iBAAiB;;EAE9B,IAAI,CAAC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Df,CAAC;AACF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI;SACR,OAAO,CAAC,YAAY,EAAE,iBAAiB,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