@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,539 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { lstat, mkdir, rename, rm, rmdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { collectGuidanceIssues, readInstructionFile, removeInstructionFile, writeInstructionFile } from "../shared/instruction-file.js";
|
|
6
|
+
import { buildInstructionDoctorReportFields, instructionDoctorStatusFromIssues, } from "../shared/instruction-doctor.js";
|
|
7
|
+
import { isRecord } from "../shared/hooks-json-file.js";
|
|
8
|
+
const TOKENJUICE_LOCALCODE_FIX_COMMAND = "tokenjuice install localcode";
|
|
9
|
+
const TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER = "tokenjuice:localcode-plugin";
|
|
10
|
+
const TOKENJUICE_LOCALCODE_MANIFEST_RESTORE_MARKER_PREFIX = "tokenjuice:localcode-restore-manifest=";
|
|
11
|
+
const TOKENJUICE_LOCALCODE_INDEX_RESTORE_MARKER_PREFIX = "tokenjuice:localcode-restore-index=";
|
|
12
|
+
const TOKENJUICE_LOCALCODE_PLUGIN_MARKER = "tokenjuice localcode plugin";
|
|
13
|
+
const TOKENJUICE_LOCALCODE_TOOL_NAME = "tokenjuice_compact_terminal_output";
|
|
14
|
+
const TOKENJUICE_LOCALCODE_COMMAND = "/tokenjuice";
|
|
15
|
+
const TOKENJUICE_LOCALCODE_ADVISORY = "LocalCode support is beta and installs a plugin tool/command for compacting provided terminal output; it does not intercept LocalCode's built-in shell output.";
|
|
16
|
+
function getLocalCodeHome(options = {}) {
|
|
17
|
+
return options.homeDir || process.env.LOCALCODE_HOME || join(homedir(), ".localcode");
|
|
18
|
+
}
|
|
19
|
+
function getPluginDir(options = {}) {
|
|
20
|
+
return join(getLocalCodeHome(options), "plugins", "tokenjuice");
|
|
21
|
+
}
|
|
22
|
+
function getManifestPath(options = {}) {
|
|
23
|
+
return join(getPluginDir(options), "localcode.plugin.json");
|
|
24
|
+
}
|
|
25
|
+
function getIndexPath(options = {}) {
|
|
26
|
+
return join(getPluginDir(options), "index.js");
|
|
27
|
+
}
|
|
28
|
+
async function rejectPluginDirectorySymlink(pluginDir) {
|
|
29
|
+
try {
|
|
30
|
+
const stats = await lstat(pluginDir);
|
|
31
|
+
if (stats.isSymbolicLink()) {
|
|
32
|
+
throw new Error(`cannot use LocalCode plugin directory ${pluginDir}; tokenjuice will not write through plugin directory symlinks`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error.code === "ENOENT") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function rejectPluginDirectorySymlinks(options = {}) {
|
|
43
|
+
const localCodeHome = getLocalCodeHome(options);
|
|
44
|
+
for (const directory of [localCodeHome, join(localCodeHome, "plugins"), getPluginDir(options)]) {
|
|
45
|
+
await rejectPluginDirectorySymlink(directory);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function rejectPluginFileSymlink(filePath) {
|
|
49
|
+
try {
|
|
50
|
+
const stats = await lstat(filePath);
|
|
51
|
+
if (stats.isSymbolicLink()) {
|
|
52
|
+
throw new Error(`cannot use LocalCode plugin file ${filePath}; tokenjuice will not read or write through plugin file symlinks`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error.code === "ENOENT") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function rejectPluginFileSidecarSymlinks(filePath) {
|
|
63
|
+
await rejectPluginFileSymlink(`${filePath}.bak`);
|
|
64
|
+
}
|
|
65
|
+
async function backupPathExists(backupPath) {
|
|
66
|
+
try {
|
|
67
|
+
await lstat(backupPath);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
if (error.code === "ENOENT") {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function chooseLocalCodeBackupPath(filePath) {
|
|
78
|
+
for (let index = 0;; index += 1) {
|
|
79
|
+
const candidate = index === 0 ? `${filePath}.bak` : `${filePath}.bak.${index}`;
|
|
80
|
+
if (!(await backupPathExists(candidate))) {
|
|
81
|
+
return candidate;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function writeTextFileWithoutBackup(filePath, text) {
|
|
86
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
87
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
88
|
+
await writeFile(tempPath, text, { encoding: "utf8", flag: "wx" });
|
|
89
|
+
try {
|
|
90
|
+
await rename(tempPath, filePath);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
await rm(tempPath, { force: true });
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function readLocalCodePluginFiles(options = {}) {
|
|
98
|
+
return {
|
|
99
|
+
manifest: await readInstructionFile(getManifestPath(options)),
|
|
100
|
+
index: await readInstructionFile(getIndexPath(options)),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function hasTokenjuiceMarker(manifestText, indexText) {
|
|
104
|
+
return manifestText.includes(TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER) || indexText.includes(TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER);
|
|
105
|
+
}
|
|
106
|
+
function readRestoreBackupSuffix(text, markerPrefix) {
|
|
107
|
+
const match = text.match(new RegExp(`^// ${markerPrefix.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}(\\.bak(?:\\.\\d+)?)$`, "mu"));
|
|
108
|
+
return match?.[1];
|
|
109
|
+
}
|
|
110
|
+
function readRestoreBackups(indexText) {
|
|
111
|
+
const manifestBackupSuffix = readRestoreBackupSuffix(indexText, TOKENJUICE_LOCALCODE_MANIFEST_RESTORE_MARKER_PREFIX);
|
|
112
|
+
const indexBackupSuffix = readRestoreBackupSuffix(indexText, TOKENJUICE_LOCALCODE_INDEX_RESTORE_MARKER_PREFIX);
|
|
113
|
+
return {
|
|
114
|
+
...(manifestBackupSuffix ? { manifestBackupSuffix } : {}),
|
|
115
|
+
...(indexBackupSuffix ? { indexBackupSuffix } : {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const TOKENJUICE_LOCALCODE_MANIFEST = JSON.stringify({
|
|
119
|
+
name: "tokenjuice",
|
|
120
|
+
version: "1.0.0",
|
|
121
|
+
description: `${TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER}; ${TOKENJUICE_LOCALCODE_PLUGIN_MARKER}: compact provided terminal output without running commands.`,
|
|
122
|
+
author: "tokenjuice",
|
|
123
|
+
tools: [TOKENJUICE_LOCALCODE_TOOL_NAME],
|
|
124
|
+
commands: [TOKENJUICE_LOCALCODE_COMMAND.trim()],
|
|
125
|
+
}, null, 2) + "\n";
|
|
126
|
+
function buildLocalCodePlugin({ manifestBackupSuffix, indexBackupSuffix, } = {}) {
|
|
127
|
+
return [
|
|
128
|
+
`// ${TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER}`,
|
|
129
|
+
...(manifestBackupSuffix ? [`// ${TOKENJUICE_LOCALCODE_MANIFEST_RESTORE_MARKER_PREFIX}${manifestBackupSuffix}`] : []),
|
|
130
|
+
...(indexBackupSuffix ? [`// ${TOKENJUICE_LOCALCODE_INDEX_RESTORE_MARKER_PREFIX}${indexBackupSuffix}`] : []),
|
|
131
|
+
"'use strict'",
|
|
132
|
+
"",
|
|
133
|
+
"const { spawnSync } = require('node:child_process')",
|
|
134
|
+
"",
|
|
135
|
+
`const TOKENJUICE_LOCALCODE_PLUGIN_MARKER = '${TOKENJUICE_LOCALCODE_PLUGIN_MARKER}'`,
|
|
136
|
+
`const TOOL_NAME = '${TOKENJUICE_LOCALCODE_TOOL_NAME}'`,
|
|
137
|
+
`const COMMAND_NAME = '${TOKENJUICE_LOCALCODE_COMMAND}'`,
|
|
138
|
+
"const DEFAULT_MAX_INLINE_CHARS = 20000",
|
|
139
|
+
"const DEFAULT_TIMEOUT_MS = 10000",
|
|
140
|
+
"",
|
|
141
|
+
"function readString(value) {",
|
|
142
|
+
" return typeof value === 'string' ? value : ''",
|
|
143
|
+
"}",
|
|
144
|
+
"",
|
|
145
|
+
"function readInteger(value, fallback) {",
|
|
146
|
+
" const parsed = Number(value)",
|
|
147
|
+
" return Number.isInteger(parsed) ? parsed : fallback",
|
|
148
|
+
"}",
|
|
149
|
+
"",
|
|
150
|
+
"function runTokenjuiceReduce({ command, output, exitCode = 0, cwd, maxInlineChars = DEFAULT_MAX_INLINE_CHARS }) {",
|
|
151
|
+
" const trimmedCommand = readString(command).trim()",
|
|
152
|
+
" const visibleText = readString(output)",
|
|
153
|
+
" if (!trimmedCommand) {",
|
|
154
|
+
" return { ok: false, message: 'command must be a non-empty string; it is metadata only and is never executed by this plugin.' }",
|
|
155
|
+
" }",
|
|
156
|
+
" if (!visibleText.trim()) {",
|
|
157
|
+
" return { ok: false, message: 'output must be non-empty terminal text captured from a prior command.' }",
|
|
158
|
+
" }",
|
|
159
|
+
"",
|
|
160
|
+
" const request = {",
|
|
161
|
+
" input: {",
|
|
162
|
+
" toolName: 'localcode-plugin',",
|
|
163
|
+
" command: trimmedCommand,",
|
|
164
|
+
" combinedText: visibleText,",
|
|
165
|
+
" exitCode: readInteger(exitCode, 0),",
|
|
166
|
+
" metadata: { source: 'localcode-plugin' },",
|
|
167
|
+
" },",
|
|
168
|
+
" options: {",
|
|
169
|
+
" maxInlineChars: readInteger(maxInlineChars, DEFAULT_MAX_INLINE_CHARS),",
|
|
170
|
+
" },",
|
|
171
|
+
" }",
|
|
172
|
+
"",
|
|
173
|
+
" const tokenjuiceBin = process.env.TOKENJUICE_BIN || 'tokenjuice'",
|
|
174
|
+
" const completed = spawnSync(tokenjuiceBin, ['reduce-json'], {",
|
|
175
|
+
" input: JSON.stringify(request),",
|
|
176
|
+
" encoding: 'utf8',",
|
|
177
|
+
" timeout: DEFAULT_TIMEOUT_MS,",
|
|
178
|
+
" cwd: cwd || process.cwd(),",
|
|
179
|
+
" shell: false,",
|
|
180
|
+
" maxBuffer: 1024 * 1024 * 8,",
|
|
181
|
+
" })",
|
|
182
|
+
"",
|
|
183
|
+
" if (completed.error) {",
|
|
184
|
+
" return { ok: false, message: `tokenjuice failed: ${completed.error.message}` }",
|
|
185
|
+
" }",
|
|
186
|
+
" if (completed.status !== 0) {",
|
|
187
|
+
" const details = (completed.stderr || completed.stdout || '').trim()",
|
|
188
|
+
" return { ok: false, message: `tokenjuice exited ${completed.status}: ${details}` }",
|
|
189
|
+
" }",
|
|
190
|
+
"",
|
|
191
|
+
" let result",
|
|
192
|
+
" try {",
|
|
193
|
+
" result = JSON.parse(completed.stdout)",
|
|
194
|
+
" } catch {",
|
|
195
|
+
" return { ok: false, message: `tokenjuice returned non-JSON output: ${completed.stdout.slice(0, 1000)}` }",
|
|
196
|
+
" }",
|
|
197
|
+
"",
|
|
198
|
+
" if (!result || typeof result.inlineText !== 'string') {",
|
|
199
|
+
" return { ok: false, message: 'tokenjuice returned no inline text.' }",
|
|
200
|
+
" }",
|
|
201
|
+
"",
|
|
202
|
+
" const reducer = result.classification && result.classification.matchedReducer ? result.classification.matchedReducer : 'generic/fallback'",
|
|
203
|
+
" const ratio = result.stats && typeof result.stats.ratio === 'number' ? `, ratio ${Math.round(result.stats.ratio * 100)}%` : ''",
|
|
204
|
+
" return { ok: true, message: `tokenjuice compacted output (${reducer}${ratio}):\\n\\n${result.inlineText}` }",
|
|
205
|
+
"}",
|
|
206
|
+
"",
|
|
207
|
+
"const commandDefinition = {",
|
|
208
|
+
" cmd: COMMAND_NAME,",
|
|
209
|
+
" description: 'Compact provided terminal output with tokenjuice; first line is the command, remaining text is output.',",
|
|
210
|
+
" async handler(args, ctx) {",
|
|
211
|
+
" const [commandLine = '', ...outputLines] = readString(args).split(/\\r?\\n/)",
|
|
212
|
+
" const outcome = runTokenjuiceReduce({",
|
|
213
|
+
" command: commandLine,",
|
|
214
|
+
" output: outputLines.join('\\n'),",
|
|
215
|
+
" cwd: ctx && ctx.cwd,",
|
|
216
|
+
" })",
|
|
217
|
+
" return { type: outcome.ok ? 'command' : 'error', title: 'tokenjuice', content: outcome.message }",
|
|
218
|
+
" },",
|
|
219
|
+
"}",
|
|
220
|
+
"",
|
|
221
|
+
"const toolDefinition = {",
|
|
222
|
+
" name: TOOL_NAME,",
|
|
223
|
+
" description: 'Compact terminal output that has already been captured. The command string is metadata only; it is never executed by this tool.',",
|
|
224
|
+
" async handler(args, ctx) {",
|
|
225
|
+
" const outcome = runTokenjuiceReduce({",
|
|
226
|
+
" command: args && args.command,",
|
|
227
|
+
" output: args && (args.output || args.stdout || args.text),",
|
|
228
|
+
" exitCode: args && (args.exitCode || args.exit_code),",
|
|
229
|
+
" maxInlineChars: args && args.maxInlineChars,",
|
|
230
|
+
" cwd: ctx && ctx.cwd,",
|
|
231
|
+
" })",
|
|
232
|
+
" return outcome.ok ? { success: true, output: outcome.message } : { success: false, error: outcome.message, output: '' }",
|
|
233
|
+
" },",
|
|
234
|
+
"}",
|
|
235
|
+
"",
|
|
236
|
+
"const plugin = {",
|
|
237
|
+
" name: 'tokenjuice',",
|
|
238
|
+
" version: '1.0.0',",
|
|
239
|
+
" description: `${TOKENJUICE_LOCALCODE_PLUGIN_MARKER}: compact provided terminal output without running commands.`,",
|
|
240
|
+
" commands: [commandDefinition],",
|
|
241
|
+
" tools: [toolDefinition],",
|
|
242
|
+
" register(registry) {",
|
|
243
|
+
" if (registry && typeof registry.addCommand === 'function') {",
|
|
244
|
+
" registry.addCommand(commandDefinition)",
|
|
245
|
+
" }",
|
|
246
|
+
" if (registry && typeof registry.addTool === 'function') {",
|
|
247
|
+
" registry.addTool({",
|
|
248
|
+
" name: toolDefinition.name,",
|
|
249
|
+
" description: toolDefinition.description,",
|
|
250
|
+
" parameters: {",
|
|
251
|
+
" type: 'object',",
|
|
252
|
+
" properties: {",
|
|
253
|
+
" command: { type: 'string', description: 'Command that produced the output; metadata only.' },",
|
|
254
|
+
" output: { type: 'string', description: 'Captured terminal output to compact.' },",
|
|
255
|
+
" exitCode: { type: 'number', description: 'Command exit code, if known.' },",
|
|
256
|
+
" maxInlineChars: { type: 'number', description: 'Maximum compacted characters to return.' },",
|
|
257
|
+
" },",
|
|
258
|
+
" required: ['command', 'output'],",
|
|
259
|
+
" },",
|
|
260
|
+
" async execute(args, ctx) {",
|
|
261
|
+
" const outcome = await toolDefinition.handler(args || {}, ctx || {})",
|
|
262
|
+
" return outcome.success ? outcome.output : (outcome.error || outcome.output || 'tokenjuice failed')",
|
|
263
|
+
" },",
|
|
264
|
+
" })",
|
|
265
|
+
" }",
|
|
266
|
+
" },",
|
|
267
|
+
"}",
|
|
268
|
+
"",
|
|
269
|
+
"module.exports = plugin",
|
|
270
|
+
"",
|
|
271
|
+
].join("\n");
|
|
272
|
+
}
|
|
273
|
+
export async function installLocalCodePlugin(options = {}) {
|
|
274
|
+
const pluginDir = getPluginDir(options);
|
|
275
|
+
const manifestPath = getManifestPath(options);
|
|
276
|
+
const indexPath = getIndexPath(options);
|
|
277
|
+
await rejectPluginDirectorySymlinks(options);
|
|
278
|
+
await rejectPluginFileSymlink(manifestPath);
|
|
279
|
+
await rejectPluginFileSymlink(indexPath);
|
|
280
|
+
await rejectPluginFileSidecarSymlinks(manifestPath);
|
|
281
|
+
await rejectPluginFileSidecarSymlinks(indexPath);
|
|
282
|
+
const { manifest: existingManifest, index: existingIndex } = await readLocalCodePluginFiles(options);
|
|
283
|
+
if (hasTokenjuiceMarker(existingManifest.text, existingIndex.text)) {
|
|
284
|
+
const restoreBackups = readRestoreBackups(existingIndex.text);
|
|
285
|
+
const manifestBackupPath = existingManifest.exists && !existingManifest.text.includes(TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER)
|
|
286
|
+
? await chooseLocalCodeBackupPath(manifestPath)
|
|
287
|
+
: undefined;
|
|
288
|
+
const indexBackupPath = existingIndex.exists && !existingIndex.text.includes(TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER)
|
|
289
|
+
? await chooseLocalCodeBackupPath(indexPath)
|
|
290
|
+
: undefined;
|
|
291
|
+
if (manifestBackupPath) {
|
|
292
|
+
await writeFile(manifestBackupPath, existingManifest.text, { encoding: "utf8", flag: "wx" });
|
|
293
|
+
}
|
|
294
|
+
if (indexBackupPath) {
|
|
295
|
+
await writeFile(indexBackupPath, existingIndex.text, { encoding: "utf8", flag: "wx" });
|
|
296
|
+
}
|
|
297
|
+
const nextIndex = buildLocalCodePlugin({
|
|
298
|
+
...restoreBackups,
|
|
299
|
+
...(manifestBackupPath ? { manifestBackupSuffix: manifestBackupPath.slice(manifestPath.length) } : {}),
|
|
300
|
+
...(indexBackupPath ? { indexBackupSuffix: indexBackupPath.slice(indexPath.length) } : {}),
|
|
301
|
+
});
|
|
302
|
+
if (existingManifest.text === TOKENJUICE_LOCALCODE_MANIFEST && existingIndex.text === nextIndex) {
|
|
303
|
+
return { pluginDir, manifestPath, indexPath };
|
|
304
|
+
}
|
|
305
|
+
let manifest;
|
|
306
|
+
if (existingManifest.text === TOKENJUICE_LOCALCODE_MANIFEST) {
|
|
307
|
+
manifest = { filePath: manifestPath };
|
|
308
|
+
}
|
|
309
|
+
else if (manifestBackupPath) {
|
|
310
|
+
await writeTextFileWithoutBackup(manifestPath, TOKENJUICE_LOCALCODE_MANIFEST);
|
|
311
|
+
manifest = { filePath: manifestPath };
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
manifest = await writeInstructionFile(manifestPath, TOKENJUICE_LOCALCODE_MANIFEST);
|
|
315
|
+
}
|
|
316
|
+
let index;
|
|
317
|
+
if (existingIndex.text === nextIndex) {
|
|
318
|
+
index = { filePath: indexPath };
|
|
319
|
+
}
|
|
320
|
+
else if (indexBackupPath) {
|
|
321
|
+
await writeTextFileWithoutBackup(indexPath, nextIndex);
|
|
322
|
+
index = { filePath: indexPath };
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
index = await writeInstructionFile(indexPath, nextIndex);
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
pluginDir,
|
|
329
|
+
manifestPath: manifest.filePath,
|
|
330
|
+
indexPath: index.filePath,
|
|
331
|
+
...(manifestBackupPath ? { manifestBackupPath } : manifest.backupPath ? { manifestBackupPath: manifest.backupPath } : {}),
|
|
332
|
+
...(indexBackupPath ? { indexBackupPath } : index.backupPath ? { indexBackupPath: index.backupPath } : {}),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
const manifestBackupPath = existingManifest.exists ? await chooseLocalCodeBackupPath(manifestPath) : undefined;
|
|
336
|
+
const indexBackupPath = existingIndex.exists ? await chooseLocalCodeBackupPath(indexPath) : undefined;
|
|
337
|
+
if (manifestBackupPath) {
|
|
338
|
+
await writeFile(manifestBackupPath, existingManifest.text, { encoding: "utf8", flag: "wx" });
|
|
339
|
+
}
|
|
340
|
+
if (indexBackupPath) {
|
|
341
|
+
await writeFile(indexBackupPath, existingIndex.text, { encoding: "utf8", flag: "wx" });
|
|
342
|
+
}
|
|
343
|
+
await writeTextFileWithoutBackup(manifestPath, TOKENJUICE_LOCALCODE_MANIFEST);
|
|
344
|
+
await writeTextFileWithoutBackup(indexPath, buildLocalCodePlugin({
|
|
345
|
+
manifestBackupSuffix: manifestBackupPath ? manifestBackupPath.slice(manifestPath.length) : undefined,
|
|
346
|
+
indexBackupSuffix: indexBackupPath ? indexBackupPath.slice(indexPath.length) : undefined,
|
|
347
|
+
}));
|
|
348
|
+
return {
|
|
349
|
+
pluginDir,
|
|
350
|
+
manifestPath,
|
|
351
|
+
indexPath,
|
|
352
|
+
...(manifestBackupPath ? { manifestBackupPath } : {}),
|
|
353
|
+
...(indexBackupPath ? { indexBackupPath } : {}),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
async function restoreOrRemoveOwnedPluginFile(filePath, existing, restoreBackupSuffix) {
|
|
357
|
+
if (!existing.exists || !existing.text.includes(TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER)) {
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
if (restoreBackupSuffix) {
|
|
361
|
+
const backupPath = `${filePath}${restoreBackupSuffix}`;
|
|
362
|
+
await rejectPluginFileSymlink(backupPath);
|
|
363
|
+
const backup = await readInstructionFile(backupPath);
|
|
364
|
+
if (backup.exists && !backup.text.includes(TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER)) {
|
|
365
|
+
await rm(filePath, { force: true });
|
|
366
|
+
await rename(backupPath, filePath);
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const result = await removeInstructionFile(filePath);
|
|
371
|
+
return result.removed;
|
|
372
|
+
}
|
|
373
|
+
export async function uninstallLocalCodePlugin(options = {}) {
|
|
374
|
+
const pluginDir = getPluginDir(options);
|
|
375
|
+
const manifestPath = getManifestPath(options);
|
|
376
|
+
const indexPath = getIndexPath(options);
|
|
377
|
+
await rejectPluginDirectorySymlinks(options);
|
|
378
|
+
await rejectPluginFileSymlink(manifestPath);
|
|
379
|
+
await rejectPluginFileSymlink(indexPath);
|
|
380
|
+
const { manifest: existingManifest, index: existingIndex } = await readLocalCodePluginFiles(options);
|
|
381
|
+
if (!hasTokenjuiceMarker(existingManifest.text, existingIndex.text)) {
|
|
382
|
+
return {
|
|
383
|
+
pluginDir,
|
|
384
|
+
manifestPath,
|
|
385
|
+
indexPath,
|
|
386
|
+
removed: false,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
const restoreBackups = readRestoreBackups(existingIndex.text);
|
|
390
|
+
const manifestRemoved = await restoreOrRemoveOwnedPluginFile(manifestPath, existingManifest, restoreBackups.manifestBackupSuffix);
|
|
391
|
+
const indexRemoved = await restoreOrRemoveOwnedPluginFile(indexPath, existingIndex, restoreBackups.indexBackupSuffix);
|
|
392
|
+
if (manifestRemoved || indexRemoved) {
|
|
393
|
+
await rmdir(pluginDir).catch(() => undefined);
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
pluginDir,
|
|
397
|
+
manifestPath,
|
|
398
|
+
indexPath,
|
|
399
|
+
removed: manifestRemoved || indexRemoved,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
function collectManifestIssues(text) {
|
|
403
|
+
let manifest;
|
|
404
|
+
try {
|
|
405
|
+
manifest = JSON.parse(text);
|
|
406
|
+
}
|
|
407
|
+
catch {
|
|
408
|
+
return ["configured LocalCode plugin manifest is not valid JSON"];
|
|
409
|
+
}
|
|
410
|
+
if (!isRecord(manifest)) {
|
|
411
|
+
return ["configured LocalCode plugin manifest is not an object"];
|
|
412
|
+
}
|
|
413
|
+
const tools = Array.isArray(manifest.tools) ? manifest.tools : [];
|
|
414
|
+
const commands = Array.isArray(manifest.commands) ? manifest.commands : [];
|
|
415
|
+
return [
|
|
416
|
+
...(text.includes(TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER)
|
|
417
|
+
? []
|
|
418
|
+
: ["configured LocalCode plugin manifest is missing the tokenjuice ownership marker"]),
|
|
419
|
+
...(manifest.name === "tokenjuice" ? [] : ["configured LocalCode plugin manifest is missing the tokenjuice plugin name"]),
|
|
420
|
+
...(manifest.version === "1.0.0" ? [] : ["configured LocalCode plugin manifest is missing the tokenjuice plugin version"]),
|
|
421
|
+
...(tools.includes(TOKENJUICE_LOCALCODE_TOOL_NAME)
|
|
422
|
+
? []
|
|
423
|
+
: ["configured LocalCode plugin manifest is missing the tokenjuice compaction tool"]),
|
|
424
|
+
...(commands.includes(TOKENJUICE_LOCALCODE_COMMAND.trim())
|
|
425
|
+
? []
|
|
426
|
+
: ["configured LocalCode plugin manifest is missing the tokenjuice slash command"]),
|
|
427
|
+
];
|
|
428
|
+
}
|
|
429
|
+
export async function doctorLocalCodePlugin(options = {}) {
|
|
430
|
+
const pluginDir = getPluginDir(options);
|
|
431
|
+
const manifestPath = getManifestPath(options);
|
|
432
|
+
const indexPath = getIndexPath(options);
|
|
433
|
+
let manifest;
|
|
434
|
+
let index;
|
|
435
|
+
try {
|
|
436
|
+
await rejectPluginDirectorySymlinks(options);
|
|
437
|
+
await rejectPluginFileSymlink(manifestPath);
|
|
438
|
+
await rejectPluginFileSymlink(indexPath);
|
|
439
|
+
({ manifest, index } = await readLocalCodePluginFiles(options));
|
|
440
|
+
}
|
|
441
|
+
catch (error) {
|
|
442
|
+
return {
|
|
443
|
+
pluginDir,
|
|
444
|
+
manifestPath,
|
|
445
|
+
indexPath,
|
|
446
|
+
hasTokenjuiceMarker: false,
|
|
447
|
+
...buildInstructionDoctorReportFields({
|
|
448
|
+
status: "broken",
|
|
449
|
+
issues: [error.message],
|
|
450
|
+
advisory: TOKENJUICE_LOCALCODE_ADVISORY,
|
|
451
|
+
fixCommand: "replace symlinked LocalCode plugin files with regular files, then run tokenjuice install localcode",
|
|
452
|
+
}),
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const hasMarker = hasTokenjuiceMarker(manifest.text, index.text);
|
|
456
|
+
if (!manifest.exists && !index.exists) {
|
|
457
|
+
return {
|
|
458
|
+
pluginDir,
|
|
459
|
+
manifestPath,
|
|
460
|
+
indexPath,
|
|
461
|
+
hasTokenjuiceMarker: false,
|
|
462
|
+
...buildInstructionDoctorReportFields({
|
|
463
|
+
status: "disabled",
|
|
464
|
+
issues: ["tokenjuice LocalCode plugin is not installed"],
|
|
465
|
+
advisory: TOKENJUICE_LOCALCODE_ADVISORY,
|
|
466
|
+
fixCommand: TOKENJUICE_LOCALCODE_FIX_COMMAND,
|
|
467
|
+
}),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
if (!hasMarker) {
|
|
471
|
+
return {
|
|
472
|
+
pluginDir,
|
|
473
|
+
manifestPath,
|
|
474
|
+
indexPath,
|
|
475
|
+
hasTokenjuiceMarker: false,
|
|
476
|
+
...buildInstructionDoctorReportFields({
|
|
477
|
+
status: "disabled",
|
|
478
|
+
issues: ["tokenjuice LocalCode plugin is not installed; existing plugin files are not tokenjuice-managed"],
|
|
479
|
+
advisory: TOKENJUICE_LOCALCODE_ADVISORY,
|
|
480
|
+
fixCommand: TOKENJUICE_LOCALCODE_FIX_COMMAND,
|
|
481
|
+
}),
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const issues = [
|
|
485
|
+
...(manifest.exists ? collectManifestIssues(manifest.text) : ["configured LocalCode plugin manifest is missing"]),
|
|
486
|
+
...(index.exists
|
|
487
|
+
? collectGuidanceIssues(index.text, {
|
|
488
|
+
required: [
|
|
489
|
+
{
|
|
490
|
+
requiredText: TOKENJUICE_LOCALCODE_OWNERSHIP_MARKER,
|
|
491
|
+
missingIssue: "configured LocalCode plugin is missing the tokenjuice ownership marker",
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
requiredText: TOKENJUICE_LOCALCODE_PLUGIN_MARKER,
|
|
495
|
+
missingIssue: "configured LocalCode plugin does not look like the tokenjuice plugin",
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
requiredText: TOKENJUICE_LOCALCODE_TOOL_NAME,
|
|
499
|
+
missingIssue: "configured LocalCode plugin is missing the tokenjuice compaction tool",
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
requiredText: "reduce-json",
|
|
503
|
+
missingIssue: "configured LocalCode plugin is missing tokenjuice reduce-json wiring",
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
requiredText: "command string is metadata only",
|
|
507
|
+
missingIssue: "configured LocalCode plugin is missing the no-command-execution safety note",
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
requiredText: "shell: false",
|
|
511
|
+
missingIssue: "configured LocalCode plugin is missing shell-free tokenjuice execution",
|
|
512
|
+
},
|
|
513
|
+
],
|
|
514
|
+
forbidden: [
|
|
515
|
+
{
|
|
516
|
+
forbiddenText: "shell: true",
|
|
517
|
+
presentIssue: "configured LocalCode plugin enables shell execution",
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
forbiddenText: "execSync(",
|
|
521
|
+
presentIssue: "configured LocalCode plugin uses execSync",
|
|
522
|
+
},
|
|
523
|
+
],
|
|
524
|
+
})
|
|
525
|
+
: ["configured LocalCode plugin index.js is missing"]),
|
|
526
|
+
];
|
|
527
|
+
return {
|
|
528
|
+
pluginDir,
|
|
529
|
+
manifestPath,
|
|
530
|
+
indexPath,
|
|
531
|
+
hasTokenjuiceMarker: hasMarker,
|
|
532
|
+
...buildInstructionDoctorReportFields({
|
|
533
|
+
status: instructionDoctorStatusFromIssues(issues),
|
|
534
|
+
issues,
|
|
535
|
+
advisory: TOKENJUICE_LOCALCODE_ADVISORY,
|
|
536
|
+
fixCommand: TOKENJUICE_LOCALCODE_FIX_COMMAND,
|
|
537
|
+
}),
|
|
538
|
+
};
|
|
539
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type McpAgentDefinitionOptions = {
|
|
2
|
+
projectDir?: string;
|
|
3
|
+
};
|
|
4
|
+
export type InstallMcpAgentDefinitionResult = {
|
|
5
|
+
agentPath: string;
|
|
6
|
+
backupPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export type UninstallMcpAgentDefinitionResult = {
|
|
9
|
+
agentPath: string;
|
|
10
|
+
removed: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type McpAgentDoctorReport = {
|
|
13
|
+
agentPath: string;
|
|
14
|
+
hasTokenjuiceMarker: boolean;
|
|
15
|
+
status: "ok" | "broken" | "disabled";
|
|
16
|
+
issues: string[];
|
|
17
|
+
advisories: string[];
|
|
18
|
+
fixCommand: string;
|
|
19
|
+
checkedPaths: string[];
|
|
20
|
+
missingPaths: string[];
|
|
21
|
+
};
|
|
22
|
+
export declare function installMcpAgentDefinition(agentPath?: string, options?: McpAgentDefinitionOptions): Promise<InstallMcpAgentDefinitionResult>;
|
|
23
|
+
export declare function uninstallMcpAgentDefinition(agentPath?: string, options?: McpAgentDefinitionOptions): Promise<UninstallMcpAgentDefinitionResult>;
|
|
24
|
+
export declare function doctorMcpAgentDefinition(agentPath?: string, options?: McpAgentDefinitionOptions): Promise<McpAgentDoctorReport>;
|