@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,851 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { unlink } from "node:fs/promises";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import { Container, getEditorKeybindings, Input, matchesKey, Spacer, Text, truncateToWidth, visibleWidth, } from "@mariozechner/pi-tui";
|
|
6
|
+
import { KeybindingsManager } from "../../../core/keybindings.js";
|
|
7
|
+
import { theme } from "../theme/theme.js";
|
|
8
|
+
import { DynamicBorder } from "./dynamic-border.js";
|
|
9
|
+
import { appKey, appKeyHint, keyHint } from "./keybinding-hints.js";
|
|
10
|
+
import { filterAndSortSessions, hasSessionName } from "./session-selector-search.js";
|
|
11
|
+
function shortenPath(path) {
|
|
12
|
+
const home = os.homedir();
|
|
13
|
+
if (!path)
|
|
14
|
+
return path;
|
|
15
|
+
if (path.startsWith(home)) {
|
|
16
|
+
return `~${path.slice(home.length)}`;
|
|
17
|
+
}
|
|
18
|
+
return path;
|
|
19
|
+
}
|
|
20
|
+
function formatSessionDate(date) {
|
|
21
|
+
const now = new Date();
|
|
22
|
+
const diffMs = now.getTime() - date.getTime();
|
|
23
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
24
|
+
const diffHours = Math.floor(diffMs / 3600000);
|
|
25
|
+
const diffDays = Math.floor(diffMs / 86400000);
|
|
26
|
+
if (diffMins < 1)
|
|
27
|
+
return "now";
|
|
28
|
+
if (diffMins < 60)
|
|
29
|
+
return `${diffMins}m`;
|
|
30
|
+
if (diffHours < 24)
|
|
31
|
+
return `${diffHours}h`;
|
|
32
|
+
if (diffDays < 7)
|
|
33
|
+
return `${diffDays}d`;
|
|
34
|
+
if (diffDays < 30)
|
|
35
|
+
return `${Math.floor(diffDays / 7)}w`;
|
|
36
|
+
if (diffDays < 365)
|
|
37
|
+
return `${Math.floor(diffDays / 30)}mo`;
|
|
38
|
+
return `${Math.floor(diffDays / 365)}y`;
|
|
39
|
+
}
|
|
40
|
+
class SessionSelectorHeader {
|
|
41
|
+
scope;
|
|
42
|
+
sortMode;
|
|
43
|
+
nameFilter;
|
|
44
|
+
keybindings;
|
|
45
|
+
requestRender;
|
|
46
|
+
loading = false;
|
|
47
|
+
loadProgress = null;
|
|
48
|
+
showPath = false;
|
|
49
|
+
confirmingDeletePath = null;
|
|
50
|
+
statusMessage = null;
|
|
51
|
+
statusTimeout = null;
|
|
52
|
+
showRenameHint = false;
|
|
53
|
+
constructor(scope, sortMode, nameFilter, keybindings, requestRender) {
|
|
54
|
+
this.scope = scope;
|
|
55
|
+
this.sortMode = sortMode;
|
|
56
|
+
this.nameFilter = nameFilter;
|
|
57
|
+
this.keybindings = keybindings;
|
|
58
|
+
this.requestRender = requestRender;
|
|
59
|
+
}
|
|
60
|
+
setScope(scope) {
|
|
61
|
+
this.scope = scope;
|
|
62
|
+
}
|
|
63
|
+
setSortMode(sortMode) {
|
|
64
|
+
this.sortMode = sortMode;
|
|
65
|
+
}
|
|
66
|
+
setNameFilter(nameFilter) {
|
|
67
|
+
this.nameFilter = nameFilter;
|
|
68
|
+
}
|
|
69
|
+
setLoading(loading) {
|
|
70
|
+
this.loading = loading;
|
|
71
|
+
// Progress is scoped to the current load; clear whenever the loading state is set
|
|
72
|
+
this.loadProgress = null;
|
|
73
|
+
}
|
|
74
|
+
setProgress(loaded, total) {
|
|
75
|
+
this.loadProgress = { loaded, total };
|
|
76
|
+
}
|
|
77
|
+
setShowPath(showPath) {
|
|
78
|
+
this.showPath = showPath;
|
|
79
|
+
}
|
|
80
|
+
setShowRenameHint(show) {
|
|
81
|
+
this.showRenameHint = show;
|
|
82
|
+
}
|
|
83
|
+
setConfirmingDeletePath(path) {
|
|
84
|
+
this.confirmingDeletePath = path;
|
|
85
|
+
}
|
|
86
|
+
clearStatusTimeout() {
|
|
87
|
+
if (!this.statusTimeout)
|
|
88
|
+
return;
|
|
89
|
+
clearTimeout(this.statusTimeout);
|
|
90
|
+
this.statusTimeout = null;
|
|
91
|
+
}
|
|
92
|
+
setStatusMessage(msg, autoHideMs) {
|
|
93
|
+
this.clearStatusTimeout();
|
|
94
|
+
this.statusMessage = msg;
|
|
95
|
+
if (!msg || !autoHideMs)
|
|
96
|
+
return;
|
|
97
|
+
this.statusTimeout = setTimeout(() => {
|
|
98
|
+
this.statusMessage = null;
|
|
99
|
+
this.statusTimeout = null;
|
|
100
|
+
this.requestRender();
|
|
101
|
+
}, autoHideMs);
|
|
102
|
+
}
|
|
103
|
+
invalidate() { }
|
|
104
|
+
render(width) {
|
|
105
|
+
const title = this.scope === "current" ? "Resume Session (Current Folder)" : "Resume Session (All)";
|
|
106
|
+
const leftText = theme.bold(title);
|
|
107
|
+
const sortLabel = this.sortMode === "threaded" ? "Threaded" : this.sortMode === "recent" ? "Recent" : "Fuzzy";
|
|
108
|
+
const sortText = theme.fg("muted", "Sort: ") + theme.fg("accent", sortLabel);
|
|
109
|
+
const nameLabel = this.nameFilter === "all" ? "All" : "Named";
|
|
110
|
+
const nameText = theme.fg("muted", "Name: ") + theme.fg("accent", nameLabel);
|
|
111
|
+
let scopeText;
|
|
112
|
+
if (this.loading) {
|
|
113
|
+
const progressText = this.loadProgress ? `${this.loadProgress.loaded}/${this.loadProgress.total}` : "...";
|
|
114
|
+
scopeText = `${theme.fg("muted", "○ Current Folder | ")}${theme.fg("accent", `Loading ${progressText}`)}`;
|
|
115
|
+
}
|
|
116
|
+
else if (this.scope === "current") {
|
|
117
|
+
scopeText = `${theme.fg("accent", "◉ Current Folder")}${theme.fg("muted", " | ○ All")}`;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
scopeText = `${theme.fg("muted", "○ Current Folder | ")}${theme.fg("accent", "◉ All")}`;
|
|
121
|
+
}
|
|
122
|
+
const rightText = truncateToWidth(`${scopeText} ${nameText} ${sortText}`, width, "");
|
|
123
|
+
const availableLeft = Math.max(0, width - visibleWidth(rightText) - 1);
|
|
124
|
+
const left = truncateToWidth(leftText, availableLeft, "");
|
|
125
|
+
const spacing = Math.max(0, width - visibleWidth(left) - visibleWidth(rightText));
|
|
126
|
+
// Build hint lines - changes based on state (all branches truncate to width)
|
|
127
|
+
let hintLine1;
|
|
128
|
+
let hintLine2;
|
|
129
|
+
if (this.confirmingDeletePath !== null) {
|
|
130
|
+
const confirmHint = "Delete session? [Enter] confirm · [Esc/Ctrl+C] cancel";
|
|
131
|
+
hintLine1 = theme.fg("error", truncateToWidth(confirmHint, width, "…"));
|
|
132
|
+
hintLine2 = "";
|
|
133
|
+
}
|
|
134
|
+
else if (this.statusMessage) {
|
|
135
|
+
const color = this.statusMessage.type === "error" ? "error" : "accent";
|
|
136
|
+
hintLine1 = theme.fg(color, truncateToWidth(this.statusMessage.message, width, "…"));
|
|
137
|
+
hintLine2 = "";
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
const pathState = this.showPath ? "(on)" : "(off)";
|
|
141
|
+
const sep = theme.fg("muted", " · ");
|
|
142
|
+
const hint1 = keyHint("tab", "scope") + sep + theme.fg("muted", 're:<pattern> regex · "phrase" exact');
|
|
143
|
+
const hint2Parts = [
|
|
144
|
+
keyHint("toggleSessionSort", "sort"),
|
|
145
|
+
appKeyHint(this.keybindings, "toggleSessionNamedFilter", "named"),
|
|
146
|
+
keyHint("deleteSession", "delete"),
|
|
147
|
+
keyHint("toggleSessionPath", `path ${pathState}`),
|
|
148
|
+
];
|
|
149
|
+
if (this.showRenameHint) {
|
|
150
|
+
hint2Parts.push(keyHint("renameSession", "rename"));
|
|
151
|
+
}
|
|
152
|
+
const hint2 = hint2Parts.join(sep);
|
|
153
|
+
hintLine1 = truncateToWidth(hint1, width, "…");
|
|
154
|
+
hintLine2 = truncateToWidth(hint2, width, "…");
|
|
155
|
+
}
|
|
156
|
+
return [`${left}${" ".repeat(spacing)}${rightText}`, hintLine1, hintLine2];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Build a tree structure from sessions based on parentSessionPath.
|
|
161
|
+
* Returns root nodes sorted by modified date (descending).
|
|
162
|
+
*/
|
|
163
|
+
function buildSessionTree(sessions) {
|
|
164
|
+
const byPath = new Map();
|
|
165
|
+
for (const session of sessions) {
|
|
166
|
+
byPath.set(session.path, { session, children: [] });
|
|
167
|
+
}
|
|
168
|
+
const roots = [];
|
|
169
|
+
for (const session of sessions) {
|
|
170
|
+
const node = byPath.get(session.path);
|
|
171
|
+
const parentPath = session.parentSessionPath;
|
|
172
|
+
if (parentPath && byPath.has(parentPath)) {
|
|
173
|
+
byPath.get(parentPath).children.push(node);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
roots.push(node);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Sort children and roots by modified date (descending)
|
|
180
|
+
const sortNodes = (nodes) => {
|
|
181
|
+
nodes.sort((a, b) => b.session.modified.getTime() - a.session.modified.getTime());
|
|
182
|
+
for (const node of nodes) {
|
|
183
|
+
sortNodes(node.children);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
sortNodes(roots);
|
|
187
|
+
return roots;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Flatten tree into display list with tree structure metadata.
|
|
191
|
+
*/
|
|
192
|
+
function flattenSessionTree(roots) {
|
|
193
|
+
const result = [];
|
|
194
|
+
const walk = (node, depth, ancestorContinues, isLast) => {
|
|
195
|
+
result.push({ session: node.session, depth, isLast, ancestorContinues });
|
|
196
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
197
|
+
const childIsLast = i === node.children.length - 1;
|
|
198
|
+
// Only show continuation line for non-root ancestors
|
|
199
|
+
const continues = depth > 0 ? !isLast : false;
|
|
200
|
+
walk(node.children[i], depth + 1, [...ancestorContinues, continues], childIsLast);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
for (let i = 0; i < roots.length; i++) {
|
|
204
|
+
walk(roots[i], 0, [], i === roots.length - 1);
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Custom session list component with multi-line items and search
|
|
210
|
+
*/
|
|
211
|
+
class SessionList {
|
|
212
|
+
getSelectedSessionPath() {
|
|
213
|
+
const selected = this.filteredSessions[this.selectedIndex];
|
|
214
|
+
return selected?.session.path;
|
|
215
|
+
}
|
|
216
|
+
allSessions = [];
|
|
217
|
+
filteredSessions = [];
|
|
218
|
+
selectedIndex = 0;
|
|
219
|
+
searchInput;
|
|
220
|
+
showCwd = false;
|
|
221
|
+
sortMode = "threaded";
|
|
222
|
+
nameFilter = "all";
|
|
223
|
+
keybindings;
|
|
224
|
+
showPath = false;
|
|
225
|
+
confirmingDeletePath = null;
|
|
226
|
+
currentSessionFilePath;
|
|
227
|
+
onSelect;
|
|
228
|
+
onCancel;
|
|
229
|
+
onExit = () => { };
|
|
230
|
+
onToggleScope;
|
|
231
|
+
onToggleSort;
|
|
232
|
+
onToggleNameFilter;
|
|
233
|
+
onTogglePath;
|
|
234
|
+
onDeleteConfirmationChange;
|
|
235
|
+
onDeleteSession;
|
|
236
|
+
onRenameSession;
|
|
237
|
+
onError;
|
|
238
|
+
maxVisible = 10; // Max sessions visible (one line each)
|
|
239
|
+
// Focusable implementation - propagate to searchInput for IME cursor positioning
|
|
240
|
+
_focused = false;
|
|
241
|
+
get focused() {
|
|
242
|
+
return this._focused;
|
|
243
|
+
}
|
|
244
|
+
set focused(value) {
|
|
245
|
+
this._focused = value;
|
|
246
|
+
this.searchInput.focused = value;
|
|
247
|
+
}
|
|
248
|
+
constructor(sessions, showCwd, sortMode, nameFilter, keybindings, currentSessionFilePath) {
|
|
249
|
+
this.allSessions = sessions;
|
|
250
|
+
this.filteredSessions = [];
|
|
251
|
+
this.searchInput = new Input();
|
|
252
|
+
this.showCwd = showCwd;
|
|
253
|
+
this.sortMode = sortMode;
|
|
254
|
+
this.nameFilter = nameFilter;
|
|
255
|
+
this.keybindings = keybindings;
|
|
256
|
+
this.currentSessionFilePath = currentSessionFilePath;
|
|
257
|
+
this.filterSessions("");
|
|
258
|
+
// Handle Enter in search input - select current item
|
|
259
|
+
this.searchInput.onSubmit = () => {
|
|
260
|
+
if (this.filteredSessions[this.selectedIndex]) {
|
|
261
|
+
const selected = this.filteredSessions[this.selectedIndex];
|
|
262
|
+
if (this.onSelect) {
|
|
263
|
+
this.onSelect(selected.session.path);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
setSortMode(sortMode) {
|
|
269
|
+
this.sortMode = sortMode;
|
|
270
|
+
this.filterSessions(this.searchInput.getValue());
|
|
271
|
+
}
|
|
272
|
+
setNameFilter(nameFilter) {
|
|
273
|
+
this.nameFilter = nameFilter;
|
|
274
|
+
this.filterSessions(this.searchInput.getValue());
|
|
275
|
+
}
|
|
276
|
+
setSessions(sessions, showCwd) {
|
|
277
|
+
this.allSessions = sessions;
|
|
278
|
+
this.showCwd = showCwd;
|
|
279
|
+
this.filterSessions(this.searchInput.getValue());
|
|
280
|
+
}
|
|
281
|
+
filterSessions(query) {
|
|
282
|
+
const trimmed = query.trim();
|
|
283
|
+
const nameFiltered = this.nameFilter === "all" ? this.allSessions : this.allSessions.filter((session) => hasSessionName(session));
|
|
284
|
+
if (this.sortMode === "threaded" && !trimmed) {
|
|
285
|
+
// Threaded mode without search: show tree structure
|
|
286
|
+
const roots = buildSessionTree(nameFiltered);
|
|
287
|
+
this.filteredSessions = flattenSessionTree(roots);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
// Other modes or with search: flat list
|
|
291
|
+
const filtered = filterAndSortSessions(nameFiltered, query, this.sortMode, "all");
|
|
292
|
+
this.filteredSessions = filtered.map((session) => ({
|
|
293
|
+
session,
|
|
294
|
+
depth: 0,
|
|
295
|
+
isLast: true,
|
|
296
|
+
ancestorContinues: [],
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
this.selectedIndex = Math.min(this.selectedIndex, Math.max(0, this.filteredSessions.length - 1));
|
|
300
|
+
}
|
|
301
|
+
setConfirmingDeletePath(path) {
|
|
302
|
+
this.confirmingDeletePath = path;
|
|
303
|
+
this.onDeleteConfirmationChange?.(path);
|
|
304
|
+
}
|
|
305
|
+
startDeleteConfirmationForSelectedSession() {
|
|
306
|
+
const selected = this.filteredSessions[this.selectedIndex];
|
|
307
|
+
if (!selected)
|
|
308
|
+
return;
|
|
309
|
+
// Prevent deleting current session
|
|
310
|
+
if (this.currentSessionFilePath && selected.session.path === this.currentSessionFilePath) {
|
|
311
|
+
this.onError?.("Cannot delete the currently active session");
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
this.setConfirmingDeletePath(selected.session.path);
|
|
315
|
+
}
|
|
316
|
+
invalidate() { }
|
|
317
|
+
render(width) {
|
|
318
|
+
const lines = [];
|
|
319
|
+
// Render search input
|
|
320
|
+
lines.push(...this.searchInput.render(width));
|
|
321
|
+
lines.push(""); // Blank line after search
|
|
322
|
+
if (this.filteredSessions.length === 0) {
|
|
323
|
+
let emptyMessage;
|
|
324
|
+
if (this.nameFilter === "named") {
|
|
325
|
+
const toggleKey = appKey(this.keybindings, "toggleSessionNamedFilter");
|
|
326
|
+
if (this.showCwd) {
|
|
327
|
+
emptyMessage = ` No named sessions found. Press ${toggleKey} to show all.`;
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
emptyMessage = ` No named sessions in current folder. Press ${toggleKey} to show all, or Tab to view all.`;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else if (this.showCwd) {
|
|
334
|
+
// "All" scope - no sessions anywhere that match filter
|
|
335
|
+
emptyMessage = " No sessions found";
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
// "Current folder" scope - hint to try "all"
|
|
339
|
+
emptyMessage = " No sessions in current folder. Press Tab to view all.";
|
|
340
|
+
}
|
|
341
|
+
lines.push(theme.fg("muted", truncateToWidth(emptyMessage, width, "…")));
|
|
342
|
+
return lines;
|
|
343
|
+
}
|
|
344
|
+
// Calculate visible range with scrolling
|
|
345
|
+
const startIndex = Math.max(0, Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredSessions.length - this.maxVisible));
|
|
346
|
+
const endIndex = Math.min(startIndex + this.maxVisible, this.filteredSessions.length);
|
|
347
|
+
// Render visible sessions (one line each with tree structure)
|
|
348
|
+
for (let i = startIndex; i < endIndex; i++) {
|
|
349
|
+
const node = this.filteredSessions[i];
|
|
350
|
+
const session = node.session;
|
|
351
|
+
const isSelected = i === this.selectedIndex;
|
|
352
|
+
const isConfirmingDelete = session.path === this.confirmingDeletePath;
|
|
353
|
+
const isCurrent = this.currentSessionFilePath === session.path;
|
|
354
|
+
// Build tree prefix
|
|
355
|
+
const prefix = this.buildTreePrefix(node);
|
|
356
|
+
// Session display text (name or first message)
|
|
357
|
+
const hasName = !!session.name;
|
|
358
|
+
const displayText = session.name ?? session.firstMessage;
|
|
359
|
+
const normalizedMessage = displayText.replace(/\n/g, " ").trim();
|
|
360
|
+
// Right side: message count and age
|
|
361
|
+
const age = formatSessionDate(session.modified);
|
|
362
|
+
const msgCount = String(session.messageCount);
|
|
363
|
+
let rightPart = `${msgCount} ${age}`;
|
|
364
|
+
if (this.showCwd && session.cwd) {
|
|
365
|
+
rightPart = `${shortenPath(session.cwd)} ${rightPart}`;
|
|
366
|
+
}
|
|
367
|
+
if (this.showPath) {
|
|
368
|
+
rightPart = `${shortenPath(session.path)} ${rightPart}`;
|
|
369
|
+
}
|
|
370
|
+
// Cursor
|
|
371
|
+
const cursor = isSelected ? theme.fg("accent", "› ") : " ";
|
|
372
|
+
// Calculate available width for message
|
|
373
|
+
const prefixWidth = visibleWidth(prefix);
|
|
374
|
+
const rightWidth = visibleWidth(rightPart) + 2; // +2 for spacing
|
|
375
|
+
const availableForMsg = width - 2 - prefixWidth - rightWidth; // -2 for cursor
|
|
376
|
+
const truncatedMsg = truncateToWidth(normalizedMessage, Math.max(10, availableForMsg), "…");
|
|
377
|
+
// Style message
|
|
378
|
+
let messageColor = null;
|
|
379
|
+
if (isConfirmingDelete) {
|
|
380
|
+
messageColor = "error";
|
|
381
|
+
}
|
|
382
|
+
else if (isCurrent) {
|
|
383
|
+
messageColor = "accent";
|
|
384
|
+
}
|
|
385
|
+
else if (hasName) {
|
|
386
|
+
messageColor = "warning";
|
|
387
|
+
}
|
|
388
|
+
let styledMsg = messageColor ? theme.fg(messageColor, truncatedMsg) : truncatedMsg;
|
|
389
|
+
if (isSelected) {
|
|
390
|
+
styledMsg = theme.bold(styledMsg);
|
|
391
|
+
}
|
|
392
|
+
// Build line
|
|
393
|
+
const leftPart = cursor + theme.fg("dim", prefix) + styledMsg;
|
|
394
|
+
const leftWidth = visibleWidth(leftPart);
|
|
395
|
+
const spacing = Math.max(1, width - leftWidth - visibleWidth(rightPart));
|
|
396
|
+
const styledRight = theme.fg(isConfirmingDelete ? "error" : "dim", rightPart);
|
|
397
|
+
let line = leftPart + " ".repeat(spacing) + styledRight;
|
|
398
|
+
if (isSelected) {
|
|
399
|
+
line = theme.bg("selectedBg", line);
|
|
400
|
+
}
|
|
401
|
+
lines.push(truncateToWidth(line, width));
|
|
402
|
+
}
|
|
403
|
+
// Add scroll indicator if needed
|
|
404
|
+
if (startIndex > 0 || endIndex < this.filteredSessions.length) {
|
|
405
|
+
const scrollText = ` (${this.selectedIndex + 1}/${this.filteredSessions.length})`;
|
|
406
|
+
const scrollInfo = theme.fg("muted", truncateToWidth(scrollText, width, ""));
|
|
407
|
+
lines.push(scrollInfo);
|
|
408
|
+
}
|
|
409
|
+
return lines;
|
|
410
|
+
}
|
|
411
|
+
buildTreePrefix(node) {
|
|
412
|
+
if (node.depth === 0) {
|
|
413
|
+
return "";
|
|
414
|
+
}
|
|
415
|
+
const parts = node.ancestorContinues.map((continues) => (continues ? "│ " : " "));
|
|
416
|
+
const branch = node.isLast ? "└─ " : "├─ ";
|
|
417
|
+
return parts.join("") + branch;
|
|
418
|
+
}
|
|
419
|
+
handleInput(keyData) {
|
|
420
|
+
const kb = getEditorKeybindings();
|
|
421
|
+
// Handle delete confirmation state first - intercept all keys
|
|
422
|
+
if (this.confirmingDeletePath !== null) {
|
|
423
|
+
if (kb.matches(keyData, "selectConfirm")) {
|
|
424
|
+
const pathToDelete = this.confirmingDeletePath;
|
|
425
|
+
this.setConfirmingDeletePath(null);
|
|
426
|
+
void this.onDeleteSession?.(pathToDelete);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
// Allow both Escape and Ctrl+C to cancel (consistent with pi UX)
|
|
430
|
+
if (kb.matches(keyData, "selectCancel") || matchesKey(keyData, "ctrl+c")) {
|
|
431
|
+
this.setConfirmingDeletePath(null);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
// Ignore all other keys while confirming
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (kb.matches(keyData, "tab")) {
|
|
438
|
+
if (this.onToggleScope) {
|
|
439
|
+
this.onToggleScope();
|
|
440
|
+
}
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (kb.matches(keyData, "toggleSessionSort")) {
|
|
444
|
+
this.onToggleSort?.();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (this.keybindings.matches(keyData, "toggleSessionNamedFilter")) {
|
|
448
|
+
this.onToggleNameFilter?.();
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
// Ctrl+P: toggle path display
|
|
452
|
+
if (kb.matches(keyData, "toggleSessionPath")) {
|
|
453
|
+
this.showPath = !this.showPath;
|
|
454
|
+
this.onTogglePath?.(this.showPath);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
// Ctrl+D: initiate delete confirmation (useful on terminals that don't distinguish Ctrl+Backspace from Backspace)
|
|
458
|
+
if (kb.matches(keyData, "deleteSession")) {
|
|
459
|
+
this.startDeleteConfirmationForSelectedSession();
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
// Ctrl+R: rename selected session
|
|
463
|
+
if (matchesKey(keyData, "ctrl+r")) {
|
|
464
|
+
const selected = this.filteredSessions[this.selectedIndex];
|
|
465
|
+
if (selected) {
|
|
466
|
+
this.onRenameSession?.(selected.session.path);
|
|
467
|
+
}
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
// Ctrl+Backspace: non-invasive convenience alias for delete
|
|
471
|
+
// Only triggers deletion when the query is empty; otherwise it is forwarded to the input
|
|
472
|
+
if (kb.matches(keyData, "deleteSessionNoninvasive")) {
|
|
473
|
+
if (this.searchInput.getValue().length > 0) {
|
|
474
|
+
this.searchInput.handleInput(keyData);
|
|
475
|
+
this.filterSessions(this.searchInput.getValue());
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
this.startDeleteConfirmationForSelectedSession();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
// Up arrow
|
|
482
|
+
if (kb.matches(keyData, "selectUp")) {
|
|
483
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - 1);
|
|
484
|
+
}
|
|
485
|
+
// Down arrow
|
|
486
|
+
else if (kb.matches(keyData, "selectDown")) {
|
|
487
|
+
this.selectedIndex = Math.min(this.filteredSessions.length - 1, this.selectedIndex + 1);
|
|
488
|
+
}
|
|
489
|
+
// Page up - jump up by maxVisible items
|
|
490
|
+
else if (kb.matches(keyData, "selectPageUp")) {
|
|
491
|
+
this.selectedIndex = Math.max(0, this.selectedIndex - this.maxVisible);
|
|
492
|
+
}
|
|
493
|
+
// Page down - jump down by maxVisible items
|
|
494
|
+
else if (kb.matches(keyData, "selectPageDown")) {
|
|
495
|
+
this.selectedIndex = Math.min(this.filteredSessions.length - 1, this.selectedIndex + this.maxVisible);
|
|
496
|
+
}
|
|
497
|
+
// Enter
|
|
498
|
+
else if (kb.matches(keyData, "selectConfirm")) {
|
|
499
|
+
const selected = this.filteredSessions[this.selectedIndex];
|
|
500
|
+
if (selected && this.onSelect) {
|
|
501
|
+
this.onSelect(selected.session.path);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
// Escape - cancel
|
|
505
|
+
else if (kb.matches(keyData, "selectCancel")) {
|
|
506
|
+
if (this.onCancel) {
|
|
507
|
+
this.onCancel();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
// Pass everything else to search input
|
|
511
|
+
else {
|
|
512
|
+
this.searchInput.handleInput(keyData);
|
|
513
|
+
this.filterSessions(this.searchInput.getValue());
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Delete a session file, trying the `trash` CLI first, then falling back to unlink
|
|
519
|
+
*/
|
|
520
|
+
async function deleteSessionFile(sessionPath) {
|
|
521
|
+
// Try `trash` first (if installed)
|
|
522
|
+
const trashArgs = sessionPath.startsWith("-") ? ["--", sessionPath] : [sessionPath];
|
|
523
|
+
const trashResult = spawnSync("trash", trashArgs, { encoding: "utf-8" });
|
|
524
|
+
const getTrashErrorHint = () => {
|
|
525
|
+
const parts = [];
|
|
526
|
+
if (trashResult.error) {
|
|
527
|
+
parts.push(trashResult.error.message);
|
|
528
|
+
}
|
|
529
|
+
const stderr = trashResult.stderr?.trim();
|
|
530
|
+
if (stderr) {
|
|
531
|
+
parts.push(stderr.split("\n")[0] ?? stderr);
|
|
532
|
+
}
|
|
533
|
+
if (parts.length === 0)
|
|
534
|
+
return null;
|
|
535
|
+
return `trash: ${parts.join(" · ").slice(0, 200)}`;
|
|
536
|
+
};
|
|
537
|
+
// If trash reports success, or the file is gone afterwards, treat it as successful
|
|
538
|
+
if (trashResult.status === 0 || !existsSync(sessionPath)) {
|
|
539
|
+
return { ok: true, method: "trash" };
|
|
540
|
+
}
|
|
541
|
+
// Fallback to permanent deletion
|
|
542
|
+
try {
|
|
543
|
+
await unlink(sessionPath);
|
|
544
|
+
return { ok: true, method: "unlink" };
|
|
545
|
+
}
|
|
546
|
+
catch (err) {
|
|
547
|
+
const unlinkError = err instanceof Error ? err.message : String(err);
|
|
548
|
+
const trashErrorHint = getTrashErrorHint();
|
|
549
|
+
const error = trashErrorHint ? `${unlinkError} (${trashErrorHint})` : unlinkError;
|
|
550
|
+
return { ok: false, method: "unlink", error };
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Component that renders a session selector
|
|
555
|
+
*/
|
|
556
|
+
export class SessionSelectorComponent extends Container {
|
|
557
|
+
handleInput(data) {
|
|
558
|
+
if (this.mode === "rename") {
|
|
559
|
+
const kb = getEditorKeybindings();
|
|
560
|
+
if (kb.matches(data, "selectCancel") || matchesKey(data, "ctrl+c")) {
|
|
561
|
+
this.exitRenameMode();
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
this.renameInput.handleInput(data);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
this.sessionList.handleInput(data);
|
|
568
|
+
}
|
|
569
|
+
canRename = true;
|
|
570
|
+
sessionList;
|
|
571
|
+
header;
|
|
572
|
+
keybindings;
|
|
573
|
+
scope = "current";
|
|
574
|
+
sortMode = "threaded";
|
|
575
|
+
nameFilter = "all";
|
|
576
|
+
currentSessions = null;
|
|
577
|
+
allSessions = null;
|
|
578
|
+
currentSessionsLoader;
|
|
579
|
+
allSessionsLoader;
|
|
580
|
+
onCancel;
|
|
581
|
+
requestRender;
|
|
582
|
+
renameSession;
|
|
583
|
+
currentLoading = false;
|
|
584
|
+
allLoading = false;
|
|
585
|
+
allLoadSeq = 0;
|
|
586
|
+
mode = "list";
|
|
587
|
+
renameInput = new Input();
|
|
588
|
+
renameTargetPath = null;
|
|
589
|
+
// Focusable implementation - propagate to sessionList for IME cursor positioning
|
|
590
|
+
_focused = false;
|
|
591
|
+
get focused() {
|
|
592
|
+
return this._focused;
|
|
593
|
+
}
|
|
594
|
+
set focused(value) {
|
|
595
|
+
this._focused = value;
|
|
596
|
+
this.sessionList.focused = value;
|
|
597
|
+
this.renameInput.focused = value;
|
|
598
|
+
if (value && this.mode === "rename") {
|
|
599
|
+
this.renameInput.focused = true;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
buildBaseLayout(content, options) {
|
|
603
|
+
this.clear();
|
|
604
|
+
this.addChild(new Spacer(1));
|
|
605
|
+
this.addChild(new DynamicBorder((s) => theme.fg("accent", s)));
|
|
606
|
+
this.addChild(new Spacer(1));
|
|
607
|
+
if (options?.showHeader ?? true) {
|
|
608
|
+
this.addChild(this.header);
|
|
609
|
+
this.addChild(new Spacer(1));
|
|
610
|
+
}
|
|
611
|
+
this.addChild(content);
|
|
612
|
+
this.addChild(new Spacer(1));
|
|
613
|
+
this.addChild(new DynamicBorder((s) => theme.fg("accent", s)));
|
|
614
|
+
}
|
|
615
|
+
constructor(currentSessionsLoader, allSessionsLoader, onSelect, onCancel, onExit, requestRender, options, currentSessionFilePath) {
|
|
616
|
+
super();
|
|
617
|
+
this.keybindings = options?.keybindings ?? KeybindingsManager.create();
|
|
618
|
+
this.currentSessionsLoader = currentSessionsLoader;
|
|
619
|
+
this.allSessionsLoader = allSessionsLoader;
|
|
620
|
+
this.onCancel = onCancel;
|
|
621
|
+
this.requestRender = requestRender;
|
|
622
|
+
this.header = new SessionSelectorHeader(this.scope, this.sortMode, this.nameFilter, this.keybindings, this.requestRender);
|
|
623
|
+
const renameSession = options?.renameSession;
|
|
624
|
+
this.renameSession = renameSession;
|
|
625
|
+
this.canRename = !!renameSession;
|
|
626
|
+
this.header.setShowRenameHint(options?.showRenameHint ?? this.canRename);
|
|
627
|
+
// Create session list (starts empty, will be populated after load)
|
|
628
|
+
this.sessionList = new SessionList([], false, this.sortMode, this.nameFilter, this.keybindings, currentSessionFilePath);
|
|
629
|
+
this.buildBaseLayout(this.sessionList);
|
|
630
|
+
this.renameInput.onSubmit = (value) => {
|
|
631
|
+
void this.confirmRename(value);
|
|
632
|
+
};
|
|
633
|
+
// Ensure header status timeouts are cleared when leaving the selector
|
|
634
|
+
const clearStatusMessage = () => this.header.setStatusMessage(null);
|
|
635
|
+
this.sessionList.onSelect = (sessionPath) => {
|
|
636
|
+
clearStatusMessage();
|
|
637
|
+
onSelect(sessionPath);
|
|
638
|
+
};
|
|
639
|
+
this.sessionList.onCancel = () => {
|
|
640
|
+
clearStatusMessage();
|
|
641
|
+
onCancel();
|
|
642
|
+
};
|
|
643
|
+
this.sessionList.onExit = () => {
|
|
644
|
+
clearStatusMessage();
|
|
645
|
+
onExit();
|
|
646
|
+
};
|
|
647
|
+
this.sessionList.onToggleScope = () => this.toggleScope();
|
|
648
|
+
this.sessionList.onToggleSort = () => this.toggleSortMode();
|
|
649
|
+
this.sessionList.onToggleNameFilter = () => this.toggleNameFilter();
|
|
650
|
+
this.sessionList.onRenameSession = (sessionPath) => {
|
|
651
|
+
if (!renameSession)
|
|
652
|
+
return;
|
|
653
|
+
if (this.scope === "current" && this.currentLoading)
|
|
654
|
+
return;
|
|
655
|
+
if (this.scope === "all" && this.allLoading)
|
|
656
|
+
return;
|
|
657
|
+
const sessions = this.scope === "all" ? (this.allSessions ?? []) : (this.currentSessions ?? []);
|
|
658
|
+
const session = sessions.find((s) => s.path === sessionPath);
|
|
659
|
+
this.enterRenameMode(sessionPath, session?.name);
|
|
660
|
+
};
|
|
661
|
+
// Sync list events to header
|
|
662
|
+
this.sessionList.onTogglePath = (showPath) => {
|
|
663
|
+
this.header.setShowPath(showPath);
|
|
664
|
+
this.requestRender();
|
|
665
|
+
};
|
|
666
|
+
this.sessionList.onDeleteConfirmationChange = (path) => {
|
|
667
|
+
this.header.setConfirmingDeletePath(path);
|
|
668
|
+
this.requestRender();
|
|
669
|
+
};
|
|
670
|
+
this.sessionList.onError = (msg) => {
|
|
671
|
+
this.header.setStatusMessage({ type: "error", message: msg }, 3000);
|
|
672
|
+
this.requestRender();
|
|
673
|
+
};
|
|
674
|
+
// Handle session deletion
|
|
675
|
+
this.sessionList.onDeleteSession = async (sessionPath) => {
|
|
676
|
+
const result = await deleteSessionFile(sessionPath);
|
|
677
|
+
if (result.ok) {
|
|
678
|
+
if (this.currentSessions) {
|
|
679
|
+
this.currentSessions = this.currentSessions.filter((s) => s.path !== sessionPath);
|
|
680
|
+
}
|
|
681
|
+
if (this.allSessions) {
|
|
682
|
+
this.allSessions = this.allSessions.filter((s) => s.path !== sessionPath);
|
|
683
|
+
}
|
|
684
|
+
const sessions = this.scope === "all" ? (this.allSessions ?? []) : (this.currentSessions ?? []);
|
|
685
|
+
const showCwd = this.scope === "all";
|
|
686
|
+
this.sessionList.setSessions(sessions, showCwd);
|
|
687
|
+
const msg = result.method === "trash" ? "Session moved to trash" : "Session deleted";
|
|
688
|
+
this.header.setStatusMessage({ type: "info", message: msg }, 2000);
|
|
689
|
+
await this.refreshSessionsAfterMutation();
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
const errorMessage = result.error ?? "Unknown error";
|
|
693
|
+
this.header.setStatusMessage({ type: "error", message: `Failed to delete: ${errorMessage}` }, 3000);
|
|
694
|
+
}
|
|
695
|
+
this.requestRender();
|
|
696
|
+
};
|
|
697
|
+
// Start loading current sessions immediately
|
|
698
|
+
this.loadCurrentSessions();
|
|
699
|
+
}
|
|
700
|
+
loadCurrentSessions() {
|
|
701
|
+
void this.loadScope("current", "initial");
|
|
702
|
+
}
|
|
703
|
+
enterRenameMode(sessionPath, currentName) {
|
|
704
|
+
this.mode = "rename";
|
|
705
|
+
this.renameTargetPath = sessionPath;
|
|
706
|
+
this.renameInput.setValue(currentName ?? "");
|
|
707
|
+
this.renameInput.focused = true;
|
|
708
|
+
const panel = new Container();
|
|
709
|
+
panel.addChild(new Text(theme.bold("Rename Session"), 1, 0));
|
|
710
|
+
panel.addChild(new Spacer(1));
|
|
711
|
+
panel.addChild(this.renameInput);
|
|
712
|
+
panel.addChild(new Spacer(1));
|
|
713
|
+
panel.addChild(new Text(theme.fg("muted", "Enter to save · Esc/Ctrl+C to cancel"), 1, 0));
|
|
714
|
+
this.buildBaseLayout(panel, { showHeader: false });
|
|
715
|
+
this.requestRender();
|
|
716
|
+
}
|
|
717
|
+
exitRenameMode() {
|
|
718
|
+
this.mode = "list";
|
|
719
|
+
this.renameTargetPath = null;
|
|
720
|
+
this.buildBaseLayout(this.sessionList);
|
|
721
|
+
this.requestRender();
|
|
722
|
+
}
|
|
723
|
+
async confirmRename(value) {
|
|
724
|
+
const next = value.trim();
|
|
725
|
+
if (!next)
|
|
726
|
+
return;
|
|
727
|
+
const target = this.renameTargetPath;
|
|
728
|
+
if (!target) {
|
|
729
|
+
this.exitRenameMode();
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
// Find current name for callback
|
|
733
|
+
const renameSession = this.renameSession;
|
|
734
|
+
if (!renameSession) {
|
|
735
|
+
this.exitRenameMode();
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
try {
|
|
739
|
+
await renameSession(target, next);
|
|
740
|
+
await this.refreshSessionsAfterMutation();
|
|
741
|
+
}
|
|
742
|
+
finally {
|
|
743
|
+
this.exitRenameMode();
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
async loadScope(scope, reason) {
|
|
747
|
+
const showCwd = scope === "all";
|
|
748
|
+
// Mark loading
|
|
749
|
+
if (scope === "current") {
|
|
750
|
+
this.currentLoading = true;
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
this.allLoading = true;
|
|
754
|
+
}
|
|
755
|
+
const seq = scope === "all" ? ++this.allLoadSeq : undefined;
|
|
756
|
+
this.header.setScope(scope);
|
|
757
|
+
this.header.setLoading(true);
|
|
758
|
+
this.requestRender();
|
|
759
|
+
const onProgress = (loaded, total) => {
|
|
760
|
+
if (scope !== this.scope)
|
|
761
|
+
return;
|
|
762
|
+
if (seq !== undefined && seq !== this.allLoadSeq)
|
|
763
|
+
return;
|
|
764
|
+
this.header.setProgress(loaded, total);
|
|
765
|
+
this.requestRender();
|
|
766
|
+
};
|
|
767
|
+
try {
|
|
768
|
+
const sessions = await (scope === "current"
|
|
769
|
+
? this.currentSessionsLoader(onProgress)
|
|
770
|
+
: this.allSessionsLoader(onProgress));
|
|
771
|
+
if (scope === "current") {
|
|
772
|
+
this.currentSessions = sessions;
|
|
773
|
+
this.currentLoading = false;
|
|
774
|
+
}
|
|
775
|
+
else {
|
|
776
|
+
this.allSessions = sessions;
|
|
777
|
+
this.allLoading = false;
|
|
778
|
+
}
|
|
779
|
+
if (scope !== this.scope)
|
|
780
|
+
return;
|
|
781
|
+
if (seq !== undefined && seq !== this.allLoadSeq)
|
|
782
|
+
return;
|
|
783
|
+
this.header.setLoading(false);
|
|
784
|
+
this.sessionList.setSessions(sessions, showCwd);
|
|
785
|
+
this.requestRender();
|
|
786
|
+
if (scope === "all" && sessions.length === 0 && (this.currentSessions?.length ?? 0) === 0) {
|
|
787
|
+
this.onCancel();
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
catch (err) {
|
|
791
|
+
if (scope === "current") {
|
|
792
|
+
this.currentLoading = false;
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
this.allLoading = false;
|
|
796
|
+
}
|
|
797
|
+
if (scope !== this.scope)
|
|
798
|
+
return;
|
|
799
|
+
if (seq !== undefined && seq !== this.allLoadSeq)
|
|
800
|
+
return;
|
|
801
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
802
|
+
this.header.setLoading(false);
|
|
803
|
+
this.header.setStatusMessage({ type: "error", message: `Failed to load sessions: ${message}` }, 4000);
|
|
804
|
+
if (reason === "initial") {
|
|
805
|
+
this.sessionList.setSessions([], showCwd);
|
|
806
|
+
}
|
|
807
|
+
this.requestRender();
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
toggleSortMode() {
|
|
811
|
+
// Cycle: threaded -> recent -> relevance -> threaded
|
|
812
|
+
this.sortMode = this.sortMode === "threaded" ? "recent" : this.sortMode === "recent" ? "relevance" : "threaded";
|
|
813
|
+
this.header.setSortMode(this.sortMode);
|
|
814
|
+
this.sessionList.setSortMode(this.sortMode);
|
|
815
|
+
this.requestRender();
|
|
816
|
+
}
|
|
817
|
+
toggleNameFilter() {
|
|
818
|
+
this.nameFilter = this.nameFilter === "all" ? "named" : "all";
|
|
819
|
+
this.header.setNameFilter(this.nameFilter);
|
|
820
|
+
this.sessionList.setNameFilter(this.nameFilter);
|
|
821
|
+
this.requestRender();
|
|
822
|
+
}
|
|
823
|
+
async refreshSessionsAfterMutation() {
|
|
824
|
+
await this.loadScope(this.scope, "refresh");
|
|
825
|
+
}
|
|
826
|
+
toggleScope() {
|
|
827
|
+
if (this.scope === "current") {
|
|
828
|
+
this.scope = "all";
|
|
829
|
+
this.header.setScope(this.scope);
|
|
830
|
+
if (this.allSessions !== null) {
|
|
831
|
+
this.header.setLoading(false);
|
|
832
|
+
this.sessionList.setSessions(this.allSessions, true);
|
|
833
|
+
this.requestRender();
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
if (!this.allLoading) {
|
|
837
|
+
void this.loadScope("all", "toggle");
|
|
838
|
+
}
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
this.scope = "current";
|
|
842
|
+
this.header.setScope(this.scope);
|
|
843
|
+
this.header.setLoading(this.currentLoading);
|
|
844
|
+
this.sessionList.setSessions(this.currentSessions ?? [], false);
|
|
845
|
+
this.requestRender();
|
|
846
|
+
}
|
|
847
|
+
getSessionList() {
|
|
848
|
+
return this.sessionList;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
//# sourceMappingURL=session-selector.js.map
|