@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,671 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { lstat, mkdir, readFile, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { buildTokenjuiceGuidanceBullets, TOKENJUICE_FULL_COMMAND, TOKENJUICE_RAW_COMMAND, TOKENJUICE_WRAP_COMMAND } from "../shared/instruction-guidance.js";
|
|
5
|
+
import { collectGuidanceIssues, readInstructionFile, removeInstructionFile, writeInstructionFile } from "../shared/instruction-file.js";
|
|
6
|
+
import { buildInstructionDoctorReportFields, instructionDoctorStatusFromIssues, } from "../shared/instruction-doctor.js";
|
|
7
|
+
import { isRecord } from "../shared/hooks-json-file.js";
|
|
8
|
+
const TOKENJUICE_AETHER_FIX_COMMAND = "tokenjuice install aether";
|
|
9
|
+
const TOKENJUICE_AETHER_INIT_FIX_COMMAND = "run aether once to create .aether/settings.json, then run tokenjuice install aether";
|
|
10
|
+
const TOKENJUICE_AETHER_PROMPT_SOURCE = ".aether/tokenjuice.md";
|
|
11
|
+
const TOKENJUICE_AETHER_MARKER = "tokenjuice Aether terminal output compaction";
|
|
12
|
+
const TOKENJUICE_AETHER_RESTORE_BACKUP_MARKER_PREFIX = "<!-- tokenjuice:aether-restore-backup=";
|
|
13
|
+
const TOKENJUICE_AETHER_SETTINGS_REFS_MARKER_PREFIX = "<!-- tokenjuice:aether-settings-added=";
|
|
14
|
+
const TOKENJUICE_AETHER_ADVISORY = "Aether support is beta and prompt-source based; tokenjuice adds `.aether/tokenjuice.md` to every configured Aether agent's prompts array.";
|
|
15
|
+
const TOKENJUICE_AETHER_UNINITIALIZED_ISSUE = "Aether project is not initialized; run `aether` once before installing tokenjuice prompt guidance";
|
|
16
|
+
function isTokenjuiceAetherPromptText(text) {
|
|
17
|
+
return text.includes(TOKENJUICE_AETHER_MARKER);
|
|
18
|
+
}
|
|
19
|
+
function readRestoreBackupSuffix(text) {
|
|
20
|
+
const match = text.match(/^<!-- tokenjuice:aether-restore-backup=(\.bak(?:\.\d+)?) -->$/mu);
|
|
21
|
+
return match?.[1];
|
|
22
|
+
}
|
|
23
|
+
function emptySettingsRefsAdded() {
|
|
24
|
+
return { topLevel: false, agents: [] };
|
|
25
|
+
}
|
|
26
|
+
function mergeSettingsRefsAdded(first, second) {
|
|
27
|
+
return {
|
|
28
|
+
topLevel: first.topLevel || second.topLevel,
|
|
29
|
+
agents: [...first.agents, ...second.agents],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function serializeSettingsRefsAdded(refs) {
|
|
33
|
+
return JSON.stringify({ topLevel: refs.topLevel, agents: refs.agents });
|
|
34
|
+
}
|
|
35
|
+
function readSettingsRefsAdded(text) {
|
|
36
|
+
const match = text.match(/^<!-- tokenjuice:aether-settings-added=(\{.*\}) -->$/mu);
|
|
37
|
+
if (!match?.[1]) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const parsed = JSON.parse(match[1]);
|
|
42
|
+
if (!isRecord(parsed) || typeof parsed.topLevel !== "boolean" || !Array.isArray(parsed.agents)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const agents = parsed.agents.filter((agent) => typeof agent === "string" && agent.length > 0);
|
|
46
|
+
return { topLevel: parsed.topLevel, agents };
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function canonicalizeJson(value) {
|
|
53
|
+
if (Array.isArray(value)) {
|
|
54
|
+
return value.map((entry) => canonicalizeJson(entry));
|
|
55
|
+
}
|
|
56
|
+
if (isRecord(value)) {
|
|
57
|
+
return Object.fromEntries(Object.keys(value)
|
|
58
|
+
.sort()
|
|
59
|
+
.map((key) => [key, canonicalizeJson(value[key])]));
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
function agentOwnershipDescriptor(agent) {
|
|
64
|
+
if (typeof agent.name === "string" && agent.name.trim()) {
|
|
65
|
+
return { name: agent.name };
|
|
66
|
+
}
|
|
67
|
+
const prompts = Array.isArray(agent.prompts)
|
|
68
|
+
? agent.prompts.filter((prompt) => typeof prompt === "string" && prompt !== TOKENJUICE_AETHER_PROMPT_SOURCE)
|
|
69
|
+
: [];
|
|
70
|
+
if (prompts.length > 0) {
|
|
71
|
+
return { prompts };
|
|
72
|
+
}
|
|
73
|
+
return { anonymous: true };
|
|
74
|
+
}
|
|
75
|
+
function agentOwnershipSignature(agent) {
|
|
76
|
+
const descriptor = JSON.stringify(canonicalizeJson(agentOwnershipDescriptor(agent)));
|
|
77
|
+
return createHash("sha256").update(descriptor).digest("hex");
|
|
78
|
+
}
|
|
79
|
+
function getExplicitProjectDir(options = {}) {
|
|
80
|
+
return options.projectDir || process.env.AETHER_PROJECT_DIR;
|
|
81
|
+
}
|
|
82
|
+
async function hasGitMetadata(dir) {
|
|
83
|
+
try {
|
|
84
|
+
await stat(join(dir, ".git"));
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function findGitRoot(startDir) {
|
|
92
|
+
let current = resolve(startDir);
|
|
93
|
+
while (true) {
|
|
94
|
+
if (await hasGitMetadata(current)) {
|
|
95
|
+
return current;
|
|
96
|
+
}
|
|
97
|
+
const parent = dirname(current);
|
|
98
|
+
if (parent === current) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
current = parent;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function pathExists(path) {
|
|
105
|
+
try {
|
|
106
|
+
await stat(path);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (error.code === "ENOENT") {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function backupPathExists(backupPath) {
|
|
117
|
+
try {
|
|
118
|
+
await lstat(backupPath);
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
if (error.code === "ENOENT") {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function chooseAetherBackupPath(filePath) {
|
|
129
|
+
for (let index = 0;; index += 1) {
|
|
130
|
+
const candidate = index === 0 ? `${filePath}.bak` : `${filePath}.bak.${index}`;
|
|
131
|
+
if (!(await backupPathExists(candidate))) {
|
|
132
|
+
return candidate;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async function resolveProjectDir(options = {}) {
|
|
137
|
+
const explicitProjectDir = getExplicitProjectDir(options);
|
|
138
|
+
if (explicitProjectDir) {
|
|
139
|
+
return resolve(explicitProjectDir);
|
|
140
|
+
}
|
|
141
|
+
return (await findGitRoot(process.cwd())) ?? process.cwd();
|
|
142
|
+
}
|
|
143
|
+
function isInsideOrEqual(parentDir, childPath) {
|
|
144
|
+
const relativePath = relative(parentDir, childPath);
|
|
145
|
+
return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
|
|
146
|
+
}
|
|
147
|
+
async function realpathExistingAncestor(path) {
|
|
148
|
+
let current = path;
|
|
149
|
+
while (true) {
|
|
150
|
+
try {
|
|
151
|
+
return await realpath(current);
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (error.code !== "ENOENT") {
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
const parent = dirname(current);
|
|
158
|
+
if (parent === current) {
|
|
159
|
+
throw error;
|
|
160
|
+
}
|
|
161
|
+
current = parent;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function rejectAetherPathSymlink(filePath) {
|
|
166
|
+
try {
|
|
167
|
+
const stats = await lstat(filePath);
|
|
168
|
+
if (stats.isSymbolicLink()) {
|
|
169
|
+
throw new Error(`cannot use Aether source ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
if (error.code === "ENOENT") {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async function rejectInstallSidecarSymlinks(filePath) {
|
|
180
|
+
await rejectAetherPathSymlink(`${filePath}.bak`);
|
|
181
|
+
await rejectAetherPathSymlink(`${filePath}.tmp`);
|
|
182
|
+
}
|
|
183
|
+
async function rejectSymlinkPathComponents(filePath, projectDir) {
|
|
184
|
+
const relativePath = relative(projectDir, filePath);
|
|
185
|
+
const segments = relativePath.split(sep).filter(Boolean);
|
|
186
|
+
let currentPath = projectDir;
|
|
187
|
+
for (const segment of segments.slice(0, -1)) {
|
|
188
|
+
currentPath = join(currentPath, segment);
|
|
189
|
+
try {
|
|
190
|
+
const stats = await lstat(currentPath);
|
|
191
|
+
if (stats.isSymbolicLink()) {
|
|
192
|
+
throw new Error(`cannot use Aether source ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
if (error.code === "ENOENT") {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function resolveSafeProjectPath(filePath, projectDir, realProjectDir = projectDir) {
|
|
204
|
+
const resolvedPath = resolve(filePath);
|
|
205
|
+
const realParentDir = await realpathExistingAncestor(dirname(resolvedPath));
|
|
206
|
+
if (!isInsideOrEqual(realProjectDir, realParentDir)) {
|
|
207
|
+
throw new Error(`cannot use Aether source ${resolvedPath}; tokenjuice will not write through instruction directories outside ${realProjectDir}`);
|
|
208
|
+
}
|
|
209
|
+
await rejectSymlinkPathComponents(resolvedPath, projectDir);
|
|
210
|
+
await rejectAetherPathSymlink(resolvedPath);
|
|
211
|
+
return resolvedPath;
|
|
212
|
+
}
|
|
213
|
+
async function resolveAetherPaths(promptPath, options = {}) {
|
|
214
|
+
const projectDir = await resolveProjectDir(options);
|
|
215
|
+
const realProjectDir = await realpath(projectDir).catch(() => projectDir);
|
|
216
|
+
const defaultPromptPath = resolve(projectDir, ".aether", "tokenjuice.md");
|
|
217
|
+
const requestedPromptPath = promptPath ? resolve(promptPath) : defaultPromptPath;
|
|
218
|
+
const resolvedPromptPath = await resolveSafeProjectPath(requestedPromptPath, projectDir, realProjectDir);
|
|
219
|
+
if (resolvedPromptPath !== defaultPromptPath) {
|
|
220
|
+
throw new Error(`cannot use Aether source ${resolvedPromptPath}; Aether settings load ${TOKENJUICE_AETHER_PROMPT_SOURCE}`);
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
promptPath: resolvedPromptPath,
|
|
224
|
+
settingsPath: await resolveSafeProjectPath(join(projectDir, ".aether", "settings.json"), projectDir, realProjectDir),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
async function getDefaultAliasPaths(promptPath, options = {}) {
|
|
228
|
+
const projectDir = await resolveProjectDir(options);
|
|
229
|
+
return {
|
|
230
|
+
promptPath: promptPath ? resolve(promptPath) : join(projectDir, ".aether", "tokenjuice.md"),
|
|
231
|
+
settingsPath: join(projectDir, ".aether", "settings.json"),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
async function hasPromptUnderSymlinkedParent(promptPath) {
|
|
235
|
+
try {
|
|
236
|
+
const parentStats = await lstat(dirname(promptPath));
|
|
237
|
+
if (!parentStats.isSymbolicLink()) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
const prompt = await readInstructionFile(promptPath);
|
|
241
|
+
return prompt.exists && prompt.text.includes(TOKENJUICE_AETHER_MARKER);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
if (error.code === "ENOENT") {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
async function detectAetherInstallEvidence(promptPath, settingsPath, options = {}) {
|
|
251
|
+
const projectDir = await resolveProjectDir(options);
|
|
252
|
+
const realProjectDir = await realpath(projectDir).catch(() => projectDir);
|
|
253
|
+
const safeSettingsPath = await resolveSafeProjectPath(settingsPath, projectDir, realProjectDir).catch(() => undefined);
|
|
254
|
+
if (safeSettingsPath) {
|
|
255
|
+
try {
|
|
256
|
+
const settings = await readAetherSettings(safeSettingsPath);
|
|
257
|
+
if (settings.exists && settingsLoadsPromptSource(settings.config)) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
// Broken settings still allow prompt-marker evidence below.
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
const safePromptPath = await resolveSafeProjectPath(promptPath, projectDir, realProjectDir).catch(() => undefined);
|
|
266
|
+
if (safePromptPath) {
|
|
267
|
+
const prompt = await readInstructionFile(safePromptPath);
|
|
268
|
+
if (prompt.exists && isTokenjuiceAetherPromptText(prompt.text)) {
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return hasPromptUnderSymlinkedParent(promptPath);
|
|
273
|
+
}
|
|
274
|
+
async function readAetherSettings(settingsPath) {
|
|
275
|
+
try {
|
|
276
|
+
const text = await readFile(settingsPath, "utf8");
|
|
277
|
+
const parsed = JSON.parse(text);
|
|
278
|
+
if (!isRecord(parsed)) {
|
|
279
|
+
throw new Error(`configured Aether settings at ${settingsPath} must be a JSON object`);
|
|
280
|
+
}
|
|
281
|
+
return { config: parsed, text, exists: true };
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
if (error.code === "ENOENT") {
|
|
285
|
+
return { config: {}, text: "", exists: false };
|
|
286
|
+
}
|
|
287
|
+
if (error instanceof SyntaxError) {
|
|
288
|
+
throw new Error(`configured Aether settings at ${settingsPath} are not valid JSON`);
|
|
289
|
+
}
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function agentLabel(agent, index) {
|
|
294
|
+
return typeof agent.name === "string" && agent.name.trim() ? agent.name : `#${index + 1}`;
|
|
295
|
+
}
|
|
296
|
+
function getPromptIssues(config) {
|
|
297
|
+
if (config.prompts !== undefined && !Array.isArray(config.prompts)) {
|
|
298
|
+
return ["configured Aether settings have a non-array top-level prompts field"];
|
|
299
|
+
}
|
|
300
|
+
if (!Array.isArray(config.agents)) {
|
|
301
|
+
return ["configured Aether settings are missing an agents array"];
|
|
302
|
+
}
|
|
303
|
+
if (config.agents.length === 0) {
|
|
304
|
+
return ["configured Aether settings do not define any agents"];
|
|
305
|
+
}
|
|
306
|
+
const issues = [];
|
|
307
|
+
for (const [index, agent] of config.agents.entries()) {
|
|
308
|
+
if (!isRecord(agent)) {
|
|
309
|
+
issues.push(`configured Aether agent #${index + 1} is not an object`);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
if (agent.prompts === undefined && Array.isArray(config.prompts) && config.prompts.includes(TOKENJUICE_AETHER_PROMPT_SOURCE)) {
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (!Array.isArray(agent.prompts)) {
|
|
316
|
+
issues.push(`configured Aether agent ${agentLabel(agent, index)} is missing a prompts array`);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (!agent.prompts.includes(TOKENJUICE_AETHER_PROMPT_SOURCE)) {
|
|
320
|
+
issues.push(`configured Aether agent ${agentLabel(agent, index)} does not load ${TOKENJUICE_AETHER_PROMPT_SOURCE}`);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return issues;
|
|
324
|
+
}
|
|
325
|
+
function settingsLoadsPromptSource(config) {
|
|
326
|
+
return (Array.isArray(config.prompts) && config.prompts.includes(TOKENJUICE_AETHER_PROMPT_SOURCE))
|
|
327
|
+
|| Array.isArray(config.agents)
|
|
328
|
+
&& config.agents.some((agent) => isRecord(agent)
|
|
329
|
+
&& Array.isArray(agent.prompts)
|
|
330
|
+
&& agent.prompts.includes(TOKENJUICE_AETHER_PROMPT_SOURCE));
|
|
331
|
+
}
|
|
332
|
+
function addPromptSourceToAgents(config) {
|
|
333
|
+
if (config.prompts !== undefined && !Array.isArray(config.prompts)) {
|
|
334
|
+
throw new Error("cannot install Aether prompt because .aether/settings.json has a non-array top-level prompts field");
|
|
335
|
+
}
|
|
336
|
+
if (!Array.isArray(config.agents)) {
|
|
337
|
+
throw new Error("cannot install Aether prompt because .aether/settings.json is missing an agents array");
|
|
338
|
+
}
|
|
339
|
+
if (config.agents.length === 0) {
|
|
340
|
+
throw new Error("cannot install Aether prompt because .aether/settings.json does not define any agents");
|
|
341
|
+
}
|
|
342
|
+
let updated = 0;
|
|
343
|
+
const refsAdded = emptySettingsRefsAdded();
|
|
344
|
+
const topLevelPrompts = Array.isArray(config.prompts) ? config.prompts : undefined;
|
|
345
|
+
const preExistingPromptSourceSignatures = new Set();
|
|
346
|
+
for (const agent of config.agents) {
|
|
347
|
+
if (isRecord(agent) && Array.isArray(agent.prompts) && agent.prompts.includes(TOKENJUICE_AETHER_PROMPT_SOURCE)) {
|
|
348
|
+
preExistingPromptSourceSignatures.add(agentOwnershipSignature(agent));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (topLevelPrompts && !topLevelPrompts.includes(TOKENJUICE_AETHER_PROMPT_SOURCE)) {
|
|
352
|
+
config.prompts = [...topLevelPrompts, TOKENJUICE_AETHER_PROMPT_SOURCE];
|
|
353
|
+
refsAdded.topLevel = true;
|
|
354
|
+
}
|
|
355
|
+
config.agents = config.agents.map((agent, index) => {
|
|
356
|
+
if (!isRecord(agent)) {
|
|
357
|
+
throw new Error(`cannot install Aether prompt because configured Aether agent #${index + 1} is not an object`);
|
|
358
|
+
}
|
|
359
|
+
if (topLevelPrompts && agent.prompts === undefined) {
|
|
360
|
+
return agent;
|
|
361
|
+
}
|
|
362
|
+
if (agent.prompts !== undefined && !Array.isArray(agent.prompts)) {
|
|
363
|
+
throw new Error(`cannot install Aether prompt because configured Aether agent ${agentLabel(agent, index)} has a non-array prompts field`);
|
|
364
|
+
}
|
|
365
|
+
const prompts = Array.isArray(agent.prompts) ? [...agent.prompts] : [];
|
|
366
|
+
if (!prompts.includes(TOKENJUICE_AETHER_PROMPT_SOURCE)) {
|
|
367
|
+
const ownershipSignature = agentOwnershipSignature(agent);
|
|
368
|
+
if (preExistingPromptSourceSignatures.has(ownershipSignature)) {
|
|
369
|
+
throw new Error(`cannot install Aether prompt because configured Aether agent ${agentLabel(agent, index)} has duplicate ownership for ${TOKENJUICE_AETHER_PROMPT_SOURCE}`);
|
|
370
|
+
}
|
|
371
|
+
refsAdded.agents.push(ownershipSignature);
|
|
372
|
+
prompts.push(TOKENJUICE_AETHER_PROMPT_SOURCE);
|
|
373
|
+
updated += 1;
|
|
374
|
+
}
|
|
375
|
+
return { ...agent, prompts };
|
|
376
|
+
});
|
|
377
|
+
return { agentsUpdated: updated, refsAdded };
|
|
378
|
+
}
|
|
379
|
+
function removePromptSourceFromAgents(config, refsAdded, { removeAll } = {}) {
|
|
380
|
+
if (!refsAdded && !removeAll) {
|
|
381
|
+
return 0;
|
|
382
|
+
}
|
|
383
|
+
let removed = 0;
|
|
384
|
+
if (Array.isArray(config.prompts) && (removeAll || refsAdded?.topLevel)) {
|
|
385
|
+
config.prompts = config.prompts.filter((prompt) => {
|
|
386
|
+
const shouldRemove = prompt === TOKENJUICE_AETHER_PROMPT_SOURCE;
|
|
387
|
+
if (shouldRemove) {
|
|
388
|
+
removed += 1;
|
|
389
|
+
}
|
|
390
|
+
return !shouldRemove;
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
if (!Array.isArray(config.agents)) {
|
|
394
|
+
return removed;
|
|
395
|
+
}
|
|
396
|
+
const removableAgentSignatures = new Map();
|
|
397
|
+
for (const signature of refsAdded?.agents ?? []) {
|
|
398
|
+
removableAgentSignatures.set(signature, (removableAgentSignatures.get(signature) ?? 0) + 1);
|
|
399
|
+
}
|
|
400
|
+
config.agents = config.agents.map((agent) => {
|
|
401
|
+
if (!isRecord(agent) || !Array.isArray(agent.prompts)) {
|
|
402
|
+
return agent;
|
|
403
|
+
}
|
|
404
|
+
if (!removeAll) {
|
|
405
|
+
const signature = agentOwnershipSignature(agent);
|
|
406
|
+
const remainingMatches = removableAgentSignatures.get(signature) ?? 0;
|
|
407
|
+
if (remainingMatches <= 0) {
|
|
408
|
+
return agent;
|
|
409
|
+
}
|
|
410
|
+
removableAgentSignatures.set(signature, remainingMatches - 1);
|
|
411
|
+
}
|
|
412
|
+
const prompts = agent.prompts.filter((prompt) => {
|
|
413
|
+
const shouldRemove = prompt === TOKENJUICE_AETHER_PROMPT_SOURCE;
|
|
414
|
+
if (shouldRemove) {
|
|
415
|
+
removed += 1;
|
|
416
|
+
}
|
|
417
|
+
return !shouldRemove;
|
|
418
|
+
});
|
|
419
|
+
if (prompts.length === 0 && config.prompts === undefined) {
|
|
420
|
+
const withoutPrompts = { ...agent };
|
|
421
|
+
delete withoutPrompts.prompts;
|
|
422
|
+
return withoutPrompts;
|
|
423
|
+
}
|
|
424
|
+
return { ...agent, prompts };
|
|
425
|
+
});
|
|
426
|
+
return removed;
|
|
427
|
+
}
|
|
428
|
+
async function writeTextFileWithoutBackup(filePath, text) {
|
|
429
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
430
|
+
const tempPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
431
|
+
await writeFile(tempPath, text, { encoding: "utf8", flag: "wx" });
|
|
432
|
+
try {
|
|
433
|
+
await rename(tempPath, filePath);
|
|
434
|
+
}
|
|
435
|
+
catch (error) {
|
|
436
|
+
await rm(tempPath, { force: true });
|
|
437
|
+
throw error;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
async function writeAetherSettings(settingsPath, config) {
|
|
441
|
+
await mkdir(dirname(settingsPath), { recursive: true });
|
|
442
|
+
await writeTextFileWithoutBackup(settingsPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
443
|
+
}
|
|
444
|
+
async function readRequiredAetherSettings(settingsPath) {
|
|
445
|
+
const existing = await readAetherSettings(settingsPath);
|
|
446
|
+
if (!existing.exists) {
|
|
447
|
+
throw new Error(`cannot install Aether prompt because ${settingsPath} does not exist; run aether once, then rerun tokenjuice install aether`);
|
|
448
|
+
}
|
|
449
|
+
return { config: existing.config, text: existing.text };
|
|
450
|
+
}
|
|
451
|
+
async function backupAetherFile(filePath, text) {
|
|
452
|
+
const backupPath = await chooseAetherBackupPath(filePath);
|
|
453
|
+
await writeFile(backupPath, text, { encoding: "utf8", flag: "wx" });
|
|
454
|
+
return backupPath;
|
|
455
|
+
}
|
|
456
|
+
function buildAetherPrompt({ restoreBackupSuffix, settingsRefsAdded = emptySettingsRefsAdded(), } = {}) {
|
|
457
|
+
return [
|
|
458
|
+
...(restoreBackupSuffix
|
|
459
|
+
? [`${TOKENJUICE_AETHER_RESTORE_BACKUP_MARKER_PREFIX}${restoreBackupSuffix} -->`, ""]
|
|
460
|
+
: []),
|
|
461
|
+
`${TOKENJUICE_AETHER_SETTINGS_REFS_MARKER_PREFIX}${serializeSettingsRefsAdded(settingsRefsAdded)} -->`,
|
|
462
|
+
"",
|
|
463
|
+
`# ${TOKENJUICE_AETHER_MARKER}`,
|
|
464
|
+
"",
|
|
465
|
+
...buildTokenjuiceGuidanceBullets({
|
|
466
|
+
wrapBullet: "- When an Aether agent runs terminal commands likely to produce long output, prefer `tokenjuice wrap -- <command>`.",
|
|
467
|
+
}),
|
|
468
|
+
"- This file is loaded through `.aether/settings.json` as an agent prompt source.",
|
|
469
|
+
"- Verify the active prompt with `aether show-prompt -a <agent>` after installing.",
|
|
470
|
+
"",
|
|
471
|
+
].join("\n");
|
|
472
|
+
}
|
|
473
|
+
export async function installAetherPrompt(promptPath, options = {}) {
|
|
474
|
+
const { promptPath: resolvedPromptPath, settingsPath } = await resolveAetherPaths(promptPath, options);
|
|
475
|
+
await rejectInstallSidecarSymlinks(resolvedPromptPath);
|
|
476
|
+
await rejectInstallSidecarSymlinks(settingsPath);
|
|
477
|
+
const settings = await readRequiredAetherSettings(settingsPath);
|
|
478
|
+
const beforeConfig = JSON.stringify(settings.config);
|
|
479
|
+
const { agentsUpdated, refsAdded } = addPromptSourceToAgents(settings.config);
|
|
480
|
+
const settingsChanged = beforeConfig !== JSON.stringify(settings.config);
|
|
481
|
+
let settingsBackupPath;
|
|
482
|
+
if (settingsChanged) {
|
|
483
|
+
settingsBackupPath = await backupAetherFile(settingsPath, settings.text);
|
|
484
|
+
}
|
|
485
|
+
const existingPrompt = await readInstructionFile(resolvedPromptPath);
|
|
486
|
+
let promptBackupPath;
|
|
487
|
+
if (existingPrompt.exists && isTokenjuiceAetherPromptText(existingPrompt.text)) {
|
|
488
|
+
const restoreBackupSuffix = readRestoreBackupSuffix(existingPrompt.text);
|
|
489
|
+
const settingsRefsAdded = mergeSettingsRefsAdded(readSettingsRefsAdded(existingPrompt.text) ?? emptySettingsRefsAdded(), refsAdded);
|
|
490
|
+
const nextPrompt = buildAetherPrompt({ restoreBackupSuffix, settingsRefsAdded });
|
|
491
|
+
if (existingPrompt.text !== nextPrompt) {
|
|
492
|
+
const promptResult = await writeInstructionFile(resolvedPromptPath, nextPrompt);
|
|
493
|
+
promptBackupPath = promptResult.backupPath;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else if (existingPrompt.exists) {
|
|
497
|
+
promptBackupPath = await backupAetherFile(resolvedPromptPath, existingPrompt.text);
|
|
498
|
+
await writeTextFileWithoutBackup(resolvedPromptPath, buildAetherPrompt({
|
|
499
|
+
restoreBackupSuffix: promptBackupPath.slice(resolvedPromptPath.length),
|
|
500
|
+
settingsRefsAdded: refsAdded,
|
|
501
|
+
}));
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
await writeTextFileWithoutBackup(resolvedPromptPath, buildAetherPrompt({ settingsRefsAdded: refsAdded }));
|
|
505
|
+
}
|
|
506
|
+
if (settingsChanged) {
|
|
507
|
+
await writeAetherSettings(settingsPath, settings.config);
|
|
508
|
+
}
|
|
509
|
+
return {
|
|
510
|
+
promptPath: resolvedPromptPath,
|
|
511
|
+
settingsPath,
|
|
512
|
+
...(promptBackupPath ? { backupPath: promptBackupPath } : {}),
|
|
513
|
+
...(settingsBackupPath ? { settingsBackupPath } : {}),
|
|
514
|
+
agentsUpdated,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
export async function uninstallAetherPrompt(promptPath, options = {}) {
|
|
518
|
+
const { promptPath: resolvedPromptPath, settingsPath } = await resolveAetherPaths(promptPath, options);
|
|
519
|
+
await rejectInstallSidecarSymlinks(settingsPath);
|
|
520
|
+
const settings = await readAetherSettings(settingsPath);
|
|
521
|
+
const existingPrompt = await readInstructionFile(resolvedPromptPath);
|
|
522
|
+
const isTokenjuicePrompt = existingPrompt.exists && isTokenjuiceAetherPromptText(existingPrompt.text);
|
|
523
|
+
const restoreBackupSuffix = existingPrompt.exists && isTokenjuiceAetherPromptText(existingPrompt.text)
|
|
524
|
+
? readRestoreBackupSuffix(existingPrompt.text)
|
|
525
|
+
: undefined;
|
|
526
|
+
if (restoreBackupSuffix) {
|
|
527
|
+
await rejectAetherPathSymlink(`${resolvedPromptPath}${restoreBackupSuffix}`);
|
|
528
|
+
}
|
|
529
|
+
const settingsRefsAdded = isTokenjuicePrompt ? readSettingsRefsAdded(existingPrompt.text) : undefined;
|
|
530
|
+
const removeLegacySettingsRefs = isTokenjuicePrompt && !settingsRefsAdded && !restoreBackupSuffix;
|
|
531
|
+
const promptsRemoved = settings.exists
|
|
532
|
+
? removePromptSourceFromAgents(settings.config, settingsRefsAdded, { removeAll: removeLegacySettingsRefs })
|
|
533
|
+
: 0;
|
|
534
|
+
if (promptsRemoved > 0) {
|
|
535
|
+
await writeAetherSettings(settingsPath, settings.config);
|
|
536
|
+
}
|
|
537
|
+
if (!isTokenjuicePrompt) {
|
|
538
|
+
return { promptPath: resolvedPromptPath, settingsPath, removed: false, promptsRemoved };
|
|
539
|
+
}
|
|
540
|
+
const settingsStillLoadPrompt = settings.exists && settingsLoadsPromptSource(settings.config);
|
|
541
|
+
if (restoreBackupSuffix) {
|
|
542
|
+
const backupPath = `${resolvedPromptPath}${restoreBackupSuffix}`;
|
|
543
|
+
const backup = await readInstructionFile(backupPath);
|
|
544
|
+
if (backup.exists && !isTokenjuiceAetherPromptText(backup.text)) {
|
|
545
|
+
await rm(resolvedPromptPath, { force: true });
|
|
546
|
+
await rename(backupPath, resolvedPromptPath);
|
|
547
|
+
return { promptPath: resolvedPromptPath, settingsPath, removed: true, promptsRemoved };
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (settingsStillLoadPrompt) {
|
|
551
|
+
return { promptPath: resolvedPromptPath, settingsPath, removed: false, promptsRemoved };
|
|
552
|
+
}
|
|
553
|
+
const result = await removeInstructionFile(resolvedPromptPath);
|
|
554
|
+
return { promptPath: result.filePath, settingsPath, removed: result.removed, promptsRemoved };
|
|
555
|
+
}
|
|
556
|
+
export async function doctorAetherPrompt(promptPath, options = {}) {
|
|
557
|
+
let resolvedPromptPath;
|
|
558
|
+
let settingsPath;
|
|
559
|
+
try {
|
|
560
|
+
({ promptPath: resolvedPromptPath, settingsPath } = await resolveAetherPaths(promptPath, options));
|
|
561
|
+
}
|
|
562
|
+
catch (error) {
|
|
563
|
+
const aliases = await getDefaultAliasPaths(promptPath, options);
|
|
564
|
+
const hasTokenjuiceMarker = await detectAetherInstallEvidence(aliases.promptPath, aliases.settingsPath, options);
|
|
565
|
+
return {
|
|
566
|
+
promptPath: aliases.promptPath,
|
|
567
|
+
settingsPath: aliases.settingsPath,
|
|
568
|
+
hasTokenjuiceMarker,
|
|
569
|
+
...buildInstructionDoctorReportFields({
|
|
570
|
+
status: "broken",
|
|
571
|
+
issues: [error.message],
|
|
572
|
+
advisory: TOKENJUICE_AETHER_ADVISORY,
|
|
573
|
+
fixCommand: error.message.includes("outside")
|
|
574
|
+
? "use a project-local Aether prompt path, then run tokenjuice install aether"
|
|
575
|
+
: error.message.includes("settings load")
|
|
576
|
+
? "use .aether/tokenjuice.md as the Aether prompt path, then run tokenjuice install aether"
|
|
577
|
+
: "replace symlinked Aether prompt/settings files with regular project files, then run tokenjuice install aether",
|
|
578
|
+
}),
|
|
579
|
+
checkedPaths: [aliases.settingsPath, aliases.promptPath],
|
|
580
|
+
missingPaths: [],
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
const checkedPaths = [settingsPath, resolvedPromptPath];
|
|
584
|
+
const missingPaths = (await Promise.all(checkedPaths.map((path) => pathExists(path))))
|
|
585
|
+
.map((exists, index) => (exists ? undefined : checkedPaths[index]))
|
|
586
|
+
.filter((path) => Boolean(path));
|
|
587
|
+
const prompt = await readInstructionFile(resolvedPromptPath);
|
|
588
|
+
let settings;
|
|
589
|
+
try {
|
|
590
|
+
settings = await readAetherSettings(settingsPath);
|
|
591
|
+
}
|
|
592
|
+
catch (error) {
|
|
593
|
+
if (!prompt.exists) {
|
|
594
|
+
return {
|
|
595
|
+
promptPath: resolvedPromptPath,
|
|
596
|
+
settingsPath,
|
|
597
|
+
hasTokenjuiceMarker: false,
|
|
598
|
+
...buildInstructionDoctorReportFields({
|
|
599
|
+
status: "disabled",
|
|
600
|
+
issues: ["tokenjuice Aether prompt is not installed", error.message],
|
|
601
|
+
advisory: TOKENJUICE_AETHER_ADVISORY,
|
|
602
|
+
fixCommand: "repair .aether/settings.json, then run tokenjuice install aether",
|
|
603
|
+
}),
|
|
604
|
+
checkedPaths,
|
|
605
|
+
missingPaths,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
promptPath: resolvedPromptPath,
|
|
610
|
+
settingsPath,
|
|
611
|
+
hasTokenjuiceMarker: isTokenjuiceAetherPromptText(prompt.text),
|
|
612
|
+
...buildInstructionDoctorReportFields({
|
|
613
|
+
status: "broken",
|
|
614
|
+
issues: [error.message],
|
|
615
|
+
advisory: TOKENJUICE_AETHER_ADVISORY,
|
|
616
|
+
fixCommand: TOKENJUICE_AETHER_FIX_COMMAND,
|
|
617
|
+
}),
|
|
618
|
+
checkedPaths,
|
|
619
|
+
missingPaths,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
const promptIssues = prompt.exists
|
|
623
|
+
? collectGuidanceIssues(prompt.text, {
|
|
624
|
+
required: [
|
|
625
|
+
{
|
|
626
|
+
requiredText: TOKENJUICE_AETHER_MARKER,
|
|
627
|
+
missingIssue: "configured Aether prompt does not look like the tokenjuice prompt",
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
requiredText: TOKENJUICE_WRAP_COMMAND,
|
|
631
|
+
missingIssue: "configured Aether prompt is missing tokenjuice wrap guidance",
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
requiredText: TOKENJUICE_RAW_COMMAND,
|
|
635
|
+
missingIssue: "configured Aether prompt is missing the raw escape hatch",
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
requiredText: "aether show-prompt",
|
|
639
|
+
missingIssue: "configured Aether prompt is missing prompt verification guidance",
|
|
640
|
+
},
|
|
641
|
+
],
|
|
642
|
+
forbidden: [
|
|
643
|
+
{
|
|
644
|
+
forbiddenText: TOKENJUICE_FULL_COMMAND,
|
|
645
|
+
presentIssue: "configured Aether prompt still suggests the full escape hatch",
|
|
646
|
+
},
|
|
647
|
+
],
|
|
648
|
+
})
|
|
649
|
+
: ["tokenjuice Aether prompt is not installed"];
|
|
650
|
+
const settingsIssues = settings.exists ? getPromptIssues(settings.config) : [TOKENJUICE_AETHER_UNINITIALIZED_ISSUE];
|
|
651
|
+
const issues = [...promptIssues, ...settingsIssues];
|
|
652
|
+
const installed = prompt.exists || (settings.exists && settingsLoadsPromptSource(settings.config));
|
|
653
|
+
const hasTokenjuiceMarker = isTokenjuiceAetherPromptText(prompt.text)
|
|
654
|
+
|| (!prompt.exists && settings.exists && settingsLoadsPromptSource(settings.config));
|
|
655
|
+
const status = !installed && !prompt.exists
|
|
656
|
+
? "disabled"
|
|
657
|
+
: instructionDoctorStatusFromIssues(issues);
|
|
658
|
+
return {
|
|
659
|
+
promptPath: resolvedPromptPath,
|
|
660
|
+
settingsPath,
|
|
661
|
+
hasTokenjuiceMarker,
|
|
662
|
+
...buildInstructionDoctorReportFields({
|
|
663
|
+
status,
|
|
664
|
+
issues,
|
|
665
|
+
advisory: TOKENJUICE_AETHER_ADVISORY,
|
|
666
|
+
fixCommand: settings.exists ? TOKENJUICE_AETHER_FIX_COMMAND : TOKENJUICE_AETHER_INIT_FIX_COMMAND,
|
|
667
|
+
}),
|
|
668
|
+
checkedPaths,
|
|
669
|
+
missingPaths,
|
|
670
|
+
};
|
|
671
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type AgentLayerInstructionsOptions = {
|
|
2
|
+
projectDir?: string;
|
|
3
|
+
};
|
|
4
|
+
export type InstallAgentLayerInstructionsResult = {
|
|
5
|
+
instructionsPath: string;
|
|
6
|
+
backupPath?: string;
|
|
7
|
+
syncCommand: string;
|
|
8
|
+
};
|
|
9
|
+
export type UninstallAgentLayerInstructionsResult = {
|
|
10
|
+
instructionsPath: string;
|
|
11
|
+
removed: boolean;
|
|
12
|
+
syncCommand: string;
|
|
13
|
+
};
|
|
14
|
+
export type AgentLayerDoctorReport = {
|
|
15
|
+
instructionsPath: string;
|
|
16
|
+
status: "ok" | "warn" | "broken" | "disabled";
|
|
17
|
+
issues: string[];
|
|
18
|
+
advisories: string[];
|
|
19
|
+
fixCommand: string;
|
|
20
|
+
checkedPaths: string[];
|
|
21
|
+
missingPaths: string[];
|
|
22
|
+
};
|
|
23
|
+
export declare function installAgentLayerInstructions(instructionsPath?: string, options?: AgentLayerInstructionsOptions): Promise<InstallAgentLayerInstructionsResult>;
|
|
24
|
+
export declare function uninstallAgentLayerInstructions(instructionsPath?: string, options?: AgentLayerInstructionsOptions): Promise<UninstallAgentLayerInstructionsResult>;
|
|
25
|
+
export declare function doctorAgentLayerInstructions(instructionsPath?: string, options?: AgentLayerInstructionsOptions): Promise<AgentLayerDoctorReport>;
|