@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
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { Text } from "@draht/tui";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { parseModelPattern } from "../model-resolver.js";
|
|
4
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "../tools/truncate.js";
|
|
5
|
+
import { runParallelTasks } from "./subagent.js";
|
|
6
|
+
const DUET_STATE_ENTRY = "duet-state";
|
|
7
|
+
const DUET_DELEGATE_TOOL = "duet_delegate";
|
|
8
|
+
const MAX_DUET_PARTICIPANTS = 8;
|
|
9
|
+
const READ_ONLY_TEAMMATE_TOOLS = ["read", "grep", "find", "ls"];
|
|
10
|
+
const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
11
|
+
function isThinkingLevel(value) {
|
|
12
|
+
return typeof value === "string" && THINKING_LEVELS.includes(value);
|
|
13
|
+
}
|
|
14
|
+
function isDuetStrategy(value) {
|
|
15
|
+
return value === "turns" || value === "triage";
|
|
16
|
+
}
|
|
17
|
+
function modelKey(model) {
|
|
18
|
+
return `${model.provider}/${model.id}`;
|
|
19
|
+
}
|
|
20
|
+
function sanitizeRole(value) {
|
|
21
|
+
let role = value
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.replace(/[^a-z0-9_-]+/g, "-")
|
|
24
|
+
.replace(/^-+|-+$/g, "");
|
|
25
|
+
if (!role)
|
|
26
|
+
return "teammate";
|
|
27
|
+
if (!/^[a-z]/.test(role))
|
|
28
|
+
role = `model-${role}`;
|
|
29
|
+
return role.slice(0, 42);
|
|
30
|
+
}
|
|
31
|
+
function validateExplicitRole(role) {
|
|
32
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,47}$/.test(role)) {
|
|
33
|
+
throw new Error(`Invalid duet role "${role}". Use 1-48 letters, numbers, underscores, or hyphens.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function uniqueDefaultRole(model, usedRoles) {
|
|
37
|
+
const shortRole = sanitizeRole(model.id.split("/").pop() ?? model.id);
|
|
38
|
+
if (!usedRoles.has(shortRole))
|
|
39
|
+
return shortRole;
|
|
40
|
+
const providerRole = sanitizeRole(`${model.provider}-${model.id}`);
|
|
41
|
+
if (!usedRoles.has(providerRole))
|
|
42
|
+
return providerRole;
|
|
43
|
+
let suffix = 2;
|
|
44
|
+
while (true) {
|
|
45
|
+
const suffixText = `-${suffix}`;
|
|
46
|
+
const candidate = `${providerRole.slice(0, 48 - suffixText.length)}${suffixText}`;
|
|
47
|
+
if (!usedRoles.has(candidate))
|
|
48
|
+
return candidate;
|
|
49
|
+
suffix++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Resolve comma-separated `[role=]provider/model[:thinking]` participant specifications. */
|
|
53
|
+
export function parseDuetParticipantSpecs(specs, availableModels) {
|
|
54
|
+
const rawSpecs = specs
|
|
55
|
+
.split(",")
|
|
56
|
+
.map((spec) => spec.trim())
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
if (rawSpecs.length < 2)
|
|
59
|
+
throw new Error("Duet mode requires at least two models.");
|
|
60
|
+
if (rawSpecs.length > MAX_DUET_PARTICIPANTS) {
|
|
61
|
+
throw new Error(`Duet mode supports at most ${MAX_DUET_PARTICIPANTS} models.`);
|
|
62
|
+
}
|
|
63
|
+
const participants = [];
|
|
64
|
+
const usedModels = new Set();
|
|
65
|
+
const usedRoles = new Set();
|
|
66
|
+
for (const rawSpec of rawSpecs) {
|
|
67
|
+
const equalsIndex = rawSpec.indexOf("=");
|
|
68
|
+
const explicitRole = equalsIndex === -1 ? undefined : rawSpec.slice(0, equalsIndex).trim();
|
|
69
|
+
const modelSpec = equalsIndex === -1 ? rawSpec : rawSpec.slice(equalsIndex + 1).trim();
|
|
70
|
+
if (explicitRole !== undefined)
|
|
71
|
+
validateExplicitRole(explicitRole);
|
|
72
|
+
if (!modelSpec)
|
|
73
|
+
throw new Error(`Missing model in duet participant "${rawSpec}".`);
|
|
74
|
+
const resolved = parseModelPattern(modelSpec, availableModels, {
|
|
75
|
+
allowInvalidThinkingLevelFallback: false,
|
|
76
|
+
});
|
|
77
|
+
if (!resolved.model) {
|
|
78
|
+
throw new Error(`Duet model "${modelSpec}" is unavailable. Authenticate it or use /scoped-models.`);
|
|
79
|
+
}
|
|
80
|
+
const key = modelKey(resolved.model);
|
|
81
|
+
if (usedModels.has(key))
|
|
82
|
+
throw new Error(`Duet model "${key}" was selected more than once.`);
|
|
83
|
+
const role = explicitRole || uniqueDefaultRole(resolved.model, usedRoles);
|
|
84
|
+
if (usedRoles.has(role))
|
|
85
|
+
throw new Error(`Duet role "${role}" was selected more than once.`);
|
|
86
|
+
usedModels.add(key);
|
|
87
|
+
usedRoles.add(role);
|
|
88
|
+
participants.push({
|
|
89
|
+
role,
|
|
90
|
+
model: resolved.model,
|
|
91
|
+
modelRef: key,
|
|
92
|
+
thinkingLevel: resolved.thinkingLevel,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return participants;
|
|
96
|
+
}
|
|
97
|
+
export function advanceDuetTurn(state) {
|
|
98
|
+
const index = ((state.nextIndex % state.participants.length) + state.participants.length) % state.participants.length;
|
|
99
|
+
const participant = state.participants[index];
|
|
100
|
+
state.nextIndex = (index + 1) % state.participants.length;
|
|
101
|
+
return participant;
|
|
102
|
+
}
|
|
103
|
+
function participantsFromScopedModels(ctx) {
|
|
104
|
+
if (ctx.scopedModels.length < 2) {
|
|
105
|
+
throw new Error("Pass models to /duet or configure at least two models with /scoped-models.");
|
|
106
|
+
}
|
|
107
|
+
const specs = ctx.scopedModels
|
|
108
|
+
.map(({ model, thinkingLevel }) => `${modelKey(model)}${thinkingLevel ? `:${thinkingLevel}` : ""}`)
|
|
109
|
+
.join(",");
|
|
110
|
+
return parseDuetParticipantSpecs(specs, ctx.modelRegistry.getAvailable());
|
|
111
|
+
}
|
|
112
|
+
function toPersistedState(state) {
|
|
113
|
+
if (!state)
|
|
114
|
+
return { version: 1, enabled: false };
|
|
115
|
+
return {
|
|
116
|
+
version: 1,
|
|
117
|
+
enabled: true,
|
|
118
|
+
strategy: state.strategy,
|
|
119
|
+
participants: state.participants.map(({ role, modelRef, thinkingLevel }) => ({
|
|
120
|
+
role,
|
|
121
|
+
modelRef,
|
|
122
|
+
thinkingLevel,
|
|
123
|
+
})),
|
|
124
|
+
nextIndex: state.nextIndex,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function isPersistedParticipant(value) {
|
|
128
|
+
if (typeof value !== "object" || value === null)
|
|
129
|
+
return false;
|
|
130
|
+
const participant = value;
|
|
131
|
+
return (typeof participant.role === "string" &&
|
|
132
|
+
typeof participant.modelRef === "string" &&
|
|
133
|
+
(participant.thinkingLevel === undefined || isThinkingLevel(participant.thinkingLevel)));
|
|
134
|
+
}
|
|
135
|
+
function isPersistedState(value) {
|
|
136
|
+
if (typeof value !== "object" || value === null)
|
|
137
|
+
return false;
|
|
138
|
+
const state = value;
|
|
139
|
+
if (state.version !== 1 || typeof state.enabled !== "boolean")
|
|
140
|
+
return false;
|
|
141
|
+
if (!state.enabled)
|
|
142
|
+
return true;
|
|
143
|
+
return (isDuetStrategy(state.strategy) &&
|
|
144
|
+
Array.isArray(state.participants) &&
|
|
145
|
+
state.participants.every(isPersistedParticipant) &&
|
|
146
|
+
(state.nextIndex === undefined || (typeof state.nextIndex === "number" && Number.isInteger(state.nextIndex))));
|
|
147
|
+
}
|
|
148
|
+
function restoreState(value, availableModels) {
|
|
149
|
+
if (!value.enabled || !value.strategy || !value.participants)
|
|
150
|
+
return undefined;
|
|
151
|
+
const specs = value.participants
|
|
152
|
+
.map(({ role, modelRef, thinkingLevel }) => `${role}=${modelRef}${thinkingLevel ? `:${thinkingLevel}` : ""}`)
|
|
153
|
+
.join(",");
|
|
154
|
+
const participants = parseDuetParticipantSpecs(specs, availableModels);
|
|
155
|
+
return {
|
|
156
|
+
strategy: value.strategy,
|
|
157
|
+
participants,
|
|
158
|
+
nextIndex: Math.max(0, value.nextIndex ?? 0) % participants.length,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export function restoreDuetTurnFromBranch(state, branch) {
|
|
162
|
+
if (state.strategy !== "turns")
|
|
163
|
+
return;
|
|
164
|
+
let stateEntryIndex = -1;
|
|
165
|
+
for (let index = branch.length - 1; index >= 0; index--) {
|
|
166
|
+
const entry = branch[index];
|
|
167
|
+
if (entry.type === "custom" && entry.customType === DUET_STATE_ENTRY) {
|
|
168
|
+
stateEntryIndex = index;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
for (let index = branch.length - 1; index > stateEntryIndex; index--) {
|
|
173
|
+
const entry = branch[index];
|
|
174
|
+
if (entry.type !== "message")
|
|
175
|
+
continue;
|
|
176
|
+
const message = entry.message;
|
|
177
|
+
if (message.role !== "assistant")
|
|
178
|
+
continue;
|
|
179
|
+
const participantIndex = state.participants.findIndex((participant) => participant.model.provider === message.provider && participant.model.id === message.model);
|
|
180
|
+
if (participantIndex !== -1)
|
|
181
|
+
state.nextIndex = (participantIndex + 1) % state.participants.length;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function formatParticipant(participant) {
|
|
186
|
+
return `${participant.role}=${participant.modelRef}${participant.thinkingLevel ? `:${participant.thinkingLevel}` : ""}`;
|
|
187
|
+
}
|
|
188
|
+
export function buildDuetSystemPrompt(state, activeParticipant) {
|
|
189
|
+
if (state.strategy === "turns") {
|
|
190
|
+
const participant = activeParticipant ?? state.participants[0];
|
|
191
|
+
return [
|
|
192
|
+
"You are working in Draht duet turn-taking mode.",
|
|
193
|
+
`Your role for this turn is "${participant.role}" using ${participant.modelRef}.`,
|
|
194
|
+
"Other duet models share this same persisted conversation, tool history, and working tree.",
|
|
195
|
+
"Build on their work, state disagreements directly, and leave the session in a useful state for the next model.",
|
|
196
|
+
].join("\n");
|
|
197
|
+
}
|
|
198
|
+
const lead = state.participants[0];
|
|
199
|
+
const teammates = state.participants.slice(1).map(formatParticipant).join(", ");
|
|
200
|
+
return [
|
|
201
|
+
"You are the lead in Draht duet triage mode.",
|
|
202
|
+
`Lead role: ${formatParticipant(lead)}. Read-only teammates: ${teammates}.`,
|
|
203
|
+
"For non-trivial requests, triage the work into independent investigations and use duet_delegate once to run useful assignments in parallel.",
|
|
204
|
+
"Assignments must be self-contained and should request evidence, file paths, risks, or recommendations rather than edits.",
|
|
205
|
+
"Teammates cannot modify files. Synthesize their results, resolve disagreements, and perform all edits and commands in the shared session yourself.",
|
|
206
|
+
"Skip delegation for trivial work where it would only add latency or cost.",
|
|
207
|
+
].join("\n");
|
|
208
|
+
}
|
|
209
|
+
export function createDuetTeammateAgent(participant) {
|
|
210
|
+
return {
|
|
211
|
+
name: participant.role,
|
|
212
|
+
description: `Read-only duet teammate using ${participant.modelRef}`,
|
|
213
|
+
model: `${participant.modelRef}${participant.thinkingLevel ? `:${participant.thinkingLevel}` : ""}`,
|
|
214
|
+
tools: [...READ_ONLY_TEAMMATE_TOOLS],
|
|
215
|
+
disableExtensions: true,
|
|
216
|
+
source: "user",
|
|
217
|
+
systemPrompt: [
|
|
218
|
+
`You are "${participant.role}", a read-only teammate in a Draht duet session.`,
|
|
219
|
+
"Investigate only the assignment from the lead. Use read-only tools as needed.",
|
|
220
|
+
"Do not modify files and do not ask the user questions.",
|
|
221
|
+
"Return concise findings with evidence, file paths, risks, and a concrete recommendation for the lead.",
|
|
222
|
+
].join("\n"),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export function combineDuetUsage(results) {
|
|
226
|
+
const usages = results.map((result) => result.usage).filter((usage) => usage !== undefined);
|
|
227
|
+
if (usages.length === 0)
|
|
228
|
+
return undefined;
|
|
229
|
+
return usages.reduce((total, usage) => ({
|
|
230
|
+
input: total.input + usage.input,
|
|
231
|
+
output: total.output + usage.output,
|
|
232
|
+
cacheRead: total.cacheRead + usage.cacheRead,
|
|
233
|
+
cacheWrite: total.cacheWrite + usage.cacheWrite,
|
|
234
|
+
...(total.cacheWrite1h !== undefined || usage.cacheWrite1h !== undefined
|
|
235
|
+
? { cacheWrite1h: (total.cacheWrite1h ?? 0) + (usage.cacheWrite1h ?? 0) }
|
|
236
|
+
: {}),
|
|
237
|
+
...(total.reasoning !== undefined || usage.reasoning !== undefined
|
|
238
|
+
? { reasoning: (total.reasoning ?? 0) + (usage.reasoning ?? 0) }
|
|
239
|
+
: {}),
|
|
240
|
+
totalTokens: total.totalTokens + usage.totalTokens,
|
|
241
|
+
cost: {
|
|
242
|
+
input: total.cost.input + usage.cost.input,
|
|
243
|
+
output: total.cost.output + usage.cost.output,
|
|
244
|
+
cacheRead: total.cost.cacheRead + usage.cost.cacheRead,
|
|
245
|
+
cacheWrite: total.cost.cacheWrite + usage.cost.cacheWrite,
|
|
246
|
+
total: total.cost.total + usage.cost.total,
|
|
247
|
+
},
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
function truncateParticipantOutput(output) {
|
|
251
|
+
const truncated = truncateHead(output, {
|
|
252
|
+
maxBytes: Math.floor(DEFAULT_MAX_BYTES / 2),
|
|
253
|
+
maxLines: Math.floor(DEFAULT_MAX_LINES / 2),
|
|
254
|
+
});
|
|
255
|
+
if (!truncated.truncated)
|
|
256
|
+
return output;
|
|
257
|
+
return `${truncated.content}\n\n[Participant output truncated: showing ${formatSize(truncated.outputBytes)} of ${formatSize(truncated.totalBytes)}.]`;
|
|
258
|
+
}
|
|
259
|
+
function formatDelegateResults(results) {
|
|
260
|
+
const successful = results.filter((result) => result.exitCode === 0).length;
|
|
261
|
+
const sections = results.map((result) => {
|
|
262
|
+
const status = result.exitCode === 0 ? "completed" : "failed";
|
|
263
|
+
const output = truncateParticipantOutput(result.output || result.stderr || "(no output)");
|
|
264
|
+
return `## ${result.agent} (${status})\n\n${output}`;
|
|
265
|
+
});
|
|
266
|
+
const fullOutput = `Duet delegation: ${successful}/${results.length} completed\n\n${sections.join("\n\n---\n\n")}`;
|
|
267
|
+
const truncated = truncateHead(fullOutput, { maxBytes: DEFAULT_MAX_BYTES, maxLines: DEFAULT_MAX_LINES });
|
|
268
|
+
if (!truncated.truncated)
|
|
269
|
+
return fullOutput;
|
|
270
|
+
return `${truncated.content}\n\n[Duet output truncated: showing ${formatSize(truncated.outputBytes)} of ${formatSize(truncated.totalBytes)}.]`;
|
|
271
|
+
}
|
|
272
|
+
const DuetAssignment = Type.Object({
|
|
273
|
+
participant: Type.String({ description: "Configured teammate role to receive this assignment" }),
|
|
274
|
+
task: Type.String({ description: "Self-contained read-only investigation for the teammate" }),
|
|
275
|
+
});
|
|
276
|
+
const DuetDelegateParams = Type.Object({
|
|
277
|
+
assignments: Type.Array(DuetAssignment, {
|
|
278
|
+
description: "Independent assignments to run concurrently, at most one per teammate",
|
|
279
|
+
minItems: 1,
|
|
280
|
+
maxItems: MAX_DUET_PARTICIPANTS - 1,
|
|
281
|
+
}),
|
|
282
|
+
});
|
|
283
|
+
export default function duetBuiltin(pi) {
|
|
284
|
+
let state;
|
|
285
|
+
let activeTurnParticipant;
|
|
286
|
+
let pendingTurnParticipant;
|
|
287
|
+
let runningTurnParticipant;
|
|
288
|
+
let delegatedForPrompt = false;
|
|
289
|
+
let selectingParticipant = false;
|
|
290
|
+
pi.registerFlag("duet", {
|
|
291
|
+
description: "Comma-separated duet models: [role=]provider/model[:thinking]",
|
|
292
|
+
type: "string",
|
|
293
|
+
});
|
|
294
|
+
pi.registerFlag("duet-strategy", {
|
|
295
|
+
description: "Duet strategy: turns or triage",
|
|
296
|
+
type: "string",
|
|
297
|
+
default: "triage",
|
|
298
|
+
});
|
|
299
|
+
function persistState() {
|
|
300
|
+
pi.appendEntry(DUET_STATE_ENTRY, toPersistedState(state));
|
|
301
|
+
}
|
|
302
|
+
function setDelegateToolActive(active) {
|
|
303
|
+
if (active && !registerDuetDelegateTool())
|
|
304
|
+
return false;
|
|
305
|
+
if (!active && !duetDelegateToolRegistered)
|
|
306
|
+
return true;
|
|
307
|
+
const names = pi.getActiveTools().filter((name) => name !== DUET_DELEGATE_TOOL);
|
|
308
|
+
if (active)
|
|
309
|
+
names.push(DUET_DELEGATE_TOOL);
|
|
310
|
+
pi.setActiveTools(names);
|
|
311
|
+
return pi.getActiveTools().includes(DUET_DELEGATE_TOOL) === active;
|
|
312
|
+
}
|
|
313
|
+
function updateStatus(ctx) {
|
|
314
|
+
if (!state) {
|
|
315
|
+
ctx.ui.setStatus("duet", undefined);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const role = state.strategy === "triage" ? state.participants[0].role : activeTurnParticipant?.role;
|
|
319
|
+
ctx.ui.setStatus("duet", `duet:${state.strategy}${role ? ` ${role}` : ""}`);
|
|
320
|
+
}
|
|
321
|
+
async function setParticipantModel(participant, ctx) {
|
|
322
|
+
selectingParticipant = true;
|
|
323
|
+
try {
|
|
324
|
+
if (!ctx.model || modelKey(ctx.model) !== participant.modelRef) {
|
|
325
|
+
const selected = await pi.setModel(participant.model, { persistDefault: false });
|
|
326
|
+
if (!selected) {
|
|
327
|
+
ctx.ui.notify(`No authentication available for ${participant.modelRef}`, "error");
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (participant.thinkingLevel && ctx.thinkingLevel !== participant.thinkingLevel) {
|
|
332
|
+
pi.setThinkingLevel(participant.thinkingLevel, { persistDefault: false });
|
|
333
|
+
}
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
ctx.ui.notify(`Could not select duet participant ${participant.role}: ${error instanceof Error ? error.message : String(error)}`, "error");
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
finally {
|
|
341
|
+
selectingParticipant = false;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async function enableDuet(strategy, participants, ctx, persist) {
|
|
345
|
+
if (!ctx.isIdle()) {
|
|
346
|
+
ctx.ui.notify("Wait for the active response to finish before changing duet mode.", "warning");
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
const previousState = state;
|
|
350
|
+
const previousActiveParticipant = activeTurnParticipant;
|
|
351
|
+
state = { strategy, participants, nextIndex: 0 };
|
|
352
|
+
activeTurnParticipant =
|
|
353
|
+
strategy === "triage"
|
|
354
|
+
? participants[0]
|
|
355
|
+
: participants.find((participant) => participant.modelRef === (ctx.model ? modelKey(ctx.model) : undefined));
|
|
356
|
+
pendingTurnParticipant = undefined;
|
|
357
|
+
runningTurnParticipant = undefined;
|
|
358
|
+
if (strategy === "triage") {
|
|
359
|
+
const extensionProviders = new Set(ctx.modelRegistry.getRegisteredProviderIds());
|
|
360
|
+
const unsupported = participants
|
|
361
|
+
.slice(1)
|
|
362
|
+
.filter((participant) => extensionProviders.has(participant.model.provider));
|
|
363
|
+
if (unsupported.length > 0) {
|
|
364
|
+
state = previousState;
|
|
365
|
+
activeTurnParticipant = previousActiveParticipant;
|
|
366
|
+
ctx.ui.notify(`Duet teammates cannot use extension-provided models because teammate extensions are disabled: ${unsupported.map(formatParticipant).join(", ")}`, "error");
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!setDelegateToolActive(strategy === "triage")) {
|
|
371
|
+
state = previousState;
|
|
372
|
+
activeTurnParticipant = previousActiveParticipant;
|
|
373
|
+
ctx.ui.notify(`Cannot enable duet triage because ${DUET_DELEGATE_TOOL} is excluded by the active tool configuration.`, "error");
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
if (strategy === "triage" && !(await setParticipantModel(participants[0], ctx))) {
|
|
377
|
+
state = previousState;
|
|
378
|
+
activeTurnParticipant = previousActiveParticipant;
|
|
379
|
+
setDelegateToolActive(previousState?.strategy === "triage");
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
if (persist)
|
|
383
|
+
persistState();
|
|
384
|
+
updateStatus(ctx);
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
function disableDuet(ctx, persist) {
|
|
388
|
+
if (persist && !ctx.isIdle()) {
|
|
389
|
+
ctx.ui.notify("Wait for the active response to finish before changing duet mode.", "warning");
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
state = undefined;
|
|
393
|
+
activeTurnParticipant = undefined;
|
|
394
|
+
pendingTurnParticipant = undefined;
|
|
395
|
+
runningTurnParticipant = undefined;
|
|
396
|
+
delegatedForPrompt = false;
|
|
397
|
+
setDelegateToolActive(false);
|
|
398
|
+
if (persist)
|
|
399
|
+
persistState();
|
|
400
|
+
updateStatus(ctx);
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
async function restoreDuetFromBranch(ctx) {
|
|
404
|
+
disableDuet(ctx, false);
|
|
405
|
+
const entry = [...ctx.sessionManager.getBranch()]
|
|
406
|
+
.reverse()
|
|
407
|
+
.find((candidate) => candidate.type === "custom" && candidate.customType === DUET_STATE_ENTRY);
|
|
408
|
+
if (!entry || entry.type !== "custom" || !isPersistedState(entry.data) || !entry.data.enabled)
|
|
409
|
+
return;
|
|
410
|
+
try {
|
|
411
|
+
const restored = restoreState(entry.data, ctx.modelRegistry.getAvailable());
|
|
412
|
+
if (restored && (await enableDuet(restored.strategy, restored.participants, ctx, false))) {
|
|
413
|
+
restoreDuetTurnFromBranch(restored, ctx.sessionManager.getBranch());
|
|
414
|
+
state = restored;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
disableDuet(ctx, false);
|
|
419
|
+
ctx.ui.notify(`Could not restore duet mode: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
let duetDelegateToolRegistered = false;
|
|
423
|
+
function registerDuetDelegateTool() {
|
|
424
|
+
if (duetDelegateToolRegistered)
|
|
425
|
+
return true;
|
|
426
|
+
if (pi.getAllTools().some((tool) => tool.name === DUET_DELEGATE_TOOL))
|
|
427
|
+
return false;
|
|
428
|
+
pi.registerTool({
|
|
429
|
+
name: DUET_DELEGATE_TOOL,
|
|
430
|
+
label: "Duet Delegate",
|
|
431
|
+
description: "Delegate independent, read-only investigations to configured duet teammates in parallel. Available only in duet triage mode.",
|
|
432
|
+
parameters: DuetDelegateParams,
|
|
433
|
+
renderCall(args, theme) {
|
|
434
|
+
const lines = [theme.fg("toolTitle", theme.bold(`duet delegate (${args.assignments.length})`))];
|
|
435
|
+
for (const assignment of args.assignments) {
|
|
436
|
+
lines.push(` ${theme.fg("accent", assignment.participant)} ${theme.fg("toolOutput", assignment.task)}`);
|
|
437
|
+
}
|
|
438
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
439
|
+
},
|
|
440
|
+
renderResult(result, options, theme) {
|
|
441
|
+
const details = result.details;
|
|
442
|
+
const text = result.content
|
|
443
|
+
.filter((part) => part.type === "text")
|
|
444
|
+
.map((part) => part.text)
|
|
445
|
+
.join("\n");
|
|
446
|
+
if (options.isPartial && details?.status)
|
|
447
|
+
return new Text(theme.fg("muted", details.status), 0, 0);
|
|
448
|
+
const lines = text.split("\n");
|
|
449
|
+
const visible = options.expanded ? lines : lines.slice(0, 10);
|
|
450
|
+
if (!options.expanded && lines.length > visible.length)
|
|
451
|
+
visible.push(`... (${lines.length - visible.length} more lines)`);
|
|
452
|
+
return new Text(theme.fg("toolOutput", visible.join("\n")), 0, 0);
|
|
453
|
+
},
|
|
454
|
+
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
455
|
+
if (!state || state.strategy !== "triage") {
|
|
456
|
+
return {
|
|
457
|
+
content: [
|
|
458
|
+
{ type: "text", text: "Duet triage mode is not enabled. Use /duet triage first." },
|
|
459
|
+
],
|
|
460
|
+
details: { results: [] },
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
if (delegatedForPrompt) {
|
|
464
|
+
return {
|
|
465
|
+
content: [
|
|
466
|
+
{
|
|
467
|
+
type: "text",
|
|
468
|
+
text: "Duet delegation already ran for this user prompt. Synthesize the existing teammate results.",
|
|
469
|
+
},
|
|
470
|
+
],
|
|
471
|
+
details: { results: [] },
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const teammates = new Map(state.participants.slice(1).map((participant) => [participant.role, participant]));
|
|
475
|
+
const assignedRoles = new Set();
|
|
476
|
+
const items = [];
|
|
477
|
+
for (const assignment of params.assignments) {
|
|
478
|
+
const participant = teammates.get(assignment.participant);
|
|
479
|
+
if (!participant) {
|
|
480
|
+
return {
|
|
481
|
+
content: [
|
|
482
|
+
{
|
|
483
|
+
type: "text",
|
|
484
|
+
text: `Unknown duet teammate "${assignment.participant}". Available: ${[...teammates.keys()].join(", ")}`,
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
details: { results: [] },
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
if (assignedRoles.has(participant.role)) {
|
|
491
|
+
return {
|
|
492
|
+
content: [
|
|
493
|
+
{
|
|
494
|
+
type: "text",
|
|
495
|
+
text: `Participant "${participant.role}" can receive only one assignment per delegation.`,
|
|
496
|
+
},
|
|
497
|
+
],
|
|
498
|
+
details: { results: [] },
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
assignedRoles.add(participant.role);
|
|
502
|
+
items.push({ agent: createDuetTeammateAgent(participant), task: assignment.task });
|
|
503
|
+
}
|
|
504
|
+
delegatedForPrompt = true;
|
|
505
|
+
const activity = new Map();
|
|
506
|
+
const results = await runParallelTasks(ctx.cwd, items, {
|
|
507
|
+
signal,
|
|
508
|
+
makeOnProgress: (role) => (message) => {
|
|
509
|
+
activity.set(role, message);
|
|
510
|
+
onUpdate?.({
|
|
511
|
+
content: [
|
|
512
|
+
{
|
|
513
|
+
type: "text",
|
|
514
|
+
text: [...activity].map(([name, text]) => `${name}: ${text}`).join("\n"),
|
|
515
|
+
},
|
|
516
|
+
],
|
|
517
|
+
details: {
|
|
518
|
+
results: [],
|
|
519
|
+
status: `${activity.size}/${items.length} teammates active`,
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
return {
|
|
525
|
+
content: [{ type: "text", text: formatDelegateResults(results) }],
|
|
526
|
+
usage: combineDuetUsage(results),
|
|
527
|
+
details: {
|
|
528
|
+
results: results.map((result) => ({ participant: result.agent, exitCode: result.exitCode })),
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
duetDelegateToolRegistered = true;
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
pi.registerCommand("duet", {
|
|
537
|
+
description: "Configure multi-model collaboration. Usage: /duet [turns|triage] [[role=]model,...] | off | status",
|
|
538
|
+
handler: async (args, ctx) => {
|
|
539
|
+
const trimmed = args.trim();
|
|
540
|
+
if (!trimmed || trimmed === "status") {
|
|
541
|
+
if (!state) {
|
|
542
|
+
ctx.ui.notify("Duet mode is off.", "info");
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
ctx.ui.notify(`Duet ${state.strategy}: ${state.participants.map(formatParticipant).join(", ")}`, "info");
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
if (["off", "none", "clear"].includes(trimmed)) {
|
|
549
|
+
if (disableDuet(ctx, true))
|
|
550
|
+
ctx.ui.notify("Duet mode disabled.", "info");
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
const firstSpace = trimmed.indexOf(" ");
|
|
554
|
+
const strategyText = firstSpace === -1 ? trimmed : trimmed.slice(0, firstSpace);
|
|
555
|
+
if (!isDuetStrategy(strategyText)) {
|
|
556
|
+
ctx.ui.notify("Usage: /duet [turns|triage] [[role=]provider/model,...] | off | status", "error");
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
try {
|
|
560
|
+
const specs = firstSpace === -1 ? "" : trimmed.slice(firstSpace + 1).trim();
|
|
561
|
+
const participants = specs
|
|
562
|
+
? parseDuetParticipantSpecs(specs, ctx.modelRegistry.getAvailable())
|
|
563
|
+
: participantsFromScopedModels(ctx);
|
|
564
|
+
if (await enableDuet(strategyText, participants, ctx, true)) {
|
|
565
|
+
ctx.ui.notify(`Duet ${strategyText} enabled: ${participants.map(formatParticipant).join(", ")}`, "info");
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
catch (error) {
|
|
569
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
getArgumentCompletions: (partial) => {
|
|
573
|
+
const options = ["status", "off", "turns", "triage"];
|
|
574
|
+
return options
|
|
575
|
+
.filter((option) => option.startsWith(partial))
|
|
576
|
+
.map((option) => ({ value: option, label: option }));
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
580
|
+
disableDuet(ctx, false);
|
|
581
|
+
const duetFlag = pi.getFlag("duet");
|
|
582
|
+
const strategyFlag = pi.getFlag("duet-strategy");
|
|
583
|
+
if (typeof duetFlag === "string" && duetFlag.trim()) {
|
|
584
|
+
if (!isDuetStrategy(strategyFlag)) {
|
|
585
|
+
ctx.ui.notify(`Invalid --duet-strategy "${String(strategyFlag)}". Use turns or triage.`, "error");
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
try {
|
|
589
|
+
const participants = parseDuetParticipantSpecs(duetFlag, ctx.modelRegistry.getAvailable());
|
|
590
|
+
await enableDuet(strategyFlag, participants, ctx, true);
|
|
591
|
+
}
|
|
592
|
+
catch (error) {
|
|
593
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
594
|
+
}
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
await restoreDuetFromBranch(ctx);
|
|
598
|
+
});
|
|
599
|
+
pi.on("session_tree", async (_event, ctx) => restoreDuetFromBranch(ctx));
|
|
600
|
+
pi.on("input", async (event, ctx) => {
|
|
601
|
+
if (!state || !ctx.isIdle() || event.text.startsWith("!"))
|
|
602
|
+
return { action: "continue" };
|
|
603
|
+
const participant = state.strategy === "triage" ? state.participants[0] : state.participants[state.nextIndex];
|
|
604
|
+
if (!(await setParticipantModel(participant, ctx)))
|
|
605
|
+
return { action: "handled" };
|
|
606
|
+
activeTurnParticipant = participant;
|
|
607
|
+
pendingTurnParticipant = state.strategy === "turns" ? participant : undefined;
|
|
608
|
+
updateStatus(ctx);
|
|
609
|
+
return { action: "continue" };
|
|
610
|
+
});
|
|
611
|
+
pi.on("agent_start", (_event, ctx) => {
|
|
612
|
+
if (!state || state.strategy !== "turns" || !pendingTurnParticipant)
|
|
613
|
+
return;
|
|
614
|
+
runningTurnParticipant = pendingTurnParticipant;
|
|
615
|
+
activeTurnParticipant = pendingTurnParticipant;
|
|
616
|
+
pendingTurnParticipant = undefined;
|
|
617
|
+
updateStatus(ctx);
|
|
618
|
+
});
|
|
619
|
+
pi.on("agent_settled", (_event, ctx) => {
|
|
620
|
+
if (!state || state.strategy !== "turns" || !runningTurnParticipant)
|
|
621
|
+
return;
|
|
622
|
+
const participantIndex = state.participants.findIndex((participant) => participant.role === runningTurnParticipant?.role);
|
|
623
|
+
if (participantIndex !== -1)
|
|
624
|
+
state.nextIndex = (participantIndex + 1) % state.participants.length;
|
|
625
|
+
runningTurnParticipant = undefined;
|
|
626
|
+
updateStatus(ctx);
|
|
627
|
+
});
|
|
628
|
+
pi.on("message_start", (event) => {
|
|
629
|
+
if (event.message.role === "user")
|
|
630
|
+
delegatedForPrompt = false;
|
|
631
|
+
});
|
|
632
|
+
pi.on("thinking_level_select", async (event, ctx) => {
|
|
633
|
+
if (!state || selectingParticipant)
|
|
634
|
+
return;
|
|
635
|
+
const expected = state.strategy === "triage"
|
|
636
|
+
? state.participants[0]
|
|
637
|
+
: (runningTurnParticipant ?? pendingTurnParticipant ?? activeTurnParticipant);
|
|
638
|
+
if (!expected?.thinkingLevel || event.level === expected.thinkingLevel)
|
|
639
|
+
return;
|
|
640
|
+
ctx.ui.notify(`Duet mode keeps the thinking level on ${expected.thinkingLevel} for ${expected.role}. Use /duet off to change it freely.`, "warning");
|
|
641
|
+
await setParticipantModel(expected, ctx);
|
|
642
|
+
});
|
|
643
|
+
pi.on("model_select", async (event, ctx) => {
|
|
644
|
+
if (!state || selectingParticipant)
|
|
645
|
+
return;
|
|
646
|
+
const expected = state.strategy === "triage"
|
|
647
|
+
? state.participants[0]
|
|
648
|
+
: (runningTurnParticipant ?? pendingTurnParticipant ?? activeTurnParticipant);
|
|
649
|
+
if (!expected || modelKey(event.model) === expected.modelRef)
|
|
650
|
+
return;
|
|
651
|
+
ctx.ui.notify(`Duet mode keeps the active model on ${formatParticipant(expected)}. Use /duet off to switch freely.`, "warning");
|
|
652
|
+
await setParticipantModel(expected, ctx);
|
|
653
|
+
});
|
|
654
|
+
pi.on("before_agent_start", (event) => {
|
|
655
|
+
if (!state)
|
|
656
|
+
return;
|
|
657
|
+
return { systemPrompt: `${event.systemPrompt}\n\n${buildDuetSystemPrompt(state, activeTurnParticipant)}` };
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
//# sourceMappingURL=duet.js.map
|