@kenkaiiii/gg-engine 0.0.0-stage → 7.0.0
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/LICENSE +661 -0
- package/NOTICE +43 -0
- package/README.md +53 -2
- package/assets/skills/bulletproof/SKILL.md +132 -0
- package/assets/skills/bulletproof/references/agent-surface.md +113 -0
- package/assets/skills/bulletproof/references/attack-classes.md +226 -0
- package/assets/skills/bulletproof/references/audit-protocol.md +232 -0
- package/assets/skills/bulletproof/references/platform-playbooks.md +196 -0
- package/assets/skills/bulletproof/references/provenance.md +146 -0
- package/assets/skills/bulletproof/references/secure-defaults.md +137 -0
- package/assets/skills/bulletproof/references/supply-chain.md +84 -0
- package/assets/skills/bulletproof/references/threat-landscape.md +66 -0
- package/assets/skills/bulletproof/references/verification.md +74 -0
- package/assets/skills/compliance-guard/SKILL.md +115 -0
- package/assets/skills/compliance-guard/references/artifacts.md +199 -0
- package/assets/skills/compliance-guard/references/eu-uk.md +162 -0
- package/assets/skills/compliance-guard/references/exposure-triage.md +177 -0
- package/assets/skills/compliance-guard/references/full-review.md +155 -0
- package/assets/skills/compliance-guard/references/lawsuit-vectors.md +153 -0
- package/assets/skills/compliance-guard/references/provenance.md +135 -0
- package/assets/skills/compliance-guard/references/sector-gates.md +187 -0
- package/assets/skills/compliance-guard/references/security-baseline.md +117 -0
- package/assets/skills/compliance-guard/references/trigger-map.md +177 -0
- package/assets/skills/compliance-guard/references/us.md +194 -0
- package/assets/skills/durable/SKILL.md +114 -0
- package/assets/skills/durable/references/agent-db-safety.md +76 -0
- package/assets/skills/durable/references/backups-and-runtime.md +93 -0
- package/assets/skills/durable/references/migrations-and-schema.md +87 -0
- package/assets/skills/gg-guide/SKILL.md +43 -0
- package/assets/skills/gg-guide/references/chat-motion-goals.md +217 -0
- package/assets/skills/gg-guide/references/checklist-and-safety.md +177 -0
- package/assets/skills/gg-guide/references/code-mode.md +269 -0
- package/assets/skills/gg-guide/references/getting-started.md +290 -0
- package/assets/skills/gg-guide/references/ken-and-autopilot.md +172 -0
- package/assets/skills/gg-guide/references/mcp-and-skills.md +204 -0
- package/assets/skills/gg-guide/references/models-and-sign-in.md +200 -0
- package/assets/skills/gg-guide/references/sessions-and-history.md +213 -0
- package/assets/skills/gg-guide/references/settings.md +193 -0
- package/assets/skills/gg-guide/references/troubleshooting-and-data.md +186 -0
- package/assets/skills/lean/SKILL.md +117 -0
- package/assets/skills/lean/references/memory-and-processes.md +99 -0
- package/assets/skills/lean/references/playbooks.md +134 -0
- package/dist/app-error.d.ts +22 -0
- package/dist/app-error.js +41 -0
- package/dist/app-error.js.map +1 -0
- package/dist/config.d.ts +90 -0
- package/dist/config.js +240 -0
- package/dist/config.js.map +1 -0
- package/dist/core/acceptance-checks.d.ts +48 -0
- package/dist/core/acceptance-checks.js +151 -0
- package/dist/core/acceptance-checks.js.map +1 -0
- package/dist/core/action-threats.d.ts +68 -0
- package/dist/core/action-threats.js +894 -0
- package/dist/core/action-threats.js.map +1 -0
- package/dist/core/agent-notifications.d.ts +79 -0
- package/dist/core/agent-notifications.js +125 -0
- package/dist/core/agent-notifications.js.map +1 -0
- package/dist/core/agent-session/helpers.d.ts +26 -0
- package/dist/core/agent-session/helpers.js +47 -0
- package/dist/core/agent-session/helpers.js.map +1 -0
- package/dist/core/agent-session/mcp-tools.d.ts +87 -0
- package/dist/core/agent-session/mcp-tools.js +227 -0
- package/dist/core/agent-session/mcp-tools.js.map +1 -0
- package/dist/core/agent-session/run-loop-monitor.d.ts +63 -0
- package/dist/core/agent-session/run-loop-monitor.js +164 -0
- package/dist/core/agent-session/run-loop-monitor.js.map +1 -0
- package/dist/core/agent-session/transcript-markers.d.ts +57 -0
- package/dist/core/agent-session/transcript-markers.js +166 -0
- package/dist/core/agent-session/transcript-markers.js.map +1 -0
- package/dist/core/agent-session/verification-tracker.d.ts +71 -0
- package/dist/core/agent-session/verification-tracker.js +295 -0
- package/dist/core/agent-session/verification-tracker.js.map +1 -0
- package/dist/core/agent-session.d.ts +1401 -0
- package/dist/core/agent-session.js +5160 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/agents.d.ts +63 -0
- package/dist/core/agents.js +160 -0
- package/dist/core/agents.js.map +1 -0
- package/dist/core/ask-user.d.ts +163 -0
- package/dist/core/ask-user.js +178 -0
- package/dist/core/ask-user.js.map +1 -0
- package/dist/core/auto-update.d.ts +32 -0
- package/dist/core/auto-update.js +218 -0
- package/dist/core/auto-update.js.map +1 -0
- package/dist/core/autopilot-cycle.d.ts +127 -0
- package/dist/core/autopilot-cycle.js +182 -0
- package/dist/core/autopilot-cycle.js.map +1 -0
- package/dist/core/autopilot-gate.d.ts +106 -0
- package/dist/core/autopilot-gate.js +192 -0
- package/dist/core/autopilot-gate.js.map +1 -0
- package/dist/core/autopilot-verdict.d.ts +55 -0
- package/dist/core/autopilot-verdict.js +226 -0
- package/dist/core/autopilot-verdict.js.map +1 -0
- package/dist/core/blocked-packages-file.d.ts +33 -0
- package/dist/core/blocked-packages-file.js +274 -0
- package/dist/core/blocked-packages-file.js.map +1 -0
- package/dist/core/bundled-agents.d.ts +2 -0
- package/dist/core/bundled-agents.js +253 -0
- package/dist/core/bundled-agents.js.map +1 -0
- package/dist/core/cache-diagnostics.d.ts +72 -0
- package/dist/core/cache-diagnostics.js +200 -0
- package/dist/core/cache-diagnostics.js.map +1 -0
- package/dist/core/cache-expiry.d.ts +89 -0
- package/dist/core/cache-expiry.js +117 -0
- package/dist/core/cache-expiry.js.map +1 -0
- package/dist/core/checklist-detection.d.ts +8 -0
- package/dist/core/checklist-detection.js +238 -0
- package/dist/core/checklist-detection.js.map +1 -0
- package/dist/core/checklist-git.d.ts +19 -0
- package/dist/core/checklist-git.js +54 -0
- package/dist/core/checklist-git.js.map +1 -0
- package/dist/core/checklist-items.d.ts +182 -0
- package/dist/core/checklist-items.js +228 -0
- package/dist/core/checklist-items.js.map +1 -0
- package/dist/core/checklist-prompt.d.ts +14 -0
- package/dist/core/checklist-prompt.js +64 -0
- package/dist/core/checklist-prompt.js.map +1 -0
- package/dist/core/checklist-snapshot.d.ts +7 -0
- package/dist/core/checklist-snapshot.js +46 -0
- package/dist/core/checklist-snapshot.js.map +1 -0
- package/dist/core/checklist-store.d.ts +45 -0
- package/dist/core/checklist-store.js +278 -0
- package/dist/core/checklist-store.js.map +1 -0
- package/dist/core/checkout-record.d.ts +22 -0
- package/dist/core/checkout-record.js +68 -0
- package/dist/core/checkout-record.js.map +1 -0
- package/dist/core/checkpoint-store.d.ts +109 -0
- package/dist/core/checkpoint-store.js +260 -0
- package/dist/core/checkpoint-store.js.map +1 -0
- package/dist/core/claude-code/complete.d.ts +35 -0
- package/dist/core/claude-code/complete.js +125 -0
- package/dist/core/claude-code/complete.js.map +1 -0
- package/dist/core/claude-code/events.d.ts +67 -0
- package/dist/core/claude-code/events.js +460 -0
- package/dist/core/claude-code/events.js.map +1 -0
- package/dist/core/claude-code/live-session.d.ts +94 -0
- package/dist/core/claude-code/live-session.js +525 -0
- package/dist/core/claude-code/live-session.js.map +1 -0
- package/dist/core/claude-code/loop.d.ts +9 -0
- package/dist/core/claude-code/loop.js +15 -0
- package/dist/core/claude-code/loop.js.map +1 -0
- package/dist/core/claude-code/session-sync.d.ts +28 -0
- package/dist/core/claude-code/session-sync.js +53 -0
- package/dist/core/claude-code/session-sync.js.map +1 -0
- package/dist/core/claude-code/tool-bridge.d.ts +49 -0
- package/dist/core/claude-code/tool-bridge.js +352 -0
- package/dist/core/claude-code/tool-bridge.js.map +1 -0
- package/dist/core/claude-code/transcripts.d.ts +39 -0
- package/dist/core/claude-code/transcripts.js +195 -0
- package/dist/core/claude-code/transcripts.js.map +1 -0
- package/dist/core/code-retrieval-chunkers.d.ts +26 -0
- package/dist/core/code-retrieval-chunkers.js +264 -0
- package/dist/core/code-retrieval-chunkers.js.map +1 -0
- package/dist/core/code-retrieval.d.ts +18 -0
- package/dist/core/code-retrieval.js +124 -0
- package/dist/core/code-retrieval.js.map +1 -0
- package/dist/core/codex-request-shape.d.ts +7 -0
- package/dist/core/codex-request-shape.js +19 -0
- package/dist/core/codex-request-shape.js.map +1 -0
- package/dist/core/compaction/active-context.d.ts +16 -0
- package/dist/core/compaction/active-context.js +20 -0
- package/dist/core/compaction/active-context.js.map +1 -0
- package/dist/core/compaction/compactor.d.ts +281 -0
- package/dist/core/compaction/compactor.js +1451 -0
- package/dist/core/compaction/compactor.js.map +1 -0
- package/dist/core/compaction/plan-step-policy.d.ts +46 -0
- package/dist/core/compaction/plan-step-policy.js +57 -0
- package/dist/core/compaction/plan-step-policy.js.map +1 -0
- package/dist/core/compaction/policy.d.ts +36 -0
- package/dist/core/compaction/policy.js +144 -0
- package/dist/core/compaction/policy.js.map +1 -0
- package/dist/core/compaction/query-aware-selector.d.ts +32 -0
- package/dist/core/compaction/query-aware-selector.js +202 -0
- package/dist/core/compaction/query-aware-selector.js.map +1 -0
- package/dist/core/compaction/token-estimator.d.ts +36 -0
- package/dist/core/compaction/token-estimator.js +180 -0
- package/dist/core/compaction/token-estimator.js.map +1 -0
- package/dist/core/compaction/tool-result-pruner.d.ts +90 -0
- package/dist/core/compaction/tool-result-pruner.js +238 -0
- package/dist/core/compaction/tool-result-pruner.js.map +1 -0
- package/dist/core/completion-review.d.ts +24 -0
- package/dist/core/completion-review.js +2 -0
- package/dist/core/completion-review.js.map +1 -0
- package/dist/core/context-files.d.ts +8 -0
- package/dist/core/context-files.js +46 -0
- package/dist/core/context-files.js.map +1 -0
- package/dist/core/context-limits.d.ts +40 -0
- package/dist/core/context-limits.js +43 -0
- package/dist/core/context-limits.js.map +1 -0
- package/dist/core/custom-commands.d.ts +18 -0
- package/dist/core/custom-commands.js +57 -0
- package/dist/core/custom-commands.js.map +1 -0
- package/dist/core/destructive-git-guard.d.ts +113 -0
- package/dist/core/destructive-git-guard.js +874 -0
- package/dist/core/destructive-git-guard.js.map +1 -0
- package/dist/core/display-items.d.ts +8 -0
- package/dist/core/display-items.js +2 -0
- package/dist/core/display-items.js.map +1 -0
- package/dist/core/encode-cwd.d.ts +41 -0
- package/dist/core/encode-cwd.js +53 -0
- package/dist/core/encode-cwd.js.map +1 -0
- package/dist/core/env-delta.d.ts +34 -0
- package/dist/core/env-delta.js +84 -0
- package/dist/core/env-delta.js.map +1 -0
- package/dist/core/event-bus.d.ts +178 -0
- package/dist/core/event-bus.js +171 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +7 -0
- package/dist/core/extensions/loader.js +68 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/plugin-bundles.d.ts +13 -0
- package/dist/core/extensions/plugin-bundles.js +45 -0
- package/dist/core/extensions/plugin-bundles.js.map +1 -0
- package/dist/core/extensions/types.d.ts +18 -0
- package/dist/core/extensions/types.js +2 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/foreign-session-import.d.ts +119 -0
- package/dist/core/foreign-session-import.js +598 -0
- package/dist/core/foreign-session-import.js.map +1 -0
- package/dist/core/foreign-transcript-blocks.d.ts +50 -0
- package/dist/core/foreign-transcript-blocks.js +151 -0
- package/dist/core/foreign-transcript-blocks.js.map +1 -0
- package/dist/core/frontmatter.d.ts +22 -0
- package/dist/core/frontmatter.js +90 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/goal-run-marker.d.ts +32 -0
- package/dist/core/goal-run-marker.js +178 -0
- package/dist/core/goal-run-marker.js.map +1 -0
- package/dist/core/goal-summary.d.ts +15 -0
- package/dist/core/goal-summary.js +110 -0
- package/dist/core/goal-summary.js.map +1 -0
- package/dist/core/goals-store.d.ts +208 -0
- package/dist/core/goals-store.js +577 -0
- package/dist/core/goals-store.js.map +1 -0
- package/dist/core/hashline.d.ts +51 -0
- package/dist/core/hashline.js +76 -0
- package/dist/core/hashline.js.map +1 -0
- package/dist/core/idle-wake.d.ts +62 -0
- package/dist/core/idle-wake.js +103 -0
- package/dist/core/idle-wake.js.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.js +15 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/injection-detect.d.ts +39 -0
- package/dist/core/injection-detect.js +241 -0
- package/dist/core/injection-detect.js.map +1 -0
- package/dist/core/installed-threats.d.ts +23 -0
- package/dist/core/installed-threats.js +71 -0
- package/dist/core/installed-threats.js.map +1 -0
- package/dist/core/internal-diagnostics.d.ts +159 -0
- package/dist/core/internal-diagnostics.js +495 -0
- package/dist/core/internal-diagnostics.js.map +1 -0
- package/dist/core/keep-awake.d.ts +88 -0
- package/dist/core/keep-awake.js +251 -0
- package/dist/core/keep-awake.js.map +1 -0
- package/dist/core/ken-ask-answer.d.ts +24 -0
- package/dist/core/ken-ask-answer.js +96 -0
- package/dist/core/ken-ask-answer.js.map +1 -0
- package/dist/core/ken-context.d.ts +119 -0
- package/dist/core/ken-context.js +447 -0
- package/dist/core/ken-context.js.map +1 -0
- package/dist/core/ken-model.d.ts +45 -0
- package/dist/core/ken-model.js +26 -0
- package/dist/core/ken-model.js.map +1 -0
- package/dist/core/ken-prompt.d.ts +21 -0
- package/dist/core/ken-prompt.js +370 -0
- package/dist/core/ken-prompt.js.map +1 -0
- package/dist/core/language-detector.d.ts +41 -0
- package/dist/core/language-detector.js +293 -0
- package/dist/core/language-detector.js.map +1 -0
- package/dist/core/live-preview.d.ts +26 -0
- package/dist/core/live-preview.js +80 -0
- package/dist/core/live-preview.js.map +1 -0
- package/dist/core/local-endpoint-store.d.ts +53 -0
- package/dist/core/local-endpoint-store.js +221 -0
- package/dist/core/local-endpoint-store.js.map +1 -0
- package/dist/core/logger.d.ts +21 -0
- package/dist/core/logger.js +94 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/loop-breaker.d.ts +89 -0
- package/dist/core/loop-breaker.js +204 -0
- package/dist/core/loop-breaker.js.map +1 -0
- package/dist/core/lsp/client.d.ts +206 -0
- package/dist/core/lsp/client.js +685 -0
- package/dist/core/lsp/client.js.map +1 -0
- package/dist/core/lsp/edit-telemetry.d.ts +26 -0
- package/dist/core/lsp/edit-telemetry.js +52 -0
- package/dist/core/lsp/edit-telemetry.js.map +1 -0
- package/dist/core/lsp/format.d.ts +11 -0
- package/dist/core/lsp/format.js +30 -0
- package/dist/core/lsp/format.js.map +1 -0
- package/dist/core/lsp/jsonrpc.d.ts +68 -0
- package/dist/core/lsp/jsonrpc.js +153 -0
- package/dist/core/lsp/jsonrpc.js.map +1 -0
- package/dist/core/lsp/manager.d.ts +188 -0
- package/dist/core/lsp/manager.js +576 -0
- package/dist/core/lsp/manager.js.map +1 -0
- package/dist/core/lsp/pool.d.ts +114 -0
- package/dist/core/lsp/pool.js +259 -0
- package/dist/core/lsp/pool.js.map +1 -0
- package/dist/core/lsp/project-root.d.ts +9 -0
- package/dist/core/lsp/project-root.js +75 -0
- package/dist/core/lsp/project-root.js.map +1 -0
- package/dist/core/lsp/reference-project.d.ts +6 -0
- package/dist/core/lsp/reference-project.js +110 -0
- package/dist/core/lsp/reference-project.js.map +1 -0
- package/dist/core/lsp/servers.d.ts +44 -0
- package/dist/core/lsp/servers.js +289 -0
- package/dist/core/lsp/servers.js.map +1 -0
- package/dist/core/lsp/test-support.d.ts +17 -0
- package/dist/core/lsp/test-support.js +27 -0
- package/dist/core/lsp/test-support.js.map +1 -0
- package/dist/core/mcp/catalog-cache.d.ts +64 -0
- package/dist/core/mcp/catalog-cache.js +166 -0
- package/dist/core/mcp/catalog-cache.js.map +1 -0
- package/dist/core/mcp/client.d.ts +317 -0
- package/dist/core/mcp/client.js +1168 -0
- package/dist/core/mcp/client.js.map +1 -0
- package/dist/core/mcp/content.d.ts +23 -0
- package/dist/core/mcp/content.js +194 -0
- package/dist/core/mcp/content.js.map +1 -0
- package/dist/core/mcp/defaults.d.ts +26 -0
- package/dist/core/mcp/defaults.js +81 -0
- package/dist/core/mcp/defaults.js.map +1 -0
- package/dist/core/mcp/deferred-catalog.d.ts +53 -0
- package/dist/core/mcp/deferred-catalog.js +117 -0
- package/dist/core/mcp/deferred-catalog.js.map +1 -0
- package/dist/core/mcp/elicitation-bridge.d.ts +40 -0
- package/dist/core/mcp/elicitation-bridge.js +36 -0
- package/dist/core/mcp/elicitation-bridge.js.map +1 -0
- package/dist/core/mcp/index.d.ts +16 -0
- package/dist/core/mcp/index.js +10 -0
- package/dist/core/mcp/index.js.map +1 -0
- package/dist/core/mcp/loopback.d.ts +26 -0
- package/dist/core/mcp/loopback.js +66 -0
- package/dist/core/mcp/loopback.js.map +1 -0
- package/dist/core/mcp/oauth-provider.d.ts +55 -0
- package/dist/core/mcp/oauth-provider.js +106 -0
- package/dist/core/mcp/oauth-provider.js.map +1 -0
- package/dist/core/mcp/oauth-store.d.ts +44 -0
- package/dist/core/mcp/oauth-store.js +76 -0
- package/dist/core/mcp/oauth-store.js.map +1 -0
- package/dist/core/mcp/parse-add-command.d.ts +50 -0
- package/dist/core/mcp/parse-add-command.js +391 -0
- package/dist/core/mcp/parse-add-command.js.map +1 -0
- package/dist/core/mcp/resolve-stdio.d.ts +77 -0
- package/dist/core/mcp/resolve-stdio.js +359 -0
- package/dist/core/mcp/resolve-stdio.js.map +1 -0
- package/dist/core/mcp/shared-pool.d.ts +157 -0
- package/dist/core/mcp/shared-pool.js +236 -0
- package/dist/core/mcp/shared-pool.js.map +1 -0
- package/dist/core/mcp/store.d.ts +100 -0
- package/dist/core/mcp/store.js +202 -0
- package/dist/core/mcp/store.js.map +1 -0
- package/dist/core/mcp/tool-guard.d.ts +58 -0
- package/dist/core/mcp/tool-guard.js +215 -0
- package/dist/core/mcp/tool-guard.js.map +1 -0
- package/dist/core/mcp/types.d.ts +57 -0
- package/dist/core/mcp/types.js +2 -0
- package/dist/core/mcp/types.js.map +1 -0
- package/dist/core/message-images.d.ts +11 -0
- package/dist/core/message-images.js +52 -0
- package/dist/core/message-images.js.map +1 -0
- package/dist/core/model-unavailable.d.ts +14 -0
- package/dist/core/model-unavailable.js +23 -0
- package/dist/core/model-unavailable.js.map +1 -0
- package/dist/core/network-guard.d.ts +28 -0
- package/dist/core/network-guard.js +251 -0
- package/dist/core/network-guard.js.map +1 -0
- package/dist/core/node-debugger.d.ts +148 -0
- package/dist/core/node-debugger.js +642 -0
- package/dist/core/node-debugger.js.map +1 -0
- package/dist/core/opencode-catalog-store.d.ts +20 -0
- package/dist/core/opencode-catalog-store.js +82 -0
- package/dist/core/opencode-catalog-store.js.map +1 -0
- package/dist/core/openrouter-catalog-store.d.ts +24 -0
- package/dist/core/openrouter-catalog-store.js +140 -0
- package/dist/core/openrouter-catalog-store.js.map +1 -0
- package/dist/core/package-cooldown.d.ts +69 -0
- package/dist/core/package-cooldown.js +297 -0
- package/dist/core/package-cooldown.js.map +1 -0
- package/dist/core/package-threats.d.ts +92 -0
- package/dist/core/package-threats.js +1339 -0
- package/dist/core/package-threats.js.map +1 -0
- package/dist/core/parked-requests.d.ts +43 -0
- package/dist/core/parked-requests.js +34 -0
- package/dist/core/parked-requests.js.map +1 -0
- package/dist/core/persistent-shell.d.ts +81 -0
- package/dist/core/persistent-shell.js +452 -0
- package/dist/core/persistent-shell.js.map +1 -0
- package/dist/core/plan-delta.d.ts +23 -0
- package/dist/core/plan-delta.js +36 -0
- package/dist/core/plan-delta.js.map +1 -0
- package/dist/core/plan-handoff.d.ts +38 -0
- package/dist/core/plan-handoff.js +21 -0
- package/dist/core/plan-handoff.js.map +1 -0
- package/dist/core/plan-submission-gate.d.ts +28 -0
- package/dist/core/plan-submission-gate.js +27 -0
- package/dist/core/plan-submission-gate.js.map +1 -0
- package/dist/core/platform-clis.d.ts +15 -0
- package/dist/core/platform-clis.js +299 -0
- package/dist/core/platform-clis.js.map +1 -0
- package/dist/core/process-gate.d.ts +61 -0
- package/dist/core/process-gate.js +103 -0
- package/dist/core/process-gate.js.map +1 -0
- package/dist/core/process-manager.d.ts +242 -0
- package/dist/core/process-manager.js +902 -0
- package/dist/core/process-manager.js.map +1 -0
- package/dist/core/progress/engine.d.ts +22 -0
- package/dist/core/progress/engine.js +131 -0
- package/dist/core/progress/engine.js.map +1 -0
- package/dist/core/progress/git-xp.d.ts +15 -0
- package/dist/core/progress/git-xp.js +100 -0
- package/dist/core/progress/git-xp.js.map +1 -0
- package/dist/core/progress/ranks.d.ts +31 -0
- package/dist/core/progress/ranks.js +310 -0
- package/dist/core/progress/ranks.js.map +1 -0
- package/dist/core/progress/rebuild.d.ts +8 -0
- package/dist/core/progress/rebuild.js +125 -0
- package/dist/core/progress/rebuild.js.map +1 -0
- package/dist/core/progress/store.d.ts +34 -0
- package/dist/core/progress/store.js +200 -0
- package/dist/core/progress/store.js.map +1 -0
- package/dist/core/progress/types.d.ts +56 -0
- package/dist/core/progress/types.js +2 -0
- package/dist/core/progress/types.js.map +1 -0
- package/dist/core/project-discovery.d.ts +64 -0
- package/dist/core/project-discovery.js +908 -0
- package/dist/core/project-discovery.js.map +1 -0
- package/dist/core/project-files.d.ts +15 -0
- package/dist/core/project-files.js +37 -0
- package/dist/core/project-files.js.map +1 -0
- package/dist/core/project-health-scan.d.ts +109 -0
- package/dist/core/project-health-scan.js +673 -0
- package/dist/core/project-health-scan.js.map +1 -0
- package/dist/core/project-health-score.d.ts +41 -0
- package/dist/core/project-health-score.js +257 -0
- package/dist/core/project-health-score.js.map +1 -0
- package/dist/core/prompt-command-expansion.d.ts +13 -0
- package/dist/core/prompt-command-expansion.js +48 -0
- package/dist/core/prompt-command-expansion.js.map +1 -0
- package/dist/core/prompt-commands.d.ts +13 -0
- package/dist/core/prompt-commands.js +370 -0
- package/dist/core/prompt-commands.js.map +1 -0
- package/dist/core/radio-players.d.ts +28 -0
- package/dist/core/radio-players.js +132 -0
- package/dist/core/radio-players.js.map +1 -0
- package/dist/core/radio.d.ts +42 -0
- package/dist/core/radio.js +499 -0
- package/dist/core/radio.js.map +1 -0
- package/dist/core/regrounding.d.ts +37 -0
- package/dist/core/regrounding.js +89 -0
- package/dist/core/regrounding.js.map +1 -0
- package/dist/core/resolve-start.d.ts +28 -0
- package/dist/core/resolve-start.js +35 -0
- package/dist/core/resolve-start.js.map +1 -0
- package/dist/core/run-claim.d.ts +36 -0
- package/dist/core/run-claim.js +46 -0
- package/dist/core/run-claim.js.map +1 -0
- package/dist/core/run-lifecycle.d.ts +58 -0
- package/dist/core/run-lifecycle.js +104 -0
- package/dist/core/run-lifecycle.js.map +1 -0
- package/dist/core/run-status.d.ts +17 -0
- package/dist/core/run-status.js +28 -0
- package/dist/core/run-status.js.map +1 -0
- package/dist/core/runtime-mode.d.ts +21 -0
- package/dist/core/runtime-mode.js +43 -0
- package/dist/core/runtime-mode.js.map +1 -0
- package/dist/core/sandbox-domains.d.ts +13 -0
- package/dist/core/sandbox-domains.js +76 -0
- package/dist/core/sandbox-domains.js.map +1 -0
- package/dist/core/sandbox-feedback.d.ts +21 -0
- package/dist/core/sandbox-feedback.js +69 -0
- package/dist/core/sandbox-feedback.js.map +1 -0
- package/dist/core/sandbox.d.ts +106 -0
- package/dist/core/sandbox.js +383 -0
- package/dist/core/sandbox.js.map +1 -0
- package/dist/core/semantic-loop-check.d.ts +58 -0
- package/dist/core/semantic-loop-check.js +103 -0
- package/dist/core/semantic-loop-check.js.map +1 -0
- package/dist/core/session-compaction.d.ts +23 -0
- package/dist/core/session-compaction.js +54 -0
- package/dist/core/session-compaction.js.map +1 -0
- package/dist/core/session-export.d.ts +97 -0
- package/dist/core/session-export.js +368 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-history.d.ts +160 -0
- package/dist/core/session-history.js +467 -0
- package/dist/core/session-history.js.map +1 -0
- package/dist/core/session-manager.d.ts +510 -0
- package/dist/core/session-manager.js +1368 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/session-preview.d.ts +12 -0
- package/dist/core/session-preview.js +58 -0
- package/dist/core/session-preview.js.map +1 -0
- package/dist/core/session-storage.d.ts +78 -0
- package/dist/core/session-storage.js +659 -0
- package/dist/core/session-storage.js.map +1 -0
- package/dist/core/session-summary-index.d.ts +51 -0
- package/dist/core/session-summary-index.js +192 -0
- package/dist/core/session-summary-index.js.map +1 -0
- package/dist/core/settings-manager.d.ts +113 -0
- package/dist/core/settings-manager.js +281 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/shared-checkout-guard.d.ts +78 -0
- package/dist/core/shared-checkout-guard.js +219 -0
- package/dist/core/shared-checkout-guard.js.map +1 -0
- package/dist/core/shell-path.d.ts +13 -0
- package/dist/core/shell-path.js +175 -0
- package/dist/core/shell-path.js.map +1 -0
- package/dist/core/shell-threats-popular-packages.d.ts +11 -0
- package/dist/core/shell-threats-popular-packages.js +675 -0
- package/dist/core/shell-threats-popular-packages.js.map +1 -0
- package/dist/core/shell-threats.d.ts +21 -0
- package/dist/core/shell-threats.js +235 -0
- package/dist/core/shell-threats.js.map +1 -0
- package/dist/core/shell.d.ts +54 -0
- package/dist/core/shell.js +99 -0
- package/dist/core/shell.js.map +1 -0
- package/dist/core/shutdown.d.ts +70 -0
- package/dist/core/shutdown.js +144 -0
- package/dist/core/shutdown.js.map +1 -0
- package/dist/core/skill-scan.d.ts +112 -0
- package/dist/core/skill-scan.js +781 -0
- package/dist/core/skill-scan.js.map +1 -0
- package/dist/core/skills.d.ts +80 -0
- package/dist/core/skills.js +270 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +58 -0
- package/dist/core/slash-commands.js +242 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/steering.d.ts +47 -0
- package/dist/core/steering.js +65 -0
- package/dist/core/steering.js.map +1 -0
- package/dist/core/steroids.d.ts +66 -0
- package/dist/core/steroids.js +243 -0
- package/dist/core/steroids.js.map +1 -0
- package/dist/core/stream-diag-level.d.ts +3 -0
- package/dist/core/stream-diag-level.js +24 -0
- package/dist/core/stream-diag-level.js.map +1 -0
- package/dist/core/stream-rules.d.ts +30 -0
- package/dist/core/stream-rules.js +151 -0
- package/dist/core/stream-rules.js.map +1 -0
- package/dist/core/subagent-manager.d.ts +239 -0
- package/dist/core/subagent-manager.js +1059 -0
- package/dist/core/subagent-manager.js.map +1 -0
- package/dist/core/subagent-policy.d.ts +9 -0
- package/dist/core/subagent-policy.js +41 -0
- package/dist/core/subagent-policy.js.map +1 -0
- package/dist/core/subagent-receipt.d.ts +54 -0
- package/dist/core/subagent-receipt.js +274 -0
- package/dist/core/subagent-receipt.js.map +1 -0
- package/dist/core/subagent-store.d.ts +41 -0
- package/dist/core/subagent-store.js +284 -0
- package/dist/core/subagent-store.js.map +1 -0
- package/dist/core/subagent-turn-record.d.ts +18 -0
- package/dist/core/subagent-turn-record.js +82 -0
- package/dist/core/subagent-turn-record.js.map +1 -0
- package/dist/core/tasks-store.d.ts +31 -0
- package/dist/core/tasks-store.js +97 -0
- package/dist/core/tasks-store.js.map +1 -0
- package/dist/core/telegram-config.d.ts +20 -0
- package/dist/core/telegram-config.js +52 -0
- package/dist/core/telegram-config.js.map +1 -0
- package/dist/core/telegram.d.ts +114 -0
- package/dist/core/telegram.js +275 -0
- package/dist/core/telegram.js.map +1 -0
- package/dist/core/temp-paths.d.ts +5 -0
- package/dist/core/temp-paths.js +50 -0
- package/dist/core/temp-paths.js.map +1 -0
- package/dist/core/test-impact.d.ts +73 -0
- package/dist/core/test-impact.js +467 -0
- package/dist/core/test-impact.js.map +1 -0
- package/dist/core/threat-feed.d.ts +65 -0
- package/dist/core/threat-feed.js +334 -0
- package/dist/core/threat-feed.js.map +1 -0
- package/dist/core/trophies/catalog-more.d.ts +2 -0
- package/dist/core/trophies/catalog-more.js +837 -0
- package/dist/core/trophies/catalog-more.js.map +1 -0
- package/dist/core/trophies/catalog.d.ts +4 -0
- package/dist/core/trophies/catalog.js +649 -0
- package/dist/core/trophies/catalog.js.map +1 -0
- package/dist/core/trophies/engine.d.ts +70 -0
- package/dist/core/trophies/engine.js +347 -0
- package/dist/core/trophies/engine.js.map +1 -0
- package/dist/core/trophies/store.d.ts +17 -0
- package/dist/core/trophies/store.js +113 -0
- package/dist/core/trophies/store.js.map +1 -0
- package/dist/core/trophies/types.d.ts +87 -0
- package/dist/core/trophies/types.js +74 -0
- package/dist/core/trophies/types.js.map +1 -0
- package/dist/core/ui-adoption.d.ts +32 -0
- package/dist/core/ui-adoption.js +302 -0
- package/dist/core/ui-adoption.js.map +1 -0
- package/dist/core/ui-compatibility.d.ts +10 -0
- package/dist/core/ui-compatibility.js +51 -0
- package/dist/core/ui-compatibility.js.map +1 -0
- package/dist/core/ui-registry.d.ts +101 -0
- package/dist/core/ui-registry.js +292 -0
- package/dist/core/ui-registry.js.map +1 -0
- package/dist/core/user-shell-context.d.ts +8 -0
- package/dist/core/user-shell-context.js +12 -0
- package/dist/core/user-shell-context.js.map +1 -0
- package/dist/core/verification-evidence.d.ts +49 -0
- package/dist/core/verification-evidence.js +816 -0
- package/dist/core/verification-evidence.js.map +1 -0
- package/dist/core/verification-gate.d.ts +77 -0
- package/dist/core/verification-gate.js +504 -0
- package/dist/core/verification-gate.js.map +1 -0
- package/dist/core/verification-snapshot.d.ts +7 -0
- package/dist/core/verification-snapshot.js +109 -0
- package/dist/core/verification-snapshot.js.map +1 -0
- package/dist/core/verify-commands.d.ts +34 -0
- package/dist/core/verify-commands.js +203 -0
- package/dist/core/verify-commands.js.map +1 -0
- package/dist/core/voice-transcriber.d.ts +32 -0
- package/dist/core/voice-transcriber.js +114 -0
- package/dist/core/voice-transcriber.js.map +1 -0
- package/dist/core/workspace-guard.d.ts +56 -0
- package/dist/core/workspace-guard.js +334 -0
- package/dist/core/workspace-guard.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/session.d.ts +44 -0
- package/dist/session.js +105 -0
- package/dist/session.js.map +1 -0
- package/dist/system-prompt.d.ts +104 -0
- package/dist/system-prompt.js +480 -0
- package/dist/system-prompt.js.map +1 -0
- package/dist/test-support/fake-home.d.ts +19 -0
- package/dist/test-support/fake-home.js +37 -0
- package/dist/test-support/fake-home.js.map +1 -0
- package/dist/test-support/keep-alive.d.ts +14 -0
- package/dist/test-support/keep-alive.js +17 -0
- package/dist/test-support/keep-alive.js.map +1 -0
- package/dist/test-support/slow-git.d.ts +1 -0
- package/dist/test-support/slow-git.js +21 -0
- package/dist/test-support/slow-git.js.map +1 -0
- package/dist/test-support/system-tools.d.ts +6 -0
- package/dist/test-support/system-tools.js +36 -0
- package/dist/test-support/system-tools.js.map +1 -0
- package/dist/tools/ask-user.d.ts +34 -0
- package/dist/tools/ask-user.js +99 -0
- package/dist/tools/ask-user.js.map +1 -0
- package/dist/tools/background-watch-lint.d.ts +18 -0
- package/dist/tools/background-watch-lint.js +102 -0
- package/dist/tools/background-watch-lint.js.map +1 -0
- package/dist/tools/bash-read-evidence.d.ts +23 -0
- package/dist/tools/bash-read-evidence.js +180 -0
- package/dist/tools/bash-read-evidence.js.map +1 -0
- package/dist/tools/bash.d.ts +64 -0
- package/dist/tools/bash.js +552 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/browser-api.d.ts +27 -0
- package/dist/tools/browser-api.js +449 -0
- package/dist/tools/browser-api.js.map +1 -0
- package/dist/tools/browser-sandbox.d.ts +16 -0
- package/dist/tools/browser-sandbox.js +158 -0
- package/dist/tools/browser-sandbox.js.map +1 -0
- package/dist/tools/browser-session.d.ts +84 -0
- package/dist/tools/browser-session.js +304 -0
- package/dist/tools/browser-session.js.map +1 -0
- package/dist/tools/browser-snapshot.d.ts +19 -0
- package/dist/tools/browser-snapshot.js +109 -0
- package/dist/tools/browser-snapshot.js.map +1 -0
- package/dist/tools/browser.d.ts +11 -0
- package/dist/tools/browser.js +106 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/checklist.d.ts +49 -0
- package/dist/tools/checklist.js +154 -0
- package/dist/tools/checklist.js.map +1 -0
- package/dist/tools/compress.d.ts +56 -0
- package/dist/tools/compress.js +226 -0
- package/dist/tools/compress.js.map +1 -0
- package/dist/tools/debug.d.ts +54 -0
- package/dist/tools/debug.js +230 -0
- package/dist/tools/debug.js.map +1 -0
- package/dist/tools/document-text.d.ts +6 -0
- package/dist/tools/document-text.js +154 -0
- package/dist/tools/document-text.js.map +1 -0
- package/dist/tools/edit-diff.d.ts +123 -0
- package/dist/tools/edit-diff.js +476 -0
- package/dist/tools/edit-diff.js.map +1 -0
- package/dist/tools/edit-targets.d.ts +10 -0
- package/dist/tools/edit-targets.js +31 -0
- package/dist/tools/edit-targets.js.map +1 -0
- package/dist/tools/edit.d.ts +38 -0
- package/dist/tools/edit.js +695 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/enter-plan.d.ts +7 -0
- package/dist/tools/enter-plan.js +20 -0
- package/dist/tools/enter-plan.js.map +1 -0
- package/dist/tools/exit-plan.d.ts +7 -0
- package/dist/tools/exit-plan.js +51 -0
- package/dist/tools/exit-plan.js.map +1 -0
- package/dist/tools/find.d.ts +17 -0
- package/dist/tools/find.js +100 -0
- package/dist/tools/find.js.map +1 -0
- package/dist/tools/generate-image.d.ts +83 -0
- package/dist/tools/generate-image.js +625 -0
- package/dist/tools/generate-image.js.map +1 -0
- package/dist/tools/grep-scan.d.ts +96 -0
- package/dist/tools/grep-scan.js +283 -0
- package/dist/tools/grep-scan.js.map +1 -0
- package/dist/tools/grep.d.ts +48 -0
- package/dist/tools/grep.js +1013 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/html-extract.d.ts +57 -0
- package/dist/tools/html-extract.js +130 -0
- package/dist/tools/html-extract.js.map +1 -0
- package/dist/tools/index.d.ts +198 -0
- package/dist/tools/index.js +216 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/live-preview.d.ts +23 -0
- package/dist/tools/live-preview.js +41 -0
- package/dist/tools/live-preview.js.map +1 -0
- package/dist/tools/ls.d.ts +9 -0
- package/dist/tools/ls.js +59 -0
- package/dist/tools/ls.js.map +1 -0
- package/dist/tools/operations.d.ts +86 -0
- package/dist/tools/operations.js +117 -0
- package/dist/tools/operations.js.map +1 -0
- package/dist/tools/overflow.d.ts +17 -0
- package/dist/tools/overflow.js +68 -0
- package/dist/tools/overflow.js.map +1 -0
- package/dist/tools/path-utils.d.ts +30 -0
- package/dist/tools/path-utils.js +74 -0
- package/dist/tools/path-utils.js.map +1 -0
- package/dist/tools/pdf-extract.d.ts +17 -0
- package/dist/tools/pdf-extract.js +43 -0
- package/dist/tools/pdf-extract.js.map +1 -0
- package/dist/tools/prompt-hints.d.ts +46 -0
- package/dist/tools/prompt-hints.js +171 -0
- package/dist/tools/prompt-hints.js.map +1 -0
- package/dist/tools/read-only-bash.d.ts +31 -0
- package/dist/tools/read-only-bash.js +338 -0
- package/dist/tools/read-only-bash.js.map +1 -0
- package/dist/tools/read-tracker.d.ts +43 -0
- package/dist/tools/read-tracker.js +120 -0
- package/dist/tools/read-tracker.js.map +1 -0
- package/dist/tools/read.d.ts +18 -0
- package/dist/tools/read.js +316 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/redaction-guard.d.ts +10 -0
- package/dist/tools/redaction-guard.js +55 -0
- package/dist/tools/redaction-guard.js.map +1 -0
- package/dist/tools/routine-output.d.ts +39 -0
- package/dist/tools/routine-output.js +281 -0
- package/dist/tools/routine-output.js.map +1 -0
- package/dist/tools/safe-env.d.ts +1 -0
- package/dist/tools/safe-env.js +79 -0
- package/dist/tools/safe-env.js.map +1 -0
- package/dist/tools/session-stats.d.ts +26 -0
- package/dist/tools/session-stats.js +51 -0
- package/dist/tools/session-stats.js.map +1 -0
- package/dist/tools/side-web-search.d.ts +34 -0
- package/dist/tools/side-web-search.js +146 -0
- package/dist/tools/side-web-search.js.map +1 -0
- package/dist/tools/skill.d.ts +12 -0
- package/dist/tools/skill.js +94 -0
- package/dist/tools/skill.js.map +1 -0
- package/dist/tools/source-path.d.ts +8 -0
- package/dist/tools/source-path.js +135 -0
- package/dist/tools/source-path.js.map +1 -0
- package/dist/tools/steroids.d.ts +44 -0
- package/dist/tools/steroids.js +356 -0
- package/dist/tools/steroids.js.map +1 -0
- package/dist/tools/subagent-control.d.ts +5 -0
- package/dist/tools/subagent-control.js +211 -0
- package/dist/tools/subagent-control.js.map +1 -0
- package/dist/tools/subagent-shared.d.ts +115 -0
- package/dist/tools/subagent-shared.js +182 -0
- package/dist/tools/subagent-shared.js.map +1 -0
- package/dist/tools/subagent.d.ts +37 -0
- package/dist/tools/subagent.js +406 -0
- package/dist/tools/subagent.js.map +1 -0
- package/dist/tools/task-output.d.ts +10 -0
- package/dist/tools/task-output.js +74 -0
- package/dist/tools/task-output.js.map +1 -0
- package/dist/tools/task-send.d.ts +11 -0
- package/dist/tools/task-send.js +36 -0
- package/dist/tools/task-send.js.map +1 -0
- package/dist/tools/task-stop.d.ts +8 -0
- package/dist/tools/task-stop.js +15 -0
- package/dist/tools/task-stop.js.map +1 -0
- package/dist/tools/tasks.d.ts +15 -0
- package/dist/tools/tasks.js +94 -0
- package/dist/tools/tasks.js.map +1 -0
- package/dist/tools/tool-search.d.ts +26 -0
- package/dist/tools/tool-search.js +81 -0
- package/dist/tools/tool-search.js.map +1 -0
- package/dist/tools/tool-tiers.d.ts +65 -0
- package/dist/tools/tool-tiers.js +121 -0
- package/dist/tools/tool-tiers.js.map +1 -0
- package/dist/tools/truncate.d.ts +39 -0
- package/dist/tools/truncate.js +242 -0
- package/dist/tools/truncate.js.map +1 -0
- package/dist/tools/ui-adopt.d.ts +16 -0
- package/dist/tools/ui-adopt.js +66 -0
- package/dist/tools/ui-adopt.js.map +1 -0
- package/dist/tools/ui-registry.d.ts +15 -0
- package/dist/tools/ui-registry.js +39 -0
- package/dist/tools/ui-registry.js.map +1 -0
- package/dist/tools/verification-review.d.ts +2 -0
- package/dist/tools/verification-review.js +41 -0
- package/dist/tools/verification-review.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +52 -0
- package/dist/tools/web-fetch.js +986 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +35 -0
- package/dist/tools/web-search.js +926 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/write.d.ts +16 -0
- package/dist/tools/write.js +196 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/types.d.ts +44 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/commit-message.d.ts +25 -0
- package/dist/utils/commit-message.js +72 -0
- package/dist/utils/commit-message.js.map +1 -0
- package/dist/utils/git.d.ts +102 -0
- package/dist/utils/git.js +325 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/github-ci.d.ts +9 -0
- package/dist/utils/github-ci.js +138 -0
- package/dist/utils/github-ci.js.map +1 -0
- package/dist/utils/github.d.ts +19 -0
- package/dist/utils/github.js +67 -0
- package/dist/utils/github.js.map +1 -0
- package/dist/utils/image.d.ts +166 -0
- package/dist/utils/image.js +673 -0
- package/dist/utils/image.js.map +1 -0
- package/dist/utils/open-browser.d.ts +13 -0
- package/dist/utils/open-browser.js +31 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/plan-steps.d.ts +90 -0
- package/dist/utils/plan-steps.js +209 -0
- package/dist/utils/plan-steps.js.map +1 -0
- package/dist/utils/process.d.ts +48 -0
- package/dist/utils/process.js +175 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/prompt-enhancer.d.ts +34 -0
- package/dist/utils/prompt-enhancer.js +178 -0
- package/dist/utils/prompt-enhancer.js.map +1 -0
- package/dist/utils/text.d.ts +61 -0
- package/dist/utils/text.js +68 -0
- package/dist/utils/text.js.map +1 -0
- package/package.json +87 -3
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conservative read-only command classifier for plan mode.
|
|
3
|
+
*
|
|
4
|
+
* Deny-by-default: false negatives are safe (a read-only command merely stays
|
|
5
|
+
* blocked), false positives are not (a mutating command would slip through).
|
|
6
|
+
* Plan mode gates bash on `isReadOnlyCommand`; anything this function cannot
|
|
7
|
+
* prove is read-only falls back to the existing plan-mode block.
|
|
8
|
+
*
|
|
9
|
+
* A command-name allowlist alone is not proof: several allowlisted utilities
|
|
10
|
+
* mutate through flags (`git branch -D`, `find -delete`, `date -s`,
|
|
11
|
+
* `sort -o file`), take create-shaped operands (`git tag v1`), or execute
|
|
12
|
+
* repo-configured code (`git diff --ext-diff`). Each carries a per-flag
|
|
13
|
+
* policy below.
|
|
14
|
+
*/
|
|
15
|
+
/** Read-only utilities allowed as the leading command word of every segment. */
|
|
16
|
+
const READ_ONLY_COMMANDS = new Set([
|
|
17
|
+
"ls",
|
|
18
|
+
"cat",
|
|
19
|
+
"head",
|
|
20
|
+
"tail",
|
|
21
|
+
"wc",
|
|
22
|
+
"grep",
|
|
23
|
+
"egrep",
|
|
24
|
+
"fgrep",
|
|
25
|
+
"rg",
|
|
26
|
+
"find",
|
|
27
|
+
"fd",
|
|
28
|
+
"tree",
|
|
29
|
+
"stat",
|
|
30
|
+
"file",
|
|
31
|
+
"du",
|
|
32
|
+
"df",
|
|
33
|
+
"pwd",
|
|
34
|
+
"echo",
|
|
35
|
+
"printf",
|
|
36
|
+
"which",
|
|
37
|
+
"type",
|
|
38
|
+
"date",
|
|
39
|
+
"whoami",
|
|
40
|
+
"hostname",
|
|
41
|
+
"uname",
|
|
42
|
+
"printenv",
|
|
43
|
+
"sort",
|
|
44
|
+
"uniq",
|
|
45
|
+
"cut",
|
|
46
|
+
"tr",
|
|
47
|
+
"column",
|
|
48
|
+
"nl",
|
|
49
|
+
"comm",
|
|
50
|
+
"diff",
|
|
51
|
+
"basename",
|
|
52
|
+
"dirname",
|
|
53
|
+
"realpath",
|
|
54
|
+
"readlink",
|
|
55
|
+
"jq",
|
|
56
|
+
"yq",
|
|
57
|
+
// No awk: its `system()` built-in is arbitrary shell execution and cannot
|
|
58
|
+
// be screened by flags. Deny-by-default costs a blocked read-only call at
|
|
59
|
+
// worst; allowing it costs plan mode running `rm`.
|
|
60
|
+
]);
|
|
61
|
+
/** Read-only git subcommands. Everything else (commit, push, …) is rejected. */
|
|
62
|
+
const READ_ONLY_GIT_SUBCOMMANDS = new Set([
|
|
63
|
+
"status",
|
|
64
|
+
"log",
|
|
65
|
+
"diff",
|
|
66
|
+
"show",
|
|
67
|
+
"branch",
|
|
68
|
+
"remote",
|
|
69
|
+
"tag",
|
|
70
|
+
"describe",
|
|
71
|
+
"blame",
|
|
72
|
+
"ls-files",
|
|
73
|
+
"rev-parse",
|
|
74
|
+
"shortlog",
|
|
75
|
+
"cat-file",
|
|
76
|
+
"config",
|
|
77
|
+
"for-each-ref",
|
|
78
|
+
"reflog",
|
|
79
|
+
]);
|
|
80
|
+
/**
|
|
81
|
+
* Shell tokens that can hide writes or execute arbitrary commands. If any
|
|
82
|
+
* segment contains one of these, the whole command is rejected.
|
|
83
|
+
*/
|
|
84
|
+
const DANGEROUS_TOKENS = [
|
|
85
|
+
">", // output redirection (covers >>, >|, &>, <> via substring)
|
|
86
|
+
"<>",
|
|
87
|
+
"$(", // command substitution
|
|
88
|
+
"`", // backtick command substitution
|
|
89
|
+
"<(", // process substitution
|
|
90
|
+
">(",
|
|
91
|
+
];
|
|
92
|
+
/** Split a command on shell control operators into individual segments. */
|
|
93
|
+
export function splitShellCommandSegments(command) {
|
|
94
|
+
// Split on ; && || | and newlines. The pipe split also covers |& since the
|
|
95
|
+
// trailing & becomes its own (empty/garbage) segment that fails the allowlist.
|
|
96
|
+
return command
|
|
97
|
+
.split(/(?:&&|\|\||[;|\n])/)
|
|
98
|
+
.map((segment) => segment.trim())
|
|
99
|
+
.filter((segment) => segment.length > 0);
|
|
100
|
+
}
|
|
101
|
+
/** Extract the leading command word from a segment (ignores nothing special). */
|
|
102
|
+
function leadingWord(segment) {
|
|
103
|
+
const match = segment.match(/^(\S+)/);
|
|
104
|
+
return match ? match[1] : "";
|
|
105
|
+
}
|
|
106
|
+
/** Tokenize a segment on whitespace for flag inspection. */
|
|
107
|
+
function tokens(segment) {
|
|
108
|
+
return segment.split(/\s+/).filter((token) => token.length > 0);
|
|
109
|
+
}
|
|
110
|
+
/** True if any token equals `flag` or is `flag=value`. */
|
|
111
|
+
function hasFlag(parts, ...flags) {
|
|
112
|
+
return parts.some((part) => flags.some((flag) => part === flag || part.startsWith(`${flag}=`)));
|
|
113
|
+
}
|
|
114
|
+
/** Non-flag tokens of `parts`. */
|
|
115
|
+
function positionals(parts) {
|
|
116
|
+
return parts.filter((part) => !part.startsWith("-"));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* True if any token is a cluster of short flags containing one of `letters`
|
|
120
|
+
* (`-df` = `-d -f`; GNU getopt and git parse-options both accept clusters, so
|
|
121
|
+
* exact-token flag checks alone can be bypassed with `sort -ro`, `date -su`,
|
|
122
|
+
* `git branch -df`). Long flags (`--…`) never match: two leading dashes fail
|
|
123
|
+
* the letter run.
|
|
124
|
+
*/
|
|
125
|
+
function hasClusteredShortFlag(parts, letters) {
|
|
126
|
+
return parts.some((part) => {
|
|
127
|
+
const match = /^-([a-zA-Z]+)\d*$/.exec(part);
|
|
128
|
+
return match !== null && [...match[1]].some((ch) => letters.has(ch));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// --- git subcommand flag policies -------------------------------------------
|
|
132
|
+
/** Listing flags that make `git branch`/`git tag` operands filters rather
|
|
133
|
+
* than create/delete targets. Without one, a positional operand creates. */
|
|
134
|
+
const GIT_LIST_FLAGS = ["--list", "-l"];
|
|
135
|
+
/** Short-flag letters that make `git branch` mutate or execute (d/D delete, m/M
|
|
136
|
+
* move, c/C copy, f force, u upstream). `a`/`v` listing letters excluded. */
|
|
137
|
+
const GIT_BRANCH_DANGEROUS_LETTERS = new Set(["d", "D", "m", "M", "c", "C", "f", "u"]);
|
|
138
|
+
/** Same for `git tag` (d/D delete, f force, a annotate, s sign, u local-user,
|
|
139
|
+
* m message, e edit). `n`/`l` listing letters excluded. */
|
|
140
|
+
const GIT_TAG_DANGEROUS_LETTERS = new Set(["d", "D", "f", "a", "s", "u", "m", "e"]);
|
|
141
|
+
function isReadOnlyGitBranch(rest) {
|
|
142
|
+
if (hasFlag(rest, "-d", "-D", "--delete", "-m", "-M", "--move", "-c", "-C", "--copy", "-f", "--force", "-u", "--set-upstream-to", "--unset-upstream", "--edit-description") ||
|
|
143
|
+
hasClusteredShortFlag(rest, GIT_BRANCH_DANGEROUS_LETTERS)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return positionals(rest).length === 0 || hasFlag(rest, ...GIT_LIST_FLAGS);
|
|
147
|
+
}
|
|
148
|
+
function isReadOnlyGitTag(rest) {
|
|
149
|
+
if (hasFlag(rest, "-d", "--delete", "-f", "--force", "-a", "--annotate", "-s", "--sign", "-u", "--local-user", "-m", "--message", "-e", "--edit") ||
|
|
150
|
+
hasClusteredShortFlag(rest, GIT_TAG_DANGEROUS_LETTERS)) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return positionals(rest).length === 0 || hasFlag(rest, ...GIT_LIST_FLAGS);
|
|
154
|
+
}
|
|
155
|
+
function isReadOnlyGitRemote(rest) {
|
|
156
|
+
const operands = positionals(rest);
|
|
157
|
+
if (operands.length === 0)
|
|
158
|
+
return true; // bare `git remote [-v]` lists
|
|
159
|
+
const sub = operands[0];
|
|
160
|
+
if (sub === "get-url")
|
|
161
|
+
return true;
|
|
162
|
+
// `git remote show` contacts the remote (network, askpass helpers);
|
|
163
|
+
// read-only only with --no-query.
|
|
164
|
+
if (sub === "show")
|
|
165
|
+
return hasFlag(rest, "-n", "--no-query");
|
|
166
|
+
return false; // add, rename, remove, set-url, set-head, prune, update …
|
|
167
|
+
}
|
|
168
|
+
function isReadOnlyGitReflog(rest) {
|
|
169
|
+
// `expire` and `delete` rewrite reflog history.
|
|
170
|
+
const sub = positionals(rest)[0];
|
|
171
|
+
return sub !== "expire" && sub !== "delete";
|
|
172
|
+
}
|
|
173
|
+
function isReadOnlyGit(segment) {
|
|
174
|
+
const parts = tokens(segment);
|
|
175
|
+
// parts[0] === "git"; find the first non-flag token as the subcommand. A
|
|
176
|
+
// global flag with a value (`git -C /tmp branch`) puts the value here and
|
|
177
|
+
// denies — fail-closed, and `-C` escapes the workspace anyway.
|
|
178
|
+
let subcommand = "";
|
|
179
|
+
for (let i = 1; i < parts.length; i += 1) {
|
|
180
|
+
const part = parts[i];
|
|
181
|
+
if (part.startsWith("-"))
|
|
182
|
+
continue;
|
|
183
|
+
subcommand = part;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
if (!READ_ONLY_GIT_SUBCOMMANDS.has(subcommand))
|
|
187
|
+
return false;
|
|
188
|
+
const rest = parts.slice(parts.indexOf(subcommand) + 1);
|
|
189
|
+
if (subcommand === "config") {
|
|
190
|
+
// `git config` is read-only only with --get (or --list / --get-all).
|
|
191
|
+
return hasFlag(rest, "--get", "--get-all", "--list", "-l");
|
|
192
|
+
}
|
|
193
|
+
// log/show/diff can execute repo-configured external diff/textconv
|
|
194
|
+
// drivers. The --no- forms (which disable them) stay allowed: exact match.
|
|
195
|
+
if (subcommand === "log" || subcommand === "show" || subcommand === "diff") {
|
|
196
|
+
if (rest.includes("--ext-diff") || rest.includes("--textconv"))
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
if (subcommand === "branch")
|
|
200
|
+
return isReadOnlyGitBranch(rest);
|
|
201
|
+
if (subcommand === "tag")
|
|
202
|
+
return isReadOnlyGitTag(rest);
|
|
203
|
+
if (subcommand === "remote")
|
|
204
|
+
return isReadOnlyGitRemote(rest);
|
|
205
|
+
if (subcommand === "reflog")
|
|
206
|
+
return isReadOnlyGitReflog(rest);
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* sed script text that could execute a command or write a file: GNU's `e`
|
|
211
|
+
* command (`e cmd`, `1e`, `/re/e`, `{ e ...`), the `s///...e` exec flag, or
|
|
212
|
+
* the `w`/`W` write commands. Applied to ALL candidate script text - every
|
|
213
|
+
* non-flag token joined plus long-flag `=values` - so quoting or splitting a
|
|
214
|
+
* script across whitespace cannot hide the command from it. False positives
|
|
215
|
+
* (a filename shaped like `1e`) merely block a read-only call.
|
|
216
|
+
*/
|
|
217
|
+
function sedScriptUnsafe(text) {
|
|
218
|
+
// `e`/`w`/`W` at a command position: script start, after `;` `{` `}`/`)`, or
|
|
219
|
+
// directly after an address (`1e`, `$e`, `/re/e`, `2w out`).
|
|
220
|
+
if (/(^|[\s;{}()])([0-9,$~/\\][^\s;{}]*)?[ewW](\s|$|\\)/.test(text))
|
|
221
|
+
return true;
|
|
222
|
+
// Exec flag on a substitution, any delimiter: `s/x/y/e`, `s#x#y#ge`.
|
|
223
|
+
if (/s(.).*\1[0-9A-Za-z]*e/.test(text))
|
|
224
|
+
return true;
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
function isReadOnlySed(segment) {
|
|
228
|
+
const rest = tokens(segment).slice(1);
|
|
229
|
+
// In-place edit (`-i`, `-i.bak`, `--in-place`) or a script read from a file
|
|
230
|
+
// (`-f`, `--file`) - the file's contents cannot be inspected here.
|
|
231
|
+
if (rest.some((part) => part.startsWith("-i") ||
|
|
232
|
+
part.startsWith("--in-place") ||
|
|
233
|
+
part.startsWith("-f") ||
|
|
234
|
+
part.startsWith("--file"))) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
// A short-flag cluster longer than two characters carries an attached value
|
|
238
|
+
// that cannot be attributed (`-es/a/b/`, `-i.bak`, even the pure `-nE`);
|
|
239
|
+
// only single-letter flags pass. Long `--flags` are words, not clusters.
|
|
240
|
+
if (rest.some((part) => /^-[a-zA-Z]./.test(part)))
|
|
241
|
+
return false;
|
|
242
|
+
// Fail closed on compound scripts: `;`/`{`/`}` chain commands across token
|
|
243
|
+
// boundaries (`sed 's/a/b/; e x' f`), so compound scripts are never provably
|
|
244
|
+
// read-only here.
|
|
245
|
+
const scriptText = rest
|
|
246
|
+
.filter((part) => !part.startsWith("-"))
|
|
247
|
+
.map((part) => part.replace(/^['"]|['"]$/g, ""))
|
|
248
|
+
.join(" ");
|
|
249
|
+
const flagValues = rest
|
|
250
|
+
.filter((part) => part.startsWith("--") && part.includes("="))
|
|
251
|
+
.map((part) => part.slice(part.indexOf("=") + 1).replace(/^['"]|['"]$/g, ""))
|
|
252
|
+
.join(" ");
|
|
253
|
+
const all = `${scriptText} ${flagValues}`;
|
|
254
|
+
if (/;|\{|\}/.test(all))
|
|
255
|
+
return false;
|
|
256
|
+
return !sedScriptUnsafe(all);
|
|
257
|
+
}
|
|
258
|
+
// --- plain-utility flag policies --------------------------------------------
|
|
259
|
+
function isReadOnlyUtility(command, parts) {
|
|
260
|
+
const rest = parts.slice(1);
|
|
261
|
+
switch (command) {
|
|
262
|
+
case "date":
|
|
263
|
+
// `-s`/`--set` sets the system clock, also when clustered (`-su`).
|
|
264
|
+
return !hasFlag(rest, "-s", "--set") && !hasClusteredShortFlag(rest, new Set(["s"]));
|
|
265
|
+
case "find":
|
|
266
|
+
// -exec/-ok (and their -dir variants) run arbitrary commands; the rest
|
|
267
|
+
// write files.
|
|
268
|
+
return !rest.some((part) => part === "-delete" ||
|
|
269
|
+
part.startsWith("-exec") ||
|
|
270
|
+
part.startsWith("-ok") ||
|
|
271
|
+
part.startsWith("-fprint") ||
|
|
272
|
+
part === "-fls");
|
|
273
|
+
case "rg":
|
|
274
|
+
// `--pre` runs a command on every file searched (`--pre-glob` only scopes it).
|
|
275
|
+
return !hasFlag(rest, "--pre");
|
|
276
|
+
case "sort":
|
|
277
|
+
// `-o` writes a file, also when clustered (`-ro`).
|
|
278
|
+
return !hasFlag(rest, "-o", "--output") && !hasClusteredShortFlag(rest, new Set(["o"]));
|
|
279
|
+
case "tree":
|
|
280
|
+
return !hasFlag(rest, "-o", "--output-file") && !hasClusteredShortFlag(rest, new Set(["o"]));
|
|
281
|
+
case "yq":
|
|
282
|
+
// -i edits in place; --split-exp/-s write one file per document.
|
|
283
|
+
return !hasFlag(rest, "-i", "--in-place", "-s", "--split-exp");
|
|
284
|
+
default:
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
export function hasUnsafeShellSyntax(segment) {
|
|
289
|
+
return DANGEROUS_TOKENS.some((token) => segment.includes(token)) || /&\s*$/.test(segment);
|
|
290
|
+
}
|
|
291
|
+
function isReadOnlySegment(segment) {
|
|
292
|
+
// Keep shell-syntax policy shared with semantic verification classification.
|
|
293
|
+
if (hasUnsafeShellSyntax(segment))
|
|
294
|
+
return false;
|
|
295
|
+
const parts = tokens(segment);
|
|
296
|
+
const command = leadingWord(segment);
|
|
297
|
+
if (command === "git")
|
|
298
|
+
return isReadOnlyGit(segment);
|
|
299
|
+
if (command === "sed")
|
|
300
|
+
return isReadOnlySed(segment);
|
|
301
|
+
return READ_ONLY_COMMANDS.has(command) && isReadOnlyUtility(command, parts);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Returns true only when every segment of the command is provably read-only.
|
|
305
|
+
*/
|
|
306
|
+
export function isReadOnlyCommand(command) {
|
|
307
|
+
const trimmed = command.trim();
|
|
308
|
+
if (trimmed.length === 0)
|
|
309
|
+
return false;
|
|
310
|
+
const segments = splitShellCommandSegments(trimmed);
|
|
311
|
+
if (segments.length === 0)
|
|
312
|
+
return false;
|
|
313
|
+
return segments.every(isReadOnlySegment);
|
|
314
|
+
}
|
|
315
|
+
const SLEEP_UNIT_SECONDS = { s: 1, m: 60, h: 3600, d: 86400 };
|
|
316
|
+
/**
|
|
317
|
+
* Total seconds a command sleeps when it does nothing else (`sleep 5`,
|
|
318
|
+
* `sleep 2; sleep 3`), or null when it does any real work.
|
|
319
|
+
*
|
|
320
|
+
* Used to catch a guessed wait on a background process, which now has a real
|
|
321
|
+
* answer in `task_output`'s `wait_ms`. Callers care about the duration because
|
|
322
|
+
* a brief settle before poking a dev server is legitimate, while a long nap is
|
|
323
|
+
* always a guess at a finish time.
|
|
324
|
+
*/
|
|
325
|
+
export function sleepOnlySeconds(command) {
|
|
326
|
+
const segments = splitShellCommandSegments(command.trim());
|
|
327
|
+
if (segments.length === 0)
|
|
328
|
+
return null;
|
|
329
|
+
let total = 0;
|
|
330
|
+
for (const segment of segments) {
|
|
331
|
+
const match = /^sleep\s+(\d+(?:\.\d+)?)([smhd])?$/.exec(segment.trim());
|
|
332
|
+
if (!match)
|
|
333
|
+
return null;
|
|
334
|
+
total += Number(match[1]) * (match[2] ? SLEEP_UNIT_SECONDS[match[2]] : 1);
|
|
335
|
+
}
|
|
336
|
+
return total;
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=read-only-bash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-only-bash.js","sourceRoot":"","sources":["../../src/tools/read-only-bash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,gFAAgF;AAChF,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;IACN,IAAI;IACJ,MAAM;IACN,OAAO;IACP,OAAO;IACP,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,QAAQ;IACR,OAAO;IACP,MAAM;IACN,MAAM;IACN,QAAQ;IACR,UAAU;IACV,OAAO;IACP,UAAU;IACV,MAAM;IACN,MAAM;IACN,KAAK;IACL,IAAI;IACJ,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;IACV,IAAI;IACJ,IAAI;IACJ,0EAA0E;IAC1E,0EAA0E;IAC1E,mDAAmD;CACpD,CAAC,CAAC;AAEH,gFAAgF;AAChF,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC;IAC7D,QAAQ;IACR,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,UAAU;IACV,OAAO;IACP,UAAU;IACV,WAAW;IACX,UAAU;IACV,UAAU;IACV,QAAQ;IACR,cAAc;IACd,QAAQ;CACT,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,gBAAgB,GAAsB;IAC1C,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AAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ToolOperations } from "./operations.js";
|
|
2
|
+
/** A 1-based, inclusive range of line numbers. */
|
|
3
|
+
export type LineRange = readonly [start: number, end: number];
|
|
4
|
+
export interface ReadEntry {
|
|
5
|
+
mtimeMs: number;
|
|
6
|
+
hash: string;
|
|
7
|
+
/** Lines in the content `hash` covers (a trailing newline does not add one). */
|
|
8
|
+
lineCount: number;
|
|
9
|
+
/**
|
|
10
|
+
* How much of that content the model has been shown: `"all"`, or the merged,
|
|
11
|
+
* sorted line ranges seen so far. A full-file `write` requires `"all"`.
|
|
12
|
+
*/
|
|
13
|
+
seen: "all" | readonly LineRange[];
|
|
14
|
+
}
|
|
15
|
+
export type ReadTracker = Map<string, ReadEntry>;
|
|
16
|
+
export declare function hashContent(content: string): string;
|
|
17
|
+
/** Line count as the read tool numbers lines, not counting the empty "line" after a final newline. */
|
|
18
|
+
export declare function countLines(content: string): number;
|
|
19
|
+
/**
|
|
20
|
+
* Record that the model was shown `shown` (default: every line) of `content`.
|
|
21
|
+
* Reads of unchanged content accumulate, so paging through a long file with
|
|
22
|
+
* offset/limit eventually counts as having seen all of it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function recordRead(tracker: ReadTracker | undefined, resolvedPath: string, content: string, mtimeMs: number, shown?: LineRange): void;
|
|
25
|
+
/**
|
|
26
|
+
* Record the model's own change to a file. `write` supplies every line itself,
|
|
27
|
+
* so the model knows the whole result. `edit` changes only part of a file, so
|
|
28
|
+
* it knows the whole result only if it had already seen all of the original.
|
|
29
|
+
*/
|
|
30
|
+
export declare function recordWrite(tracker: ReadTracker | undefined, resolvedPath: string, content: string, ops: ToolOperations, scope?: "whole" | "edit"): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Lines of the file as it is on disk now that the model has not been shown:
|
|
33
|
+
* `"all"` when it never read the file or the file changed since its last
|
|
34
|
+
* read/write (mtime, else content hash), otherwise the gaps between the ranges
|
|
35
|
+
* it has seen (empty when it has seen every line). A full-file `write` uses
|
|
36
|
+
* this to report which lines it removed without the model having seen them.
|
|
37
|
+
*/
|
|
38
|
+
export declare function unseenLines(tracker: ReadTracker | undefined, resolvedPath: string, ops: ToolOperations): Promise<"all" | readonly LineRange[]>;
|
|
39
|
+
/**
|
|
40
|
+
* True when the recorded read still matches disk (mtime, else content hash).
|
|
41
|
+
* A hash match after an mtime-only change refreshes the recorded mtime.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isFresh(tracker: ReadTracker, resolvedPath: string, ops: ToolOperations): Promise<boolean>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
export function hashContent(content) {
|
|
3
|
+
return crypto.createHash("sha256").update(content).digest("hex");
|
|
4
|
+
}
|
|
5
|
+
/** Line count as the read tool numbers lines, not counting the empty "line" after a final newline. */
|
|
6
|
+
export function countLines(content) {
|
|
7
|
+
if (content === "")
|
|
8
|
+
return 0;
|
|
9
|
+
const lines = content.split("\n").length;
|
|
10
|
+
return content.endsWith("\n") ? lines - 1 : lines;
|
|
11
|
+
}
|
|
12
|
+
function mergeRanges(ranges) {
|
|
13
|
+
const sorted = [...ranges].sort((a, b) => a[0] - b[0]);
|
|
14
|
+
const merged = [];
|
|
15
|
+
for (const [start, end] of sorted) {
|
|
16
|
+
const last = merged[merged.length - 1];
|
|
17
|
+
if (last && start <= last[1] + 1) {
|
|
18
|
+
last[1] = Math.max(last[1], end);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
merged.push([start, end]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return merged;
|
|
25
|
+
}
|
|
26
|
+
/** Clamp `ranges` to the file and collapse them to `"all"` once they cover every line. */
|
|
27
|
+
function toSeen(ranges, lineCount) {
|
|
28
|
+
if (lineCount === 0)
|
|
29
|
+
return "all";
|
|
30
|
+
const merged = mergeRanges(ranges
|
|
31
|
+
.map(([start, end]) => [Math.max(1, start), Math.min(lineCount, end)])
|
|
32
|
+
.filter(([start, end]) => start <= end));
|
|
33
|
+
const only = merged.length === 1 ? merged[0] : undefined;
|
|
34
|
+
return only && only[0] === 1 && only[1] === lineCount ? "all" : merged;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Record that the model was shown `shown` (default: every line) of `content`.
|
|
38
|
+
* Reads of unchanged content accumulate, so paging through a long file with
|
|
39
|
+
* offset/limit eventually counts as having seen all of it.
|
|
40
|
+
*/
|
|
41
|
+
export function recordRead(tracker, resolvedPath, content, mtimeMs, shown) {
|
|
42
|
+
if (!tracker)
|
|
43
|
+
return;
|
|
44
|
+
const hash = hashContent(content);
|
|
45
|
+
const lineCount = countLines(content);
|
|
46
|
+
const previous = tracker.get(resolvedPath);
|
|
47
|
+
let seen;
|
|
48
|
+
if (!shown) {
|
|
49
|
+
seen = "all";
|
|
50
|
+
}
|
|
51
|
+
else if (previous?.hash === hash) {
|
|
52
|
+
seen = previous.seen === "all" ? "all" : toSeen([...previous.seen, shown], lineCount);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
seen = toSeen([shown], lineCount);
|
|
56
|
+
}
|
|
57
|
+
tracker.set(resolvedPath, { mtimeMs, hash, lineCount, seen });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Record the model's own change to a file. `write` supplies every line itself,
|
|
61
|
+
* so the model knows the whole result. `edit` changes only part of a file, so
|
|
62
|
+
* it knows the whole result only if it had already seen all of the original.
|
|
63
|
+
*/
|
|
64
|
+
export async function recordWrite(tracker, resolvedPath, content, ops, scope = "whole") {
|
|
65
|
+
if (!tracker)
|
|
66
|
+
return;
|
|
67
|
+
const stat = await ops.stat(resolvedPath);
|
|
68
|
+
const knewAll = scope === "whole" || tracker.get(resolvedPath)?.seen === "all";
|
|
69
|
+
tracker.set(resolvedPath, {
|
|
70
|
+
mtimeMs: stat.mtimeMs,
|
|
71
|
+
hash: hashContent(content),
|
|
72
|
+
lineCount: countLines(content),
|
|
73
|
+
// An edit shifts line numbers, so ranges seen before it no longer line up.
|
|
74
|
+
seen: knewAll ? "all" : [],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Lines of the file as it is on disk now that the model has not been shown:
|
|
79
|
+
* `"all"` when it never read the file or the file changed since its last
|
|
80
|
+
* read/write (mtime, else content hash), otherwise the gaps between the ranges
|
|
81
|
+
* it has seen (empty when it has seen every line). A full-file `write` uses
|
|
82
|
+
* this to report which lines it removed without the model having seen them.
|
|
83
|
+
*/
|
|
84
|
+
export async function unseenLines(tracker, resolvedPath, ops) {
|
|
85
|
+
if (!tracker)
|
|
86
|
+
return [];
|
|
87
|
+
if (!tracker.has(resolvedPath) || !(await isFresh(tracker, resolvedPath, ops)))
|
|
88
|
+
return "all";
|
|
89
|
+
const entry = tracker.get(resolvedPath);
|
|
90
|
+
if (!entry || entry.seen === "all")
|
|
91
|
+
return [];
|
|
92
|
+
const gaps = [];
|
|
93
|
+
let next = 1;
|
|
94
|
+
for (const [start, end] of entry.seen) {
|
|
95
|
+
if (start > next)
|
|
96
|
+
gaps.push([next, start - 1]);
|
|
97
|
+
next = end + 1;
|
|
98
|
+
}
|
|
99
|
+
if (next <= entry.lineCount)
|
|
100
|
+
gaps.push([next, entry.lineCount]);
|
|
101
|
+
return gaps;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* True when the recorded read still matches disk (mtime, else content hash).
|
|
105
|
+
* A hash match after an mtime-only change refreshes the recorded mtime.
|
|
106
|
+
*/
|
|
107
|
+
export async function isFresh(tracker, resolvedPath, ops) {
|
|
108
|
+
const entry = tracker.get(resolvedPath);
|
|
109
|
+
if (!entry)
|
|
110
|
+
return false;
|
|
111
|
+
const stat = await ops.stat(resolvedPath);
|
|
112
|
+
if (stat.mtimeMs === entry.mtimeMs)
|
|
113
|
+
return true;
|
|
114
|
+
const current = await ops.readFile(resolvedPath);
|
|
115
|
+
if (hashContent(current) !== entry.hash)
|
|
116
|
+
return false;
|
|
117
|
+
tracker.set(resolvedPath, { ...entry, mtimeMs: stat.mtimeMs });
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=read-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-tracker.js","sourceRoot":"","sources":["../../src/tools/read-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAoBjC,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IACzC,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC;AAED,SAAS,WAAW,CAAC,MAA4B;IAC/C,MAAM,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,MAAM,EAAE,CAAC;QAClC,MAAM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AEnB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1C,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACjD,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,KAAK,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentTool } from "@kenkaiiii/gg-agent";
|
|
3
|
+
import { type ToolOperations } from "./operations.js";
|
|
4
|
+
import { type ReadTracker } from "./read-tracker.js";
|
|
5
|
+
export declare const BINARY_EXTENSIONS: Set<string>;
|
|
6
|
+
declare const ReadParams: z.ZodObject<{
|
|
7
|
+
file_path: z.ZodString;
|
|
8
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
anchors: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare function createReadTool(cwd: string, readFiles?: ReadTracker, ops?: ToolOperations, onFileRead?: (filePath: string) => void | Promise<void>,
|
|
13
|
+
/** Max video payload (bytes) the active model accepts, or `undefined` for
|
|
14
|
+
* models without video support. When set, video files are returned as a
|
|
15
|
+
* native `video` content part (compressed to fit this cap); when undefined
|
|
16
|
+
* they fall through to the generic binary-file notice. */
|
|
17
|
+
videoByteLimit?: number): AgentTool<typeof ReadParams>;
|
|
18
|
+
export {};
|