@vandeepunk/pi-coding-agent 0.0.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 +2564 -0
- package/README.md +555 -0
- package/dist/cli/args.d.ts +47 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +286 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +68 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +203 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +574 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2260 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-storage.d.ts +102 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +282 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +47 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +212 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +86 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +607 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +35 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +138 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +34 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +222 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +909 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1549 -0
- package/dist/core/export-html/tool-renderer.d.ts +35 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +57 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +25 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +400 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +129 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +576 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +928 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +27 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +32 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +134 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +55 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +153 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +100 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +419 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +76 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +313 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/package-manager.d.ts +131 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1290 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +50 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +251 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +17 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +184 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +673 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +90 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +234 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-manager.d.ts +323 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1091 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +187 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +552 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +58 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +310 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +21 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/system-prompt.d.ts +24 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +137 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +25 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +55 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +242 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +63 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +243 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +39 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +146 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/find.d.ts +39 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +206 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +45 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +239 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +73 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +61 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +40 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +118 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +8 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +39 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +166 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +205 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +29 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +78 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +623 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +261 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +333 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +16 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +91 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +162 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +479 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +70 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +79 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +17 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +102 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +24 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +78 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +26 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +220 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +32 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +41 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +42 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +145 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +266 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +19 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +97 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +49 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +270 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +851 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +53 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +277 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +35 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +46 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +70 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +621 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +68 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +934 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +113 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +8 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +16 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +313 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +3664 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +78 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +944 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +98 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +217 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +405 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +500 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +409 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +162 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +7 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/git.d.ts +2 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +6 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize.d.ts +36 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +181 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +26 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +186 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +201 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/docs/compaction.md +390 -0
- package/docs/custom-provider.md +539 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +1827 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +79 -0
- package/docs/keybindings.md +174 -0
- package/docs/models.md +254 -0
- package/docs/packages.md +191 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +168 -0
- package/docs/rpc.md +1311 -0
- package/docs/sdk.md +957 -0
- package/docs/session.md +412 -0
- package/docs/settings.md +221 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +227 -0
- package/docs/terminal-setup.md +70 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tree.md +219 -0
- package/docs/tui.md +887 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +202 -0
- package/examples/extensions/antigravity-image-gen.ts +413 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +114 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/custom-provider-qwen-cli/index.ts +345 -0
- package/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +150 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +881 -0
- package/examples/extensions/overlay-test.ts +150 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +398 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/qna.ts +119 -0
- package/examples/extensions/question.ts +264 -0
- package/examples/extensions/questionnaire.ts +427 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/rpc-demo.ts +124 -0
- package/examples/extensions/sandbox/index.ts +318 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +127 -0
- package/examples/extensions/subagent/index.ts +963 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +195 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +299 -0
- package/examples/extensions/tool-override.ts +143 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +192 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +38 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +97 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Questionnaire Tool - Unified tool for asking single or multiple questions
|
|
3
|
+
*
|
|
4
|
+
* Single question: simple options list
|
|
5
|
+
* Multiple questions: tab bar navigation between questions
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
|
+
import { Editor, type EditorTheme, Key, matchesKey, Text, truncateToWidth } from "@mariozechner/pi-tui";
|
|
10
|
+
import { Type } from "@sinclair/typebox";
|
|
11
|
+
|
|
12
|
+
// Types
|
|
13
|
+
interface QuestionOption {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type RenderOption = QuestionOption & { isOther?: boolean };
|
|
20
|
+
|
|
21
|
+
interface Question {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
prompt: string;
|
|
25
|
+
options: QuestionOption[];
|
|
26
|
+
allowOther: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Answer {
|
|
30
|
+
id: string;
|
|
31
|
+
value: string;
|
|
32
|
+
label: string;
|
|
33
|
+
wasCustom: boolean;
|
|
34
|
+
index?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface QuestionnaireResult {
|
|
38
|
+
questions: Question[];
|
|
39
|
+
answers: Answer[];
|
|
40
|
+
cancelled: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Schema
|
|
44
|
+
const QuestionOptionSchema = Type.Object({
|
|
45
|
+
value: Type.String({ description: "The value returned when selected" }),
|
|
46
|
+
label: Type.String({ description: "Display label for the option" }),
|
|
47
|
+
description: Type.Optional(Type.String({ description: "Optional description shown below label" })),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const QuestionSchema = Type.Object({
|
|
51
|
+
id: Type.String({ description: "Unique identifier for this question" }),
|
|
52
|
+
label: Type.Optional(
|
|
53
|
+
Type.String({
|
|
54
|
+
description: "Short contextual label for tab bar, e.g. 'Scope', 'Priority' (defaults to Q1, Q2)",
|
|
55
|
+
}),
|
|
56
|
+
),
|
|
57
|
+
prompt: Type.String({ description: "The full question text to display" }),
|
|
58
|
+
options: Type.Array(QuestionOptionSchema, { description: "Available options to choose from" }),
|
|
59
|
+
allowOther: Type.Optional(Type.Boolean({ description: "Allow 'Type something' option (default: true)" })),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const QuestionnaireParams = Type.Object({
|
|
63
|
+
questions: Type.Array(QuestionSchema, { description: "Questions to ask the user" }),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
function errorResult(
|
|
67
|
+
message: string,
|
|
68
|
+
questions: Question[] = [],
|
|
69
|
+
): { content: { type: "text"; text: string }[]; details: QuestionnaireResult } {
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: "text", text: message }],
|
|
72
|
+
details: { questions, answers: [], cancelled: true },
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default function questionnaire(pi: ExtensionAPI) {
|
|
77
|
+
pi.registerTool({
|
|
78
|
+
name: "questionnaire",
|
|
79
|
+
label: "Questionnaire",
|
|
80
|
+
description:
|
|
81
|
+
"Ask the user one or more questions. Use for clarifying requirements, getting preferences, or confirming decisions. For single questions, shows a simple option list. For multiple questions, shows a tab-based interface.",
|
|
82
|
+
parameters: QuestionnaireParams,
|
|
83
|
+
|
|
84
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
85
|
+
if (!ctx.hasUI) {
|
|
86
|
+
return errorResult("Error: UI not available (running in non-interactive mode)");
|
|
87
|
+
}
|
|
88
|
+
if (params.questions.length === 0) {
|
|
89
|
+
return errorResult("Error: No questions provided");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Normalize questions with defaults
|
|
93
|
+
const questions: Question[] = params.questions.map((q, i) => ({
|
|
94
|
+
...q,
|
|
95
|
+
label: q.label || `Q${i + 1}`,
|
|
96
|
+
allowOther: q.allowOther !== false,
|
|
97
|
+
}));
|
|
98
|
+
|
|
99
|
+
const isMulti = questions.length > 1;
|
|
100
|
+
const totalTabs = questions.length + 1; // questions + Submit
|
|
101
|
+
|
|
102
|
+
const result = await ctx.ui.custom<QuestionnaireResult>((tui, theme, _kb, done) => {
|
|
103
|
+
// State
|
|
104
|
+
let currentTab = 0;
|
|
105
|
+
let optionIndex = 0;
|
|
106
|
+
let inputMode = false;
|
|
107
|
+
let inputQuestionId: string | null = null;
|
|
108
|
+
let cachedLines: string[] | undefined;
|
|
109
|
+
const answers = new Map<string, Answer>();
|
|
110
|
+
|
|
111
|
+
// Editor for "Type something" option
|
|
112
|
+
const editorTheme: EditorTheme = {
|
|
113
|
+
borderColor: (s) => theme.fg("accent", s),
|
|
114
|
+
selectList: {
|
|
115
|
+
selectedPrefix: (t) => theme.fg("accent", t),
|
|
116
|
+
selectedText: (t) => theme.fg("accent", t),
|
|
117
|
+
description: (t) => theme.fg("muted", t),
|
|
118
|
+
scrollInfo: (t) => theme.fg("dim", t),
|
|
119
|
+
noMatch: (t) => theme.fg("warning", t),
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const editor = new Editor(tui, editorTheme);
|
|
123
|
+
|
|
124
|
+
// Helpers
|
|
125
|
+
function refresh() {
|
|
126
|
+
cachedLines = undefined;
|
|
127
|
+
tui.requestRender();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function submit(cancelled: boolean) {
|
|
131
|
+
done({ questions, answers: Array.from(answers.values()), cancelled });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function currentQuestion(): Question | undefined {
|
|
135
|
+
return questions[currentTab];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function currentOptions(): RenderOption[] {
|
|
139
|
+
const q = currentQuestion();
|
|
140
|
+
if (!q) return [];
|
|
141
|
+
const opts: RenderOption[] = [...q.options];
|
|
142
|
+
if (q.allowOther) {
|
|
143
|
+
opts.push({ value: "__other__", label: "Type something.", isOther: true });
|
|
144
|
+
}
|
|
145
|
+
return opts;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function allAnswered(): boolean {
|
|
149
|
+
return questions.every((q) => answers.has(q.id));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function advanceAfterAnswer() {
|
|
153
|
+
if (!isMulti) {
|
|
154
|
+
submit(false);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (currentTab < questions.length - 1) {
|
|
158
|
+
currentTab++;
|
|
159
|
+
} else {
|
|
160
|
+
currentTab = questions.length; // Submit tab
|
|
161
|
+
}
|
|
162
|
+
optionIndex = 0;
|
|
163
|
+
refresh();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function saveAnswer(questionId: string, value: string, label: string, wasCustom: boolean, index?: number) {
|
|
167
|
+
answers.set(questionId, { id: questionId, value, label, wasCustom, index });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Editor submit callback
|
|
171
|
+
editor.onSubmit = (value) => {
|
|
172
|
+
if (!inputQuestionId) return;
|
|
173
|
+
const trimmed = value.trim() || "(no response)";
|
|
174
|
+
saveAnswer(inputQuestionId, trimmed, trimmed, true);
|
|
175
|
+
inputMode = false;
|
|
176
|
+
inputQuestionId = null;
|
|
177
|
+
editor.setText("");
|
|
178
|
+
advanceAfterAnswer();
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
function handleInput(data: string) {
|
|
182
|
+
// Input mode: route to editor
|
|
183
|
+
if (inputMode) {
|
|
184
|
+
if (matchesKey(data, Key.escape)) {
|
|
185
|
+
inputMode = false;
|
|
186
|
+
inputQuestionId = null;
|
|
187
|
+
editor.setText("");
|
|
188
|
+
refresh();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
editor.handleInput(data);
|
|
192
|
+
refresh();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const q = currentQuestion();
|
|
197
|
+
const opts = currentOptions();
|
|
198
|
+
|
|
199
|
+
// Tab navigation (multi-question only)
|
|
200
|
+
if (isMulti) {
|
|
201
|
+
if (matchesKey(data, Key.tab) || matchesKey(data, Key.right)) {
|
|
202
|
+
currentTab = (currentTab + 1) % totalTabs;
|
|
203
|
+
optionIndex = 0;
|
|
204
|
+
refresh();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (matchesKey(data, Key.shift("tab")) || matchesKey(data, Key.left)) {
|
|
208
|
+
currentTab = (currentTab - 1 + totalTabs) % totalTabs;
|
|
209
|
+
optionIndex = 0;
|
|
210
|
+
refresh();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Submit tab
|
|
216
|
+
if (currentTab === questions.length) {
|
|
217
|
+
if (matchesKey(data, Key.enter) && allAnswered()) {
|
|
218
|
+
submit(false);
|
|
219
|
+
} else if (matchesKey(data, Key.escape)) {
|
|
220
|
+
submit(true);
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Option navigation
|
|
226
|
+
if (matchesKey(data, Key.up)) {
|
|
227
|
+
optionIndex = Math.max(0, optionIndex - 1);
|
|
228
|
+
refresh();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (matchesKey(data, Key.down)) {
|
|
232
|
+
optionIndex = Math.min(opts.length - 1, optionIndex + 1);
|
|
233
|
+
refresh();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Select option
|
|
238
|
+
if (matchesKey(data, Key.enter) && q) {
|
|
239
|
+
const opt = opts[optionIndex];
|
|
240
|
+
if (opt.isOther) {
|
|
241
|
+
inputMode = true;
|
|
242
|
+
inputQuestionId = q.id;
|
|
243
|
+
editor.setText("");
|
|
244
|
+
refresh();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
saveAnswer(q.id, opt.value, opt.label, false, optionIndex + 1);
|
|
248
|
+
advanceAfterAnswer();
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Cancel
|
|
253
|
+
if (matchesKey(data, Key.escape)) {
|
|
254
|
+
submit(true);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function render(width: number): string[] {
|
|
259
|
+
if (cachedLines) return cachedLines;
|
|
260
|
+
|
|
261
|
+
const lines: string[] = [];
|
|
262
|
+
const q = currentQuestion();
|
|
263
|
+
const opts = currentOptions();
|
|
264
|
+
|
|
265
|
+
// Helper to add truncated line
|
|
266
|
+
const add = (s: string) => lines.push(truncateToWidth(s, width));
|
|
267
|
+
|
|
268
|
+
add(theme.fg("accent", "─".repeat(width)));
|
|
269
|
+
|
|
270
|
+
// Tab bar (multi-question only)
|
|
271
|
+
if (isMulti) {
|
|
272
|
+
const tabs: string[] = ["← "];
|
|
273
|
+
for (let i = 0; i < questions.length; i++) {
|
|
274
|
+
const isActive = i === currentTab;
|
|
275
|
+
const isAnswered = answers.has(questions[i].id);
|
|
276
|
+
const lbl = questions[i].label;
|
|
277
|
+
const box = isAnswered ? "■" : "□";
|
|
278
|
+
const color = isAnswered ? "success" : "muted";
|
|
279
|
+
const text = ` ${box} ${lbl} `;
|
|
280
|
+
const styled = isActive ? theme.bg("selectedBg", theme.fg("text", text)) : theme.fg(color, text);
|
|
281
|
+
tabs.push(`${styled} `);
|
|
282
|
+
}
|
|
283
|
+
const canSubmit = allAnswered();
|
|
284
|
+
const isSubmitTab = currentTab === questions.length;
|
|
285
|
+
const submitText = " ✓ Submit ";
|
|
286
|
+
const submitStyled = isSubmitTab
|
|
287
|
+
? theme.bg("selectedBg", theme.fg("text", submitText))
|
|
288
|
+
: theme.fg(canSubmit ? "success" : "dim", submitText);
|
|
289
|
+
tabs.push(`${submitStyled} →`);
|
|
290
|
+
add(` ${tabs.join("")}`);
|
|
291
|
+
lines.push("");
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Helper to render options list
|
|
295
|
+
function renderOptions() {
|
|
296
|
+
for (let i = 0; i < opts.length; i++) {
|
|
297
|
+
const opt = opts[i];
|
|
298
|
+
const selected = i === optionIndex;
|
|
299
|
+
const isOther = opt.isOther === true;
|
|
300
|
+
const prefix = selected ? theme.fg("accent", "> ") : " ";
|
|
301
|
+
const color = selected ? "accent" : "text";
|
|
302
|
+
// Mark "Type something" differently when in input mode
|
|
303
|
+
if (isOther && inputMode) {
|
|
304
|
+
add(prefix + theme.fg("accent", `${i + 1}. ${opt.label} ✎`));
|
|
305
|
+
} else {
|
|
306
|
+
add(prefix + theme.fg(color, `${i + 1}. ${opt.label}`));
|
|
307
|
+
}
|
|
308
|
+
if (opt.description) {
|
|
309
|
+
add(` ${theme.fg("muted", opt.description)}`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Content
|
|
315
|
+
if (inputMode && q) {
|
|
316
|
+
add(theme.fg("text", ` ${q.prompt}`));
|
|
317
|
+
lines.push("");
|
|
318
|
+
// Show options for reference
|
|
319
|
+
renderOptions();
|
|
320
|
+
lines.push("");
|
|
321
|
+
add(theme.fg("muted", " Your answer:"));
|
|
322
|
+
for (const line of editor.render(width - 2)) {
|
|
323
|
+
add(` ${line}`);
|
|
324
|
+
}
|
|
325
|
+
lines.push("");
|
|
326
|
+
add(theme.fg("dim", " Enter to submit • Esc to cancel"));
|
|
327
|
+
} else if (currentTab === questions.length) {
|
|
328
|
+
add(theme.fg("accent", theme.bold(" Ready to submit")));
|
|
329
|
+
lines.push("");
|
|
330
|
+
for (const question of questions) {
|
|
331
|
+
const answer = answers.get(question.id);
|
|
332
|
+
if (answer) {
|
|
333
|
+
const prefix = answer.wasCustom ? "(wrote) " : "";
|
|
334
|
+
add(`${theme.fg("muted", ` ${question.label}: `)}${theme.fg("text", prefix + answer.label)}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
lines.push("");
|
|
338
|
+
if (allAnswered()) {
|
|
339
|
+
add(theme.fg("success", " Press Enter to submit"));
|
|
340
|
+
} else {
|
|
341
|
+
const missing = questions
|
|
342
|
+
.filter((q) => !answers.has(q.id))
|
|
343
|
+
.map((q) => q.label)
|
|
344
|
+
.join(", ");
|
|
345
|
+
add(theme.fg("warning", ` Unanswered: ${missing}`));
|
|
346
|
+
}
|
|
347
|
+
} else if (q) {
|
|
348
|
+
add(theme.fg("text", ` ${q.prompt}`));
|
|
349
|
+
lines.push("");
|
|
350
|
+
renderOptions();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
lines.push("");
|
|
354
|
+
if (!inputMode) {
|
|
355
|
+
const help = isMulti
|
|
356
|
+
? " Tab/←→ navigate • ↑↓ select • Enter confirm • Esc cancel"
|
|
357
|
+
: " ↑↓ navigate • Enter select • Esc cancel";
|
|
358
|
+
add(theme.fg("dim", help));
|
|
359
|
+
}
|
|
360
|
+
add(theme.fg("accent", "─".repeat(width)));
|
|
361
|
+
|
|
362
|
+
cachedLines = lines;
|
|
363
|
+
return lines;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return {
|
|
367
|
+
render,
|
|
368
|
+
invalidate: () => {
|
|
369
|
+
cachedLines = undefined;
|
|
370
|
+
},
|
|
371
|
+
handleInput,
|
|
372
|
+
};
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
if (result.cancelled) {
|
|
376
|
+
return {
|
|
377
|
+
content: [{ type: "text", text: "User cancelled the questionnaire" }],
|
|
378
|
+
details: result,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const answerLines = result.answers.map((a) => {
|
|
383
|
+
const qLabel = questions.find((q) => q.id === a.id)?.label || a.id;
|
|
384
|
+
if (a.wasCustom) {
|
|
385
|
+
return `${qLabel}: user wrote: ${a.label}`;
|
|
386
|
+
}
|
|
387
|
+
return `${qLabel}: user selected: ${a.index}. ${a.label}`;
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
content: [{ type: "text", text: answerLines.join("\n") }],
|
|
392
|
+
details: result,
|
|
393
|
+
};
|
|
394
|
+
},
|
|
395
|
+
|
|
396
|
+
renderCall(args, theme) {
|
|
397
|
+
const qs = (args.questions as Question[]) || [];
|
|
398
|
+
const count = qs.length;
|
|
399
|
+
const labels = qs.map((q) => q.label || q.id).join(", ");
|
|
400
|
+
let text = theme.fg("toolTitle", theme.bold("questionnaire "));
|
|
401
|
+
text += theme.fg("muted", `${count} question${count !== 1 ? "s" : ""}`);
|
|
402
|
+
if (labels) {
|
|
403
|
+
text += theme.fg("dim", ` (${truncateToWidth(labels, 40)})`);
|
|
404
|
+
}
|
|
405
|
+
return new Text(text, 0, 0);
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
renderResult(result, _options, theme) {
|
|
409
|
+
const details = result.details as QuestionnaireResult | undefined;
|
|
410
|
+
if (!details) {
|
|
411
|
+
const text = result.content[0];
|
|
412
|
+
return new Text(text?.type === "text" ? text.text : "", 0, 0);
|
|
413
|
+
}
|
|
414
|
+
if (details.cancelled) {
|
|
415
|
+
return new Text(theme.fg("warning", "Cancelled"), 0, 0);
|
|
416
|
+
}
|
|
417
|
+
const lines = details.answers.map((a) => {
|
|
418
|
+
if (a.wasCustom) {
|
|
419
|
+
return `${theme.fg("success", "✓ ")}${theme.fg("accent", a.id)}: ${theme.fg("muted", "(wrote) ")}${a.label}`;
|
|
420
|
+
}
|
|
421
|
+
const display = a.index ? `${a.index}. ${a.label}` : a.label;
|
|
422
|
+
return `${theme.fg("success", "✓ ")}${theme.fg("accent", a.id)}: ${display}`;
|
|
423
|
+
});
|
|
424
|
+
return new Text(lines.join("\n"), 0, 0);
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rainbow Editor - highlights "ultrathink" with animated shine effect
|
|
3
|
+
*
|
|
4
|
+
* Usage: pi --extension ./examples/extensions/rainbow-editor.ts
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { CustomEditor, type ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
8
|
+
|
|
9
|
+
// Base colors (coral → yellow → green → teal → blue → purple → pink)
|
|
10
|
+
const COLORS: [number, number, number][] = [
|
|
11
|
+
[233, 137, 115], // coral
|
|
12
|
+
[228, 186, 103], // yellow
|
|
13
|
+
[141, 192, 122], // green
|
|
14
|
+
[102, 194, 179], // teal
|
|
15
|
+
[121, 157, 207], // blue
|
|
16
|
+
[157, 134, 195], // purple
|
|
17
|
+
[206, 130, 172], // pink
|
|
18
|
+
];
|
|
19
|
+
const RESET = "\x1b[0m";
|
|
20
|
+
|
|
21
|
+
function brighten(rgb: [number, number, number], factor: number): string {
|
|
22
|
+
const [r, g, b] = rgb.map((c) => Math.round(c + (255 - c) * factor));
|
|
23
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function colorize(text: string, shinePos: number): string {
|
|
27
|
+
return (
|
|
28
|
+
[...text]
|
|
29
|
+
.map((c, i) => {
|
|
30
|
+
const baseColor = COLORS[i % COLORS.length]!;
|
|
31
|
+
// 3-letter shine: center bright, adjacent dimmer
|
|
32
|
+
let factor = 0;
|
|
33
|
+
if (shinePos >= 0) {
|
|
34
|
+
const dist = Math.abs(i - shinePos);
|
|
35
|
+
if (dist === 0) factor = 0.7;
|
|
36
|
+
else if (dist === 1) factor = 0.35;
|
|
37
|
+
}
|
|
38
|
+
return `${brighten(baseColor, factor)}${c}`;
|
|
39
|
+
})
|
|
40
|
+
.join("") + RESET
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class RainbowEditor extends CustomEditor {
|
|
45
|
+
private animationTimer?: ReturnType<typeof setInterval>;
|
|
46
|
+
private frame = 0;
|
|
47
|
+
|
|
48
|
+
private hasUltrathink(): boolean {
|
|
49
|
+
return /ultrathink/i.test(this.getText());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private startAnimation(): void {
|
|
53
|
+
if (this.animationTimer) return;
|
|
54
|
+
this.animationTimer = setInterval(() => {
|
|
55
|
+
this.frame++;
|
|
56
|
+
this.tui.requestRender();
|
|
57
|
+
}, 60);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private stopAnimation(): void {
|
|
61
|
+
if (this.animationTimer) {
|
|
62
|
+
clearInterval(this.animationTimer);
|
|
63
|
+
this.animationTimer = undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
handleInput(data: string): void {
|
|
68
|
+
super.handleInput(data);
|
|
69
|
+
if (this.hasUltrathink()) {
|
|
70
|
+
this.startAnimation();
|
|
71
|
+
} else {
|
|
72
|
+
this.stopAnimation();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
render(width: number): string[] {
|
|
77
|
+
// Cycle: 10 shine positions + 10 pause frames
|
|
78
|
+
const cycle = this.frame % 20;
|
|
79
|
+
const shinePos = cycle < 10 ? cycle : -1; // -1 means no shine (pause)
|
|
80
|
+
return super.render(width).map((line) => line.replace(/ultrathink/gi, (m) => colorize(m, shinePos)));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default function (pi: ExtensionAPI) {
|
|
85
|
+
pi.on("session_start", (_event, ctx) => {
|
|
86
|
+
ctx.ui.setEditorComponent((tui, theme, kb) => new RainbowEditor(tui, theme, kb));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Extension UI Demo
|
|
3
|
+
*
|
|
4
|
+
* Purpose-built extension that exercises all RPC-supported extension UI methods.
|
|
5
|
+
* Designed to be loaded alongside the rpc-extension-ui-example.ts script to
|
|
6
|
+
* demonstrate the full extension UI protocol.
|
|
7
|
+
*
|
|
8
|
+
* UI methods exercised:
|
|
9
|
+
* - select() - on tool_call for dangerous bash commands
|
|
10
|
+
* - confirm() - on session_before_switch
|
|
11
|
+
* - input() - via /rpc-input command
|
|
12
|
+
* - editor() - via /rpc-editor command
|
|
13
|
+
* - notify() - after each dialog completes
|
|
14
|
+
* - setStatus() - on turn_start/turn_end
|
|
15
|
+
* - setWidget() - on session_start
|
|
16
|
+
* - setTitle() - on session_start and session_switch
|
|
17
|
+
* - setEditorText() - via /rpc-prefill command
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
21
|
+
|
|
22
|
+
export default function (pi: ExtensionAPI) {
|
|
23
|
+
let turnCount = 0;
|
|
24
|
+
|
|
25
|
+
// -- setTitle, setWidget, setStatus on session lifecycle --
|
|
26
|
+
|
|
27
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
28
|
+
ctx.ui.setTitle("pi RPC Demo");
|
|
29
|
+
ctx.ui.setWidget("rpc-demo", ["--- RPC Extension UI Demo ---", "Loaded and ready."]);
|
|
30
|
+
ctx.ui.setStatus("rpc-demo", `Turns: ${turnCount}`);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
pi.on("session_switch", async (_event, ctx) => {
|
|
34
|
+
turnCount = 0;
|
|
35
|
+
ctx.ui.setTitle("pi RPC Demo (new session)");
|
|
36
|
+
ctx.ui.setStatus("rpc-demo", `Turns: ${turnCount}`);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// -- setStatus on turn lifecycle --
|
|
40
|
+
|
|
41
|
+
pi.on("turn_start", async (_event, ctx) => {
|
|
42
|
+
turnCount++;
|
|
43
|
+
ctx.ui.setStatus("rpc-demo", `Turn ${turnCount} running...`);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
pi.on("turn_end", async (_event, ctx) => {
|
|
47
|
+
ctx.ui.setStatus("rpc-demo", `Turn ${turnCount} done`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// -- select on dangerous tool calls --
|
|
51
|
+
|
|
52
|
+
pi.on("tool_call", async (event, ctx) => {
|
|
53
|
+
if (event.toolName !== "bash") return undefined;
|
|
54
|
+
|
|
55
|
+
const command = event.input.command as string;
|
|
56
|
+
const isDangerous = /\brm\s+(-rf?|--recursive)/i.test(command) || /\bsudo\b/i.test(command);
|
|
57
|
+
|
|
58
|
+
if (isDangerous) {
|
|
59
|
+
if (!ctx.hasUI) {
|
|
60
|
+
return { block: true, reason: "Dangerous command blocked (no UI)" };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const choice = await ctx.ui.select(`Dangerous command: ${command}`, ["Allow", "Block"]);
|
|
64
|
+
if (choice !== "Allow") {
|
|
65
|
+
ctx.ui.notify("Command blocked by user", "warning");
|
|
66
|
+
return { block: true, reason: "Blocked by user" };
|
|
67
|
+
}
|
|
68
|
+
ctx.ui.notify("Command allowed", "info");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return undefined;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// -- confirm on session clear --
|
|
75
|
+
|
|
76
|
+
pi.on("session_before_switch", async (event, ctx) => {
|
|
77
|
+
if (event.reason !== "new") return;
|
|
78
|
+
if (!ctx.hasUI) return;
|
|
79
|
+
|
|
80
|
+
const confirmed = await ctx.ui.confirm("Clear session?", "All messages will be lost.");
|
|
81
|
+
if (!confirmed) {
|
|
82
|
+
ctx.ui.notify("Clear cancelled", "info");
|
|
83
|
+
return { cancel: true };
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// -- input via command --
|
|
88
|
+
|
|
89
|
+
pi.registerCommand("rpc-input", {
|
|
90
|
+
description: "Prompt for text input (demonstrates ctx.ui.input in RPC)",
|
|
91
|
+
handler: async (_args, ctx) => {
|
|
92
|
+
const value = await ctx.ui.input("Enter a value", "type something...");
|
|
93
|
+
if (value) {
|
|
94
|
+
ctx.ui.notify(`You entered: ${value}`, "info");
|
|
95
|
+
} else {
|
|
96
|
+
ctx.ui.notify("Input cancelled", "info");
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// -- editor via command --
|
|
102
|
+
|
|
103
|
+
pi.registerCommand("rpc-editor", {
|
|
104
|
+
description: "Open multi-line editor (demonstrates ctx.ui.editor in RPC)",
|
|
105
|
+
handler: async (_args, ctx) => {
|
|
106
|
+
const text = await ctx.ui.editor("Edit some text", "Line 1\nLine 2\nLine 3");
|
|
107
|
+
if (text) {
|
|
108
|
+
ctx.ui.notify(`Editor submitted (${text.split("\n").length} lines)`, "info");
|
|
109
|
+
} else {
|
|
110
|
+
ctx.ui.notify("Editor cancelled", "info");
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// -- setEditorText via command --
|
|
116
|
+
|
|
117
|
+
pi.registerCommand("rpc-prefill", {
|
|
118
|
+
description: "Prefill the input editor (demonstrates ctx.ui.setEditorText in RPC)",
|
|
119
|
+
handler: async (_args, ctx) => {
|
|
120
|
+
ctx.ui.setEditorText("This text was set by the rpc-demo extension.");
|
|
121
|
+
ctx.ui.notify("Editor prefilled", "info");
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
}
|