@openclaw/tokenjuice 2026.5.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/index.js +13 -0
- package/dist/runtime-api.js +2 -0
- package/dist/tool-result-middleware.js +34 -0
- package/node_modules/tokenjuice/LICENSE +21 -0
- package/node_modules/tokenjuice/README.md +311 -0
- package/node_modules/tokenjuice/SECURITY.md +50 -0
- package/node_modules/tokenjuice/dist/cli/doctor-output.d.ts +2 -0
- package/node_modules/tokenjuice/dist/cli/doctor-output.js +92 -0
- package/node_modules/tokenjuice/dist/cli/install-output.d.ts +5 -0
- package/node_modules/tokenjuice/dist/cli/install-output.js +11 -0
- package/node_modules/tokenjuice/dist/cli/main.d.ts +34 -0
- package/node_modules/tokenjuice/dist/cli/main.js +6614 -0
- package/node_modules/tokenjuice/dist/core/analysis.d.ts +88 -0
- package/node_modules/tokenjuice/dist/core/analysis.js +313 -0
- package/node_modules/tokenjuice/dist/core/artifacts.d.ts +9 -0
- package/node_modules/tokenjuice/dist/core/artifacts.js +210 -0
- package/node_modules/tokenjuice/dist/core/builtin-rules.generated.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/builtin-rules.generated.js +262 -0
- package/node_modules/tokenjuice/dist/core/classify.d.ts +18 -0
- package/node_modules/tokenjuice/dist/core/classify.js +181 -0
- package/node_modules/tokenjuice/dist/core/cli-client.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/cli-client.js +127 -0
- package/node_modules/tokenjuice/dist/core/command-identity.d.ts +9 -0
- package/node_modules/tokenjuice/dist/core/command-identity.js +201 -0
- package/node_modules/tokenjuice/dist/core/command-match.d.ts +16 -0
- package/node_modules/tokenjuice/dist/core/command-match.js +443 -0
- package/node_modules/tokenjuice/dist/core/command-shell.d.ts +18 -0
- package/node_modules/tokenjuice/dist/core/command-shell.js +291 -0
- package/node_modules/tokenjuice/dist/core/command.d.ts +5 -0
- package/node_modules/tokenjuice/dist/core/command.js +4 -0
- package/node_modules/tokenjuice/dist/core/compaction-metadata.d.ts +10 -0
- package/node_modules/tokenjuice/dist/core/compaction-metadata.js +28 -0
- package/node_modules/tokenjuice/dist/core/env.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/env.js +5 -0
- package/node_modules/tokenjuice/dist/core/execution-input.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/execution-input.js +51 -0
- package/node_modules/tokenjuice/dist/core/fixtures.d.ts +14 -0
- package/node_modules/tokenjuice/dist/core/fixtures.js +190 -0
- package/node_modules/tokenjuice/dist/core/github-actions-summary.d.ts +6 -0
- package/node_modules/tokenjuice/dist/core/github-actions-summary.js +105 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.d.ts +33 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.js +85 -0
- package/node_modules/tokenjuice/dist/core/integrations/rewrite-policy.d.ts +8 -0
- package/node_modules/tokenjuice/dist/core/integrations/rewrite-policy.js +25 -0
- package/node_modules/tokenjuice/dist/core/inventory-safety.d.ts +11 -0
- package/node_modules/tokenjuice/dist/core/inventory-safety.js +347 -0
- package/node_modules/tokenjuice/dist/core/json-protocol.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/json-protocol.js +131 -0
- package/node_modules/tokenjuice/dist/core/reduce-formatters.d.ts +15 -0
- package/node_modules/tokenjuice/dist/core/reduce-formatters.js +611 -0
- package/node_modules/tokenjuice/dist/core/reduce-inspection-summary.d.ts +9 -0
- package/node_modules/tokenjuice/dist/core/reduce-inspection-summary.js +125 -0
- package/node_modules/tokenjuice/dist/core/reduce-utils.d.ts +12 -0
- package/node_modules/tokenjuice/dist/core/reduce-utils.js +117 -0
- package/node_modules/tokenjuice/dist/core/reduce.d.ts +5 -0
- package/node_modules/tokenjuice/dist/core/reduce.js +511 -0
- package/node_modules/tokenjuice/dist/core/rules.d.ts +22 -0
- package/node_modules/tokenjuice/dist/core/rules.js +265 -0
- package/node_modules/tokenjuice/dist/core/source.d.ts +6 -0
- package/node_modules/tokenjuice/dist/core/source.js +113 -0
- package/node_modules/tokenjuice/dist/core/text.d.ts +23 -0
- package/node_modules/tokenjuice/dist/core/text.js +204 -0
- package/node_modules/tokenjuice/dist/core/time.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/time.js +82 -0
- package/node_modules/tokenjuice/dist/core/validate-rules.d.ts +10 -0
- package/node_modules/tokenjuice/dist/core/validate-rules.js +198 -0
- package/node_modules/tokenjuice/dist/core/wrap.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/wrap.js +104 -0
- package/node_modules/tokenjuice/dist/hosts/adal/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/adal/index.js +157 -0
- package/node_modules/tokenjuice/dist/hosts/aether/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/aether/index.js +671 -0
- package/node_modules/tokenjuice/dist/hosts/agent-layer/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/agent-layer/index.js +173 -0
- package/node_modules/tokenjuice/dist/hosts/agentinit/index.d.ts +27 -0
- package/node_modules/tokenjuice/dist/hosts/agentinit/index.js +252 -0
- package/node_modules/tokenjuice/dist/hosts/agentlink/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/agentlink/index.js +310 -0
- package/node_modules/tokenjuice/dist/hosts/agentloom/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/agentloom/index.js +161 -0
- package/node_modules/tokenjuice/dist/hosts/agents-cli/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/agents-cli/index.js +136 -0
- package/node_modules/tokenjuice/dist/hosts/agents-md/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/agents-md/index.js +240 -0
- package/node_modules/tokenjuice/dist/hosts/agentsge/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/agentsge/index.js +119 -0
- package/node_modules/tokenjuice/dist/hosts/agentsmesh/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/agentsmesh/index.js +337 -0
- package/node_modules/tokenjuice/dist/hosts/ai-memory-protocol/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/ai-memory-protocol/index.js +392 -0
- package/node_modules/tokenjuice/dist/hosts/aictl/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/aictl/index.js +271 -0
- package/node_modules/tokenjuice/dist/hosts/aider/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/aider/index.js +79 -0
- package/node_modules/tokenjuice/dist/hosts/amazon-q/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/amazon-q/index.js +169 -0
- package/node_modules/tokenjuice/dist/hosts/amp/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/amp/index.js +306 -0
- package/node_modules/tokenjuice/dist/hosts/antigravity/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/antigravity/index.js +172 -0
- package/node_modules/tokenjuice/dist/hosts/anywhere-agents/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/anywhere-agents/index.js +260 -0
- package/node_modules/tokenjuice/dist/hosts/augment/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/augment/index.js +171 -0
- package/node_modules/tokenjuice/dist/hosts/avante/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/avante/index.js +68 -0
- package/node_modules/tokenjuice/dist/hosts/baz/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/baz/index.js +286 -0
- package/node_modules/tokenjuice/dist/hosts/bito/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/bito/index.js +363 -0
- package/node_modules/tokenjuice/dist/hosts/blackbox/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/blackbox/index.js +305 -0
- package/node_modules/tokenjuice/dist/hosts/blocks/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/blocks/index.js +317 -0
- package/node_modules/tokenjuice/dist/hosts/bob/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/bob/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/builder/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/builder/index.js +177 -0
- package/node_modules/tokenjuice/dist/hosts/charlie/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/charlie/index.js +275 -0
- package/node_modules/tokenjuice/dist/hosts/claude-code/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/claude-code/index.js +364 -0
- package/node_modules/tokenjuice/dist/hosts/clawdbot/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/clawdbot/index.js +320 -0
- package/node_modules/tokenjuice/dist/hosts/cline/index.d.ts +27 -0
- package/node_modules/tokenjuice/dist/hosts/cline/index.js +156 -0
- package/node_modules/tokenjuice/dist/hosts/codeant/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/codeant/index.js +370 -0
- package/node_modules/tokenjuice/dist/hosts/codebuddy/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/codebuddy/index.js +379 -0
- package/node_modules/tokenjuice/dist/hosts/codebuff/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/codebuff/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/codegen/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/codegen/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/coder-agents/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/coder-agents/index.js +339 -0
- package/node_modules/tokenjuice/dist/hosts/coderabbit/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/coderabbit/index.js +599 -0
- package/node_modules/tokenjuice/dist/hosts/codex/index.d.ts +93 -0
- package/node_modules/tokenjuice/dist/hosts/codex/index.js +945 -0
- package/node_modules/tokenjuice/dist/hosts/command-code/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/command-code/index.js +366 -0
- package/node_modules/tokenjuice/dist/hosts/continue/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/continue/index.js +81 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-agent/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-agent/index.js +497 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-cli/index.d.ts +31 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-cli/index.js +428 -0
- package/node_modules/tokenjuice/dist/hosts/crush/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/crush/index.js +135 -0
- package/node_modules/tokenjuice/dist/hosts/cursor/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/cursor/index.js +293 -0
- package/node_modules/tokenjuice/dist/hosts/deepagents/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/deepagents/index.js +157 -0
- package/node_modules/tokenjuice/dist/hosts/devin/index.d.ts +31 -0
- package/node_modules/tokenjuice/dist/hosts/devin/index.js +283 -0
- package/node_modules/tokenjuice/dist/hosts/docker-agent/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/docker-agent/index.js +206 -0
- package/node_modules/tokenjuice/dist/hosts/dot-agents/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/dot-agents/index.js +171 -0
- package/node_modules/tokenjuice/dist/hosts/droid/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/droid/index.js +313 -0
- package/node_modules/tokenjuice/dist/hosts/eca/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/eca/index.js +347 -0
- package/node_modules/tokenjuice/dist/hosts/elyra/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/elyra/index.js +382 -0
- package/node_modules/tokenjuice/dist/hosts/firebase-studio/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/firebase-studio/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/forgecode/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/forgecode/index.js +273 -0
- package/node_modules/tokenjuice/dist/hosts/gemini-cli/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/gemini-cli/index.js +234 -0
- package/node_modules/tokenjuice/dist/hosts/gitlab-duo/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/gitlab-duo/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/goose/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/goose/index.js +288 -0
- package/node_modules/tokenjuice/dist/hosts/gptme/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/gptme/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/greptile/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/greptile/index.js +299 -0
- package/node_modules/tokenjuice/dist/hosts/grok-build/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/grok-build/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/grok-cli/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/grok-cli/index.js +262 -0
- package/node_modules/tokenjuice/dist/hosts/jean2/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/jean2/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/jetbrains-ai/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/jetbrains-ai/index.js +202 -0
- package/node_modules/tokenjuice/dist/hosts/jules/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/jules/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/junie/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/junie/index.js +68 -0
- package/node_modules/tokenjuice/dist/hosts/kilo/index.d.ts +30 -0
- package/node_modules/tokenjuice/dist/hosts/kilo/index.js +497 -0
- package/node_modules/tokenjuice/dist/hosts/kimi/index.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/kimi/index.js +255 -0
- package/node_modules/tokenjuice/dist/hosts/kiro/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/kiro/index.js +116 -0
- package/node_modules/tokenjuice/dist/hosts/knowns/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/knowns/index.js +273 -0
- package/node_modules/tokenjuice/dist/hosts/leanctl/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/leanctl/index.js +317 -0
- package/node_modules/tokenjuice/dist/hosts/localcode/index.d.ts +31 -0
- package/node_modules/tokenjuice/dist/hosts/localcode/index.js +539 -0
- package/node_modules/tokenjuice/dist/hosts/mcp-agent/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/mcp-agent/index.js +302 -0
- package/node_modules/tokenjuice/dist/hosts/mini-swe-agent/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/mini-swe-agent/index.js +226 -0
- package/node_modules/tokenjuice/dist/hosts/mistral-vibe/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/mistral-vibe/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/mux/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/mux/index.js +411 -0
- package/node_modules/tokenjuice/dist/hosts/novakit/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/novakit/index.js +273 -0
- package/node_modules/tokenjuice/dist/hosts/ona/index.d.ts +41 -0
- package/node_modules/tokenjuice/dist/hosts/ona/index.js +596 -0
- package/node_modules/tokenjuice/dist/hosts/open-interpreter/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/open-interpreter/index.js +348 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/extension.d.ts +8 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/extension.js +104 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/index.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/openclaw/index.js +1 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.d.ts +17 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.js +9094 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/index.d.ts +21 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/index.js +163 -0
- package/node_modules/tokenjuice/dist/hosts/openhands/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/openhands/index.js +211 -0
- package/node_modules/tokenjuice/dist/hosts/openwebui/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/openwebui/index.js +245 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/pi-types.d.ts +79 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/pi-types.js +3 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.d.ts +5 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.js +9372 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/settings.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/settings.js +26 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status-panel.d.ts +3 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status-panel.js +72 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status.d.ts +20 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status.js +58 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/tool-result.d.ts +4 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/tool-result.js +24 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/utils.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/pi/extension/utils.js +6 -0
- package/node_modules/tokenjuice/dist/hosts/pi/index.d.ts +26 -0
- package/node_modules/tokenjuice/dist/hosts/pi/index.js +228 -0
- package/node_modules/tokenjuice/dist/hosts/pi-go/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/pi-go/index.js +352 -0
- package/node_modules/tokenjuice/dist/hosts/plandex/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/plandex/index.js +164 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/qodo/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/qodo/index.js +584 -0
- package/node_modules/tokenjuice/dist/hosts/qwen-code/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/qwen-code/index.js +276 -0
- package/node_modules/tokenjuice/dist/hosts/replit/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/replit/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/roo/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/roo/index.js +101 -0
- package/node_modules/tokenjuice/dist/hosts/rovo/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/rovo/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/ruler/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/ruler/index.js +157 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.d.ts +19 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.js +32 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.d.ts +5 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.js +94 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.d.ts +212 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.js +270 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-output.d.ts +4 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-output.js +15 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hooks-json-file.d.ts +18 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hooks-json-file.js +108 -0
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.d.ts +10 -0
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.js +70 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-doctor.d.ts +16 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-doctor.js +13 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-file.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-file.js +121 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-guidance.d.ts +7 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-guidance.js +12 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instructions.d.ts +32 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instructions.js +100 -0
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.d.ts +91 -0
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.js +186 -0
- package/node_modules/tokenjuice/dist/hosts/shared/tool-result.d.ts +15 -0
- package/node_modules/tokenjuice/dist/hosts/shared/tool-result.js +52 -0
- package/node_modules/tokenjuice/dist/hosts/stagewise/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/stagewise/index.js +468 -0
- package/node_modules/tokenjuice/dist/hosts/swe-agent/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/swe-agent/index.js +223 -0
- package/node_modules/tokenjuice/dist/hosts/tabby/index.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/tabby/index.js +469 -0
- package/node_modules/tokenjuice/dist/hosts/tabnine/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/tabnine/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/trae/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/trae/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/uipath/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/uipath/index.js +155 -0
- package/node_modules/tokenjuice/dist/hosts/vscode-copilot/index.d.ts +32 -0
- package/node_modules/tokenjuice/dist/hosts/vscode-copilot/index.js +416 -0
- package/node_modules/tokenjuice/dist/hosts/warp/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/warp/index.js +181 -0
- package/node_modules/tokenjuice/dist/hosts/windsurf/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/windsurf/index.js +99 -0
- package/node_modules/tokenjuice/dist/hosts/zed/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/zed/index.js +68 -0
- package/node_modules/tokenjuice/dist/hosts/zencoder/index.d.ts +23 -0
- package/node_modules/tokenjuice/dist/hosts/zencoder/index.js +227 -0
- package/node_modules/tokenjuice/dist/index.d.ts +214 -0
- package/node_modules/tokenjuice/dist/index.js +113 -0
- package/node_modules/tokenjuice/dist/rules/archive/tar.json +30 -0
- package/node_modules/tokenjuice/dist/rules/archive/unzip.json +30 -0
- package/node_modules/tokenjuice/dist/rules/archive/zip.json +30 -0
- package/node_modules/tokenjuice/dist/rules/build/cmake.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/dotnet.json +36 -0
- package/node_modules/tokenjuice/dist/rules/build/esbuild.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/go-build.json +31 -0
- package/node_modules/tokenjuice/dist/rules/build/gradle.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/maven.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/msbuild.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/pnpm-build.json +44 -0
- package/node_modules/tokenjuice/dist/rules/build/swift-build.json +56 -0
- package/node_modules/tokenjuice/dist/rules/build/tsc.json +74 -0
- package/node_modules/tokenjuice/dist/rules/build/tsdown.json +35 -0
- package/node_modules/tokenjuice/dist/rules/build/vite.json +42 -0
- package/node_modules/tokenjuice/dist/rules/build/webpack.json +51 -0
- package/node_modules/tokenjuice/dist/rules/build/xcodebuild.json +80 -0
- package/node_modules/tokenjuice/dist/rules/cloud/aws.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/az.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/flyctl.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/gcloud.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/gh.json +30 -0
- package/node_modules/tokenjuice/dist/rules/cloud/vercel.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/mongosh.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/mysql.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/psql.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/redis-cli.json +30 -0
- package/node_modules/tokenjuice/dist/rules/database/sqlite3.json +30 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-build.json +53 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-compose.json +44 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-images.json +30 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-logs.json +43 -0
- package/node_modules/tokenjuice/dist/rules/devops/docker-ps.json +30 -0
- package/node_modules/tokenjuice/dist/rules/devops/helm.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/kubectl-describe.json +45 -0
- package/node_modules/tokenjuice/dist/rules/devops/kubectl-get.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/kubectl-logs.json +43 -0
- package/node_modules/tokenjuice/dist/rules/devops/pulumi.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/terraform.json +35 -0
- package/node_modules/tokenjuice/dist/rules/devops/terragrunt.json +35 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/fd.json +33 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/find.json +42 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/git-ls-files.json +35 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/ls.json +29 -0
- package/node_modules/tokenjuice/dist/rules/filesystem/rg-files.json +34 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/archive/tar.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/archive/unzip.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/archive/zip.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/cmake.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/dotnet.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/esbuild.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/go-build.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/gradle.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/maven.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/msbuild.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/pnpm-build-failure.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/pnpm-build.fixture.json +18 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/swift-build.fixture.json +29 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/tsc.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/tsdown.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/vite.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/webpack.fixture.json +20 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/build/xcodebuild.fixture.json +27 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/aws.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/az.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/flyctl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/gcloud.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/gh.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/cloud/vercel.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/mongosh.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/mysql.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/psql.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/redis-cli.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/database/sqlite3.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-build.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-compose.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-images.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-logs.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/docker-ps.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/helm.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/kubectl-describe.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/kubectl-get.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/kubectl-logs.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/pulumi.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/terraform.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/devops/terragrunt.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/fd.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/find.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/git-ls-files.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/ls.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/filesystem/rg-files.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/generic/fallback.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/generic/help.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/branch.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/diff-name-only.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/diff-stat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/diff.fixture.json +26 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/log-oneline.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/remote-v.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/show.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/stash-list.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/status.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/git/worktree-list.fixture.json +17 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/bun-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/bun-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-ci-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-ci.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/npm-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/pnpm-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/pnpm-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/yarn-install-up-to-date.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/install/yarn-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/biome.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/eslint.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/oxlint.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/lint/prettier-check.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/media/ffmpeg.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/media/mediainfo.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/curl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/dig.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/nslookup.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/ping.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/ssh.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/traceroute.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/network/wget.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/free.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/htop.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/iostat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/top.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/observability/vmstat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/openclaw/sessions-history.fixture.json +33 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/apt-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/apt-upgrade.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/brew-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/brew-upgrade.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/composer.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/dnf-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/fnm.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/npm-ls.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/package/yum-install.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/search/git-grep.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/search/grep.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/search/rg.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/journalctl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/launchctl.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/lsof.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/netstat.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/pm2.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/service.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/ss.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/service/systemctl-status.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/df.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/du.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/file.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/system/ps.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/env.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/just.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/make.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/mise.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/node.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/php.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/python.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/ruby.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/task/uv.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/bun-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/cargo-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/go-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/jest.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/mocha.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/npm-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/playwright.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/pnpm-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/pytest.fixture.json +19 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/rspec.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/swift-test.fixture.json +30 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/vitest.fixture.json +15 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/tests/yarn-test.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/text/wc.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/transfer/rsync.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/fixtures/transfer/scp.fixture.json +16 -0
- package/node_modules/tokenjuice/dist/rules/generic/fallback.json +32 -0
- package/node_modules/tokenjuice/dist/rules/generic/help.json +25 -0
- package/node_modules/tokenjuice/dist/rules/git/branch.json +29 -0
- package/node_modules/tokenjuice/dist/rules/git/diff-name-only.json +29 -0
- package/node_modules/tokenjuice/dist/rules/git/diff-stat.json +37 -0
- package/node_modules/tokenjuice/dist/rules/git/diff.json +65 -0
- package/node_modules/tokenjuice/dist/rules/git/log-oneline.json +30 -0
- package/node_modules/tokenjuice/dist/rules/git/remote-v.json +29 -0
- package/node_modules/tokenjuice/dist/rules/git/show.json +50 -0
- package/node_modules/tokenjuice/dist/rules/git/stash-list.json +30 -0
- package/node_modules/tokenjuice/dist/rules/git/status.json +54 -0
- package/node_modules/tokenjuice/dist/rules/git/worktree-list.json +31 -0
- package/node_modules/tokenjuice/dist/rules/install/bun-install.json +43 -0
- package/node_modules/tokenjuice/dist/rules/install/npm-ci.json +49 -0
- package/node_modules/tokenjuice/dist/rules/install/npm-install.json +49 -0
- package/node_modules/tokenjuice/dist/rules/install/pnpm-install.json +43 -0
- package/node_modules/tokenjuice/dist/rules/install/yarn-install.json +42 -0
- package/node_modules/tokenjuice/dist/rules/lint/biome.json +35 -0
- package/node_modules/tokenjuice/dist/rules/lint/eslint.json +45 -0
- package/node_modules/tokenjuice/dist/rules/lint/oxlint.json +35 -0
- package/node_modules/tokenjuice/dist/rules/lint/prettier-check.json +34 -0
- package/node_modules/tokenjuice/dist/rules/media/ffmpeg.json +30 -0
- package/node_modules/tokenjuice/dist/rules/media/mediainfo.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/curl.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/dig.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/nslookup.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/ping.json +35 -0
- package/node_modules/tokenjuice/dist/rules/network/ssh.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/traceroute.json +30 -0
- package/node_modules/tokenjuice/dist/rules/network/wget.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/free.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/htop.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/iostat.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/top.json +30 -0
- package/node_modules/tokenjuice/dist/rules/observability/vmstat.json +30 -0
- package/node_modules/tokenjuice/dist/rules/openclaw/sessions-history.json +59 -0
- package/node_modules/tokenjuice/dist/rules/package/apt-install.json +36 -0
- package/node_modules/tokenjuice/dist/rules/package/apt-upgrade.json +36 -0
- package/node_modules/tokenjuice/dist/rules/package/brew-install.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/brew-upgrade.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/composer.json +35 -0
- package/node_modules/tokenjuice/dist/rules/package/dnf-install.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/fnm.json +35 -0
- package/node_modules/tokenjuice/dist/rules/package/npm-ls.json +31 -0
- package/node_modules/tokenjuice/dist/rules/package/yum-install.json +31 -0
- package/node_modules/tokenjuice/dist/rules/search/git-grep.json +30 -0
- package/node_modules/tokenjuice/dist/rules/search/grep.json +38 -0
- package/node_modules/tokenjuice/dist/rules/search/rg.json +38 -0
- package/node_modules/tokenjuice/dist/rules/service/journalctl.json +42 -0
- package/node_modules/tokenjuice/dist/rules/service/launchctl.json +41 -0
- package/node_modules/tokenjuice/dist/rules/service/lsof.json +29 -0
- package/node_modules/tokenjuice/dist/rules/service/netstat.json +29 -0
- package/node_modules/tokenjuice/dist/rules/service/pm2.json +35 -0
- package/node_modules/tokenjuice/dist/rules/service/service.json +46 -0
- package/node_modules/tokenjuice/dist/rules/service/ss.json +29 -0
- package/node_modules/tokenjuice/dist/rules/service/systemctl-status.json +45 -0
- package/node_modules/tokenjuice/dist/rules/system/df.json +29 -0
- package/node_modules/tokenjuice/dist/rules/system/du.json +29 -0
- package/node_modules/tokenjuice/dist/rules/system/file.json +30 -0
- package/node_modules/tokenjuice/dist/rules/system/ps.json +29 -0
- package/node_modules/tokenjuice/dist/rules/task/env.json +31 -0
- package/node_modules/tokenjuice/dist/rules/task/just.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/make.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/mise.json +35 -0
- package/node_modules/tokenjuice/dist/rules/task/node.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/php.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/python.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/ruby.json +30 -0
- package/node_modules/tokenjuice/dist/rules/task/uv.json +35 -0
- package/node_modules/tokenjuice/dist/rules/tests/bun-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/cargo-test.json +41 -0
- package/node_modules/tokenjuice/dist/rules/tests/go-test.json +49 -0
- package/node_modules/tokenjuice/dist/rules/tests/jest.json +41 -0
- package/node_modules/tokenjuice/dist/rules/tests/mocha.json +35 -0
- package/node_modules/tokenjuice/dist/rules/tests/npm-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/playwright.json +37 -0
- package/node_modules/tokenjuice/dist/rules/tests/pnpm-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/pytest.json +54 -0
- package/node_modules/tokenjuice/dist/rules/tests/rspec.json +31 -0
- package/node_modules/tokenjuice/dist/rules/tests/swift-test.json +66 -0
- package/node_modules/tokenjuice/dist/rules/tests/vitest.json +56 -0
- package/node_modules/tokenjuice/dist/rules/tests/yarn-test.json +56 -0
- package/node_modules/tokenjuice/dist/rules/text/wc.json +35 -0
- package/node_modules/tokenjuice/dist/rules/tokenjuice-rule.schema.json +155 -0
- package/node_modules/tokenjuice/dist/rules/transfer/rsync.json +30 -0
- package/node_modules/tokenjuice/dist/rules/transfer/scp.json +30 -0
- package/node_modules/tokenjuice/dist/types.d.ts +212 -0
- package/node_modules/tokenjuice/dist/types.js +1 -0
- package/node_modules/tokenjuice/package.json +80 -0
- package/npm-shrinkwrap.json +39 -0
- package/openclaw.plugin.json +16 -0
- package/package.json +55 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { mkdir, rename, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { buildTokenjuiceGuidanceBullets, TOKENJUICE_FULL_COMMAND, TOKENJUICE_RAW_COMMAND, TOKENJUICE_WRAP_COMMAND } from "../shared/instruction-guidance.js";
|
|
4
|
+
import { collectGuidanceIssues, readInstructionFile, removeInstructionFile, writeInstructionFile } from "../shared/instruction-file.js";
|
|
5
|
+
import { buildInstructionDoctorReportFields, instructionDoctorStatusFromIssues, } from "../shared/instruction-doctor.js";
|
|
6
|
+
const TOKENJUICE_KILO_FIX_COMMAND = "tokenjuice install kilo";
|
|
7
|
+
const TOKENJUICE_KILO_RULE_MARKER = "tokenjuice terminal output compaction";
|
|
8
|
+
const TOKENJUICE_KILO_ADVISORY = "Kilo Code support is beta and rule-based; it guides command usage but does not intercept tool output.";
|
|
9
|
+
const TOKENJUICE_KILO_INSTRUCTION_REF = ".kilo/rules/tokenjuice.md";
|
|
10
|
+
function getProjectDir(options = {}) {
|
|
11
|
+
return options.projectDir || process.env.KILO_PROJECT_DIR || process.cwd();
|
|
12
|
+
}
|
|
13
|
+
function getDefaultRulePath(options = {}) {
|
|
14
|
+
return join(getProjectDir(options), TOKENJUICE_KILO_INSTRUCTION_REF);
|
|
15
|
+
}
|
|
16
|
+
function getRootConfigPath(options = {}) {
|
|
17
|
+
return join(getProjectDir(options), "kilo.jsonc");
|
|
18
|
+
}
|
|
19
|
+
function getDotConfigPath(options = {}) {
|
|
20
|
+
return join(getProjectDir(options), ".kilo", "kilo.jsonc");
|
|
21
|
+
}
|
|
22
|
+
async function getDefaultConfigPath(options = {}) {
|
|
23
|
+
const dotConfigPath = getDotConfigPath(options);
|
|
24
|
+
if ((await readInstructionFile(dotConfigPath)).exists) {
|
|
25
|
+
return dotConfigPath;
|
|
26
|
+
}
|
|
27
|
+
return getRootConfigPath(options);
|
|
28
|
+
}
|
|
29
|
+
function getProjectConfigPaths(options = {}) {
|
|
30
|
+
return [getDotConfigPath(options), getRootConfigPath(options)];
|
|
31
|
+
}
|
|
32
|
+
function getInstructionRefForRule(rulePath, options = {}) {
|
|
33
|
+
const projectDir = resolve(getProjectDir(options));
|
|
34
|
+
const resolvedRulePath = resolve(rulePath);
|
|
35
|
+
const instructionRef = relative(projectDir, resolvedRulePath);
|
|
36
|
+
if (!instructionRef || instructionRef.startsWith("..") || isAbsolute(instructionRef)) {
|
|
37
|
+
throw new Error("Kilo Code rule path must be inside the project directory");
|
|
38
|
+
}
|
|
39
|
+
return instructionRef.split(sep).join("/");
|
|
40
|
+
}
|
|
41
|
+
const TOKENJUICE_KILO_RULE = [
|
|
42
|
+
"# tokenjuice terminal output compaction",
|
|
43
|
+
"",
|
|
44
|
+
...buildTokenjuiceGuidanceBullets({
|
|
45
|
+
wrapBullet: `- When running terminal commands through Kilo Code, prefer \`${TOKENJUICE_WRAP_COMMAND}\` for commands likely to produce long output.`,
|
|
46
|
+
}),
|
|
47
|
+
"",
|
|
48
|
+
].join("\n");
|
|
49
|
+
function skipWhitespaceAndComments(text, index) {
|
|
50
|
+
let cursor = index;
|
|
51
|
+
while (cursor < text.length) {
|
|
52
|
+
const char = text[cursor];
|
|
53
|
+
const next = text[cursor + 1];
|
|
54
|
+
if (/\s/u.test(char ?? "")) {
|
|
55
|
+
cursor += 1;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (char === "/" && next === "/") {
|
|
59
|
+
const lineEnd = text.indexOf("\n", cursor + 2);
|
|
60
|
+
cursor = lineEnd === -1 ? text.length : lineEnd + 1;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (char === "/" && next === "*") {
|
|
64
|
+
const blockEnd = text.indexOf("*/", cursor + 2);
|
|
65
|
+
cursor = blockEnd === -1 ? text.length : blockEnd + 2;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return cursor;
|
|
71
|
+
}
|
|
72
|
+
function readJsonString(text, start) {
|
|
73
|
+
if (text[start] !== "\"") {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
let cursor = start + 1;
|
|
77
|
+
while (cursor < text.length) {
|
|
78
|
+
const char = text[cursor];
|
|
79
|
+
if (char === "\\") {
|
|
80
|
+
cursor += 2;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (char === "\"") {
|
|
84
|
+
const raw = text.slice(start, cursor + 1);
|
|
85
|
+
try {
|
|
86
|
+
return { end: cursor, value: JSON.parse(raw) };
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
cursor += 1;
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function findMatchingDelimiter(text, openIndex, openChar, closeChar) {
|
|
97
|
+
let depth = 0;
|
|
98
|
+
let cursor = openIndex;
|
|
99
|
+
while (cursor < text.length) {
|
|
100
|
+
cursor = skipWhitespaceAndComments(text, cursor);
|
|
101
|
+
const stringValue = readJsonString(text, cursor);
|
|
102
|
+
if (stringValue) {
|
|
103
|
+
cursor = stringValue.end + 1;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const char = text[cursor];
|
|
107
|
+
if (char === openChar) {
|
|
108
|
+
depth += 1;
|
|
109
|
+
}
|
|
110
|
+
else if (char === closeChar) {
|
|
111
|
+
depth -= 1;
|
|
112
|
+
if (depth === 0) {
|
|
113
|
+
return cursor;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
cursor += 1;
|
|
117
|
+
}
|
|
118
|
+
return -1;
|
|
119
|
+
}
|
|
120
|
+
function skipJsonValue(text, index, limit) {
|
|
121
|
+
let cursor = skipWhitespaceAndComments(text, index);
|
|
122
|
+
const stringValue = readJsonString(text, cursor);
|
|
123
|
+
if (stringValue) {
|
|
124
|
+
return stringValue.end + 1;
|
|
125
|
+
}
|
|
126
|
+
if (text[cursor] === "{") {
|
|
127
|
+
const objectEnd = findMatchingDelimiter(text, cursor, "{", "}");
|
|
128
|
+
return objectEnd === -1 ? limit : objectEnd + 1;
|
|
129
|
+
}
|
|
130
|
+
if (text[cursor] === "[") {
|
|
131
|
+
const arrayEnd = findMatchingDelimiter(text, cursor, "[", "]");
|
|
132
|
+
return arrayEnd === -1 ? limit : arrayEnd + 1;
|
|
133
|
+
}
|
|
134
|
+
while (cursor < limit) {
|
|
135
|
+
cursor = skipWhitespaceAndComments(text, cursor);
|
|
136
|
+
const nestedString = readJsonString(text, cursor);
|
|
137
|
+
if (nestedString) {
|
|
138
|
+
cursor = nestedString.end + 1;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (text[cursor] === ",") {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
cursor += 1;
|
|
145
|
+
}
|
|
146
|
+
return cursor;
|
|
147
|
+
}
|
|
148
|
+
function findLastSignificantChar(text, start, end) {
|
|
149
|
+
let cursor = start;
|
|
150
|
+
let last;
|
|
151
|
+
while (cursor < end) {
|
|
152
|
+
cursor = skipWhitespaceAndComments(text, cursor);
|
|
153
|
+
if (cursor >= end) {
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
const stringValue = readJsonString(text, cursor);
|
|
157
|
+
if (stringValue) {
|
|
158
|
+
last = "\"";
|
|
159
|
+
cursor = stringValue.end + 1;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
last = text[cursor];
|
|
163
|
+
cursor += 1;
|
|
164
|
+
}
|
|
165
|
+
return last;
|
|
166
|
+
}
|
|
167
|
+
function findInstructionsArray(text) {
|
|
168
|
+
const rootStart = skipWhitespaceAndComments(text, 0);
|
|
169
|
+
if (text[rootStart] !== "{") {
|
|
170
|
+
return { kind: "missing" };
|
|
171
|
+
}
|
|
172
|
+
const rootEnd = findMatchingDelimiter(text, rootStart, "{", "}");
|
|
173
|
+
if (rootEnd === -1) {
|
|
174
|
+
return { kind: "invalid", message: "kilo.jsonc object is not closed" };
|
|
175
|
+
}
|
|
176
|
+
let cursor = rootStart + 1;
|
|
177
|
+
while (cursor < rootEnd) {
|
|
178
|
+
cursor = skipWhitespaceAndComments(text, cursor);
|
|
179
|
+
if (text[cursor] === ",") {
|
|
180
|
+
cursor += 1;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const key = readJsonString(text, cursor);
|
|
184
|
+
if (!key) {
|
|
185
|
+
cursor += 1;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
cursor = key.end + 1;
|
|
189
|
+
cursor = skipWhitespaceAndComments(text, cursor);
|
|
190
|
+
if (text[cursor] !== ":") {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
cursor = skipWhitespaceAndComments(text, cursor + 1);
|
|
194
|
+
if (key.value !== "instructions") {
|
|
195
|
+
cursor = skipJsonValue(text, cursor, rootEnd);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (text[cursor] !== "[") {
|
|
199
|
+
return { kind: "invalid", message: "kilo.jsonc instructions must be an array" };
|
|
200
|
+
}
|
|
201
|
+
const arrayEnd = findMatchingDelimiter(text, cursor, "[", "]");
|
|
202
|
+
if (arrayEnd === -1) {
|
|
203
|
+
return { kind: "invalid", message: "kilo.jsonc instructions array is not closed" };
|
|
204
|
+
}
|
|
205
|
+
return { kind: "array", arrayStart: cursor, arrayEnd };
|
|
206
|
+
}
|
|
207
|
+
return { kind: "missing" };
|
|
208
|
+
}
|
|
209
|
+
function getLineIndent(text, index) {
|
|
210
|
+
const lineStart = text.lastIndexOf("\n", index - 1) + 1;
|
|
211
|
+
return text.slice(lineStart, index).match(/^\s*/u)?.[0] ?? "";
|
|
212
|
+
}
|
|
213
|
+
function hasKiloInstructionRef(text, location, instructionRef) {
|
|
214
|
+
if (location.kind !== "array") {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
let cursor = location.arrayStart + 1;
|
|
218
|
+
while (cursor < location.arrayEnd) {
|
|
219
|
+
cursor = skipWhitespaceAndComments(text, cursor);
|
|
220
|
+
if (text[cursor] === ",") {
|
|
221
|
+
cursor += 1;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
const entry = readJsonString(text, cursor);
|
|
225
|
+
if (entry?.value === instructionRef) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
cursor = entry ? entry.end + 1 : skipJsonValue(text, cursor, location.arrayEnd);
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
function hasAnyInstructionsValue(text, location) {
|
|
233
|
+
if (location.kind !== "array") {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
return findLastSignificantChar(text, location.arrayStart + 1, location.arrayEnd) !== undefined;
|
|
237
|
+
}
|
|
238
|
+
function ensureKiloConfigInstruction(text, instructionRef) {
|
|
239
|
+
const encodedInstructionRef = JSON.stringify(instructionRef);
|
|
240
|
+
const trimmed = text.trim();
|
|
241
|
+
if (!trimmed) {
|
|
242
|
+
return {
|
|
243
|
+
text: `{\n "instructions": [\n ${encodedInstructionRef}\n ]\n}\n`,
|
|
244
|
+
updated: true,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const location = findInstructionsArray(text);
|
|
248
|
+
if (location.kind === "invalid") {
|
|
249
|
+
throw new Error(location.message);
|
|
250
|
+
}
|
|
251
|
+
if (hasKiloInstructionRef(text, location, instructionRef)) {
|
|
252
|
+
return { text, updated: false };
|
|
253
|
+
}
|
|
254
|
+
if (location.kind === "array") {
|
|
255
|
+
const closeIndent = getLineIndent(text, location.arrayEnd);
|
|
256
|
+
const itemIndent = `${closeIndent} `;
|
|
257
|
+
const separator = findLastSignificantChar(text, location.arrayStart + 1, location.arrayEnd) === "," ? "" : ",";
|
|
258
|
+
const insertion = hasAnyInstructionsValue(text, location)
|
|
259
|
+
? `${separator}\n${itemIndent}${encodedInstructionRef}\n${closeIndent}`
|
|
260
|
+
: `\n${itemIndent}${encodedInstructionRef}\n${closeIndent}`;
|
|
261
|
+
return {
|
|
262
|
+
text: `${text.slice(0, location.arrayEnd)}${insertion}${text.slice(location.arrayEnd)}`,
|
|
263
|
+
updated: true,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const rootStart = skipWhitespaceAndComments(text, 0);
|
|
267
|
+
if (text[rootStart] !== "{") {
|
|
268
|
+
throw new Error("kilo.jsonc must be a JSON object");
|
|
269
|
+
}
|
|
270
|
+
const rootEnd = findMatchingDelimiter(text, rootStart, "{", "}");
|
|
271
|
+
if (rootEnd === -1) {
|
|
272
|
+
throw new Error("kilo.jsonc object is not closed");
|
|
273
|
+
}
|
|
274
|
+
const closeIndent = getLineIndent(text, rootEnd);
|
|
275
|
+
const propIndent = `${closeIndent} `;
|
|
276
|
+
const property = `"instructions": [\n${propIndent} ${encodedInstructionRef}\n${propIndent}]`;
|
|
277
|
+
const body = text.slice(rootStart + 1, rootEnd);
|
|
278
|
+
const existingBody = body.startsWith("\n") ? body : `\n${propIndent}${body.trimStart()}`;
|
|
279
|
+
const insertion = body.trim()
|
|
280
|
+
? `\n${propIndent}${property},${existingBody}`
|
|
281
|
+
: `\n${propIndent}${property}\n${closeIndent}`;
|
|
282
|
+
return {
|
|
283
|
+
text: `${text.slice(0, rootStart + 1)}${insertion}${text.slice(rootEnd)}`,
|
|
284
|
+
updated: true,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function removeKiloConfigInstruction(text, instructionRef) {
|
|
288
|
+
let updatedText = text;
|
|
289
|
+
let updated = false;
|
|
290
|
+
while (true) {
|
|
291
|
+
const location = findInstructionsArray(updatedText);
|
|
292
|
+
if (location.kind !== "array") {
|
|
293
|
+
return { text: updatedText, updated };
|
|
294
|
+
}
|
|
295
|
+
let cursor = location.arrayStart + 1;
|
|
296
|
+
let removed = false;
|
|
297
|
+
while (cursor < location.arrayEnd) {
|
|
298
|
+
cursor = skipWhitespaceAndComments(updatedText, cursor);
|
|
299
|
+
if (updatedText[cursor] === ",") {
|
|
300
|
+
cursor += 1;
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
const entry = readJsonString(updatedText, cursor);
|
|
304
|
+
if (!entry) {
|
|
305
|
+
cursor = skipJsonValue(updatedText, cursor, location.arrayEnd);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (entry.value !== instructionRef) {
|
|
309
|
+
cursor = entry.end + 1;
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
let removeStart = cursor;
|
|
313
|
+
let removeEnd = entry.end + 1;
|
|
314
|
+
let previous = cursor - 1;
|
|
315
|
+
while (previous > location.arrayStart && /\s/u.test(updatedText[previous] ?? "")) {
|
|
316
|
+
previous -= 1;
|
|
317
|
+
}
|
|
318
|
+
const next = skipWhitespaceAndComments(updatedText, entry.end + 1);
|
|
319
|
+
if (updatedText[previous] === ",") {
|
|
320
|
+
removeStart = previous;
|
|
321
|
+
}
|
|
322
|
+
else if (updatedText[next] === ",") {
|
|
323
|
+
removeEnd = next + 1;
|
|
324
|
+
}
|
|
325
|
+
updatedText = `${updatedText.slice(0, removeStart)}${updatedText.slice(removeEnd)}`.replace(/\n{3,}/gu, "\n\n");
|
|
326
|
+
updated = true;
|
|
327
|
+
removed = true;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
if (!removed) {
|
|
331
|
+
return { text: updatedText, updated };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
async function writeTextFileWithBackup(filePath, text) {
|
|
336
|
+
const existing = await readInstructionFile(filePath);
|
|
337
|
+
let backupPath;
|
|
338
|
+
if (existing.exists) {
|
|
339
|
+
backupPath = `${filePath}.bak`;
|
|
340
|
+
await writeFile(backupPath, existing.text, "utf8");
|
|
341
|
+
}
|
|
342
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
343
|
+
const tempPath = `${filePath}.tmp`;
|
|
344
|
+
await writeFile(tempPath, text, "utf8");
|
|
345
|
+
await rename(tempPath, filePath);
|
|
346
|
+
return backupPath ? { backupPath } : {};
|
|
347
|
+
}
|
|
348
|
+
async function ensureKiloConfig(configPath, instructionRef) {
|
|
349
|
+
const existing = await readInstructionFile(configPath);
|
|
350
|
+
const updated = ensureKiloConfigInstruction(existing.text, instructionRef);
|
|
351
|
+
if (!updated.updated) {
|
|
352
|
+
return { configPath, updated: false };
|
|
353
|
+
}
|
|
354
|
+
const written = await writeTextFileWithBackup(configPath, updated.text);
|
|
355
|
+
return {
|
|
356
|
+
configPath,
|
|
357
|
+
updated: true,
|
|
358
|
+
...(written.backupPath ? { backupPath: written.backupPath } : {}),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
async function removeKiloConfigRef(configPath, instructionRef) {
|
|
362
|
+
const existing = await readInstructionFile(configPath);
|
|
363
|
+
if (!existing.exists) {
|
|
364
|
+
return { configPath, updated: false };
|
|
365
|
+
}
|
|
366
|
+
const updated = removeKiloConfigInstruction(existing.text, instructionRef);
|
|
367
|
+
if (!updated.updated) {
|
|
368
|
+
return { configPath, updated: false };
|
|
369
|
+
}
|
|
370
|
+
const written = await writeTextFileWithBackup(configPath, updated.text);
|
|
371
|
+
return {
|
|
372
|
+
configPath,
|
|
373
|
+
updated: true,
|
|
374
|
+
...(written.backupPath ? { backupPath: written.backupPath } : {}),
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
export async function installKiloRule(rulePath, options = {}) {
|
|
378
|
+
const resolvedRulePath = rulePath ?? getDefaultRulePath(options);
|
|
379
|
+
const resolvedConfigPath = await getDefaultConfigPath(options);
|
|
380
|
+
const instructionRef = getInstructionRefForRule(resolvedRulePath, options);
|
|
381
|
+
const previousRule = await readInstructionFile(resolvedRulePath);
|
|
382
|
+
const result = await writeInstructionFile(resolvedRulePath, TOKENJUICE_KILO_RULE);
|
|
383
|
+
let configResult;
|
|
384
|
+
try {
|
|
385
|
+
configResult = await ensureKiloConfig(resolvedConfigPath, instructionRef);
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
if (previousRule.exists) {
|
|
389
|
+
await mkdir(dirname(resolvedRulePath), { recursive: true });
|
|
390
|
+
await writeFile(resolvedRulePath, previousRule.text, "utf8");
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
await rm(resolvedRulePath, { force: true });
|
|
394
|
+
}
|
|
395
|
+
throw error;
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
rulePath: result.filePath,
|
|
399
|
+
configPath: configResult.configPath,
|
|
400
|
+
...(result.backupPath ? { backupPath: result.backupPath } : {}),
|
|
401
|
+
...(configResult.backupPath ? { configBackupPath: configResult.backupPath } : {}),
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
export async function uninstallKiloRule(rulePath, options = {}) {
|
|
405
|
+
const resolvedRulePath = rulePath ?? getDefaultRulePath(options);
|
|
406
|
+
const resolvedConfigPath = await getDefaultConfigPath(options);
|
|
407
|
+
const instructionRef = getInstructionRefForRule(resolvedRulePath, options);
|
|
408
|
+
const existing = await readInstructionFile(resolvedRulePath);
|
|
409
|
+
if (existing.exists && !existing.text.includes(TOKENJUICE_KILO_RULE_MARKER)) {
|
|
410
|
+
return {
|
|
411
|
+
rulePath: resolvedRulePath,
|
|
412
|
+
configPath: resolvedConfigPath,
|
|
413
|
+
removed: false,
|
|
414
|
+
configUpdated: false,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
const result = existing.exists
|
|
418
|
+
? await removeInstructionFile(resolvedRulePath)
|
|
419
|
+
: { filePath: resolvedRulePath, removed: false };
|
|
420
|
+
const configResults = await Promise.all(getProjectConfigPaths(options).map((configPath) => removeKiloConfigRef(configPath, instructionRef)));
|
|
421
|
+
const configUpdated = configResults.some((configResult) => configResult.updated);
|
|
422
|
+
const configBackupPaths = configResults.flatMap((configResult) => configResult.backupPath ? [configResult.backupPath] : []);
|
|
423
|
+
const configBackupPath = configResults.find((configResult) => configResult.configPath === resolvedConfigPath)?.backupPath ?? configBackupPaths[0];
|
|
424
|
+
return {
|
|
425
|
+
rulePath: result.filePath,
|
|
426
|
+
configPath: resolvedConfigPath,
|
|
427
|
+
removed: result.removed,
|
|
428
|
+
configUpdated,
|
|
429
|
+
...(configBackupPath ? { configBackupPath } : {}),
|
|
430
|
+
...(configBackupPaths.length > 0 ? { configBackupPaths } : {}),
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
export async function doctorKiloRule(rulePath, options = {}) {
|
|
434
|
+
const resolvedRulePath = rulePath ?? getDefaultRulePath(options);
|
|
435
|
+
const resolvedConfigPath = await getDefaultConfigPath(options);
|
|
436
|
+
const instructionRef = getInstructionRefForRule(resolvedRulePath, options);
|
|
437
|
+
const existing = await readInstructionFile(resolvedRulePath);
|
|
438
|
+
const config = await readInstructionFile(resolvedConfigPath);
|
|
439
|
+
const configLocation = config.exists ? findInstructionsArray(config.text) : { kind: "missing" };
|
|
440
|
+
const configHasInstruction = config.exists && hasKiloInstructionRef(config.text, configLocation, instructionRef);
|
|
441
|
+
if (!existing.exists) {
|
|
442
|
+
const staleIssues = configHasInstruction
|
|
443
|
+
? ["kilo.jsonc references the tokenjuice Kilo Code rule, but the rule file is missing"]
|
|
444
|
+
: [];
|
|
445
|
+
return {
|
|
446
|
+
rulePath: resolvedRulePath,
|
|
447
|
+
configPath: resolvedConfigPath,
|
|
448
|
+
...buildInstructionDoctorReportFields({
|
|
449
|
+
status: staleIssues.length > 0 ? "broken" : "disabled",
|
|
450
|
+
issues: staleIssues.length > 0 ? staleIssues : ["tokenjuice Kilo Code rule is not installed"],
|
|
451
|
+
advisory: TOKENJUICE_KILO_ADVISORY,
|
|
452
|
+
fixCommand: TOKENJUICE_KILO_FIX_COMMAND,
|
|
453
|
+
}),
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
const issues = collectGuidanceIssues(existing.text, {
|
|
457
|
+
required: [
|
|
458
|
+
{
|
|
459
|
+
requiredText: TOKENJUICE_KILO_RULE_MARKER,
|
|
460
|
+
missingIssue: "configured Kilo Code rule file does not look like the tokenjuice rule",
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
requiredText: TOKENJUICE_WRAP_COMMAND,
|
|
464
|
+
missingIssue: "configured Kilo Code rule file is missing tokenjuice wrap guidance",
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
requiredText: TOKENJUICE_RAW_COMMAND,
|
|
468
|
+
missingIssue: "configured Kilo Code rule file is missing the raw escape hatch",
|
|
469
|
+
},
|
|
470
|
+
],
|
|
471
|
+
forbidden: [
|
|
472
|
+
{
|
|
473
|
+
forbiddenText: TOKENJUICE_FULL_COMMAND,
|
|
474
|
+
presentIssue: "configured Kilo Code rule file still suggests the full escape hatch",
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
});
|
|
478
|
+
if (!config.exists) {
|
|
479
|
+
issues.push("kilo.jsonc is missing the tokenjuice instructions entry");
|
|
480
|
+
}
|
|
481
|
+
else if (configLocation.kind === "invalid") {
|
|
482
|
+
issues.push(configLocation.message);
|
|
483
|
+
}
|
|
484
|
+
else if (!configHasInstruction) {
|
|
485
|
+
issues.push(`kilo.jsonc instructions does not reference ${instructionRef}`);
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
rulePath: resolvedRulePath,
|
|
489
|
+
configPath: resolvedConfigPath,
|
|
490
|
+
...buildInstructionDoctorReportFields({
|
|
491
|
+
status: instructionDoctorStatusFromIssues(issues),
|
|
492
|
+
issues,
|
|
493
|
+
advisory: TOKENJUICE_KILO_ADVISORY,
|
|
494
|
+
fixCommand: TOKENJUICE_KILO_FIX_COMMAND,
|
|
495
|
+
}),
|
|
496
|
+
};
|
|
497
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type TokenjuiceHookCommandOptions } from "../shared/host-command.js";
|
|
2
|
+
export type KimiHookCommandOptions = TokenjuiceHookCommandOptions & {
|
|
3
|
+
configDir?: string;
|
|
4
|
+
};
|
|
5
|
+
export type InstallKimiHookResult = {
|
|
6
|
+
configPath: string;
|
|
7
|
+
backupPath?: string;
|
|
8
|
+
command: string;
|
|
9
|
+
};
|
|
10
|
+
export type UninstallKimiHookResult = {
|
|
11
|
+
configPath: string;
|
|
12
|
+
removed: number;
|
|
13
|
+
};
|
|
14
|
+
export type KimiDoctorReport = {
|
|
15
|
+
configPath: string;
|
|
16
|
+
status: "ok" | "warn" | "broken" | "disabled";
|
|
17
|
+
issues: string[];
|
|
18
|
+
advisories: string[];
|
|
19
|
+
fixCommand: string;
|
|
20
|
+
expectedCommand: string;
|
|
21
|
+
detectedCommand?: string;
|
|
22
|
+
hasTokenjuiceMarker: boolean;
|
|
23
|
+
checkedPaths: string[];
|
|
24
|
+
missingPaths: string[];
|
|
25
|
+
};
|
|
26
|
+
export declare function installKimiHook(configPath?: string, options?: KimiHookCommandOptions): Promise<InstallKimiHookResult>;
|
|
27
|
+
export declare function uninstallKimiHook(configPath?: string): Promise<UninstallKimiHookResult>;
|
|
28
|
+
export declare function doctorKimiHook(configPath?: string, options?: KimiHookCommandOptions): Promise<KimiDoctorReport>;
|
|
29
|
+
export declare function runKimiPostToolUseHook(rawText: string): Promise<number>;
|