@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,88 @@
|
|
|
1
|
+
import type { CompactResult, StoredArtifactMetadata, ToolExecutionInput } from "../types.js";
|
|
2
|
+
export type AnalysisEntry = {
|
|
3
|
+
metadata: StoredArtifactMetadata;
|
|
4
|
+
};
|
|
5
|
+
export type DiscoverCandidate = {
|
|
6
|
+
kind: "missing-rule" | "weak-rule";
|
|
7
|
+
source?: string;
|
|
8
|
+
signature: string;
|
|
9
|
+
count: number;
|
|
10
|
+
totalRawChars: number;
|
|
11
|
+
avgRatio: number | null;
|
|
12
|
+
sampleCommand: string;
|
|
13
|
+
matchedReducer?: string;
|
|
14
|
+
};
|
|
15
|
+
export type DoctorReport = {
|
|
16
|
+
totals: {
|
|
17
|
+
entries: number;
|
|
18
|
+
genericArtifacts: number;
|
|
19
|
+
weakArtifacts: number;
|
|
20
|
+
avgRatio: number | null;
|
|
21
|
+
};
|
|
22
|
+
health: "good" | "warn" | "poor";
|
|
23
|
+
alerts: string[];
|
|
24
|
+
topMissingCommands: DiscoverCandidate[];
|
|
25
|
+
topWeakReducers: DiscoverCandidate[];
|
|
26
|
+
topReducers: Array<{
|
|
27
|
+
reducer: string;
|
|
28
|
+
count: number;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
export type StatsReport = {
|
|
32
|
+
source?: string;
|
|
33
|
+
totals: {
|
|
34
|
+
observedEntries: number;
|
|
35
|
+
captureTruncatedEntries: number;
|
|
36
|
+
observedRawChars: number;
|
|
37
|
+
observedReducedChars: number;
|
|
38
|
+
observedSavedChars: number;
|
|
39
|
+
observedAvgRatio: number | null;
|
|
40
|
+
observedSavingsPercent: number | null;
|
|
41
|
+
entries: number;
|
|
42
|
+
rawChars: number;
|
|
43
|
+
reducedChars: number;
|
|
44
|
+
savedChars: number;
|
|
45
|
+
avgRatio: number | null;
|
|
46
|
+
savingsPercent: number | null;
|
|
47
|
+
};
|
|
48
|
+
reducers: Array<{
|
|
49
|
+
reducer: string;
|
|
50
|
+
count: number;
|
|
51
|
+
rawChars: number;
|
|
52
|
+
reducedChars: number;
|
|
53
|
+
savedChars: number;
|
|
54
|
+
avgRatio: number | null;
|
|
55
|
+
}>;
|
|
56
|
+
commands: Array<{
|
|
57
|
+
signature: string;
|
|
58
|
+
count: number;
|
|
59
|
+
rawChars: number;
|
|
60
|
+
reducedChars: number;
|
|
61
|
+
savedChars: number;
|
|
62
|
+
avgRatio: number | null;
|
|
63
|
+
}>;
|
|
64
|
+
daily: Array<{
|
|
65
|
+
day: string;
|
|
66
|
+
count: number;
|
|
67
|
+
rawChars: number;
|
|
68
|
+
reducedChars: number;
|
|
69
|
+
savedChars: number;
|
|
70
|
+
}>;
|
|
71
|
+
sources?: StatsSourceReport[];
|
|
72
|
+
};
|
|
73
|
+
export type StatsOptions = {
|
|
74
|
+
timeZone?: string;
|
|
75
|
+
source?: string;
|
|
76
|
+
bySource?: boolean;
|
|
77
|
+
};
|
|
78
|
+
export type DiscoverOptions = {
|
|
79
|
+
source?: string;
|
|
80
|
+
bySource?: boolean;
|
|
81
|
+
};
|
|
82
|
+
export type StatsSourceReport = Omit<StatsReport, "sources"> & {
|
|
83
|
+
source: string;
|
|
84
|
+
};
|
|
85
|
+
export declare function buildAnalysisEntry(input: ToolExecutionInput, result: CompactResult): AnalysisEntry;
|
|
86
|
+
export declare function discoverCandidates(entries: AnalysisEntry[], options?: DiscoverOptions): DiscoverCandidate[];
|
|
87
|
+
export declare function statsArtifacts(entries: AnalysisEntry[], options?: StatsOptions): StatsReport;
|
|
88
|
+
export declare function doctorArtifacts(entries: AnalysisEntry[]): DoctorReport;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
import { normalizeCommandSignature } from "./command-identity.js";
|
|
2
|
+
import { readStoredArtifactSource, resolveArtifactSource } from "./source.js";
|
|
3
|
+
import { buildCalendarDayFormatter } from "./time.js";
|
|
4
|
+
const GENERIC_REDUCERS = new Set(["generic/fallback", undefined]);
|
|
5
|
+
const WEAK_RATIO_THRESHOLD = 0.65;
|
|
6
|
+
const MISSING_RAW_CHARS_THRESHOLD = 200;
|
|
7
|
+
const WEAK_RAW_CHARS_THRESHOLD = 500;
|
|
8
|
+
function clampRatio(value) {
|
|
9
|
+
return Math.min(Math.max(value, 0), 1);
|
|
10
|
+
}
|
|
11
|
+
function effectiveReducedChars(metadata) {
|
|
12
|
+
const reduced = metadata.reducedChars ?? metadata.rawChars;
|
|
13
|
+
return Math.min(Math.max(reduced, 0), metadata.rawChars);
|
|
14
|
+
}
|
|
15
|
+
function effectiveRatio(metadata) {
|
|
16
|
+
if (metadata.rawChars === 0) {
|
|
17
|
+
return 1;
|
|
18
|
+
}
|
|
19
|
+
return clampRatio(effectiveReducedChars(metadata) / metadata.rawChars);
|
|
20
|
+
}
|
|
21
|
+
export function buildAnalysisEntry(input, result) {
|
|
22
|
+
const captureTruncated = input.metadata?.tokenjuiceCaptureTruncated;
|
|
23
|
+
return {
|
|
24
|
+
metadata: {
|
|
25
|
+
createdAt: new Date().toISOString(),
|
|
26
|
+
source: resolveArtifactSource(input),
|
|
27
|
+
classification: result.classification,
|
|
28
|
+
rawChars: result.stats.rawChars,
|
|
29
|
+
reducedChars: result.stats.reducedChars,
|
|
30
|
+
ratio: result.stats.ratio,
|
|
31
|
+
...(input.toolName ? { toolName: input.toolName } : {}),
|
|
32
|
+
...(input.command ? { command: input.command } : {}),
|
|
33
|
+
...(typeof input.exitCode === "number" ? { exitCode: input.exitCode } : {}),
|
|
34
|
+
...(typeof captureTruncated === "boolean" ? { captureTruncated } : {}),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function entrySource(entry) {
|
|
39
|
+
return readStoredArtifactSource(entry.metadata.source);
|
|
40
|
+
}
|
|
41
|
+
function filterEntriesBySource(entries, source) {
|
|
42
|
+
const normalized = readStoredArtifactSource(source);
|
|
43
|
+
if (!source) {
|
|
44
|
+
return entries;
|
|
45
|
+
}
|
|
46
|
+
return entries.filter((entry) => entrySource(entry) === normalized);
|
|
47
|
+
}
|
|
48
|
+
function groupCandidates(entries, options = {}) {
|
|
49
|
+
const groups = new Map();
|
|
50
|
+
const includeSource = options.bySource || Boolean(options.source);
|
|
51
|
+
for (const entry of entries) {
|
|
52
|
+
const signature = normalizeCommandSignature(entry.metadata.command);
|
|
53
|
+
if (!signature) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const source = entrySource(entry);
|
|
57
|
+
const key = [
|
|
58
|
+
entry.kind,
|
|
59
|
+
includeSource ? source : "",
|
|
60
|
+
signature,
|
|
61
|
+
entry.metadata.classification.matchedReducer ?? "",
|
|
62
|
+
].join(":");
|
|
63
|
+
const existing = groups.get(key) ?? {
|
|
64
|
+
kind: entry.kind,
|
|
65
|
+
...(includeSource ? { source } : {}),
|
|
66
|
+
signature,
|
|
67
|
+
count: 0,
|
|
68
|
+
totalRawChars: 0,
|
|
69
|
+
ratioSum: 0,
|
|
70
|
+
ratioCount: 0,
|
|
71
|
+
sampleCommand: entry.metadata.command ?? signature,
|
|
72
|
+
...(entry.metadata.classification.matchedReducer
|
|
73
|
+
? { matchedReducer: entry.metadata.classification.matchedReducer }
|
|
74
|
+
: {}),
|
|
75
|
+
};
|
|
76
|
+
existing.count += 1;
|
|
77
|
+
existing.totalRawChars += entry.metadata.rawChars;
|
|
78
|
+
const ratio = effectiveRatio(entry.metadata);
|
|
79
|
+
if (ratio !== null) {
|
|
80
|
+
existing.ratioSum += ratio;
|
|
81
|
+
existing.ratioCount += 1;
|
|
82
|
+
}
|
|
83
|
+
groups.set(key, existing);
|
|
84
|
+
}
|
|
85
|
+
return [...groups.values()]
|
|
86
|
+
.map((group) => ({
|
|
87
|
+
kind: group.kind,
|
|
88
|
+
...(group.source ? { source: group.source } : {}),
|
|
89
|
+
signature: group.signature,
|
|
90
|
+
count: group.count,
|
|
91
|
+
totalRawChars: group.totalRawChars,
|
|
92
|
+
avgRatio: group.ratioCount > 0 ? group.ratioSum / group.ratioCount : null,
|
|
93
|
+
sampleCommand: group.sampleCommand,
|
|
94
|
+
...(group.matchedReducer ? { matchedReducer: group.matchedReducer } : {}),
|
|
95
|
+
}))
|
|
96
|
+
.sort((left, right) => {
|
|
97
|
+
const countDiff = right.count - left.count;
|
|
98
|
+
if (countDiff !== 0) {
|
|
99
|
+
return countDiff;
|
|
100
|
+
}
|
|
101
|
+
return right.totalRawChars - left.totalRawChars;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export function discoverCandidates(entries, options = {}) {
|
|
105
|
+
const filteredEntries = filterEntriesBySource(entries, options.source);
|
|
106
|
+
const missing = filteredEntries
|
|
107
|
+
.filter((entry) => GENERIC_REDUCERS.has(entry.metadata.classification.matchedReducer))
|
|
108
|
+
.filter((entry) => entry.metadata.rawChars >= MISSING_RAW_CHARS_THRESHOLD)
|
|
109
|
+
.map((entry) => ({
|
|
110
|
+
...entry,
|
|
111
|
+
kind: "missing-rule",
|
|
112
|
+
}));
|
|
113
|
+
const weak = filteredEntries
|
|
114
|
+
.filter((entry) => !GENERIC_REDUCERS.has(entry.metadata.classification.matchedReducer))
|
|
115
|
+
.filter((entry) => typeof entry.metadata.ratio === "number" && entry.metadata.ratio >= WEAK_RATIO_THRESHOLD)
|
|
116
|
+
.filter((entry) => entry.metadata.rawChars >= WEAK_RAW_CHARS_THRESHOLD)
|
|
117
|
+
.map((entry) => ({
|
|
118
|
+
...entry,
|
|
119
|
+
kind: "weak-rule",
|
|
120
|
+
}));
|
|
121
|
+
return [
|
|
122
|
+
...groupCandidates(missing, options),
|
|
123
|
+
...groupCandidates(weak, options),
|
|
124
|
+
].sort((left, right) => {
|
|
125
|
+
if (left.kind !== right.kind) {
|
|
126
|
+
return left.kind.localeCompare(right.kind);
|
|
127
|
+
}
|
|
128
|
+
const countDiff = right.count - left.count;
|
|
129
|
+
if (countDiff !== 0) {
|
|
130
|
+
return countDiff;
|
|
131
|
+
}
|
|
132
|
+
return right.totalRawChars - left.totalRawChars;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function buildDoctorAlerts(entries, avgRatio, genericCount, weakCount) {
|
|
136
|
+
const alerts = [];
|
|
137
|
+
if (entries.length === 0) {
|
|
138
|
+
return {
|
|
139
|
+
health: "warn",
|
|
140
|
+
alerts: ["no entries available yet; run with --store or analyze a file/stdin log"],
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (genericCount > 0) {
|
|
144
|
+
alerts.push(`${genericCount} entry${genericCount === 1 ? "" : "ies"} fell back to generic/fallback`);
|
|
145
|
+
}
|
|
146
|
+
if (weakCount > 0) {
|
|
147
|
+
alerts.push(`${weakCount} entry${weakCount === 1 ? "" : "ies"} matched a reducer but still compressed weakly`);
|
|
148
|
+
}
|
|
149
|
+
if (avgRatio !== null && avgRatio >= 0.85) {
|
|
150
|
+
alerts.push(`average reduction ratio is weak at ${Math.round(avgRatio * 100)}%`);
|
|
151
|
+
}
|
|
152
|
+
if (alerts.length === 0) {
|
|
153
|
+
return {
|
|
154
|
+
health: "good",
|
|
155
|
+
alerts: [],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const health = avgRatio !== null && avgRatio >= 0.85 ? "poor" : "warn";
|
|
159
|
+
return { health, alerts };
|
|
160
|
+
}
|
|
161
|
+
function addToStatsGroup(group, rawChars, reducedChars, ratio) {
|
|
162
|
+
return {
|
|
163
|
+
count: (group?.count ?? 0) + 1,
|
|
164
|
+
rawChars: (group?.rawChars ?? 0) + rawChars,
|
|
165
|
+
reducedChars: (group?.reducedChars ?? 0) + reducedChars,
|
|
166
|
+
ratioSum: (group?.ratioSum ?? 0) + (ratio ?? 0),
|
|
167
|
+
ratioCount: (group?.ratioCount ?? 0) + (ratio !== null ? 1 : 0),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function avgRatioFromGroup(group) {
|
|
171
|
+
return group.ratioCount > 0 ? group.ratioSum / group.ratioCount : null;
|
|
172
|
+
}
|
|
173
|
+
function buildStatsReport(entries, options, source) {
|
|
174
|
+
const reducers = new Map();
|
|
175
|
+
const commands = new Map();
|
|
176
|
+
const daily = new Map();
|
|
177
|
+
const formatDay = buildCalendarDayFormatter(options.timeZone);
|
|
178
|
+
let observedRawChars = 0;
|
|
179
|
+
let observedReducedChars = 0;
|
|
180
|
+
let observedRatioSum = 0;
|
|
181
|
+
let observedRatioCount = 0;
|
|
182
|
+
let captureTruncatedEntries = 0;
|
|
183
|
+
let rawChars = 0;
|
|
184
|
+
let reducedChars = 0;
|
|
185
|
+
let ratioSum = 0;
|
|
186
|
+
let ratioCount = 0;
|
|
187
|
+
for (const entry of entries) {
|
|
188
|
+
const reduced = effectiveReducedChars(entry.metadata);
|
|
189
|
+
const ratio = effectiveRatio(entry.metadata);
|
|
190
|
+
observedRawChars += entry.metadata.rawChars;
|
|
191
|
+
observedReducedChars += reduced;
|
|
192
|
+
if (ratio !== null) {
|
|
193
|
+
observedRatioSum += ratio;
|
|
194
|
+
observedRatioCount += 1;
|
|
195
|
+
}
|
|
196
|
+
if (entry.metadata.captureTruncated) {
|
|
197
|
+
captureTruncatedEntries += 1;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const reducer = entry.metadata.classification.matchedReducer ?? "generic/fallback";
|
|
201
|
+
const signature = normalizeCommandSignature(entry.metadata.command) ?? "(unknown)";
|
|
202
|
+
const day = formatDay(entry.metadata.createdAt);
|
|
203
|
+
rawChars += entry.metadata.rawChars;
|
|
204
|
+
reducedChars += reduced;
|
|
205
|
+
if (ratio !== null) {
|
|
206
|
+
ratioSum += ratio;
|
|
207
|
+
ratioCount += 1;
|
|
208
|
+
}
|
|
209
|
+
reducers.set(reducer, addToStatsGroup(reducers.get(reducer), entry.metadata.rawChars, reduced, ratio));
|
|
210
|
+
commands.set(signature, addToStatsGroup(commands.get(signature), entry.metadata.rawChars, reduced, ratio));
|
|
211
|
+
daily.set(day, addToStatsGroup(daily.get(day), entry.metadata.rawChars, reduced, ratio));
|
|
212
|
+
}
|
|
213
|
+
const totalSavedChars = Math.max(rawChars - reducedChars, 0);
|
|
214
|
+
const avgRatio = ratioCount > 0 ? ratioSum / ratioCount : null;
|
|
215
|
+
const savingsPercent = rawChars > 0 ? totalSavedChars / rawChars : null;
|
|
216
|
+
const observedSavedChars = Math.max(observedRawChars - observedReducedChars, 0);
|
|
217
|
+
const observedAvgRatio = observedRatioCount > 0 ? observedRatioSum / observedRatioCount : null;
|
|
218
|
+
const observedSavingsPercent = observedRawChars > 0 ? observedSavedChars / observedRawChars : null;
|
|
219
|
+
return {
|
|
220
|
+
...(source ? { source } : {}),
|
|
221
|
+
totals: {
|
|
222
|
+
observedEntries: entries.length,
|
|
223
|
+
captureTruncatedEntries,
|
|
224
|
+
observedRawChars,
|
|
225
|
+
observedReducedChars,
|
|
226
|
+
observedSavedChars,
|
|
227
|
+
observedAvgRatio,
|
|
228
|
+
observedSavingsPercent,
|
|
229
|
+
entries: entries.length - captureTruncatedEntries,
|
|
230
|
+
rawChars,
|
|
231
|
+
reducedChars,
|
|
232
|
+
savedChars: totalSavedChars,
|
|
233
|
+
avgRatio,
|
|
234
|
+
savingsPercent,
|
|
235
|
+
},
|
|
236
|
+
reducers: [...reducers.entries()]
|
|
237
|
+
.map(([reducer, group]) => ({
|
|
238
|
+
reducer,
|
|
239
|
+
count: group.count,
|
|
240
|
+
rawChars: group.rawChars,
|
|
241
|
+
reducedChars: group.reducedChars,
|
|
242
|
+
savedChars: Math.max(group.rawChars - group.reducedChars, 0),
|
|
243
|
+
avgRatio: avgRatioFromGroup(group),
|
|
244
|
+
}))
|
|
245
|
+
.sort((left, right) => right.savedChars - left.savedChars || right.count - left.count)
|
|
246
|
+
.slice(0, 10),
|
|
247
|
+
commands: [...commands.entries()]
|
|
248
|
+
.map(([signature, group]) => ({
|
|
249
|
+
signature,
|
|
250
|
+
count: group.count,
|
|
251
|
+
rawChars: group.rawChars,
|
|
252
|
+
reducedChars: group.reducedChars,
|
|
253
|
+
savedChars: Math.max(group.rawChars - group.reducedChars, 0),
|
|
254
|
+
avgRatio: avgRatioFromGroup(group),
|
|
255
|
+
}))
|
|
256
|
+
.sort((left, right) => right.savedChars - left.savedChars || right.count - left.count)
|
|
257
|
+
.slice(0, 10),
|
|
258
|
+
daily: [...daily.entries()]
|
|
259
|
+
.map(([day, group]) => ({
|
|
260
|
+
day,
|
|
261
|
+
count: group.count,
|
|
262
|
+
rawChars: group.rawChars,
|
|
263
|
+
reducedChars: group.reducedChars,
|
|
264
|
+
savedChars: Math.max(group.rawChars - group.reducedChars, 0),
|
|
265
|
+
}))
|
|
266
|
+
.sort((left, right) => left.day.localeCompare(right.day)),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
export function statsArtifacts(entries, options = {}) {
|
|
270
|
+
const filteredEntries = filterEntriesBySource(entries, options.source);
|
|
271
|
+
const report = buildStatsReport(filteredEntries, options, options.source ? readStoredArtifactSource(options.source) : undefined);
|
|
272
|
+
if (!options.bySource) {
|
|
273
|
+
return report;
|
|
274
|
+
}
|
|
275
|
+
const sources = [...new Set(filteredEntries.map((entry) => entrySource(entry)))]
|
|
276
|
+
.sort()
|
|
277
|
+
.map((source) => buildStatsReport(filteredEntries.filter((entry) => entrySource(entry) === source), options, source));
|
|
278
|
+
return {
|
|
279
|
+
...report,
|
|
280
|
+
sources,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
export function doctorArtifacts(entries) {
|
|
284
|
+
const ratios = entries
|
|
285
|
+
.map((entry) => effectiveRatio(entry.metadata))
|
|
286
|
+
.filter((ratio) => ratio !== null);
|
|
287
|
+
const discover = discoverCandidates(entries);
|
|
288
|
+
const reducerCounts = new Map();
|
|
289
|
+
for (const entry of entries) {
|
|
290
|
+
const reducer = entry.metadata.classification.matchedReducer ?? "generic/fallback";
|
|
291
|
+
reducerCounts.set(reducer, (reducerCounts.get(reducer) ?? 0) + 1);
|
|
292
|
+
}
|
|
293
|
+
const genericCount = entries.filter((entry) => GENERIC_REDUCERS.has(entry.metadata.classification.matchedReducer)).length;
|
|
294
|
+
const weakCount = discover.filter((candidate) => candidate.kind === "weak-rule").reduce((sum, candidate) => sum + candidate.count, 0);
|
|
295
|
+
const avgRatio = ratios.length > 0 ? ratios.reduce((sum, ratio) => sum + ratio, 0) / ratios.length : null;
|
|
296
|
+
const alerts = buildDoctorAlerts(entries, avgRatio, genericCount, weakCount);
|
|
297
|
+
return {
|
|
298
|
+
totals: {
|
|
299
|
+
entries: entries.length,
|
|
300
|
+
genericArtifacts: genericCount,
|
|
301
|
+
weakArtifacts: weakCount,
|
|
302
|
+
avgRatio,
|
|
303
|
+
},
|
|
304
|
+
health: alerts.health,
|
|
305
|
+
alerts: alerts.alerts,
|
|
306
|
+
topMissingCommands: discover.filter((candidate) => candidate.kind === "missing-rule").slice(0, 10),
|
|
307
|
+
topWeakReducers: discover.filter((candidate) => candidate.kind === "weak-rule").slice(0, 10),
|
|
308
|
+
topReducers: [...reducerCounts.entries()]
|
|
309
|
+
.map(([reducer, count]) => ({ reducer, count }))
|
|
310
|
+
.sort((left, right) => right.count - left.count)
|
|
311
|
+
.slice(0, 10),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ArtifactMetadataRef, StoredArtifact, StoredArtifactInput, StoredArtifactRef } from "../types.js";
|
|
2
|
+
export declare const ARTIFACT_DIR_ENV = "TOKENJUICE_ARTIFACT_DIR";
|
|
3
|
+
export declare function resolveArtifactBaseDir(storeDir?: string): string;
|
|
4
|
+
export declare function isValidArtifactId(id: string): boolean;
|
|
5
|
+
export declare function storeArtifact(input: StoredArtifactInput, storeDir?: string): Promise<StoredArtifactRef>;
|
|
6
|
+
export declare function storeArtifactMetadata(input: StoredArtifactInput, storeDir?: string): Promise<ArtifactMetadataRef>;
|
|
7
|
+
export declare function getArtifact(id: string, storeDir?: string): Promise<StoredArtifact | null>;
|
|
8
|
+
export declare function listArtifacts(storeDir?: string): Promise<StoredArtifactRef[]>;
|
|
9
|
+
export declare function listArtifactMetadata(storeDir?: string): Promise<ArtifactMetadataRef[]>;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { countTextChars, stripAnsi } from "./text.js";
|
|
6
|
+
import { resolveArtifactSource } from "./source.js";
|
|
7
|
+
const ARTIFACT_ID_PATTERN = /^tj_[0-9a-f-]{12}$/iu;
|
|
8
|
+
export const ARTIFACT_DIR_ENV = "TOKENJUICE_ARTIFACT_DIR";
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function isStoredArtifactMetadata(value) {
|
|
13
|
+
if (!isRecord(value) || typeof value.createdAt !== "string" || typeof value.rawChars !== "number") {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (!isRecord(value.classification) || typeof value.classification.family !== "string" || typeof value.classification.confidence !== "number") {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if ("matchedReducer" in value.classification && value.classification.matchedReducer !== undefined && typeof value.classification.matchedReducer !== "string") {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if ("toolName" in value && value.toolName !== undefined && typeof value.toolName !== "string") {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if ("source" in value && value.source !== undefined && typeof value.source !== "string") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if ("command" in value && value.command !== undefined && typeof value.command !== "string") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if ("exitCode" in value && value.exitCode !== undefined && typeof value.exitCode !== "number") {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if ("captureTruncated" in value && value.captureTruncated !== undefined && typeof value.captureTruncated !== "boolean") {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if ("reducedChars" in value && value.reducedChars !== undefined && typeof value.reducedChars !== "number") {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if ("ratio" in value && value.ratio !== undefined && typeof value.ratio !== "number") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
function extractCaptureTruncatedFlag(input) {
|
|
46
|
+
const value = input.metadata?.tokenjuiceCaptureTruncated;
|
|
47
|
+
return typeof value === "boolean" ? value : undefined;
|
|
48
|
+
}
|
|
49
|
+
function getDefaultArtifactDir() {
|
|
50
|
+
const artifactDir = process.env[ARTIFACT_DIR_ENV];
|
|
51
|
+
if (typeof artifactDir === "string" && artifactDir.trim()) {
|
|
52
|
+
return artifactDir.trim();
|
|
53
|
+
}
|
|
54
|
+
return join(homedir(), ".tokenjuice", "artifacts");
|
|
55
|
+
}
|
|
56
|
+
export function resolveArtifactBaseDir(storeDir) {
|
|
57
|
+
return storeDir ?? getDefaultArtifactDir();
|
|
58
|
+
}
|
|
59
|
+
export function isValidArtifactId(id) {
|
|
60
|
+
return ARTIFACT_ID_PATTERN.test(id);
|
|
61
|
+
}
|
|
62
|
+
function buildArtifactPaths(id, storeDir) {
|
|
63
|
+
if (!isValidArtifactId(id)) {
|
|
64
|
+
throw new Error(`invalid artifact id: ${id}`);
|
|
65
|
+
}
|
|
66
|
+
const base = resolveArtifactBaseDir(storeDir);
|
|
67
|
+
return {
|
|
68
|
+
id,
|
|
69
|
+
storage: "file",
|
|
70
|
+
path: join(base, `${id}.txt`),
|
|
71
|
+
metadataPath: join(base, `${id}.json`),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function buildMetadataOnlyPath(id, storeDir) {
|
|
75
|
+
if (!isValidArtifactId(id)) {
|
|
76
|
+
throw new Error(`invalid artifact id: ${id}`);
|
|
77
|
+
}
|
|
78
|
+
return join(resolveArtifactBaseDir(storeDir), `${id}.meta.json`);
|
|
79
|
+
}
|
|
80
|
+
export async function storeArtifact(input, storeDir) {
|
|
81
|
+
const id = `tj_${randomUUID().slice(0, 12)}`;
|
|
82
|
+
const ref = buildArtifactPaths(id, storeDir);
|
|
83
|
+
await mkdir(resolveArtifactBaseDir(storeDir), { recursive: true, mode: 0o700 });
|
|
84
|
+
const captureTruncated = extractCaptureTruncatedFlag(input.input);
|
|
85
|
+
const artifact = {
|
|
86
|
+
id,
|
|
87
|
+
rawText: input.rawText,
|
|
88
|
+
metadata: {
|
|
89
|
+
createdAt: new Date().toISOString(),
|
|
90
|
+
source: resolveArtifactSource(input.input),
|
|
91
|
+
classification: input.classification,
|
|
92
|
+
rawChars: input.stats?.rawChars ?? countTextChars(stripAnsi(input.rawText)),
|
|
93
|
+
...(input.input.toolName ? { toolName: input.input.toolName } : {}),
|
|
94
|
+
...(input.input.command ? { command: input.input.command } : {}),
|
|
95
|
+
...(typeof input.input.exitCode === "number" ? { exitCode: input.input.exitCode } : {}),
|
|
96
|
+
...(captureTruncated !== undefined ? { captureTruncated } : {}),
|
|
97
|
+
...(input.stats ? { reducedChars: input.stats.reducedChars, ratio: input.stats.ratio } : {}),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
await Promise.all([
|
|
101
|
+
writeFile(ref.path, input.rawText, { encoding: "utf8", mode: 0o600 }),
|
|
102
|
+
writeFile(ref.metadataPath, JSON.stringify(artifact.metadata, null, 2), { encoding: "utf8", mode: 0o600 }),
|
|
103
|
+
]);
|
|
104
|
+
return ref;
|
|
105
|
+
}
|
|
106
|
+
export async function storeArtifactMetadata(input, storeDir) {
|
|
107
|
+
const id = `tj_${randomUUID().slice(0, 12)}`;
|
|
108
|
+
const metadataPath = buildMetadataOnlyPath(id, storeDir);
|
|
109
|
+
const captureTruncated = extractCaptureTruncatedFlag(input.input);
|
|
110
|
+
const metadata = {
|
|
111
|
+
createdAt: new Date().toISOString(),
|
|
112
|
+
source: resolveArtifactSource(input.input),
|
|
113
|
+
classification: input.classification,
|
|
114
|
+
rawChars: input.stats?.rawChars ?? countTextChars(stripAnsi(input.rawText)),
|
|
115
|
+
...(input.input.toolName ? { toolName: input.input.toolName } : {}),
|
|
116
|
+
...(input.input.command ? { command: input.input.command } : {}),
|
|
117
|
+
...(typeof input.input.exitCode === "number" ? { exitCode: input.input.exitCode } : {}),
|
|
118
|
+
...(captureTruncated !== undefined ? { captureTruncated } : {}),
|
|
119
|
+
...(input.stats ? { reducedChars: input.stats.reducedChars, ratio: input.stats.ratio } : {}),
|
|
120
|
+
};
|
|
121
|
+
await mkdir(resolveArtifactBaseDir(storeDir), { recursive: true, mode: 0o700 });
|
|
122
|
+
await writeFile(metadataPath, JSON.stringify(metadata, null, 2), { encoding: "utf8", mode: 0o600 });
|
|
123
|
+
return {
|
|
124
|
+
id,
|
|
125
|
+
storage: "file",
|
|
126
|
+
metadataPath,
|
|
127
|
+
metadata,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export async function getArtifact(id, storeDir) {
|
|
131
|
+
if (!isValidArtifactId(id)) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const ref = buildArtifactPaths(id, storeDir);
|
|
135
|
+
try {
|
|
136
|
+
const [rawText, metadataRaw] = await Promise.all([
|
|
137
|
+
readFile(ref.path, "utf8"),
|
|
138
|
+
readFile(ref.metadataPath, "utf8"),
|
|
139
|
+
]);
|
|
140
|
+
return {
|
|
141
|
+
id,
|
|
142
|
+
rawText,
|
|
143
|
+
metadata: (() => {
|
|
144
|
+
const parsed = JSON.parse(metadataRaw);
|
|
145
|
+
if (!isStoredArtifactMetadata(parsed)) {
|
|
146
|
+
throw new Error("invalid artifact metadata");
|
|
147
|
+
}
|
|
148
|
+
return parsed;
|
|
149
|
+
})(),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export async function listArtifacts(storeDir) {
|
|
157
|
+
const base = resolveArtifactBaseDir(storeDir);
|
|
158
|
+
try {
|
|
159
|
+
const files = await readdir(base);
|
|
160
|
+
return files
|
|
161
|
+
.filter((name) => name.endsWith(".json"))
|
|
162
|
+
.map((name) => name.replace(/\.json$/u, ""))
|
|
163
|
+
.filter((id) => isValidArtifactId(id))
|
|
164
|
+
.sort()
|
|
165
|
+
.reverse()
|
|
166
|
+
.map((id) => buildArtifactPaths(id, storeDir));
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export async function listArtifactMetadata(storeDir) {
|
|
173
|
+
const base = resolveArtifactBaseDir(storeDir);
|
|
174
|
+
try {
|
|
175
|
+
const files = await readdir(base);
|
|
176
|
+
const metadata = await Promise.all(files
|
|
177
|
+
.filter((name) => name.endsWith(".json"))
|
|
178
|
+
.map(async (name) => {
|
|
179
|
+
const rawId = name.endsWith(".meta.json") ? name.replace(/\.meta\.json$/u, "") : name.replace(/\.json$/u, "");
|
|
180
|
+
if (!isValidArtifactId(rawId)) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
const metadataPath = join(base, name);
|
|
184
|
+
try {
|
|
185
|
+
const raw = await readFile(metadataPath, "utf8");
|
|
186
|
+
const parsed = JSON.parse(raw);
|
|
187
|
+
if (!isStoredArtifactMetadata(parsed)) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const path = name.endsWith(".meta.json") ? undefined : join(base, `${rawId}.txt`);
|
|
191
|
+
return {
|
|
192
|
+
id: rawId,
|
|
193
|
+
storage: "file",
|
|
194
|
+
...(path ? { path } : {}),
|
|
195
|
+
metadataPath,
|
|
196
|
+
metadata: parsed,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}));
|
|
203
|
+
return metadata
|
|
204
|
+
.filter((entry) => entry !== null)
|
|
205
|
+
.sort((left, right) => right.metadata.createdAt.localeCompare(left.metadata.createdAt));
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
}
|