@openclaw/tokenjuice 2026.11.7 → 2026.11.10-beta.2
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 +1 -1
- package/dist/.source-module-urls/e1cd11006f37307698d3ccaa0b9377541a8f8fcd96acf7a0d93ee391c8c5abfa.json +1 -1
- package/dist/index.js +1 -2
- package/dist/tool-result-middleware.js +33 -19
- package/node_modules/tokenjuice/README.md +71 -272
- package/node_modules/tokenjuice/dist/cli/command-types.d.ts +36 -0
- package/node_modules/tokenjuice/dist/cli/command-types.js +1 -0
- package/node_modules/tokenjuice/dist/cli/doctor-commands.d.ts +2 -0
- package/node_modules/tokenjuice/dist/cli/doctor-commands.js +674 -0
- package/node_modules/tokenjuice/dist/cli/doctor-output.d.ts +2 -1
- package/node_modules/tokenjuice/dist/cli/doctor-output.js +9 -0
- package/node_modules/tokenjuice/dist/cli/host-command.d.ts +4 -0
- package/node_modules/tokenjuice/dist/cli/host-command.js +19 -0
- package/node_modules/tokenjuice/dist/cli/install-commands.d.ts +2 -0
- package/node_modules/tokenjuice/dist/cli/install-commands.js +1263 -0
- package/node_modules/tokenjuice/dist/cli/main.d.ts +2 -33
- package/node_modules/tokenjuice/dist/cli/main.js +255 -5950
- package/node_modules/tokenjuice/dist/cli/uninstall-commands.d.ts +2 -0
- package/node_modules/tokenjuice/dist/cli/uninstall-commands.js +554 -0
- package/node_modules/tokenjuice/dist/core/bounded-jsonl.js +15 -3
- package/node_modules/tokenjuice/dist/core/bounded-text-file.d.ts +3 -0
- package/node_modules/tokenjuice/dist/core/bounded-text-file.js +32 -0
- package/node_modules/tokenjuice/dist/core/classify.d.ts +0 -5
- package/node_modules/tokenjuice/dist/core/classify.js +1 -1
- package/node_modules/tokenjuice/dist/core/command-identity.d.ts +0 -2
- package/node_modules/tokenjuice/dist/core/command-identity.js +2 -2
- package/node_modules/tokenjuice/dist/core/command-match.d.ts +0 -3
- package/node_modules/tokenjuice/dist/core/command-match.js +88 -8
- package/node_modules/tokenjuice/dist/core/command.d.ts +0 -1
- package/node_modules/tokenjuice/dist/core/compaction-metadata.d.ts +1 -1
- package/node_modules/tokenjuice/dist/core/env.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/env.js +8 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.d.ts +7 -3
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.js +190 -10
- package/node_modules/tokenjuice/dist/core/integrations/compact-copilot-result.d.ts +6 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-copilot-result.js +50 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-deepseek-result.d.ts +7 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-deepseek-result.js +46 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-framework-result.d.ts +11 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-framework-result.js +19 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-opencode-v2-result.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-opencode-v2-result.js +39 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-qoder-result.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-qoder-result.js +34 -0
- package/node_modules/tokenjuice/dist/core/integrations/openclaw-command.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/integrations/openclaw-command.js +13 -0
- package/node_modules/tokenjuice/dist/core/integrations/rewrite-cline-input.d.ts +4 -0
- package/node_modules/tokenjuice/dist/core/integrations/rewrite-cline-input.js +18 -0
- package/node_modules/tokenjuice/dist/core/inventory-safety.d.ts +0 -1
- package/node_modules/tokenjuice/dist/core/inventory-safety.js +1 -1
- package/node_modules/tokenjuice/dist/core/record-fields.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/record-fields.js +9 -0
- package/node_modules/tokenjuice/dist/core/reduce-inspection-summary.d.ts +2 -1
- package/node_modules/tokenjuice/dist/core/reduce-inspection-summary.js +7 -94
- package/node_modules/tokenjuice/dist/core/simple-yaml-frontmatter.d.ts +9 -0
- package/node_modules/tokenjuice/dist/core/simple-yaml-frontmatter.js +125 -0
- package/node_modules/tokenjuice/dist/core/source.d.ts +0 -1
- package/node_modules/tokenjuice/dist/core/source.js +14 -4
- package/node_modules/tokenjuice/dist/core/structural-markers.d.ts +11 -0
- package/node_modules/tokenjuice/dist/core/structural-markers.js +49 -0
- package/node_modules/tokenjuice/dist/core/text.d.ts +0 -1
- package/node_modules/tokenjuice/dist/core/text.js +0 -3
- package/node_modules/tokenjuice/dist/core/toml-structure.d.ts +2 -0
- package/node_modules/tokenjuice/dist/core/toml-structure.js +83 -0
- package/node_modules/tokenjuice/dist/core/validate-rules.d.ts +2 -2
- package/node_modules/tokenjuice/dist/core/wrap.js +1 -1
- package/node_modules/tokenjuice/dist/hosts/adal/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/adal/index.js +15 -125
- package/node_modules/tokenjuice/dist/hosts/aether/index.d.ts +2 -7
- package/node_modules/tokenjuice/dist/hosts/aether/index.js +17 -155
- package/node_modules/tokenjuice/dist/hosts/agent-layer/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/agent-layer/index.js +10 -64
- package/node_modules/tokenjuice/dist/hosts/agentinit/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/agentinit/index.js +15 -111
- package/node_modules/tokenjuice/dist/hosts/agentlink/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/agentlink/index.js +14 -97
- package/node_modules/tokenjuice/dist/hosts/agentloom/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/agentloom/index.js +11 -52
- package/node_modules/tokenjuice/dist/hosts/agents-cli/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/agents-cli/index.js +10 -41
- package/node_modules/tokenjuice/dist/hosts/agents-md/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/agents-md/index.js +16 -128
- package/node_modules/tokenjuice/dist/hosts/agentsge/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/agentsge/index.js +11 -52
- package/node_modules/tokenjuice/dist/hosts/agentsmesh/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/agentsmesh/index.js +10 -53
- package/node_modules/tokenjuice/dist/hosts/ai-memory-protocol/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/ai-memory-protocol/index.js +13 -42
- package/node_modules/tokenjuice/dist/hosts/aictl/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/aictl/index.js +17 -128
- package/node_modules/tokenjuice/dist/hosts/aider/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/aider/index.js +6 -18
- package/node_modules/tokenjuice/dist/hosts/amazon-q/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/amazon-q/index.js +31 -105
- package/node_modules/tokenjuice/dist/hosts/amp/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/amp/index.js +11 -72
- package/node_modules/tokenjuice/dist/hosts/ante/index.d.ts +11 -0
- package/node_modules/tokenjuice/dist/hosts/ante/index.js +76 -0
- package/node_modules/tokenjuice/dist/hosts/antigravity/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/antigravity/index.js +29 -117
- package/node_modules/tokenjuice/dist/hosts/anywhere-agents/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/anywhere-agents/index.js +14 -97
- package/node_modules/tokenjuice/dist/hosts/augment/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/augment/index.js +29 -117
- package/node_modules/tokenjuice/dist/hosts/avante/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/avante/index.js +5 -27
- package/node_modules/tokenjuice/dist/hosts/baz/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/baz/index.js +17 -132
- package/node_modules/tokenjuice/dist/hosts/bito/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/bito/index.js +11 -108
- package/node_modules/tokenjuice/dist/hosts/blackbox/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/blackbox/index.js +16 -157
- package/node_modules/tokenjuice/dist/hosts/blocks/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/blocks/index.js +16 -157
- package/node_modules/tokenjuice/dist/hosts/bob/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/bob/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/builder/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/builder/index.js +34 -131
- package/node_modules/tokenjuice/dist/hosts/charlie/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/charlie/index.js +16 -140
- package/node_modules/tokenjuice/dist/hosts/claude-code/index.js +12 -49
- package/node_modules/tokenjuice/dist/hosts/clawdbot/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/clawdbot/index.js +48 -235
- package/node_modules/tokenjuice/dist/hosts/cline/index.d.ts +6 -13
- package/node_modules/tokenjuice/dist/hosts/cline/index.js +134 -135
- package/node_modules/tokenjuice/dist/hosts/codeant/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/codeant/index.js +12 -123
- package/node_modules/tokenjuice/dist/hosts/codebuddy/index.js +14 -58
- package/node_modules/tokenjuice/dist/hosts/codebuff/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/codebuff/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/codegen/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/codegen/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/coder-agents/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/coder-agents/index.js +25 -193
- package/node_modules/tokenjuice/dist/hosts/coderabbit/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/coderabbit/index.js +16 -173
- package/node_modules/tokenjuice/dist/hosts/codex/index.d.ts +3 -4
- package/node_modules/tokenjuice/dist/hosts/codex/index.js +26 -58
- package/node_modules/tokenjuice/dist/hosts/command-code/index.d.ts +6 -13
- package/node_modules/tokenjuice/dist/hosts/command-code/index.js +87 -331
- package/node_modules/tokenjuice/dist/hosts/continue/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/continue/index.js +6 -18
- package/node_modules/tokenjuice/dist/hosts/copilot-agent/index.d.ts +2 -11
- package/node_modules/tokenjuice/dist/hosts/copilot-agent/index.js +15 -166
- package/node_modules/tokenjuice/dist/hosts/copilot-cli/index.d.ts +2 -11
- package/node_modules/tokenjuice/dist/hosts/copilot-cli/index.js +24 -196
- package/node_modules/tokenjuice/dist/hosts/copilot-sdk/index.d.ts +12 -0
- package/node_modules/tokenjuice/dist/hosts/copilot-sdk/index.js +15 -0
- package/node_modules/tokenjuice/dist/hosts/crush/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/crush/index.js +6 -18
- package/node_modules/tokenjuice/dist/hosts/cursor/index.js +7 -8
- package/node_modules/tokenjuice/dist/hosts/deepagents/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/deepagents/index.js +15 -125
- package/node_modules/tokenjuice/dist/hosts/deepseek-harness/bundle/cordis.patch.yml +3 -0
- package/node_modules/tokenjuice/dist/hosts/deepseek-harness/bundle/index.js +9656 -0
- package/node_modules/tokenjuice/dist/hosts/deepseek-harness/bundle/package.json +18 -0
- package/node_modules/tokenjuice/dist/hosts/deepseek-harness/runtime.d.ts +7 -0
- package/node_modules/tokenjuice/dist/hosts/deepseek-harness/runtime.js +23 -0
- package/node_modules/tokenjuice/dist/hosts/devin/index.d.ts +2 -11
- package/node_modules/tokenjuice/dist/hosts/devin/index.js +7 -9
- package/node_modules/tokenjuice/dist/hosts/docker-agent/index.d.ts +2 -7
- package/node_modules/tokenjuice/dist/hosts/docker-agent/index.js +19 -99
- package/node_modules/tokenjuice/dist/hosts/dot-agents/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/dot-agents/index.js +12 -41
- package/node_modules/tokenjuice/dist/hosts/droid/index.d.ts +5 -12
- package/node_modules/tokenjuice/dist/hosts/droid/index.js +106 -211
- package/node_modules/tokenjuice/dist/hosts/eca/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/eca/index.js +26 -190
- package/node_modules/tokenjuice/dist/hosts/elyra/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/elyra/index.js +26 -190
- package/node_modules/tokenjuice/dist/hosts/firebase-studio/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/firebase-studio/index.js +16 -123
- package/node_modules/tokenjuice/dist/hosts/forgecode/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/forgecode/index.js +20 -161
- package/node_modules/tokenjuice/dist/hosts/gemini-cli/index.d.ts +5 -12
- package/node_modules/tokenjuice/dist/hosts/gemini-cli/index.js +87 -94
- package/node_modules/tokenjuice/dist/hosts/gitlab-duo/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/gitlab-duo/index.js +17 -123
- package/node_modules/tokenjuice/dist/hosts/goose/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/goose/index.js +34 -77
- package/node_modules/tokenjuice/dist/hosts/gptme/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/gptme/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/greptile/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/greptile/index.js +18 -156
- package/node_modules/tokenjuice/dist/hosts/grok-bot/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/grok-bot/index.js +14 -110
- package/node_modules/tokenjuice/dist/hosts/grok-build/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/grok-build/index.js +13 -113
- package/node_modules/tokenjuice/dist/hosts/grok-cli/index.d.ts +7 -14
- package/node_modules/tokenjuice/dist/hosts/grok-cli/index.js +32 -188
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/__init__.py +1 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/plugin.yaml +7 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/README.md +29 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/__init__.py +3 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/bridge.py +39 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/fastmcp.py +24 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/hermes.py +13 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/langchain.py +38 -0
- package/node_modules/tokenjuice/dist/hosts/hermes/bundle/tokenjuice_integrations/plugin.yaml +7 -0
- package/node_modules/tokenjuice/dist/hosts/jean2/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/jean2/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/jetbrains-ai/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/jetbrains-ai/index.js +33 -133
- package/node_modules/tokenjuice/dist/hosts/jules/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/jules/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/junie/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/junie/index.js +5 -27
- package/node_modules/tokenjuice/dist/hosts/kilo/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/kilo/index.js +6 -18
- package/node_modules/tokenjuice/dist/hosts/kimi/index.d.ts +7 -13
- package/node_modules/tokenjuice/dist/hosts/kimi/index.js +38 -156
- package/node_modules/tokenjuice/dist/hosts/kiro/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/kiro/index.js +6 -18
- package/node_modules/tokenjuice/dist/hosts/knowns/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/knowns/index.js +35 -203
- package/node_modules/tokenjuice/dist/hosts/leanctl/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/leanctl/index.js +15 -156
- package/node_modules/tokenjuice/dist/hosts/localcode/index.d.ts +2 -7
- package/node_modules/tokenjuice/dist/hosts/localcode/index.js +10 -68
- package/node_modules/tokenjuice/dist/hosts/mastra/index.d.ts +28 -0
- package/node_modules/tokenjuice/dist/hosts/mastra/index.js +26 -0
- package/node_modules/tokenjuice/dist/hosts/mcp-agent/index.d.ts +2 -7
- package/node_modules/tokenjuice/dist/hosts/mcp-agent/index.js +15 -109
- package/node_modules/tokenjuice/dist/hosts/mini-swe-agent/index.d.ts +2 -7
- package/node_modules/tokenjuice/dist/hosts/mini-swe-agent/index.js +21 -110
- package/node_modules/tokenjuice/dist/hosts/mistral-vibe/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/mistral-vibe/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/mux/index.d.ts +6 -13
- package/node_modules/tokenjuice/dist/hosts/mux/index.js +54 -349
- package/node_modules/tokenjuice/dist/hosts/novakit/index.d.ts +5 -16
- package/node_modules/tokenjuice/dist/hosts/novakit/index.js +35 -203
- package/node_modules/tokenjuice/dist/hosts/ona/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/ona/index.js +19 -283
- package/node_modules/tokenjuice/dist/hosts/open-interpreter/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/open-interpreter/index.js +11 -66
- package/node_modules/tokenjuice/dist/hosts/openclaw/extension.js +6 -5
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.js +540 -363
- package/node_modules/tokenjuice/dist/hosts/opencode/index.js +8 -54
- package/node_modules/tokenjuice/dist/hosts/opencode/v2/bundle/index.js +9648 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/v2/index.d.ts +37 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/v2/index.js +97 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/v2/runtime.d.ts +13 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/v2/runtime.js +23 -0
- package/node_modules/tokenjuice/dist/hosts/openhands/index.d.ts +7 -14
- package/node_modules/tokenjuice/dist/hosts/openhands/index.js +111 -186
- package/node_modules/tokenjuice/dist/hosts/openwebui/index.d.ts +2 -7
- package/node_modules/tokenjuice/dist/hosts/openwebui/index.js +2 -24
- package/node_modules/tokenjuice/dist/hosts/pi/extension/pi-types.d.ts +3 -2
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.d.ts +2 -1
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.js +545 -359
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status-panel.d.ts +1 -1
- package/node_modules/tokenjuice/dist/hosts/pi/extension/status.d.ts +1 -1
- package/node_modules/tokenjuice/dist/hosts/pi/extension/tool-result.d.ts +1 -1
- package/node_modules/tokenjuice/dist/hosts/pi/index.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/pi/index.js +5 -53
- package/node_modules/tokenjuice/dist/hosts/pi-go/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/pi-go/index.js +26 -190
- package/node_modules/tokenjuice/dist/hosts/plandex/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/plandex/index.js +10 -41
- package/node_modules/tokenjuice/dist/hosts/qoder/hook-install.d.ts +22 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/hook-install.js +105 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/hook.d.ts +1 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/hook.js +22 -0
- package/node_modules/tokenjuice/dist/hosts/qoder/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/qoder/index.js +13 -113
- package/node_modules/tokenjuice/dist/hosts/qoderwork/index.d.ts +36 -0
- package/node_modules/tokenjuice/dist/hosts/qoderwork/index.js +20 -0
- package/node_modules/tokenjuice/dist/hosts/qodo/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/qodo/index.js +20 -290
- package/node_modules/tokenjuice/dist/hosts/qwen-code/index.d.ts +6 -13
- package/node_modules/tokenjuice/dist/hosts/qwen-code/index.js +60 -165
- package/node_modules/tokenjuice/dist/hosts/qwenwork/index.d.ts +36 -0
- package/node_modules/tokenjuice/dist/hosts/qwenwork/index.js +20 -0
- package/node_modules/tokenjuice/dist/hosts/replit/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/replit/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/roo/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/roo/index.js +5 -31
- package/node_modules/tokenjuice/dist/hosts/rovo/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/rovo/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/ruler/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/ruler/index.js +10 -64
- package/node_modules/tokenjuice/dist/hosts/shared/bundle-runtime.d.ts +2 -0
- package/node_modules/tokenjuice/dist/hosts/shared/bundle-runtime.js +56 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.d.ts +3 -8
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.js +3 -3
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.d.ts +112 -101
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.js +10 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-output.d.ts +0 -1
- package/node_modules/tokenjuice/dist/hosts/shared/hook-output.js +1 -1
- package/node_modules/tokenjuice/dist/hosts/shared/hooks-json-file.d.ts +15 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hooks-json-file.js +93 -0
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.d.ts +1 -1
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.js +4 -4
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-doctor.d.ts +4 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-file.d.ts +26 -6
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-file.js +125 -5
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-guidance.d.ts +7 -0
- package/node_modules/tokenjuice/dist/hosts/shared/instruction-guidance.js +24 -0
- package/node_modules/tokenjuice/dist/hosts/shared/managed-skill.d.ts +42 -0
- package/node_modules/tokenjuice/dist/hosts/shared/managed-skill.js +87 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instruction-doctor.d.ts +29 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instruction-doctor.js +72 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instructions.d.ts +12 -0
- package/node_modules/tokenjuice/dist/hosts/shared/marker-instructions.js +43 -0
- package/node_modules/tokenjuice/dist/hosts/shared/owned-instruction-doctor.d.ts +9 -0
- package/node_modules/tokenjuice/dist/hosts/shared/owned-instruction-doctor.js +17 -0
- package/node_modules/tokenjuice/dist/hosts/shared/path-ancestors.d.ts +14 -0
- package/node_modules/tokenjuice/dist/hosts/shared/path-ancestors.js +117 -0
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.d.ts +7 -7
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.js +13 -48
- package/node_modules/tokenjuice/dist/hosts/shared/private-config-file.d.ts +2 -0
- package/node_modules/tokenjuice/dist/hosts/shared/private-config-file.js +36 -0
- package/node_modules/tokenjuice/dist/hosts/shared/project-root.d.ts +5 -0
- package/node_modules/tokenjuice/dist/hosts/shared/project-root.js +33 -0
- package/node_modules/tokenjuice/dist/hosts/shared/project-skill-doctor.d.ts +14 -0
- package/node_modules/tokenjuice/dist/hosts/shared/project-skill-doctor.js +62 -0
- package/node_modules/tokenjuice/dist/hosts/shared/restorable-rule.d.ts +15 -0
- package/node_modules/tokenjuice/dist/hosts/shared/restorable-rule.js +64 -0
- package/node_modules/tokenjuice/dist/hosts/shared/restorable-skill.d.ts +15 -0
- package/node_modules/tokenjuice/dist/hosts/shared/restorable-skill.js +48 -0
- package/node_modules/tokenjuice/dist/hosts/shared/settings-file.d.ts +5 -1
- package/node_modules/tokenjuice/dist/hosts/shared/settings-file.js +33 -5
- package/node_modules/tokenjuice/dist/hosts/shared/skill-frontmatter.d.ts +5 -0
- package/node_modules/tokenjuice/dist/hosts/shared/skill-frontmatter.js +18 -0
- package/node_modules/tokenjuice/dist/hosts/stagewise/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/stagewise/index.js +50 -377
- package/node_modules/tokenjuice/dist/hosts/swe-agent/index.d.ts +2 -7
- package/node_modules/tokenjuice/dist/hosts/swe-agent/index.js +20 -88
- package/node_modules/tokenjuice/dist/hosts/tabby/index.d.ts +2 -8
- package/node_modules/tokenjuice/dist/hosts/tabby/index.js +13 -190
- package/node_modules/tokenjuice/dist/hosts/tabnine/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/tabnine/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/trae/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/trae/index.js +17 -123
- package/node_modules/tokenjuice/dist/hosts/uipath/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/uipath/index.js +13 -123
- package/node_modules/tokenjuice/dist/hosts/vscode-copilot/index.d.ts +2 -11
- package/node_modules/tokenjuice/dist/hosts/vscode-copilot/index.js +15 -101
- package/node_modules/tokenjuice/dist/hosts/warp/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/warp/index.js +14 -116
- package/node_modules/tokenjuice/dist/hosts/windsurf/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/windsurf/index.js +6 -18
- package/node_modules/tokenjuice/dist/hosts/zed/index.d.ts +5 -17
- package/node_modules/tokenjuice/dist/hosts/zed/index.js +5 -27
- package/node_modules/tokenjuice/dist/hosts/zencoder/index.d.ts +2 -9
- package/node_modules/tokenjuice/dist/hosts/zencoder/index.js +42 -139
- package/node_modules/tokenjuice/dist/index.d.ts +20 -4
- package/node_modules/tokenjuice/dist/index.js +14 -4
- package/node_modules/tokenjuice/dist/python/LICENSE +21 -0
- package/node_modules/tokenjuice/dist/python/README.md +38 -0
- package/node_modules/tokenjuice/dist/python/pyproject.toml +30 -0
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/README.md +29 -0
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/__init__.py +3 -0
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/bridge.py +39 -0
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/fastmcp.py +24 -0
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/hermes.py +13 -0
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/langchain.py +38 -0
- package/node_modules/tokenjuice/dist/python/tokenjuice_integrations/plugin.yaml +7 -0
- package/node_modules/tokenjuice/dist/types.d.ts +9 -8
- package/node_modules/tokenjuice/package.json +32 -11
- package/package.json +5 -5
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PathDoctorReport } from "../shared/instruction-doctor.js";
|
|
1
2
|
export type BuilderRuleOptions = {
|
|
2
3
|
projectDir?: string;
|
|
3
4
|
};
|
|
@@ -9,15 +10,7 @@ export type UninstallBuilderRuleResult = {
|
|
|
9
10
|
rulePath: string;
|
|
10
11
|
removed: boolean;
|
|
11
12
|
};
|
|
12
|
-
export type BuilderDoctorReport =
|
|
13
|
-
rulePath: string;
|
|
14
|
-
status: "ok" | "warn" | "broken" | "disabled";
|
|
15
|
-
issues: string[];
|
|
16
|
-
advisories: string[];
|
|
17
|
-
fixCommand: string;
|
|
18
|
-
checkedPaths: string[];
|
|
19
|
-
missingPaths: string[];
|
|
20
|
-
};
|
|
13
|
+
export type BuilderDoctorReport = PathDoctorReport<"rulePath">;
|
|
21
14
|
export declare function installBuilderRule(rulePath?: string, options?: BuilderRuleOptions): Promise<InstallBuilderRuleResult>;
|
|
22
15
|
export declare function uninstallBuilderRule(rulePath?: string, options?: BuilderRuleOptions): Promise<UninstallBuilderRuleResult>;
|
|
23
16
|
export declare function doctorBuilderRule(rulePath?: string, options?: BuilderRuleOptions): Promise<BuilderDoctorReport>;
|
|
@@ -1,45 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { doctorOwnedInstructionFile } from "../shared/owned-instruction-doctor.js";
|
|
3
|
+
import { createProjectDirResolver } from "../shared/project-root.js";
|
|
4
|
+
import { collectTokenjuiceGuidanceIssues, buildTokenjuiceGuidanceBullets, TOKENJUICE_WRAP_COMMAND, } from "../shared/instruction-guidance.js";
|
|
5
|
+
import { uninstallManagedInstructionFile, installManagedInstructionFile, } from "../shared/instruction-file.js";
|
|
6
6
|
const TOKENJUICE_BUILDER_FIX_COMMAND = "tokenjuice install builder";
|
|
7
7
|
const TOKENJUICE_BUILDER_OWNERSHIP_MARKER = "<!-- tokenjuice:builder-rule -->";
|
|
8
8
|
const TOKENJUICE_BUILDER_RULE_MARKER = "tokenjuice terminal output compaction";
|
|
9
9
|
const TOKENJUICE_BUILDER_ADVISORY = "Builder support is beta and rule-based; it guides command usage but does not intercept tool output.";
|
|
10
|
-
const
|
|
11
|
-
function getExplicitProjectDir(options = {}) {
|
|
12
|
-
return options.projectDir || process.env.BUILDER_PROJECT_DIR;
|
|
13
|
-
}
|
|
14
|
-
async function hasGitMetadata(dir) {
|
|
15
|
-
try {
|
|
16
|
-
await stat(join(dir, ".git"));
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async function findGitRoot(startDir) {
|
|
24
|
-
let current = resolve(startDir);
|
|
25
|
-
while (true) {
|
|
26
|
-
if (await hasGitMetadata(current)) {
|
|
27
|
-
return current;
|
|
28
|
-
}
|
|
29
|
-
const parent = dirname(current);
|
|
30
|
-
if (parent === current) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
current = parent;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async function resolveProjectDir(options = {}) {
|
|
37
|
-
const explicitProjectDir = getExplicitProjectDir(options);
|
|
38
|
-
if (explicitProjectDir) {
|
|
39
|
-
return resolve(explicitProjectDir);
|
|
40
|
-
}
|
|
41
|
-
return (await findGitRoot(process.cwd())) ?? process.cwd();
|
|
42
|
-
}
|
|
10
|
+
const resolveProjectDir = createProjectDirResolver("BUILDER_PROJECT_DIR");
|
|
43
11
|
async function getDefaultRulePath(options = {}) {
|
|
44
12
|
return join(await resolveProjectDir(options), ".builder", "rules", "tokenjuice.mdc");
|
|
45
13
|
}
|
|
@@ -62,29 +30,9 @@ const TOKENJUICE_BUILDER_RULE = [
|
|
|
62
30
|
function isTokenjuiceBuilderRuleText(text) {
|
|
63
31
|
return text.includes(TOKENJUICE_BUILDER_OWNERSHIP_MARKER);
|
|
64
32
|
}
|
|
65
|
-
async function writeBuilderRuleWithoutBackup(rulePath) {
|
|
66
|
-
await mkdir(dirname(rulePath), { recursive: true });
|
|
67
|
-
const tempPath = `${rulePath}.tmp`;
|
|
68
|
-
await writeFile(tempPath, TOKENJUICE_BUILDER_RULE, "utf8");
|
|
69
|
-
await rename(tempPath, rulePath);
|
|
70
|
-
}
|
|
71
33
|
export async function installBuilderRule(rulePath, options = {}) {
|
|
72
34
|
const resolvedRulePath = rulePath ?? (await getDefaultRulePath(options));
|
|
73
|
-
const
|
|
74
|
-
if (existing.exists && isTokenjuiceBuilderRuleText(existing.text)) {
|
|
75
|
-
if (existing.text === TOKENJUICE_BUILDER_RULE) {
|
|
76
|
-
return { rulePath: resolvedRulePath };
|
|
77
|
-
}
|
|
78
|
-
const primaryBackupPath = `${resolvedRulePath}.bak`;
|
|
79
|
-
const primaryBackup = await readInstructionFile(primaryBackupPath);
|
|
80
|
-
const backupPath = primaryBackup.exists && !isTokenjuiceBuilderRuleText(primaryBackup.text)
|
|
81
|
-
? `${resolvedRulePath}${TOKENJUICE_BUILDER_REINSTALL_BACKUP_SUFFIX}`
|
|
82
|
-
: primaryBackupPath;
|
|
83
|
-
await writeFile(backupPath, existing.text, "utf8");
|
|
84
|
-
await writeBuilderRuleWithoutBackup(resolvedRulePath);
|
|
85
|
-
return { rulePath: resolvedRulePath, backupPath };
|
|
86
|
-
}
|
|
87
|
-
const result = await writeInstructionFile(resolvedRulePath, TOKENJUICE_BUILDER_RULE);
|
|
35
|
+
const result = await installManagedInstructionFile(resolvedRulePath, TOKENJUICE_BUILDER_RULE, isTokenjuiceBuilderRuleText);
|
|
88
36
|
return {
|
|
89
37
|
rulePath: result.filePath,
|
|
90
38
|
...(result.backupPath ? { backupPath: result.backupPath } : {}),
|
|
@@ -92,86 +40,41 @@ export async function installBuilderRule(rulePath, options = {}) {
|
|
|
92
40
|
}
|
|
93
41
|
export async function uninstallBuilderRule(rulePath, options = {}) {
|
|
94
42
|
const resolvedRulePath = rulePath ?? (await getDefaultRulePath(options));
|
|
95
|
-
const
|
|
96
|
-
if (existing.exists && !isTokenjuiceBuilderRuleText(existing.text)) {
|
|
97
|
-
throw new Error(`refusing to remove ${resolvedRulePath}; it does not look like the tokenjuice Builder rule. Review and remove it manually, or reinstall tokenjuice builder first.`);
|
|
98
|
-
}
|
|
99
|
-
const backupPath = `${resolvedRulePath}.bak`;
|
|
100
|
-
const backup = await readInstructionFile(backupPath);
|
|
101
|
-
if (existing.exists && backup.exists && !isTokenjuiceBuilderRuleText(backup.text)) {
|
|
102
|
-
await rm(resolvedRulePath, { force: true });
|
|
103
|
-
await rename(backupPath, resolvedRulePath);
|
|
104
|
-
return { rulePath: resolvedRulePath, removed: true };
|
|
105
|
-
}
|
|
106
|
-
const result = await removeInstructionFile(resolvedRulePath);
|
|
43
|
+
const result = await uninstallManagedInstructionFile(resolvedRulePath, isTokenjuiceBuilderRuleText, `refusing to remove ${resolvedRulePath}; it does not look like the tokenjuice Builder rule. Review and remove it manually, or reinstall tokenjuice builder first.`);
|
|
107
44
|
return { rulePath: result.filePath, removed: result.removed };
|
|
108
45
|
}
|
|
109
46
|
export async function doctorBuilderRule(rulePath, options = {}) {
|
|
110
47
|
const resolvedRulePath = rulePath ?? (await getDefaultRulePath(options));
|
|
111
|
-
const existing = await readInstructionFile(resolvedRulePath);
|
|
112
|
-
if (!existing.exists) {
|
|
113
|
-
return {
|
|
114
|
-
rulePath: resolvedRulePath,
|
|
115
|
-
...buildInstructionDoctorReportFields({
|
|
116
|
-
status: "disabled",
|
|
117
|
-
issues: ["tokenjuice Builder rule is not installed"],
|
|
118
|
-
advisory: TOKENJUICE_BUILDER_ADVISORY,
|
|
119
|
-
fixCommand: TOKENJUICE_BUILDER_FIX_COMMAND,
|
|
120
|
-
}),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
if (!isTokenjuiceBuilderRuleText(existing.text)) {
|
|
124
|
-
return {
|
|
125
|
-
rulePath: resolvedRulePath,
|
|
126
|
-
...buildInstructionDoctorReportFields({
|
|
127
|
-
status: "disabled",
|
|
128
|
-
issues: ["tokenjuice Builder rule is not installed; existing rule file is not tokenjuice-managed"],
|
|
129
|
-
advisory: TOKENJUICE_BUILDER_ADVISORY,
|
|
130
|
-
fixCommand: TOKENJUICE_BUILDER_FIX_COMMAND,
|
|
131
|
-
}),
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const issues = collectGuidanceIssues(existing.text, {
|
|
135
|
-
required: [
|
|
136
|
-
{
|
|
137
|
-
requiredText: "description: tokenjuice terminal output compaction",
|
|
138
|
-
missingIssue: "configured Builder rule file is missing description metadata",
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
requiredText: "alwaysApply: true",
|
|
142
|
-
missingIssue: "configured Builder rule file is missing alwaysApply metadata",
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
requiredText: TOKENJUICE_BUILDER_OWNERSHIP_MARKER,
|
|
146
|
-
missingIssue: "configured Builder rule file is missing the tokenjuice ownership marker",
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
requiredText: TOKENJUICE_BUILDER_RULE_MARKER,
|
|
150
|
-
missingIssue: "configured Builder rule file does not look like the tokenjuice rule",
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
requiredText: TOKENJUICE_WRAP_COMMAND,
|
|
154
|
-
missingIssue: "configured Builder rule file is missing tokenjuice wrap guidance",
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
requiredText: TOKENJUICE_RAW_COMMAND,
|
|
158
|
-
missingIssue: "configured Builder rule file is missing the raw escape hatch",
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
forbidden: [
|
|
162
|
-
{
|
|
163
|
-
forbiddenText: TOKENJUICE_FULL_COMMAND,
|
|
164
|
-
presentIssue: "configured Builder rule file still suggests the full escape hatch",
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
});
|
|
168
48
|
return {
|
|
169
49
|
rulePath: resolvedRulePath,
|
|
170
|
-
...
|
|
171
|
-
|
|
172
|
-
|
|
50
|
+
...await doctorOwnedInstructionFile(resolvedRulePath, {
|
|
51
|
+
isManagedText: isTokenjuiceBuilderRuleText,
|
|
52
|
+
missingIssue: "tokenjuice Builder rule is not installed",
|
|
53
|
+
unmanagedIssue: "tokenjuice Builder rule is not installed; existing rule file is not tokenjuice-managed",
|
|
173
54
|
advisory: TOKENJUICE_BUILDER_ADVISORY,
|
|
174
55
|
fixCommand: TOKENJUICE_BUILDER_FIX_COMMAND,
|
|
56
|
+
collectIssues: (text) => collectTokenjuiceGuidanceIssues(text, {
|
|
57
|
+
configuredLabel: "Builder rule file",
|
|
58
|
+
singular: true,
|
|
59
|
+
additionalRequired: [
|
|
60
|
+
{
|
|
61
|
+
requiredText: "description: tokenjuice terminal output compaction",
|
|
62
|
+
missingIssue: "configured Builder rule file is missing description metadata",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
requiredText: "alwaysApply: true",
|
|
66
|
+
missingIssue: "configured Builder rule file is missing alwaysApply metadata",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
requiredText: TOKENJUICE_BUILDER_OWNERSHIP_MARKER,
|
|
70
|
+
missingIssue: "configured Builder rule file is missing the tokenjuice ownership marker",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
requiredText: TOKENJUICE_BUILDER_RULE_MARKER,
|
|
74
|
+
missingIssue: "configured Builder rule file does not look like the tokenjuice rule",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
}),
|
|
175
78
|
}),
|
|
176
79
|
};
|
|
177
80
|
}
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
+
import { type InstructionsDoctorReport } from "../shared/instruction-doctor.js";
|
|
2
|
+
import { type RemoveInstructionFileResult, type WriteInstructionFileResult } from "../shared/instruction-file.js";
|
|
1
3
|
export type CharlieInstructionsOptions = {
|
|
2
4
|
projectDir?: string;
|
|
3
5
|
};
|
|
4
|
-
export type InstallCharlieInstructionsResult =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export type UninstallCharlieInstructionsResult = {
|
|
9
|
-
instructionsPath: string;
|
|
10
|
-
removed: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type CharlieDoctorReport = {
|
|
13
|
-
instructionsPath: string;
|
|
6
|
+
export type InstallCharlieInstructionsResult = WriteInstructionFileResult<"instructionsPath">;
|
|
7
|
+
export type UninstallCharlieInstructionsResult = RemoveInstructionFileResult<"instructionsPath">;
|
|
8
|
+
export type CharlieDoctorReport = InstructionsDoctorReport & {
|
|
14
9
|
hasTokenjuiceMarker: boolean;
|
|
15
10
|
hasUnsafePathIssue: boolean;
|
|
16
|
-
status: "ok" | "warn" | "broken" | "disabled";
|
|
17
|
-
issues: string[];
|
|
18
|
-
advisories: string[];
|
|
19
|
-
fixCommand: string;
|
|
20
|
-
checkedPaths: string[];
|
|
21
|
-
missingPaths: string[];
|
|
22
11
|
};
|
|
23
12
|
export declare function installCharlieInstructions(instructionsPath?: string, options?: CharlieInstructionsOptions): Promise<InstallCharlieInstructionsResult>;
|
|
24
13
|
export declare function uninstallCharlieInstructions(instructionsPath?: string, options?: CharlieInstructionsOptions): Promise<UninstallCharlieInstructionsResult>;
|
|
@@ -1,81 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { realpath } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { createSymlinkGuard, isInsideOrEqual, realpathExistingAncestor } from "../shared/path-ancestors.js";
|
|
4
|
+
import { createProjectDirResolver } from "../shared/project-root.js";
|
|
5
|
+
import { createMarkerInstructionCommands, getMarkerDelimitedBlockText, hasMalformedMarkerDelimitedBlock, collectMarkerDelimitedBlockIssues, inspectMarkerDelimitedBlock, } from "../shared/marker-instructions.js";
|
|
6
|
+
import { collectTokenjuiceGuidanceIssues, buildTokenjuiceGuidanceBullets } from "../shared/instruction-guidance.js";
|
|
5
7
|
import { buildInstructionDoctorReportFields, instructionDoctorStatusFromIssues, } from "../shared/instruction-doctor.js";
|
|
6
|
-
import {
|
|
8
|
+
import { pathEntryExists, readInstructionFile, } from "../shared/instruction-file.js";
|
|
7
9
|
const TOKENJUICE_CHARLIE_FIX_COMMAND = "tokenjuice install charlie";
|
|
8
10
|
const TOKENJUICE_CHARLIE_BEGIN = "<!-- tokenjuice:charlie begin -->";
|
|
9
11
|
const TOKENJUICE_CHARLIE_END = "<!-- tokenjuice:charlie end -->";
|
|
10
12
|
const TOKENJUICE_CHARLIE_ADVISORY = "Charlie support is beta and AGENTS.md-based; Charlie still owns planning, coding, review, and command execution.";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
async function hasGitMetadata(dir) {
|
|
15
|
-
try {
|
|
16
|
-
await stat(join(dir, ".git"));
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async function findGitRoot(startDir) {
|
|
24
|
-
let current = resolve(startDir);
|
|
25
|
-
while (true) {
|
|
26
|
-
if (await hasGitMetadata(current)) {
|
|
27
|
-
return current;
|
|
28
|
-
}
|
|
29
|
-
const parent = dirname(current);
|
|
30
|
-
if (parent === current) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
current = parent;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async function resolveProjectDir(options = {}) {
|
|
37
|
-
const explicitProjectDir = getExplicitProjectDir(options);
|
|
38
|
-
if (explicitProjectDir) {
|
|
39
|
-
return resolve(explicitProjectDir);
|
|
40
|
-
}
|
|
41
|
-
return (await findGitRoot(process.cwd())) ?? process.cwd();
|
|
42
|
-
}
|
|
43
|
-
function isInsideOrEqual(parentDir, childPath) {
|
|
44
|
-
const relativePath = relative(parentDir, childPath);
|
|
45
|
-
return relativePath === "" || (!relativePath.startsWith("..") && !isAbsolute(relativePath));
|
|
46
|
-
}
|
|
47
|
-
async function realpathExistingAncestor(path) {
|
|
48
|
-
let current = path;
|
|
49
|
-
while (true) {
|
|
50
|
-
try {
|
|
51
|
-
return await realpath(current);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
if (error.code !== "ENOENT") {
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
const parent = dirname(current);
|
|
58
|
-
if (parent === current) {
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
current = parent;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
async function rejectInstructionSymlink(filePath) {
|
|
66
|
-
try {
|
|
67
|
-
const stats = await lstat(filePath);
|
|
68
|
-
if (stats.isSymbolicLink()) {
|
|
69
|
-
throw new Error(`cannot use Charlie instructions ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
if (error.code === "ENOENT") {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
13
|
+
const resolveProjectDir = createProjectDirResolver("CHARLIE_PROJECT_DIR");
|
|
14
|
+
const rejectInstructionSymlink = createSymlinkGuard((filePath) => `cannot use Charlie instructions ${filePath}; tokenjuice will not read or write through instruction symlinks`);
|
|
79
15
|
async function rejectInstallSidecarSymlinks(filePath) {
|
|
80
16
|
await rejectInstructionSymlink(`${filePath}.bak`);
|
|
81
17
|
await rejectInstructionSymlink(`${filePath}.tmp`);
|
|
@@ -105,18 +41,6 @@ async function getDefaultInstructionsPath(options = {}) {
|
|
|
105
41
|
async function getDefaultAliasPath(options = {}) {
|
|
106
42
|
return getExpectedInstructionsPath(await resolveProjectDir(options));
|
|
107
43
|
}
|
|
108
|
-
async function instructionsArtifactExists(filePath) {
|
|
109
|
-
try {
|
|
110
|
-
await lstat(filePath);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
if (error.code === "ENOENT") {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
throw error;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
44
|
async function resolveInstructionsPath(instructionsPath, options = {}) {
|
|
121
45
|
if (instructionsPath) {
|
|
122
46
|
const projectDir = await resolveProjectDir(options);
|
|
@@ -139,48 +63,15 @@ const TOKENJUICE_CHARLIE_BLOCK_CONFIG = {
|
|
|
139
63
|
endMarker: TOKENJUICE_CHARLIE_END,
|
|
140
64
|
block: TOKENJUICE_CHARLIE_BLOCK,
|
|
141
65
|
};
|
|
142
|
-
|
|
143
|
-
const beginIndex = text.indexOf(TOKENJUICE_CHARLIE_BEGIN);
|
|
144
|
-
if (beginIndex === -1) {
|
|
145
|
-
return "";
|
|
146
|
-
}
|
|
147
|
-
const endIndex = text.indexOf(TOKENJUICE_CHARLIE_END, beginIndex + TOKENJUICE_CHARLIE_BEGIN.length);
|
|
148
|
-
if (endIndex === -1) {
|
|
149
|
-
return text.slice(beginIndex);
|
|
150
|
-
}
|
|
151
|
-
return text.slice(beginIndex, endIndex + TOKENJUICE_CHARLIE_END.length);
|
|
152
|
-
}
|
|
153
|
-
function countMarker(text, marker) {
|
|
154
|
-
return text.split(marker).length - 1;
|
|
155
|
-
}
|
|
156
|
-
function hasMalformedMarkerStructure(text, completeBlockCount) {
|
|
157
|
-
const beginCount = countMarker(text, TOKENJUICE_CHARLIE_BEGIN);
|
|
158
|
-
const endCount = countMarker(text, TOKENJUICE_CHARLIE_END);
|
|
159
|
-
return beginCount !== endCount || beginCount !== completeBlockCount || endCount !== completeBlockCount;
|
|
160
|
-
}
|
|
66
|
+
const markerInstructions = createMarkerInstructionCommands("charlie", TOKENJUICE_CHARLIE_BLOCK_CONFIG);
|
|
161
67
|
export async function installCharlieInstructions(instructionsPath, options = {}) {
|
|
162
68
|
const resolvedInstructionsPath = await resolveInstructionsPath(instructionsPath, options);
|
|
163
69
|
await rejectInstallSidecarSymlinks(resolvedInstructionsPath);
|
|
164
|
-
|
|
165
|
-
const markerState = inspectMarkerDelimitedBlock(existing.text, TOKENJUICE_CHARLIE_BLOCK_CONFIG);
|
|
166
|
-
if (existing.exists && hasMalformedMarkerStructure(existing.text, markerState.completeBlockCount)) {
|
|
167
|
-
throw new Error(`cannot safely repair malformed tokenjuice markers in ${resolvedInstructionsPath}; remove the dangling marker manually, then rerun tokenjuice install charlie`);
|
|
168
|
-
}
|
|
169
|
-
const result = await installMarkerDelimitedBlock(resolvedInstructionsPath, TOKENJUICE_CHARLIE_BLOCK_CONFIG);
|
|
170
|
-
return {
|
|
171
|
-
instructionsPath: result.filePath,
|
|
172
|
-
...(result.backupPath ? { backupPath: result.backupPath } : {}),
|
|
173
|
-
};
|
|
70
|
+
return markerInstructions.install(resolvedInstructionsPath);
|
|
174
71
|
}
|
|
175
72
|
export async function uninstallCharlieInstructions(instructionsPath, options = {}) {
|
|
176
73
|
const resolvedInstructionsPath = await resolveInstructionsPath(instructionsPath, options);
|
|
177
|
-
|
|
178
|
-
const markerState = inspectMarkerDelimitedBlock(existing.text, TOKENJUICE_CHARLIE_BLOCK_CONFIG);
|
|
179
|
-
if (existing.exists && hasMalformedMarkerStructure(existing.text, markerState.completeBlockCount)) {
|
|
180
|
-
throw new Error(`cannot safely uninstall malformed tokenjuice markers in ${resolvedInstructionsPath}; remove the dangling marker manually, then rerun tokenjuice uninstall charlie`);
|
|
181
|
-
}
|
|
182
|
-
const result = await uninstallMarkerDelimitedBlock(resolvedInstructionsPath, TOKENJUICE_CHARLIE_BLOCK_CONFIG);
|
|
183
|
-
return { instructionsPath: result.filePath, removed: result.removed };
|
|
74
|
+
return markerInstructions.uninstall(resolvedInstructionsPath);
|
|
184
75
|
}
|
|
185
76
|
export async function doctorCharlieInstructions(instructionsPath, options = {}) {
|
|
186
77
|
let resolvedInstructionsPath;
|
|
@@ -189,7 +80,7 @@ export async function doctorCharlieInstructions(instructionsPath, options = {})
|
|
|
189
80
|
}
|
|
190
81
|
catch (error) {
|
|
191
82
|
const aliasPath = instructionsPath ?? (await getDefaultAliasPath(options));
|
|
192
|
-
if (!instructionsPath && !(await
|
|
83
|
+
if (!instructionsPath && !(await pathEntryExists(aliasPath))) {
|
|
193
84
|
return {
|
|
194
85
|
instructionsPath: aliasPath,
|
|
195
86
|
hasTokenjuiceMarker: false,
|
|
@@ -236,27 +127,12 @@ export async function doctorCharlieInstructions(instructionsPath, options = {})
|
|
|
236
127
|
configuredLabel: "Charlie instructions",
|
|
237
128
|
repairCommand: TOKENJUICE_CHARLIE_FIX_COMMAND,
|
|
238
129
|
});
|
|
239
|
-
const hasMalformedMarkers =
|
|
130
|
+
const hasMalformedMarkers = hasMalformedMarkerDelimitedBlock(existing.text, markerState.completeBlockCount, TOKENJUICE_CHARLIE_BLOCK_CONFIG);
|
|
240
131
|
const issues = [
|
|
241
132
|
...markerIssues,
|
|
242
133
|
...(hasMalformedMarkers ? ["configured Charlie instructions have malformed tokenjuice marker nesting or extra markers"] : []),
|
|
243
|
-
...
|
|
244
|
-
|
|
245
|
-
{
|
|
246
|
-
requiredText: TOKENJUICE_WRAP_COMMAND,
|
|
247
|
-
missingIssue: "configured Charlie instructions are missing tokenjuice wrap guidance",
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
requiredText: TOKENJUICE_RAW_COMMAND,
|
|
251
|
-
missingIssue: "configured Charlie instructions are missing the raw escape hatch",
|
|
252
|
-
},
|
|
253
|
-
],
|
|
254
|
-
forbidden: [
|
|
255
|
-
{
|
|
256
|
-
forbiddenText: TOKENJUICE_FULL_COMMAND,
|
|
257
|
-
presentIssue: "configured Charlie instructions still suggest the full escape hatch",
|
|
258
|
-
},
|
|
259
|
-
],
|
|
134
|
+
...collectTokenjuiceGuidanceIssues(getMarkerDelimitedBlockText(existing.text, TOKENJUICE_CHARLIE_BLOCK_CONFIG), {
|
|
135
|
+
configuredLabel: "Charlie instructions",
|
|
260
136
|
}),
|
|
261
137
|
];
|
|
262
138
|
return {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
1
|
import { join } from "node:path";
|
|
3
2
|
import { homedir } from "node:os";
|
|
4
|
-
import {
|
|
3
|
+
import { pruneHookGroups, readJsonHooksConfig } from "../shared/hooks-json-file.js";
|
|
4
|
+
import { inspectTokenjuiceHookCommand } from "../shared/hook-command-doctor.js";
|
|
5
5
|
import { readSettingsFile, writeSettingsFile } from "../shared/settings-file.js";
|
|
6
|
-
import { buildWrapLauncherHookCommand, buildWrappedCommand, commandAlreadyWrapped,
|
|
6
|
+
import { buildWrapLauncherHookCommand, buildWrappedCommand, commandAlreadyWrapped, isRecord, resolveHostShell, } from "../shared/pre-tool-wrap.js";
|
|
7
7
|
const TOKENJUICE_CLAUDE_CODE_STATUS = "wrapping bash through tokenjuice for compaction";
|
|
8
8
|
const TOKENJUICE_CLAUDE_CODE_LEGACY_STATUS = "compacting bash output with tokenjuice";
|
|
9
9
|
const TOKENJUICE_CLAUDE_CODE_FIX_COMMAND = "tokenjuice install claude-code";
|
|
@@ -99,49 +99,14 @@ function sanitizeClaudeCodeSettings(raw) {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
async function readClaudeCodeSettings(settingsPath) {
|
|
102
|
-
|
|
103
|
-
const rawText = await readFile(settingsPath, "utf8");
|
|
104
|
-
const parsed = JSON.parse(rawText);
|
|
105
|
-
return {
|
|
106
|
-
config: sanitizeClaudeCodeSettings(parsed),
|
|
107
|
-
exists: true,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
if (error.code === "ENOENT") {
|
|
112
|
-
return {
|
|
113
|
-
config: { hooks: {} },
|
|
114
|
-
exists: false,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
throw new Error(`failed to read claude code settings from ${settingsPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function pruneTokenjuiceHookEntries(groups) {
|
|
121
|
-
const pruned = [];
|
|
122
|
-
for (const group of groups) {
|
|
123
|
-
if (!isRecord(group) || !Array.isArray(group.hooks)) {
|
|
124
|
-
pruned.push(group);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const retainedHooks = group.hooks.filter((hook) => !isTokenjuiceClaudeCodeHookEntry(hook));
|
|
128
|
-
if (retainedHooks.length === 0) {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (retainedHooks.length === group.hooks.length) {
|
|
132
|
-
pruned.push(group);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
pruned.push({ ...group, hooks: retainedHooks });
|
|
136
|
-
}
|
|
137
|
-
return pruned;
|
|
102
|
+
return readJsonHooksConfig(settingsPath, "claude code settings", sanitizeClaudeCodeSettings, { hooks: {} });
|
|
138
103
|
}
|
|
139
104
|
function removeTokenjuiceHookEvent(config, event) {
|
|
140
105
|
if (!Array.isArray(config.hooks[event])) {
|
|
141
106
|
return false;
|
|
142
107
|
}
|
|
143
108
|
const groups = config.hooks[event];
|
|
144
|
-
const pruned =
|
|
109
|
+
const pruned = pruneHookGroups(groups, isTokenjuiceClaudeCodeHookEntry);
|
|
145
110
|
const changed = pruned.length !== groups.length || pruned.some((group, index) => group !== groups[index]);
|
|
146
111
|
if (!changed) {
|
|
147
112
|
return false;
|
|
@@ -168,7 +133,7 @@ export async function installClaudeCodeHook(settingsPath = getDefaultSettingsPat
|
|
|
168
133
|
const config = sanitizeClaudeCodeSettings(settings.data ? JSON.parse(settings.data.toString("utf8")) : undefined);
|
|
169
134
|
const command = await buildClaudeCodeHookCommand(options);
|
|
170
135
|
if (Array.isArray(config.hooks.PostToolUse)) {
|
|
171
|
-
const prunedPost =
|
|
136
|
+
const prunedPost = pruneHookGroups(config.hooks.PostToolUse, isTokenjuiceClaudeCodeHookEntry);
|
|
172
137
|
if (prunedPost.length === 0) {
|
|
173
138
|
delete config.hooks.PostToolUse;
|
|
174
139
|
}
|
|
@@ -177,7 +142,7 @@ export async function installClaudeCodeHook(settingsPath = getDefaultSettingsPat
|
|
|
177
142
|
}
|
|
178
143
|
}
|
|
179
144
|
const preToolUse = Array.isArray(config.hooks.PreToolUse) ? config.hooks.PreToolUse : [];
|
|
180
|
-
const retained =
|
|
145
|
+
const retained = pruneHookGroups(preToolUse, isTokenjuiceClaudeCodeHookEntry);
|
|
181
146
|
retained.push(createTokenjuiceClaudeCodeHook(command));
|
|
182
147
|
config.hooks.PreToolUse = retained;
|
|
183
148
|
const backupPath = await writeSettingsFile(settings, `${JSON.stringify(config, null, 2)}\n`, "replace");
|
|
@@ -234,13 +199,9 @@ export async function doctorClaudeCodeHook(settingsPath = getDefaultSettingsPath
|
|
|
234
199
|
missingPaths: [],
|
|
235
200
|
};
|
|
236
201
|
}
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
if (!(await isExecutableFile(path)) && !(path.endsWith(".js") && await pathExists(path))) {
|
|
241
|
-
missingPaths.push(path);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
202
|
+
const inspection = await inspectTokenjuiceHookCommand({ command: detectedCommand });
|
|
203
|
+
const checkedPaths = inspection.checkedPaths;
|
|
204
|
+
const missingPaths = checkedPaths.filter(path => inspection.missingPaths.includes(path) || inspection.nonExecutablePaths.includes(path));
|
|
244
205
|
const issues = [];
|
|
245
206
|
if (detected.hookEvent !== "PreToolUse") {
|
|
246
207
|
issues.push("legacy Claude Code PostToolUse tokenjuice hook is installed; rerun tokenjuice install claude-code to migrate to PreToolUse");
|
|
@@ -278,6 +239,8 @@ export async function runClaudeCodePreToolUseHook(rawText, wrapLauncher = "token
|
|
|
278
239
|
catch {
|
|
279
240
|
return 0;
|
|
280
241
|
}
|
|
242
|
+
if (!isRecord(payload))
|
|
243
|
+
return 0;
|
|
281
244
|
if (payload.hook_event_name !== "PreToolUse") {
|
|
282
245
|
return 0;
|
|
283
246
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PathDoctorReport } from "../shared/instruction-doctor.js";
|
|
1
2
|
export type ClawdbotSkillOptions = {
|
|
2
3
|
projectDir?: string;
|
|
3
4
|
};
|
|
@@ -9,16 +10,9 @@ export type UninstallClawdbotSkillResult = {
|
|
|
9
10
|
skillPath: string;
|
|
10
11
|
removed: boolean;
|
|
11
12
|
};
|
|
12
|
-
export type ClawdbotDoctorReport = {
|
|
13
|
-
skillPath: string;
|
|
13
|
+
export type ClawdbotDoctorReport = PathDoctorReport<"skillPath"> & {
|
|
14
14
|
hasTokenjuiceMarker: boolean;
|
|
15
15
|
hasUnsafePathIssue: boolean;
|
|
16
|
-
status: "ok" | "warn" | "broken" | "disabled";
|
|
17
|
-
issues: string[];
|
|
18
|
-
advisories: string[];
|
|
19
|
-
fixCommand: string;
|
|
20
|
-
checkedPaths: string[];
|
|
21
|
-
missingPaths: string[];
|
|
22
16
|
};
|
|
23
17
|
export declare function installClawdbotSkill(skillPath?: string, options?: ClawdbotSkillOptions): Promise<InstallClawdbotSkillResult>;
|
|
24
18
|
export declare function uninstallClawdbotSkill(skillPath?: string, options?: ClawdbotSkillOptions): Promise<UninstallClawdbotSkillResult>;
|