@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,286 @@
|
|
|
1
|
+
import { lstat, realpath, stat } 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_BAZ_FIX_COMMAND = "tokenjuice install baz";
|
|
7
|
+
const TOKENJUICE_BAZ_OWNERSHIP_MARKER = "<!-- tokenjuice:baz-skill -->";
|
|
8
|
+
const TOKENJUICE_BAZ_SKILL_MARKER = "# tokenjuice terminal output compaction";
|
|
9
|
+
const TOKENJUICE_BAZ_ADVISORY = "Baz support is beta and skill-based; Baz discovers Skill folders containing SKILL.md and converts them into AI Coding Guidelines, but tokenjuice does not intercept Baz review output.";
|
|
10
|
+
function isTokenjuiceBazSkillText(text) {
|
|
11
|
+
return text.includes(TOKENJUICE_BAZ_OWNERSHIP_MARKER);
|
|
12
|
+
}
|
|
13
|
+
function getExplicitProjectDir(options = {}) {
|
|
14
|
+
return options.projectDir || process.env.BAZ_PROJECT_DIR;
|
|
15
|
+
}
|
|
16
|
+
async function hasGitMetadata(dir) {
|
|
17
|
+
try {
|
|
18
|
+
await stat(join(dir, ".git"));
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function findGitRoot(startDir) {
|
|
26
|
+
let current = resolve(startDir);
|
|
27
|
+
while (true) {
|
|
28
|
+
if (await hasGitMetadata(current)) {
|
|
29
|
+
return current;
|
|
30
|
+
}
|
|
31
|
+
const parent = dirname(current);
|
|
32
|
+
if (parent === current) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
current = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function resolveProjectDir(options = {}) {
|
|
39
|
+
const explicitProjectDir = getExplicitProjectDir(options);
|
|
40
|
+
if (explicitProjectDir) {
|
|
41
|
+
return resolve(explicitProjectDir);
|
|
42
|
+
}
|
|
43
|
+
return (await findGitRoot(process.cwd())) ?? process.cwd();
|
|
44
|
+
}
|
|
45
|
+
function isInsideOrEqual(parentDir, childPath) {
|
|
46
|
+
const relativePath = relative(parentDir, childPath);
|
|
47
|
+
return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
|
|
48
|
+
}
|
|
49
|
+
function getExpectedSkillPath(projectDir) {
|
|
50
|
+
return join(projectDir, ".baz", "skills", "tokenjuice", "SKILL.md");
|
|
51
|
+
}
|
|
52
|
+
async function realpathExistingAncestor(path) {
|
|
53
|
+
let current = path;
|
|
54
|
+
while (true) {
|
|
55
|
+
try {
|
|
56
|
+
return await realpath(current);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error.code !== "ENOENT") {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
const parent = dirname(current);
|
|
63
|
+
if (parent === current) {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
current = parent;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function rejectSkillSymlink(filePath) {
|
|
71
|
+
try {
|
|
72
|
+
const stats = await lstat(filePath);
|
|
73
|
+
if (stats.isSymbolicLink()) {
|
|
74
|
+
throw new Error(`cannot use Baz skill ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error.code === "ENOENT") {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function rejectInstallSidecarSymlinks(filePath) {
|
|
85
|
+
await rejectSkillSymlink(`${filePath}.bak`);
|
|
86
|
+
await rejectSkillSymlink(`${filePath}.tmp`);
|
|
87
|
+
}
|
|
88
|
+
async function rejectSymlinkPathComponents(filePath, projectDir) {
|
|
89
|
+
const relativePath = relative(projectDir, filePath);
|
|
90
|
+
const segments = relativePath.split(sep).filter(Boolean);
|
|
91
|
+
let currentPath = projectDir;
|
|
92
|
+
for (const segment of segments.slice(0, -1)) {
|
|
93
|
+
currentPath = join(currentPath, segment);
|
|
94
|
+
try {
|
|
95
|
+
const stats = await lstat(currentPath);
|
|
96
|
+
if (stats.isSymbolicLink()) {
|
|
97
|
+
throw new Error(`cannot use Baz skill ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (error.code === "ENOENT") {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function resolveSafeProjectSkillPath(filePath, projectDir, realProjectDir = projectDir) {
|
|
109
|
+
const resolvedPath = resolve(filePath);
|
|
110
|
+
if (projectDir !== realProjectDir) {
|
|
111
|
+
throw new Error(`cannot use Baz skill ${resolvedPath}; tokenjuice will not read or write through instruction symlinks`);
|
|
112
|
+
}
|
|
113
|
+
const realParentDir = await realpathExistingAncestor(dirname(resolvedPath));
|
|
114
|
+
if (!isInsideOrEqual(realProjectDir, realParentDir)) {
|
|
115
|
+
throw new Error(`cannot use Baz skill ${resolvedPath}; tokenjuice will not write through instruction directories outside ${realProjectDir}`);
|
|
116
|
+
}
|
|
117
|
+
await rejectSkillSymlink(projectDir);
|
|
118
|
+
await rejectSymlinkPathComponents(resolvedPath, projectDir);
|
|
119
|
+
await rejectSkillSymlink(resolvedPath);
|
|
120
|
+
const expectedSkillPath = getExpectedSkillPath(projectDir);
|
|
121
|
+
if (resolvedPath !== expectedSkillPath) {
|
|
122
|
+
throw new Error(`cannot use Baz skill ${resolvedPath}; tokenjuice only installs the project-local .baz/skills/tokenjuice/SKILL.md skill`);
|
|
123
|
+
}
|
|
124
|
+
return resolvedPath;
|
|
125
|
+
}
|
|
126
|
+
async function getDefaultSkillPath(options = {}) {
|
|
127
|
+
const projectDir = await resolveProjectDir(options);
|
|
128
|
+
const realProjectDir = await realpath(projectDir).catch(() => projectDir);
|
|
129
|
+
return resolveSafeProjectSkillPath(getExpectedSkillPath(projectDir), projectDir, realProjectDir);
|
|
130
|
+
}
|
|
131
|
+
async function getDefaultAliasPath(options = {}) {
|
|
132
|
+
return getExpectedSkillPath(await resolveProjectDir(options));
|
|
133
|
+
}
|
|
134
|
+
async function pathExistsWithoutReading(filePath) {
|
|
135
|
+
try {
|
|
136
|
+
await lstat(filePath);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
if (error.code === "ENOENT") {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function resolveSkillPath(skillPath, options = {}) {
|
|
147
|
+
if (skillPath) {
|
|
148
|
+
const projectDir = await resolveProjectDir(options);
|
|
149
|
+
const realProjectDir = await realpath(projectDir).catch(() => projectDir);
|
|
150
|
+
return resolveSafeProjectSkillPath(skillPath, projectDir, realProjectDir);
|
|
151
|
+
}
|
|
152
|
+
return getDefaultSkillPath(options);
|
|
153
|
+
}
|
|
154
|
+
const TOKENJUICE_BAZ_SKILL = [
|
|
155
|
+
"---",
|
|
156
|
+
"name: tokenjuice",
|
|
157
|
+
'description: "Use tokenjuice to compact noisy terminal output when Baz agents inspect a repository."',
|
|
158
|
+
"---",
|
|
159
|
+
"",
|
|
160
|
+
TOKENJUICE_BAZ_OWNERSHIP_MARKER,
|
|
161
|
+
"",
|
|
162
|
+
"# tokenjuice terminal output compaction",
|
|
163
|
+
"",
|
|
164
|
+
...buildTokenjuiceGuidanceBullets({
|
|
165
|
+
wrapBullet: "- When Baz agents run terminal commands likely to produce long output during review, fixer, or runtime inspection workflows, prefer `tokenjuice wrap -- <command>`.",
|
|
166
|
+
}),
|
|
167
|
+
"- Baz discovers this reusable skill from `.baz/skills/tokenjuice/SKILL.md` and still owns review, fixer, shell execution, and comment delivery.",
|
|
168
|
+
"",
|
|
169
|
+
].join("\n");
|
|
170
|
+
export async function installBazSkill(skillPath, options = {}) {
|
|
171
|
+
const resolvedSkillPath = await resolveSkillPath(skillPath, options);
|
|
172
|
+
await rejectInstallSidecarSymlinks(resolvedSkillPath);
|
|
173
|
+
const result = await writeInstructionFile(resolvedSkillPath, TOKENJUICE_BAZ_SKILL);
|
|
174
|
+
return {
|
|
175
|
+
skillPath: result.filePath,
|
|
176
|
+
...(result.backupPath ? { backupPath: result.backupPath } : {}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export async function uninstallBazSkill(skillPath, options = {}) {
|
|
180
|
+
const resolvedSkillPath = await resolveSkillPath(skillPath, options);
|
|
181
|
+
const existing = await readInstructionFile(resolvedSkillPath);
|
|
182
|
+
if (!existing.exists || !isTokenjuiceBazSkillText(existing.text)) {
|
|
183
|
+
return { skillPath: resolvedSkillPath, removed: false };
|
|
184
|
+
}
|
|
185
|
+
const result = await removeInstructionFile(resolvedSkillPath);
|
|
186
|
+
return { skillPath: result.filePath, removed: result.removed };
|
|
187
|
+
}
|
|
188
|
+
export async function doctorBazSkill(skillPath, options = {}) {
|
|
189
|
+
let resolvedSkillPath;
|
|
190
|
+
try {
|
|
191
|
+
resolvedSkillPath = await resolveSkillPath(skillPath, options);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const aliasPath = skillPath ?? (await getDefaultAliasPath(options));
|
|
195
|
+
if (!skillPath && !(await pathExistsWithoutReading(aliasPath))) {
|
|
196
|
+
return {
|
|
197
|
+
skillPath: aliasPath,
|
|
198
|
+
hasTokenjuiceMarker: false,
|
|
199
|
+
hasUnsafePathIssue: false,
|
|
200
|
+
...buildInstructionDoctorReportFields({
|
|
201
|
+
status: "disabled",
|
|
202
|
+
issues: ["tokenjuice Baz skill is not installed"],
|
|
203
|
+
advisory: TOKENJUICE_BAZ_ADVISORY,
|
|
204
|
+
fixCommand: TOKENJUICE_BAZ_FIX_COMMAND,
|
|
205
|
+
}),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
skillPath: aliasPath,
|
|
210
|
+
hasTokenjuiceMarker: false,
|
|
211
|
+
hasUnsafePathIssue: true,
|
|
212
|
+
...buildInstructionDoctorReportFields({
|
|
213
|
+
status: "broken",
|
|
214
|
+
issues: [error.message],
|
|
215
|
+
advisory: TOKENJUICE_BAZ_ADVISORY,
|
|
216
|
+
fixCommand: error.message.includes("outside") || error.message.includes("only installs")
|
|
217
|
+
? "use a project-local .baz/skills/tokenjuice/SKILL.md path, then run tokenjuice install baz"
|
|
218
|
+
: "replace symlinked Baz skill with a regular project file, then run tokenjuice install baz",
|
|
219
|
+
}),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const existing = await readInstructionFile(resolvedSkillPath);
|
|
223
|
+
const hasTokenjuiceMarker = isTokenjuiceBazSkillText(existing.text);
|
|
224
|
+
if (!existing.exists) {
|
|
225
|
+
return {
|
|
226
|
+
skillPath: resolvedSkillPath,
|
|
227
|
+
hasTokenjuiceMarker: false,
|
|
228
|
+
hasUnsafePathIssue: false,
|
|
229
|
+
...buildInstructionDoctorReportFields({
|
|
230
|
+
status: "disabled",
|
|
231
|
+
issues: ["tokenjuice Baz skill is not installed"],
|
|
232
|
+
advisory: TOKENJUICE_BAZ_ADVISORY,
|
|
233
|
+
fixCommand: TOKENJUICE_BAZ_FIX_COMMAND,
|
|
234
|
+
}),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const issues = collectGuidanceIssues(existing.text, {
|
|
238
|
+
required: [
|
|
239
|
+
{
|
|
240
|
+
requiredText: TOKENJUICE_BAZ_OWNERSHIP_MARKER,
|
|
241
|
+
missingIssue: "configured Baz skill is missing the tokenjuice ownership marker",
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
requiredText: "name: tokenjuice",
|
|
245
|
+
missingIssue: "configured Baz skill is missing the required tokenjuice skill name",
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
requiredText: "description:",
|
|
249
|
+
missingIssue: "configured Baz skill is missing discovery frontmatter",
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
requiredText: TOKENJUICE_BAZ_SKILL_MARKER,
|
|
253
|
+
missingIssue: "configured Baz skill does not look like the tokenjuice skill",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
requiredText: TOKENJUICE_WRAP_COMMAND,
|
|
257
|
+
missingIssue: "configured Baz skill is missing tokenjuice wrap guidance",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
requiredText: TOKENJUICE_RAW_COMMAND,
|
|
261
|
+
missingIssue: "configured Baz skill is missing the raw escape hatch",
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
requiredText: ".baz/skills/tokenjuice/SKILL.md",
|
|
265
|
+
missingIssue: "configured Baz skill is missing workspace skill path guidance",
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
forbidden: [
|
|
269
|
+
{
|
|
270
|
+
forbiddenText: TOKENJUICE_FULL_COMMAND,
|
|
271
|
+
presentIssue: "configured Baz skill still suggests the full escape hatch",
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
skillPath: resolvedSkillPath,
|
|
277
|
+
hasTokenjuiceMarker,
|
|
278
|
+
hasUnsafePathIssue: false,
|
|
279
|
+
...buildInstructionDoctorReportFields({
|
|
280
|
+
status: instructionDoctorStatusFromIssues(issues),
|
|
281
|
+
issues,
|
|
282
|
+
advisory: TOKENJUICE_BAZ_ADVISORY,
|
|
283
|
+
fixCommand: TOKENJUICE_BAZ_FIX_COMMAND,
|
|
284
|
+
}),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type BitoGuidelinesOptions = {
|
|
2
|
+
projectDir?: string;
|
|
3
|
+
};
|
|
4
|
+
export type InstallBitoGuidelinesResult = {
|
|
5
|
+
configPath: string;
|
|
6
|
+
guidelinesPath: string;
|
|
7
|
+
configBackupPath?: string;
|
|
8
|
+
guidelinesBackupPath?: string;
|
|
9
|
+
};
|
|
10
|
+
export type UninstallBitoGuidelinesResult = {
|
|
11
|
+
configPath: string;
|
|
12
|
+
guidelinesPath: string;
|
|
13
|
+
removed: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type BitoDoctorReport = {
|
|
16
|
+
configPath: string;
|
|
17
|
+
guidelinesPath: string;
|
|
18
|
+
hasTokenjuiceMarker: boolean;
|
|
19
|
+
status: "ok" | "warn" | "broken" | "disabled";
|
|
20
|
+
issues: string[];
|
|
21
|
+
advisories: string[];
|
|
22
|
+
fixCommand: string;
|
|
23
|
+
checkedPaths: string[];
|
|
24
|
+
missingPaths: string[];
|
|
25
|
+
};
|
|
26
|
+
export declare function installBitoGuidelines(options?: BitoGuidelinesOptions): Promise<InstallBitoGuidelinesResult>;
|
|
27
|
+
export declare function uninstallBitoGuidelines(options?: BitoGuidelinesOptions): Promise<UninstallBitoGuidelinesResult>;
|
|
28
|
+
export declare function doctorBitoGuidelines(options?: BitoGuidelinesOptions): Promise<BitoDoctorReport>;
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { lstat, realpath, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { inspectMarkerDelimitedBlock, installMarkerDelimitedBlock, uninstallMarkerDelimitedBlock, } from "../shared/marker-instructions.js";
|
|
4
|
+
import { buildTokenjuiceGuidanceBullets, TOKENJUICE_FULL_COMMAND, TOKENJUICE_RAW_COMMAND, TOKENJUICE_WRAP_COMMAND, } from "../shared/instruction-guidance.js";
|
|
5
|
+
import { buildInstructionDoctorReportFields, instructionDoctorStatusFromIssues, } from "../shared/instruction-doctor.js";
|
|
6
|
+
import { assertSafeInstructionBackupPath, collectGuidanceIssues, readInstructionFile, removeInstructionFile, writeInstructionFile, } from "../shared/instruction-file.js";
|
|
7
|
+
const TOKENJUICE_BITO_FIX_COMMAND = "tokenjuice install bito";
|
|
8
|
+
const TOKENJUICE_BITO_BEGIN = "# tokenjuice:bito begin";
|
|
9
|
+
const TOKENJUICE_BITO_END = "# tokenjuice:bito end";
|
|
10
|
+
const TOKENJUICE_BITO_GUIDELINES_MARKER = "# tokenjuice terminal output compaction";
|
|
11
|
+
const TOKENJUICE_BITO_GUIDELINES_RELATIVE_PATH = "./.bito/tokenjuice.md";
|
|
12
|
+
const TOKENJUICE_BITO_ADVISORY = "Bito support is beta and custom-guidelines based; Bito still owns PR review, analysis settings, tools, and comment delivery.";
|
|
13
|
+
function getExplicitProjectDir(options = {}) {
|
|
14
|
+
return options.projectDir || process.env.BITO_PROJECT_DIR;
|
|
15
|
+
}
|
|
16
|
+
async function hasGitMetadata(dir) {
|
|
17
|
+
try {
|
|
18
|
+
await stat(join(dir, ".git"));
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function findGitRoot(startDir) {
|
|
26
|
+
let current = resolve(startDir);
|
|
27
|
+
while (true) {
|
|
28
|
+
if (await hasGitMetadata(current)) {
|
|
29
|
+
return current;
|
|
30
|
+
}
|
|
31
|
+
const parent = dirname(current);
|
|
32
|
+
if (parent === current) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
current = parent;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function resolveProjectDir(options = {}) {
|
|
39
|
+
const explicitProjectDir = getExplicitProjectDir(options);
|
|
40
|
+
if (explicitProjectDir) {
|
|
41
|
+
return resolve(explicitProjectDir);
|
|
42
|
+
}
|
|
43
|
+
return (await findGitRoot(process.cwd())) ?? process.cwd();
|
|
44
|
+
}
|
|
45
|
+
function isInsideOrEqual(parentDir, childPath) {
|
|
46
|
+
const relativePath = relative(parentDir, childPath);
|
|
47
|
+
return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
|
|
48
|
+
}
|
|
49
|
+
async function realpathExistingAncestor(path) {
|
|
50
|
+
let current = path;
|
|
51
|
+
while (true) {
|
|
52
|
+
try {
|
|
53
|
+
return await realpath(current);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error.code !== "ENOENT") {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
const parent = dirname(current);
|
|
60
|
+
if (parent === current) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
current = parent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function rejectInstructionSymlink(filePath, label) {
|
|
68
|
+
try {
|
|
69
|
+
const stats = await lstat(filePath);
|
|
70
|
+
if (stats.isSymbolicLink()) {
|
|
71
|
+
throw new Error(`cannot use Bito ${label} ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error.code === "ENOENT") {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function rejectSymlinkPathComponents(filePath, projectDir, label) {
|
|
82
|
+
const relativePath = relative(projectDir, filePath);
|
|
83
|
+
const segments = relativePath.split(sep).filter(Boolean);
|
|
84
|
+
let currentPath = projectDir;
|
|
85
|
+
for (const segment of segments.slice(0, -1)) {
|
|
86
|
+
currentPath = join(currentPath, segment);
|
|
87
|
+
try {
|
|
88
|
+
const stats = await lstat(currentPath);
|
|
89
|
+
if (stats.isSymbolicLink()) {
|
|
90
|
+
throw new Error(`cannot use Bito ${label} ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error.code === "ENOENT") {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function resolveSafeProjectPath(filePath, projectDir, realProjectDir, label) {
|
|
102
|
+
const resolvedPath = resolve(filePath);
|
|
103
|
+
if (projectDir !== realProjectDir) {
|
|
104
|
+
throw new Error(`cannot use Bito ${label} ${resolvedPath}; tokenjuice will not read or write through instruction symlinks`);
|
|
105
|
+
}
|
|
106
|
+
await rejectInstructionSymlink(projectDir, label);
|
|
107
|
+
await rejectSymlinkPathComponents(resolvedPath, projectDir, label);
|
|
108
|
+
const realParentDir = await realpathExistingAncestor(dirname(resolvedPath));
|
|
109
|
+
if (!isInsideOrEqual(realProjectDir, realParentDir)) {
|
|
110
|
+
throw new Error(`cannot use Bito ${label} ${resolvedPath}; tokenjuice will not write through instruction directories outside ${realProjectDir}`);
|
|
111
|
+
}
|
|
112
|
+
await rejectInstructionSymlink(resolvedPath, label);
|
|
113
|
+
return resolvedPath;
|
|
114
|
+
}
|
|
115
|
+
async function getProjectPaths(options = {}) {
|
|
116
|
+
const projectDir = await resolveProjectDir(options);
|
|
117
|
+
const realProjectDir = await realpath(projectDir).catch(() => projectDir);
|
|
118
|
+
return {
|
|
119
|
+
configPath: await resolveSafeProjectPath(join(projectDir, ".bito.yaml"), projectDir, realProjectDir, "config"),
|
|
120
|
+
guidelinesPath: await resolveSafeProjectPath(join(projectDir, ".bito", "tokenjuice.md"), projectDir, realProjectDir, "guidelines"),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async function getProjectAliasPaths(options = {}) {
|
|
124
|
+
const projectDir = await resolveProjectDir(options);
|
|
125
|
+
return {
|
|
126
|
+
configPath: join(projectDir, ".bito.yaml"),
|
|
127
|
+
guidelinesPath: join(projectDir, ".bito", "tokenjuice.md"),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
async function resolveSafeProjectPathIfAvailable(filePath, projectDir, realProjectDir, label) {
|
|
131
|
+
try {
|
|
132
|
+
return await resolveSafeProjectPath(filePath, projectDir, realProjectDir, label);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function detectTokenjuiceMarkerEvidence(options = {}) {
|
|
139
|
+
const projectDir = await resolveProjectDir(options);
|
|
140
|
+
const realProjectDir = await realpath(projectDir).catch(() => projectDir);
|
|
141
|
+
const configPath = await resolveSafeProjectPathIfAvailable(join(projectDir, ".bito.yaml"), projectDir, realProjectDir, "config");
|
|
142
|
+
if (configPath) {
|
|
143
|
+
const config = await readInstructionFile(configPath);
|
|
144
|
+
const markerState = inspectMarkerDelimitedBlock(config.text, TOKENJUICE_BITO_CONFIG);
|
|
145
|
+
if (config.exists && hasTokenjuiceConfigMarkers(config.text, markerState.completeBlockCount)) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const guidelinesPath = await resolveSafeProjectPathIfAvailable(join(projectDir, ".bito", "tokenjuice.md"), projectDir, realProjectDir, "guidelines");
|
|
150
|
+
if (guidelinesPath) {
|
|
151
|
+
const guidelines = await readInstructionFile(guidelinesPath);
|
|
152
|
+
if (guidelines.exists && hasTokenjuiceGuidelinesMarker(guidelines.text)) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
const TOKENJUICE_BITO_GUIDELINES = [
|
|
159
|
+
TOKENJUICE_BITO_GUIDELINES_MARKER,
|
|
160
|
+
"",
|
|
161
|
+
...buildTokenjuiceGuidanceBullets({
|
|
162
|
+
wrapBullet: "- When Bito review, chat, or tool workflows suggest terminal commands likely to produce long output, prefer `tokenjuice wrap -- <command>`.",
|
|
163
|
+
}),
|
|
164
|
+
"- Bito reads this file through `.bito.yaml` custom guidelines; Bito still owns PR review, tools, app settings, and comment delivery.",
|
|
165
|
+
"",
|
|
166
|
+
].join("\n");
|
|
167
|
+
const TOKENJUICE_BITO_CONFIG_BLOCK = [
|
|
168
|
+
TOKENJUICE_BITO_BEGIN,
|
|
169
|
+
"custom_guidelines:",
|
|
170
|
+
" general:",
|
|
171
|
+
' - name: "Tokenjuice terminal output compaction"',
|
|
172
|
+
` path: "${TOKENJUICE_BITO_GUIDELINES_RELATIVE_PATH}"`,
|
|
173
|
+
TOKENJUICE_BITO_END,
|
|
174
|
+
].join("\n");
|
|
175
|
+
const TOKENJUICE_BITO_CONFIG = {
|
|
176
|
+
beginMarker: TOKENJUICE_BITO_BEGIN,
|
|
177
|
+
endMarker: TOKENJUICE_BITO_END,
|
|
178
|
+
block: TOKENJUICE_BITO_CONFIG_BLOCK,
|
|
179
|
+
};
|
|
180
|
+
function getTokenjuiceConfigBlockText(text) {
|
|
181
|
+
const beginIndex = text.indexOf(TOKENJUICE_BITO_BEGIN);
|
|
182
|
+
if (beginIndex === -1) {
|
|
183
|
+
return "";
|
|
184
|
+
}
|
|
185
|
+
const endIndex = text.indexOf(TOKENJUICE_BITO_END, beginIndex + TOKENJUICE_BITO_BEGIN.length);
|
|
186
|
+
if (endIndex === -1) {
|
|
187
|
+
return text.slice(beginIndex);
|
|
188
|
+
}
|
|
189
|
+
return text.slice(beginIndex, endIndex + TOKENJUICE_BITO_END.length);
|
|
190
|
+
}
|
|
191
|
+
function removeTokenjuiceConfigBlockText(text) {
|
|
192
|
+
const beginIndex = text.indexOf(TOKENJUICE_BITO_BEGIN);
|
|
193
|
+
if (beginIndex === -1) {
|
|
194
|
+
return text;
|
|
195
|
+
}
|
|
196
|
+
const endIndex = text.indexOf(TOKENJUICE_BITO_END, beginIndex + TOKENJUICE_BITO_BEGIN.length);
|
|
197
|
+
if (endIndex === -1) {
|
|
198
|
+
return text.slice(0, beginIndex);
|
|
199
|
+
}
|
|
200
|
+
return `${text.slice(0, beginIndex)}${text.slice(endIndex + TOKENJUICE_BITO_END.length)}`;
|
|
201
|
+
}
|
|
202
|
+
function countMarker(text, marker) {
|
|
203
|
+
return text.split(marker).length - 1;
|
|
204
|
+
}
|
|
205
|
+
function hasMalformedMarkerStructure(text, completeBlockCount) {
|
|
206
|
+
const beginCount = countMarker(text, TOKENJUICE_BITO_BEGIN);
|
|
207
|
+
const endCount = countMarker(text, TOKENJUICE_BITO_END);
|
|
208
|
+
return beginCount !== endCount || beginCount !== completeBlockCount || endCount !== completeBlockCount;
|
|
209
|
+
}
|
|
210
|
+
function hasTokenjuiceConfigMarkers(text, completeBlockCount) {
|
|
211
|
+
return text.includes(TOKENJUICE_BITO_BEGIN) || text.includes(TOKENJUICE_BITO_END) || completeBlockCount > 0;
|
|
212
|
+
}
|
|
213
|
+
function hasTokenjuiceGuidelinesMarker(text) {
|
|
214
|
+
return text.includes(TOKENJUICE_BITO_GUIDELINES_MARKER);
|
|
215
|
+
}
|
|
216
|
+
function hasUserOwnedCustomGuidelines(text) {
|
|
217
|
+
return /^\s*(?:"custom_guidelines"|'custom_guidelines'|custom_guidelines)\s*:/mu.test(removeTokenjuiceConfigBlockText(text));
|
|
218
|
+
}
|
|
219
|
+
function collectBitoMarkerIssues(text, completeBlockCount) {
|
|
220
|
+
const beginCount = countMarker(text, TOKENJUICE_BITO_BEGIN);
|
|
221
|
+
const endCount = countMarker(text, TOKENJUICE_BITO_END);
|
|
222
|
+
if (beginCount === 0 && endCount === 0) {
|
|
223
|
+
return ["configured Bito config is missing tokenjuice markers"];
|
|
224
|
+
}
|
|
225
|
+
if (beginCount > 1 || endCount > 1 || completeBlockCount > 1) {
|
|
226
|
+
return [`configured Bito config has multiple tokenjuice blocks; run ${TOKENJUICE_BITO_FIX_COMMAND} to repair`];
|
|
227
|
+
}
|
|
228
|
+
if (beginCount === 1 && endCount === 0) {
|
|
229
|
+
return ["configured Bito config has a tokenjuice start marker without an end marker"];
|
|
230
|
+
}
|
|
231
|
+
if (beginCount === 0 && endCount === 1) {
|
|
232
|
+
return ["configured Bito config has a tokenjuice end marker without a start marker"];
|
|
233
|
+
}
|
|
234
|
+
if (completeBlockCount !== 1) {
|
|
235
|
+
return ["configured Bito config has tokenjuice markers in an unsupported order"];
|
|
236
|
+
}
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
export async function installBitoGuidelines(options = {}) {
|
|
240
|
+
const paths = await getProjectPaths(options);
|
|
241
|
+
const existingConfig = await readInstructionFile(paths.configPath);
|
|
242
|
+
const markerState = inspectMarkerDelimitedBlock(existingConfig.text, TOKENJUICE_BITO_CONFIG);
|
|
243
|
+
if (existingConfig.exists && hasMalformedMarkerStructure(existingConfig.text, markerState.completeBlockCount)) {
|
|
244
|
+
throw new Error(`cannot safely repair malformed tokenjuice Bito markers in ${paths.configPath}; remove the dangling marker manually, then rerun tokenjuice install bito`);
|
|
245
|
+
}
|
|
246
|
+
if (existingConfig.exists && hasUserOwnedCustomGuidelines(existingConfig.text)) {
|
|
247
|
+
throw new Error(`cannot install Bito guidance because ${paths.configPath} already defines custom_guidelines; add ${TOKENJUICE_BITO_GUIDELINES_RELATIVE_PATH} manually or remove the custom_guidelines block, then rerun tokenjuice install bito`);
|
|
248
|
+
}
|
|
249
|
+
await assertSafeInstructionBackupPath(paths.configPath);
|
|
250
|
+
await assertSafeInstructionBackupPath(paths.guidelinesPath);
|
|
251
|
+
const guidelines = await writeInstructionFile(paths.guidelinesPath, TOKENJUICE_BITO_GUIDELINES);
|
|
252
|
+
const config = await installMarkerDelimitedBlock(paths.configPath, TOKENJUICE_BITO_CONFIG);
|
|
253
|
+
return {
|
|
254
|
+
configPath: config.filePath,
|
|
255
|
+
guidelinesPath: guidelines.filePath,
|
|
256
|
+
...(config.backupPath ? { configBackupPath: config.backupPath } : {}),
|
|
257
|
+
...(guidelines.backupPath ? { guidelinesBackupPath: guidelines.backupPath } : {}),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export async function uninstallBitoGuidelines(options = {}) {
|
|
261
|
+
const paths = await getProjectPaths(options);
|
|
262
|
+
const existingConfig = await readInstructionFile(paths.configPath);
|
|
263
|
+
const markerState = inspectMarkerDelimitedBlock(existingConfig.text, TOKENJUICE_BITO_CONFIG);
|
|
264
|
+
if (existingConfig.exists && hasMalformedMarkerStructure(existingConfig.text, markerState.completeBlockCount)) {
|
|
265
|
+
throw new Error(`cannot safely uninstall malformed tokenjuice Bito markers in ${paths.configPath}; remove the dangling marker manually, then rerun tokenjuice uninstall bito`);
|
|
266
|
+
}
|
|
267
|
+
const config = await uninstallMarkerDelimitedBlock(paths.configPath, TOKENJUICE_BITO_CONFIG);
|
|
268
|
+
const existingGuidelines = await readInstructionFile(paths.guidelinesPath);
|
|
269
|
+
const guidelines = existingGuidelines.exists && hasTokenjuiceGuidelinesMarker(existingGuidelines.text)
|
|
270
|
+
? await removeInstructionFile(paths.guidelinesPath)
|
|
271
|
+
: { filePath: paths.guidelinesPath, removed: false };
|
|
272
|
+
return { configPath: paths.configPath, guidelinesPath: paths.guidelinesPath, removed: config.removed || guidelines.removed };
|
|
273
|
+
}
|
|
274
|
+
export async function doctorBitoGuidelines(options = {}) {
|
|
275
|
+
let paths;
|
|
276
|
+
try {
|
|
277
|
+
paths = await getProjectPaths(options);
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
const aliases = await getProjectAliasPaths(options);
|
|
281
|
+
const hasTokenjuiceMarker = await detectTokenjuiceMarkerEvidence(options).catch(() => false);
|
|
282
|
+
return {
|
|
283
|
+
...aliases,
|
|
284
|
+
hasTokenjuiceMarker,
|
|
285
|
+
...buildInstructionDoctorReportFields({
|
|
286
|
+
status: "broken",
|
|
287
|
+
issues: [error.message],
|
|
288
|
+
advisory: TOKENJUICE_BITO_ADVISORY,
|
|
289
|
+
fixCommand: "replace symlinked Bito files with regular project files, then run tokenjuice install bito",
|
|
290
|
+
}),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const config = await readInstructionFile(paths.configPath);
|
|
294
|
+
const guidelines = await readInstructionFile(paths.guidelinesPath);
|
|
295
|
+
const markerState = inspectMarkerDelimitedBlock(config.text, TOKENJUICE_BITO_CONFIG);
|
|
296
|
+
const hasConfigMarkers = config.exists && hasTokenjuiceConfigMarkers(config.text, markerState.completeBlockCount);
|
|
297
|
+
const hasGuidelinesMarker = guidelines.exists && hasTokenjuiceGuidelinesMarker(guidelines.text);
|
|
298
|
+
const hasTokenjuiceMarker = hasConfigMarkers || hasGuidelinesMarker;
|
|
299
|
+
if (!hasConfigMarkers && !hasGuidelinesMarker) {
|
|
300
|
+
return {
|
|
301
|
+
...paths,
|
|
302
|
+
hasTokenjuiceMarker,
|
|
303
|
+
...buildInstructionDoctorReportFields({
|
|
304
|
+
status: "disabled",
|
|
305
|
+
issues: ["tokenjuice Bito custom guidelines are not installed"],
|
|
306
|
+
advisory: TOKENJUICE_BITO_ADVISORY,
|
|
307
|
+
fixCommand: TOKENJUICE_BITO_FIX_COMMAND,
|
|
308
|
+
}),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
const markerIssues = config.exists
|
|
312
|
+
? collectBitoMarkerIssues(config.text, markerState.completeBlockCount)
|
|
313
|
+
: ["configured Bito config is missing .bito.yaml"];
|
|
314
|
+
const configIssues = collectGuidanceIssues(getTokenjuiceConfigBlockText(config.text), {
|
|
315
|
+
required: [
|
|
316
|
+
{
|
|
317
|
+
requiredText: "custom_guidelines:",
|
|
318
|
+
missingIssue: "configured Bito config is missing custom_guidelines",
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
requiredText: TOKENJUICE_BITO_GUIDELINES_RELATIVE_PATH,
|
|
322
|
+
missingIssue: "configured Bito config is missing the tokenjuice guidelines path",
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
});
|
|
326
|
+
const guidelinesIssues = guidelines.exists
|
|
327
|
+
? collectGuidanceIssues(guidelines.text, {
|
|
328
|
+
required: [
|
|
329
|
+
{
|
|
330
|
+
requiredText: TOKENJUICE_BITO_GUIDELINES_MARKER,
|
|
331
|
+
missingIssue: "configured Bito guidelines do not look like the tokenjuice guidelines",
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
requiredText: TOKENJUICE_WRAP_COMMAND,
|
|
335
|
+
missingIssue: "configured Bito guidelines are missing tokenjuice wrap guidance",
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
requiredText: TOKENJUICE_RAW_COMMAND,
|
|
339
|
+
missingIssue: "configured Bito guidelines are missing the raw escape hatch",
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
forbidden: [
|
|
343
|
+
{
|
|
344
|
+
forbiddenText: TOKENJUICE_FULL_COMMAND,
|
|
345
|
+
presentIssue: "configured Bito guidelines still suggest the full escape hatch",
|
|
346
|
+
},
|
|
347
|
+
],
|
|
348
|
+
})
|
|
349
|
+
: ["configured Bito guidelines file is missing"];
|
|
350
|
+
const issues = [...markerIssues, ...configIssues, ...guidelinesIssues];
|
|
351
|
+
return {
|
|
352
|
+
...paths,
|
|
353
|
+
hasTokenjuiceMarker,
|
|
354
|
+
...buildInstructionDoctorReportFields({
|
|
355
|
+
status: instructionDoctorStatusFromIssues(issues),
|
|
356
|
+
issues,
|
|
357
|
+
advisory: TOKENJUICE_BITO_ADVISORY,
|
|
358
|
+
fixCommand: hasMalformedMarkerStructure(config.text, markerState.completeBlockCount)
|
|
359
|
+
? "remove unmatched tokenjuice markers from .bito.yaml, then run tokenjuice install bito"
|
|
360
|
+
: TOKENJUICE_BITO_FIX_COMMAND,
|
|
361
|
+
}),
|
|
362
|
+
};
|
|
363
|
+
}
|