@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 @@
|
|
|
1
|
+
export declare function getAutoCompactionEnabled(projectRoot: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { isRecord } from "./pi-types.js";
|
|
4
|
+
import { formatErrorMessage } from "./utils.js";
|
|
5
|
+
export function getAutoCompactionEnabled(projectRoot) {
|
|
6
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
7
|
+
const agentDir = process.env.PI_CODING_AGENT_DIR || join(home, ".pi", "agent");
|
|
8
|
+
const settingsPaths = [join(agentDir, "settings.json"), join(projectRoot, ".pi", "settings.json")];
|
|
9
|
+
let enabled = true;
|
|
10
|
+
for (const settingsPath of settingsPaths) {
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error.code === "ENOENT") {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`tokenjuice failed to load pi settings from ${settingsPath}: ${formatErrorMessage(error)}`);
|
|
20
|
+
}
|
|
21
|
+
if (isRecord(parsed) && isRecord(parsed.compaction) && typeof parsed.compaction.enabled === "boolean") {
|
|
22
|
+
enabled = parsed.compaction.enabled;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return enabled;
|
|
26
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { formatCompactNumber } from "./status.js";
|
|
2
|
+
const ANSI_SGR_PATTERN = new RegExp("\\u001B\\[[0-9;]*m", "g");
|
|
3
|
+
function visibleWidth(text) {
|
|
4
|
+
return String(text).replace(ANSI_SGR_PATTERN, "").length;
|
|
5
|
+
}
|
|
6
|
+
function truncateToWidth(text, width) {
|
|
7
|
+
if (visibleWidth(text) <= width) {
|
|
8
|
+
return text;
|
|
9
|
+
}
|
|
10
|
+
const plain = String(text).replace(ANSI_SGR_PATTERN, "");
|
|
11
|
+
return plain.slice(0, Math.max(0, width));
|
|
12
|
+
}
|
|
13
|
+
function padToWidth(text, width) {
|
|
14
|
+
const truncated = truncateToWidth(text, width);
|
|
15
|
+
return truncated + " ".repeat(Math.max(0, width - visibleWidth(truncated)));
|
|
16
|
+
}
|
|
17
|
+
function line(theme, label, value, width) {
|
|
18
|
+
return truncateToWidth(` ${theme.fg("dim", `${label}:`)} ${value}`, width);
|
|
19
|
+
}
|
|
20
|
+
function stateColor(theme, on, offStyle = "dim") {
|
|
21
|
+
return on ? theme.fg("success", "on") : theme.fg(offStyle, "off");
|
|
22
|
+
}
|
|
23
|
+
export async function showTokenjuiceStatusPanel(ctx, snapshot) {
|
|
24
|
+
if (!ctx.hasUI || typeof ctx.ui.custom !== "function") {
|
|
25
|
+
ctx.ui.notify(`tokenjuice manual ${snapshot.manualEnabled ? "on" : "off"}; pi auto-compaction ${snapshot.autoCompactEnabled ? "on" : "off"}; effective ${snapshot.effectiveEnabled ? "on" : "off"}; bypass-next ${snapshot.bypassNext ? "armed" : "idle"}`, "info");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
await ctx.ui.custom((_tui, theme, _keybindings, done) => ({
|
|
29
|
+
render(width) {
|
|
30
|
+
const panelWidth = Math.max(0, Math.min(width, 68));
|
|
31
|
+
if (panelWidth === 0) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
if (panelWidth < 4) {
|
|
35
|
+
return [truncateToWidth("tokenjuice", panelWidth)];
|
|
36
|
+
}
|
|
37
|
+
const innerWidth = panelWidth - 4;
|
|
38
|
+
const lines = [
|
|
39
|
+
theme.fg("accent", "tokenjuice"),
|
|
40
|
+
"",
|
|
41
|
+
theme.fg("dim", "state"),
|
|
42
|
+
line(theme, "manual", stateColor(theme, snapshot.manualEnabled), innerWidth),
|
|
43
|
+
line(theme, "pi auto-compaction", stateColor(theme, snapshot.autoCompactEnabled, "warning"), innerWidth),
|
|
44
|
+
line(theme, "effective", stateColor(theme, snapshot.effectiveEnabled, "warning"), innerWidth),
|
|
45
|
+
line(theme, "bypass-next", snapshot.bypassNext ? theme.fg("warning", "armed") : theme.fg("dim", "idle"), innerWidth),
|
|
46
|
+
"",
|
|
47
|
+
theme.fg("dim", "session savings"),
|
|
48
|
+
line(theme, "compacted results", String(snapshot.compactedCount), innerWidth),
|
|
49
|
+
line(theme, "saved chars", formatCompactNumber(snapshot.savedChars), innerWidth),
|
|
50
|
+
line(theme, "raw chars", formatCompactNumber(snapshot.rawChars), innerWidth),
|
|
51
|
+
line(theme, "reduced chars", formatCompactNumber(snapshot.reducedChars), innerWidth),
|
|
52
|
+
line(theme, "avg saved/result", formatCompactNumber(snapshot.averageSavedChars), innerWidth),
|
|
53
|
+
...(snapshot.lastReducer ? [line(theme, "last reducer", snapshot.lastReducer, innerWidth)] : []),
|
|
54
|
+
"",
|
|
55
|
+
theme.fg("dim", "commands"),
|
|
56
|
+
truncateToWidth(" /tj on /tj off /tj raw-next", innerWidth),
|
|
57
|
+
"",
|
|
58
|
+
theme.fg("dim", "esc / enter / q to close"),
|
|
59
|
+
];
|
|
60
|
+
const border = theme.fg("dim", `┌${"─".repeat(innerWidth + 2)}┐`);
|
|
61
|
+
const footer = theme.fg("dim", `└${"─".repeat(innerWidth + 2)}┘`);
|
|
62
|
+
const boxedLines = lines.map((content) => `${theme.fg("dim", "│")} ${padToWidth(content, innerWidth)} ${theme.fg("dim", "│")}`);
|
|
63
|
+
return [border, ...boxedLines, footer].map((renderedLine) => truncateToWidth(renderedLine, panelWidth));
|
|
64
|
+
},
|
|
65
|
+
handleInput(data) {
|
|
66
|
+
if (data === "\r" || data === "\n" || data === "q" || data === "\u001b") {
|
|
67
|
+
done(undefined);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
invalidate() { },
|
|
71
|
+
}), { overlay: true });
|
|
72
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PiContext } from "./pi-types.js";
|
|
2
|
+
export type TokenjuiceStatusSnapshot = {
|
|
3
|
+
manualEnabled: boolean;
|
|
4
|
+
autoCompactEnabled: boolean;
|
|
5
|
+
effectiveEnabled: boolean;
|
|
6
|
+
bypassNext: boolean;
|
|
7
|
+
compactedCount: number;
|
|
8
|
+
savedChars: number;
|
|
9
|
+
rawChars: number;
|
|
10
|
+
reducedChars: number;
|
|
11
|
+
averageSavedChars: number;
|
|
12
|
+
lastReducer?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function formatCompactNumber(count: number): string;
|
|
15
|
+
export declare function buildTokenjuiceStatusSnapshot(sessionManager: PiContext["sessionManager"], options: {
|
|
16
|
+
manualEnabled: boolean;
|
|
17
|
+
autoCompactEnabled: boolean;
|
|
18
|
+
bypassNext: boolean;
|
|
19
|
+
}): TokenjuiceStatusSnapshot;
|
|
20
|
+
export declare function buildTokenjuiceStatusMessage(enabled: boolean, autoCompactEnabled: boolean, bypassNext: boolean): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isRecord } from "./pi-types.js";
|
|
2
|
+
export function formatCompactNumber(count) {
|
|
3
|
+
if (count < 1000)
|
|
4
|
+
return count.toString();
|
|
5
|
+
if (count < 10000)
|
|
6
|
+
return `${(count / 1000).toFixed(1)}k`;
|
|
7
|
+
if (count < 1000000)
|
|
8
|
+
return `${Math.round(count / 1000)}k`;
|
|
9
|
+
if (count < 10000000)
|
|
10
|
+
return `${(count / 1000000).toFixed(1)}M`;
|
|
11
|
+
return `${Math.round(count / 1000000)}M`;
|
|
12
|
+
}
|
|
13
|
+
function getTokenjuiceEntries(sessionManager) {
|
|
14
|
+
return sessionManager.getBranch();
|
|
15
|
+
}
|
|
16
|
+
export function buildTokenjuiceStatusSnapshot(sessionManager, options) {
|
|
17
|
+
let compactedCount = 0;
|
|
18
|
+
let savedChars = 0;
|
|
19
|
+
let rawChars = 0;
|
|
20
|
+
let reducedChars = 0;
|
|
21
|
+
let lastReducer;
|
|
22
|
+
for (const entry of getTokenjuiceEntries(sessionManager)) {
|
|
23
|
+
if (entry.type !== "message" || entry.message?.role !== "toolResult") {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const details = isRecord(entry.message.details) ? entry.message.details : null;
|
|
27
|
+
const tokenjuice = details && isRecord(details.tokenjuice) ? details.tokenjuice : null;
|
|
28
|
+
if (!tokenjuice || tokenjuice.compacted !== true) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
compactedCount += 1;
|
|
32
|
+
savedChars += typeof tokenjuice.savedChars === "number" ? tokenjuice.savedChars : 0;
|
|
33
|
+
rawChars += typeof tokenjuice.rawChars === "number" ? tokenjuice.rawChars : 0;
|
|
34
|
+
reducedChars += typeof tokenjuice.reducedChars === "number" ? tokenjuice.reducedChars : 0;
|
|
35
|
+
if (typeof tokenjuice.reducer === "string" && tokenjuice.reducer) {
|
|
36
|
+
lastReducer = tokenjuice.reducer;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
manualEnabled: options.manualEnabled,
|
|
41
|
+
autoCompactEnabled: options.autoCompactEnabled,
|
|
42
|
+
effectiveEnabled: options.manualEnabled && options.autoCompactEnabled,
|
|
43
|
+
bypassNext: options.bypassNext,
|
|
44
|
+
compactedCount,
|
|
45
|
+
savedChars,
|
|
46
|
+
rawChars,
|
|
47
|
+
reducedChars,
|
|
48
|
+
averageSavedChars: compactedCount > 0 ? Math.round(savedChars / compactedCount) : 0,
|
|
49
|
+
...(lastReducer ? { lastReducer } : {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function buildTokenjuiceStatusMessage(enabled, autoCompactEnabled, bypassNext) {
|
|
53
|
+
const manualState = enabled ? "on" : "off";
|
|
54
|
+
const autoState = autoCompactEnabled ? "on" : "off";
|
|
55
|
+
const effectiveState = enabled && autoCompactEnabled ? "on" : "off";
|
|
56
|
+
const bypassState = bypassNext ? "armed" : "idle";
|
|
57
|
+
return `tokenjuice manual ${manualState}; pi auto-compaction ${autoState}; effective ${effectiveState}; bypass-next ${bypassState}`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildBypassNotice, buildCompactionNotice, buildTokenjuiceDetails, extractTextContent, mergeDetails, type TokenjuiceDetails, } from "../../shared/tool-result.js";
|
|
2
|
+
export declare function parseExitCode(text: string, isError: boolean): number;
|
|
3
|
+
export declare function extractFullOutputPath(details: unknown): string | undefined;
|
|
4
|
+
export declare function stripPiBashEpilogue(text: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { buildBypassNotice, buildCompactionNotice, buildTokenjuiceDetails, extractTextContent, mergeDetails, } from "../../shared/tool-result.js";
|
|
2
|
+
import { isRecord } from "./pi-types.js";
|
|
3
|
+
export function parseExitCode(text, isError) {
|
|
4
|
+
if (!isError) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
const match = text.match(/Command exited with code (\d+)/u);
|
|
8
|
+
if (match?.[1]) {
|
|
9
|
+
return Number(match[1]);
|
|
10
|
+
}
|
|
11
|
+
return 1;
|
|
12
|
+
}
|
|
13
|
+
export function extractFullOutputPath(details) {
|
|
14
|
+
if (isRecord(details) && typeof details.fullOutputPath === "string" && details.fullOutputPath) {
|
|
15
|
+
return details.fullOutputPath;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export function stripPiBashEpilogue(text) {
|
|
20
|
+
return text
|
|
21
|
+
.replace(/\n\nCommand exited with code \d+\s*$/u, "")
|
|
22
|
+
.replace(/\n\nCommand timed out after \d+ seconds\s*$/u, "")
|
|
23
|
+
.replace(/\n\nCommand aborted\s*$/u, "");
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatErrorMessage(error: unknown): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type PiExtensionCommandOptions = {
|
|
2
|
+
local?: boolean;
|
|
3
|
+
binaryPath?: string;
|
|
4
|
+
nodePath?: string;
|
|
5
|
+
};
|
|
6
|
+
export type InstallPiExtensionResult = {
|
|
7
|
+
extensionPath: string;
|
|
8
|
+
backupPath?: string;
|
|
9
|
+
};
|
|
10
|
+
export type UninstallPiExtensionResult = {
|
|
11
|
+
extensionPath: string;
|
|
12
|
+
backupPath?: string;
|
|
13
|
+
removed: boolean;
|
|
14
|
+
restoredBackup: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type PiDoctorReport = {
|
|
17
|
+
extensionPath: string;
|
|
18
|
+
status: "ok" | "warn" | "broken" | "disabled";
|
|
19
|
+
issues: string[];
|
|
20
|
+
fixCommand: string;
|
|
21
|
+
checkedPaths: string[];
|
|
22
|
+
missingPaths: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function installPiExtension(extensionPath?: string, options?: PiExtensionCommandOptions): Promise<InstallPiExtensionResult>;
|
|
25
|
+
export declare function uninstallPiExtension(extensionPath?: string): Promise<UninstallPiExtensionResult>;
|
|
26
|
+
export declare function doctorPiExtension(extensionPath?: string): Promise<PiDoctorReport>;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { access, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import packageJson from "../../../package.json" with { type: "json" };
|
|
6
|
+
const TOKENJUICE_PI_EXTENSION_COMMAND = "tj";
|
|
7
|
+
const LEGACY_PI_RUNTIME_BASENAME = "tokenjuice-runtime.js";
|
|
8
|
+
const TOKENJUICE_PI_FIX_COMMAND = "tokenjuice install pi";
|
|
9
|
+
function getPiAgentDir() {
|
|
10
|
+
return process.env.PI_CODING_AGENT_DIR || join(homedir(), ".pi", "agent");
|
|
11
|
+
}
|
|
12
|
+
function getDefaultExtensionPath() {
|
|
13
|
+
return join(getPiAgentDir(), "extensions", "tokenjuice.js");
|
|
14
|
+
}
|
|
15
|
+
function buildPiExtensionSource(runtimeSource, config) {
|
|
16
|
+
return String.raw `/**
|
|
17
|
+
* tokenjuice pi extension
|
|
18
|
+
* generated by tokenjuice v${packageJson.version}
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
${runtimeSource}
|
|
22
|
+
|
|
23
|
+
const config = ${JSON.stringify(config, null, 2)};
|
|
24
|
+
|
|
25
|
+
export default createTokenjuicePiExtension(config);
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
async function resolvePiRuntimeEntryPoint() {
|
|
29
|
+
const candidates = [
|
|
30
|
+
fileURLToPath(new URL("./extension/runtime.ts", import.meta.url)),
|
|
31
|
+
fileURLToPath(new URL("../../../src/hosts/pi/extension/runtime.ts", import.meta.url)),
|
|
32
|
+
];
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
try {
|
|
35
|
+
await access(candidate);
|
|
36
|
+
return candidate;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`unable to resolve pi runtime source entrypoint from ${candidates.join(", ")}`);
|
|
43
|
+
}
|
|
44
|
+
async function bundlePiExtensionRuntimeSource() {
|
|
45
|
+
let esbuild;
|
|
46
|
+
try {
|
|
47
|
+
esbuild = await import("esbuild");
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new Error(`unable to load esbuild to bundle the pi runtime from source: ${String(error)}`);
|
|
51
|
+
}
|
|
52
|
+
const entryPoint = await resolvePiRuntimeEntryPoint();
|
|
53
|
+
const result = await esbuild.build({
|
|
54
|
+
entryPoints: [entryPoint],
|
|
55
|
+
bundle: true,
|
|
56
|
+
format: "esm",
|
|
57
|
+
platform: "node",
|
|
58
|
+
target: "node20",
|
|
59
|
+
write: false,
|
|
60
|
+
});
|
|
61
|
+
const runtimeSource = result.outputFiles[0]?.text;
|
|
62
|
+
if (!runtimeSource) {
|
|
63
|
+
throw new Error("failed to bundle the pi runtime: esbuild produced no output");
|
|
64
|
+
}
|
|
65
|
+
return runtimeSource;
|
|
66
|
+
}
|
|
67
|
+
async function loadPiExtensionRuntimeSource(local = false) {
|
|
68
|
+
if (local) {
|
|
69
|
+
return await bundlePiExtensionRuntimeSource();
|
|
70
|
+
}
|
|
71
|
+
const runtimeAssetUrl = new URL("./extension/runtime.js", import.meta.url);
|
|
72
|
+
try {
|
|
73
|
+
return await readFile(runtimeAssetUrl, "utf8");
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error.code !== "ENOENT") {
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return await bundlePiExtensionRuntimeSource();
|
|
81
|
+
}
|
|
82
|
+
async function writeAtomically(path, content) {
|
|
83
|
+
const tempPath = `${path}.tmp`;
|
|
84
|
+
await writeFile(tempPath, content, { encoding: "utf8", mode: 0o600 });
|
|
85
|
+
await rename(tempPath, path);
|
|
86
|
+
}
|
|
87
|
+
async function chooseBackupPath(filePath) {
|
|
88
|
+
for (let index = 0;; index += 1) {
|
|
89
|
+
const candidate = index === 0 ? `${filePath}.bak` : `${filePath}.bak.${index}`;
|
|
90
|
+
try {
|
|
91
|
+
await access(candidate);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error.code === "ENOENT") {
|
|
95
|
+
return candidate;
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function removeLegacyRuntimeFile(extensionPath) {
|
|
102
|
+
const legacyRuntimePath = join(dirname(extensionPath), LEGACY_PI_RUNTIME_BASENAME);
|
|
103
|
+
try {
|
|
104
|
+
await rm(legacyRuntimePath);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (error.code !== "ENOENT") {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function isTokenjuiceGeneratedPiExtension(source) {
|
|
113
|
+
return source.includes("generated by tokenjuice v") && source.includes("createTokenjuicePiExtension");
|
|
114
|
+
}
|
|
115
|
+
async function findRestorableBackup(extensionPath) {
|
|
116
|
+
let latest;
|
|
117
|
+
for (let index = 0;; index += 1) {
|
|
118
|
+
const backupPath = index === 0 ? `${extensionPath}.bak` : `${extensionPath}.bak.${index}`;
|
|
119
|
+
try {
|
|
120
|
+
const source = await readFile(backupPath, "utf8");
|
|
121
|
+
if (!isTokenjuiceGeneratedPiExtension(source)) {
|
|
122
|
+
latest = { backupPath, source };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error.code === "ENOENT") {
|
|
127
|
+
return latest;
|
|
128
|
+
}
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export async function installPiExtension(extensionPath = getDefaultExtensionPath(), options = {}) {
|
|
134
|
+
const runtimeConfig = {
|
|
135
|
+
extensionCommand: TOKENJUICE_PI_EXTENSION_COMMAND,
|
|
136
|
+
};
|
|
137
|
+
const runtimeSource = await loadPiExtensionRuntimeSource(Boolean(options.local));
|
|
138
|
+
const extensionSource = buildPiExtensionSource(runtimeSource, runtimeConfig);
|
|
139
|
+
await mkdir(dirname(extensionPath), { recursive: true });
|
|
140
|
+
let backupPath;
|
|
141
|
+
try {
|
|
142
|
+
const existing = await readFile(extensionPath, "utf8");
|
|
143
|
+
backupPath = await chooseBackupPath(extensionPath);
|
|
144
|
+
await writeFile(backupPath, existing, "utf8");
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error.code !== "ENOENT") {
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
await removeLegacyRuntimeFile(extensionPath);
|
|
152
|
+
await writeAtomically(extensionPath, extensionSource);
|
|
153
|
+
return {
|
|
154
|
+
extensionPath,
|
|
155
|
+
...(backupPath ? { backupPath } : {}),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export async function uninstallPiExtension(extensionPath = getDefaultExtensionPath()) {
|
|
159
|
+
let source;
|
|
160
|
+
try {
|
|
161
|
+
source = await readFile(extensionPath, "utf8");
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
if (error.code === "ENOENT") {
|
|
165
|
+
return { extensionPath, removed: false, restoredBackup: false };
|
|
166
|
+
}
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
if (!isTokenjuiceGeneratedPiExtension(source)) {
|
|
170
|
+
return { extensionPath, removed: false, restoredBackup: false };
|
|
171
|
+
}
|
|
172
|
+
await removeLegacyRuntimeFile(extensionPath);
|
|
173
|
+
const restorableBackup = await findRestorableBackup(extensionPath);
|
|
174
|
+
if (restorableBackup) {
|
|
175
|
+
await writeAtomically(extensionPath, restorableBackup.source);
|
|
176
|
+
return { extensionPath, backupPath: restorableBackup.backupPath, removed: true, restoredBackup: true };
|
|
177
|
+
}
|
|
178
|
+
await rm(extensionPath);
|
|
179
|
+
return { extensionPath, removed: true, restoredBackup: false };
|
|
180
|
+
}
|
|
181
|
+
export async function doctorPiExtension(extensionPath = getDefaultExtensionPath()) {
|
|
182
|
+
let source;
|
|
183
|
+
try {
|
|
184
|
+
source = await readFile(extensionPath, "utf8");
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
if (error.code === "ENOENT") {
|
|
188
|
+
return {
|
|
189
|
+
extensionPath,
|
|
190
|
+
status: "disabled",
|
|
191
|
+
issues: [],
|
|
192
|
+
fixCommand: TOKENJUICE_PI_FIX_COMMAND,
|
|
193
|
+
checkedPaths: [],
|
|
194
|
+
missingPaths: [],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
extensionPath,
|
|
199
|
+
status: "broken",
|
|
200
|
+
issues: [`tokenjuice pi extension could not be read: ${String(error)}`],
|
|
201
|
+
fixCommand: TOKENJUICE_PI_FIX_COMMAND,
|
|
202
|
+
checkedPaths: [extensionPath],
|
|
203
|
+
missingPaths: [],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (!isTokenjuiceGeneratedPiExtension(source)) {
|
|
207
|
+
return {
|
|
208
|
+
extensionPath,
|
|
209
|
+
status: "disabled",
|
|
210
|
+
issues: [],
|
|
211
|
+
fixCommand: TOKENJUICE_PI_FIX_COMMAND,
|
|
212
|
+
checkedPaths: [],
|
|
213
|
+
missingPaths: [],
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const issues = [];
|
|
217
|
+
if (source.includes(LEGACY_PI_RUNTIME_BASENAME)) {
|
|
218
|
+
issues.push("installed pi extension still references the legacy sibling runtime");
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
extensionPath,
|
|
222
|
+
status: issues.length > 0 ? "warn" : "ok",
|
|
223
|
+
issues,
|
|
224
|
+
fixCommand: TOKENJUICE_PI_FIX_COMMAND,
|
|
225
|
+
checkedPaths: [extensionPath],
|
|
226
|
+
missingPaths: [],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type PiGoSkillOptions = {
|
|
2
|
+
projectDir?: string;
|
|
3
|
+
};
|
|
4
|
+
export type InstallPiGoSkillResult = {
|
|
5
|
+
skillPath: string;
|
|
6
|
+
backupPath?: string;
|
|
7
|
+
};
|
|
8
|
+
export type UninstallPiGoSkillResult = {
|
|
9
|
+
skillPath: string;
|
|
10
|
+
removed: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type PiGoDoctorReport = {
|
|
13
|
+
skillPath: string;
|
|
14
|
+
hasTokenjuiceMarker: boolean;
|
|
15
|
+
status: "ok" | "warn" | "broken" | "disabled";
|
|
16
|
+
issues: string[];
|
|
17
|
+
advisories: string[];
|
|
18
|
+
fixCommand: string;
|
|
19
|
+
checkedPaths: string[];
|
|
20
|
+
missingPaths: string[];
|
|
21
|
+
};
|
|
22
|
+
export declare function installPiGoSkill(skillPath?: string, options?: PiGoSkillOptions): Promise<InstallPiGoSkillResult>;
|
|
23
|
+
export declare function uninstallPiGoSkill(skillPath?: string, options?: PiGoSkillOptions): Promise<UninstallPiGoSkillResult>;
|
|
24
|
+
export declare function doctorPiGoSkill(skillPath?: string, options?: PiGoSkillOptions): Promise<PiGoDoctorReport>;
|