@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,283 @@
|
|
|
1
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { isSetupWrapperSegment, splitTopLevelCommandChain, tokenizeCommand } from "../../core/command.js";
|
|
4
|
+
import { extractHookCommandPaths } from "../shared/hook-command.js";
|
|
5
|
+
import { buildWrapLauncherHookCommand, buildWrappedCommand, commandAlreadyWrapped, isExecutableFile, isRecord, pathExists, resolveHostShell, } from "../shared/pre-tool-wrap.js";
|
|
6
|
+
const TOKENJUICE_DEVIN_SUBCOMMAND = "devin-pre-tool-use";
|
|
7
|
+
const TOKENJUICE_DEVIN_FIX_COMMAND = "tokenjuice install devin";
|
|
8
|
+
const TOKENJUICE_DEVIN_MATCHER = "exec";
|
|
9
|
+
const TOKENJUICE_DEVIN_HOOK_TIMEOUT_SECONDS = 10;
|
|
10
|
+
const TOKENJUICE_DEVIN_ADVISORY = "Devin support uses Claude-compatible PreToolUse exec input rewriting to route shell commands through tokenjuice wrap.";
|
|
11
|
+
function getProjectDir(options = {}) {
|
|
12
|
+
return resolve(options.projectDir || process.env.DEVIN_PROJECT_DIR || process.cwd());
|
|
13
|
+
}
|
|
14
|
+
function getDefaultHooksPath(options = {}) {
|
|
15
|
+
return join(getProjectDir(options), ".devin", "hooks.v1.json");
|
|
16
|
+
}
|
|
17
|
+
async function buildDevinHookCommand(options = {}) {
|
|
18
|
+
return buildWrapLauncherHookCommand({
|
|
19
|
+
...options,
|
|
20
|
+
subcommand: TOKENJUICE_DEVIN_SUBCOMMAND,
|
|
21
|
+
hostName: "devin",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function getDevinFixCommand(local = false) {
|
|
25
|
+
return local ? `${TOKENJUICE_DEVIN_FIX_COMMAND} --local` : TOKENJUICE_DEVIN_FIX_COMMAND;
|
|
26
|
+
}
|
|
27
|
+
function sanitizeDevinHooksConfig(raw) {
|
|
28
|
+
return isRecord(raw) ? { ...raw } : {};
|
|
29
|
+
}
|
|
30
|
+
async function readDevinHooksConfig(hooksPath) {
|
|
31
|
+
try {
|
|
32
|
+
const rawText = await readFile(hooksPath, "utf8");
|
|
33
|
+
return { config: sanitizeDevinHooksConfig(JSON.parse(rawText)), exists: true };
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error.code === "ENOENT") {
|
|
37
|
+
return { config: {}, exists: false };
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`failed to read Devin hooks from ${hooksPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function loadDevinHooksConfigWithBackup(hooksPath) {
|
|
43
|
+
try {
|
|
44
|
+
const rawText = await readFile(hooksPath, "utf8");
|
|
45
|
+
const backupPath = `${hooksPath}.bak`;
|
|
46
|
+
await writeFile(backupPath, rawText, "utf8");
|
|
47
|
+
return { config: sanitizeDevinHooksConfig(JSON.parse(rawText)), backupPath };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error.code === "ENOENT") {
|
|
51
|
+
return { config: {} };
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`failed to load Devin hooks from ${hooksPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function writeDevinHooksConfig(hooksPath, config) {
|
|
57
|
+
await mkdir(dirname(hooksPath), { recursive: true });
|
|
58
|
+
const tempPath = `${hooksPath}.tmp`;
|
|
59
|
+
await writeFile(tempPath, `${JSON.stringify(config, null, 2)}\n`, "utf8");
|
|
60
|
+
await rename(tempPath, hooksPath);
|
|
61
|
+
}
|
|
62
|
+
function isTokenjuiceDevinHookEntry(hook) {
|
|
63
|
+
return isRecord(hook)
|
|
64
|
+
&& typeof hook.command === "string"
|
|
65
|
+
&& hook.command.includes(TOKENJUICE_DEVIN_SUBCOMMAND);
|
|
66
|
+
}
|
|
67
|
+
function getPreToolUseGroups(config) {
|
|
68
|
+
const preToolUse = config.PreToolUse;
|
|
69
|
+
return Array.isArray(preToolUse) ? preToolUse : [];
|
|
70
|
+
}
|
|
71
|
+
function findTokenjuiceDevinHookCommand(config) {
|
|
72
|
+
for (const group of getPreToolUseGroups(config)) {
|
|
73
|
+
if (!isRecord(group) || !Array.isArray(group.hooks)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const hook = group.hooks.find(isTokenjuiceDevinHookEntry);
|
|
77
|
+
if (isRecord(hook) && typeof hook.command === "string") {
|
|
78
|
+
return hook.command;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
function removeTokenjuiceDevinHooks(config) {
|
|
84
|
+
const preToolUse = getPreToolUseGroups(config);
|
|
85
|
+
const retainedGroups = [];
|
|
86
|
+
let removed = 0;
|
|
87
|
+
for (const group of preToolUse) {
|
|
88
|
+
if (!isRecord(group) || !Array.isArray(group.hooks)) {
|
|
89
|
+
retainedGroups.push(group);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const retainedHooks = group.hooks.filter((hook) => !isTokenjuiceDevinHookEntry(hook));
|
|
93
|
+
removed += group.hooks.length - retainedHooks.length;
|
|
94
|
+
if (retainedHooks.length > 0) {
|
|
95
|
+
retainedGroups.push({ ...group, hooks: retainedHooks });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (retainedGroups.length === 0) {
|
|
99
|
+
delete config.PreToolUse;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
config.PreToolUse = retainedGroups;
|
|
103
|
+
}
|
|
104
|
+
return removed;
|
|
105
|
+
}
|
|
106
|
+
function createTokenjuiceDevinHook(command) {
|
|
107
|
+
return {
|
|
108
|
+
matcher: TOKENJUICE_DEVIN_MATCHER,
|
|
109
|
+
hooks: [
|
|
110
|
+
{
|
|
111
|
+
type: "command",
|
|
112
|
+
command,
|
|
113
|
+
timeout: TOKENJUICE_DEVIN_HOOK_TIMEOUT_SECONDS,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function configIsEmpty(config) {
|
|
119
|
+
return Object.keys(config).length === 0;
|
|
120
|
+
}
|
|
121
|
+
async function resolveDevinHostShell(toolInput) {
|
|
122
|
+
return resolveHostShell([
|
|
123
|
+
typeof toolInput.shell === "string" ? toolInput.shell : undefined,
|
|
124
|
+
process.env.TOKENJUICE_DEVIN_SHELL,
|
|
125
|
+
process.env.SHELL,
|
|
126
|
+
"bash",
|
|
127
|
+
"sh",
|
|
128
|
+
]);
|
|
129
|
+
}
|
|
130
|
+
function isDevinStatefulShellSegment(argv, command) {
|
|
131
|
+
const commandName = argv[0]?.split(/[\\/]/u).pop();
|
|
132
|
+
if (!commandName) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
if (isSetupWrapperSegment(argv, command)) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
if (commandName === "nvm" && argv[1] === "use") {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
if ((commandName === "conda" || commandName === "micromamba" || commandName === "mamba")
|
|
142
|
+
&& (argv[1] === "activate" || argv[1] === "deactivate")) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
if ((commandName === "pyenv" || commandName === "rbenv" || commandName === "asdf")
|
|
146
|
+
&& argv[1] === "shell") {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
if (commandName === "shopt"
|
|
150
|
+
|| commandName === "alias"
|
|
151
|
+
|| commandName === "unalias"
|
|
152
|
+
|| commandName === "ulimit"
|
|
153
|
+
|| commandName === "umask") {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
function commandOnlyMutatesDevinShellState(command) {
|
|
159
|
+
const segments = splitTopLevelCommandChain(command);
|
|
160
|
+
return segments.length > 0
|
|
161
|
+
&& segments.every((segment) => isDevinStatefulShellSegment(tokenizeCommand(segment), segment));
|
|
162
|
+
}
|
|
163
|
+
export async function installDevinHook(hooksPath, options = {}) {
|
|
164
|
+
const resolvedHooksPath = hooksPath ?? getDefaultHooksPath(options);
|
|
165
|
+
const { config, backupPath } = await loadDevinHooksConfigWithBackup(resolvedHooksPath);
|
|
166
|
+
const command = await buildDevinHookCommand(options);
|
|
167
|
+
removeTokenjuiceDevinHooks(config);
|
|
168
|
+
config.PreToolUse = [...getPreToolUseGroups(config), createTokenjuiceDevinHook(command)];
|
|
169
|
+
await writeDevinHooksConfig(resolvedHooksPath, config);
|
|
170
|
+
return {
|
|
171
|
+
hooksPath: resolvedHooksPath,
|
|
172
|
+
...(backupPath ? { backupPath } : {}),
|
|
173
|
+
command,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export async function uninstallDevinHook(hooksPath, options = {}) {
|
|
177
|
+
const resolvedHooksPath = hooksPath ?? getDefaultHooksPath(options);
|
|
178
|
+
const { config, exists: configExists } = await readDevinHooksConfig(resolvedHooksPath);
|
|
179
|
+
if (!configExists) {
|
|
180
|
+
return { hooksPath: resolvedHooksPath, removed: 0, deletedFile: false };
|
|
181
|
+
}
|
|
182
|
+
const removed = removeTokenjuiceDevinHooks(config);
|
|
183
|
+
if (removed === 0) {
|
|
184
|
+
return { hooksPath: resolvedHooksPath, removed: 0, deletedFile: false };
|
|
185
|
+
}
|
|
186
|
+
if (configIsEmpty(config)) {
|
|
187
|
+
await rm(resolvedHooksPath, { force: true });
|
|
188
|
+
return { hooksPath: resolvedHooksPath, removed, deletedFile: true };
|
|
189
|
+
}
|
|
190
|
+
await writeDevinHooksConfig(resolvedHooksPath, config);
|
|
191
|
+
return { hooksPath: resolvedHooksPath, removed, deletedFile: false };
|
|
192
|
+
}
|
|
193
|
+
export async function doctorDevinHook(hooksPath, options = {}) {
|
|
194
|
+
const resolvedHooksPath = hooksPath ?? getDefaultHooksPath(options);
|
|
195
|
+
const expectedCommand = await buildDevinHookCommand(options);
|
|
196
|
+
const { config, exists: configExists } = await readDevinHooksConfig(resolvedHooksPath);
|
|
197
|
+
const detectedCommand = findTokenjuiceDevinHookCommand(config);
|
|
198
|
+
const fixCommand = getDevinFixCommand(options.local);
|
|
199
|
+
if (!configExists || !detectedCommand) {
|
|
200
|
+
return {
|
|
201
|
+
hooksPath: resolvedHooksPath,
|
|
202
|
+
status: "disabled",
|
|
203
|
+
issues: [],
|
|
204
|
+
advisories: [TOKENJUICE_DEVIN_ADVISORY],
|
|
205
|
+
fixCommand,
|
|
206
|
+
expectedCommand,
|
|
207
|
+
checkedPaths: [],
|
|
208
|
+
missingPaths: [],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const checkedPaths = extractHookCommandPaths(detectedCommand);
|
|
212
|
+
const missingPaths = [];
|
|
213
|
+
for (const path of checkedPaths) {
|
|
214
|
+
if (!(await isExecutableFile(path)) && !(path.endsWith(".js") && await pathExists(path))) {
|
|
215
|
+
missingPaths.push(path);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const issues = [];
|
|
219
|
+
if (detectedCommand !== expectedCommand) {
|
|
220
|
+
if (detectedCommand.includes("/Cellar/")) {
|
|
221
|
+
issues.push("configured Devin hook is pinned to a versioned Homebrew Cellar path");
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
issues.push("configured Devin hook command does not match the current recommended command");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (missingPaths.length > 0) {
|
|
228
|
+
issues.push(`configured Devin hook points at missing path${missingPaths.length === 1 ? "" : "s"}`);
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
hooksPath: resolvedHooksPath,
|
|
232
|
+
status: missingPaths.length > 0 ? "broken" : issues.length > 0 ? "warn" : "ok",
|
|
233
|
+
issues,
|
|
234
|
+
advisories: [TOKENJUICE_DEVIN_ADVISORY],
|
|
235
|
+
fixCommand,
|
|
236
|
+
expectedCommand,
|
|
237
|
+
detectedCommand,
|
|
238
|
+
checkedPaths,
|
|
239
|
+
missingPaths,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
export async function runDevinPreToolUseHook(rawText, wrapLauncher = "tokenjuice") {
|
|
243
|
+
let payload;
|
|
244
|
+
try {
|
|
245
|
+
payload = JSON.parse(rawText);
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
if (payload.hook_event_name !== "PreToolUse") {
|
|
251
|
+
return 0;
|
|
252
|
+
}
|
|
253
|
+
if (payload.tool_name !== "exec" || !isRecord(payload.tool_input)) {
|
|
254
|
+
return 0;
|
|
255
|
+
}
|
|
256
|
+
const toolInput = payload.tool_input;
|
|
257
|
+
const command = typeof toolInput.command === "string" ? toolInput.command : undefined;
|
|
258
|
+
if (!command || !command.trim()) {
|
|
259
|
+
return 0;
|
|
260
|
+
}
|
|
261
|
+
if (commandAlreadyWrapped(command)) {
|
|
262
|
+
return 0;
|
|
263
|
+
}
|
|
264
|
+
if (commandOnlyMutatesDevinShellState(command)) {
|
|
265
|
+
return 0;
|
|
266
|
+
}
|
|
267
|
+
const shellPath = await resolveDevinHostShell(toolInput);
|
|
268
|
+
if (!shellPath) {
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
const wrappedCommand = buildWrappedCommand({ wrapLauncher, shellPath, command, source: "devin" });
|
|
272
|
+
const response = {
|
|
273
|
+
hookSpecificOutput: {
|
|
274
|
+
hookEventName: "PreToolUse",
|
|
275
|
+
updatedInput: {
|
|
276
|
+
...toolInput,
|
|
277
|
+
command: wrappedCommand,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
process.stdout.write(`${JSON.stringify(response)}\n`);
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type DockerAgentPromptOptions = {
|
|
2
|
+
projectDir?: string;
|
|
3
|
+
};
|
|
4
|
+
export type InstallDockerAgentPromptResult = {
|
|
5
|
+
promptPath: string;
|
|
6
|
+
backupPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export type UninstallDockerAgentPromptResult = {
|
|
9
|
+
promptPath: string;
|
|
10
|
+
removed: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type DockerAgentDoctorReport = {
|
|
13
|
+
promptPath: string;
|
|
14
|
+
status: "ok" | "broken" | "disabled";
|
|
15
|
+
issues: string[];
|
|
16
|
+
advisories: string[];
|
|
17
|
+
fixCommand: string;
|
|
18
|
+
checkedPaths: string[];
|
|
19
|
+
missingPaths: string[];
|
|
20
|
+
};
|
|
21
|
+
export declare function installDockerAgentPrompt(promptPath?: string, options?: DockerAgentPromptOptions): Promise<InstallDockerAgentPromptResult>;
|
|
22
|
+
export declare function uninstallDockerAgentPrompt(promptPath?: string, options?: DockerAgentPromptOptions): Promise<UninstallDockerAgentPromptResult>;
|
|
23
|
+
export declare function doctorDockerAgentPrompt(promptPath?: string, options?: DockerAgentPromptOptions): Promise<DockerAgentDoctorReport>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { lstat, mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { buildTokenjuiceGuidanceBullets, TOKENJUICE_FULL_COMMAND, TOKENJUICE_RAW_COMMAND, TOKENJUICE_WRAP_COMMAND } from "../shared/instruction-guidance.js";
|
|
5
|
+
import { collectGuidanceIssues, readInstructionFile, removeInstructionFile, writeInstructionFile } from "../shared/instruction-file.js";
|
|
6
|
+
import { buildInstructionDoctorReportFields, instructionDoctorStatusFromIssues, } from "../shared/instruction-doctor.js";
|
|
7
|
+
const TOKENJUICE_DOCKER_AGENT_FIX_COMMAND = "tokenjuice install docker-agent";
|
|
8
|
+
const TOKENJUICE_DOCKER_AGENT_MARKER = "tokenjuice Docker Agent terminal output compaction";
|
|
9
|
+
const TOKENJUICE_DOCKER_AGENT_RESTORE_BACKUP_MARKER_PREFIX = "# tokenjuice:docker-agent-restore-backup=";
|
|
10
|
+
const TOKENJUICE_DOCKER_AGENT_LOAD_GUIDANCE = "add `.docker-agent/tokenjuice.md` to `agents.<name>.add_prompt_files`";
|
|
11
|
+
const TOKENJUICE_DOCKER_AGENT_ADVISORY = "Docker Agent support is beta and prompt-file based; add `.docker-agent/tokenjuice.md` to the agent config's `add_prompt_files` list.";
|
|
12
|
+
function isTokenjuiceDockerAgentPromptText(text) {
|
|
13
|
+
return text.includes(TOKENJUICE_DOCKER_AGENT_MARKER);
|
|
14
|
+
}
|
|
15
|
+
function readRestoreBackupSuffix(text) {
|
|
16
|
+
const match = text.match(/^# tokenjuice:docker-agent-restore-backup=(\.bak(?:\.\d+)?)$/mu);
|
|
17
|
+
return match?.[1];
|
|
18
|
+
}
|
|
19
|
+
async function backupPathExists(backupPath) {
|
|
20
|
+
try {
|
|
21
|
+
await lstat(backupPath);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error.code === "ENOENT") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function chooseDockerAgentBackupPath(promptPath) {
|
|
32
|
+
for (let index = 0;; index += 1) {
|
|
33
|
+
const candidate = index === 0 ? `${promptPath}.bak` : `${promptPath}.bak.${index}`;
|
|
34
|
+
if (!(await backupPathExists(candidate))) {
|
|
35
|
+
return candidate;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function writeDockerAgentPromptWithoutBackup(promptPath, text) {
|
|
40
|
+
await mkdir(dirname(promptPath), { recursive: true });
|
|
41
|
+
const tempPath = `${promptPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
42
|
+
await writeFile(tempPath, text, { encoding: "utf8", flag: "wx" });
|
|
43
|
+
try {
|
|
44
|
+
await rename(tempPath, promptPath);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
await rm(tempPath, { force: true });
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function getExplicitProjectDir(options = {}) {
|
|
52
|
+
return options.projectDir || process.env.DOCKER_AGENT_PROJECT_DIR || process.env.CAGENT_PROJECT_DIR;
|
|
53
|
+
}
|
|
54
|
+
async function hasGitMetadata(dir) {
|
|
55
|
+
try {
|
|
56
|
+
await stat(join(dir, ".git"));
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function findGitRoot(startDir) {
|
|
64
|
+
let current = resolve(startDir);
|
|
65
|
+
while (true) {
|
|
66
|
+
if (await hasGitMetadata(current)) {
|
|
67
|
+
return current;
|
|
68
|
+
}
|
|
69
|
+
const parent = dirname(current);
|
|
70
|
+
if (parent === current) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
current = parent;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function resolveProjectDir(options = {}) {
|
|
77
|
+
const explicitProjectDir = getExplicitProjectDir(options);
|
|
78
|
+
if (explicitProjectDir) {
|
|
79
|
+
return resolve(explicitProjectDir);
|
|
80
|
+
}
|
|
81
|
+
return (await findGitRoot(process.cwd())) ?? process.cwd();
|
|
82
|
+
}
|
|
83
|
+
async function getDefaultPromptPath(options = {}) {
|
|
84
|
+
return join(await resolveProjectDir(options), ".docker-agent", "tokenjuice.md");
|
|
85
|
+
}
|
|
86
|
+
function buildDockerAgentPrompt({ restoreBackupSuffix } = {}) {
|
|
87
|
+
return [
|
|
88
|
+
`# ${TOKENJUICE_DOCKER_AGENT_MARKER}`,
|
|
89
|
+
...(restoreBackupSuffix ? [`${TOKENJUICE_DOCKER_AGENT_RESTORE_BACKUP_MARKER_PREFIX}${restoreBackupSuffix}`] : []),
|
|
90
|
+
"",
|
|
91
|
+
...buildTokenjuiceGuidanceBullets({
|
|
92
|
+
wrapBullet: `- When Docker Agent runs shell commands likely to produce long output, prefer \`${TOKENJUICE_WRAP_COMMAND}\`.`,
|
|
93
|
+
}),
|
|
94
|
+
"",
|
|
95
|
+
"For Docker Agent configs, load this prompt file from the relevant agent:",
|
|
96
|
+
"",
|
|
97
|
+
"```yaml",
|
|
98
|
+
"agents:",
|
|
99
|
+
" root:",
|
|
100
|
+
" add_prompt_files:",
|
|
101
|
+
" - .docker-agent/tokenjuice.md",
|
|
102
|
+
"```",
|
|
103
|
+
"",
|
|
104
|
+
`In short: ${TOKENJUICE_DOCKER_AGENT_LOAD_GUIDANCE}.`,
|
|
105
|
+
"",
|
|
106
|
+
].join("\n");
|
|
107
|
+
}
|
|
108
|
+
export async function installDockerAgentPrompt(promptPath, options = {}) {
|
|
109
|
+
const resolvedPromptPath = promptPath ?? (await getDefaultPromptPath(options));
|
|
110
|
+
const existing = await readInstructionFile(resolvedPromptPath);
|
|
111
|
+
if (existing.exists && isTokenjuiceDockerAgentPromptText(existing.text)) {
|
|
112
|
+
const restoreBackupSuffix = readRestoreBackupSuffix(existing.text);
|
|
113
|
+
if (existing.text === buildDockerAgentPrompt({ restoreBackupSuffix })) {
|
|
114
|
+
return { promptPath: resolvedPromptPath };
|
|
115
|
+
}
|
|
116
|
+
const result = await writeInstructionFile(resolvedPromptPath, buildDockerAgentPrompt({ restoreBackupSuffix }));
|
|
117
|
+
return {
|
|
118
|
+
promptPath: result.filePath,
|
|
119
|
+
...(result.backupPath ? { backupPath: result.backupPath } : {}),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (existing.exists) {
|
|
123
|
+
const backupPath = await chooseDockerAgentBackupPath(resolvedPromptPath);
|
|
124
|
+
await writeFile(backupPath, existing.text, { encoding: "utf8", flag: "wx" });
|
|
125
|
+
await writeDockerAgentPromptWithoutBackup(resolvedPromptPath, buildDockerAgentPrompt({ restoreBackupSuffix: backupPath.slice(resolvedPromptPath.length) }));
|
|
126
|
+
return { promptPath: resolvedPromptPath, backupPath };
|
|
127
|
+
}
|
|
128
|
+
const result = await writeInstructionFile(resolvedPromptPath, buildDockerAgentPrompt());
|
|
129
|
+
return {
|
|
130
|
+
promptPath: result.filePath,
|
|
131
|
+
...(result.backupPath ? { backupPath: result.backupPath } : {}),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export async function uninstallDockerAgentPrompt(promptPath, options = {}) {
|
|
135
|
+
const resolvedPromptPath = promptPath ?? (await getDefaultPromptPath(options));
|
|
136
|
+
const existing = await readInstructionFile(resolvedPromptPath);
|
|
137
|
+
if (!existing.exists || !isTokenjuiceDockerAgentPromptText(existing.text)) {
|
|
138
|
+
return { promptPath: resolvedPromptPath, removed: false };
|
|
139
|
+
}
|
|
140
|
+
const restoreBackupSuffix = readRestoreBackupSuffix(existing.text);
|
|
141
|
+
if (restoreBackupSuffix) {
|
|
142
|
+
const backupPath = `${resolvedPromptPath}${restoreBackupSuffix}`;
|
|
143
|
+
const backup = await readInstructionFile(backupPath);
|
|
144
|
+
if (backup.exists && !isTokenjuiceDockerAgentPromptText(backup.text)) {
|
|
145
|
+
await rm(resolvedPromptPath, { force: true });
|
|
146
|
+
await rename(backupPath, resolvedPromptPath);
|
|
147
|
+
return { promptPath: resolvedPromptPath, removed: true };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const result = await removeInstructionFile(resolvedPromptPath);
|
|
151
|
+
return { promptPath: result.filePath, removed: result.removed };
|
|
152
|
+
}
|
|
153
|
+
export async function doctorDockerAgentPrompt(promptPath, options = {}) {
|
|
154
|
+
const resolvedPromptPath = promptPath ?? (await getDefaultPromptPath(options));
|
|
155
|
+
const existing = await readInstructionFile(resolvedPromptPath);
|
|
156
|
+
if (!existing.exists) {
|
|
157
|
+
return {
|
|
158
|
+
promptPath: resolvedPromptPath,
|
|
159
|
+
...buildInstructionDoctorReportFields({
|
|
160
|
+
status: "disabled",
|
|
161
|
+
issues: ["tokenjuice Docker Agent prompt file is not installed"],
|
|
162
|
+
advisory: TOKENJUICE_DOCKER_AGENT_ADVISORY,
|
|
163
|
+
fixCommand: TOKENJUICE_DOCKER_AGENT_FIX_COMMAND,
|
|
164
|
+
}),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const issues = collectGuidanceIssues(existing.text, {
|
|
168
|
+
required: [
|
|
169
|
+
{
|
|
170
|
+
requiredText: TOKENJUICE_DOCKER_AGENT_MARKER,
|
|
171
|
+
missingIssue: "configured Docker Agent prompt file does not look like the tokenjuice prompt",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
requiredText: TOKENJUICE_WRAP_COMMAND,
|
|
175
|
+
missingIssue: "configured Docker Agent prompt file is missing tokenjuice wrap guidance",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
requiredText: TOKENJUICE_RAW_COMMAND,
|
|
179
|
+
missingIssue: "configured Docker Agent prompt file is missing the raw escape hatch",
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
requiredText: ".docker-agent/tokenjuice.md",
|
|
183
|
+
missingIssue: "configured Docker Agent prompt file is missing prompt-file path guidance",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
requiredText: "add_prompt_files",
|
|
187
|
+
missingIssue: "configured Docker Agent prompt file is missing add_prompt_files guidance",
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
forbidden: [
|
|
191
|
+
{
|
|
192
|
+
forbiddenText: TOKENJUICE_FULL_COMMAND,
|
|
193
|
+
presentIssue: "configured Docker Agent prompt file still suggests the full escape hatch",
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
});
|
|
197
|
+
return {
|
|
198
|
+
promptPath: resolvedPromptPath,
|
|
199
|
+
...buildInstructionDoctorReportFields({
|
|
200
|
+
status: instructionDoctorStatusFromIssues(issues),
|
|
201
|
+
issues,
|
|
202
|
+
advisory: TOKENJUICE_DOCKER_AGENT_ADVISORY,
|
|
203
|
+
fixCommand: TOKENJUICE_DOCKER_AGENT_FIX_COMMAND,
|
|
204
|
+
}),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type DotAgentsRuleOptions = {
|
|
2
|
+
configDir?: string;
|
|
3
|
+
};
|
|
4
|
+
export type InstallDotAgentsRuleResult = {
|
|
5
|
+
rulePath: string;
|
|
6
|
+
backupPath?: string;
|
|
7
|
+
syncCommand: string;
|
|
8
|
+
};
|
|
9
|
+
export type UninstallDotAgentsRuleResult = {
|
|
10
|
+
rulePath: string;
|
|
11
|
+
removed: boolean;
|
|
12
|
+
syncCommand: string;
|
|
13
|
+
};
|
|
14
|
+
export type DotAgentsDoctorReport = {
|
|
15
|
+
rulePath: string;
|
|
16
|
+
syncCommand: string;
|
|
17
|
+
status: "ok" | "warn" | "broken" | "disabled";
|
|
18
|
+
issues: string[];
|
|
19
|
+
advisories: string[];
|
|
20
|
+
fixCommand: string;
|
|
21
|
+
checkedPaths: string[];
|
|
22
|
+
missingPaths: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function installDotAgentsRule(rulePath?: string, options?: DotAgentsRuleOptions): Promise<InstallDotAgentsRuleResult>;
|
|
25
|
+
export declare function uninstallDotAgentsRule(rulePath?: string, options?: DotAgentsRuleOptions): Promise<UninstallDotAgentsRuleResult>;
|
|
26
|
+
export declare function doctorDotAgentsRule(rulePath?: string, options?: DotAgentsRuleOptions): Promise<DotAgentsDoctorReport>;
|