@openclaw/tokenjuice 2026.5.28
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/README.md +35 -0
- package/dist/index.js +13 -0
- package/dist/runtime-api.js +2 -0
- package/dist/tool-result-middleware.js +34 -0
- package/node_modules/tokenjuice/LICENSE +21 -0
- package/node_modules/tokenjuice/README.md +311 -0
- package/node_modules/tokenjuice/SECURITY.md +50 -0
- package/node_modules/tokenjuice/dist/cli/doctor-output.d.ts +2 -0
- package/node_modules/tokenjuice/dist/cli/doctor-output.js +92 -0
- package/node_modules/tokenjuice/dist/cli/install-output.d.ts +5 -0
- package/node_modules/tokenjuice/dist/cli/install-output.js +11 -0
- package/node_modules/tokenjuice/dist/cli/main.d.ts +34 -0
- package/node_modules/tokenjuice/dist/cli/main.js +6614 -0
- package/node_modules/tokenjuice/dist/core/analysis.d.ts +88 -0
- package/node_modules/tokenjuice/dist/core/analysis.js +313 -0
- package/node_modules/tokenjuice/dist/core/artifacts.d.ts +9 -0
- package/node_modules/tokenjuice/dist/core/artifacts.js +210 -0
- package/node_modules/tokenjuice/dist/core/builtin-rules.generated.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/builtin-rules.generated.js +262 -0
- package/node_modules/tokenjuice/dist/core/classify.d.ts +18 -0
- package/node_modules/tokenjuice/dist/core/classify.js +181 -0
- package/node_modules/tokenjuice/dist/core/cli-client.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/cli-client.js +127 -0
- package/node_modules/tokenjuice/dist/core/command-identity.d.ts +9 -0
- package/node_modules/tokenjuice/dist/core/command-identity.js +201 -0
- package/node_modules/tokenjuice/dist/core/command-match.d.ts +16 -0
- package/node_modules/tokenjuice/dist/core/command-match.js +443 -0
- package/node_modules/tokenjuice/dist/core/command-shell.d.ts +18 -0
- package/node_modules/tokenjuice/dist/core/command-shell.js +291 -0
- package/node_modules/tokenjuice/dist/core/command.d.ts +5 -0
- package/node_modules/tokenjuice/dist/core/command.js +4 -0
- package/node_modules/tokenjuice/dist/core/compaction-metadata.d.ts +10 -0
- package/node_modules/tokenjuice/dist/core/compaction-metadata.js +28 -0
- package/node_modules/tokenjuice/dist/core/env.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/env.js +5 -0
- package/node_modules/tokenjuice/dist/core/execution-input.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/execution-input.js +51 -0
- package/node_modules/tokenjuice/dist/core/fixtures.d.ts +14 -0
- package/node_modules/tokenjuice/dist/core/fixtures.js +190 -0
- package/node_modules/tokenjuice/dist/core/github-actions-summary.d.ts +6 -0
- package/node_modules/tokenjuice/dist/core/github-actions-summary.js +105 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.d.ts +33 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.js +85 -0
- package/node_modules/tokenjuice/dist/core/integrations/rewrite-policy.d.ts +8 -0
- package/node_modules/tokenjuice/dist/core/integrations/rewrite-policy.js +25 -0
- package/node_modules/tokenjuice/dist/core/inventory-safety.d.ts +11 -0
- package/node_modules/tokenjuice/dist/core/inventory-safety.js +347 -0
- package/node_modules/tokenjuice/dist/core/json-protocol.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/json-protocol.js +131 -0
- package/node_modules/tokenjuice/dist/core/reduce-formatters.d.ts +15 -0
- package/node_modules/tokenjuice/dist/core/reduce-formatters.js +611 -0
- package/node_modules/tokenjuice/dist/core/reduce-inspection-summary.d.ts +9 -0
- package/node_modules/tokenjuice/dist/core/reduce-inspection-summary.js +125 -0
- package/node_modules/tokenjuice/dist/core/reduce-utils.d.ts +12 -0
- package/node_modules/tokenjuice/dist/core/reduce-utils.js +117 -0
- package/node_modules/tokenjuice/dist/core/reduce.d.ts +5 -0
- package/node_modules/tokenjuice/dist/core/reduce.js +511 -0
- package/node_modules/tokenjuice/dist/core/rules.d.ts +22 -0
- package/node_modules/tokenjuice/dist/core/rules.js +265 -0
- package/node_modules/tokenjuice/dist/core/source.d.ts +6 -0
- package/node_modules/tokenjuice/dist/core/source.js +113 -0
- package/node_modules/tokenjuice/dist/core/text.d.ts +23 -0
- package/node_modules/tokenjuice/dist/core/text.js +204 -0
- package/node_modules/tokenjuice/dist/core/time.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/time.js +82 -0
- package/node_modules/tokenjuice/dist/core/validate-rules.d.ts +10 -0
- package/node_modules/tokenjuice/dist/core/validate-rules.js +198 -0
- package/node_modules/tokenjuice/dist/core/wrap.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/wrap.js +104 -0
- package/node_modules/tokenjuice/dist/hosts/adal/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/adal/index.js +157 -0
- package/node_modules/tokenjuice/dist/hosts/aether/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/aether/index.js +671 -0
- package/node_modules/tokenjuice/dist/hosts/agent-layer/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/agent-layer/index.js +173 -0
- package/node_modules/tokenjuice/dist/hosts/agentinit/index.d.ts +27 -0
- package/node_modules/tokenjuice/dist/hosts/agentinit/index.js +252 -0
- package/node_modules/tokenjuice/dist/hosts/agentlink/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/agentlink/index.js +310 -0
- package/node_modules/tokenjuice/dist/hosts/agentloom/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/agentloom/index.js +161 -0
- package/node_modules/tokenjuice/dist/hosts/agents-cli/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/agents-cli/index.js +136 -0
- package/node_modules/tokenjuice/dist/hosts/agents-md/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/agents-md/index.js +240 -0
- package/node_modules/tokenjuice/dist/hosts/agentsge/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/agentsge/index.js +119 -0
- package/node_modules/tokenjuice/dist/hosts/agentsmesh/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/agentsmesh/index.js +337 -0
- package/node_modules/tokenjuice/dist/hosts/ai-memory-protocol/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/ai-memory-protocol/index.js +392 -0
- package/node_modules/tokenjuice/dist/hosts/aictl/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/aictl/index.js +271 -0
- package/node_modules/tokenjuice/dist/hosts/aider/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/aider/index.js +79 -0
- package/node_modules/tokenjuice/dist/hosts/amazon-q/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/amazon-q/index.js +169 -0
- package/node_modules/tokenjuice/dist/hosts/amp/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/amp/index.js +306 -0
- package/node_modules/tokenjuice/dist/hosts/antigravity/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/antigravity/index.js +172 -0
- package/node_modules/tokenjuice/dist/hosts/anywhere-agents/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/anywhere-agents/index.js +260 -0
- package/node_modules/tokenjuice/dist/hosts/augment/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/augment/index.js +171 -0
- package/node_modules/tokenjuice/dist/hosts/avante/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/avante/index.js +68 -0
- package/node_modules/tokenjuice/dist/hosts/baz/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/baz/index.js +286 -0
- package/node_modules/tokenjuice/dist/hosts/bito/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/bito/index.js +363 -0
- package/node_modules/tokenjuice/dist/hosts/blackbox/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/blackbox/index.js +305 -0
- package/node_modules/tokenjuice/dist/hosts/blocks/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/blocks/index.js +317 -0
- package/node_modules/tokenjuice/dist/hosts/bob/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/bob/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/builder/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/builder/index.js +177 -0
- package/node_modules/tokenjuice/dist/hosts/charlie/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/charlie/index.js +275 -0
- package/node_modules/tokenjuice/dist/hosts/claude-code/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/claude-code/index.js +364 -0
- package/node_modules/tokenjuice/dist/hosts/clawdbot/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/clawdbot/index.js +320 -0
- package/node_modules/tokenjuice/dist/hosts/cline/index.d.ts +27 -0
- package/node_modules/tokenjuice/dist/hosts/cline/index.js +156 -0
- package/node_modules/tokenjuice/dist/hosts/codeant/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/codeant/index.js +370 -0
- package/node_modules/tokenjuice/dist/hosts/codebuddy/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/codebuddy/index.js +379 -0
- package/node_modules/tokenjuice/dist/hosts/codebuff/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/codebuff/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/codegen/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/codegen/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/coder-agents/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/coder-agents/index.js +339 -0
- package/node_modules/tokenjuice/dist/hosts/coderabbit/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/coderabbit/index.js +599 -0
- package/node_modules/tokenjuice/dist/hosts/codex/index.d.ts +93 -0
- package/node_modules/tokenjuice/dist/hosts/codex/index.js +945 -0
- package/node_modules/tokenjuice/dist/hosts/command-code/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/command-code/index.js +366 -0
- package/node_modules/tokenjuice/dist/hosts/continue/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/continue/index.js +81 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-agent/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-agent/index.js +497 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-cli/index.d.ts +31 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-cli/index.js +428 -0
- package/node_modules/tokenjuice/dist/hosts/crush/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/crush/index.js +135 -0
- package/node_modules/tokenjuice/dist/hosts/cursor/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/cursor/index.js +293 -0
- package/node_modules/tokenjuice/dist/hosts/deepagents/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/deepagents/index.js +157 -0
- package/node_modules/tokenjuice/dist/hosts/devin/index.d.ts +31 -0
- package/node_modules/tokenjuice/dist/hosts/devin/index.js +283 -0
- package/node_modules/tokenjuice/dist/hosts/docker-agent/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/docker-agent/index.js +206 -0
- package/node_modules/tokenjuice/dist/hosts/dot-agents/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/dot-agents/index.js +171 -0
- package/node_modules/tokenjuice/dist/hosts/droid/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/droid/index.js +313 -0
- package/node_modules/tokenjuice/dist/hosts/eca/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/eca/index.js +347 -0
- package/node_modules/tokenjuice/dist/hosts/elyra/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/elyra/index.js +382 -0
- package/node_modules/tokenjuice/dist/hosts/firebase-studio/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/firebase-studio/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/forgecode/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/forgecode/index.js +273 -0
- package/node_modules/tokenjuice/dist/hosts/gemini-cli/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/gemini-cli/index.js +234 -0
- package/node_modules/tokenjuice/dist/hosts/gitlab-duo/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/gitlab-duo/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/goose/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/goose/index.js +288 -0
- package/node_modules/tokenjuice/dist/hosts/gptme/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/gptme/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/greptile/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/greptile/index.js +299 -0
- package/node_modules/tokenjuice/dist/hosts/grok-build/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/grok-build/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/grok-cli/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/grok-cli/index.js +262 -0
- package/node_modules/tokenjuice/dist/hosts/jean2/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/jean2/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/jetbrains-ai/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/jetbrains-ai/index.js +202 -0
- package/node_modules/tokenjuice/dist/hosts/jules/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/jules/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/junie/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/junie/index.js +68 -0
- package/node_modules/tokenjuice/dist/hosts/kilo/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/kilo/index.js +497 -0
- package/node_modules/tokenjuice/dist/hosts/kimi/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/kimi/index.js +255 -0
- package/node_modules/tokenjuice/dist/hosts/kiro/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/kiro/index.js +116 -0
- package/node_modules/tokenjuice/dist/hosts/knowns/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/knowns/index.js +273 -0
- package/node_modules/tokenjuice/dist/hosts/leanctl/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/leanctl/index.js +317 -0
- package/node_modules/tokenjuice/dist/hosts/localcode/index.d.ts +31 -0
- package/node_modules/tokenjuice/dist/hosts/localcode/index.js +539 -0
- package/node_modules/tokenjuice/dist/hosts/mcp-agent/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/mcp-agent/index.js +302 -0
- package/node_modules/tokenjuice/dist/hosts/mini-swe-agent/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/mini-swe-agent/index.js +226 -0
- package/node_modules/tokenjuice/dist/hosts/mistral-vibe/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/mistral-vibe/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/mux/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/mux/index.js +411 -0
- package/node_modules/tokenjuice/dist/hosts/novakit/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/novakit/index.js +273 -0
- package/node_modules/tokenjuice/dist/hosts/ona/index.d.ts +41 -0
- package/node_modules/tokenjuice/dist/hosts/ona/index.js +596 -0
- package/node_modules/tokenjuice/dist/hosts/open-interpreter/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/open-interpreter/index.js +348 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/extension.d.ts +8 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/extension.js +104 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/index.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/index.js +1 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.d.ts +17 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.js +9094 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/index.d.ts +21 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/index.js +163 -0
- package/node_modules/tokenjuice/dist/hosts/openhands/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/openhands/index.js +211 -0
- package/node_modules/tokenjuice/dist/hosts/openwebui/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/openwebui/index.js +245 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/pi-types.d.ts +79 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/pi-types.js +3 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.d.ts +5 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.js +9372 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/settings.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/settings.js +26 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status-panel.d.ts +3 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status-panel.js +72 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status.d.ts +20 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status.js +58 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/tool-result.d.ts +4 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/tool-result.js +24 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/utils.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/utils.js +6 -0
- package/node_modules/tokenjuice/dist/hosts/pi/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/pi/index.js +228 -0
- package/node_modules/tokenjuice/dist/hosts/pi-go/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/pi-go/index.js +352 -0
- package/node_modules/tokenjuice/dist/hosts/plandex/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/plandex/index.js +164 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/qodo/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/qodo/index.js +584 -0
- package/node_modules/tokenjuice/dist/hosts/qwen-code/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/qwen-code/index.js +276 -0
- package/node_modules/tokenjuice/dist/hosts/replit/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/replit/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/roo/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/roo/index.js +101 -0
- package/node_modules/tokenjuice/dist/hosts/rovo/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/rovo/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/ruler/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/ruler/index.js +157 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.d.ts +19 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.js +32 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.d.ts +5 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.js +94 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.d.ts +212 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.js +270 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-output.d.ts +4 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-output.js +15 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hooks-json-file.d.ts +18 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hooks-json-file.js +108 -0
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.d.ts +10 -0
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.js +70 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-doctor.d.ts +16 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-doctor.js +13 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-file.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-file.js +121 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-guidance.d.ts +7 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-guidance.js +12 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instructions.d.ts +32 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instructions.js +100 -0
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.d.ts +91 -0
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.js +186 -0
- package/node_modules/tokenjuice/dist/hosts/shared/tool-result.d.ts +15 -0
- package/node_modules/tokenjuice/dist/hosts/shared/tool-result.js +52 -0
- package/node_modules/tokenjuice/dist/hosts/stagewise/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/stagewise/index.js +468 -0
- package/node_modules/tokenjuice/dist/hosts/swe-agent/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/swe-agent/index.js +223 -0
- package/node_modules/tokenjuice/dist/hosts/tabby/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/tabby/index.js +469 -0
- package/node_modules/tokenjuice/dist/hosts/tabnine/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/tabnine/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/trae/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/trae/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/uipath/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/uipath/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/vscode-copilot/index.d.ts +32 -0
- package/node_modules/tokenjuice/dist/hosts/vscode-copilot/index.js +416 -0
- package/node_modules/tokenjuice/dist/hosts/warp/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/warp/index.js +181 -0
- package/node_modules/tokenjuice/dist/hosts/windsurf/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/windsurf/index.js +99 -0
- package/node_modules/tokenjuice/dist/hosts/zed/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/zed/index.js +68 -0
- package/node_modules/tokenjuice/dist/hosts/zencoder/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/zencoder/index.js +227 -0
- package/node_modules/tokenjuice/dist/index.d.ts +214 -0
- package/node_modules/tokenjuice/dist/index.js +113 -0
- package/node_modules/tokenjuice/dist/rules/archive/tar.json +30 -0
- package/node_modules/tokenjuice/dist/rules/archive/unzip.json +30 -0
- package/node_modules/tokenjuice/dist/rules/archive/zip.json +30 -0
- package/node_modules/tokenjuice/dist/rules/build/cmake.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/dotnet.json +36 -0
- package/node_modules/tokenjuice/dist/rules/build/esbuild.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/go-build.json +31 -0
- package/node_modules/tokenjuice/dist/rules/build/gradle.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/maven.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/msbuild.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/pnpm-build.json +44 -0
- package/node_modules/tokenjuice/dist/rules/build/swift-build.json +56 -0
- package/node_modules/tokenjuice/dist/rules/build/tsc.json +74 -0
- package/node_modules/tokenjuice/dist/rules/build/tsdown.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/vite.json +42 -0
- package/node_modules/tokenjuice/dist/rules/build/webpack.json +51 -0
- package/node_modules/tokenjuice/dist/rules/build/xcodebuild.json +80 -0
- package/node_modules/tokenjuice/dist/rules/cloud/aws.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/az.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/flyctl.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/gcloud.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/gh.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/vercel.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/mongosh.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/mysql.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/psql.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/redis-cli.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/sqlite3.json +30 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-build.json +53 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-compose.json +44 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-images.json +30 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-logs.json +43 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-ps.json +30 -0
- package/node_modules/tokenjuice/dist/rules/devops/helm.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/kubectl-describe.json +45 -0
- package/node_modules/tokenjuice/dist/rules/devops/kubectl-get.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/kubectl-logs.json +43 -0
- package/node_modules/tokenjuice/dist/rules/devops/pulumi.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/terraform.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/terragrunt.json +35 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/fd.json +33 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/find.json +42 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/git-ls-files.json +35 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/ls.json +29 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/rg-files.json +34 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/archive/tar.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/archive/unzip.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/archive/zip.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/cmake.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/dotnet.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/esbuild.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/go-build.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/gradle.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/maven.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/msbuild.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/pnpm-build-failure.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/pnpm-build.fixture.json +18 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/swift-build.fixture.json +29 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/tsc.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/tsdown.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/vite.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/webpack.fixture.json +20 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/xcodebuild.fixture.json +27 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/aws.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/az.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/flyctl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/gcloud.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/gh.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/vercel.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/mongosh.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/mysql.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/psql.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/redis-cli.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/sqlite3.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-build.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-compose.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-images.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-logs.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-ps.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/helm.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/kubectl-describe.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/kubectl-get.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/kubectl-logs.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/pulumi.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/terraform.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/terragrunt.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/fd.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/find.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/git-ls-files.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/ls.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/rg-files.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/generic/fallback.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/generic/help.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/branch.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/diff-name-only.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/diff-stat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/diff.fixture.json +26 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/log-oneline.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/remote-v.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/show.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/stash-list.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/status.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/worktree-list.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/bun-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/bun-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-ci-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-ci.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/pnpm-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/pnpm-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/yarn-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/yarn-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/biome.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/eslint.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/oxlint.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/prettier-check.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/media/ffmpeg.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/media/mediainfo.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/curl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/dig.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/nslookup.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/ping.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/ssh.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/traceroute.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/wget.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/free.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/htop.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/iostat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/top.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/vmstat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/openclaw/sessions-history.fixture.json +33 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/apt-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/apt-upgrade.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/brew-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/brew-upgrade.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/composer.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/dnf-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/fnm.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/npm-ls.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/yum-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/search/git-grep.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/search/grep.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/search/rg.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/journalctl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/launchctl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/lsof.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/netstat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/pm2.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/service.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/ss.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/systemctl-status.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/df.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/du.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/file.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/ps.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/env.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/just.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/make.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/mise.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/node.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/php.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/python.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/ruby.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/uv.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/bun-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/cargo-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/go-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/jest.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/mocha.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/npm-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/playwright.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/pnpm-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/pytest.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/rspec.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/swift-test.fixture.json +30 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/vitest.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/yarn-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/text/wc.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/transfer/rsync.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/transfer/scp.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/generic/fallback.json +32 -0
- package/node_modules/tokenjuice/dist/rules/generic/help.json +25 -0
- package/node_modules/tokenjuice/dist/rules/git/branch.json +29 -0
- package/node_modules/tokenjuice/dist/rules/git/diff-name-only.json +29 -0
- package/node_modules/tokenjuice/dist/rules/git/diff-stat.json +37 -0
- package/node_modules/tokenjuice/dist/rules/git/diff.json +65 -0
- package/node_modules/tokenjuice/dist/rules/git/log-oneline.json +30 -0
- package/node_modules/tokenjuice/dist/rules/git/remote-v.json +29 -0
- package/node_modules/tokenjuice/dist/rules/git/show.json +50 -0
- package/node_modules/tokenjuice/dist/rules/git/stash-list.json +30 -0
- package/node_modules/tokenjuice/dist/rules/git/status.json +54 -0
- package/node_modules/tokenjuice/dist/rules/git/worktree-list.json +31 -0
- package/node_modules/tokenjuice/dist/rules/install/bun-install.json +43 -0
- package/node_modules/tokenjuice/dist/rules/install/npm-ci.json +49 -0
- package/node_modules/tokenjuice/dist/rules/install/npm-install.json +49 -0
- package/node_modules/tokenjuice/dist/rules/install/pnpm-install.json +43 -0
- package/node_modules/tokenjuice/dist/rules/install/yarn-install.json +42 -0
- package/node_modules/tokenjuice/dist/rules/lint/biome.json +35 -0
- package/node_modules/tokenjuice/dist/rules/lint/eslint.json +45 -0
- package/node_modules/tokenjuice/dist/rules/lint/oxlint.json +35 -0
- package/node_modules/tokenjuice/dist/rules/lint/prettier-check.json +34 -0
- package/node_modules/tokenjuice/dist/rules/media/ffmpeg.json +30 -0
- package/node_modules/tokenjuice/dist/rules/media/mediainfo.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/curl.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/dig.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/nslookup.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/ping.json +35 -0
- package/node_modules/tokenjuice/dist/rules/network/ssh.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/traceroute.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/wget.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/free.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/htop.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/iostat.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/top.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/vmstat.json +30 -0
- package/node_modules/tokenjuice/dist/rules/openclaw/sessions-history.json +59 -0
- package/node_modules/tokenjuice/dist/rules/package/apt-install.json +36 -0
- package/node_modules/tokenjuice/dist/rules/package/apt-upgrade.json +36 -0
- package/node_modules/tokenjuice/dist/rules/package/brew-install.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/brew-upgrade.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/composer.json +35 -0
- package/node_modules/tokenjuice/dist/rules/package/dnf-install.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/fnm.json +35 -0
- package/node_modules/tokenjuice/dist/rules/package/npm-ls.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/yum-install.json +31 -0
- package/node_modules/tokenjuice/dist/rules/search/git-grep.json +30 -0
- package/node_modules/tokenjuice/dist/rules/search/grep.json +38 -0
- package/node_modules/tokenjuice/dist/rules/search/rg.json +38 -0
- package/node_modules/tokenjuice/dist/rules/service/journalctl.json +42 -0
- package/node_modules/tokenjuice/dist/rules/service/launchctl.json +41 -0
- package/node_modules/tokenjuice/dist/rules/service/lsof.json +29 -0
- package/node_modules/tokenjuice/dist/rules/service/netstat.json +29 -0
- package/node_modules/tokenjuice/dist/rules/service/pm2.json +35 -0
- package/node_modules/tokenjuice/dist/rules/service/service.json +46 -0
- package/node_modules/tokenjuice/dist/rules/service/ss.json +29 -0
- package/node_modules/tokenjuice/dist/rules/service/systemctl-status.json +45 -0
- package/node_modules/tokenjuice/dist/rules/system/df.json +29 -0
- package/node_modules/tokenjuice/dist/rules/system/du.json +29 -0
- package/node_modules/tokenjuice/dist/rules/system/file.json +30 -0
- package/node_modules/tokenjuice/dist/rules/system/ps.json +29 -0
- package/node_modules/tokenjuice/dist/rules/task/env.json +31 -0
- package/node_modules/tokenjuice/dist/rules/task/just.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/make.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/mise.json +35 -0
- package/node_modules/tokenjuice/dist/rules/task/node.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/php.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/python.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/ruby.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/uv.json +35 -0
- package/node_modules/tokenjuice/dist/rules/tests/bun-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/cargo-test.json +41 -0
- package/node_modules/tokenjuice/dist/rules/tests/go-test.json +49 -0
- package/node_modules/tokenjuice/dist/rules/tests/jest.json +41 -0
- package/node_modules/tokenjuice/dist/rules/tests/mocha.json +35 -0
- package/node_modules/tokenjuice/dist/rules/tests/npm-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/playwright.json +37 -0
- package/node_modules/tokenjuice/dist/rules/tests/pnpm-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/pytest.json +54 -0
- package/node_modules/tokenjuice/dist/rules/tests/rspec.json +31 -0
- package/node_modules/tokenjuice/dist/rules/tests/swift-test.json +66 -0
- package/node_modules/tokenjuice/dist/rules/tests/vitest.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/yarn-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/text/wc.json +35 -0
- package/node_modules/tokenjuice/dist/rules/tokenjuice-rule.schema.json +155 -0
- package/node_modules/tokenjuice/dist/rules/transfer/rsync.json +30 -0
- package/node_modules/tokenjuice/dist/rules/transfer/scp.json +30 -0
- package/node_modules/tokenjuice/dist/types.d.ts +212 -0
- package/node_modules/tokenjuice/dist/types.js +1 -0
- package/node_modules/tokenjuice/package.json +80 -0
- package/npm-shrinkwrap.json +39 -0
- package/openclaw.plugin.json +16 -0
- package/package.json +55 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { readdir, rm, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { stripLeadingCdPrefix, stripLeadingEnvAssignments } from "../../core/command.js";
|
|
4
|
+
import { compactBashResult } from "../../core/integrations/compact-bash-result.js";
|
|
5
|
+
import { extractHookCommandPaths, isNodeExecutablePath, isTokenjuiceExecutablePath, parseShellWords, shellQuote } from "../shared/hook-command.js";
|
|
6
|
+
import { buildTokenjuiceHookCommand, isExecutableFile, pathExists, } from "../shared/host-command.js";
|
|
7
|
+
import { ensureHooksDir, isRecord, loadCopilotHooksConfigWithBackup, readCopilotHooksConfig, writeCopilotHooksConfigAtomic, } from "../shared/hooks-json-file.js";
|
|
8
|
+
const TOKENJUICE_COPILOT_AGENT_SUBCOMMAND = "copilot-agent-post-tool-use";
|
|
9
|
+
const TOKENJUICE_COPILOT_AGENT_FIX_COMMAND = "tokenjuice install copilot-agent";
|
|
10
|
+
const TOKENJUICE_COPILOT_AGENT_FILENAME = "tokenjuice-agent.json";
|
|
11
|
+
const TOKENJUICE_COPILOT_AGENT_TIMEOUT_SECONDS = 10;
|
|
12
|
+
const TOKENJUICE_COPILOT_AGENT_ADVISORY = "Copilot coding agent support is beta; cloud agent jobs must have tokenjuice available in PATH before the repo hook runs.";
|
|
13
|
+
const TOKENJUICE_COPILOT_AGENT_DISABLED_ADVISORY = "Copilot coding agent support is beta; install writes a repo-level .github/hooks hook for bash PostToolUse events.";
|
|
14
|
+
const GENERIC_FALLBACK_MIN_SAVED_CHARS = 120;
|
|
15
|
+
const GENERIC_FALLBACK_MAX_RATIO = 0.75;
|
|
16
|
+
async function buildCopilotAgentHookCommand(options = {}) {
|
|
17
|
+
if (!options.local) {
|
|
18
|
+
return `${shellQuote("tokenjuice")} ${TOKENJUICE_COPILOT_AGENT_SUBCOMMAND}`;
|
|
19
|
+
}
|
|
20
|
+
return buildTokenjuiceHookCommand(TOKENJUICE_COPILOT_AGENT_SUBCOMMAND, "copilot-agent", options);
|
|
21
|
+
}
|
|
22
|
+
function getExplicitProjectDir(options = {}) {
|
|
23
|
+
return options.projectDir || process.env.COPILOT_AGENT_PROJECT_DIR;
|
|
24
|
+
}
|
|
25
|
+
async function hasGitMetadata(dir) {
|
|
26
|
+
try {
|
|
27
|
+
await stat(join(dir, ".git"));
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function findGitRoot(startDir) {
|
|
35
|
+
let current = resolve(startDir);
|
|
36
|
+
while (true) {
|
|
37
|
+
if (await hasGitMetadata(current)) {
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
const parent = dirname(current);
|
|
41
|
+
if (parent === current) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
current = parent;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function resolveProjectDir(options = {}, requireRepositoryRoot = false) {
|
|
48
|
+
const explicitProjectDir = getExplicitProjectDir(options);
|
|
49
|
+
if (explicitProjectDir) {
|
|
50
|
+
return resolve(explicitProjectDir);
|
|
51
|
+
}
|
|
52
|
+
const gitRoot = await findGitRoot(process.cwd());
|
|
53
|
+
if (gitRoot) {
|
|
54
|
+
return gitRoot;
|
|
55
|
+
}
|
|
56
|
+
if (requireRepositoryRoot) {
|
|
57
|
+
throw new Error("copilot-agent install must run inside a git repository or receive an explicit projectDir");
|
|
58
|
+
}
|
|
59
|
+
return process.cwd();
|
|
60
|
+
}
|
|
61
|
+
async function getDefaultHooksPath(options = {}, requireRepositoryRoot = false) {
|
|
62
|
+
return join(await resolveProjectDir(options, requireRepositoryRoot), ".github", "hooks", TOKENJUICE_COPILOT_AGENT_FILENAME);
|
|
63
|
+
}
|
|
64
|
+
function getCopilotAgentFixCommand(local = false) {
|
|
65
|
+
return local
|
|
66
|
+
? `${TOKENJUICE_COPILOT_AGENT_FIX_COMMAND} --local`
|
|
67
|
+
: TOKENJUICE_COPILOT_AGENT_FIX_COMMAND;
|
|
68
|
+
}
|
|
69
|
+
function readHookCommand(entry) {
|
|
70
|
+
if (!isRecord(entry)) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
for (const key of ["bash", "command", "powershell"]) {
|
|
74
|
+
const value = entry[key];
|
|
75
|
+
if (typeof value === "string" && value.includes(TOKENJUICE_COPILOT_AGENT_SUBCOMMAND)) {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
function isTokenjuiceCopilotAgentHook(entry) {
|
|
82
|
+
return readHookCommand(entry) !== undefined;
|
|
83
|
+
}
|
|
84
|
+
function getPostToolUseHooks(config) {
|
|
85
|
+
const postToolUse = config.hooks.postToolUse;
|
|
86
|
+
return Array.isArray(postToolUse) ? postToolUse : [];
|
|
87
|
+
}
|
|
88
|
+
function removeTokenjuiceCopilotAgentHooks(config) {
|
|
89
|
+
let removed = 0;
|
|
90
|
+
for (const [eventName, entries] of Object.entries(config.hooks)) {
|
|
91
|
+
if (!Array.isArray(entries)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const retained = entries.filter((entry) => !isTokenjuiceCopilotAgentHook(entry));
|
|
95
|
+
removed += entries.length - retained.length;
|
|
96
|
+
if (retained.length === 0) {
|
|
97
|
+
delete config.hooks[eventName];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
config.hooks[eventName] = retained;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return removed;
|
|
104
|
+
}
|
|
105
|
+
function isEffectivelyEmptyHooksConfig(config) {
|
|
106
|
+
return Object.keys(config.hooks).length === 0
|
|
107
|
+
&& Object.keys(config).filter((key) => key !== "hooks" && key !== "version").length === 0;
|
|
108
|
+
}
|
|
109
|
+
async function writeOrDeleteHooksConfig(hooksPath, config) {
|
|
110
|
+
if (isEffectivelyEmptyHooksConfig(config)) {
|
|
111
|
+
await rm(hooksPath, { force: true });
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
await writeCopilotHooksConfigAtomic(hooksPath, config);
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
function findTokenjuiceCopilotAgentHook(config) {
|
|
118
|
+
for (const entry of getPostToolUseHooks(config)) {
|
|
119
|
+
if (isTokenjuiceCopilotAgentHook(entry) && isRecord(entry)) {
|
|
120
|
+
return entry;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
function findTokenjuiceCopilotAgentHookCommand(config) {
|
|
126
|
+
return readHookCommand(findTokenjuiceCopilotAgentHook(config));
|
|
127
|
+
}
|
|
128
|
+
function findAnyTokenjuiceCopilotAgentHookCommand(config) {
|
|
129
|
+
for (const entries of Object.values(config.hooks)) {
|
|
130
|
+
if (!Array.isArray(entries)) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
for (const entry of entries) {
|
|
134
|
+
const command = readHookCommand(entry);
|
|
135
|
+
if (command) {
|
|
136
|
+
return command;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
function findMisplacedTokenjuiceCopilotAgentHookEvents(config) {
|
|
143
|
+
const events = [];
|
|
144
|
+
for (const [eventName, entries] of Object.entries(config.hooks)) {
|
|
145
|
+
if (eventName === "postToolUse" || !Array.isArray(entries)) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (entries.some((entry) => isTokenjuiceCopilotAgentHook(entry))) {
|
|
149
|
+
events.push(eventName);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return events;
|
|
153
|
+
}
|
|
154
|
+
function createTokenjuiceCopilotAgentHook(command) {
|
|
155
|
+
return {
|
|
156
|
+
type: "command",
|
|
157
|
+
bash: command,
|
|
158
|
+
command,
|
|
159
|
+
timeoutSec: TOKENJUICE_COPILOT_AGENT_TIMEOUT_SECONDS,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function collectTokenjuiceHookTimeoutWarnings(config, fixCommand) {
|
|
163
|
+
const hook = findTokenjuiceCopilotAgentHook(config);
|
|
164
|
+
if (!hook || hook.timeoutSec === TOKENJUICE_COPILOT_AGENT_TIMEOUT_SECONDS) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
return [
|
|
168
|
+
`configured copilot-agent tokenjuice hook timeout is missing or stale; run ${fixCommand} to add the ${TOKENJUICE_COPILOT_AGENT_TIMEOUT_SECONDS}s safety cap`,
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
async function findStrayCopilotAgentHooks(hooksDir, canonicalPath) {
|
|
172
|
+
let entries;
|
|
173
|
+
try {
|
|
174
|
+
entries = await readdir(hooksDir);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
const hooks = [];
|
|
180
|
+
for (const entry of entries) {
|
|
181
|
+
if (!entry.endsWith(".json")) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const candidate = join(hooksDir, entry);
|
|
185
|
+
if (candidate === canonicalPath) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const { config } = await readCopilotHooksConfig(candidate, "copilot-agent");
|
|
190
|
+
const command = findAnyTokenjuiceCopilotAgentHookCommand(config);
|
|
191
|
+
if (command) {
|
|
192
|
+
hooks.push({ path: candidate, command });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
// Ignore unreadable or invalid sibling hook files in doctor output.
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return hooks;
|
|
200
|
+
}
|
|
201
|
+
async function uninstallStrayCopilotAgentHookFiles(hooksDir, canonicalPath) {
|
|
202
|
+
let entries;
|
|
203
|
+
try {
|
|
204
|
+
entries = await readdir(hooksDir);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return 0;
|
|
208
|
+
}
|
|
209
|
+
let removed = 0;
|
|
210
|
+
for (const entry of entries) {
|
|
211
|
+
if (!entry.endsWith(".json")) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const candidate = join(hooksDir, entry);
|
|
215
|
+
if (candidate === canonicalPath) {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
try {
|
|
219
|
+
const { config } = await readCopilotHooksConfig(candidate, "copilot-agent");
|
|
220
|
+
const removedFromFile = removeTokenjuiceCopilotAgentHooks(config);
|
|
221
|
+
if (removedFromFile === 0) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
await writeOrDeleteHooksConfig(candidate, config);
|
|
225
|
+
removed += removedFromFile;
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
// Leave unreadable or invalid sibling hook files untouched.
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return removed;
|
|
232
|
+
}
|
|
233
|
+
export async function installCopilotAgentHook(hooksPath, options = {}) {
|
|
234
|
+
const resolvedHooksPath = hooksPath ?? await getDefaultHooksPath(options, true);
|
|
235
|
+
const { config, backupPath } = await loadCopilotHooksConfigWithBackup(resolvedHooksPath, "copilot-agent");
|
|
236
|
+
const command = await buildCopilotAgentHookCommand(options);
|
|
237
|
+
removeTokenjuiceCopilotAgentHooks(config);
|
|
238
|
+
const retained = getPostToolUseHooks(config);
|
|
239
|
+
config.hooks.postToolUse = [...retained, createTokenjuiceCopilotAgentHook(command)];
|
|
240
|
+
if (typeof config.version !== "number") {
|
|
241
|
+
config.version = 1;
|
|
242
|
+
}
|
|
243
|
+
await ensureHooksDir(dirname(resolvedHooksPath));
|
|
244
|
+
await writeCopilotHooksConfigAtomic(resolvedHooksPath, config);
|
|
245
|
+
await uninstallStrayCopilotAgentHookFiles(dirname(resolvedHooksPath), resolvedHooksPath);
|
|
246
|
+
return {
|
|
247
|
+
hooksPath: resolvedHooksPath,
|
|
248
|
+
...(backupPath ? { backupPath } : {}),
|
|
249
|
+
command,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
export async function uninstallCopilotAgentHook(hooksPath, options = {}) {
|
|
253
|
+
const resolvedHooksPath = hooksPath ?? await getDefaultHooksPath(options, true);
|
|
254
|
+
const hooksDir = dirname(resolvedHooksPath);
|
|
255
|
+
const { config, exists } = await readCopilotHooksConfig(resolvedHooksPath, "copilot-agent");
|
|
256
|
+
let removed = 0;
|
|
257
|
+
let deletedFile = false;
|
|
258
|
+
if (exists) {
|
|
259
|
+
const removedFromCanonical = removeTokenjuiceCopilotAgentHooks(config);
|
|
260
|
+
if (removedFromCanonical > 0) {
|
|
261
|
+
deletedFile = await writeOrDeleteHooksConfig(resolvedHooksPath, config);
|
|
262
|
+
removed += removedFromCanonical;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
removed += await uninstallStrayCopilotAgentHookFiles(hooksDir, resolvedHooksPath);
|
|
266
|
+
return { hooksPath: resolvedHooksPath, removed, deletedFile };
|
|
267
|
+
}
|
|
268
|
+
export async function doctorCopilotAgentHook(hooksPath, options = {}) {
|
|
269
|
+
const resolvedHooksPath = hooksPath ?? await getDefaultHooksPath(options);
|
|
270
|
+
const expectedCommand = await buildCopilotAgentHookCommand(options);
|
|
271
|
+
const fixCommand = getCopilotAgentFixCommand(options.local);
|
|
272
|
+
const { config, exists } = await readCopilotHooksConfig(resolvedHooksPath, "copilot-agent");
|
|
273
|
+
const strayHooks = await findStrayCopilotAgentHooks(dirname(resolvedHooksPath), resolvedHooksPath);
|
|
274
|
+
const strayIssues = strayHooks.map((stray) => `stray tokenjuice entry in sibling hook file: ${stray.path}`);
|
|
275
|
+
const strayDetectedCommand = strayHooks[0]?.command;
|
|
276
|
+
const advisories = [exists ? TOKENJUICE_COPILOT_AGENT_ADVISORY : TOKENJUICE_COPILOT_AGENT_DISABLED_ADVISORY];
|
|
277
|
+
if (!exists) {
|
|
278
|
+
return {
|
|
279
|
+
hooksPath: resolvedHooksPath,
|
|
280
|
+
status: strayIssues.length > 0 ? "warn" : "disabled",
|
|
281
|
+
issues: strayIssues,
|
|
282
|
+
advisories,
|
|
283
|
+
fixCommand,
|
|
284
|
+
expectedCommand,
|
|
285
|
+
...(strayDetectedCommand ? { detectedCommand: strayDetectedCommand } : {}),
|
|
286
|
+
checkedPaths: [],
|
|
287
|
+
missingPaths: [],
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
const detectedCommand = findTokenjuiceCopilotAgentHookCommand(config);
|
|
291
|
+
const canonicalDetectedCommand = detectedCommand ?? findAnyTokenjuiceCopilotAgentHookCommand(config);
|
|
292
|
+
const misplacedEvents = findMisplacedTokenjuiceCopilotAgentHookEvents(config);
|
|
293
|
+
const misplacedIssues = misplacedEvents.map((eventName) => `tokenjuice copilot-agent hook is configured outside postToolUse in ${eventName}; run ${fixCommand} to repair`);
|
|
294
|
+
if (!detectedCommand) {
|
|
295
|
+
const detectedInstallCommand = canonicalDetectedCommand ?? strayDetectedCommand;
|
|
296
|
+
return {
|
|
297
|
+
hooksPath: resolvedHooksPath,
|
|
298
|
+
status: canonicalDetectedCommand || strayIssues.length > 0 ? "warn" : "disabled",
|
|
299
|
+
issues: [...misplacedIssues, ...strayIssues],
|
|
300
|
+
advisories,
|
|
301
|
+
fixCommand,
|
|
302
|
+
expectedCommand,
|
|
303
|
+
...(detectedInstallCommand ? { detectedCommand: detectedInstallCommand } : {}),
|
|
304
|
+
checkedPaths: [],
|
|
305
|
+
missingPaths: [],
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
if (config.disableAllHooks === true) {
|
|
309
|
+
return {
|
|
310
|
+
hooksPath: resolvedHooksPath,
|
|
311
|
+
status: "broken",
|
|
312
|
+
issues: [
|
|
313
|
+
"copilot-agent hook file sets disableAllHooks: true; configured hooks will not run",
|
|
314
|
+
...misplacedIssues,
|
|
315
|
+
...strayIssues,
|
|
316
|
+
],
|
|
317
|
+
advisories,
|
|
318
|
+
fixCommand,
|
|
319
|
+
expectedCommand,
|
|
320
|
+
detectedCommand,
|
|
321
|
+
checkedPaths: [],
|
|
322
|
+
missingPaths: [],
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
const checkedPaths = extractHookCommandPaths(detectedCommand);
|
|
326
|
+
const missingPaths = [];
|
|
327
|
+
for (const path of checkedPaths) {
|
|
328
|
+
if (!(await isExecutableFile(path)) && !(path.endsWith(".js") && await pathExists(path))) {
|
|
329
|
+
missingPaths.push(path);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const issues = [];
|
|
333
|
+
issues.push(...collectTokenjuiceHookTimeoutWarnings(config, fixCommand));
|
|
334
|
+
issues.push(...misplacedIssues);
|
|
335
|
+
if (detectedCommand !== expectedCommand) {
|
|
336
|
+
issues.push("configured copilot-agent hook command does not match the current recommended command");
|
|
337
|
+
}
|
|
338
|
+
if (missingPaths.length > 0) {
|
|
339
|
+
issues.push(`configured copilot-agent hook points at missing path${missingPaths.length === 1 ? "" : "s"}`);
|
|
340
|
+
}
|
|
341
|
+
issues.push(...strayIssues);
|
|
342
|
+
return {
|
|
343
|
+
hooksPath: resolvedHooksPath,
|
|
344
|
+
status: missingPaths.length > 0 ? "broken" : issues.length > 0 ? "warn" : "ok",
|
|
345
|
+
issues,
|
|
346
|
+
advisories,
|
|
347
|
+
fixCommand,
|
|
348
|
+
expectedCommand,
|
|
349
|
+
detectedCommand,
|
|
350
|
+
checkedPaths,
|
|
351
|
+
missingPaths,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function parseJsonObject(value) {
|
|
355
|
+
if (isRecord(value)) {
|
|
356
|
+
return value;
|
|
357
|
+
}
|
|
358
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
359
|
+
return undefined;
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
const parsed = JSON.parse(value);
|
|
363
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
364
|
+
}
|
|
365
|
+
catch {
|
|
366
|
+
return undefined;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
function commandRequestsTokenjuiceRawBypass(command) {
|
|
370
|
+
let argv;
|
|
371
|
+
try {
|
|
372
|
+
argv = stripLeadingEnvAssignments(parseShellWords(stripLeadingCdPrefix(command)));
|
|
373
|
+
}
|
|
374
|
+
catch {
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
if (argv.length < 3) {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
let wrapIndex = -1;
|
|
381
|
+
const first = argv[0];
|
|
382
|
+
const second = argv[1];
|
|
383
|
+
if (typeof first === "string" && isTokenjuiceExecutablePath(first)) {
|
|
384
|
+
wrapIndex = 1;
|
|
385
|
+
}
|
|
386
|
+
else if (typeof first === "string"
|
|
387
|
+
&& isNodeExecutablePath(first)
|
|
388
|
+
&& typeof second === "string"
|
|
389
|
+
&& second.endsWith(".js")) {
|
|
390
|
+
wrapIndex = 2;
|
|
391
|
+
}
|
|
392
|
+
if (wrapIndex === -1 || argv[wrapIndex] !== "wrap") {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
const optionEndIndex = argv.indexOf("--", wrapIndex + 1);
|
|
396
|
+
if (optionEndIndex === -1) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
const optionArgs = argv.slice(wrapIndex + 1, optionEndIndex);
|
|
400
|
+
return optionArgs.includes("--raw") || optionArgs.includes("--full");
|
|
401
|
+
}
|
|
402
|
+
function readPositiveIntegerEnv(name) {
|
|
403
|
+
const value = process.env[name];
|
|
404
|
+
if (!value) {
|
|
405
|
+
return undefined;
|
|
406
|
+
}
|
|
407
|
+
const parsed = Number(value);
|
|
408
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
409
|
+
}
|
|
410
|
+
function shouldStoreFromEnv() {
|
|
411
|
+
const value = process.env.TOKENJUICE_COPILOT_AGENT_STORE;
|
|
412
|
+
return value === "1" || value === "true" || value === "TRUE" || value === "yes" || value === "YES";
|
|
413
|
+
}
|
|
414
|
+
export async function runCopilotAgentPostToolUseHook(rawText) {
|
|
415
|
+
let payload;
|
|
416
|
+
try {
|
|
417
|
+
payload = JSON.parse(rawText);
|
|
418
|
+
}
|
|
419
|
+
catch {
|
|
420
|
+
process.stdout.write("{}\n");
|
|
421
|
+
return 0;
|
|
422
|
+
}
|
|
423
|
+
const toolName = typeof payload.toolName === "string"
|
|
424
|
+
? payload.toolName
|
|
425
|
+
: typeof payload.tool_name === "string"
|
|
426
|
+
? payload.tool_name
|
|
427
|
+
: undefined;
|
|
428
|
+
if (toolName !== "bash") {
|
|
429
|
+
process.stdout.write("{}\n");
|
|
430
|
+
return 0;
|
|
431
|
+
}
|
|
432
|
+
const toolInput = parseJsonObject(payload.toolArgs)
|
|
433
|
+
?? parseJsonObject(payload.toolInput)
|
|
434
|
+
?? parseJsonObject(payload.tool_input);
|
|
435
|
+
const command = typeof toolInput?.command === "string" ? toolInput.command : undefined;
|
|
436
|
+
if (!command || !command.trim() || commandRequestsTokenjuiceRawBypass(command)) {
|
|
437
|
+
process.stdout.write("{}\n");
|
|
438
|
+
return 0;
|
|
439
|
+
}
|
|
440
|
+
const toolResult = parseJsonObject(payload.toolResult) ?? parseJsonObject(payload.tool_result);
|
|
441
|
+
if (!toolResult) {
|
|
442
|
+
process.stdout.write("{}\n");
|
|
443
|
+
return 0;
|
|
444
|
+
}
|
|
445
|
+
const resultType = typeof toolResult.resultType === "string"
|
|
446
|
+
? toolResult.resultType
|
|
447
|
+
: typeof toolResult.result_type === "string"
|
|
448
|
+
? toolResult.result_type
|
|
449
|
+
: undefined;
|
|
450
|
+
if (resultType && resultType !== "success") {
|
|
451
|
+
process.stdout.write("{}\n");
|
|
452
|
+
return 0;
|
|
453
|
+
}
|
|
454
|
+
const visibleText = typeof toolResult.textResultForLlm === "string"
|
|
455
|
+
? toolResult.textResultForLlm
|
|
456
|
+
: typeof toolResult.text_result_for_llm === "string"
|
|
457
|
+
? toolResult.text_result_for_llm
|
|
458
|
+
: "";
|
|
459
|
+
if (!visibleText.trim()) {
|
|
460
|
+
process.stdout.write("{}\n");
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
const maxInlineChars = readPositiveIntegerEnv("TOKENJUICE_COPILOT_AGENT_MAX_INLINE_CHARS");
|
|
464
|
+
try {
|
|
465
|
+
const outcome = await compactBashResult({
|
|
466
|
+
source: "copilot-agent",
|
|
467
|
+
command,
|
|
468
|
+
visibleText,
|
|
469
|
+
...(typeof payload.cwd === "string" && payload.cwd.trim() ? { cwd: payload.cwd } : {}),
|
|
470
|
+
...(typeof maxInlineChars === "number" ? { maxInlineChars } : {}),
|
|
471
|
+
inspectionPolicy: "allow-safe-inventory",
|
|
472
|
+
storeRaw: shouldStoreFromEnv(),
|
|
473
|
+
metadata: { source: "copilot-agent-post-tool-use" },
|
|
474
|
+
genericFallbackMinSavedChars: GENERIC_FALLBACK_MIN_SAVED_CHARS,
|
|
475
|
+
genericFallbackMaxRatio: GENERIC_FALLBACK_MAX_RATIO,
|
|
476
|
+
skipGenericFallbackForCompoundCommands: true,
|
|
477
|
+
});
|
|
478
|
+
if (outcome.action === "keep") {
|
|
479
|
+
process.stdout.write("{}\n");
|
|
480
|
+
return 0;
|
|
481
|
+
}
|
|
482
|
+
process.stdout.write(`${JSON.stringify({
|
|
483
|
+
modifiedResult: {
|
|
484
|
+
...toolResult,
|
|
485
|
+
resultType: "success",
|
|
486
|
+
result_type: "success",
|
|
487
|
+
textResultForLlm: outcome.result.inlineText,
|
|
488
|
+
text_result_for_llm: outcome.result.inlineText,
|
|
489
|
+
},
|
|
490
|
+
})}\n`);
|
|
491
|
+
return 0;
|
|
492
|
+
}
|
|
493
|
+
catch {
|
|
494
|
+
process.stdout.write("{}\n");
|
|
495
|
+
return 0;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type CopilotCliHookCommandOptions = {
|
|
2
|
+
local?: boolean;
|
|
3
|
+
binaryPath?: string;
|
|
4
|
+
nodePath?: string;
|
|
5
|
+
};
|
|
6
|
+
export type InstallCopilotCliHookResult = {
|
|
7
|
+
hooksPath: string;
|
|
8
|
+
backupPath?: string;
|
|
9
|
+
command: string;
|
|
10
|
+
};
|
|
11
|
+
export type UninstallCopilotCliHookResult = {
|
|
12
|
+
hooksPath: string;
|
|
13
|
+
removed: number;
|
|
14
|
+
deletedFile: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type CopilotCliDoctorReport = {
|
|
17
|
+
hooksPath: string;
|
|
18
|
+
status: "ok" | "warn" | "broken" | "disabled";
|
|
19
|
+
issues: string[];
|
|
20
|
+
advisories: string[];
|
|
21
|
+
fixCommand: string;
|
|
22
|
+
expectedCommand: string;
|
|
23
|
+
detectedCommand?: string;
|
|
24
|
+
checkedPaths: string[];
|
|
25
|
+
missingPaths: string[];
|
|
26
|
+
};
|
|
27
|
+
export declare function getCopilotCliInstructionsSnippet(): string;
|
|
28
|
+
export declare function installCopilotCliHook(hooksPath?: string, options?: CopilotCliHookCommandOptions): Promise<InstallCopilotCliHookResult>;
|
|
29
|
+
export declare function uninstallCopilotCliHook(hooksPath?: string): Promise<UninstallCopilotCliHookResult>;
|
|
30
|
+
export declare function doctorCopilotCliHook(hooksPath?: string, options?: CopilotCliHookCommandOptions): Promise<CopilotCliDoctorReport>;
|
|
31
|
+
export declare function runCopilotCliPostToolUseHook(rawText: string): Promise<number>;
|