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,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single "may we send?" predicate, checked before every append and again
|
|
3
|
+
* before every send.
|
|
4
|
+
*
|
|
5
|
+
* Four independent gates, in the order a user would expect them to win:
|
|
6
|
+
*
|
|
7
|
+
* 1. A key at all — dev builds and forks have none (see key.ts), so the whole
|
|
8
|
+
* subsystem is inert for anyone who did not install a published graft.
|
|
9
|
+
* 2. `DO_NOT_TRACK` — the cross-tool convention (consoledonottrack.com).
|
|
10
|
+
* Honoured unconditionally: it outranks our own setting, because a user who
|
|
11
|
+
* set it machine-wide has already answered the question for every tool.
|
|
12
|
+
* 3. CI — a build server is not a user. Counting it would inflate every number
|
|
13
|
+
* we care about and tell us nothing about a person.
|
|
14
|
+
* 4. The user's own choice, from the `graft init` picker or
|
|
15
|
+
* `graft telemetry disable`. Default on when never set.
|
|
16
|
+
*
|
|
17
|
+
* Re-checked at every append rather than cached at boot, so `graft telemetry
|
|
18
|
+
* disable` in one terminal takes effect in a long-lived MCP server in another
|
|
19
|
+
* without a restart.
|
|
20
|
+
*/
|
|
21
|
+
import { posthogKey } from './key.js';
|
|
22
|
+
import { readState } from './identity.js';
|
|
23
|
+
import { cmd } from '../brand.js';
|
|
24
|
+
/** The `DO_NOT_TRACK` convention: set and not `0`/empty means "off". */
|
|
25
|
+
export function doNotTrack(env = process.env) {
|
|
26
|
+
const v = env.DO_NOT_TRACK;
|
|
27
|
+
return v !== undefined && v !== '' && v !== '0';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Every variable {@link inCi} reads, named once.
|
|
31
|
+
*
|
|
32
|
+
* Exported because a test that needs telemetry actually ON has to clear all of
|
|
33
|
+
* them, and clearing a hand-copied subset is how this list silently drifts: the
|
|
34
|
+
* `cursor-session-end` test cleared `CI` alone, so it passed on a laptop and failed
|
|
35
|
+
* on GitHub Actions — where `GITHUB_ACTIONS` is set — for every run until someone
|
|
36
|
+
* read the log. One list, both callers.
|
|
37
|
+
*/
|
|
38
|
+
export const CI_ENV_VARS = [
|
|
39
|
+
'CI', 'GITHUB_ACTIONS', 'GITLAB_CI', 'BUILDKITE', 'CIRCLECI',
|
|
40
|
+
'TEAMCITY_VERSION', 'JENKINS_URL', 'TF_BUILD', 'BUILD_NUMBER',
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* CI detection. `CI` covers essentially every provider; the rest are the ones
|
|
44
|
+
* that historically did not set it. Deliberately generous — a false positive
|
|
45
|
+
* costs one uncounted user, a false negative pollutes the dataset.
|
|
46
|
+
*
|
|
47
|
+
* `CI` is the one read with a value test: `CI=false` is a real thing a user sets
|
|
48
|
+
* to mean "not CI", while the provider-specific vars are presence-only — none of
|
|
49
|
+
* them is ever deliberately set to a falsy string.
|
|
50
|
+
*/
|
|
51
|
+
export function inCi(env = process.env) {
|
|
52
|
+
if (env.CI !== undefined && env.CI !== '' && env.CI !== '0' && env.CI !== 'false')
|
|
53
|
+
return true;
|
|
54
|
+
return CI_ENV_VARS.some((name) => name !== 'CI' && Boolean(env[name]));
|
|
55
|
+
}
|
|
56
|
+
/** Null when telemetry may run, otherwise the first gate that closed. */
|
|
57
|
+
export function offReason(home, env = process.env) {
|
|
58
|
+
if (!posthogKey())
|
|
59
|
+
return 'no-key';
|
|
60
|
+
if (doNotTrack(env))
|
|
61
|
+
return 'do-not-track';
|
|
62
|
+
if (inCi(env))
|
|
63
|
+
return 'ci';
|
|
64
|
+
if (readState(home)?.enabled === false)
|
|
65
|
+
return 'disabled';
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
export function telemetryOn(home, env = process.env) {
|
|
69
|
+
return offReason(home, env) === null;
|
|
70
|
+
}
|
|
71
|
+
/** One line for `graft telemetry status`, naming the gate that is closed so a
|
|
72
|
+
* user who thinks they disabled it can see which switch actually took. */
|
|
73
|
+
export function explainOff(reason) {
|
|
74
|
+
switch (reason) {
|
|
75
|
+
case 'no-key': return 'off: this build has no telemetry key (a fork, or a local `npm run build`), so nothing can be sent';
|
|
76
|
+
case 'do-not-track': return 'off: DO_NOT_TRACK is set in this environment';
|
|
77
|
+
case 'ci': return 'off: this looks like CI';
|
|
78
|
+
case 'disabled': return `off: you disabled it (\`${cmd('graft telemetry enable')}\` to turn it back on)`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../../src/telemetry/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlC,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC7D,MAAM,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC;IAC3B,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;AAClD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU;IAC5D,kBAAkB,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc;CACrD,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvD,IAAI,GAAG,CAAC,EAAE,KAAK,SAAS,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC/F,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,IAAa,EAAE,MAAyB,OAAO,CAAC,GAAG;IAC3E,IAAI,CAAC,UAAU,EAAE;QAAE,OAAO,QAAQ,CAAC;IACnC,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,cAAc,CAAC;IAC3C,IAAI,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,KAAK;QAAE,OAAO,UAAU,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAa,EAAE,MAAyB,OAAO,CAAC,GAAG;IAC7E,OAAO,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;AACvC,CAAC;AAED;2EAC2E;AAC3E,MAAM,UAAU,UAAU,CAAC,MAAiB;IAC1C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ,CAAC,CAAQ,OAAO,mGAAmG,CAAC;QACjI,KAAK,cAAc,CAAC,CAAE,OAAO,8CAA8C,CAAC;QAC5E,KAAK,IAAI,CAAC,CAAY,OAAO,yBAAyB,CAAC;QACvD,KAAK,UAAU,CAAC,CAAM,OAAO,2BAA2B,GAAG,CAAC,wBAAwB,CAAC,wBAAwB,CAAC;IAChH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Machine-global telemetry state. Shares `~/.graft/` with `update-check.json`. */
|
|
2
|
+
export interface TelemetryState {
|
|
3
|
+
installId: string;
|
|
4
|
+
/** The user's choice. Absent means "never chosen" → the default (on) applies. */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
/** ISO stamp of the one-time first-run notice, so it prints exactly once. */
|
|
7
|
+
noticeShownAt?: string;
|
|
8
|
+
/** ISO stamp of the `first_run` event. Its own field rather than "did this
|
|
9
|
+
* call mint the install id", because the postinstall hook now mints the id
|
|
10
|
+
* before any command runs — see `trackFirstRunIfNew`. */
|
|
11
|
+
firstRunAt?: string;
|
|
12
|
+
/** The version the `install` event was last sent for, so an upgrade counts as
|
|
13
|
+
* an install and a repeated `npm install` of the same version does not. */
|
|
14
|
+
installedVersion?: string;
|
|
15
|
+
/** Epoch ms of the last flush ATTEMPT, mirroring `UpdateCache.checkedAt`. */
|
|
16
|
+
flushedAt?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function statePath(home?: string): string;
|
|
19
|
+
export declare function readState(home?: string): TelemetryState | null;
|
|
20
|
+
/** Read-modify-write. Not atomic across processes; a lost update costs at most a
|
|
21
|
+
* duplicated notice or an extra flush attempt, never corruption. */
|
|
22
|
+
export declare function patchState(patch: Partial<TelemetryState>, home?: string): TelemetryState;
|
|
23
|
+
export interface Install {
|
|
24
|
+
id: string;
|
|
25
|
+
/** True when this call minted the id, i.e. this is the machine's first run. */
|
|
26
|
+
firstRun: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** The install id, minted on first call. */
|
|
29
|
+
export declare function installId(home?: string): Install;
|
|
30
|
+
/**
|
|
31
|
+
* The repo id, in `graft/.cache/` rather than `.graft/config.json`.
|
|
32
|
+
*
|
|
33
|
+
* `.graft/config.json` would have been the tidier home, but writing it runs
|
|
34
|
+
* `ensureBuildConfigIgnored`, which appends to the repo's `.gitignore`. Minting
|
|
35
|
+
* an id during a read-only `graft ask` must not modify a file the user has
|
|
36
|
+
* committed. `graft/.cache/` is already derived, already git-ignored, and
|
|
37
|
+
* already where every other per-repo sidecar lives.
|
|
38
|
+
*/
|
|
39
|
+
export declare function repoId(repo: string): string;
|
|
40
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/telemetry/identity.ts"],"names":[],"mappings":"AA0BA,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;8DAE0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;gFAC4E;IAC5E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE1D;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAE9D;AAED;qEACqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAIxF;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,4CAA4C;AAC5C,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAahD;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO3C"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two identifiers, and why neither of them identifies anyone.
|
|
3
|
+
*
|
|
4
|
+
* • install id — one per machine, in `~/.graft/telemetry.json`, beside the
|
|
5
|
+
* update-check cache that already lives there. Lets us count people rather
|
|
6
|
+
* than events, so a dev running forty queries is one user and not forty.
|
|
7
|
+
* • repo id — one per checkout, in `graft/.cache/`. Activation and retention
|
|
8
|
+
* for graft are per-repo facts ("did this repo ever get past build?"), and
|
|
9
|
+
* the install id alone cannot express them.
|
|
10
|
+
*
|
|
11
|
+
* Both are `randomUUID()`. Not a machine id, not a hash of the git remote, not
|
|
12
|
+
* derived from anything real — a coin flip, written down. A hash would at least
|
|
13
|
+
* be guessable by us (we could hash a public repo URL and look for it); a random
|
|
14
|
+
* UUID cannot be reversed or confirmed even in principle. Deleting `~/.graft/`
|
|
15
|
+
* or `graft/` deletes them, and the user simply looks like someone new.
|
|
16
|
+
*
|
|
17
|
+
* Every function here is fail-soft: an unwritable home is a very common state
|
|
18
|
+
* (a locked-down CI image, a read-only container) and it must cost the caller
|
|
19
|
+
* nothing. A failed persist yields an ephemeral id for this process — still
|
|
20
|
+
* anonymous, just not stable — and never a throw.
|
|
21
|
+
*/
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
import { randomUUID } from 'node:crypto';
|
|
25
|
+
import { cacheDir, readJson, writeJsonAtomic } from '../util/state.js';
|
|
26
|
+
export function statePath(home = homedir()) {
|
|
27
|
+
return join(home, '.graft', 'telemetry.json');
|
|
28
|
+
}
|
|
29
|
+
export function readState(home) {
|
|
30
|
+
return readJson(statePath(home));
|
|
31
|
+
}
|
|
32
|
+
/** Read-modify-write. Not atomic across processes; a lost update costs at most a
|
|
33
|
+
* duplicated notice or an extra flush attempt, never corruption. */
|
|
34
|
+
export function patchState(patch, home) {
|
|
35
|
+
const next = { ...(readState(home) ?? { installId: randomUUID() }), ...patch };
|
|
36
|
+
try {
|
|
37
|
+
writeJsonAtomic(statePath(home), next);
|
|
38
|
+
}
|
|
39
|
+
catch { /* unwritable home — in-memory only */ }
|
|
40
|
+
return next;
|
|
41
|
+
}
|
|
42
|
+
/** The install id, minted on first call. */
|
|
43
|
+
export function installId(home) {
|
|
44
|
+
const existing = readState(home);
|
|
45
|
+
if (existing?.installId)
|
|
46
|
+
return { id: existing.installId, firstRun: false };
|
|
47
|
+
const id = randomUUID();
|
|
48
|
+
try {
|
|
49
|
+
writeJsonAtomic(statePath(home), { ...(existing ?? {}), installId: id });
|
|
50
|
+
return { id, firstRun: true };
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Unwritable home: use the id for this process rather than failing closed.
|
|
54
|
+
// Reported as firstRun:false so a machine that can never persist doesn't
|
|
55
|
+
// send a first_run event on every single command.
|
|
56
|
+
return { id, firstRun: false };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The repo id, in `graft/.cache/` rather than `.graft/config.json`.
|
|
61
|
+
*
|
|
62
|
+
* `.graft/config.json` would have been the tidier home, but writing it runs
|
|
63
|
+
* `ensureBuildConfigIgnored`, which appends to the repo's `.gitignore`. Minting
|
|
64
|
+
* an id during a read-only `graft ask` must not modify a file the user has
|
|
65
|
+
* committed. `graft/.cache/` is already derived, already git-ignored, and
|
|
66
|
+
* already where every other per-repo sidecar lives.
|
|
67
|
+
*/
|
|
68
|
+
export function repoId(repo) {
|
|
69
|
+
const path = join(cacheDir(repo), 'telemetry-repo-id.json');
|
|
70
|
+
const existing = readJson(path);
|
|
71
|
+
if (existing?.repoId)
|
|
72
|
+
return existing.repoId;
|
|
73
|
+
const id = randomUUID();
|
|
74
|
+
try {
|
|
75
|
+
writeJsonAtomic(path, { repoId: id });
|
|
76
|
+
}
|
|
77
|
+
catch { /* unwritable — ephemeral */ }
|
|
78
|
+
return id;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/telemetry/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAoBvE,MAAM,UAAU,SAAS,CAAC,OAAe,OAAO,EAAE;IAChD,OAAO,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,QAAQ,CAAiB,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;qEACqE;AACrE,MAAM,UAAU,UAAU,CAAC,KAA8B,EAAE,IAAa;IACtE,MAAM,IAAI,GAAmB,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC;IAC/F,IAAI,CAAC;QAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,sCAAsC,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC;AAQD,4CAA4C;AAC5C,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,QAAQ,EAAE,SAAS;QAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC5E,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,IAAI,CAAC;QACH,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAA2B,CAAC,CAAC;QAClG,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,yEAAyE;QACzE,kDAAkD;QAClD,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACjC,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,wBAAwB,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,QAAQ,CAAsB,IAAI,CAAC,CAAC;IACrD,IAAI,QAAQ,EAAE,MAAM;QAAE,OAAO,QAAQ,CAAC,MAAM,CAAC;IAC7C,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,IAAI,CAAC;QAAC,eAAe,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,4BAA4B,CAAC,CAAC;IACrF,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anonymous adoption telemetry. `TELEMETRY.md` is the public contract;
|
|
3
|
+
* `contract.ts` is the same list enforced in code.
|
|
4
|
+
*
|
|
5
|
+
* The whole subsystem is inert unless four things are true at once: the build
|
|
6
|
+
* carries a key (published releases only), `DO_NOT_TRACK` is unset, this is not
|
|
7
|
+
* CI, and the user has not disabled it. See `gate.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export { EVENTS, VALUES, COMMON_KEYS, isTrackedCommand, errorCode, filesBucket, durationBucket, countBucket, savedTokensBucket, hookMsBucket, langsValue } from './contract.js';
|
|
10
|
+
export type { AgentHost, Surface, TrackedCommand, BuildStage, ErrorCode } from './contract.js';
|
|
11
|
+
export { track, trackFirstRunIfNew, trackInstallIfNew, detectHost } from './track.js';
|
|
12
|
+
export type { QueuedEvent, TrackContext } from './track.js';
|
|
13
|
+
export { telemetryOn, offReason, explainOff } from './gate.js';
|
|
14
|
+
export { maybeFlushInBackground, runFlush } from './flush.js';
|
|
15
|
+
export { firstRunNotice, formatStatus, formatDebug, NOTICE, TELEMETRY_DOC_URL } from './notice.js';
|
|
16
|
+
export { patchState, readState } from './identity.js';
|
|
17
|
+
export { flushClosedSessions, summarizeSession } from './sessions.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChL,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtF,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anonymous adoption telemetry. `TELEMETRY.md` is the public contract;
|
|
3
|
+
* `contract.ts` is the same list enforced in code.
|
|
4
|
+
*
|
|
5
|
+
* The whole subsystem is inert unless four things are true at once: the build
|
|
6
|
+
* carries a key (published releases only), `DO_NOT_TRACK` is unset, this is not
|
|
7
|
+
* CI, and the user has not disabled it. See `gate.ts`.
|
|
8
|
+
*/
|
|
9
|
+
export { EVENTS, VALUES, COMMON_KEYS, isTrackedCommand, errorCode, filesBucket, durationBucket, countBucket, savedTokensBucket, hookMsBucket, langsValue } from './contract.js';
|
|
10
|
+
export { track, trackFirstRunIfNew, trackInstallIfNew, detectHost } from './track.js';
|
|
11
|
+
export { telemetryOn, offReason, explainOff } from './gate.js';
|
|
12
|
+
export { maybeFlushInBackground, runFlush } from './flush.js';
|
|
13
|
+
export { firstRunNotice, formatStatus, formatDebug, NOTICE, TELEMETRY_DOC_URL } from './notice.js';
|
|
14
|
+
export { patchState, readState } from './identity.js';
|
|
15
|
+
export { flushClosedSessions, summarizeSession } from './sessions.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhL,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PostHog project key, and the reason forks stay silent.
|
|
3
|
+
*
|
|
4
|
+
* `BAKED_KEY` is empty in the repository and is rewritten in place by
|
|
5
|
+
* `scripts/stamp-telemetry-key.mjs`, which runs from `prepublishOnly`. So the
|
|
6
|
+
* key exists only in the published tarball: a clone, a fork, and a plain
|
|
7
|
+
* `npm run build` all compile to `''`, and every send path short-circuits. A
|
|
8
|
+
* contributor cannot accidentally send us their own usage, and a fork cannot
|
|
9
|
+
* send us anything at all.
|
|
10
|
+
*
|
|
11
|
+
* `GRAFT_POSTHOG_KEY` overrides it at runtime so a maintainer can exercise the
|
|
12
|
+
* real path locally without publishing.
|
|
13
|
+
*
|
|
14
|
+
* Public project keys are write-only ingestion keys — they authorise capture and
|
|
15
|
+
* nothing else — which is why one may sit in a published artifact at all. It is
|
|
16
|
+
* still not committed here: an empty default is what makes "forks never send"
|
|
17
|
+
* true by construction rather than by policy.
|
|
18
|
+
*/
|
|
19
|
+
export declare function posthogKey(): string;
|
|
20
|
+
export declare function posthogHost(): string;
|
|
21
|
+
//# sourceMappingURL=key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/telemetry/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA4BH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PostHog project key, and the reason forks stay silent.
|
|
3
|
+
*
|
|
4
|
+
* `BAKED_KEY` is empty in the repository and is rewritten in place by
|
|
5
|
+
* `scripts/stamp-telemetry-key.mjs`, which runs from `prepublishOnly`. So the
|
|
6
|
+
* key exists only in the published tarball: a clone, a fork, and a plain
|
|
7
|
+
* `npm run build` all compile to `''`, and every send path short-circuits. A
|
|
8
|
+
* contributor cannot accidentally send us their own usage, and a fork cannot
|
|
9
|
+
* send us anything at all.
|
|
10
|
+
*
|
|
11
|
+
* `GRAFT_POSTHOG_KEY` overrides it at runtime so a maintainer can exercise the
|
|
12
|
+
* real path locally without publishing.
|
|
13
|
+
*
|
|
14
|
+
* Public project keys are write-only ingestion keys — they authorise capture and
|
|
15
|
+
* nothing else — which is why one may sit in a published artifact at all. It is
|
|
16
|
+
* still not committed here: an empty default is what makes "forks never send"
|
|
17
|
+
* true by construction rather than by policy.
|
|
18
|
+
*/
|
|
19
|
+
/** Rewritten at publish time. Do not hand-edit — see the module comment. */
|
|
20
|
+
const BAKED_KEY = '';
|
|
21
|
+
/**
|
|
22
|
+
* Nanonets' own PostHog host, not `us.i.posthog.com`.
|
|
23
|
+
*
|
|
24
|
+
* Every Nanonets product ingests through a nanonets.com proxy rather than
|
|
25
|
+
* PostHog directly, on one shared project token, so pointing graft at PostHog
|
|
26
|
+
* Cloud would put its events in a project nobody looks at.
|
|
27
|
+
*
|
|
28
|
+
* `events.` rather than `e.` because graft is server-side, and this is the host
|
|
29
|
+
* the other server-side integration already uses (the agents-platform Go
|
|
30
|
+
* backend sets `POSTHOG_HOST=https://events.nanonets.com`). The one documented
|
|
31
|
+
* objection to it — 400 `invalid_payload` — was gzip-compressed ingest from
|
|
32
|
+
* `posthog-js` in a browser, fixed there with `disable_compression: true`. We
|
|
33
|
+
* send plain uncompressed JSON from Node, so that failure mode cannot apply.
|
|
34
|
+
*
|
|
35
|
+
* Probed directly, that host answers 401 to a well-formed batch with a bad key,
|
|
36
|
+
* so it serves `/batch/` and parses the body — see the note in send.ts.
|
|
37
|
+
*
|
|
38
|
+
* The HOST is safe to commit; the KEY is not, and stays empty here. That
|
|
39
|
+
* asymmetry is the point: with no key, a fork built from this source sends
|
|
40
|
+
* nothing no matter where the host points.
|
|
41
|
+
*/
|
|
42
|
+
const BAKED_HOST = 'https://events.nanonets.com';
|
|
43
|
+
export function posthogKey() {
|
|
44
|
+
return process.env.GRAFT_POSTHOG_KEY || BAKED_KEY;
|
|
45
|
+
}
|
|
46
|
+
export function posthogHost() {
|
|
47
|
+
return (process.env.GRAFT_POSTHOG_HOST || BAKED_HOST).replace(/\/+$/, '');
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../src/telemetry/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,4EAA4E;AAC5E,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,GAAG,6BAA6B,CAAC;AAEjD,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,UAAU,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const TELEMETRY_DOC_URL = "https://github.com/trailhq/Trail-Code/blob/main/TELEMETRY.md";
|
|
2
|
+
export declare const NOTICE: string;
|
|
3
|
+
/**
|
|
4
|
+
* The notice text the first time it is due, then null forever after. Marks it as
|
|
5
|
+
* shown before returning, so two concurrent commands print it at most twice
|
|
6
|
+
* rather than every time.
|
|
7
|
+
*/
|
|
8
|
+
export declare function firstRunNotice(home?: string, env?: NodeJS.ProcessEnv): string | null;
|
|
9
|
+
/** `graft telemetry status`. `env` is a test seam, as elsewhere in this module —
|
|
10
|
+
* a real run must be gated on the real `DO_NOT_TRACK` and CI variables. */
|
|
11
|
+
export declare function formatStatus(home?: string, env?: NodeJS.ProcessEnv): string;
|
|
12
|
+
/**
|
|
13
|
+
* `graft telemetry debug` — Next.js's `NEXT_TELEMETRY_DEBUG` and Astro's
|
|
14
|
+
* `DEBUG=astro:telemetry` in command form. Prints the pending queue and the
|
|
15
|
+
* literal JSON body a flush would POST, and sends nothing. The point is that a
|
|
16
|
+
* user never has to take our word for the contract.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatDebug(home?: string): string;
|
|
19
|
+
//# sourceMappingURL=notice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../src/telemetry/notice.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,iBAAiB,iEAAiE,CAAC;AAEhG,eAAO,MAAM,MAAM,QAGP,CAAC;AAEb;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CASpF;AAED;4EAC4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAqB3E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBjD"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one-time disclosure, and the `graft telemetry` command's output.
|
|
3
|
+
*
|
|
4
|
+
* The notice is the whole reason this design is defensible. Every telemetry
|
|
5
|
+
* backlash in the tools we looked at — the GitHub CLI's silent 2.91.0 rollout,
|
|
6
|
+
* Gatsby's on-by-default addition, the .NET SDK's opt-out that distributors now
|
|
7
|
+
* patch out — was about a tool that started sending without saying so. Homebrew
|
|
8
|
+
* does exactly what is done here and is uncontroversial: print once, in plain
|
|
9
|
+
* language, before anything leaves, and say how to turn it off in the same
|
|
10
|
+
* breath.
|
|
11
|
+
*
|
|
12
|
+
* Once per MACHINE, not per repo: a dev with twelve checkouts should read this
|
|
13
|
+
* one time. `graft init`'s picker is the other disclosure surface, for the users
|
|
14
|
+
* who see it — this catches everyone else.
|
|
15
|
+
*/
|
|
16
|
+
import { patchState, readState } from './identity.js';
|
|
17
|
+
import { doNotTrack, explainOff, offReason } from './gate.js';
|
|
18
|
+
import { peek } from './queue.js';
|
|
19
|
+
import { buildBatch } from './send.js';
|
|
20
|
+
import { posthogHost } from './key.js';
|
|
21
|
+
import { brand, cmd, inBrand } from '../brand.js';
|
|
22
|
+
export const TELEMETRY_DOC_URL = 'https://github.com/trailhq/Trail-Code/blob/main/TELEMETRY.md';
|
|
23
|
+
export const NOTICE = [
|
|
24
|
+
'· graft collects anonymous usage stats (no code, no file paths, no queries).',
|
|
25
|
+
` What exactly: ${TELEMETRY_DOC_URL}. Turn it off with \`graft telemetry disable\`.`,
|
|
26
|
+
].join('\n');
|
|
27
|
+
/**
|
|
28
|
+
* The notice text the first time it is due, then null forever after. Marks it as
|
|
29
|
+
* shown before returning, so two concurrent commands print it at most twice
|
|
30
|
+
* rather than every time.
|
|
31
|
+
*/
|
|
32
|
+
export function firstRunNotice(home, env) {
|
|
33
|
+
try {
|
|
34
|
+
if (offReason(home, env) !== null)
|
|
35
|
+
return null; // nothing to disclose if nothing can be sent
|
|
36
|
+
if (readState(home)?.noticeShownAt)
|
|
37
|
+
return null;
|
|
38
|
+
patchState({ noticeShownAt: new Date().toISOString() }, home);
|
|
39
|
+
return inBrand(NOTICE, brand(env));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** `graft telemetry status`. `env` is a test seam, as elsewhere in this module —
|
|
46
|
+
* a real run must be gated on the real `DO_NOT_TRACK` and CI variables. */
|
|
47
|
+
export function formatStatus(home, env) {
|
|
48
|
+
const reason = offReason(home, env);
|
|
49
|
+
const pending = peek(home).length;
|
|
50
|
+
const lines = [
|
|
51
|
+
reason === null
|
|
52
|
+
? 'telemetry: on, anonymous and aggregate-only'
|
|
53
|
+
: `telemetry: ${explainOff(reason)}`,
|
|
54
|
+
` contract: ${TELEMETRY_DOC_URL}`,
|
|
55
|
+
];
|
|
56
|
+
if (doNotTrack(env))
|
|
57
|
+
lines.push(' update check: off — DO_NOT_TRACK is set');
|
|
58
|
+
if (reason === null || reason === 'disabled') {
|
|
59
|
+
lines.push(` endpoint: ${posthogHost()}`);
|
|
60
|
+
lines.push(` queued: ${pending} event${pending === 1 ? '' : 's'} waiting for the next daily flush`);
|
|
61
|
+
}
|
|
62
|
+
lines.push(reason === 'disabled'
|
|
63
|
+
? ` enable: ${cmd('graft telemetry enable')}`
|
|
64
|
+
: ` disable: ${cmd('graft telemetry disable')} (or set DO_NOT_TRACK=1)`);
|
|
65
|
+
lines.push(` inspect: ${cmd('graft telemetry debug')} (prints the exact batch, sends nothing)`);
|
|
66
|
+
return lines.join('\n');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* `graft telemetry debug` — Next.js's `NEXT_TELEMETRY_DEBUG` and Astro's
|
|
70
|
+
* `DEBUG=astro:telemetry` in command form. Prints the pending queue and the
|
|
71
|
+
* literal JSON body a flush would POST, and sends nothing. The point is that a
|
|
72
|
+
* user never has to take our word for the contract.
|
|
73
|
+
*/
|
|
74
|
+
export function formatDebug(home) {
|
|
75
|
+
const events = peek(home);
|
|
76
|
+
if (events.length === 0) {
|
|
77
|
+
return [
|
|
78
|
+
'telemetry: nothing queued.',
|
|
79
|
+
' Run a graft command first: events are written locally and flushed once a day.',
|
|
80
|
+
].join('\n');
|
|
81
|
+
}
|
|
82
|
+
// A literal placeholder, never the key itself. This output is written to be
|
|
83
|
+
// pasted into an issue; the project key is not the user's to share and is not
|
|
84
|
+
// needed to audit what graft sends.
|
|
85
|
+
const body = { api_key: '<omitted: graft\'s own ingestion key>', ...buildBatch(events) };
|
|
86
|
+
return [
|
|
87
|
+
`telemetry: ${events.length} event(s) queued. This is the exact body a flush would POST`,
|
|
88
|
+
`to ${posthogHost()}/batch/. Running this command sends nothing.`,
|
|
89
|
+
'',
|
|
90
|
+
JSON.stringify(body, null, 2),
|
|
91
|
+
].join('\n');
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notice.js","sourceRoot":"","sources":["../../src/telemetry/notice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,8DAA8D,CAAC;AAEhG,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,8EAA8E;IAC9E,mBAAmB,iBAAiB,iDAAiD;CACtF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAa,EAAE,GAAuB;IACnE,IAAI,CAAC;QACH,IAAI,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,CAAC,6CAA6C;QAC7F,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,aAAa;YAAE,OAAO,IAAI,CAAC;QAChD,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAC9D,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;4EAC4E;AAC5E,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,GAAuB;IACjE,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAClC,MAAM,KAAK,GAAG;QACZ,MAAM,KAAK,IAAI;YACb,CAAC,CAAC,6CAA6C;YAC/C,CAAC,CAAC,cAAc,UAAU,CAAC,MAAM,CAAC,EAAE;QACtC,gBAAgB,iBAAiB,EAAE;KACpC,CAAC;IACF,IAAI,UAAU,CAAC,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;IAC7E,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QAC7C,KAAK,CAAC,IAAI,CAAC,gBAAgB,WAAW,EAAE,EAAE,CAAC,CAAC;QAC5C,KAAK,CAAC,IAAI,CAAC,gBAAgB,OAAO,SAAS,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,mCAAmC,CAAC,CAAC;IAC1G,CAAC;IACD,KAAK,CAAC,IAAI,CACR,MAAM,KAAK,UAAU;QACnB,CAAC,CAAC,gBAAgB,GAAG,CAAC,wBAAwB,CAAC,EAAE;QACjD,CAAC,CAAC,gBAAgB,GAAG,CAAC,yBAAyB,CAAC,2BAA2B,CAC9E,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,gBAAgB,GAAG,CAAC,uBAAuB,CAAC,4CAA4C,CAAC,CAAC;IACrG,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;YACL,4BAA4B;YAC5B,iFAAiF;SAClF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,CAAC;IACD,4EAA4E;IAC5E,8EAA8E;IAC9E,oCAAoC;IACpC,MAAM,IAAI,GAAG,EAAE,OAAO,EAAE,uCAAuC,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;IACzF,OAAO;QACL,cAAc,MAAM,CAAC,MAAM,6DAA6D;QACxF,MAAM,WAAW,EAAE,8CAA8C;QACjE,EAAE;QACF,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ceiling on the queue. An unflushable machine — permanently offline, or a
|
|
3
|
+
* key that never works — must not grow a file in someone's home forever.
|
|
4
|
+
*
|
|
5
|
+
* Bytes are the bound, because size is the only thing cheap enough to check on
|
|
6
|
+
* every append (one `statSync`); counting lines would mean reading the whole
|
|
7
|
+
* file each time. {@link TRIM_TO_EVENTS} is not a second ceiling — it is how
|
|
8
|
+
* FAR a trim cuts back, so a queue of unusually small events sheds a worthwhile
|
|
9
|
+
* amount rather than one line at a time. Between trims the file can hold more
|
|
10
|
+
* than that many events, and can exceed the byte bound by one append.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MAX_QUEUE_BYTES: number;
|
|
13
|
+
export declare const TRIM_TO_EVENTS = 500;
|
|
14
|
+
export declare function queuePath(home?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Append one event. Never throws — a full disk or a read-only home must not fail
|
|
17
|
+
* the command the user actually ran.
|
|
18
|
+
*/
|
|
19
|
+
export declare function enqueue(event: unknown, home?: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Take everything pending, leaving an empty queue behind.
|
|
22
|
+
*
|
|
23
|
+
* The rename is what makes this safe against a concurrent append: from the
|
|
24
|
+
* instant it returns, other processes are writing to a brand-new file. Malformed
|
|
25
|
+
* lines are skipped rather than poisoning the batch — a torn write from a crash
|
|
26
|
+
* mid-append should cost one event, not the whole queue.
|
|
27
|
+
*/
|
|
28
|
+
export declare function drain(home?: string): unknown[];
|
|
29
|
+
/** Read without draining, for `graft telemetry debug`. */
|
|
30
|
+
export declare function peek(home?: string): unknown[];
|
|
31
|
+
/** Put a failed batch back, so a flush that could not reach the network does not
|
|
32
|
+
* silently discard a week of events. Oldest-first, ahead of anything queued
|
|
33
|
+
* since the drain. */
|
|
34
|
+
export declare function requeue(events: unknown[], home?: string): void;
|
|
35
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/telemetry/queue.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,QAAa,CAAC;AAC1C,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE1D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAO3D;AA6BD;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAa9C;AAED,0DAA0D;AAC1D,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,CAS7C;AAED;;uBAEuB;AACvB,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAQ9D"}
|