@openclaw/tokenjuice 2026.11.5 → 2026.11.10-beta.1
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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { compactBashResult } from "./compact-bash-result.js";
|
|
2
|
+
const SOURCES = new Set(["hermes", "copilot-sdk", "langchain", "mastra", "fastmcp"]);
|
|
3
|
+
export async function compactFrameworkResult(source, input) {
|
|
4
|
+
if (!SOURCES.has(source) || typeof input !== "object" || input === null || Array.isArray(input))
|
|
5
|
+
return undefined;
|
|
6
|
+
const value = input;
|
|
7
|
+
if (typeof value.command !== "string" || !value.command.trim() || typeof value.output !== "string"
|
|
8
|
+
|| value.exitCode !== 0 || value.background === true || value.truncated === true
|
|
9
|
+
|| (value.cwd !== undefined && typeof value.cwd !== "string"))
|
|
10
|
+
return undefined;
|
|
11
|
+
const outcome = await compactBashResult({
|
|
12
|
+
source, command: value.command, visibleText: value.output, exitCode: 0,
|
|
13
|
+
...(typeof value.cwd === "string" ? { cwd: value.cwd } : {}),
|
|
14
|
+
inspectionPolicy: "allow-safe-inventory",
|
|
15
|
+
genericFallbackMinSavedChars: 120, genericFallbackMaxRatio: 0.75,
|
|
16
|
+
skipGenericFallbackForCompoundCommands: true,
|
|
17
|
+
});
|
|
18
|
+
return outcome.action === "rewrite" ? outcome.result.inlineText : undefined;
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { compactBashResult } from "./compact-bash-result.js";
|
|
2
|
+
function record(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
/** V2 shell results have both structured output and model-facing content. */
|
|
6
|
+
export async function compactOpenCodeV2Result(event) {
|
|
7
|
+
if (!record(event) || event.tool !== "shell" || event.status !== "completed"
|
|
8
|
+
|| !record(event.input) || typeof event.input.command !== "string" || event.input.background === true
|
|
9
|
+
|| !record(event.result) || !record(event.result.output))
|
|
10
|
+
return undefined;
|
|
11
|
+
const result = event.result;
|
|
12
|
+
const output = event.result.output;
|
|
13
|
+
if (output.status !== "completed" || output.exit !== 0 || output.truncated !== false
|
|
14
|
+
|| output.signal !== undefined || output.timeout === true || output.shellID !== undefined
|
|
15
|
+
|| typeof output.output !== "string")
|
|
16
|
+
return undefined;
|
|
17
|
+
const metadata = result.metadata;
|
|
18
|
+
if (record(metadata) && (metadata.truncated === true || metadata.timeout === true
|
|
19
|
+
|| metadata.signal !== undefined || metadata.shellID !== undefined
|
|
20
|
+
|| (metadata.exit !== undefined && metadata.exit !== 0)
|
|
21
|
+
|| (metadata.status !== undefined && metadata.status !== "completed")))
|
|
22
|
+
return undefined;
|
|
23
|
+
const content = result.content;
|
|
24
|
+
if (!Array.isArray(content) || content.length !== 1 || !record(content[0])
|
|
25
|
+
|| content[0].type !== "text" || content[0].text !== output.output)
|
|
26
|
+
return undefined;
|
|
27
|
+
const outcome = await compactBashResult({
|
|
28
|
+
source: "opencode", command: event.input.command, visibleText: output.output, exitCode: 0,
|
|
29
|
+
// The plugin instance directory is not the session's execution directory.
|
|
30
|
+
inspectionPolicy: "skip-all", skipCommandNames: ["tokenjuice"],
|
|
31
|
+
genericFallbackMinSavedChars: 120, genericFallbackMaxRatio: 0.75,
|
|
32
|
+
skipGenericFallbackForCompoundCommands: true,
|
|
33
|
+
metadata: { source: "opencode-v2-tool-result" },
|
|
34
|
+
});
|
|
35
|
+
if (outcome.action !== "rewrite")
|
|
36
|
+
return undefined;
|
|
37
|
+
const text = outcome.result.inlineText;
|
|
38
|
+
return { ...result, output: { ...output, output: text }, content: [{ ...content[0], text }] };
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { compactBashResult } from "./compact-bash-result.js";
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
/** Qoder replaces the complete tool response with a string, not a partial object. */
|
|
6
|
+
export async function compactQoderResult(payload) {
|
|
7
|
+
if (!isRecord(payload) || payload.hook_event_name !== "PostToolUse" || payload.tool_name !== "Bash"
|
|
8
|
+
|| !isRecord(payload.tool_input) || typeof payload.tool_input.command !== "string"
|
|
9
|
+
|| !isRecord(payload.tool_response)) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const response = payload.tool_response;
|
|
13
|
+
if (typeof response.stdout !== "string" || typeof response.stderr !== "string"
|
|
14
|
+
|| response.exitCode !== 0 || response.interrupted === true
|
|
15
|
+
|| response.kind !== undefined || response.taskId !== undefined || response.outputFile !== undefined) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const outcome = await compactBashResult({
|
|
19
|
+
source: "qoder",
|
|
20
|
+
command: payload.tool_input.command,
|
|
21
|
+
visibleText: response.stdout,
|
|
22
|
+
exitCode: response.exitCode,
|
|
23
|
+
...(typeof payload.cwd === "string" ? { cwd: payload.cwd } : {}),
|
|
24
|
+
inspectionPolicy: "allow-safe-inventory",
|
|
25
|
+
skipCommandNames: ["tokenjuice"],
|
|
26
|
+
minSavedCharsAny: 8,
|
|
27
|
+
genericFallbackMinSavedChars: 120,
|
|
28
|
+
genericFallbackMaxRatio: 0.75,
|
|
29
|
+
skipGenericFallbackForCompoundCommands: true,
|
|
30
|
+
});
|
|
31
|
+
return outcome.action === "rewrite"
|
|
32
|
+
? JSON.stringify({ ...response, stdout: outcome.result.inlineText })
|
|
33
|
+
: undefined;
|
|
34
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Read a shell command without treating OpenClaw Code Mode as shell execution. */
|
|
2
|
+
export function readOpenClawShellCommand(input) {
|
|
3
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
4
|
+
return "";
|
|
5
|
+
}
|
|
6
|
+
// Code Mode pairs its JavaScript code with a command alias before hooks.
|
|
7
|
+
// Do not parse the source or trust the exec name: even a malformed/empty code
|
|
8
|
+
// field is ambiguous and must not opt arbitrary tool results into compaction.
|
|
9
|
+
if ("code" in input) {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
return "command" in input && typeof input.command === "string" ? input.command : "";
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function record(value) {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
/** Cline's native pre-tool control replaces the complete run_commands input. */
|
|
5
|
+
export function rewriteClineInput(payload, rewriteCommand) {
|
|
6
|
+
if (!record(payload) || payload.hookName !== "tool_call" || !record(payload.tool_call)
|
|
7
|
+
|| payload.tool_call.name !== "run_commands" || !record(payload.tool_call.input))
|
|
8
|
+
return undefined;
|
|
9
|
+
const input = payload.tool_call.input;
|
|
10
|
+
if (!Array.isArray(input.commands) || input.commands.length === 0
|
|
11
|
+
|| !input.commands.every(command => typeof command === "string" && command.trim()))
|
|
12
|
+
return undefined;
|
|
13
|
+
const original = input.commands;
|
|
14
|
+
const commands = original.map(rewriteCommand);
|
|
15
|
+
if (commands.every((command, index) => command === original[index]))
|
|
16
|
+
return undefined;
|
|
17
|
+
return { overrideInput: { ...input, commands } };
|
|
18
|
+
}
|
|
@@ -6,6 +6,5 @@ export declare function isRepositoryInventoryCommand(input: Pick<ToolExecutionIn
|
|
|
6
6
|
export declare function getRepositoryInventorySafety(command: string): RepositoryInventorySafety;
|
|
7
7
|
export declare function isSafeRepositoryInventoryPipeline(command: string): boolean;
|
|
8
8
|
export declare function isRepositoryInspectionCommand(input: Pick<ToolExecutionInput, "argv" | "command">): boolean;
|
|
9
|
-
export declare function hasCommandOnlyFileContentSummary(command: string): boolean;
|
|
10
9
|
export declare function getSafeRepositoryInventorySourceArgv(command: string): string[] | null;
|
|
11
10
|
export declare function getInspectionCommandSkipReason(command: string, policy: InspectionCommandPolicy): InspectionCommandSkipReason | null;
|
|
@@ -307,7 +307,7 @@ export function isRepositoryInspectionCommand(input) {
|
|
|
307
307
|
}
|
|
308
308
|
return false;
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
function hasCommandOnlyFileContentSummary(command) {
|
|
311
311
|
const effectiveCommand = stripLeadingCdPrefix(command);
|
|
312
312
|
return /\bpackage-lock\.json\b/u.test(effectiveCommand);
|
|
313
313
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readStringField(record: Record<string, unknown>, keys: readonly string[]): string | undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type CompactionMetadata } from "./compaction-metadata.js";
|
|
2
2
|
import type { ToolExecutionInput } from "../types.js";
|
|
3
|
-
|
|
3
|
+
type InspectionSummaryReducerId = "generic/package-lock-summary";
|
|
4
4
|
export type InspectionSummary = {
|
|
5
5
|
lines: string[];
|
|
6
6
|
matchedReducer: InspectionSummaryReducerId;
|
|
7
7
|
compaction: CompactionMetadata;
|
|
8
8
|
};
|
|
9
9
|
export declare function buildInspectionSummary(input: ToolExecutionInput, rawText: string, noOmit?: boolean): InspectionSummary | null;
|
|
10
|
+
export {};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { clipMiddleWithHash, parseJsonValue } from "./reduce-utils.js";
|
|
4
|
-
import { countTextChars, headTail, normalizeLines, stripAnsi, trimEmptyEdges } from "./text.js";
|
|
5
|
-
const LARGE_INSPECTION_MIN_CHARS = 4_000;
|
|
6
|
-
const LARGE_INSPECTION_MIN_LINES = 40;
|
|
1
|
+
import { createCompactionMetadata } from "./compaction-metadata.js";
|
|
2
|
+
import { parseJsonValue } from "./reduce-utils.js";
|
|
7
3
|
const PACKAGE_LOCK_RE = /\bpackage-lock\.json\b/u;
|
|
8
4
|
function buildPackageLockSummary(value, noOmit = false) {
|
|
9
5
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -30,96 +26,13 @@ function buildPackageLockSummary(value, noOmit = false) {
|
|
|
30
26
|
}
|
|
31
27
|
return lines;
|
|
32
28
|
}
|
|
33
|
-
function buildLargeDocumentSummary(lines, rawText, noOmit = false) {
|
|
34
|
-
const headings = lines
|
|
35
|
-
.map((line) => line.trim())
|
|
36
|
-
.filter((line) => /^#{1,6}\s+\S/u.test(line))
|
|
37
|
-
.slice(0, 24);
|
|
38
|
-
const excerpt = headTail(lines, 6, 6, noOmit);
|
|
39
|
-
const clippedHeadingCompactions = [];
|
|
40
|
-
const clippedHeadings = headings.map((line) => {
|
|
41
|
-
const clipped = clipMiddleWithHash(line, 180, noOmit);
|
|
42
|
-
if (clipped.compaction) {
|
|
43
|
-
clippedHeadingCompactions.push(clipped.compaction);
|
|
44
|
-
}
|
|
45
|
-
return `- ${clipped.text}`;
|
|
46
|
-
});
|
|
47
|
-
const clippedExcerptCompactions = [];
|
|
48
|
-
const excerptLines = excerpt.lines.map((line) => {
|
|
49
|
-
const clipped = clipMiddleWithHash(line, 180, noOmit);
|
|
50
|
-
if (clipped.compaction) {
|
|
51
|
-
clippedExcerptCompactions.push(clipped.compaction);
|
|
52
|
-
}
|
|
53
|
-
return clipped.text;
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
lines: [
|
|
57
|
-
`large document summary: ${lines.length} lines, ${countTextChars(rawText)} chars`,
|
|
58
|
-
...(clippedHeadings.length > 0 ? ["headings:", ...clippedHeadings] : []),
|
|
59
|
-
"excerpt:",
|
|
60
|
-
...excerptLines,
|
|
61
|
-
],
|
|
62
|
-
compaction: mergeCompactionMetadata(createCompactionMetadata("inspection-large-document-summary"), excerpt.compaction, ...clippedHeadingCompactions, ...clippedExcerptCompactions),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function isLikelyDocumentLine(line) {
|
|
66
|
-
const trimmed = line.trim();
|
|
67
|
-
if (trimmed.length < 50) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
if (/^(?:import|export|const|let|var|function|class|interface|type|return|if|for|while|switch|case|try|catch)\b/u.test(trimmed)) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
if (/^[{}()[\].,;:]/u.test(trimmed) || /[{};]$/u.test(trimmed)) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return /\s/u.test(trimmed);
|
|
77
|
-
}
|
|
78
|
-
function isLikelyCodeLine(line) {
|
|
79
|
-
const trimmed = line.trim();
|
|
80
|
-
if (!trimmed) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return /^(?:import|export|const|let|var|function|class|interface|type|return|if|for|while|switch|case|try|catch|\}|\{|\)|\])/u.test(trimmed)
|
|
84
|
-
|| /[{};]$/u.test(trimmed);
|
|
85
|
-
}
|
|
86
|
-
function isLargeDocumentOutput(lines, rawChars) {
|
|
87
|
-
if (rawChars < LARGE_INSPECTION_MIN_CHARS) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (lines.length < LARGE_INSPECTION_MIN_LINES) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
const nonEmptyLines = lines.filter((line) => line.trim() !== "");
|
|
94
|
-
const headingCount = nonEmptyLines.filter((line) => /^#{1,6}\s+\S/u.test(line.trim())).length;
|
|
95
|
-
const hasFrontmatter = nonEmptyLines[0]?.trim() === "---"
|
|
96
|
-
&& nonEmptyLines.slice(1, 20).some((line) => line.trim() === "---");
|
|
97
|
-
if (headingCount >= 2 || (hasFrontmatter && headingCount >= 1)) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
const documentLines = nonEmptyLines.filter(isLikelyDocumentLine).length;
|
|
101
|
-
const codeLines = nonEmptyLines.filter(isLikelyCodeLine).length;
|
|
102
|
-
return documentLines >= 20
|
|
103
|
-
&& documentLines / nonEmptyLines.length >= 0.5
|
|
104
|
-
&& codeLines / nonEmptyLines.length < 0.25;
|
|
105
|
-
}
|
|
106
29
|
export function buildInspectionSummary(input, rawText, noOmit = false) {
|
|
107
30
|
const command = input.command ?? "";
|
|
108
|
-
if (PACKAGE_LOCK_RE.test(command)) {
|
|
109
|
-
const lines = buildPackageLockSummary(parseJsonValue(rawText), noOmit);
|
|
110
|
-
return lines.length > 0
|
|
111
|
-
? { lines, matchedReducer: "generic/package-lock-summary", compaction: createCompactionMetadata("inspection-package-lock-summary") }
|
|
112
|
-
: null;
|
|
113
|
-
}
|
|
114
|
-
const rawChars = countTextChars(rawText);
|
|
115
|
-
const lines = trimEmptyEdges(normalizeLines(stripAnsi(rawText)));
|
|
116
|
-
if (!isFileContentInspectionCommand(input) || !isLargeDocumentOutput(lines, rawChars)) {
|
|
31
|
+
if (!PACKAGE_LOCK_RE.test(command)) {
|
|
117
32
|
return null;
|
|
118
33
|
}
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
lines: summary
|
|
122
|
-
|
|
123
|
-
compaction: summary.compaction,
|
|
124
|
-
};
|
|
34
|
+
const lines = buildPackageLockSummary(parseJsonValue(rawText), noOmit);
|
|
35
|
+
return lines.length > 0
|
|
36
|
+
? { lines, matchedReducer: "generic/package-lock-summary", compaction: createCompactionMetadata("inspection-package-lock-summary") }
|
|
37
|
+
: null;
|
|
125
38
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function stripYamlComment(value: string): {
|
|
2
|
+
value: string;
|
|
3
|
+
isValid: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function isValidDoubleQuotedYamlScalar(value: string): boolean;
|
|
6
|
+
export declare function parseSimpleYamlFrontmatter(frontmatter: string[], isValidSimpleYamlScalar: (rawValue: string) => boolean): {
|
|
7
|
+
hasValidYaml: boolean;
|
|
8
|
+
values: Map<string, string>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export function stripYamlComment(value) {
|
|
2
|
+
let quote;
|
|
3
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
4
|
+
const char = value[index];
|
|
5
|
+
if (quote === "\"") {
|
|
6
|
+
if (char === "\\" && index + 1 < value.length) {
|
|
7
|
+
index += 1;
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
if (char === "\"") {
|
|
11
|
+
quote = undefined;
|
|
12
|
+
}
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (quote === "'") {
|
|
16
|
+
if (char === "'" && value[index + 1] === "'") {
|
|
17
|
+
index += 1;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (char === "'") {
|
|
21
|
+
quote = undefined;
|
|
22
|
+
}
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (char === "\"" || char === "'") {
|
|
26
|
+
quote = char;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (char === "#" && (index === 0 || /\s/u.test(value[index - 1] ?? ""))) {
|
|
30
|
+
return { value: value.slice(0, index).trim(), isValid: true };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { value: value.trim(), isValid: quote === undefined };
|
|
34
|
+
}
|
|
35
|
+
function hasHexDigits(value, start, length) {
|
|
36
|
+
if (start + length > value.length) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return /^[0-9A-Fa-f]+$/u.test(value.slice(start, start + length));
|
|
40
|
+
}
|
|
41
|
+
export function isValidDoubleQuotedYamlScalar(value) {
|
|
42
|
+
if (!value.startsWith("\"") || !value.endsWith("\"")) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
for (let index = 1; index < value.length - 1; index += 1) {
|
|
46
|
+
if (value[index] === "\"") {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (value[index] !== "\\") {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const escape = value[index + 1];
|
|
53
|
+
if (!escape) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if ("0abtnvfre\"/\\N_LP".includes(escape)) {
|
|
57
|
+
index += 1;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const hexLength = escape === "x" ? 2 : escape === "u" ? 4 : escape === "U" ? 8 : 0;
|
|
61
|
+
if (hexLength === 0 || !hasHexDigits(value, index + 2, hexLength)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
index += 1 + hexLength;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
function isYamlBlockScalarHeader(value) {
|
|
69
|
+
return /^[|>](?:[+-][1-9]?|[1-9][+-]?)?$/u.test(value);
|
|
70
|
+
}
|
|
71
|
+
function normalizeYamlScalar(value) {
|
|
72
|
+
if (value.startsWith("\"") && value.endsWith("\"")) {
|
|
73
|
+
return value.slice(1, -1).replace(/\\(["\\])/gu, "$1");
|
|
74
|
+
}
|
|
75
|
+
if (value.startsWith("'") && value.endsWith("'")) {
|
|
76
|
+
return value.slice(1, -1).replace(/''/gu, "'");
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
export function parseSimpleYamlFrontmatter(frontmatter, isValidSimpleYamlScalar) {
|
|
81
|
+
const values = new Map();
|
|
82
|
+
for (let index = 0; index < frontmatter.length; index += 1) {
|
|
83
|
+
const line = frontmatter[index] ?? "";
|
|
84
|
+
const trimmedLine = line.trim();
|
|
85
|
+
if (trimmedLine === "" || trimmedLine.startsWith("#")) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const match = /^\s*([A-Za-z0-9_-]+):\s*(.*)$/u.exec(line);
|
|
89
|
+
if (!match) {
|
|
90
|
+
return { hasValidYaml: false, values };
|
|
91
|
+
}
|
|
92
|
+
const key = match[1] ?? "";
|
|
93
|
+
if (values.has(key)) {
|
|
94
|
+
return { hasValidYaml: false, values };
|
|
95
|
+
}
|
|
96
|
+
const rawValue = match[2] ?? "";
|
|
97
|
+
const stripped = stripYamlComment(rawValue);
|
|
98
|
+
if (!stripped.isValid) {
|
|
99
|
+
return { hasValidYaml: false, values };
|
|
100
|
+
}
|
|
101
|
+
if (isYamlBlockScalarHeader(stripped.value)) {
|
|
102
|
+
const blockLines = [];
|
|
103
|
+
for (index += 1; index < frontmatter.length; index += 1) {
|
|
104
|
+
const blockLine = frontmatter[index] ?? "";
|
|
105
|
+
if (blockLine.trim() === "") {
|
|
106
|
+
blockLines.push("");
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (/^\s/u.test(blockLine)) {
|
|
110
|
+
blockLines.push(blockLine.trimEnd());
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
index -= 1;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
values.set(key, blockLines.join("\n").trim());
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (!isValidSimpleYamlScalar(rawValue)) {
|
|
120
|
+
return { hasValidYaml: false, values };
|
|
121
|
+
}
|
|
122
|
+
values.set(key, normalizeYamlScalar(stripped.value));
|
|
123
|
+
}
|
|
124
|
+
return { hasValidYaml: true, values };
|
|
125
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ToolExecutionInput } from "../types.js";
|
|
2
2
|
export declare const UNKNOWN_ARTIFACT_SOURCE = "unknown";
|
|
3
|
-
export declare const DEFAULT_CLI_ARTIFACT_SOURCE = "cli";
|
|
4
3
|
export declare function normalizeArtifactSource(value: unknown): string | null;
|
|
5
4
|
export declare function resolveArtifactSource(input: ToolExecutionInput): string;
|
|
6
5
|
export declare function readStoredArtifactSource(source: string | undefined): string;
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
export const UNKNOWN_ARTIFACT_SOURCE = "unknown";
|
|
2
|
-
|
|
2
|
+
const DEFAULT_CLI_ARTIFACT_SOURCE = "cli";
|
|
3
|
+
function trimHyphens(value) {
|
|
4
|
+
let start = 0;
|
|
5
|
+
let end = value.length;
|
|
6
|
+
while (value[start] === "-") {
|
|
7
|
+
start += 1;
|
|
8
|
+
}
|
|
9
|
+
while (end > start && value[end - 1] === "-") {
|
|
10
|
+
end -= 1;
|
|
11
|
+
}
|
|
12
|
+
return value.slice(start, end);
|
|
13
|
+
}
|
|
3
14
|
export function normalizeArtifactSource(value) {
|
|
4
15
|
if (typeof value !== "string") {
|
|
5
16
|
return null;
|
|
6
17
|
}
|
|
7
|
-
const source = value
|
|
18
|
+
const source = trimHyphens(value
|
|
8
19
|
.trim()
|
|
9
20
|
.toLowerCase()
|
|
10
21
|
.replace(/[_\s]+/gu, "-")
|
|
11
|
-
.replace(/[^a-z0-9.-]+/gu, "-")
|
|
12
|
-
.replace(/^-+|-+$/gu, "");
|
|
22
|
+
.replace(/[^a-z0-9.-]+/gu, "-"));
|
|
13
23
|
if (!source) {
|
|
14
24
|
return null;
|
|
15
25
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function createStructuredMarkerInspector(beginMarker: string, endMarker: string, getStructureLines: (lines: readonly string[]) => string[]): {
|
|
2
|
+
findTokenjuiceBlockLineRange: (text: string) => {
|
|
3
|
+
lines: string[];
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
} | undefined;
|
|
7
|
+
hasMalformedMarkerStructure: (text: string) => boolean;
|
|
8
|
+
hasStructuralTokenjuiceMarker: (text: string) => boolean;
|
|
9
|
+
hasTokenjuiceBlock: (text: string) => boolean;
|
|
10
|
+
getTokenjuiceBlockText: (text: string) => string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function createStructuredMarkerInspector(beginMarker, endMarker, getStructureLines) {
|
|
2
|
+
function getStructuralMarkerLines(text, marker) {
|
|
3
|
+
const lines = text.split("\n");
|
|
4
|
+
const structureLines = getStructureLines(lines);
|
|
5
|
+
return {
|
|
6
|
+
lines,
|
|
7
|
+
markerLines: structureLines.flatMap((line, index) => (line.trim() === marker ? [index] : [])),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function findTokenjuiceBlockLineRange(text) {
|
|
11
|
+
const begin = getStructuralMarkerLines(text, beginMarker);
|
|
12
|
+
const end = getStructuralMarkerLines(text, endMarker);
|
|
13
|
+
if (begin.markerLines.length !== 1 || end.markerLines.length !== 1 || end.markerLines[0] < begin.markerLines[0]) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
lines: begin.lines,
|
|
18
|
+
start: begin.markerLines[0],
|
|
19
|
+
end: end.markerLines[0] + 1,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function hasMalformedMarkerStructure(text) {
|
|
23
|
+
const begin = getStructuralMarkerLines(text, beginMarker);
|
|
24
|
+
const end = getStructuralMarkerLines(text, endMarker);
|
|
25
|
+
const beginCount = begin.markerLines.length;
|
|
26
|
+
const endCount = end.markerLines.length;
|
|
27
|
+
return beginCount !== endCount || beginCount > 1 || endCount > 1 || (beginCount === 1 && end.markerLines[0] < begin.markerLines[0]);
|
|
28
|
+
}
|
|
29
|
+
function hasStructuralTokenjuiceMarker(text) {
|
|
30
|
+
return getStructuralMarkerLines(text, beginMarker).markerLines.length > 0 || getStructuralMarkerLines(text, endMarker).markerLines.length > 0;
|
|
31
|
+
}
|
|
32
|
+
function hasTokenjuiceBlock(text) {
|
|
33
|
+
return Boolean(findTokenjuiceBlockLineRange(text));
|
|
34
|
+
}
|
|
35
|
+
function getTokenjuiceBlockText(text) {
|
|
36
|
+
const range = findTokenjuiceBlockLineRange(text);
|
|
37
|
+
if (!range) {
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
return range.lines.slice(range.start, range.end).join("\n");
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
findTokenjuiceBlockLineRange,
|
|
44
|
+
hasMalformedMarkerStructure,
|
|
45
|
+
hasStructuralTokenjuiceMarker,
|
|
46
|
+
hasTokenjuiceBlock,
|
|
47
|
+
getTokenjuiceBlockText,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -19,7 +19,6 @@ export declare function clampTextWithMetadata(text: string, maxChars: number, no
|
|
|
19
19
|
text: string;
|
|
20
20
|
compaction?: CompactionMetadata;
|
|
21
21
|
};
|
|
22
|
-
export declare function clampTextMiddle(text: string, maxChars: number): string;
|
|
23
22
|
export declare function clampTextMiddleWithMetadata(text: string, maxChars: number, noOmit?: boolean): {
|
|
24
23
|
text: string;
|
|
25
24
|
compaction?: CompactionMetadata;
|
|
@@ -194,9 +194,6 @@ export function clampTextWithMetadata(text, maxChars, noOmit = false) {
|
|
|
194
194
|
compaction: createCompactionMetadata("tail-truncation"),
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
-
export function clampTextMiddle(text, maxChars) {
|
|
198
|
-
return clampTextMiddleWithMetadata(text, maxChars).text;
|
|
199
|
-
}
|
|
200
197
|
export function clampTextMiddleWithMetadata(text, maxChars, noOmit = false) {
|
|
201
198
|
if (countTextChars(text) <= maxChars) {
|
|
202
199
|
return { text };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function isEscaped(text, index) {
|
|
2
|
+
let slashCount = 0;
|
|
3
|
+
for (let cursor = index - 1; cursor >= 0 && text[cursor] === "\\"; cursor -= 1) {
|
|
4
|
+
slashCount += 1;
|
|
5
|
+
}
|
|
6
|
+
return slashCount % 2 === 1;
|
|
7
|
+
}
|
|
8
|
+
function findTomlMultilineClose(line, delimiter, fromIndex) {
|
|
9
|
+
let searchIndex = fromIndex;
|
|
10
|
+
while (searchIndex < line.length) {
|
|
11
|
+
const closeIndex = line.indexOf(delimiter, searchIndex);
|
|
12
|
+
if (closeIndex === -1) {
|
|
13
|
+
return -1;
|
|
14
|
+
}
|
|
15
|
+
if (delimiter === "'''" || !isEscaped(line, closeIndex)) {
|
|
16
|
+
return closeIndex;
|
|
17
|
+
}
|
|
18
|
+
searchIndex = closeIndex + 1;
|
|
19
|
+
}
|
|
20
|
+
return -1;
|
|
21
|
+
}
|
|
22
|
+
function updateTomlMultilineState(line, state) {
|
|
23
|
+
let index = 0;
|
|
24
|
+
let inBasicString = false;
|
|
25
|
+
let inLiteralString = false;
|
|
26
|
+
while (index < line.length) {
|
|
27
|
+
if (state.delimiter) {
|
|
28
|
+
const closeIndex = findTomlMultilineClose(line, state.delimiter, index);
|
|
29
|
+
if (closeIndex === -1) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
index = closeIndex + state.delimiter.length;
|
|
33
|
+
state.delimiter = undefined;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const next = line.slice(index, index + 3);
|
|
37
|
+
const char = line[index];
|
|
38
|
+
if (inBasicString) {
|
|
39
|
+
if (char === "\"" && !isEscaped(line, index)) {
|
|
40
|
+
inBasicString = false;
|
|
41
|
+
}
|
|
42
|
+
index += 1;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (inLiteralString) {
|
|
46
|
+
if (char === "'") {
|
|
47
|
+
inLiteralString = false;
|
|
48
|
+
}
|
|
49
|
+
index += 1;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (char === "#") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (next === "\"\"\"" || next === "'''") {
|
|
56
|
+
const closeIndex = findTomlMultilineClose(line, next, index + next.length);
|
|
57
|
+
if (closeIndex === -1) {
|
|
58
|
+
state.delimiter = next;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
index = closeIndex + next.length;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (char === "\"") {
|
|
65
|
+
inBasicString = true;
|
|
66
|
+
}
|
|
67
|
+
else if (char === "'") {
|
|
68
|
+
inLiteralString = true;
|
|
69
|
+
}
|
|
70
|
+
index += 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function getTomlStructureLines(lines) {
|
|
74
|
+
const state = { delimiter: undefined };
|
|
75
|
+
return lines.map((line) => {
|
|
76
|
+
const structuralLine = state.delimiter ? "" : line;
|
|
77
|
+
updateTomlMultilineState(line, state);
|
|
78
|
+
return structuralLine;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export function isTomlTableHeader(line) {
|
|
82
|
+
return /^\s*(?:\[[^\]\n]+\]|\[\[[^\]\n]+\]\])\s*(?:#.*)?$/u.test(line);
|
|
83
|
+
}
|