@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,70 @@
|
|
|
1
|
+
import { constants as fsConstants } from "node:fs";
|
|
2
|
+
import { access } from "node:fs/promises";
|
|
3
|
+
import { delimiter, isAbsolute, join, resolve } from "node:path";
|
|
4
|
+
import { extractHookCommandPaths, shellQuote } from "./hook-command.js";
|
|
5
|
+
export async function isExecutableFile(path) {
|
|
6
|
+
try {
|
|
7
|
+
await access(path, fsConstants.X_OK);
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function pathExists(path) {
|
|
15
|
+
try {
|
|
16
|
+
await access(path);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function resolveInstalledTokenjuicePath() {
|
|
24
|
+
const pathValue = process.env.PATH;
|
|
25
|
+
if (!pathValue) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const candidateNames = process.platform === "win32"
|
|
29
|
+
? ["tokenjuice.exe", "tokenjuice.cmd", "tokenjuice.bat", "tokenjuice"]
|
|
30
|
+
: ["tokenjuice"];
|
|
31
|
+
for (const segment of pathValue.split(delimiter)) {
|
|
32
|
+
if (!segment) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
for (const candidateName of candidateNames) {
|
|
36
|
+
const candidatePath = join(segment, candidateName);
|
|
37
|
+
if (await isExecutableFile(candidatePath)) {
|
|
38
|
+
return candidatePath;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
export async function buildTokenjuiceHookCommand(subcommand, hostLabel, options = {}) {
|
|
45
|
+
const rawBinaryPath = options.binaryPath ?? process.argv[1];
|
|
46
|
+
const binaryPath = rawBinaryPath && !isAbsolute(rawBinaryPath) ? resolve(rawBinaryPath) : rawBinaryPath;
|
|
47
|
+
const nodePath = options.nodePath ?? process.execPath;
|
|
48
|
+
if (!binaryPath) {
|
|
49
|
+
throw new Error(`unable to resolve tokenjuice binary path for ${hostLabel} install`);
|
|
50
|
+
}
|
|
51
|
+
let launcher = binaryPath;
|
|
52
|
+
if (!options.local) {
|
|
53
|
+
const installedBinaryPath = await resolveInstalledTokenjuicePath();
|
|
54
|
+
launcher = installedBinaryPath ?? binaryPath;
|
|
55
|
+
}
|
|
56
|
+
if (launcher.endsWith(".js")) {
|
|
57
|
+
return `${shellQuote(nodePath)} ${shellQuote(launcher)} ${subcommand}`;
|
|
58
|
+
}
|
|
59
|
+
return `${shellQuote(launcher)} ${subcommand}`;
|
|
60
|
+
}
|
|
61
|
+
export async function findMissingHookCommandPaths(command) {
|
|
62
|
+
const paths = extractHookCommandPaths(command);
|
|
63
|
+
const missing = [];
|
|
64
|
+
for (const path of paths) {
|
|
65
|
+
if (!(await pathExists(path))) {
|
|
66
|
+
missing.push(path);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return missing;
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type InstructionDoctorStatus = "ok" | "broken" | "disabled";
|
|
2
|
+
export type InstructionDoctorReportFields = {
|
|
3
|
+
status: InstructionDoctorStatus;
|
|
4
|
+
issues: string[];
|
|
5
|
+
advisories: string[];
|
|
6
|
+
fixCommand: string;
|
|
7
|
+
checkedPaths: string[];
|
|
8
|
+
missingPaths: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare function instructionDoctorStatusFromIssues(issues: readonly unknown[]): "ok" | "broken";
|
|
11
|
+
export declare function buildInstructionDoctorReportFields(options: {
|
|
12
|
+
status: InstructionDoctorStatus;
|
|
13
|
+
issues?: string[];
|
|
14
|
+
advisory: string;
|
|
15
|
+
fixCommand: string;
|
|
16
|
+
}): InstructionDoctorReportFields;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function instructionDoctorStatusFromIssues(issues) {
|
|
2
|
+
return issues.length > 0 ? "broken" : "ok";
|
|
3
|
+
}
|
|
4
|
+
export function buildInstructionDoctorReportFields(options) {
|
|
5
|
+
return {
|
|
6
|
+
status: options.status,
|
|
7
|
+
issues: options.issues ?? [],
|
|
8
|
+
advisories: [options.advisory],
|
|
9
|
+
fixCommand: options.fixCommand,
|
|
10
|
+
checkedPaths: [],
|
|
11
|
+
missingPaths: [],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type InstructionFileSnapshot = {
|
|
2
|
+
text: string;
|
|
3
|
+
exists: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type WriteInstructionFileResult = {
|
|
6
|
+
filePath: string;
|
|
7
|
+
backupPath?: string;
|
|
8
|
+
};
|
|
9
|
+
export type RemoveInstructionFileResult = {
|
|
10
|
+
filePath: string;
|
|
11
|
+
removed: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type GuidanceIssueCheck = {
|
|
14
|
+
requiredText: string;
|
|
15
|
+
missingIssue: string;
|
|
16
|
+
};
|
|
17
|
+
export type ForbiddenGuidanceCheck = {
|
|
18
|
+
forbiddenText: string;
|
|
19
|
+
presentIssue: string;
|
|
20
|
+
};
|
|
21
|
+
export type GuidanceIssueOptions = {
|
|
22
|
+
required: GuidanceIssueCheck[];
|
|
23
|
+
forbidden?: ForbiddenGuidanceCheck[];
|
|
24
|
+
};
|
|
25
|
+
export declare function readInstructionFile(filePath: string): Promise<InstructionFileSnapshot>;
|
|
26
|
+
export declare function assertSafeInstructionBackupPath(filePath: string): Promise<void>;
|
|
27
|
+
export declare function writeInstructionFile(filePath: string, text: string): Promise<WriteInstructionFileResult>;
|
|
28
|
+
export declare function removeInstructionFile(filePath: string): Promise<RemoveInstructionFileResult>;
|
|
29
|
+
export declare function collectGuidanceIssues(text: string, options: GuidanceIssueOptions): string[];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { lstat, mkdir, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
export async function readInstructionFile(filePath) {
|
|
4
|
+
try {
|
|
5
|
+
return { text: await readFile(filePath, "utf8"), exists: true };
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
if (error.code === "ENOENT") {
|
|
9
|
+
return { text: "", exists: false };
|
|
10
|
+
}
|
|
11
|
+
throw error;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function writeInstructionFileAtomically(filePath, text) {
|
|
15
|
+
const tempDir = await mkdtemp(join(dirname(filePath), ".tokenjuice-"));
|
|
16
|
+
const tempPath = join(tempDir, "write");
|
|
17
|
+
try {
|
|
18
|
+
await writeFile(tempPath, text, { encoding: "utf8", flag: "wx" });
|
|
19
|
+
await rename(tempPath, filePath);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
await rm(tempDir, { recursive: true, force: true });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function resolveBackupPath(filePath) {
|
|
26
|
+
let suffix = 0;
|
|
27
|
+
while (true) {
|
|
28
|
+
const candidate = suffix === 0 ? `${filePath}.bak` : `${filePath}.bak.${suffix}`;
|
|
29
|
+
try {
|
|
30
|
+
const stats = await lstat(candidate);
|
|
31
|
+
if (stats.isSymbolicLink()) {
|
|
32
|
+
throw new Error(`cannot write instruction backup ${candidate}; tokenjuice will not write through instruction symlinks`);
|
|
33
|
+
}
|
|
34
|
+
suffix += 1;
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error.code === "ENOENT") {
|
|
38
|
+
return candidate;
|
|
39
|
+
}
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export async function assertSafeInstructionBackupPath(filePath) {
|
|
45
|
+
try {
|
|
46
|
+
await lstat(filePath);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error.code === "ENOENT") {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
await resolveBackupPath(filePath);
|
|
55
|
+
}
|
|
56
|
+
async function writeInstructionBackup(filePath, text) {
|
|
57
|
+
while (true) {
|
|
58
|
+
const backupPath = await resolveBackupPath(filePath);
|
|
59
|
+
try {
|
|
60
|
+
await writeFile(backupPath, text, { encoding: "utf8", flag: "wx" });
|
|
61
|
+
return backupPath;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error.code === "EEXIST") {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export async function writeInstructionFile(filePath, text) {
|
|
72
|
+
const existing = await readInstructionFile(filePath);
|
|
73
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
74
|
+
let backupPath;
|
|
75
|
+
if (existing.exists) {
|
|
76
|
+
backupPath = await writeInstructionBackup(filePath, existing.text);
|
|
77
|
+
}
|
|
78
|
+
await writeInstructionFileAtomically(filePath, text);
|
|
79
|
+
return {
|
|
80
|
+
filePath,
|
|
81
|
+
...(backupPath ? { backupPath } : {}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export async function removeInstructionFile(filePath) {
|
|
85
|
+
const existing = await readInstructionFile(filePath);
|
|
86
|
+
if (existing.exists) {
|
|
87
|
+
await rm(filePath, { force: true });
|
|
88
|
+
}
|
|
89
|
+
return { filePath, removed: existing.exists };
|
|
90
|
+
}
|
|
91
|
+
function escapeRegExp(value) {
|
|
92
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
93
|
+
}
|
|
94
|
+
function matchesForbiddenText(text, forbiddenText) {
|
|
95
|
+
if (text.includes(forbiddenText)) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
const commandPlaceholder = "<command>";
|
|
99
|
+
const placeholderIndex = forbiddenText.indexOf(commandPlaceholder);
|
|
100
|
+
if (placeholderIndex === -1) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
const prefix = forbiddenText.slice(0, placeholderIndex).trimEnd();
|
|
104
|
+
const suffix = forbiddenText.slice(placeholderIndex + commandPlaceholder.length).trimStart();
|
|
105
|
+
const commandPattern = new RegExp(`${escapeRegExp(prefix)}\\s+\\S+${escapeRegExp(suffix)}`, "u");
|
|
106
|
+
return commandPattern.test(text);
|
|
107
|
+
}
|
|
108
|
+
export function collectGuidanceIssues(text, options) {
|
|
109
|
+
const issues = [];
|
|
110
|
+
for (const check of options.required) {
|
|
111
|
+
if (!text.includes(check.requiredText)) {
|
|
112
|
+
issues.push(check.missingIssue);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
for (const check of options.forbidden ?? []) {
|
|
116
|
+
if (matchesForbiddenText(text, check.forbiddenText)) {
|
|
117
|
+
issues.push(check.presentIssue);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return issues;
|
|
121
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const TOKENJUICE_WRAP_COMMAND = "tokenjuice wrap -- <command>";
|
|
2
|
+
export declare const TOKENJUICE_RAW_COMMAND = "tokenjuice wrap --raw -- <command>";
|
|
3
|
+
export declare const TOKENJUICE_FULL_COMMAND = "tokenjuice wrap --full -- <command>";
|
|
4
|
+
export type TokenjuiceGuidanceOptions = {
|
|
5
|
+
wrapBullet?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function buildTokenjuiceGuidanceBullets(options?: TokenjuiceGuidanceOptions): string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const TOKENJUICE_WRAP_COMMAND = "tokenjuice wrap -- <command>";
|
|
2
|
+
export const TOKENJUICE_RAW_COMMAND = "tokenjuice wrap --raw -- <command>";
|
|
3
|
+
export const TOKENJUICE_FULL_COMMAND = "tokenjuice wrap --full -- <command>";
|
|
4
|
+
export function buildTokenjuiceGuidanceBullets(options = {}) {
|
|
5
|
+
const wrapBullet = options.wrapBullet ?? `- For terminal commands likely to produce long output, run them through \`${TOKENJUICE_WRAP_COMMAND}\`.`;
|
|
6
|
+
return [
|
|
7
|
+
wrapBullet,
|
|
8
|
+
"- Treat compacted tokenjuice output as authoritative unless it explicitly says raw output is required.",
|
|
9
|
+
`- If raw bytes are required, rerun the command with exactly \`${TOKENJUICE_RAW_COMMAND}\`.`,
|
|
10
|
+
"- Do not suggest both raw and full reruns; use the raw escape hatch.",
|
|
11
|
+
];
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type MarkerDelimitedBlockConfig = {
|
|
2
|
+
beginMarker: string;
|
|
3
|
+
endMarker: string;
|
|
4
|
+
block: string;
|
|
5
|
+
preserveSurroundingText?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type MarkerDelimitedBlockState = {
|
|
8
|
+
hasBegin: boolean;
|
|
9
|
+
hasEnd: boolean;
|
|
10
|
+
completeBlockCount: number;
|
|
11
|
+
};
|
|
12
|
+
export type MarkerDelimitedBlockIssueOptions = {
|
|
13
|
+
configuredLabel: string;
|
|
14
|
+
repairCommand: string;
|
|
15
|
+
};
|
|
16
|
+
export type InstallMarkerDelimitedBlockResult = {
|
|
17
|
+
filePath: string;
|
|
18
|
+
backupPath?: string;
|
|
19
|
+
};
|
|
20
|
+
export type UninstallMarkerDelimitedBlockResult = {
|
|
21
|
+
filePath: string;
|
|
22
|
+
removed: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare function inspectMarkerDelimitedBlock(text: string, config: MarkerDelimitedBlockConfig): MarkerDelimitedBlockState;
|
|
25
|
+
export declare function collectMarkerDelimitedBlockIssues(state: MarkerDelimitedBlockState, options: MarkerDelimitedBlockIssueOptions): string[];
|
|
26
|
+
export declare function removeMarkerDelimitedBlock(text: string, config: MarkerDelimitedBlockConfig): {
|
|
27
|
+
text: string;
|
|
28
|
+
removed: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare function upsertMarkerDelimitedBlock(text: string, config: MarkerDelimitedBlockConfig): string;
|
|
31
|
+
export declare function installMarkerDelimitedBlock(filePath: string, config: MarkerDelimitedBlockConfig): Promise<InstallMarkerDelimitedBlockResult>;
|
|
32
|
+
export declare function uninstallMarkerDelimitedBlock(filePath: string, config: MarkerDelimitedBlockConfig): Promise<UninstallMarkerDelimitedBlockResult>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { readInstructionFile, writeInstructionFile } from "./instruction-file.js";
|
|
3
|
+
function escapeRegExp(value) {
|
|
4
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
5
|
+
}
|
|
6
|
+
function buildBlockPattern(config) {
|
|
7
|
+
return new RegExp(`\\n?${escapeRegExp(config.beginMarker)}[\\s\\S]*?${escapeRegExp(config.endMarker)}\\n?`, "gu");
|
|
8
|
+
}
|
|
9
|
+
function buildExactBlockPattern(config) {
|
|
10
|
+
return new RegExp(`${escapeRegExp(config.beginMarker)}[\\s\\S]*?${escapeRegExp(config.endMarker)}`, "gu");
|
|
11
|
+
}
|
|
12
|
+
export function inspectMarkerDelimitedBlock(text, config) {
|
|
13
|
+
return {
|
|
14
|
+
hasBegin: text.includes(config.beginMarker),
|
|
15
|
+
hasEnd: text.includes(config.endMarker),
|
|
16
|
+
completeBlockCount: [...text.matchAll(config.preserveSurroundingText ? buildExactBlockPattern(config) : buildBlockPattern(config))].length,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function collectMarkerDelimitedBlockIssues(state, options) {
|
|
20
|
+
if (state.hasBegin && !state.hasEnd) {
|
|
21
|
+
return [`configured ${options.configuredLabel} have a tokenjuice start marker without an end marker`];
|
|
22
|
+
}
|
|
23
|
+
if (!state.hasBegin && state.hasEnd) {
|
|
24
|
+
return [`configured ${options.configuredLabel} have a tokenjuice end marker without a start marker`];
|
|
25
|
+
}
|
|
26
|
+
if (state.completeBlockCount !== 1) {
|
|
27
|
+
return [`configured ${options.configuredLabel} have multiple tokenjuice blocks; run ${options.repairCommand} to repair`];
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
export function removeMarkerDelimitedBlock(text, config) {
|
|
32
|
+
if (config.preserveSurroundingText) {
|
|
33
|
+
const firstMatch = buildExactBlockPattern(config).exec(text);
|
|
34
|
+
if (!firstMatch) {
|
|
35
|
+
return { text, removed: false };
|
|
36
|
+
}
|
|
37
|
+
let nextText = text.replace(buildExactBlockPattern(config), "");
|
|
38
|
+
if (firstMatch.index === 0 && nextText.startsWith("\n")) {
|
|
39
|
+
nextText = nextText.slice(1);
|
|
40
|
+
}
|
|
41
|
+
return { text: nextText, removed: true };
|
|
42
|
+
}
|
|
43
|
+
const pattern = buildBlockPattern(config);
|
|
44
|
+
if (!pattern.test(text)) {
|
|
45
|
+
return { text, removed: false };
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
text: text.replace(buildBlockPattern(config), "\n").replace(/\n{3,}/gu, "\n\n").trim(),
|
|
49
|
+
removed: true,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function upsertMarkerDelimitedBlock(text, config) {
|
|
53
|
+
if (config.preserveSurroundingText) {
|
|
54
|
+
const withoutBlock = removeMarkerDelimitedBlock(text, config).text;
|
|
55
|
+
return `${config.block}\n${withoutBlock}`;
|
|
56
|
+
}
|
|
57
|
+
const withoutBlock = removeMarkerDelimitedBlock(text, config).text.trim();
|
|
58
|
+
if (!withoutBlock) {
|
|
59
|
+
return `${config.block}\n`;
|
|
60
|
+
}
|
|
61
|
+
return `${withoutBlock}\n\n${config.block}\n`;
|
|
62
|
+
}
|
|
63
|
+
export async function installMarkerDelimitedBlock(filePath, config) {
|
|
64
|
+
const existing = await readInstructionFile(filePath);
|
|
65
|
+
const nextText = upsertMarkerDelimitedBlock(existing.text, config);
|
|
66
|
+
if (existing.exists && existing.text === nextText) {
|
|
67
|
+
return { filePath };
|
|
68
|
+
}
|
|
69
|
+
const result = await writeInstructionFile(filePath, nextText);
|
|
70
|
+
return {
|
|
71
|
+
filePath: result.filePath,
|
|
72
|
+
...(result.backupPath ? { backupPath: result.backupPath } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export async function uninstallMarkerDelimitedBlock(filePath, config) {
|
|
76
|
+
const existing = await readInstructionFile(filePath);
|
|
77
|
+
if (!existing.exists) {
|
|
78
|
+
return { filePath, removed: false };
|
|
79
|
+
}
|
|
80
|
+
const removed = removeMarkerDelimitedBlock(existing.text, config);
|
|
81
|
+
if (!removed.removed) {
|
|
82
|
+
return { filePath, removed: false };
|
|
83
|
+
}
|
|
84
|
+
if (config.preserveSurroundingText) {
|
|
85
|
+
if (removed.text) {
|
|
86
|
+
await writeFile(filePath, removed.text, "utf8");
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
await rm(filePath, { force: true });
|
|
90
|
+
}
|
|
91
|
+
return { filePath, removed: true };
|
|
92
|
+
}
|
|
93
|
+
if (removed.text.trim()) {
|
|
94
|
+
await writeFile(filePath, `${removed.text.trim()}\n`, "utf8");
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
await rm(filePath, { force: true });
|
|
98
|
+
}
|
|
99
|
+
return { filePath, removed: true };
|
|
100
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers shared by PreToolUse "wrap" hosts (cursor, codebuddy).
|
|
3
|
+
*
|
|
4
|
+
* These hosts intercept a host-level Bash/Shell tool call, wrap its command
|
|
5
|
+
* line with `tokenjuice wrap -- <host-shell> -lc '<original>'`, and return a
|
|
6
|
+
* host-shaped response so the agent's tool output flows through tokenjuice's
|
|
7
|
+
* compaction path.
|
|
8
|
+
*
|
|
9
|
+
* The wire-format response (`updated_input` vs. `hookSpecificOutput`) is
|
|
10
|
+
* host-specific and stays in the per-host module. Everything else — resolving
|
|
11
|
+
* the installed tokenjuice launcher, picking a host shell, quoting the
|
|
12
|
+
* wrapped command, detecting already-wrapped commands — is host-agnostic and
|
|
13
|
+
* lives here.
|
|
14
|
+
*/
|
|
15
|
+
export type WrapLauncherOptions = {
|
|
16
|
+
/** When true, bypass the `PATH` lookup for an installed tokenjuice binary and route through the caller's build. */
|
|
17
|
+
local?: boolean;
|
|
18
|
+
/** Override the binary/entrypoint path. Defaults to `process.argv[1]`. */
|
|
19
|
+
binaryPath?: string;
|
|
20
|
+
/** Override the node executable used when dispatching a `.js` entrypoint. Defaults to `process.execPath`. */
|
|
21
|
+
nodePath?: string;
|
|
22
|
+
};
|
|
23
|
+
export type BuildWrapLauncherHookCommandOptions = WrapLauncherOptions & {
|
|
24
|
+
/** Host-specific CLI subcommand name, e.g. `"cursor-pre-tool-use"` or `"codebuddy-pre-tool-use"`. */
|
|
25
|
+
subcommand: string;
|
|
26
|
+
/** Error context used when `binaryPath` cannot be resolved. */
|
|
27
|
+
hostName: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
30
|
+
export declare function isExecutableFile(path: string): Promise<boolean>;
|
|
31
|
+
export declare function pathExists(path: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Walk `PATH` and return the first executable `tokenjuice` (or Windows
|
|
34
|
+
* variant) found. Empty segments and missing entries are skipped.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveInstalledTokenjuicePath(): Promise<string | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a single shell candidate string to an executable path. Accepts
|
|
39
|
+
* either an absolute path (checked directly) or a bare name (walked against
|
|
40
|
+
* `PATH`). Returns `undefined` when the candidate is unusable.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveShellPath(shell: string): Promise<string | undefined>;
|
|
43
|
+
/**
|
|
44
|
+
* Try each candidate in order and return the first one that resolves. Callers
|
|
45
|
+
* pass the host-specific ordering (e.g. for codebuddy:
|
|
46
|
+
* `[tool_input.shell, TOKENJUICE_CODEBUDDY_SHELL, SHELL, "bash", "sh"]`).
|
|
47
|
+
*
|
|
48
|
+
* `undefined` / empty / whitespace-only candidates are skipped silently so
|
|
49
|
+
* callers can pass the raw env-var values without filtering first.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveHostShell(candidates: (string | undefined)[]): Promise<string | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Build the command stored in a PreToolUse hook entry, shaped like:
|
|
54
|
+
*
|
|
55
|
+
* <launcher-command> <subcommand> --wrap-launcher <launcher>
|
|
56
|
+
*
|
|
57
|
+
* Where `<launcher-command>` is either the launcher executable itself or
|
|
58
|
+
* `<node-path> <launcher-js-path>` when the launcher points at a `.js`
|
|
59
|
+
* entrypoint (so cursor/codebuddy can invoke a repo-local build without
|
|
60
|
+
* chmod'ing the script).
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildWrapLauncherHookCommand(options: BuildWrapLauncherHookCommandOptions): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Build the command the host should ask the agent to run — the original
|
|
65
|
+
* command routed through `tokenjuice wrap` and the selected host shell:
|
|
66
|
+
*
|
|
67
|
+
* <launcher-command> wrap -- <shell-path> -lc '<original>'
|
|
68
|
+
*
|
|
69
|
+
* `wrapLauncher` comes from the PreToolUse hook's `--wrap-launcher` argv so
|
|
70
|
+
* the dispatched binary matches the one the host installed.
|
|
71
|
+
*/
|
|
72
|
+
export declare function buildWrappedCommand(params: {
|
|
73
|
+
wrapLauncher: string;
|
|
74
|
+
shellPath: string;
|
|
75
|
+
command: string;
|
|
76
|
+
source?: string;
|
|
77
|
+
nodePath?: string;
|
|
78
|
+
}): string;
|
|
79
|
+
/**
|
|
80
|
+
* Detect whether a command has already been wrapped by tokenjuice. Matches
|
|
81
|
+
* three shapes:
|
|
82
|
+
*
|
|
83
|
+
* `tokenjuice wrap ...` — bare executable on PATH
|
|
84
|
+
* `/abs/path/to/tokenjuice wrap ...` — absolute launcher (pnpm link,
|
|
85
|
+
* homebrew, etc.)
|
|
86
|
+
* `node /some/dist/cli/main.js ... wrap` — node-dispatched local build
|
|
87
|
+
*
|
|
88
|
+
* Avoids double-wrapping when a tool call is already routed through tokenjuice
|
|
89
|
+
* (e.g. the user invoked `tokenjuice wrap --raw -- <cmd>` explicitly).
|
|
90
|
+
*/
|
|
91
|
+
export declare function commandAlreadyWrapped(command: string): boolean;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers shared by PreToolUse "wrap" hosts (cursor, codebuddy).
|
|
3
|
+
*
|
|
4
|
+
* These hosts intercept a host-level Bash/Shell tool call, wrap its command
|
|
5
|
+
* line with `tokenjuice wrap -- <host-shell> -lc '<original>'`, and return a
|
|
6
|
+
* host-shaped response so the agent's tool output flows through tokenjuice's
|
|
7
|
+
* compaction path.
|
|
8
|
+
*
|
|
9
|
+
* The wire-format response (`updated_input` vs. `hookSpecificOutput`) is
|
|
10
|
+
* host-specific and stays in the per-host module. Everything else — resolving
|
|
11
|
+
* the installed tokenjuice launcher, picking a host shell, quoting the
|
|
12
|
+
* wrapped command, detecting already-wrapped commands — is host-agnostic and
|
|
13
|
+
* lives here.
|
|
14
|
+
*/
|
|
15
|
+
import { constants as fsConstants } from "node:fs";
|
|
16
|
+
import { access } from "node:fs/promises";
|
|
17
|
+
import { delimiter, isAbsolute, join, resolve } from "node:path";
|
|
18
|
+
import { stripLeadingCdPrefix, tokenizeCommand } from "../../core/command.js";
|
|
19
|
+
import { isNodeExecutablePath, isTokenjuiceExecutablePath, shellQuote } from "./hook-command.js";
|
|
20
|
+
export function isRecord(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
export async function isExecutableFile(path) {
|
|
24
|
+
try {
|
|
25
|
+
await access(path, fsConstants.X_OK);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export async function pathExists(path) {
|
|
33
|
+
try {
|
|
34
|
+
await access(path);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Walk `PATH` and return the first executable `tokenjuice` (or Windows
|
|
43
|
+
* variant) found. Empty segments and missing entries are skipped.
|
|
44
|
+
*/
|
|
45
|
+
export async function resolveInstalledTokenjuicePath() {
|
|
46
|
+
const pathValue = process.env.PATH;
|
|
47
|
+
if (!pathValue) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const candidateNames = process.platform === "win32"
|
|
51
|
+
? ["tokenjuice.exe", "tokenjuice.cmd", "tokenjuice.bat", "tokenjuice"]
|
|
52
|
+
: ["tokenjuice"];
|
|
53
|
+
for (const segment of pathValue.split(delimiter)) {
|
|
54
|
+
if (!segment) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
for (const candidateName of candidateNames) {
|
|
58
|
+
const candidatePath = join(segment, candidateName);
|
|
59
|
+
if (await isExecutableFile(candidatePath)) {
|
|
60
|
+
return candidatePath;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a single shell candidate string to an executable path. Accepts
|
|
68
|
+
* either an absolute path (checked directly) or a bare name (walked against
|
|
69
|
+
* `PATH`). Returns `undefined` when the candidate is unusable.
|
|
70
|
+
*/
|
|
71
|
+
export async function resolveShellPath(shell) {
|
|
72
|
+
const trimmed = shell.trim();
|
|
73
|
+
if (!trimmed) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (trimmed.includes("/") || trimmed.includes("\\")) {
|
|
77
|
+
return await isExecutableFile(trimmed) ? trimmed : undefined;
|
|
78
|
+
}
|
|
79
|
+
const pathValue = process.env.PATH;
|
|
80
|
+
if (!pathValue) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
for (const segment of pathValue.split(delimiter)) {
|
|
84
|
+
if (!segment) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const candidatePath = join(segment, trimmed);
|
|
88
|
+
if (await isExecutableFile(candidatePath)) {
|
|
89
|
+
return candidatePath;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Try each candidate in order and return the first one that resolves. Callers
|
|
96
|
+
* pass the host-specific ordering (e.g. for codebuddy:
|
|
97
|
+
* `[tool_input.shell, TOKENJUICE_CODEBUDDY_SHELL, SHELL, "bash", "sh"]`).
|
|
98
|
+
*
|
|
99
|
+
* `undefined` / empty / whitespace-only candidates are skipped silently so
|
|
100
|
+
* callers can pass the raw env-var values without filtering first.
|
|
101
|
+
*/
|
|
102
|
+
export async function resolveHostShell(candidates) {
|
|
103
|
+
const usable = candidates.filter((candidate) => typeof candidate === "string" && candidate.trim().length > 0);
|
|
104
|
+
for (const candidate of usable) {
|
|
105
|
+
const resolved = await resolveShellPath(candidate);
|
|
106
|
+
if (resolved) {
|
|
107
|
+
return resolved;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Build the command stored in a PreToolUse hook entry, shaped like:
|
|
114
|
+
*
|
|
115
|
+
* <launcher-command> <subcommand> --wrap-launcher <launcher>
|
|
116
|
+
*
|
|
117
|
+
* Where `<launcher-command>` is either the launcher executable itself or
|
|
118
|
+
* `<node-path> <launcher-js-path>` when the launcher points at a `.js`
|
|
119
|
+
* entrypoint (so cursor/codebuddy can invoke a repo-local build without
|
|
120
|
+
* chmod'ing the script).
|
|
121
|
+
*/
|
|
122
|
+
export async function buildWrapLauncherHookCommand(options) {
|
|
123
|
+
const rawBinaryPath = options.binaryPath ?? process.argv[1];
|
|
124
|
+
const binaryPath = rawBinaryPath && !isAbsolute(rawBinaryPath) ? resolve(rawBinaryPath) : rawBinaryPath;
|
|
125
|
+
const nodePath = options.nodePath ?? process.execPath;
|
|
126
|
+
if (!binaryPath) {
|
|
127
|
+
throw new Error(`unable to resolve tokenjuice binary path for ${options.hostName} install`);
|
|
128
|
+
}
|
|
129
|
+
let launcher = binaryPath;
|
|
130
|
+
if (!options.local) {
|
|
131
|
+
const installedBinaryPath = await resolveInstalledTokenjuicePath();
|
|
132
|
+
launcher = installedBinaryPath ?? binaryPath;
|
|
133
|
+
}
|
|
134
|
+
const launcherCommand = launcher.endsWith(".js")
|
|
135
|
+
? `${shellQuote(nodePath)} ${shellQuote(launcher)}`
|
|
136
|
+
: shellQuote(launcher);
|
|
137
|
+
return `${launcherCommand} ${options.subcommand} --wrap-launcher ${shellQuote(launcher)}`;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Build the command the host should ask the agent to run — the original
|
|
141
|
+
* command routed through `tokenjuice wrap` and the selected host shell:
|
|
142
|
+
*
|
|
143
|
+
* <launcher-command> wrap -- <shell-path> -lc '<original>'
|
|
144
|
+
*
|
|
145
|
+
* `wrapLauncher` comes from the PreToolUse hook's `--wrap-launcher` argv so
|
|
146
|
+
* the dispatched binary matches the one the host installed.
|
|
147
|
+
*/
|
|
148
|
+
export function buildWrappedCommand(params) {
|
|
149
|
+
const nodePath = params.nodePath ?? process.execPath;
|
|
150
|
+
const launcherCommand = params.wrapLauncher.endsWith(".js")
|
|
151
|
+
? `${shellQuote(nodePath)} ${shellQuote(params.wrapLauncher)}`
|
|
152
|
+
: shellQuote(params.wrapLauncher);
|
|
153
|
+
const sourceArgs = params.source ? ` --source ${shellQuote(params.source)}` : "";
|
|
154
|
+
return `${launcherCommand} wrap${sourceArgs} -- ${shellQuote(params.shellPath)} -lc ${shellQuote(params.command)}`;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Detect whether a command has already been wrapped by tokenjuice. Matches
|
|
158
|
+
* three shapes:
|
|
159
|
+
*
|
|
160
|
+
* `tokenjuice wrap ...` — bare executable on PATH
|
|
161
|
+
* `/abs/path/to/tokenjuice wrap ...` — absolute launcher (pnpm link,
|
|
162
|
+
* homebrew, etc.)
|
|
163
|
+
* `node /some/dist/cli/main.js ... wrap` — node-dispatched local build
|
|
164
|
+
*
|
|
165
|
+
* Avoids double-wrapping when a tool call is already routed through tokenjuice
|
|
166
|
+
* (e.g. the user invoked `tokenjuice wrap --raw -- <cmd>` explicitly).
|
|
167
|
+
*/
|
|
168
|
+
export function commandAlreadyWrapped(command) {
|
|
169
|
+
const argv = tokenizeCommand(stripLeadingCdPrefix(command));
|
|
170
|
+
if (argv.length < 2) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
const first = argv[0];
|
|
174
|
+
const second = argv[1];
|
|
175
|
+
if (typeof first === "string" && isTokenjuiceExecutablePath(first) && second === "wrap") {
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
if (typeof first === "string"
|
|
179
|
+
&& isNodeExecutablePath(first)
|
|
180
|
+
&& typeof second === "string"
|
|
181
|
+
&& second.endsWith(".js")
|
|
182
|
+
&& argv.slice(2).includes("wrap")) {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
}
|