@draht/coding-agent 2026.7.30 → 2026.9.5-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/CHANGELOG.md +154 -0
- package/README.md +46 -2
- package/agents/debugger.md +12 -1
- package/agents/git-committer.md +1 -0
- package/agents/implementer.md +20 -0
- package/agents/investigator.md +75 -0
- package/agents/reviewer.md +7 -0
- package/agents/spec-reviewer.md +66 -0
- package/agents/verifier.md +4 -3
- package/bin/draht-tools.cjs +472 -41
- package/dist/agents/debugger.md +12 -1
- package/dist/agents/git-committer.md +1 -0
- package/dist/agents/implementer.md +20 -0
- package/dist/agents/investigator.md +75 -0
- package/dist/agents/reviewer.md +7 -0
- package/dist/agents/spec-reviewer.md +66 -0
- package/dist/agents/verifier.md +4 -3
- package/dist/cli/args.d.ts +10 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +69 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/attach-mode.d.ts +61 -0
- package/dist/cli/attach-mode.d.ts.map +1 -1
- package/dist/cli/attach-mode.js +243 -5
- package/dist/cli/attach-mode.js.map +1 -1
- package/dist/cli/credential-print.d.ts +1 -1
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +5 -4
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +31 -4
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +17 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +87 -30
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +35 -16
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +149 -64
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +5 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +72 -15
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtins/checkpoints.d.ts +20 -0
- package/dist/core/builtins/checkpoints.d.ts.map +1 -0
- package/dist/core/builtins/checkpoints.js +161 -0
- package/dist/core/builtins/checkpoints.js.map +1 -0
- package/dist/core/builtins/duet.d.ts +26 -0
- package/dist/core/builtins/duet.d.ts.map +1 -0
- package/dist/core/builtins/duet.js +660 -0
- package/dist/core/builtins/duet.js.map +1 -0
- package/dist/core/builtins/index.d.ts.map +1 -1
- package/dist/core/builtins/index.js +7 -1
- package/dist/core/builtins/index.js.map +1 -1
- package/dist/core/builtins/subagent.d.ts +24 -4
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +278 -35
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/checkpoints/checkpoint-cli.d.ts +17 -0
- package/dist/core/checkpoints/checkpoint-cli.d.ts.map +1 -0
- package/dist/core/checkpoints/checkpoint-cli.js +78 -0
- package/dist/core/checkpoints/checkpoint-cli.js.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts +294 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.js +865 -0
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -0
- package/dist/core/checkpoints/rewind.d.ts +141 -0
- package/dist/core/checkpoints/rewind.d.ts.map +1 -0
- package/dist/core/checkpoints/rewind.js +246 -0
- package/dist/core/checkpoints/rewind.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +9 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +25 -4
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +83 -20
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +13 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +37 -2
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +189 -6
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +7 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +5 -0
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +1 -0
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +3 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -8
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +34 -7
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +7 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +30 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +4 -3
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/multi-agent/worktree.d.ts +2 -0
- package/dist/core/multi-agent/worktree.d.ts.map +1 -1
- package/dist/core/multi-agent/worktree.js +2 -2
- package/dist/core/multi-agent/worktree.js.map +1 -1
- package/dist/core/package-manager.d.ts +7 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +21 -44
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permission-relay/index.d.ts +19 -0
- package/dist/core/permission-relay/index.d.ts.map +1 -0
- package/dist/core/permission-relay/index.js +49 -0
- package/dist/core/permission-relay/index.js.map +1 -0
- package/dist/core/permission-relay/relay-ui-context.d.ts +39 -0
- package/dist/core/permission-relay/relay-ui-context.d.ts.map +1 -0
- package/dist/core/permission-relay/relay-ui-context.js +788 -0
- package/dist/core/permission-relay/relay-ui-context.js.map +1 -0
- package/dist/core/permission-relay/types.d.ts +222 -0
- package/dist/core/permission-relay/types.d.ts.map +1 -0
- package/dist/core/permission-relay/types.js +15 -0
- package/dist/core/permission-relay/types.js.map +1 -0
- package/dist/core/pi-manifest.d.ts +14 -0
- package/dist/core/pi-manifest.d.ts.map +1 -0
- package/dist/core/pi-manifest.js +35 -0
- package/dist/core/pi-manifest.js.map +1 -0
- package/dist/core/project-trust.js +2 -2
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/resource-loader.d.ts +21 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +101 -24
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sandbox/bash-operations.d.ts +149 -0
- package/dist/core/sandbox/bash-operations.d.ts.map +1 -0
- package/dist/core/sandbox/bash-operations.js +163 -0
- package/dist/core/sandbox/bash-operations.js.map +1 -0
- package/dist/core/sandbox/env.d.ts +83 -0
- package/dist/core/sandbox/env.d.ts.map +1 -0
- package/dist/core/sandbox/env.js +123 -0
- package/dist/core/sandbox/env.js.map +1 -0
- package/dist/core/sandbox/executor.d.ts +104 -0
- package/dist/core/sandbox/executor.d.ts.map +1 -0
- package/dist/core/sandbox/executor.js +92 -0
- package/dist/core/sandbox/executor.js.map +1 -0
- package/dist/core/sandbox/index.d.ts +36 -0
- package/dist/core/sandbox/index.d.ts.map +1 -0
- package/dist/core/sandbox/index.js +36 -0
- package/dist/core/sandbox/index.js.map +1 -0
- package/dist/core/sandbox/linux.d.ts +121 -0
- package/dist/core/sandbox/linux.d.ts.map +1 -0
- package/dist/core/sandbox/linux.js +260 -0
- package/dist/core/sandbox/linux.js.map +1 -0
- package/dist/core/sandbox/policy.d.ts +142 -0
- package/dist/core/sandbox/policy.d.ts.map +1 -0
- package/dist/core/sandbox/policy.js +297 -0
- package/dist/core/sandbox/policy.js.map +1 -0
- package/dist/core/sandbox/real-path.d.ts +112 -0
- package/dist/core/sandbox/real-path.d.ts.map +1 -0
- package/dist/core/sandbox/real-path.js +158 -0
- package/dist/core/sandbox/real-path.js.map +1 -0
- package/dist/core/sandbox/seatbelt-profile.d.ts +95 -0
- package/dist/core/sandbox/seatbelt-profile.d.ts.map +1 -0
- package/dist/core/sandbox/seatbelt-profile.js +239 -0
- package/dist/core/sandbox/seatbelt-profile.js.map +1 -0
- package/dist/core/sandbox/seatbelt.d.ts +95 -0
- package/dist/core/sandbox/seatbelt.d.ts.map +1 -0
- package/dist/core/sandbox/seatbelt.js +154 -0
- package/dist/core/sandbox/seatbelt.js.map +1 -0
- package/dist/core/sandbox/self-test.d.ts +109 -0
- package/dist/core/sandbox/self-test.d.ts.map +1 -0
- package/dist/core/sandbox/self-test.js +369 -0
- package/dist/core/sandbox/self-test.js.map +1 -0
- package/dist/core/sandbox/spawn.d.ts +33 -0
- package/dist/core/sandbox/spawn.d.ts.map +1 -0
- package/dist/core/sandbox/spawn.js +87 -0
- package/dist/core/sandbox/spawn.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +60 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +53 -6
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +21 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +36 -16
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +3 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +19 -6
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/soak/soak-log.d.ts +298 -0
- package/dist/core/soak/soak-log.d.ts.map +1 -0
- package/dist/core/soak/soak-log.js +660 -0
- package/dist/core/soak/soak-log.js.map +1 -0
- package/dist/core/soak/soak-reader.d.ts +60 -0
- package/dist/core/soak/soak-reader.d.ts.map +1 -0
- package/dist/core/soak/soak-reader.js +106 -0
- package/dist/core/soak/soak-reader.js.map +1 -0
- package/dist/core/socket-server/discovery.d.ts +78 -1
- package/dist/core/socket-server/discovery.d.ts.map +1 -1
- package/dist/core/socket-server/discovery.js +356 -37
- package/dist/core/socket-server/discovery.js.map +1 -1
- package/dist/core/socket-server/index.d.ts +10 -4
- package/dist/core/socket-server/index.d.ts.map +1 -1
- package/dist/core/socket-server/index.js +6 -3
- package/dist/core/socket-server/index.js.map +1 -1
- package/dist/core/socket-server/permission-delivery.d.ts +125 -0
- package/dist/core/socket-server/permission-delivery.d.ts.map +1 -0
- package/dist/core/socket-server/permission-delivery.js +152 -0
- package/dist/core/socket-server/permission-delivery.js.map +1 -0
- package/dist/core/socket-server/permission-registry.d.ts +301 -0
- package/dist/core/socket-server/permission-registry.d.ts.map +1 -0
- package/dist/core/socket-server/permission-registry.js +410 -0
- package/dist/core/socket-server/permission-registry.js.map +1 -0
- package/dist/core/socket-server/permission-relay.d.ts +81 -0
- package/dist/core/socket-server/permission-relay.d.ts.map +1 -0
- package/dist/core/socket-server/permission-relay.js +528 -0
- package/dist/core/socket-server/permission-relay.js.map +1 -0
- package/dist/core/socket-server/safe-text.d.ts +83 -0
- package/dist/core/socket-server/safe-text.d.ts.map +1 -0
- package/dist/core/socket-server/safe-text.js +277 -0
- package/dist/core/socket-server/safe-text.js.map +1 -0
- package/dist/core/socket-server/session-integration.d.ts +65 -2
- package/dist/core/socket-server/session-integration.d.ts.map +1 -1
- package/dist/core/socket-server/session-integration.js +434 -32
- package/dist/core/socket-server/session-integration.js.map +1 -1
- package/dist/core/socket-server/socket-client.d.ts +21 -2
- package/dist/core/socket-server/socket-client.d.ts.map +1 -1
- package/dist/core/socket-server/socket-client.js +52 -1
- package/dist/core/socket-server/socket-client.js.map +1 -1
- package/dist/core/socket-server/socket-server.d.ts +152 -1
- package/dist/core/socket-server/socket-server.d.ts.map +1 -1
- package/dist/core/socket-server/socket-server.js +775 -26
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +106 -2
- package/dist/core/socket-server/types.d.ts.map +1 -1
- package/dist/core/socket-server/types.js +13 -1
- package/dist/core/socket-server/types.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +8 -9
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +5 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +17 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +3 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -18
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/trust-manager.d.ts +6 -4
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +55 -21
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +5 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +5 -1
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/stub-provider/index.d.ts +9 -0
- package/dist/extensions/stub-provider/index.d.ts.map +1 -0
- package/dist/extensions/stub-provider/index.js +13 -0
- package/dist/extensions/stub-provider/index.js.map +1 -0
- package/dist/extensions/stub-provider/provider.d.ts +77 -0
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -0
- package/dist/extensions/stub-provider/provider.js +193 -0
- package/dist/extensions/stub-provider/provider.js.map +1 -0
- package/dist/hooks/gsd/draht-quality-gate.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +242 -45
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +3 -2
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +49 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +202 -5
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +10 -2
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +10 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +10 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +20 -2
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +21 -5
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +97 -3
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +394 -24
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +165 -7
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +68 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/prompts/commands/atomic-commit.md +1 -12
- package/dist/prompts/commands/brainstorm.md +12 -15
- package/dist/prompts/commands/create-verification-skill.md +108 -0
- package/dist/prompts/commands/discuss-phase.md +3 -14
- package/dist/prompts/commands/execute-phase.md +3 -11
- package/dist/prompts/commands/fix.md +41 -18
- package/dist/prompts/commands/grill.md +66 -0
- package/dist/prompts/commands/init-project.md +5 -15
- package/dist/prompts/commands/map-codebase.md +1 -13
- package/dist/prompts/commands/new-project.md +5 -15
- package/dist/prompts/commands/next-milestone.md +1 -13
- package/dist/prompts/commands/orchestrate.md +1 -1
- package/dist/prompts/commands/pause-work.md +1 -13
- package/dist/prompts/commands/plan-phase.md +2 -11
- package/dist/prompts/commands/progress.md +0 -13
- package/dist/prompts/commands/quick.md +3 -11
- package/dist/prompts/commands/resolve-conflicts.md +71 -0
- package/dist/prompts/commands/resume-work.md +0 -13
- package/dist/prompts/commands/review.md +4 -13
- package/dist/prompts/commands/triage.md +159 -0
- package/dist/prompts/commands/verify-work.md +4 -14
- package/dist/prompts/commands/why.md +135 -0
- package/dist/skills/atomic-reasoning/SKILL.md +115 -0
- package/dist/skills/blast-radius/SKILL.md +55 -0
- package/dist/skills/epistemics/SKILL.md +99 -0
- package/dist/skills/hexagon-animation/SKILL.md +49 -0
- package/dist/skills/hexagon-animation/generate.mjs +81 -0
- package/dist/skills/hexagon-animation/template.html +361 -0
- package/dist/skills/typescript-discipline/SKILL.md +50 -0
- package/dist/skills/typescript-discipline/references/patterns.md +294 -0
- package/dist/skills/unslop/SKILL.md +101 -0
- package/dist/utils/canonical-path.d.ts +28 -0
- package/dist/utils/canonical-path.d.ts.map +1 -0
- package/dist/utils/canonical-path.js +90 -0
- package/dist/utils/canonical-path.js.map +1 -0
- package/dist/utils/child-process.d.ts +12 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +25 -8
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +22 -2
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/paths.d.ts +2 -7
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +13 -15
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +6 -4
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +3 -5
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/attachable-sessions.md +79 -0
- package/docs/compaction.md +21 -21
- package/docs/containerization.md +23 -23
- package/docs/custom-provider.md +16 -16
- package/docs/development.md +9 -9
- package/docs/docs.json +6 -2
- package/docs/duet.md +42 -0
- package/docs/extensions.md +58 -58
- package/docs/index.md +10 -10
- package/docs/json.md +7 -7
- package/docs/keybindings.md +6 -5
- package/docs/llama-cpp.md +6 -6
- package/docs/models.md +6 -6
- package/docs/packages.md +43 -43
- package/docs/prompt-templates.md +4 -4
- package/docs/providers.md +12 -12
- package/docs/quickstart.md +32 -32
- package/docs/rpc.md +83 -12
- package/docs/sdk.md +15 -15
- package/docs/security.md +18 -18
- package/docs/session-format.md +35 -13
- package/docs/sessions.md +17 -14
- package/docs/settings.md +25 -18
- package/docs/shell-aliases.md +2 -2
- package/docs/skills.md +12 -11
- package/docs/terminal-setup.md +12 -12
- package/docs/termux.md +6 -6
- package/docs/themes.md +11 -11
- package/docs/tmux.md +4 -4
- package/docs/tui.md +5 -5
- package/docs/usage.md +50 -50
- package/docs/windows.md +2 -2
- package/examples/extensions/overlay-qa-tests.ts +3 -3
- package/hooks/gsd/draht-quality-gate.js +3 -3
- package/package.json +11 -10
- package/prompts/commands/atomic-commit.md +1 -12
- package/prompts/commands/brainstorm.md +12 -15
- package/prompts/commands/create-verification-skill.md +108 -0
- package/prompts/commands/discuss-phase.md +3 -14
- package/prompts/commands/execute-phase.md +3 -11
- package/prompts/commands/fix.md +41 -18
- package/prompts/commands/grill.md +66 -0
- package/prompts/commands/init-project.md +5 -15
- package/prompts/commands/map-codebase.md +1 -13
- package/prompts/commands/new-project.md +5 -15
- package/prompts/commands/next-milestone.md +1 -13
- package/prompts/commands/orchestrate.md +1 -1
- package/prompts/commands/pause-work.md +1 -13
- package/prompts/commands/plan-phase.md +2 -11
- package/prompts/commands/progress.md +0 -13
- package/prompts/commands/quick.md +3 -11
- package/prompts/commands/resolve-conflicts.md +71 -0
- package/prompts/commands/resume-work.md +0 -13
- package/prompts/commands/review.md +4 -13
- package/prompts/commands/triage.md +159 -0
- package/prompts/commands/verify-work.md +4 -14
- package/prompts/commands/why.md +135 -0
- package/skills/atomic-reasoning/SKILL.md +115 -0
- package/skills/blast-radius/SKILL.md +55 -0
- package/skills/epistemics/SKILL.md +99 -0
- package/skills/hexagon-animation/SKILL.md +49 -0
- package/skills/hexagon-animation/generate.mjs +81 -0
- package/skills/hexagon-animation/template.html +361 -0
- package/skills/typescript-discipline/SKILL.md +50 -0
- package/skills/typescript-discipline/references/patterns.md +294 -0
- package/skills/unslop/SKILL.md +101 -0
- package/dist/prompts/agents/build.md +0 -86
- package/dist/prompts/agents/plan.md +0 -79
- package/dist/prompts/agents/verify.md +0 -69
- package/prompts/agents/build.md +0 -86
- package/prompts/agents/plan.md +0 -79
- package/prompts/agents/verify.md +0 -69
|
@@ -13,6 +13,8 @@ import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, DISPLAY_VERSION, getAgentDir, get
|
|
|
13
13
|
import { parseSkillBlock } from "../../core/agent-session.js";
|
|
14
14
|
import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
|
|
15
15
|
import { CACHE_TTL_MS, collectCacheMisses, computeCacheWaste, detectCacheMiss, } from "../../core/cache-stats.js";
|
|
16
|
+
import { CheckpointManager } from "../../core/checkpoints/checkpoint-manager.js";
|
|
17
|
+
import { DEFAULT_REWIND_SCOPE, listRewindTargets, performRewind, REWIND_SCOPE_CHOICES, rewindScopeForLabel, } from "../../core/checkpoints/rewind.js";
|
|
16
18
|
import { formatContextWindow } from "../../core/context-windows.js";
|
|
17
19
|
import { FooterDataProvider } from "../../core/footer-data-provider.js";
|
|
18
20
|
import { configureHttpDispatcher, formatHttpIdleTimeoutMs } from "../../core/http-dispatcher.js";
|
|
@@ -23,6 +25,7 @@ import { DefaultPackageManager } from "../../core/package-manager.js";
|
|
|
23
25
|
import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
|
|
24
26
|
import { SessionManager, sessionEntryToContextMessages } from "../../core/session-manager.js";
|
|
25
27
|
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
|
28
|
+
import { boundedSafeText } from "../../core/socket-server/safe-text.js";
|
|
26
29
|
import { isInstallTelemetryEnabled } from "../../core/telemetry.js";
|
|
27
30
|
import { hasTrustRequiringProjectResources, ProjectTrustStore } from "../../core/trust-manager.js";
|
|
28
31
|
import { getUsageCostBreakdown } from "../../core/usage-totals.js";
|
|
@@ -50,7 +53,7 @@ import { DynamicBorder } from "./components/dynamic-border.js";
|
|
|
50
53
|
import { EarendilAnnouncementComponent } from "./components/earendil-announcement.js";
|
|
51
54
|
import { ExtensionEditorComponent } from "./components/extension-editor.js";
|
|
52
55
|
import { ExtensionInputComponent } from "./components/extension-input.js";
|
|
53
|
-
import { ExtensionSelectorComponent } from "./components/extension-selector.js";
|
|
56
|
+
import { boundDialogText, ExtensionSelectorComponent, MAX_DETAIL_ROWS } from "./components/extension-selector.js";
|
|
54
57
|
import { FooterComponent, formatTokens } from "./components/footer.js";
|
|
55
58
|
import { formatKeyText, keyDisplayText, keyHint, keyText, rawKeyHint } from "./components/keybinding-hints.js";
|
|
56
59
|
import { LoginDialogComponent } from "./components/login-dialog.js";
|
|
@@ -210,6 +213,10 @@ export class InteractiveMode {
|
|
|
210
213
|
this.signalCleanupHandlers = [];
|
|
211
214
|
// Track if editor is in bash mode (text starts with !)
|
|
212
215
|
this.isBashMode = false;
|
|
216
|
+
// True while `/rewind` is rewriting the working tree. The selector hands
|
|
217
|
+
// focus back to the editor before the restore finishes, so submissions have
|
|
218
|
+
// to be gated here or a new prompt runs against a half-restored tree.
|
|
219
|
+
this.isRewindRunning = false;
|
|
213
220
|
// Track current bash execution component
|
|
214
221
|
this.bashComponent = undefined;
|
|
215
222
|
// Track pending bash components (shown in pending area, moved to chat on submit)
|
|
@@ -220,8 +227,22 @@ export class InteractiveMode {
|
|
|
220
227
|
this.shutdownRequested = false;
|
|
221
228
|
// Extension UI state
|
|
222
229
|
this.extensionSelector = undefined;
|
|
230
|
+
/**
|
|
231
|
+
* Settles the promise of the dialog currently occupying {@link extensionSelector}.
|
|
232
|
+
*
|
|
233
|
+
* The slot holds at most one dialog, so opening a second one used to overwrite the first without
|
|
234
|
+
* settling it — stranding a promise that `beforeToolCall` is awaiting, which wedges the agent
|
|
235
|
+
* loop forever. Keeping the settle function beside the component makes the slot non-clobbering.
|
|
236
|
+
*/
|
|
237
|
+
this.extensionSelectorSettle = undefined;
|
|
238
|
+
/** Label of the surface that decided the open ask elsewhere, pending a one-line notice. */
|
|
239
|
+
this.extensionDialogDecidedBy = undefined;
|
|
223
240
|
this.extensionInput = undefined;
|
|
241
|
+
/** Settles the promise `showExtensionInput` returned. See {@link hideExtensionInput}. */
|
|
242
|
+
this.extensionInputSettle = undefined;
|
|
224
243
|
this.extensionEditor = undefined;
|
|
244
|
+
/** Settles the promise `showExtensionEditor` returned. See {@link hideExtensionEditor}. */
|
|
245
|
+
this.extensionEditorSettle = undefined;
|
|
225
246
|
this.extensionTerminalInputUnsubscribers = new Set();
|
|
226
247
|
// Extension widgets (components rendered above/below the editor)
|
|
227
248
|
this.extensionWidgetsAbove = new Map();
|
|
@@ -1717,50 +1738,190 @@ export class InteractiveMode {
|
|
|
1717
1738
|
/**
|
|
1718
1739
|
* Show a selector for extensions.
|
|
1719
1740
|
*/
|
|
1720
|
-
showExtensionSelector(title, options, opts) {
|
|
1741
|
+
showExtensionSelector(title, options, opts, detailRows) {
|
|
1721
1742
|
return new Promise((resolve) => {
|
|
1722
1743
|
if (opts?.signal?.aborted) {
|
|
1723
1744
|
resolve(undefined);
|
|
1724
1745
|
return;
|
|
1725
1746
|
}
|
|
1747
|
+
let settled = false;
|
|
1748
|
+
const settle = (value) => {
|
|
1749
|
+
if (settled)
|
|
1750
|
+
return;
|
|
1751
|
+
settled = true;
|
|
1752
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
1753
|
+
if (this.extensionSelectorSettle === settle)
|
|
1754
|
+
this.extensionSelectorSettle = undefined;
|
|
1755
|
+
// A deciding-surface label that nothing flushed belongs to THIS ask and dies with it.
|
|
1756
|
+
// Left standing it is sticky: the next, unrelated dialog's teardown would emit
|
|
1757
|
+
// "Permission resolved by <whoever>" about an ask that surface never saw.
|
|
1758
|
+
this.extensionDialogDecidedBy = undefined;
|
|
1759
|
+
resolve(value);
|
|
1760
|
+
};
|
|
1726
1761
|
const onAbort = () => {
|
|
1727
|
-
|
|
1728
|
-
|
|
1762
|
+
// A dialog that was already displaced by a newer one must not tear the newer one down.
|
|
1763
|
+
if (!settled) {
|
|
1764
|
+
// Flush BEFORE settling: `settle` drops the pending label, and `hideExtensionSelector`
|
|
1765
|
+
// now settles this dialog fail-closed on its way out.
|
|
1766
|
+
this.flushExtensionDialogDecidedNotice();
|
|
1767
|
+
this.hideExtensionSelector();
|
|
1768
|
+
}
|
|
1769
|
+
settle(undefined);
|
|
1729
1770
|
};
|
|
1730
1771
|
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1731
|
-
|
|
1732
|
-
|
|
1772
|
+
// Non-clobbering slot. Whatever is already in it is disposed and its promise settled as
|
|
1773
|
+
// cancelled BEFORE the replacement takes over; the previous code overwrote the field and
|
|
1774
|
+
// left the earlier caller awaiting a promise nothing could ever resolve.
|
|
1775
|
+
const displaced = this.extensionSelectorSettle;
|
|
1776
|
+
this.extensionSelector?.dispose();
|
|
1777
|
+
this.extensionSelector = undefined;
|
|
1778
|
+
this.extensionSelectorSettle = undefined;
|
|
1779
|
+
this.extensionSelector = new ExtensionSelectorComponent(title, options,
|
|
1780
|
+
// Settle BEFORE hiding: `hideExtensionSelector` settles whatever is still in the slot
|
|
1781
|
+
// fail-closed, so hiding first would resolve the ask as `undefined` (a denial) and the
|
|
1782
|
+
// human's actual choice would be swallowed by the `settled` guard.
|
|
1783
|
+
(option) => {
|
|
1784
|
+
settle(option);
|
|
1733
1785
|
this.hideExtensionSelector();
|
|
1734
|
-
resolve(option);
|
|
1735
1786
|
}, () => {
|
|
1736
|
-
|
|
1787
|
+
settle(undefined);
|
|
1737
1788
|
this.hideExtensionSelector();
|
|
1738
|
-
|
|
1739
|
-
|
|
1789
|
+
}, {
|
|
1790
|
+
tui: this.ui,
|
|
1791
|
+
timeout: opts?.timeout,
|
|
1792
|
+
detailRows,
|
|
1793
|
+
onToggleToolsExpanded: () => this.toggleToolOutputExpansion(),
|
|
1794
|
+
});
|
|
1795
|
+
this.extensionSelectorSettle = settle;
|
|
1740
1796
|
this.editorContainer.clear();
|
|
1741
1797
|
this.editorContainer.addChild(this.extensionSelector);
|
|
1742
1798
|
this.ui.setFocus(this.extensionSelector);
|
|
1743
1799
|
this.ui.requestRender();
|
|
1800
|
+
// Settle the displaced caller only once the replacement is installed, so its continuation
|
|
1801
|
+
// cannot observe an empty dialog slot.
|
|
1802
|
+
displaced?.(undefined);
|
|
1744
1803
|
});
|
|
1745
1804
|
}
|
|
1746
1805
|
/**
|
|
1747
|
-
*
|
|
1806
|
+
* Record that the open ask was decided by another surface (an attached client, the RPC caller).
|
|
1807
|
+
*
|
|
1808
|
+
* This does NOT dismiss the dialog: `opts.signal` already does that, and the relay aborts it
|
|
1809
|
+
* right after calling this. All that is added here is the RENDERING — the operator otherwise
|
|
1810
|
+
* watches a permission dialog vanish with no account of who answered it.
|
|
1811
|
+
*/
|
|
1812
|
+
noteExtensionDialogResolvedElsewhere(label) {
|
|
1813
|
+
this.extensionDialogDecidedBy = label;
|
|
1814
|
+
// Nothing is open to abort, so no teardown will flush the notice — emit it now.
|
|
1815
|
+
if (!this.extensionSelector)
|
|
1816
|
+
this.flushExtensionDialogDecidedNotice();
|
|
1817
|
+
}
|
|
1818
|
+
/** Emit the pending deciding-surface notice at most once, then forget it. */
|
|
1819
|
+
flushExtensionDialogDecidedNotice() {
|
|
1820
|
+
const label = this.extensionDialogDecidedBy;
|
|
1821
|
+
if (label === undefined)
|
|
1822
|
+
return;
|
|
1823
|
+
this.extensionDialogDecidedBy = undefined;
|
|
1824
|
+
this.showExtensionNotify(`Permission resolved by ${label}`, "info");
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Hide the extension selector, settling its promise FAIL-CLOSED if nothing else has.
|
|
1828
|
+
*
|
|
1829
|
+
* Every teardown path FOR THE SELECTOR funnels through here — {@link hideExtensionInput} and
|
|
1830
|
+
* {@link hideExtensionEditor} are the matching, separate ones for the other two dialog types, and
|
|
1831
|
+
* they need the same treatment for the same reason. This one used to drop the component on the
|
|
1832
|
+
* floor without touching {@link extensionSelectorSettle} when `resetExtensionUI` (reached from
|
|
1833
|
+
* `setBeforeSessionInvalidate` and from `/reload`) called it. A session invalidate while a permission ask
|
|
1834
|
+
* was open therefore stranded the promise `beforeToolCall` awaits and wedged the agent loop
|
|
1835
|
+
* forever: no dialog on screen, no tool call, no way out.
|
|
1836
|
+
*
|
|
1837
|
+
* `undefined` is the fail-closed answer — `showExtensionConfirm` maps it to `false`, i.e. denial.
|
|
1838
|
+
* Callers that carry a real answer must `settle(...)` it BEFORE calling this.
|
|
1748
1839
|
*/
|
|
1749
1840
|
hideExtensionSelector() {
|
|
1841
|
+
const settle = this.extensionSelectorSettle;
|
|
1842
|
+
this.extensionSelectorSettle = undefined;
|
|
1750
1843
|
this.extensionSelector?.dispose();
|
|
1751
1844
|
this.editorContainer.clear();
|
|
1752
1845
|
this.editorContainer.addChild(this.editor);
|
|
1753
1846
|
this.extensionSelector = undefined;
|
|
1754
1847
|
this.ui.setFocus(this.editor);
|
|
1755
1848
|
this.ui.requestRender();
|
|
1849
|
+
// Last, so the caller's continuation cannot observe a half-torn-down dialog slot.
|
|
1850
|
+
settle?.(undefined);
|
|
1756
1851
|
}
|
|
1757
1852
|
/**
|
|
1758
1853
|
* Show a confirmation dialog for extensions.
|
|
1854
|
+
*
|
|
1855
|
+
* `ui.confirm(title, message, opts)` is a PUBLIC extension surface and the attach relay forwards
|
|
1856
|
+
* the caller's title through unchanged, so `title` is attacker-influenced even when the built-in
|
|
1857
|
+
* permission gate passes a constant. Untreated it carried every defect the detail rows were
|
|
1858
|
+
* hardened against: `ESC[2J` in a title cleared the operator's screen, U+202E survived verbatim,
|
|
1859
|
+
* and `"Approve\nYes\nNo"` rendered four option-looking rows above two real ones.
|
|
1860
|
+
*
|
|
1861
|
+
* TITLE and MESSAGE are bounded DIFFERENTLY, because they are different things:
|
|
1862
|
+
*
|
|
1863
|
+
* - a TITLE is a header, so it stays exactly ONE row on every path and its newlines are
|
|
1864
|
+
* neutralized. That is what stops `"Approve\nYes\nNo"` from drawing option-looking rows above
|
|
1865
|
+
* the real ones, and it costs nothing HERE: no caller of `showExtensionConfirm` writes a
|
|
1866
|
+
* multi-line title. (Two callers elsewhere do — `showStartupSelector` gets the five-line
|
|
1867
|
+
* `formatMissingSessionCwdPrompt` from `main.ts`, and `project-trust.ts` passes
|
|
1868
|
+
* `${title}\n${message}` — but they reach `ExtensionSelectorComponent` directly, where
|
|
1869
|
+
* `TitleRowsComponent` draws one row per line. The reasoning below depends only on the
|
|
1870
|
+
* `showExtensionConfirm` path.)
|
|
1871
|
+
* - a MESSAGE is prose, so it gets a ROW BUDGET and its own newlines are row breaks. Bounding it
|
|
1872
|
+
* to a single row's width instead gutted the `/rewind --fork` consent dialog (215 of its 273
|
|
1873
|
+
* characters elided at 80 columns) and collapsed the deliberately 5-line
|
|
1874
|
+
* `formatMissingSessionCwdPrompt` into one. See {@link boundDialogText}.
|
|
1759
1875
|
*/
|
|
1760
1876
|
async showExtensionConfirm(title, message, opts) {
|
|
1761
|
-
|
|
1877
|
+
// Grapheme budget for one row of dialog text: the terminal width less the row's `paddingX: 1`
|
|
1878
|
+
// on each side. The floor keeps a very narrow terminal from producing a useless budget.
|
|
1879
|
+
const columns = this.ui?.terminal?.columns ?? 80;
|
|
1880
|
+
const safeTitle = boundedSafeText(title, Math.max(16, columns - 2)).value;
|
|
1881
|
+
const detail = opts?.detail;
|
|
1882
|
+
if (detail !== undefined) {
|
|
1883
|
+
// A permission ask arrives with typed fields, so it is rendered as typed rows. Flattening
|
|
1884
|
+
// it back into `${title}\n${message}` would hand the attacker-influenced command a way to
|
|
1885
|
+
// forge rows, and the human would be deciding about a string rather than about a call.
|
|
1886
|
+
const rows = this.buildPermissionDetailRows(detail);
|
|
1887
|
+
const result = await this.showExtensionSelector(safeTitle, ["Yes", "No"], opts, rows);
|
|
1888
|
+
return result === "Yes";
|
|
1889
|
+
}
|
|
1890
|
+
// Two rows of the header budget are already spoken for: the single-row title above, and the
|
|
1891
|
+
// spacer `ExtensionSelectorComponent` draws between the header and the option list when there
|
|
1892
|
+
// are no detail rows. Both sit above `Yes`, so both have to come out of the same budget.
|
|
1893
|
+
const safeMessage = boundDialogText(message, columns, MAX_DETAIL_ROWS - 2);
|
|
1894
|
+
const result = await this.showExtensionSelector(`${safeTitle}\n${safeMessage}`, ["Yes", "No"], opts);
|
|
1762
1895
|
return result === "Yes";
|
|
1763
1896
|
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Turn a {@link PermissionAskDetail} into one bounded, neutralized row per fact.
|
|
1899
|
+
*
|
|
1900
|
+
* The protocol layer neutralizes what arrives from a remote surface, but a LOCALLY raised ask
|
|
1901
|
+
* never crosses the wire — so the rule is applied here too. Note the ORDER: neutralize, then
|
|
1902
|
+
* measure. `visibleWidth` strips ANSI for measurement only and reports zero width for bidi
|
|
1903
|
+
* controls and DEL, so any width budget computed over raw text is a fiction.
|
|
1904
|
+
*/
|
|
1905
|
+
buildPermissionDetailRows(detail) {
|
|
1906
|
+
const labels = [
|
|
1907
|
+
["Tool", detail.toolName],
|
|
1908
|
+
["Directory", detail.cwd],
|
|
1909
|
+
["Command", detail.command],
|
|
1910
|
+
["Path", detail.path],
|
|
1911
|
+
["Operation", detail.operation],
|
|
1912
|
+
["Reason", detail.reason],
|
|
1913
|
+
];
|
|
1914
|
+
const present = labels.filter((entry) => {
|
|
1915
|
+
const value = entry[1];
|
|
1916
|
+
return value !== undefined && value.length > 0;
|
|
1917
|
+
});
|
|
1918
|
+
const labelWidth = present.reduce((max, [label]) => Math.max(max, label.length), 0);
|
|
1919
|
+
// Terminal width minus the row margins, the label column and its ": " separator. The floor
|
|
1920
|
+
// keeps a narrow terminal from producing a zero or negative budget.
|
|
1921
|
+
const columns = this.ui?.terminal?.columns ?? 80;
|
|
1922
|
+
const budget = Math.max(16, columns - 2 - labelWidth - 2);
|
|
1923
|
+
return present.map(([label, value]) => `${label.padEnd(labelWidth)}: ${boundedSafeText(value, budget).value}`);
|
|
1924
|
+
}
|
|
1764
1925
|
async promptForMissingSessionCwd(error) {
|
|
1765
1926
|
const confirmed = await this.showExtensionConfirm("Session cwd not found", formatMissingSessionCwdPrompt(error.issue));
|
|
1766
1927
|
return confirmed ? error.issue.fallbackCwd : undefined;
|
|
@@ -1774,64 +1935,125 @@ export class InteractiveMode {
|
|
|
1774
1935
|
resolve(undefined);
|
|
1775
1936
|
return;
|
|
1776
1937
|
}
|
|
1938
|
+
let settled = false;
|
|
1939
|
+
const settle = (value) => {
|
|
1940
|
+
if (settled)
|
|
1941
|
+
return;
|
|
1942
|
+
settled = true;
|
|
1943
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
1944
|
+
if (this.extensionInputSettle === settle)
|
|
1945
|
+
this.extensionInputSettle = undefined;
|
|
1946
|
+
resolve(value);
|
|
1947
|
+
};
|
|
1777
1948
|
const onAbort = () => {
|
|
1778
|
-
|
|
1779
|
-
|
|
1949
|
+
// A dialog already displaced by a newer one must not tear the newer one down.
|
|
1950
|
+
if (!settled)
|
|
1951
|
+
this.hideExtensionInput();
|
|
1952
|
+
settle(undefined);
|
|
1780
1953
|
};
|
|
1781
1954
|
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
1782
|
-
|
|
1783
|
-
|
|
1955
|
+
const displaced = this.extensionInputSettle;
|
|
1956
|
+
this.extensionInput?.dispose();
|
|
1957
|
+
this.extensionInput = undefined;
|
|
1958
|
+
this.extensionInputSettle = undefined;
|
|
1959
|
+
this.extensionInput = new ExtensionInputComponent(title, placeholder,
|
|
1960
|
+
// Settle BEFORE hiding, for the same reason the selector does: `hideExtensionInput`
|
|
1961
|
+
// settles whatever is still in the slot fail-closed, so hiding first would resolve the
|
|
1962
|
+
// ask as `undefined` and the human's actual answer would hit the `settled` guard.
|
|
1963
|
+
(value) => {
|
|
1964
|
+
settle(value);
|
|
1784
1965
|
this.hideExtensionInput();
|
|
1785
|
-
resolve(value);
|
|
1786
1966
|
}, () => {
|
|
1787
|
-
|
|
1967
|
+
settle(undefined);
|
|
1788
1968
|
this.hideExtensionInput();
|
|
1789
|
-
resolve(undefined);
|
|
1790
1969
|
}, { tui: this.ui, timeout: opts?.timeout });
|
|
1970
|
+
this.extensionInputSettle = settle;
|
|
1791
1971
|
this.editorContainer.clear();
|
|
1792
1972
|
this.editorContainer.addChild(this.extensionInput);
|
|
1793
1973
|
this.ui.setFocus(this.extensionInput);
|
|
1794
1974
|
this.ui.requestRender();
|
|
1975
|
+
// Only once the replacement is installed, so the displaced caller's continuation cannot
|
|
1976
|
+
// observe an empty dialog slot.
|
|
1977
|
+
displaced?.(undefined);
|
|
1795
1978
|
});
|
|
1796
1979
|
}
|
|
1797
1980
|
/**
|
|
1798
|
-
* Hide the extension input.
|
|
1981
|
+
* Hide the extension input, settling its promise FAIL-CLOSED if nothing else has.
|
|
1982
|
+
*
|
|
1983
|
+
* Same defect the selector had: this used to dispose and re-focus without touching the `resolve`
|
|
1984
|
+
* captured in {@link showExtensionInput}'s closure, so `resetExtensionUI` — a session invalidate
|
|
1985
|
+
* or `/reload` — left the extension awaiting `ui.input(...)` hanging forever.
|
|
1986
|
+
*
|
|
1987
|
+
* Callers that carry a real answer must `settle(...)` it BEFORE calling this.
|
|
1799
1988
|
*/
|
|
1800
1989
|
hideExtensionInput() {
|
|
1990
|
+
const settle = this.extensionInputSettle;
|
|
1991
|
+
this.extensionInputSettle = undefined;
|
|
1801
1992
|
this.extensionInput?.dispose();
|
|
1802
1993
|
this.editorContainer.clear();
|
|
1803
1994
|
this.editorContainer.addChild(this.editor);
|
|
1804
1995
|
this.extensionInput = undefined;
|
|
1805
1996
|
this.ui.setFocus(this.editor);
|
|
1806
1997
|
this.ui.requestRender();
|
|
1998
|
+
// Last, so the caller's continuation cannot observe a half-torn-down dialog slot.
|
|
1999
|
+
settle?.(undefined);
|
|
1807
2000
|
}
|
|
1808
2001
|
/**
|
|
1809
2002
|
* Show a multi-line editor for extensions (with Ctrl+G support).
|
|
1810
2003
|
*/
|
|
1811
2004
|
showExtensionEditor(title, prefill) {
|
|
1812
2005
|
return new Promise((resolve) => {
|
|
1813
|
-
|
|
1814
|
-
|
|
2006
|
+
let settled = false;
|
|
2007
|
+
const settle = (value) => {
|
|
2008
|
+
if (settled)
|
|
2009
|
+
return;
|
|
2010
|
+
settled = true;
|
|
2011
|
+
if (this.extensionEditorSettle === settle)
|
|
2012
|
+
this.extensionEditorSettle = undefined;
|
|
1815
2013
|
resolve(value);
|
|
2014
|
+
};
|
|
2015
|
+
const displaced = this.extensionEditorSettle;
|
|
2016
|
+
this.extensionEditor = undefined;
|
|
2017
|
+
this.extensionEditorSettle = undefined;
|
|
2018
|
+
this.extensionEditor = new ExtensionEditorComponent(this.ui, this.keybindings, title, prefill,
|
|
2019
|
+
// Settle BEFORE hiding: `hideExtensionEditor` settles the slot fail-closed.
|
|
2020
|
+
(value) => {
|
|
2021
|
+
settle(value);
|
|
2022
|
+
this.hideExtensionEditor();
|
|
1816
2023
|
}, () => {
|
|
2024
|
+
settle(undefined);
|
|
1817
2025
|
this.hideExtensionEditor();
|
|
1818
|
-
resolve(undefined);
|
|
1819
2026
|
}, undefined, this.settingsManager.getExternalEditorCommand());
|
|
2027
|
+
this.extensionEditorSettle = settle;
|
|
1820
2028
|
this.editorContainer.clear();
|
|
1821
2029
|
this.editorContainer.addChild(this.extensionEditor);
|
|
1822
2030
|
this.ui.setFocus(this.extensionEditor);
|
|
1823
2031
|
this.ui.requestRender();
|
|
2032
|
+
// Only once the replacement is installed, so the displaced caller's continuation cannot
|
|
2033
|
+
// observe an empty dialog slot.
|
|
2034
|
+
displaced?.(undefined);
|
|
1824
2035
|
});
|
|
1825
2036
|
}
|
|
1826
2037
|
/**
|
|
1827
|
-
* Hide the extension editor.
|
|
2038
|
+
* Hide the extension editor, settling its promise FAIL-CLOSED if nothing else has.
|
|
2039
|
+
*
|
|
2040
|
+
* Same defect the selector had: this used to clear the container and re-focus without touching
|
|
2041
|
+
* the `resolve` captured in {@link showExtensionEditor}'s closure, so `resetExtensionUI` — a
|
|
2042
|
+
* session invalidate or `/reload` — stranded whoever was awaiting the editor forever. `/compact`
|
|
2043
|
+
* with custom instructions is one such caller.
|
|
2044
|
+
*
|
|
2045
|
+
* Callers that carry a real answer must `settle(...)` it BEFORE calling this.
|
|
1828
2046
|
*/
|
|
1829
2047
|
hideExtensionEditor() {
|
|
2048
|
+
const settle = this.extensionEditorSettle;
|
|
2049
|
+
this.extensionEditorSettle = undefined;
|
|
1830
2050
|
this.editorContainer.clear();
|
|
1831
2051
|
this.editorContainer.addChild(this.editor);
|
|
1832
2052
|
this.extensionEditor = undefined;
|
|
1833
2053
|
this.ui.setFocus(this.editor);
|
|
1834
2054
|
this.ui.requestRender();
|
|
2055
|
+
// Last, so the caller's continuation cannot observe a half-torn-down dialog slot.
|
|
2056
|
+
settle?.(undefined);
|
|
1835
2057
|
}
|
|
1836
2058
|
/**
|
|
1837
2059
|
* Set a custom editor component from an extension.
|
|
@@ -1857,6 +2079,9 @@ export class InteractiveMode {
|
|
|
1857
2079
|
if (newEditor.setPaddingX !== undefined) {
|
|
1858
2080
|
newEditor.setPaddingX(this.defaultEditor.getPaddingX());
|
|
1859
2081
|
}
|
|
2082
|
+
if (newEditor.setAutocompleteMaxVisible !== undefined) {
|
|
2083
|
+
newEditor.setAutocompleteMaxVisible(this.defaultEditor.getAutocompleteMaxVisible());
|
|
2084
|
+
}
|
|
1860
2085
|
// Set autocomplete if supported
|
|
1861
2086
|
if (newEditor.setAutocompleteProvider && this.autocompleteProvider) {
|
|
1862
2087
|
newEditor.setAutocompleteProvider(this.autocompleteProvider);
|
|
@@ -2053,6 +2278,7 @@ export class InteractiveMode {
|
|
|
2053
2278
|
this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
|
|
2054
2279
|
this.defaultEditor.onAction("app.session.new", () => this.handleClearCommand());
|
|
2055
2280
|
this.defaultEditor.onAction("app.session.tree", () => this.showTreeSelector());
|
|
2281
|
+
this.defaultEditor.onAction("app.session.rewind", () => this.showRewindSelector());
|
|
2056
2282
|
this.defaultEditor.onAction("app.session.fork", () => this.showUserMessageSelector());
|
|
2057
2283
|
this.defaultEditor.onAction("app.session.resume", () => this.showSessionSelector());
|
|
2058
2284
|
this.defaultEditor.onChange = (text) => {
|
|
@@ -2096,6 +2322,14 @@ export class InteractiveMode {
|
|
|
2096
2322
|
text = text.trim();
|
|
2097
2323
|
if (!text)
|
|
2098
2324
|
return;
|
|
2325
|
+
// A `/rewind` is rewriting the working tree right now. Anything
|
|
2326
|
+
// submitted here would run against a tree that is mid-restore, so
|
|
2327
|
+
// hold the text in the editor the way the bash guard below does.
|
|
2328
|
+
if (this.isRewindRunning) {
|
|
2329
|
+
this.showWarning("A rewind is restoring your files. Wait for it to finish.");
|
|
2330
|
+
this.editor.setText(text);
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2099
2333
|
// Handle commands
|
|
2100
2334
|
if (text === "/settings") {
|
|
2101
2335
|
this.showSettingsSelector();
|
|
@@ -2168,6 +2402,11 @@ export class InteractiveMode {
|
|
|
2168
2402
|
this.editor.setText("");
|
|
2169
2403
|
return;
|
|
2170
2404
|
}
|
|
2405
|
+
if (text === "/rewind") {
|
|
2406
|
+
this.showRewindSelector();
|
|
2407
|
+
this.editor.setText("");
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2171
2410
|
if (text === "/trust") {
|
|
2172
2411
|
this.showTrustSelector();
|
|
2173
2412
|
this.editor.setText("");
|
|
@@ -3466,6 +3705,7 @@ export class InteractiveMode {
|
|
|
3466
3705
|
outputPad: this.settingsManager.getOutputPad(),
|
|
3467
3706
|
autocompleteMaxVisible: this.settingsManager.getAutocompleteMaxVisible(),
|
|
3468
3707
|
quietStartup: this.settingsManager.getQuietStartup(),
|
|
3708
|
+
attachableSessions: this.settingsManager.getAttachableSessions(),
|
|
3469
3709
|
clearOnShrink: this.settingsManager.getClearOnShrink(),
|
|
3470
3710
|
showTerminalProgress: this.settingsManager.getShowTerminalProgress(),
|
|
3471
3711
|
warnings: this.settingsManager.getWarnings(),
|
|
@@ -3549,6 +3789,10 @@ export class InteractiveMode {
|
|
|
3549
3789
|
onQuietStartupChange: (enabled) => {
|
|
3550
3790
|
this.settingsManager.setQuietStartup(enabled);
|
|
3551
3791
|
},
|
|
3792
|
+
onAttachableSessionsChange: (enabled) => {
|
|
3793
|
+
// Takes effect on the next session start: this one already bound (or did not).
|
|
3794
|
+
this.settingsManager.setAttachableSessions(enabled);
|
|
3795
|
+
},
|
|
3552
3796
|
onDefaultProjectTrustChange: (defaultProjectTrust) => {
|
|
3553
3797
|
this.settingsManager.setDefaultProjectTrust(defaultProjectTrust);
|
|
3554
3798
|
},
|
|
@@ -3843,6 +4087,14 @@ export class InteractiveMode {
|
|
|
3843
4087
|
this.showSelector((done) => {
|
|
3844
4088
|
const selector = new UserMessageSelectorComponent(userMessages.map((m) => ({ id: m.entryId, text: m.text })), async (entryId) => {
|
|
3845
4089
|
done();
|
|
4090
|
+
// The user committed to forking: stop the active response first,
|
|
4091
|
+
// the same way /tree and /rewind do. The fork fires the
|
|
4092
|
+
// checkpoint restore offer, and that must never rewrite the
|
|
4093
|
+
// working tree while the agent is still writing to it.
|
|
4094
|
+
if (this.session.isStreaming) {
|
|
4095
|
+
this.restoreQueuedMessagesToEditor();
|
|
4096
|
+
await this.session.abort();
|
|
4097
|
+
}
|
|
3846
4098
|
try {
|
|
3847
4099
|
const result = await this.runtimeHost.fork(entryId);
|
|
3848
4100
|
if (result.cancelled) {
|
|
@@ -4000,6 +4252,124 @@ export class InteractiveMode {
|
|
|
4000
4252
|
return { component: selector, focus: selector };
|
|
4001
4253
|
});
|
|
4002
4254
|
}
|
|
4255
|
+
/** Checkpoint manager for the live session; undefined before a session file exists. */
|
|
4256
|
+
createCheckpointManager() {
|
|
4257
|
+
const sessionFile = this.sessionManager.getSessionFile();
|
|
4258
|
+
if (!sessionFile)
|
|
4259
|
+
return undefined;
|
|
4260
|
+
return new CheckpointManager({
|
|
4261
|
+
cwd: this.sessionManager.getCwd(),
|
|
4262
|
+
sessionId: this.sessionManager.getSessionId(),
|
|
4263
|
+
sessionFile,
|
|
4264
|
+
});
|
|
4265
|
+
}
|
|
4266
|
+
/**
|
|
4267
|
+
* `/rewind` (R42-RWD.1): the tree selector, restricted to entries that have a
|
|
4268
|
+
* checkpoint and annotated with its time and dirty-file count, followed by the
|
|
4269
|
+
* restore-scope menu (R42-RWD.2). Entries on abandoned branches keep their
|
|
4270
|
+
* checkpoints, so rewinding forward to one is just another selection (R42-RWD.6).
|
|
4271
|
+
*/
|
|
4272
|
+
showRewindSelector(initialSelectedId) {
|
|
4273
|
+
const tree = this.sessionManager.getTree();
|
|
4274
|
+
if (tree.length === 0) {
|
|
4275
|
+
this.showStatus("No entries in session");
|
|
4276
|
+
return;
|
|
4277
|
+
}
|
|
4278
|
+
const manager = this.createCheckpointManager();
|
|
4279
|
+
const targets = manager ? listRewindTargets(manager.list()) : [];
|
|
4280
|
+
const checkpoints = targets.length > 0
|
|
4281
|
+
? new Map(targets.map((target) => [
|
|
4282
|
+
target.entryId,
|
|
4283
|
+
{ timestamp: target.timestamp, dirtyFileCount: target.dirtyFileCount },
|
|
4284
|
+
]))
|
|
4285
|
+
: undefined;
|
|
4286
|
+
if (!checkpoints) {
|
|
4287
|
+
// No snapshots (e.g. a non-git cwd): still rewind the conversation.
|
|
4288
|
+
this.showStatus("No checkpoints recorded - /rewind will restore the conversation only");
|
|
4289
|
+
}
|
|
4290
|
+
this.showSelector((done) => {
|
|
4291
|
+
const selector = new TreeSelectorComponent(tree, this.sessionManager.getLeafId(), this.ui.terminal.rows, async (entryId) => {
|
|
4292
|
+
done();
|
|
4293
|
+
if (!checkpoints) {
|
|
4294
|
+
await this.runRewind(entryId, "conversation-only", undefined);
|
|
4295
|
+
return;
|
|
4296
|
+
}
|
|
4297
|
+
const label = await this.showExtensionSelector("Restore scope?", REWIND_SCOPE_CHOICES.map((choice) => choice.label));
|
|
4298
|
+
if (label === undefined) {
|
|
4299
|
+
// Escape returns to the selector with the same entry focused.
|
|
4300
|
+
this.showRewindSelector(entryId);
|
|
4301
|
+
return;
|
|
4302
|
+
}
|
|
4303
|
+
await this.runRewind(entryId, rewindScopeForLabel(label) ?? DEFAULT_REWIND_SCOPE, manager);
|
|
4304
|
+
}, () => {
|
|
4305
|
+
done();
|
|
4306
|
+
this.ui.requestRender();
|
|
4307
|
+
}, undefined, initialSelectedId, undefined, { title: "Rewind", checkpoints });
|
|
4308
|
+
return { component: selector, focus: selector };
|
|
4309
|
+
});
|
|
4310
|
+
}
|
|
4311
|
+
/**
|
|
4312
|
+
* Run the rewind under the chosen scope. The conversation leaf is moved by
|
|
4313
|
+
* `performRewind` through this navigate callback, which it only invokes once
|
|
4314
|
+
* the file restore has succeeded (R42-RWD.5).
|
|
4315
|
+
*/
|
|
4316
|
+
async runRewind(targetEntryId, scope, manager) {
|
|
4317
|
+
const currentEntryId = this.sessionManager.getLeafId();
|
|
4318
|
+
if (!currentEntryId) {
|
|
4319
|
+
this.showStatus("Nothing to rewind yet");
|
|
4320
|
+
return;
|
|
4321
|
+
}
|
|
4322
|
+
if (targetEntryId === currentEntryId && scope === "conversation-only") {
|
|
4323
|
+
this.showStatus("Already at this point");
|
|
4324
|
+
return;
|
|
4325
|
+
}
|
|
4326
|
+
// The user committed to rewinding: stop the active response first.
|
|
4327
|
+
if (this.session.isStreaming) {
|
|
4328
|
+
this.restoreQueuedMessagesToEditor();
|
|
4329
|
+
await this.session.abort();
|
|
4330
|
+
}
|
|
4331
|
+
// The selector already called `done()`, so the editor has focus again
|
|
4332
|
+
// while this runs. Block submissions until the restore is finished
|
|
4333
|
+
// rather than let a new prompt race the file writes.
|
|
4334
|
+
this.isRewindRunning = true;
|
|
4335
|
+
let result;
|
|
4336
|
+
try {
|
|
4337
|
+
result = await performRewind({
|
|
4338
|
+
manager,
|
|
4339
|
+
scope,
|
|
4340
|
+
// Scopes the in-progress gate to this session (R35-ALWAYS.5).
|
|
4341
|
+
// Read at call time so it follows a session replacement.
|
|
4342
|
+
sessionId: this.sessionManager.getSessionId(),
|
|
4343
|
+
targetEntryId,
|
|
4344
|
+
currentEntryId,
|
|
4345
|
+
// Gives extensions the `session_before_rewind` veto (R42-RWD.8).
|
|
4346
|
+
runner: this.session.extensionRunner,
|
|
4347
|
+
navigate: async () => {
|
|
4348
|
+
if (targetEntryId === currentEntryId)
|
|
4349
|
+
return;
|
|
4350
|
+
const navigation = await this.session.navigateTree(targetEntryId, { summarize: false });
|
|
4351
|
+
if (navigation.cancelled)
|
|
4352
|
+
throw new Error("navigation cancelled");
|
|
4353
|
+
this.chatContainer.clear();
|
|
4354
|
+
this.renderInitialMessages();
|
|
4355
|
+
if (navigation.editorText && !this.editor.getText().trim()) {
|
|
4356
|
+
this.editor.setText(navigation.editorText);
|
|
4357
|
+
}
|
|
4358
|
+
void this.flushCompactionQueue({ willRetry: false });
|
|
4359
|
+
},
|
|
4360
|
+
});
|
|
4361
|
+
}
|
|
4362
|
+
finally {
|
|
4363
|
+
this.isRewindRunning = false;
|
|
4364
|
+
}
|
|
4365
|
+
if (result.ok) {
|
|
4366
|
+
this.showStatus(result.message);
|
|
4367
|
+
}
|
|
4368
|
+
else {
|
|
4369
|
+
this.showError(result.message);
|
|
4370
|
+
}
|
|
4371
|
+
this.ui.requestRender();
|
|
4372
|
+
}
|
|
4003
4373
|
showSessionSelector() {
|
|
4004
4374
|
this.showSelector((done) => {
|
|
4005
4375
|
const selector = new SessionSelectorComponent((onProgress) => SessionManager.list(this.sessionManager.getCwd(), this.sessionManager.getSessionDir(), onProgress), (onProgress) => this.sessionManager.usesDefaultSessionDir()
|