@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,265 @@
|
|
|
1
|
+
import { readdir, readFile, realpath } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { BUNDLED_BUILTIN_RULES } from "./builtin-rules.generated.js";
|
|
6
|
+
import { assertValidRule, validateRule } from "./validate-rules.js";
|
|
7
|
+
const ruleCache = new Map();
|
|
8
|
+
function builtinRulesRoot() {
|
|
9
|
+
return resolve(fileURLToPath(new URL("../rules", import.meta.url)));
|
|
10
|
+
}
|
|
11
|
+
function mergeRegexFlags(flags) {
|
|
12
|
+
return [...new Set(`u${flags ?? ""}`.split(""))].join("");
|
|
13
|
+
}
|
|
14
|
+
function compileRule(descriptor) {
|
|
15
|
+
return {
|
|
16
|
+
rule: descriptor.rule,
|
|
17
|
+
source: descriptor.source,
|
|
18
|
+
path: descriptor.path,
|
|
19
|
+
compiled: {
|
|
20
|
+
skipPatterns: (descriptor.rule.filters?.skipPatterns ?? []).map((pattern) => new RegExp(pattern, "u")),
|
|
21
|
+
keepPatterns: (descriptor.rule.filters?.keepPatterns ?? []).map((pattern) => new RegExp(pattern, "u")),
|
|
22
|
+
counters: (descriptor.rule.counters ?? []).map((counter) => ({
|
|
23
|
+
name: counter.name,
|
|
24
|
+
pattern: new RegExp(counter.pattern, mergeRegexFlags(counter.flags)),
|
|
25
|
+
})),
|
|
26
|
+
outputMatches: (descriptor.rule.matchOutput ?? []).map((entry) => ({
|
|
27
|
+
pattern: new RegExp(entry.pattern, mergeRegexFlags(entry.flags)),
|
|
28
|
+
message: entry.message,
|
|
29
|
+
})),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function listRuleFiles(root) {
|
|
34
|
+
const resolvedRoot = await realpath(root).catch(() => null);
|
|
35
|
+
if (!resolvedRoot) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const rootRealPath = resolvedRoot;
|
|
39
|
+
async function walk(currentDir) {
|
|
40
|
+
const entries = (await readdir(currentDir, { withFileTypes: true })).sort((left, right) => left.name.localeCompare(right.name));
|
|
41
|
+
const files = await Promise.all(entries.map(async (entry) => {
|
|
42
|
+
const fullPath = join(currentDir, entry.name);
|
|
43
|
+
if (entry.isSymbolicLink()) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
if (entry.isDirectory()) {
|
|
47
|
+
return await walk(fullPath);
|
|
48
|
+
}
|
|
49
|
+
if (!entry.isFile()
|
|
50
|
+
|| !entry.name.endsWith(".json")
|
|
51
|
+
|| entry.name.endsWith(".schema.json")
|
|
52
|
+
|| entry.name.endsWith(".fixture.json")) {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
const realFilePath = await realpath(fullPath).catch(() => null);
|
|
56
|
+
if (!realFilePath) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const relativePath = relative(rootRealPath, realFilePath);
|
|
60
|
+
if (relativePath.startsWith("..") || isAbsolute(relativePath)) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
return [realFilePath];
|
|
64
|
+
}));
|
|
65
|
+
return files.flat();
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
return await walk(root);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function userRulesRoot(customDir) {
|
|
75
|
+
return customDir ?? join(homedir(), ".config", "tokenjuice", "rules");
|
|
76
|
+
}
|
|
77
|
+
function projectRulesRoot(cwd, customDir) {
|
|
78
|
+
return customDir ?? join(cwd ?? process.cwd(), ".tokenjuice", "rules");
|
|
79
|
+
}
|
|
80
|
+
function sortRules(rules) {
|
|
81
|
+
return [...rules].sort((left, right) => {
|
|
82
|
+
if (left.rule.id === "generic/fallback") {
|
|
83
|
+
return 1;
|
|
84
|
+
}
|
|
85
|
+
if (right.rule.id === "generic/fallback") {
|
|
86
|
+
return -1;
|
|
87
|
+
}
|
|
88
|
+
return left.rule.id.localeCompare(right.rule.id);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async function loadRuleDescriptorsFromRoot(root, source) {
|
|
92
|
+
const files = await listRuleFiles(root);
|
|
93
|
+
return await Promise.all(files.map(async (fullPath) => {
|
|
94
|
+
const parsed = JSON.parse(await readFile(fullPath, "utf8"));
|
|
95
|
+
assertValidRule(parsed);
|
|
96
|
+
return {
|
|
97
|
+
source,
|
|
98
|
+
path: fullPath,
|
|
99
|
+
relativePath: relative(root, fullPath),
|
|
100
|
+
rule: parsed,
|
|
101
|
+
};
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
function loadBundledBuiltinRuleDescriptors() {
|
|
105
|
+
return BUNDLED_BUILTIN_RULES.map((rule) => {
|
|
106
|
+
assertValidRule(rule);
|
|
107
|
+
return {
|
|
108
|
+
source: "builtin",
|
|
109
|
+
path: `bundled:${rule.id}`,
|
|
110
|
+
relativePath: rule.id,
|
|
111
|
+
rule,
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function cacheKey(options) {
|
|
116
|
+
return JSON.stringify({
|
|
117
|
+
cwd: options.cwd ?? process.cwd(),
|
|
118
|
+
includeUser: options.includeUser ?? true,
|
|
119
|
+
includeProject: options.includeProject ?? true,
|
|
120
|
+
userRulesDir: options.userRulesDir ?? null,
|
|
121
|
+
projectRulesDir: options.projectRulesDir ?? null,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function overlayRules(descriptors) {
|
|
125
|
+
const byId = new Map();
|
|
126
|
+
for (const descriptor of descriptors) {
|
|
127
|
+
byId.set(descriptor.rule.id, descriptor);
|
|
128
|
+
}
|
|
129
|
+
return sortRules([...byId.values()].map((descriptor) => compileRule(descriptor)));
|
|
130
|
+
}
|
|
131
|
+
export async function loadRules(options = {}) {
|
|
132
|
+
const key = cacheKey(options);
|
|
133
|
+
const cached = ruleCache.get(key);
|
|
134
|
+
if (cached) {
|
|
135
|
+
return cached;
|
|
136
|
+
}
|
|
137
|
+
const descriptors = [];
|
|
138
|
+
const builtinDescriptors = await loadRuleDescriptorsFromRoot(builtinRulesRoot(), "builtin");
|
|
139
|
+
descriptors.push(...(builtinDescriptors.length > 0 ? builtinDescriptors : loadBundledBuiltinRuleDescriptors()));
|
|
140
|
+
if (options.includeUser ?? true) {
|
|
141
|
+
descriptors.push(...await loadRuleDescriptorsFromRoot(userRulesRoot(options.userRulesDir), "user"));
|
|
142
|
+
}
|
|
143
|
+
if (options.includeProject ?? true) {
|
|
144
|
+
descriptors.push(...await loadRuleDescriptorsFromRoot(projectRulesRoot(options.cwd, options.projectRulesDir), "project"));
|
|
145
|
+
}
|
|
146
|
+
const compiled = overlayRules(descriptors);
|
|
147
|
+
ruleCache.set(key, compiled);
|
|
148
|
+
return compiled;
|
|
149
|
+
}
|
|
150
|
+
export async function loadBuiltinRules() {
|
|
151
|
+
return await loadRules({
|
|
152
|
+
includeUser: false,
|
|
153
|
+
includeProject: false,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
export function clearRuleCache() {
|
|
157
|
+
ruleCache.clear();
|
|
158
|
+
}
|
|
159
|
+
async function verifyRuleRoot(root, source) {
|
|
160
|
+
const files = await listRuleFiles(root);
|
|
161
|
+
const results = await Promise.all(files.map(async (fullPath) => {
|
|
162
|
+
try {
|
|
163
|
+
const raw = JSON.parse(await readFile(fullPath, "utf8"));
|
|
164
|
+
const validation = validateRule(raw);
|
|
165
|
+
const errors = validation.ok ? [] : [...validation.errors];
|
|
166
|
+
if (validation.ok) {
|
|
167
|
+
try {
|
|
168
|
+
assertValidRule(raw);
|
|
169
|
+
compileRule({
|
|
170
|
+
source,
|
|
171
|
+
path: fullPath,
|
|
172
|
+
relativePath: relative(root, fullPath),
|
|
173
|
+
rule: raw,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
id: validation.ok && typeof raw === "object" && raw !== null && "id" in raw && typeof raw.id === "string"
|
|
182
|
+
? raw.id
|
|
183
|
+
: relative(root, fullPath).replace(/\.json$/u, ""),
|
|
184
|
+
ok: errors.length === 0,
|
|
185
|
+
source,
|
|
186
|
+
path: fullPath,
|
|
187
|
+
errors,
|
|
188
|
+
warnings: [],
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
return {
|
|
193
|
+
id: relative(root, fullPath).replace(/\.json$/u, ""),
|
|
194
|
+
ok: false,
|
|
195
|
+
source,
|
|
196
|
+
path: fullPath,
|
|
197
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
198
|
+
warnings: [],
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}));
|
|
202
|
+
const idGroups = new Map();
|
|
203
|
+
for (const result of results) {
|
|
204
|
+
const group = idGroups.get(result.id) ?? [];
|
|
205
|
+
group.push(result);
|
|
206
|
+
idGroups.set(result.id, group);
|
|
207
|
+
}
|
|
208
|
+
for (const [id, group] of idGroups) {
|
|
209
|
+
if (group.length > 1) {
|
|
210
|
+
for (const result of group) {
|
|
211
|
+
result.errors.push(`duplicate rule id in ${source} layer: ${id}`);
|
|
212
|
+
result.ok = false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return results;
|
|
217
|
+
}
|
|
218
|
+
function ruleSourceRank(source) {
|
|
219
|
+
switch (source) {
|
|
220
|
+
case "builtin":
|
|
221
|
+
return 0;
|
|
222
|
+
case "user":
|
|
223
|
+
return 1;
|
|
224
|
+
case "project":
|
|
225
|
+
return 2;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function addShadowWarnings(results) {
|
|
229
|
+
const byId = new Map();
|
|
230
|
+
for (const result of results) {
|
|
231
|
+
const group = byId.get(result.id) ?? [];
|
|
232
|
+
group.push(result);
|
|
233
|
+
byId.set(result.id, group);
|
|
234
|
+
}
|
|
235
|
+
for (const [id, group] of byId) {
|
|
236
|
+
if (group.length < 2) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const ordered = [...group].sort((left, right) => ruleSourceRank(left.source) - ruleSourceRank(right.source));
|
|
240
|
+
const winner = ordered[ordered.length - 1];
|
|
241
|
+
const shadowed = ordered.slice(0, -1);
|
|
242
|
+
winner.warnings.push(`shadows ${shadowed.map((result) => `${result.source}:${id}`).join(", ")}`);
|
|
243
|
+
for (const result of shadowed) {
|
|
244
|
+
result.warnings.push(`shadowed by ${winner.source}:${id}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
export async function verifyRules(options = {}) {
|
|
249
|
+
const results = [];
|
|
250
|
+
results.push(...await verifyRuleRoot(builtinRulesRoot(), "builtin"));
|
|
251
|
+
if (options.includeUser ?? true) {
|
|
252
|
+
results.push(...await verifyRuleRoot(userRulesRoot(options.userRulesDir), "user"));
|
|
253
|
+
}
|
|
254
|
+
if (options.includeProject ?? true) {
|
|
255
|
+
results.push(...await verifyRuleRoot(projectRulesRoot(options.cwd, options.projectRulesDir), "project"));
|
|
256
|
+
}
|
|
257
|
+
addShadowWarnings(results);
|
|
258
|
+
return results;
|
|
259
|
+
}
|
|
260
|
+
export async function verifyBuiltinRules() {
|
|
261
|
+
return await verifyRules({
|
|
262
|
+
includeUser: false,
|
|
263
|
+
includeProject: false,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolExecutionInput } from "../types.js";
|
|
2
|
+
export declare const UNKNOWN_ARTIFACT_SOURCE = "unknown";
|
|
3
|
+
export declare const DEFAULT_CLI_ARTIFACT_SOURCE = "cli";
|
|
4
|
+
export declare function normalizeArtifactSource(value: unknown): string | null;
|
|
5
|
+
export declare function resolveArtifactSource(input: ToolExecutionInput): string;
|
|
6
|
+
export declare function readStoredArtifactSource(source: string | undefined): string;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export const UNKNOWN_ARTIFACT_SOURCE = "unknown";
|
|
2
|
+
export const DEFAULT_CLI_ARTIFACT_SOURCE = "cli";
|
|
3
|
+
export function normalizeArtifactSource(value) {
|
|
4
|
+
if (typeof value !== "string") {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const source = value
|
|
8
|
+
.trim()
|
|
9
|
+
.toLowerCase()
|
|
10
|
+
.replace(/[_\s]+/gu, "-")
|
|
11
|
+
.replace(/[^a-z0-9.-]+/gu, "-")
|
|
12
|
+
.replace(/^-+|-+$/gu, "");
|
|
13
|
+
if (!source) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (source.startsWith("amazon-q") || source.startsWith("amazonq") || source.startsWith("aws-q")) {
|
|
17
|
+
return "amazon-q";
|
|
18
|
+
}
|
|
19
|
+
if (source.startsWith("claude-code") || source === "claude") {
|
|
20
|
+
return "claude-code";
|
|
21
|
+
}
|
|
22
|
+
if (source.startsWith("cline")) {
|
|
23
|
+
return "cline";
|
|
24
|
+
}
|
|
25
|
+
if (source.startsWith("codex")) {
|
|
26
|
+
return "codex";
|
|
27
|
+
}
|
|
28
|
+
if (source.startsWith("command-code") || source.startsWith("commandcode")) {
|
|
29
|
+
return "command-code";
|
|
30
|
+
}
|
|
31
|
+
if (source.startsWith("copilot-agent") || source.startsWith("github-copilot-agent")) {
|
|
32
|
+
return "copilot-agent";
|
|
33
|
+
}
|
|
34
|
+
if (source.startsWith("copilot-cli") || source.startsWith("github-copilot-cli")) {
|
|
35
|
+
return "copilot-cli";
|
|
36
|
+
}
|
|
37
|
+
if (source.startsWith("crush")) {
|
|
38
|
+
return "crush";
|
|
39
|
+
}
|
|
40
|
+
if (source.startsWith("cursor")) {
|
|
41
|
+
return "cursor";
|
|
42
|
+
}
|
|
43
|
+
if (source.startsWith("droid") || source.startsWith("factory-droid")) {
|
|
44
|
+
return "droid";
|
|
45
|
+
}
|
|
46
|
+
if (source.startsWith("gemini")) {
|
|
47
|
+
return "gemini-cli";
|
|
48
|
+
}
|
|
49
|
+
if (source.startsWith("grok-build") || source.startsWith("grokbuild") || source.startsWith("xai-grok-build")) {
|
|
50
|
+
return "grok-build";
|
|
51
|
+
}
|
|
52
|
+
if (source.startsWith("grok")) {
|
|
53
|
+
return "grok-cli";
|
|
54
|
+
}
|
|
55
|
+
if (source.startsWith("goose")) {
|
|
56
|
+
return "goose";
|
|
57
|
+
}
|
|
58
|
+
if (source.startsWith("antigravity") || source === "google-antigravity") {
|
|
59
|
+
return "antigravity";
|
|
60
|
+
}
|
|
61
|
+
if (source.startsWith("augment") || source.startsWith("auggie")) {
|
|
62
|
+
return "augment";
|
|
63
|
+
}
|
|
64
|
+
if (source.startsWith("openclaw")) {
|
|
65
|
+
return "openclaw";
|
|
66
|
+
}
|
|
67
|
+
if (source.startsWith("openhands")) {
|
|
68
|
+
return "openhands";
|
|
69
|
+
}
|
|
70
|
+
if (source.startsWith("openinterpreter") || source.startsWith("open-interpreter")) {
|
|
71
|
+
return "open-interpreter";
|
|
72
|
+
}
|
|
73
|
+
if (source.startsWith("openwebui") || source.startsWith("open-webui")) {
|
|
74
|
+
return "openwebui";
|
|
75
|
+
}
|
|
76
|
+
if (source.startsWith("opencode") || source.startsWith("open-code")) {
|
|
77
|
+
return "opencode";
|
|
78
|
+
}
|
|
79
|
+
if (source.startsWith("pi")) {
|
|
80
|
+
return "pi";
|
|
81
|
+
}
|
|
82
|
+
if (source.startsWith("plandex")) {
|
|
83
|
+
return "plandex";
|
|
84
|
+
}
|
|
85
|
+
if (source.startsWith("qoder")) {
|
|
86
|
+
return "qoder";
|
|
87
|
+
}
|
|
88
|
+
if (source.startsWith("qwen")) {
|
|
89
|
+
return "qwen-code";
|
|
90
|
+
}
|
|
91
|
+
if (source.startsWith("kimi")) {
|
|
92
|
+
return "kimi";
|
|
93
|
+
}
|
|
94
|
+
if (source.startsWith("mux")) {
|
|
95
|
+
return "mux";
|
|
96
|
+
}
|
|
97
|
+
if (source.startsWith("ruler")) {
|
|
98
|
+
return "ruler";
|
|
99
|
+
}
|
|
100
|
+
if (source.startsWith("vscode-copilot") || source.startsWith("vs-code-copilot")) {
|
|
101
|
+
return "vscode-copilot";
|
|
102
|
+
}
|
|
103
|
+
if (source === "direct" || source === "tokenjuice" || source === "wrap") {
|
|
104
|
+
return DEFAULT_CLI_ARTIFACT_SOURCE;
|
|
105
|
+
}
|
|
106
|
+
return source;
|
|
107
|
+
}
|
|
108
|
+
export function resolveArtifactSource(input) {
|
|
109
|
+
return normalizeArtifactSource(input.metadata?.source) ?? DEFAULT_CLI_ARTIFACT_SOURCE;
|
|
110
|
+
}
|
|
111
|
+
export function readStoredArtifactSource(source) {
|
|
112
|
+
return normalizeArtifactSource(source) ?? UNKNOWN_ARTIFACT_SOURCE;
|
|
113
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type CompactionMetadata } from "./compaction-metadata.js";
|
|
2
|
+
export declare function stripAnsi(text: string): string;
|
|
3
|
+
export declare function countTextChars(text: string): number;
|
|
4
|
+
export declare function sliceTextChars(text: string, start: number, end?: number): string;
|
|
5
|
+
export declare function countTerminalCells(text: string): number;
|
|
6
|
+
export declare function normalizeLines(text: string): string[];
|
|
7
|
+
export declare function trimEmptyEdges(lines: string[]): string[];
|
|
8
|
+
export declare function dedupeAdjacent(lines: string[]): string[];
|
|
9
|
+
export declare function headTail(lines: string[], head: number, tail: number, noOmit?: boolean): {
|
|
10
|
+
lines: string[];
|
|
11
|
+
compaction?: CompactionMetadata;
|
|
12
|
+
};
|
|
13
|
+
export declare function clampText(text: string, maxChars: number): string;
|
|
14
|
+
export declare function clampTextWithMetadata(text: string, maxChars: number, noOmit?: boolean): {
|
|
15
|
+
text: string;
|
|
16
|
+
compaction?: CompactionMetadata;
|
|
17
|
+
};
|
|
18
|
+
export declare function clampTextMiddle(text: string, maxChars: number): string;
|
|
19
|
+
export declare function clampTextMiddleWithMetadata(text: string, maxChars: number, noOmit?: boolean): {
|
|
20
|
+
text: string;
|
|
21
|
+
compaction?: CompactionMetadata;
|
|
22
|
+
};
|
|
23
|
+
export declare function pluralize(count: number, noun: string): string;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { createCompactionMetadata, createPassthroughCompactionMetadata } from "./compaction-metadata.js";
|
|
2
|
+
const ANSI_CSI_PATTERN = new RegExp(String.raw `\u001B\[[0-?]*[ -/]*[@-~]`, "g");
|
|
3
|
+
const ANSI_OSC_PATTERN = new RegExp(String.raw `\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)`, "g");
|
|
4
|
+
const ANSI_CSI_INCOMPLETE_PATTERN = new RegExp(String.raw `\u001B\[[0-?]*[ -/]*$`, "g");
|
|
5
|
+
const ANSI_OSC_INCOMPLETE_PATTERN = new RegExp(String.raw `\u001B\][^\u0007\u001B]*$`, "g");
|
|
6
|
+
const ANSI_SINGLE_PATTERN = new RegExp(String.raw `\u001B[@-_]`, "g");
|
|
7
|
+
const TRUNCATION_SUFFIX = "\n... truncated ...";
|
|
8
|
+
const MIDDLE_TRUNCATION_MARKER = "\n... omitted ...\n";
|
|
9
|
+
const COMBINING_MARK_PATTERN = /\p{Mark}/u;
|
|
10
|
+
const EMOJI_PATTERN = /\p{Extended_Pictographic}/u;
|
|
11
|
+
const graphemeSegmenter = typeof Intl !== "undefined" && "Segmenter" in Intl
|
|
12
|
+
? new Intl.Segmenter(undefined, { granularity: "grapheme" })
|
|
13
|
+
: null;
|
|
14
|
+
function graphemes(text) {
|
|
15
|
+
if (!graphemeSegmenter) {
|
|
16
|
+
return Array.from(text);
|
|
17
|
+
}
|
|
18
|
+
return Array.from(graphemeSegmenter.segment(text), (segment) => segment.segment);
|
|
19
|
+
}
|
|
20
|
+
function trimHeadToLineBoundary(text) {
|
|
21
|
+
const lastNewline = text.lastIndexOf("\n");
|
|
22
|
+
if (lastNewline === -1 || lastNewline < Math.floor(text.length * 0.5)) {
|
|
23
|
+
return text;
|
|
24
|
+
}
|
|
25
|
+
return text.slice(0, lastNewline);
|
|
26
|
+
}
|
|
27
|
+
function trimTailToLineBoundary(text) {
|
|
28
|
+
const firstNewline = text.indexOf("\n");
|
|
29
|
+
if (firstNewline === -1 || firstNewline > Math.ceil(text.length * 0.5)) {
|
|
30
|
+
return text;
|
|
31
|
+
}
|
|
32
|
+
return text.slice(firstNewline + 1);
|
|
33
|
+
}
|
|
34
|
+
export function stripAnsi(text) {
|
|
35
|
+
return text
|
|
36
|
+
.replaceAll(ANSI_OSC_PATTERN, "")
|
|
37
|
+
.replaceAll(ANSI_CSI_PATTERN, "")
|
|
38
|
+
.replaceAll(ANSI_OSC_INCOMPLETE_PATTERN, "")
|
|
39
|
+
.replaceAll(ANSI_CSI_INCOMPLETE_PATTERN, "")
|
|
40
|
+
.replaceAll(ANSI_SINGLE_PATTERN, "")
|
|
41
|
+
.replaceAll("\u001b", "");
|
|
42
|
+
}
|
|
43
|
+
export function countTextChars(text) {
|
|
44
|
+
return graphemes(text).length;
|
|
45
|
+
}
|
|
46
|
+
export function sliceTextChars(text, start, end) {
|
|
47
|
+
return graphemes(text).slice(start, end).join("");
|
|
48
|
+
}
|
|
49
|
+
function codePointWidth(codePoint) {
|
|
50
|
+
if (codePoint === 0
|
|
51
|
+
|| (codePoint >= 0x0000 && codePoint < 0x0020)
|
|
52
|
+
|| (codePoint >= 0x007f && codePoint < 0x00a0)) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
if ((codePoint >= 0x1100 && codePoint <= 0x115f)
|
|
56
|
+
|| codePoint === 0x2329
|
|
57
|
+
|| codePoint === 0x232a
|
|
58
|
+
|| (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f)
|
|
59
|
+
|| (codePoint >= 0xac00 && codePoint <= 0xd7a3)
|
|
60
|
+
|| (codePoint >= 0xf900 && codePoint <= 0xfaff)
|
|
61
|
+
|| (codePoint >= 0xfe10 && codePoint <= 0xfe19)
|
|
62
|
+
|| (codePoint >= 0xfe30 && codePoint <= 0xfe6f)
|
|
63
|
+
|| (codePoint >= 0xff00 && codePoint <= 0xff60)
|
|
64
|
+
|| (codePoint >= 0xffe0 && codePoint <= 0xffe6)
|
|
65
|
+
|| (codePoint >= 0x1f300 && codePoint <= 0x1faff)
|
|
66
|
+
|| (codePoint >= 0x20000 && codePoint <= 0x3fffd)) {
|
|
67
|
+
return 2;
|
|
68
|
+
}
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
function graphemeWidth(segment) {
|
|
72
|
+
if (segment === "") {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
if (EMOJI_PATTERN.test(segment)) {
|
|
76
|
+
return 2;
|
|
77
|
+
}
|
|
78
|
+
let width = 0;
|
|
79
|
+
let hasVisibleCodePoint = false;
|
|
80
|
+
for (const char of segment) {
|
|
81
|
+
if (char === "\u200d" || char === "\ufe0f" || COMBINING_MARK_PATTERN.test(char)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
width = Math.max(width, codePointWidth(char.codePointAt(0) ?? 0));
|
|
85
|
+
hasVisibleCodePoint = true;
|
|
86
|
+
}
|
|
87
|
+
return hasVisibleCodePoint ? width : 0;
|
|
88
|
+
}
|
|
89
|
+
export function countTerminalCells(text) {
|
|
90
|
+
return graphemes(text).reduce((sum, segment) => sum + graphemeWidth(segment), 0);
|
|
91
|
+
}
|
|
92
|
+
export function normalizeLines(text) {
|
|
93
|
+
return text
|
|
94
|
+
.replaceAll("\r\n", "\n")
|
|
95
|
+
.split("\n")
|
|
96
|
+
.map((line) => line.replace(/\s+$/u, ""));
|
|
97
|
+
}
|
|
98
|
+
export function trimEmptyEdges(lines) {
|
|
99
|
+
let start = 0;
|
|
100
|
+
let end = lines.length;
|
|
101
|
+
while (start < end && lines[start]?.trim() === "") {
|
|
102
|
+
start += 1;
|
|
103
|
+
}
|
|
104
|
+
while (end > start && lines[end - 1]?.trim() === "") {
|
|
105
|
+
end -= 1;
|
|
106
|
+
}
|
|
107
|
+
return lines.slice(start, end);
|
|
108
|
+
}
|
|
109
|
+
export function dedupeAdjacent(lines) {
|
|
110
|
+
const next = [];
|
|
111
|
+
for (const line of lines) {
|
|
112
|
+
if (next[next.length - 1] !== line) {
|
|
113
|
+
next.push(line);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return next;
|
|
117
|
+
}
|
|
118
|
+
export function headTail(lines, head, tail, noOmit = false) {
|
|
119
|
+
const safeHead = Math.max(0, head);
|
|
120
|
+
const safeTail = Math.max(0, tail);
|
|
121
|
+
if (safeHead === 0 && safeTail === 0) {
|
|
122
|
+
return { lines };
|
|
123
|
+
}
|
|
124
|
+
if (lines.length <= safeHead + safeTail) {
|
|
125
|
+
return { lines };
|
|
126
|
+
}
|
|
127
|
+
if (noOmit) {
|
|
128
|
+
return {
|
|
129
|
+
lines,
|
|
130
|
+
compaction: createPassthroughCompactionMetadata("no-omit-head-tail-passthrough"),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
lines: [
|
|
135
|
+
...lines.slice(0, safeHead),
|
|
136
|
+
`... ${lines.length - safeHead - safeTail} lines omitted ...`,
|
|
137
|
+
...lines.slice(-safeTail),
|
|
138
|
+
],
|
|
139
|
+
compaction: createCompactionMetadata("head-tail-omission"),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function clampText(text, maxChars) {
|
|
143
|
+
if (countTextChars(text) <= maxChars) {
|
|
144
|
+
return text;
|
|
145
|
+
}
|
|
146
|
+
const bodyChars = Math.max(0, maxChars - countTextChars(TRUNCATION_SUFFIX));
|
|
147
|
+
const head = trimHeadToLineBoundary(graphemes(text).slice(0, bodyChars).join(""));
|
|
148
|
+
return `${head}${TRUNCATION_SUFFIX}`;
|
|
149
|
+
}
|
|
150
|
+
export function clampTextWithMetadata(text, maxChars, noOmit = false) {
|
|
151
|
+
if (countTextChars(text) <= maxChars) {
|
|
152
|
+
return { text };
|
|
153
|
+
}
|
|
154
|
+
if (noOmit) {
|
|
155
|
+
return {
|
|
156
|
+
text,
|
|
157
|
+
compaction: createPassthroughCompactionMetadata("no-omit-char-clip-passthrough"),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
text: clampText(text, maxChars),
|
|
162
|
+
compaction: createCompactionMetadata("tail-truncation"),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
export function clampTextMiddle(text, maxChars) {
|
|
166
|
+
return clampTextMiddleWithMetadata(text, maxChars).text;
|
|
167
|
+
}
|
|
168
|
+
export function clampTextMiddleWithMetadata(text, maxChars, noOmit = false) {
|
|
169
|
+
if (countTextChars(text) <= maxChars) {
|
|
170
|
+
return { text };
|
|
171
|
+
}
|
|
172
|
+
if (noOmit) {
|
|
173
|
+
return {
|
|
174
|
+
text,
|
|
175
|
+
compaction: createPassthroughCompactionMetadata("no-omit-char-clip-passthrough"),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const markerChars = countTextChars(MIDDLE_TRUNCATION_MARKER);
|
|
179
|
+
const bodyChars = Math.max(0, maxChars - markerChars);
|
|
180
|
+
const headChars = Math.ceil(bodyChars * 0.7);
|
|
181
|
+
const tailChars = Math.max(0, bodyChars - headChars);
|
|
182
|
+
const segments = graphemes(text);
|
|
183
|
+
const head = trimHeadToLineBoundary(segments.slice(0, headChars).join(""));
|
|
184
|
+
const tail = trimTailToLineBoundary(segments.slice(-tailChars).join(""));
|
|
185
|
+
return {
|
|
186
|
+
text: `${head}${MIDDLE_TRUNCATION_MARKER}${tail}`,
|
|
187
|
+
compaction: createCompactionMetadata("middle-truncation"),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export function pluralize(count, noun) {
|
|
191
|
+
if (/(?:passed|failed|skipped)$/u.test(noun)) {
|
|
192
|
+
return `${count} ${noun}`;
|
|
193
|
+
}
|
|
194
|
+
if (count === 1) {
|
|
195
|
+
return `${count} ${noun}`;
|
|
196
|
+
}
|
|
197
|
+
if (/[sxz]$/u.test(noun) || /(sh|ch)$/u.test(noun)) {
|
|
198
|
+
return `${count} ${noun}es`;
|
|
199
|
+
}
|
|
200
|
+
if (/[^aeiou]y$/u.test(noun)) {
|
|
201
|
+
return `${count} ${noun.slice(0, -1)}ies`;
|
|
202
|
+
}
|
|
203
|
+
return `${count} ${noun}s`;
|
|
204
|
+
}
|