@draht/coding-agent 2026.5.12 → 2026.7.7
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 +41 -0
- package/README.md +1 -4
- package/bin/draht-tools.cjs +3756 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +4 -2
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/register-bedrock.js +1 -1
- package/dist/bun/register-bedrock.js.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +36 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +9 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +91 -38
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +5 -3
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +13 -26
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +7 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/session-picker.d.ts +3 -2
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +5 -4
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +20 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +184 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -4
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +27 -13
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +284 -63
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +45 -9
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +100 -33
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +6 -4
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +7 -4
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +55 -33
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +560 -492
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +21 -13
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +48 -28
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -15
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +10 -24
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtins/subagent.d.ts.map +1 -1
- package/dist/core/builtins/subagent.js +1 -2
- package/dist/core/builtins/subagent.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +9 -5
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +10 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +8 -7
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +56 -47
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +3 -3
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +1 -1
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +13 -11
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.css +69 -4
- package/dist/core/export-html/template.js +231 -57
- package/dist/core/export-html/tool-renderer.d.ts +0 -6
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +15 -2
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/export-html/vendor/marked.min.js +75 -3
- package/dist/core/extensions/index.d.ts +8 -8
- 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 +5 -6
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +98 -43
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +31 -12
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +248 -33
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +191 -36
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +2 -2
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +7 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +78 -54
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +91 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +9 -8
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +67 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +59 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +24 -5
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +188 -51
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +12 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +84 -39
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/output-guard.d.ts +1 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +52 -22
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts +22 -4
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +455 -157
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +59 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +13 -11
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +67 -76
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +72 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +36 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +13 -6
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +143 -22
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +36 -15
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +178 -79
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +34 -18
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +47 -16
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +32 -14
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +366 -209
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +62 -6
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +230 -40
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +10 -10
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +13 -35
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +7 -4
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +4 -4
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +20 -16
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +4 -2
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +24 -14
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts +11 -16
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +187 -178
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +26 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +110 -23
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +22 -24
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +201 -113
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +27 -12
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts +7 -18
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +148 -101
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +11 -30
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +23 -12
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +26 -101
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +78 -52
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +6 -15
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +12 -17
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +2 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js +40 -22
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts +7 -18
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +103 -52
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +5 -2
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +18 -2
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +12 -2
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +5 -14
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +27 -46
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts +36 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +202 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/index.d.ts +33 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +5 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +208 -93
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +2 -2
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -4
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +5 -5
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +5 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +37 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +3 -3
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +36 -5
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +318 -36
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +2 -2
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +2 -2
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +2 -2
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +26 -9
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +8 -3
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +103 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +4 -3
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +27 -7
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +33 -31
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +2 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +5 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +19 -5
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +12 -2
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +45 -11
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +10 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +18 -6
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +93 -25
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +5 -12
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +49 -31
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -2
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +33 -14
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +17 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +301 -20
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +6 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +57 -14
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +137 -13
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +91 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +2 -2
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +8 -7
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +6 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +22 -8
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +76 -19
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1294 -494
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +5 -4
- package/dist/modes/interactive/theme/light.json +5 -4
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +102 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +2 -1
- package/dist/modes/interactive/theme/theme.d.ts +41 -3
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +183 -106
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +40 -20
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +30 -5
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +87 -8
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +113 -31
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +42 -4
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +6 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +504 -25
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/brainstorm.md +148 -0
- package/dist/prompts/commands/map-codebase.md +14 -0
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +2 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +78 -0
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +12 -5
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +33 -5
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -2
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts +3 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js +14 -8
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +84 -45
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +54 -22
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +21 -15
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +7 -27
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +75 -115
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +100 -16
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +25 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +75 -2
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +11 -6
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +42 -26
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +86 -10
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +15 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +59 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +12 -12
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +187 -47
- package/docs/development.md +5 -5
- package/docs/docs.json +156 -0
- package/docs/extensions.md +520 -79
- package/docs/index.md +82 -0
- package/docs/json.md +4 -4
- package/docs/keybindings.md +24 -2
- package/docs/models.md +119 -17
- package/docs/packages.md +19 -11
- package/docs/prompt-templates.md +30 -2
- package/docs/providers.md +85 -23
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +99 -10
- package/docs/sdk.md +118 -50
- package/docs/security.md +55 -0
- package/docs/{session.md → session-format.md} +29 -19
- package/docs/sessions.md +145 -0
- package/docs/settings.md +71 -11
- package/docs/skills.md +16 -17
- package/docs/terminal-setup.md +44 -2
- package/docs/termux.md +4 -4
- package/docs/themes.md +3 -3
- package/docs/tmux.md +4 -2
- package/docs/tui.md +44 -4
- package/docs/usage.md +305 -0
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/border-status-editor.ts +145 -0
- package/examples/extensions/built-in-tool-renderer.ts +3 -0
- package/examples/extensions/custom-compaction.ts +2 -1
- package/examples/extensions/custom-header.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +2 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +63 -8
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +2 -2
- package/examples/extensions/doom-overlay/doom-component.ts +2 -2
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/examples/extensions/dynamic-tools.ts +2 -2
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +52 -14
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/notify.ts +2 -9
- package/examples/extensions/overlay-qa-tests.ts +240 -138
- package/examples/extensions/overlay-test.ts +7 -4
- package/examples/extensions/plan-mode/index.ts +87 -37
- package/examples/extensions/plan-mode/utils.ts +1 -1
- package/examples/extensions/preset.ts +46 -7
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/provider-payload.ts +8 -4
- package/examples/extensions/qna.ts +3 -3
- package/examples/extensions/question.ts +34 -20
- package/examples/extensions/questionnaire.ts +43 -30
- package/examples/extensions/reload-runtime.ts +1 -1
- package/examples/extensions/sandbox/index.ts +6 -6
- package/examples/extensions/sandbox/package-lock.json +5 -5
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/shutdown-command.ts +1 -1
- package/examples/extensions/snake.ts +1 -1
- package/examples/extensions/space-invaders.ts +1 -1
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/agents.ts +2 -2
- package/examples/extensions/subagent/index.ts +58 -29
- package/examples/extensions/summarize.ts +3 -2
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/titlebar-spinner.ts +2 -2
- package/examples/extensions/todo.ts +2 -2
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.ts +5 -0
- package/examples/extensions/truncated-tool.ts +1 -1
- package/examples/extensions/with-deps/index.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +3 -3
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/sdk/01-minimal.ts +14 -10
- package/examples/sdk/02-custom-model.ts +13 -9
- package/examples/sdk/03-custom-prompt.ts +32 -17
- package/examples/sdk/04-skills.ts +5 -2
- package/examples/sdk/05-tools.ts +23 -31
- package/examples/sdk/06-extensions.ts +14 -8
- package/examples/sdk/07-context-files.ts +5 -3
- package/examples/sdk/08-prompt-templates.ts +5 -2
- package/examples/sdk/09-api-keys-and-oauth.ts +8 -4
- package/examples/sdk/10-settings.ts +8 -6
- package/examples/sdk/11-sessions.ts +4 -0
- package/examples/sdk/12-full-control.ts +15 -19
- package/package.json +22 -16
- package/prompts/commands/brainstorm.md +148 -0
- package/prompts/commands/map-codebase.md +14 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Plan Mode Extension
|
|
3
3
|
*
|
|
4
4
|
* Read-only exploration mode for safe code analysis.
|
|
5
|
-
* When enabled,
|
|
5
|
+
* When enabled, built-in write tools are disabled.
|
|
6
6
|
*
|
|
7
7
|
* Features:
|
|
8
8
|
* - /plan command or Ctrl+Alt+P to toggle
|
|
@@ -21,6 +21,15 @@ import { extractTodoItems, isSafeCommand, markCompletedSteps, type TodoItem } fr
|
|
|
21
21
|
// Tools
|
|
22
22
|
const PLAN_MODE_TOOLS = ["read", "bash", "grep", "find", "ls", "questionnaire"];
|
|
23
23
|
const NORMAL_MODE_TOOLS = ["read", "bash", "edit", "write"];
|
|
24
|
+
const PLAN_MODE_DISABLED_TOOLS = new Set<string>(["edit", "write"]);
|
|
25
|
+
const PLAN_MANAGED_TOOLS = new Set<string>([...PLAN_MODE_TOOLS, ...NORMAL_MODE_TOOLS]);
|
|
26
|
+
|
|
27
|
+
interface PlanModeState {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
todos?: TodoItem[];
|
|
30
|
+
executing?: boolean;
|
|
31
|
+
toolsBeforePlanMode?: string[];
|
|
32
|
+
}
|
|
24
33
|
|
|
25
34
|
// Type guard for assistant messages
|
|
26
35
|
function isAssistantMessage(m: AgentMessage): m is AssistantMessage {
|
|
@@ -39,6 +48,7 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
39
48
|
let planModeEnabled = false;
|
|
40
49
|
let executionMode = false;
|
|
41
50
|
let todoItems: TodoItem[] = [];
|
|
51
|
+
let toolsBeforePlanMode: string[] | undefined;
|
|
42
52
|
|
|
43
53
|
pi.registerFlag("plan", {
|
|
44
54
|
description: "Start in plan mode (read-only exploration)",
|
|
@@ -73,19 +83,34 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
73
83
|
}
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
todoItems = [];
|
|
86
|
+
function uniqueToolNames(toolNames: string[]): string[] {
|
|
87
|
+
return [...new Set(toolNames)];
|
|
88
|
+
}
|
|
80
89
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
function getPlanModeTools(activeToolNames: string[]): string[] {
|
|
91
|
+
return uniqueToolNames([
|
|
92
|
+
...activeToolNames.filter((name) => !PLAN_MODE_DISABLED_TOOLS.has(name)),
|
|
93
|
+
...PLAN_MODE_TOOLS,
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getNormalModeTools(activeToolNames: string[]): string[] {
|
|
98
|
+
return uniqueToolNames([
|
|
99
|
+
...NORMAL_MODE_TOOLS,
|
|
100
|
+
...activeToolNames.filter((name) => !PLAN_MANAGED_TOOLS.has(name)),
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function enablePlanModeTools(): void {
|
|
105
|
+
if (toolsBeforePlanMode === undefined) {
|
|
106
|
+
toolsBeforePlanMode = pi.getActiveTools();
|
|
87
107
|
}
|
|
88
|
-
|
|
108
|
+
pi.setActiveTools(getPlanModeTools(toolsBeforePlanMode));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function restoreNormalModeTools(): void {
|
|
112
|
+
pi.setActiveTools(toolsBeforePlanMode ?? getNormalModeTools(pi.getActiveTools()));
|
|
113
|
+
toolsBeforePlanMode = undefined;
|
|
89
114
|
}
|
|
90
115
|
|
|
91
116
|
function persistState(): void {
|
|
@@ -93,9 +118,26 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
93
118
|
enabled: planModeEnabled,
|
|
94
119
|
todos: todoItems,
|
|
95
120
|
executing: executionMode,
|
|
121
|
+
toolsBeforePlanMode,
|
|
96
122
|
});
|
|
97
123
|
}
|
|
98
124
|
|
|
125
|
+
function togglePlanMode(ctx: ExtensionContext): void {
|
|
126
|
+
planModeEnabled = !planModeEnabled;
|
|
127
|
+
executionMode = false;
|
|
128
|
+
todoItems = [];
|
|
129
|
+
|
|
130
|
+
if (planModeEnabled) {
|
|
131
|
+
enablePlanModeTools();
|
|
132
|
+
ctx.ui.notify("Plan mode enabled. Built-in write tools disabled.");
|
|
133
|
+
} else {
|
|
134
|
+
restoreNormalModeTools();
|
|
135
|
+
ctx.ui.notify("Plan mode disabled. Full access restored.");
|
|
136
|
+
}
|
|
137
|
+
updateStatus(ctx);
|
|
138
|
+
persistState();
|
|
139
|
+
}
|
|
140
|
+
|
|
99
141
|
pi.registerCommand("plan", {
|
|
100
142
|
description: "Toggle plan mode (read-only exploration)",
|
|
101
143
|
handler: async (_args, ctx) => togglePlanMode(ctx),
|
|
@@ -165,8 +207,8 @@ export default function planModeExtension(pi: ExtensionAPI): void {
|
|
|
165
207
|
You are in plan mode - a read-only exploration mode for safe code analysis.
|
|
166
208
|
|
|
167
209
|
Restrictions:
|
|
168
|
-
-
|
|
169
|
-
-
|
|
210
|
+
- Built-in edit and write tools are disabled
|
|
211
|
+
- Other currently active tools remain available
|
|
170
212
|
- Bash is restricted to an allowlist of read-only commands
|
|
171
213
|
|
|
172
214
|
Ask clarifying questions using the questionnaire tool.
|
|
@@ -228,7 +270,6 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
228
270
|
);
|
|
229
271
|
executionMode = false;
|
|
230
272
|
todoItems = [];
|
|
231
|
-
pi.setActiveTools(NORMAL_MODE_TOOLS);
|
|
232
273
|
updateStatus(ctx);
|
|
233
274
|
persistState(); // Save cleared state so resume doesn't restore old execution mode
|
|
234
275
|
}
|
|
@@ -246,43 +287,51 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
246
287
|
}
|
|
247
288
|
}
|
|
248
289
|
|
|
290
|
+
if (todoItems.length === 0) return;
|
|
291
|
+
persistState();
|
|
292
|
+
|
|
249
293
|
// Show plan steps and prompt for next action
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
display: true,
|
|
257
|
-
},
|
|
258
|
-
{ triggerTurn: false },
|
|
259
|
-
);
|
|
260
|
-
}
|
|
294
|
+
const todoListText = todoItems.map((t, i) => `${i + 1}. ☐ ${t.text}`).join("\n");
|
|
295
|
+
const planTodoListMessage = {
|
|
296
|
+
customType: "plan-todo-list",
|
|
297
|
+
content: `**Plan Steps (${todoItems.length}):**\n\n${todoListText}`,
|
|
298
|
+
display: true,
|
|
299
|
+
};
|
|
261
300
|
|
|
262
301
|
const choice = await ctx.ui.select("Plan mode - what next?", [
|
|
263
|
-
|
|
302
|
+
"Execute the plan (track progress)",
|
|
264
303
|
"Stay in plan mode",
|
|
265
304
|
"Refine the plan",
|
|
266
305
|
]);
|
|
267
306
|
|
|
268
307
|
if (choice?.startsWith("Execute")) {
|
|
308
|
+
const firstTodoItem = todoItems[0];
|
|
309
|
+
if (!firstTodoItem) return;
|
|
310
|
+
|
|
269
311
|
planModeEnabled = false;
|
|
270
|
-
executionMode =
|
|
271
|
-
|
|
312
|
+
executionMode = true;
|
|
313
|
+
restoreNormalModeTools();
|
|
272
314
|
updateStatus(ctx);
|
|
315
|
+
persistState();
|
|
316
|
+
|
|
317
|
+
const remainingList = todoItems.map((t) => `${t.step}. ${t.text}`).join("\n");
|
|
318
|
+
const execMessage = `Execute the plan.
|
|
319
|
+
|
|
320
|
+
Remaining steps:
|
|
321
|
+
${remainingList}
|
|
273
322
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
: "Execute the plan you just created.";
|
|
323
|
+
Start with: ${firstTodoItem.text}
|
|
324
|
+
After completing a step, include a [DONE:n] tag in your response.`;
|
|
325
|
+
pi.sendMessage(planTodoListMessage, { deliverAs: "followUp" });
|
|
278
326
|
pi.sendMessage(
|
|
279
327
|
{ customType: "plan-mode-execute", content: execMessage, display: true },
|
|
280
|
-
{ triggerTurn: true },
|
|
328
|
+
{ triggerTurn: true, deliverAs: "followUp" },
|
|
281
329
|
);
|
|
282
330
|
} else if (choice === "Refine the plan") {
|
|
283
331
|
const refinement = await ctx.ui.editor("Refine the plan:", "");
|
|
284
332
|
if (refinement?.trim()) {
|
|
285
|
-
pi.
|
|
333
|
+
pi.sendMessage(planTodoListMessage, { deliverAs: "followUp" });
|
|
334
|
+
pi.sendUserMessage(refinement.trim(), { deliverAs: "followUp" });
|
|
286
335
|
}
|
|
287
336
|
}
|
|
288
337
|
});
|
|
@@ -298,12 +347,13 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
298
347
|
// Restore persisted state
|
|
299
348
|
const planModeEntry = entries
|
|
300
349
|
.filter((e: { type: string; customType?: string }) => e.type === "custom" && e.customType === "plan-mode")
|
|
301
|
-
.pop() as { data?:
|
|
350
|
+
.pop() as { data?: PlanModeState } | undefined;
|
|
302
351
|
|
|
303
352
|
if (planModeEntry?.data) {
|
|
304
353
|
planModeEnabled = planModeEntry.data.enabled ?? planModeEnabled;
|
|
305
354
|
todoItems = planModeEntry.data.todos ?? todoItems;
|
|
306
355
|
executionMode = planModeEntry.data.executing ?? executionMode;
|
|
356
|
+
toolsBeforePlanMode = planModeEntry.data.toolsBeforePlanMode ?? toolsBeforePlanMode;
|
|
307
357
|
}
|
|
308
358
|
|
|
309
359
|
// On resume: re-scan messages to rebuild completion state
|
|
@@ -333,7 +383,7 @@ After completing a step, include a [DONE:n] tag in your response.`,
|
|
|
333
383
|
}
|
|
334
384
|
|
|
335
385
|
if (planModeEnabled) {
|
|
336
|
-
|
|
386
|
+
enablePlanModeTools();
|
|
337
387
|
}
|
|
338
388
|
updateStatus(ctx);
|
|
339
389
|
});
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
|
|
41
41
|
import { existsSync, readFileSync } from "node:fs";
|
|
42
42
|
import { join } from "node:path";
|
|
43
|
+
import type { Api, Model } from "@draht/ai";
|
|
43
44
|
import type { ExtensionAPI, ExtensionContext } from "@draht/coding-agent";
|
|
44
|
-
import { DynamicBorder, getAgentDir } from "@draht/coding-agent";
|
|
45
|
+
import { CONFIG_DIR_NAME, DynamicBorder, getAgentDir } from "@draht/coding-agent";
|
|
45
46
|
import { Container, Key, type SelectItem, SelectList, Text } from "@draht/tui";
|
|
46
47
|
|
|
47
48
|
// Preset configuration
|
|
@@ -68,7 +69,7 @@ interface PresetsConfig {
|
|
|
68
69
|
*/
|
|
69
70
|
function loadPresets(cwd: string): PresetsConfig {
|
|
70
71
|
const globalPath = join(getAgentDir(), "presets.json");
|
|
71
|
-
const projectPath = join(cwd,
|
|
72
|
+
const projectPath = join(cwd, CONFIG_DIR_NAME, "presets.json");
|
|
72
73
|
|
|
73
74
|
let globalPresets: PresetsConfig = {};
|
|
74
75
|
let projectPresets: PresetsConfig = {};
|
|
@@ -97,10 +98,17 @@ function loadPresets(cwd: string): PresetsConfig {
|
|
|
97
98
|
return { ...globalPresets, ...projectPresets };
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
interface OriginalState {
|
|
102
|
+
model: Model<Api> | undefined;
|
|
103
|
+
thinkingLevel: "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
104
|
+
tools: string[];
|
|
105
|
+
}
|
|
106
|
+
|
|
100
107
|
export default function presetExtension(pi: ExtensionAPI) {
|
|
101
108
|
let presets: PresetsConfig = {};
|
|
102
109
|
let activePresetName: string | undefined;
|
|
103
110
|
let activePreset: Preset | undefined;
|
|
111
|
+
let originalState: OriginalState | undefined;
|
|
104
112
|
|
|
105
113
|
// Register --preset CLI flag
|
|
106
114
|
pi.registerFlag("preset", {
|
|
@@ -112,6 +120,15 @@ export default function presetExtension(pi: ExtensionAPI) {
|
|
|
112
120
|
* Apply a preset configuration.
|
|
113
121
|
*/
|
|
114
122
|
async function applyPreset(name: string, preset: Preset, ctx: ExtensionContext): Promise<boolean> {
|
|
123
|
+
// Snapshot state before the first preset is applied (i.e. only when transitioning from no-preset)
|
|
124
|
+
if (activePresetName === undefined) {
|
|
125
|
+
originalState = {
|
|
126
|
+
model: ctx.model,
|
|
127
|
+
thinkingLevel: pi.getThinkingLevel(),
|
|
128
|
+
tools: pi.getActiveTools(),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
115
132
|
// Apply model if specified
|
|
116
133
|
if (preset.provider && preset.model) {
|
|
117
134
|
const model = ctx.modelRegistry.find(preset.provider, preset.model);
|
|
@@ -183,7 +200,10 @@ export default function presetExtension(pi: ExtensionAPI) {
|
|
|
183
200
|
const presetNames = Object.keys(presets);
|
|
184
201
|
|
|
185
202
|
if (presetNames.length === 0) {
|
|
186
|
-
ctx.ui.notify(
|
|
203
|
+
ctx.ui.notify(
|
|
204
|
+
`No presets defined. Add presets to ${join(getAgentDir(), "presets.json")} or ${join(ctx.cwd, CONFIG_DIR_NAME, "presets.json")}`,
|
|
205
|
+
"warning",
|
|
206
|
+
);
|
|
187
207
|
return;
|
|
188
208
|
}
|
|
189
209
|
|
|
@@ -248,10 +268,18 @@ export default function presetExtension(pi: ExtensionAPI) {
|
|
|
248
268
|
if (!result) return;
|
|
249
269
|
|
|
250
270
|
if (result === "(none)") {
|
|
251
|
-
// Clear preset and restore
|
|
271
|
+
// Clear preset and restore original state
|
|
252
272
|
activePresetName = undefined;
|
|
253
273
|
activePreset = undefined;
|
|
254
|
-
|
|
274
|
+
if (originalState) {
|
|
275
|
+
if (originalState.model) {
|
|
276
|
+
await pi.setModel(originalState.model);
|
|
277
|
+
}
|
|
278
|
+
pi.setThinkingLevel(originalState.thinkingLevel);
|
|
279
|
+
pi.setActiveTools(originalState.tools);
|
|
280
|
+
} else {
|
|
281
|
+
pi.setActiveTools(["read", "bash", "edit", "write"]);
|
|
282
|
+
}
|
|
255
283
|
ctx.ui.notify("Preset cleared, defaults restored", "info");
|
|
256
284
|
updateStatus(ctx);
|
|
257
285
|
return;
|
|
@@ -283,7 +311,10 @@ export default function presetExtension(pi: ExtensionAPI) {
|
|
|
283
311
|
async function cyclePreset(ctx: ExtensionContext): Promise<void> {
|
|
284
312
|
const presetNames = getPresetOrder();
|
|
285
313
|
if (presetNames.length === 0) {
|
|
286
|
-
ctx.ui.notify(
|
|
314
|
+
ctx.ui.notify(
|
|
315
|
+
`No presets defined. Add presets to ${join(getAgentDir(), "presets.json")} or ${join(ctx.cwd, CONFIG_DIR_NAME, "presets.json")}`,
|
|
316
|
+
"warning",
|
|
317
|
+
);
|
|
287
318
|
return;
|
|
288
319
|
}
|
|
289
320
|
|
|
@@ -296,7 +327,15 @@ export default function presetExtension(pi: ExtensionAPI) {
|
|
|
296
327
|
if (nextName === "(none)") {
|
|
297
328
|
activePresetName = undefined;
|
|
298
329
|
activePreset = undefined;
|
|
299
|
-
|
|
330
|
+
if (originalState) {
|
|
331
|
+
if (originalState.model) {
|
|
332
|
+
await pi.setModel(originalState.model);
|
|
333
|
+
}
|
|
334
|
+
pi.setThinkingLevel(originalState.thinkingLevel);
|
|
335
|
+
pi.setActiveTools(originalState.tools);
|
|
336
|
+
} else {
|
|
337
|
+
pi.setActiveTools(["read", "bash", "edit", "write"]);
|
|
338
|
+
}
|
|
300
339
|
ctx.ui.notify("Preset cleared, defaults restored", "info");
|
|
301
340
|
updateStatus(ctx);
|
|
302
341
|
return;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Trust Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates the project_trust event. Install globally or pass via -e:
|
|
5
|
+
*
|
|
6
|
+
* mkdir -p ~/.pi/agent/extensions
|
|
7
|
+
* cp packages/coding-agent/examples/extensions/project-trust.ts ~/.pi/agent/extensions/
|
|
8
|
+
*
|
|
9
|
+
* Or:
|
|
10
|
+
*
|
|
11
|
+
* pi -e packages/coding-agent/examples/extensions/project-trust.ts
|
|
12
|
+
*
|
|
13
|
+
* Try it in a project containing .pi, AGENTS.md/CLAUDE.md, or .agents/skills.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { ExtensionAPI, ProjectTrustEventResult } from "@draht/coding-agent";
|
|
17
|
+
|
|
18
|
+
export default function (pi: ExtensionAPI) {
|
|
19
|
+
let loadCount = 0;
|
|
20
|
+
loadCount++;
|
|
21
|
+
|
|
22
|
+
// Multiple handlers in one extension are allowed. The first handler that returns
|
|
23
|
+
// { trusted: "yes" } or { trusted: "no" } wins and suppresses the built-in
|
|
24
|
+
// trust prompt. Return { trusted: "undecided" } to let another handler or the
|
|
25
|
+
// built-in flow decide.
|
|
26
|
+
pi.on("project_trust", async (event, ctx): Promise<ProjectTrustEventResult> => {
|
|
27
|
+
ctx.ui.notify(`project_trust fired for ${event.cwd} (mode: ${ctx.mode}, load: ${loadCount})`, "info");
|
|
28
|
+
|
|
29
|
+
if (!ctx.hasUI) {
|
|
30
|
+
return { trusted: "undecided" };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const choice = await ctx.ui.select(`Project trust for:\n${event.cwd}`, [
|
|
34
|
+
"Trust and remember",
|
|
35
|
+
"Trust with note and remember",
|
|
36
|
+
"Trust this session",
|
|
37
|
+
"Do not trust this session",
|
|
38
|
+
"Let built-in prompt decide",
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
if (choice === "Trust with note and remember") {
|
|
42
|
+
const note = await ctx.ui.input("Project trust note", "Optional note for this demo");
|
|
43
|
+
ctx.ui.notify(note ? `Recorded demo note: ${note}` : "No demo note entered", "info");
|
|
44
|
+
return { trusted: "yes", remember: true };
|
|
45
|
+
}
|
|
46
|
+
if (choice === "Trust and remember") {
|
|
47
|
+
return { trusted: "yes", remember: true };
|
|
48
|
+
}
|
|
49
|
+
if (choice === "Trust this session") {
|
|
50
|
+
return { trusted: "yes" };
|
|
51
|
+
}
|
|
52
|
+
if (choice === "Do not trust this session") {
|
|
53
|
+
return { trusted: "no" };
|
|
54
|
+
}
|
|
55
|
+
if (choice === "Let built-in prompt decide") {
|
|
56
|
+
return { trusted: "undecided" };
|
|
57
|
+
}
|
|
58
|
+
return { trusted: "undecided" };
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
pi.on("session_start", (_event, ctx) => {
|
|
62
|
+
ctx.ui.notify(`project-trust example loaded after trust resolution in ${ctx.cwd}`, "info");
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Customizer Extension
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates using systemPromptOptions to make informed, context-aware
|
|
5
|
+
* modifications to the system prompt without re-discovering resources.
|
|
6
|
+
*
|
|
7
|
+
* This extension adds tool-specific guidance based on what tools and skills
|
|
8
|
+
* are currently active, respecting whatever the user has configured.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
|
|
12
|
+
* 2. Use the extension — it automatically adapts to your active tools and skills
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { BuildSystemPromptOptions, ExtensionAPI } from "@draht/coding-agent";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Adds tool-specific guidance that adapts to the active tool set.
|
|
19
|
+
* Instead of appending one-size-fits-all instructions, this reads what's
|
|
20
|
+
* actually loaded and tailors the guidance accordingly.
|
|
21
|
+
*/
|
|
22
|
+
function addToolGuidance(options: BuildSystemPromptOptions, basePrompt: string): string {
|
|
23
|
+
const hasTool = (name: string) => options.selectedTools?.includes(name) ?? false;
|
|
24
|
+
|
|
25
|
+
const parts: string[] = [];
|
|
26
|
+
|
|
27
|
+
if (hasTool("read")) {
|
|
28
|
+
parts.push(
|
|
29
|
+
"• Use the `read` tool for file contents (supports text and images).",
|
|
30
|
+
" - For large files, use `offset` and `limit` to read in chunks.",
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (hasTool("bash")) {
|
|
35
|
+
parts.push("• Execute commands with the `bash` tool. Use it for file operations like `ls`, `find`, `grep`.");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (hasTool("edit")) {
|
|
39
|
+
parts.push(
|
|
40
|
+
"• Use the `edit` tool for precise text replacements in files. Match exact content including whitespace.",
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (hasTool("write")) {
|
|
45
|
+
parts.push("• Use the `write` tool to create new files or overwrite existing ones completely.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (options.skills && options.skills.length > 0) {
|
|
49
|
+
const skillNames = options.skills.map((s) => s.name).join(", ");
|
|
50
|
+
parts.push(`\nAvailable skills: ${skillNames}`, "Use skill documentation for best practices on specific tools.");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (parts.length === 0) {
|
|
54
|
+
return basePrompt;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return `${basePrompt}
|
|
58
|
+
|
|
59
|
+
## Tool Guidance
|
|
60
|
+
|
|
61
|
+
${parts.join("\n")}
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Merges extension instructions with user-provided append prompts.
|
|
67
|
+
* This respects whatever the user configured via --append-system-prompt
|
|
68
|
+
* flags or files, rather than duplicating that work.
|
|
69
|
+
*/
|
|
70
|
+
function mergeWithUserAppend(options: BuildSystemPromptOptions): string {
|
|
71
|
+
const userAppend = options.appendSystemPrompt;
|
|
72
|
+
const extensionSpecific = `
|
|
73
|
+
## Extension-Added Context
|
|
74
|
+
|
|
75
|
+
This prompt includes tool guidance and skill information loaded dynamically.
|
|
76
|
+
If you have additional requirements, configure them via --append-system-prompt or project context files.
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
if (userAppend) {
|
|
80
|
+
return `${userAppend}\n\n${extensionSpecific}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return extensionSpecific;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default function promptCustomizer(pi: ExtensionAPI) {
|
|
87
|
+
pi.on("before_agent_start", async (event) => {
|
|
88
|
+
const { systemPrompt, systemPromptOptions } = event;
|
|
89
|
+
|
|
90
|
+
const customPrompt = addToolGuidance(systemPromptOptions, systemPrompt);
|
|
91
|
+
const appendSection = mergeWithUserAppend(systemPromptOptions);
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
systemPrompt: `${customPrompt}${appendSection}`,
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { appendFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import type
|
|
3
|
+
import { CONFIG_DIR_NAME, type ExtensionAPI } from "@draht/coding-agent";
|
|
4
4
|
|
|
5
5
|
export default function (pi: ExtensionAPI) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
pi.on("before_provider_request", (event) => {
|
|
6
|
+
pi.on("before_provider_request", (event, ctx) => {
|
|
7
|
+
const logFile = join(ctx.cwd, CONFIG_DIR_NAME, "provider-payload.log");
|
|
9
8
|
appendFileSync(logFile, `${JSON.stringify(event.payload, null, 2)}\n\n`, "utf8");
|
|
10
9
|
|
|
11
10
|
// Optional: replace the payload instead of only logging it.
|
|
12
11
|
// return { ...event.payload, temperature: 0 };
|
|
13
12
|
});
|
|
13
|
+
|
|
14
|
+
pi.on("after_provider_response", (event, ctx) => {
|
|
15
|
+
const logFile = join(ctx.cwd, CONFIG_DIR_NAME, "provider-payload.log");
|
|
16
|
+
appendFileSync(logFile, `[${event.status}] ${JSON.stringify(event.headers)}\n\n`, "utf8");
|
|
17
|
+
});
|
|
14
18
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 3. Loads the result into the editor for user to fill in answers
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { complete, type UserMessage } from "@draht/ai";
|
|
10
|
+
import { complete, type UserMessage } from "@draht/ai/compat";
|
|
11
11
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
12
12
|
import { BorderedLoader } from "@draht/coding-agent";
|
|
13
13
|
|
|
@@ -31,7 +31,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
31
31
|
pi.registerCommand("qna", {
|
|
32
32
|
description: "Extract questions from last assistant message into editor",
|
|
33
33
|
handler: async (_args, ctx) => {
|
|
34
|
-
if (
|
|
34
|
+
if (ctx.mode !== "tui") {
|
|
35
35
|
ctx.ui.notify("qna requires interactive mode", "error");
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
@@ -90,7 +90,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
90
90
|
const response = await complete(
|
|
91
91
|
ctx.model!,
|
|
92
92
|
{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
|
|
93
|
-
{ apiKey: auth.apiKey, headers: auth.headers, signal: loader.signal },
|
|
93
|
+
{ apiKey: auth.apiKey, headers: auth.headers, env: auth.env, signal: loader.signal },
|
|
94
94
|
);
|
|
95
95
|
|
|
96
96
|
if (response.stopReason === "aborted") {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
8
|
-
import { Editor, type EditorTheme, Key, matchesKey, Text,
|
|
9
|
-
import { Type } from "
|
|
8
|
+
import { Editor, type EditorTheme, Key, matchesKey, Text, visibleWidth, wrapTextWithAnsi } from "@draht/tui";
|
|
9
|
+
import { Type } from "typebox";
|
|
10
10
|
|
|
11
11
|
interface OptionWithDesc {
|
|
12
12
|
label: string;
|
|
@@ -39,9 +39,10 @@ export default function question(pi: ExtensionAPI) {
|
|
|
39
39
|
label: "Question",
|
|
40
40
|
description: "Ask the user a question and let them pick from options. Use when you need user input to proceed.",
|
|
41
41
|
parameters: QuestionParams,
|
|
42
|
+
executionMode: "sequential",
|
|
42
43
|
|
|
43
44
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
44
|
-
if (
|
|
45
|
+
if (ctx.mode !== "tui") {
|
|
45
46
|
return {
|
|
46
47
|
content: [{ type: "text", text: "Error: UI not available (running in non-interactive mode)" }],
|
|
47
48
|
details: {
|
|
@@ -139,10 +140,27 @@ export default function question(pi: ExtensionAPI) {
|
|
|
139
140
|
if (cachedLines) return cachedLines;
|
|
140
141
|
|
|
141
142
|
const lines: string[] = [];
|
|
142
|
-
const
|
|
143
|
+
const renderWidth = Math.max(1, width);
|
|
143
144
|
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
function addWrapped(text: string) {
|
|
146
|
+
lines.push(...wrapTextWithAnsi(text, renderWidth));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function addWrappedWithPrefix(prefix: string, text: string) {
|
|
150
|
+
const prefixWidth = visibleWidth(prefix);
|
|
151
|
+
if (prefixWidth >= renderWidth) {
|
|
152
|
+
addWrapped(prefix + text);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const wrapped = wrapTextWithAnsi(text, renderWidth - prefixWidth);
|
|
156
|
+
const continuationPrefix = " ".repeat(prefixWidth);
|
|
157
|
+
for (let i = 0; i < wrapped.length; i++) {
|
|
158
|
+
lines.push(`${i === 0 ? prefix : continuationPrefix}${wrapped[i]}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
163
|
+
addWrappedWithPrefix(" ", theme.fg("text", params.question));
|
|
146
164
|
lines.push("");
|
|
147
165
|
|
|
148
166
|
for (let i = 0; i < allOptions.length; i++) {
|
|
@@ -150,36 +168,32 @@ export default function question(pi: ExtensionAPI) {
|
|
|
150
168
|
const selected = i === optionIndex;
|
|
151
169
|
const isOther = opt.isOther === true;
|
|
152
170
|
const prefix = selected ? theme.fg("accent", "> ") : " ";
|
|
171
|
+
const label = `${i + 1}. ${opt.label}${isOther && editMode ? " ✎" : ""}`;
|
|
172
|
+
const color = selected || (isOther && editMode) ? "accent" : "text";
|
|
153
173
|
|
|
154
|
-
|
|
155
|
-
add(prefix + theme.fg("accent", `${i + 1}. ${opt.label} ✎`));
|
|
156
|
-
} else if (selected) {
|
|
157
|
-
add(prefix + theme.fg("accent", `${i + 1}. ${opt.label}`));
|
|
158
|
-
} else {
|
|
159
|
-
add(` ${theme.fg("text", `${i + 1}. ${opt.label}`)}`);
|
|
160
|
-
}
|
|
174
|
+
addWrappedWithPrefix(prefix, theme.fg(color, label));
|
|
161
175
|
|
|
162
176
|
// Show description if present
|
|
163
177
|
if (opt.description) {
|
|
164
|
-
|
|
178
|
+
addWrappedWithPrefix(" ", theme.fg("muted", opt.description));
|
|
165
179
|
}
|
|
166
180
|
}
|
|
167
181
|
|
|
168
182
|
if (editMode) {
|
|
169
183
|
lines.push("");
|
|
170
|
-
|
|
171
|
-
for (const line of editor.render(
|
|
172
|
-
|
|
184
|
+
addWrappedWithPrefix(" ", theme.fg("muted", "Your answer:"));
|
|
185
|
+
for (const line of editor.render(Math.max(1, renderWidth - 2))) {
|
|
186
|
+
lines.push(` ${line}`);
|
|
173
187
|
}
|
|
174
188
|
}
|
|
175
189
|
|
|
176
190
|
lines.push("");
|
|
177
191
|
if (editMode) {
|
|
178
|
-
|
|
192
|
+
addWrappedWithPrefix(" ", theme.fg("dim", "Enter to submit • Esc to go back"));
|
|
179
193
|
} else {
|
|
180
|
-
|
|
194
|
+
addWrappedWithPrefix(" ", theme.fg("dim", "↑↓ navigate • Enter to select • Esc to cancel"));
|
|
181
195
|
}
|
|
182
|
-
|
|
196
|
+
lines.push(theme.fg("accent", "─".repeat(renderWidth)));
|
|
183
197
|
|
|
184
198
|
cachedLines = lines;
|
|
185
199
|
return lines;
|