@selesai/code 0.1.0
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/README.md +198 -0
- package/dist/agents/architect.md +216 -0
- package/dist/agents/builder.md +119 -0
- package/dist/agents/commentator.md +128 -0
- package/dist/agents/explorer.md +51 -0
- package/dist/agents/recapper.md +24 -0
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +9 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +36 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +57 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +379 -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 +82 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.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 +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/session-picker.d.ts +10 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +36 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +23 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +172 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +154 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +579 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/core/agent-session-runtime.js +303 -0
- package/dist/core/agent-session-runtime.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +88 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +119 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +607 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2552 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/agents.d.ts +53 -0
- package/dist/core/agents.d.ts.map +1 -0
- package/dist/core/agents.js +238 -0
- package/dist/core/agents.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +140 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +434 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +32 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +111 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +92 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +249 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +122 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +625 -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 +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +153 -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 +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +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 +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +226 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -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 +78 -0
- package/dist/core/extensions/index.d.ts +12 -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 +23 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +531 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +166 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +876 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1209 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +45 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +338 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +64 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +353 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +295 -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 +151 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +750 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +111 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +534 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +7 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +89 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +207 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2088 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +59 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +53 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +236 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +82 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +36 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +247 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +230 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +861 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +109 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +267 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/session-manager.d.ts +332 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1230 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +286 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +874 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +69 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +387 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +26 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +18 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +19 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +31 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +128 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +8 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +31 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +68 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +346 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +424 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +51 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +284 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +52 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +35 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +305 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +37 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +304 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +40 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +112 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +37 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +167 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +99 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +289 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +65 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.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 +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +26 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +197 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/trust-manager.d.ts +36 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +202 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/defaults/models.json +3 -0
- package/dist/defaults/settings.json +68 -0
- package/dist/extensions/copy-turn.ts +125 -0
- package/dist/extensions/gitignore-guard.ts +132 -0
- package/dist/extensions/hooks/claude-codex-hooks.json +44 -0
- package/dist/extensions/hooks/copilot-hooks.json +21 -0
- package/dist/extensions/hooks/ponytail-activate.js +91 -0
- package/dist/extensions/hooks/ponytail-config.js +122 -0
- package/dist/extensions/hooks/ponytail-instructions.js +94 -0
- package/dist/extensions/hooks/ponytail-mode-tracker.js +55 -0
- package/dist/extensions/hooks/ponytail-runtime.js +68 -0
- package/dist/extensions/hooks/ponytail-statusline.ps1 +21 -0
- package/dist/extensions/hooks/ponytail-statusline.sh +12 -0
- package/dist/extensions/hooks/ponytail-subagent.js +22 -0
- package/dist/extensions/package.json +19 -0
- package/dist/extensions/pi-extension/index.js +189 -0
- package/dist/extensions/pi-extension/package.json +8 -0
- package/dist/extensions/pi-extension/test/extension.test.js +167 -0
- package/dist/extensions/pi-extension/test/helpers.test.js +92 -0
- package/dist/extensions/pi-powerline-footer/CHANGELOG.md +516 -0
- package/dist/extensions/pi-powerline-footer/README.md +382 -0
- package/dist/extensions/pi-powerline-footer/banner.png +0 -0
- package/dist/extensions/pi-powerline-footer/bash-mode/completion.ts +556 -0
- package/dist/extensions/pi-powerline-footer/bash-mode/editor.ts +397 -0
- package/dist/extensions/pi-powerline-footer/bash-mode/history.ts +151 -0
- package/dist/extensions/pi-powerline-footer/bash-mode/shell-session.ts +286 -0
- package/dist/extensions/pi-powerline-footer/bash-mode/transcript.ts +108 -0
- package/dist/extensions/pi-powerline-footer/bash-mode/types.ts +59 -0
- package/dist/extensions/pi-powerline-footer/colors.ts +69 -0
- package/dist/extensions/pi-powerline-footer/context-usage.ts +41 -0
- package/dist/extensions/pi-powerline-footer/fixed-editor/cluster.ts +113 -0
- package/dist/extensions/pi-powerline-footer/fixed-editor/terminal-split.ts +1077 -0
- package/dist/extensions/pi-powerline-footer/git-status.ts +212 -0
- package/dist/extensions/pi-powerline-footer/icons.ts +181 -0
- package/dist/extensions/pi-powerline-footer/index.ts +2817 -0
- package/dist/extensions/pi-powerline-footer/package.json +46 -0
- package/dist/extensions/pi-powerline-footer/powerline-config.ts +182 -0
- package/dist/extensions/pi-powerline-footer/presets.ts +121 -0
- package/dist/extensions/pi-powerline-footer/render-scheduler.ts +24 -0
- package/dist/extensions/pi-powerline-footer/segments.ts +566 -0
- package/dist/extensions/pi-powerline-footer/separators.ts +57 -0
- package/dist/extensions/pi-powerline-footer/shortcuts.ts +47 -0
- package/dist/extensions/pi-powerline-footer/tests/bash-mode.test.ts +1503 -0
- package/dist/extensions/pi-powerline-footer/tests/context-usage.test.ts +38 -0
- package/dist/extensions/pi-powerline-footer/tests/custom-items.test.ts +135 -0
- package/dist/extensions/pi-powerline-footer/tests/editor-responsiveness.test.ts +180 -0
- package/dist/extensions/pi-powerline-footer/tests/fixed-editor.test.ts +1416 -0
- package/dist/extensions/pi-powerline-footer/tests/jump-shortcuts.test.ts +213 -0
- package/dist/extensions/pi-powerline-footer/tests/stash-shortcut.test.ts +32 -0
- package/dist/extensions/pi-powerline-footer/tests/thinking-segment.test.ts +61 -0
- package/dist/extensions/pi-powerline-footer/tests/working-vibes.test.ts +226 -0
- package/dist/extensions/pi-powerline-footer/theme.example.json +24 -0
- package/dist/extensions/pi-powerline-footer/theme.json +12 -0
- package/dist/extensions/pi-powerline-footer/theme.ts +227 -0
- package/dist/extensions/pi-powerline-footer/types.ts +191 -0
- package/dist/extensions/pi-powerline-footer/welcome-dismiss.ts +34 -0
- package/dist/extensions/pi-powerline-footer/welcome.ts +611 -0
- package/dist/extensions/pi-powerline-footer/working-vibes.ts +695 -0
- package/dist/extensions/prototype.ts +713 -0
- package/dist/extensions/question.ts +350 -0
- package/dist/extensions/rtk.ts +81 -0
- package/dist/extensions/tps-tracker.ts +280 -0
- package/dist/extensions/undo.ts +292 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +700 -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 +281 -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/assets/clankolas.png +0 -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 +20 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +121 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +175 -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 +54 -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 +506 -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/earendil-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.js +40 -0
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +119 -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 +26 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +83 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +103 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +28 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +221 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +35 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +179 -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 +279 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +31 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +165 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +293 -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 +867 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +73 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +570 -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 +39 -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 +50 -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 +51 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +317 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1208 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +91 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +114 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +10 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +29 -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 +381 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +4802 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +86 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +102 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +336 -0
- package/dist/modes/interactive/theme/theme.d.ts +119 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1056 -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 +132 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +227 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +467 -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 +637 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +428 -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/package-manager-cli.d.ts +8 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +659 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/skills/grill-me/SKILL.md +10 -0
- package/dist/skills/handoff/SKILL.md +15 -0
- package/dist/skills/implanger/SKILL.md +68 -0
- package/dist/skills/improve-codebase/REFERENCE.md +78 -0
- package/dist/skills/improve-codebase/SKILL.md +178 -0
- package/dist/skills/planger/SKILL.md +165 -0
- package/dist/skills/ponytail/SKILL.md +117 -0
- package/dist/skills/ponytail-audit/SKILL.md +41 -0
- package/dist/skills/ponytail-debt/SKILL.md +44 -0
- package/dist/skills/ponytail-gain/SKILL.md +50 -0
- package/dist/skills/ponytail-help/SKILL.md +69 -0
- package/dist/skills/ponytail-review/SKILL.md +57 -0
- package/dist/skills/selesai-default/SKILL.md +16 -0
- package/dist/themes/powerline-footer/theme.json +33 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +22 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +165 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +18 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +106 -0
- package/dist/utils/child-process.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 +245 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +10 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +20 -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 +117 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +158 -0
- package/dist/utils/exif-orientation.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/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +195 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +39 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +16 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +97 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +69 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +92 -0
- package/dist/utils/paths.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/pi-user-agent.d.ts +2 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -0
- package/dist/utils/pi-user-agent.js +5 -0
- package/dist/utils/pi-user-agent.js.map +1 -0
- package/dist/utils/shell.d.ts +31 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +202 -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/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +328 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +15 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +52 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +396 -0
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +737 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +156 -0
- package/docs/extensions.md +2681 -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/index.md +82 -0
- package/docs/json.md +82 -0
- package/docs/keybindings.md +197 -0
- package/docs/models.md +495 -0
- package/docs/packages.md +227 -0
- package/docs/prompt-templates.md +95 -0
- package/docs/providers.md +274 -0
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +1412 -0
- package/docs/sdk.md +1143 -0
- package/docs/security.md +59 -0
- package/docs/session-format.md +412 -0
- package/docs/sessions.md +145 -0
- package/docs/settings.md +308 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +142 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +63 -0
- package/docs/tui.md +927 -0
- package/docs/usage.md +308 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +211 -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/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +249 -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 +127 -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 +404 -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/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/dynamic-tools.ts +74 -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/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform-streaming.ts +39 -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 +1450 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +66 -0
- package/examples/extensions/plan-mode/index.ts +390 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +436 -0
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +122 -0
- package/examples/extensions/question.ts +285 -0
- package/examples/extensions/questionnaire.ts +448 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +321 -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 +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -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 +126 -0
- package/examples/extensions/subagent/index.ts +1015 -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 +206 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +53 -0
- package/examples/sdk/03-custom-prompt.ts +75 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +99 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +52 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +77 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +65 -0
|
@@ -0,0 +1,1077 @@
|
|
|
1
|
+
import { isKeyRelease, matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { matchesConfiguredShortcut } from "../shortcuts.ts";
|
|
3
|
+
import type { FixedEditorClusterRender } from "./cluster.ts";
|
|
4
|
+
|
|
5
|
+
export interface TerminalLike {
|
|
6
|
+
columns: number;
|
|
7
|
+
rows: number;
|
|
8
|
+
kittyProtocolActive?: boolean;
|
|
9
|
+
write(data: string): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface KeyboardScrollShortcuts {
|
|
13
|
+
up: string;
|
|
14
|
+
down: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface TerminalSplitCompositorOptions {
|
|
18
|
+
tui: any;
|
|
19
|
+
terminal: TerminalLike;
|
|
20
|
+
renderCluster: (width: number, terminalRows: number) => FixedEditorClusterRender;
|
|
21
|
+
getShowHardwareCursor?: () => boolean;
|
|
22
|
+
mouseScroll?: boolean;
|
|
23
|
+
keyboardScrollShortcuts?: KeyboardScrollShortcuts;
|
|
24
|
+
onCopySelection?: (text: string) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface PatchedRenderable {
|
|
28
|
+
render(width: number): string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface RenderPatch {
|
|
32
|
+
target: PatchedRenderable;
|
|
33
|
+
originalRender: (width: number) => string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface RenderPassCluster {
|
|
37
|
+
width: number;
|
|
38
|
+
terminalRows: number;
|
|
39
|
+
cluster: FixedEditorClusterRender;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type CompositeLineAt = (
|
|
43
|
+
baseLine: string,
|
|
44
|
+
overlayLine: string,
|
|
45
|
+
startCol: number,
|
|
46
|
+
overlayWidth: number,
|
|
47
|
+
totalWidth: number,
|
|
48
|
+
) => string;
|
|
49
|
+
|
|
50
|
+
interface SgrMousePacket {
|
|
51
|
+
code: number;
|
|
52
|
+
col: number;
|
|
53
|
+
row: number;
|
|
54
|
+
final: "M" | "m";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface SelectionPoint {
|
|
58
|
+
line: number;
|
|
59
|
+
col: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type SelectionArea = "root" | "cluster";
|
|
63
|
+
|
|
64
|
+
interface SelectionLocation {
|
|
65
|
+
area: SelectionArea;
|
|
66
|
+
point: SelectionPoint;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface DisposeOptions {
|
|
70
|
+
resetExtendedKeyboardModes?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type ExtendedKeyboardMode = "kitty" | "modifyOtherKeys";
|
|
74
|
+
|
|
75
|
+
const CONTEXT_MENU_MOUSE_REPORTING_PAUSE_MS = 1200;
|
|
76
|
+
const CONTEXT_MENU_SELECTION_RESTORE_WINDOW_MS = 5000;
|
|
77
|
+
const CONTEXT_MENU_CLIPBOARD_RESTORE_INTERVAL_MS = 100;
|
|
78
|
+
const DOUBLE_CLICK_MS = 500;
|
|
79
|
+
const DEFAULT_KEYBOARD_SCROLL_SHORTCUTS: KeyboardScrollShortcuts = {
|
|
80
|
+
up: "super+up",
|
|
81
|
+
down: "super+down",
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export function beginSynchronizedOutput(): string {
|
|
85
|
+
return "\x1b[?2026h";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function endSynchronizedOutput(): string {
|
|
89
|
+
return "\x1b[?2026l";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function setScrollRegion(top: number, bottom: number): string {
|
|
93
|
+
return `\x1b[${top};${bottom}r`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function resetScrollRegion(): string {
|
|
97
|
+
return "\x1b[r";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function moveCursor(row: number, col: number): string {
|
|
101
|
+
return `\x1b[${row};${col}H`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function clearLine(): string {
|
|
105
|
+
return "\x1b[2K";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function hideCursor(): string {
|
|
109
|
+
return "\x1b[?25l";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function showCursor(): string {
|
|
113
|
+
return "\x1b[?25h";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function enterAlternateScreen(): string {
|
|
117
|
+
return "\x1b[?1049h";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function exitAlternateScreen(): string {
|
|
121
|
+
return "\x1b[?1049l";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function enableAlternateScrollMode(): string {
|
|
125
|
+
return "\x1b[?1007h";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function disableAlternateScrollMode(): string {
|
|
129
|
+
return "\x1b[?1007l";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function enableMouseReporting(): string {
|
|
133
|
+
return "\x1b[?1002h\x1b[?1006h";
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function disableMouseReporting(): string {
|
|
137
|
+
return "\x1b[?1006l\x1b[?1002l\x1b[?1000l";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function enableExtendedKeyboardMode(mode: ExtendedKeyboardMode): string {
|
|
141
|
+
return mode === "kitty" ? "\x1b[>7u" : "\x1b[>4;2m";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function disableExtendedKeyboardMode(mode: ExtendedKeyboardMode): string {
|
|
145
|
+
return mode === "kitty" ? "\x1b[<u" : "\x1b[>4;0m";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function resetExtendedKeyboardModes(): string {
|
|
149
|
+
return "\x1b[<999u\x1b[>4;0m";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function emergencyTerminalModeReset(): string {
|
|
153
|
+
return beginSynchronizedOutput()
|
|
154
|
+
+ resetScrollRegion()
|
|
155
|
+
+ disableMouseReporting()
|
|
156
|
+
+ enableAlternateScrollMode()
|
|
157
|
+
+ exitAlternateScreen()
|
|
158
|
+
+ resetExtendedKeyboardModes()
|
|
159
|
+
+ endSynchronizedOutput();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function parseKeyboardScrollDelta(data: string, shortcuts: KeyboardScrollShortcuts = DEFAULT_KEYBOARD_SCROLL_SHORTCUTS): number {
|
|
163
|
+
if (isKeyRelease(data)) return 0;
|
|
164
|
+
|
|
165
|
+
if (
|
|
166
|
+
matchesConfiguredShortcut(data, shortcuts.up)
|
|
167
|
+
|| matchesKey(data, "pageUp")
|
|
168
|
+
|| matchesKey(data, "ctrl+shift+up")
|
|
169
|
+
|| /^\x1b\[(?:5;9(?::[12])?~|1;6(?::[12])?A|57421;9(?::[12])?u|57419;6(?::[12])?u)$/.test(data)
|
|
170
|
+
) return 10;
|
|
171
|
+
if (
|
|
172
|
+
matchesConfiguredShortcut(data, shortcuts.down)
|
|
173
|
+
|| matchesKey(data, "pageDown")
|
|
174
|
+
|| matchesKey(data, "ctrl+shift+down")
|
|
175
|
+
|| /^\x1b\[(?:6;9(?::[12])?~|1;6(?::[12])?B|57422;9(?::[12])?u|57420;6(?::[12])?u)$/.test(data)
|
|
176
|
+
) return -10;
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function parseSgrMousePackets(data: string): SgrMousePacket[] | null {
|
|
181
|
+
const pattern = /\x1b\[<(\d+);(\d+);(\d+)([Mm])/g;
|
|
182
|
+
const packets: SgrMousePacket[] = [];
|
|
183
|
+
let offset = 0;
|
|
184
|
+
|
|
185
|
+
for (const match of data.matchAll(pattern)) {
|
|
186
|
+
if (match.index !== offset) return null;
|
|
187
|
+
offset = match.index + match[0].length;
|
|
188
|
+
packets.push({
|
|
189
|
+
code: Number(match[1]),
|
|
190
|
+
col: Number(match[2]),
|
|
191
|
+
row: Number(match[3]),
|
|
192
|
+
final: match[4] as "M" | "m",
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return packets.length > 0 && offset === data.length ? packets : null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function mouseBaseButton(code: number): number {
|
|
200
|
+
return code & ~(4 | 8 | 16 | 32);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function mouseScrollDelta(packet: SgrMousePacket): number {
|
|
204
|
+
if (packet.final !== "M") return 0;
|
|
205
|
+
const baseButton = mouseBaseButton(packet.code);
|
|
206
|
+
if (baseButton === 64) return 3;
|
|
207
|
+
if (baseButton === 65) return -3;
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function isLeftPress(packet: SgrMousePacket): boolean {
|
|
212
|
+
return packet.final === "M" && mouseBaseButton(packet.code) === 0 && (packet.code & 32) === 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function isLeftDrag(packet: SgrMousePacket): boolean {
|
|
216
|
+
return packet.final === "M" && mouseBaseButton(packet.code) === 0 && (packet.code & 32) !== 0;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function isRightPress(packet: SgrMousePacket): boolean {
|
|
220
|
+
return packet.final === "M" && mouseBaseButton(packet.code) === 2 && (packet.code & 32) === 0;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function isMouseRelease(packet: SgrMousePacket): boolean {
|
|
224
|
+
return packet.final === "m";
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function stripOscSequences(line: string): string {
|
|
228
|
+
return line.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)/g, "");
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function stripAnsi(line: string): string {
|
|
232
|
+
return stripOscSequences(line).replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, "");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
236
|
+
|
|
237
|
+
function sliceColumns(text: string, startCol: number, endCol: number): string {
|
|
238
|
+
let col = 0;
|
|
239
|
+
let result = "";
|
|
240
|
+
for (const { segment } of graphemeSegmenter.segment(text)) {
|
|
241
|
+
const width = Math.max(0, visibleWidth(segment));
|
|
242
|
+
if (col >= startCol && col < endCol) {
|
|
243
|
+
result += segment;
|
|
244
|
+
}
|
|
245
|
+
col += width;
|
|
246
|
+
}
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function compareSelectionPoints(a: SelectionPoint, b: SelectionPoint): number {
|
|
251
|
+
return a.line === b.line ? a.col - b.col : a.line - b.line;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function descriptorForRows(terminal: TerminalLike): PropertyDescriptor | undefined {
|
|
255
|
+
let target: object | null = terminal;
|
|
256
|
+
while (target) {
|
|
257
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, "rows");
|
|
258
|
+
if (descriptor) return descriptor;
|
|
259
|
+
target = Object.getPrototypeOf(target);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return undefined;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function readRows(terminal: TerminalLike, descriptor: PropertyDescriptor | undefined): number {
|
|
266
|
+
if (descriptor?.get) {
|
|
267
|
+
const value = descriptor.get.call(terminal);
|
|
268
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 24;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const value = Reflect.get(terminal, "rows");
|
|
272
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 24;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function sanitizeLine(line: string, width: number): string {
|
|
276
|
+
return visibleWidth(line) > width ? truncateToWidth(line, width, "", true) : line;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function sanitizeOverlayBaseLine(line: string, width: number): string {
|
|
280
|
+
return sanitizeLine(stripOscSequences(line), width);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function normalizeOverlayCompositionLine(line: string): string {
|
|
284
|
+
return line.includes("\t") ? line.replace(/\t/g, " ") : line;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function buildFixedClusterPaint(
|
|
288
|
+
cluster: FixedEditorClusterRender,
|
|
289
|
+
terminalRows: number,
|
|
290
|
+
width: number,
|
|
291
|
+
showHardwareCursor: boolean,
|
|
292
|
+
): string {
|
|
293
|
+
if (cluster.lines.length === 0) return "";
|
|
294
|
+
|
|
295
|
+
const startRow = Math.max(1, terminalRows - cluster.lines.length + 1);
|
|
296
|
+
let buffer = resetScrollRegion();
|
|
297
|
+
|
|
298
|
+
for (let i = 0; i < cluster.lines.length; i++) {
|
|
299
|
+
buffer += moveCursor(startRow + i, 1);
|
|
300
|
+
buffer += clearLine();
|
|
301
|
+
buffer += sanitizeLine(cluster.lines[i] ?? "", width);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (cluster.cursor && showHardwareCursor) {
|
|
305
|
+
buffer += moveCursor(startRow + cluster.cursor.row, Math.max(1, cluster.cursor.col + 1));
|
|
306
|
+
buffer += showCursor();
|
|
307
|
+
} else {
|
|
308
|
+
buffer += hideCursor();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return buffer;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export class TerminalSplitCompositor {
|
|
315
|
+
private readonly tui: any;
|
|
316
|
+
private readonly terminal: TerminalLike;
|
|
317
|
+
private readonly renderCluster: (width: number, terminalRows: number) => FixedEditorClusterRender;
|
|
318
|
+
private readonly getShowHardwareCursor: () => boolean;
|
|
319
|
+
private readonly mouseScroll: boolean;
|
|
320
|
+
private readonly keyboardScrollShortcuts: KeyboardScrollShortcuts;
|
|
321
|
+
private readonly onCopySelection: ((text: string) => void) | null;
|
|
322
|
+
private extendedKeyboardMode: ExtendedKeyboardMode | null = null;
|
|
323
|
+
private readonly rowsDescriptor: PropertyDescriptor | undefined;
|
|
324
|
+
private readonly originalWrite: (data: string) => void;
|
|
325
|
+
private readonly originalDoRender: (() => void) | null;
|
|
326
|
+
private readonly originalRender: ((width: number) => string[]) | null;
|
|
327
|
+
private originalCompositeLineAt: CompositeLineAt | null = null;
|
|
328
|
+
private readonly patchedRenders: RenderPatch[] = [];
|
|
329
|
+
private removeInputListener: (() => void) | null = null;
|
|
330
|
+
private emergencyCleanup: (() => void) | null = null;
|
|
331
|
+
private mouseReportingResumeTimer: ReturnType<typeof setTimeout> | null = null;
|
|
332
|
+
private clipboardRestoreTimer: ReturnType<typeof setTimeout> | null = null;
|
|
333
|
+
private installed = false;
|
|
334
|
+
private disposed = false;
|
|
335
|
+
private writing = false;
|
|
336
|
+
private renderPassActive = false;
|
|
337
|
+
private renderPassCluster: RenderPassCluster | null = null;
|
|
338
|
+
private renderingCluster = false;
|
|
339
|
+
private renderingScrollableRoot = false;
|
|
340
|
+
private checkingOverlay = false;
|
|
341
|
+
private scrollOffset = 0;
|
|
342
|
+
private maxScrollOffset = 0;
|
|
343
|
+
private lastRootLineCount = 0;
|
|
344
|
+
private rootLines: string[] = [];
|
|
345
|
+
private visibleRootStart = 0;
|
|
346
|
+
private visibleScrollableRows = 0;
|
|
347
|
+
private visibleRootLines: string[] = [];
|
|
348
|
+
private visibleClusterLines: string[] = [];
|
|
349
|
+
private selectionArea: SelectionArea | null = null;
|
|
350
|
+
private selectionAnchor: SelectionPoint | null = null;
|
|
351
|
+
private selectionFocus: SelectionPoint | null = null;
|
|
352
|
+
private selectionDragging = false;
|
|
353
|
+
private preserveSelectionFocusOnRelease = false;
|
|
354
|
+
private lastLeftPress: { area: SelectionArea; line: number; at: number } | null = null;
|
|
355
|
+
|
|
356
|
+
constructor(options: TerminalSplitCompositorOptions) {
|
|
357
|
+
this.tui = options.tui;
|
|
358
|
+
this.terminal = options.terminal;
|
|
359
|
+
this.renderCluster = options.renderCluster;
|
|
360
|
+
this.getShowHardwareCursor = options.getShowHardwareCursor ?? (() => false);
|
|
361
|
+
this.mouseScroll = options.mouseScroll !== false;
|
|
362
|
+
this.keyboardScrollShortcuts = options.keyboardScrollShortcuts ?? DEFAULT_KEYBOARD_SCROLL_SHORTCUTS;
|
|
363
|
+
this.onCopySelection = options.onCopySelection ?? null;
|
|
364
|
+
this.rowsDescriptor = descriptorForRows(options.terminal);
|
|
365
|
+
this.originalWrite = options.terminal.write.bind(options.terminal);
|
|
366
|
+
this.originalDoRender = typeof options.tui.doRender === "function" ? options.tui.doRender.bind(options.tui) : null;
|
|
367
|
+
this.originalRender = typeof options.tui.render === "function" ? options.tui.render.bind(options.tui) : null;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
install(): void {
|
|
371
|
+
if (this.installed) return;
|
|
372
|
+
if (typeof this.terminal.write !== "function") {
|
|
373
|
+
throw new Error("[powerline-footer] Fixed editor compositor expected terminal.write(data) to exist");
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
this.originalWrite(
|
|
377
|
+
beginSynchronizedOutput()
|
|
378
|
+
+ enterAlternateScreen()
|
|
379
|
+
+ this.enableAlternateScreenKeyboardMode()
|
|
380
|
+
+ disableAlternateScrollMode()
|
|
381
|
+
+ (this.mouseScroll ? enableMouseReporting() : "")
|
|
382
|
+
+ endSynchronizedOutput(),
|
|
383
|
+
);
|
|
384
|
+
this.emergencyCleanup = () => {
|
|
385
|
+
if (!this.disposed) {
|
|
386
|
+
this.restoreTerminalStateForExit();
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
process.once("exit", this.emergencyCleanup);
|
|
390
|
+
|
|
391
|
+
Object.defineProperty(this.terminal, "rows", {
|
|
392
|
+
configurable: true,
|
|
393
|
+
get: () => this.getScrollableRows(),
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
if (this.originalRender) {
|
|
397
|
+
this.tui.render = (width: number) => this.renderScrollableRoot(width);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (typeof this.tui.addInputListener === "function") {
|
|
401
|
+
this.removeInputListener = this.tui.addInputListener((data: string) => this.handleInput(data));
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
this.terminal.write = (data: string) => this.write(data);
|
|
405
|
+
if (this.originalDoRender) {
|
|
406
|
+
this.tui.doRender = () => {
|
|
407
|
+
this.renderPassActive = true;
|
|
408
|
+
this.renderPassCluster = null;
|
|
409
|
+
try {
|
|
410
|
+
this.originalDoRender?.();
|
|
411
|
+
this.requestRepaint();
|
|
412
|
+
} finally {
|
|
413
|
+
this.renderPassActive = false;
|
|
414
|
+
this.renderPassCluster = null;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
if (typeof this.tui.compositeLineAt === "function") {
|
|
419
|
+
this.originalCompositeLineAt = this.tui.compositeLineAt.bind(this.tui) as CompositeLineAt;
|
|
420
|
+
this.tui.compositeLineAt = (
|
|
421
|
+
baseLine: string,
|
|
422
|
+
overlayLine: string,
|
|
423
|
+
startCol: number,
|
|
424
|
+
overlayWidth: number,
|
|
425
|
+
totalWidth: number,
|
|
426
|
+
) => this.originalCompositeLineAt?.(
|
|
427
|
+
normalizeOverlayCompositionLine(baseLine),
|
|
428
|
+
normalizeOverlayCompositionLine(overlayLine),
|
|
429
|
+
startCol,
|
|
430
|
+
overlayWidth,
|
|
431
|
+
totalWidth,
|
|
432
|
+
) ?? "";
|
|
433
|
+
}
|
|
434
|
+
this.installed = true;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
hideRenderable(target: PatchedRenderable): void {
|
|
438
|
+
if (this.patchedRenders.some((patch) => patch.target === target)) return;
|
|
439
|
+
const originalRender = target.render.bind(target);
|
|
440
|
+
this.patchedRenders.push({ target, originalRender });
|
|
441
|
+
target.render = () => [];
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
renderHidden(target: PatchedRenderable, width: number): string[] {
|
|
445
|
+
const patch = this.patchedRenders.find((candidate) => candidate.target === target);
|
|
446
|
+
const render = patch?.originalRender ?? target.render.bind(target);
|
|
447
|
+
return render(width);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
jumpToPreviousRootTarget(targetLines: readonly number[]): boolean {
|
|
451
|
+
return this.jumpToRootTarget(targetLines, "previous");
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
jumpToNextRootTarget(targetLines: readonly number[]): boolean {
|
|
455
|
+
return this.jumpToRootTarget(targetLines, "next");
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
jumpToRootBottom(): boolean {
|
|
459
|
+
if (this.disposed || this.hasVisibleOverlay() || this.scrollOffset === 0) return false;
|
|
460
|
+
|
|
461
|
+
this.clearSelection();
|
|
462
|
+
this.lastLeftPress = null;
|
|
463
|
+
this.scrollOffset = 0;
|
|
464
|
+
this.requestRender();
|
|
465
|
+
return true;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
private jumpToRootTarget(targetLines: readonly number[], direction: "previous" | "next"): boolean {
|
|
469
|
+
if (this.disposed || targetLines.length === 0 || this.hasVisibleOverlay()) return false;
|
|
470
|
+
|
|
471
|
+
const start = this.visibleRootStart;
|
|
472
|
+
const candidates = direction === "previous"
|
|
473
|
+
? targetLines.filter((line) => line < start).sort((a, b) => b - a)
|
|
474
|
+
: targetLines.filter((line) => line > start).sort((a, b) => a - b);
|
|
475
|
+
|
|
476
|
+
for (const target of candidates) {
|
|
477
|
+
const nextOffset = Math.max(0, Math.min(
|
|
478
|
+
this.lastRootLineCount - Math.max(1, this.visibleScrollableRows) - target,
|
|
479
|
+
this.maxScrollOffset,
|
|
480
|
+
));
|
|
481
|
+
if (nextOffset === this.scrollOffset) continue;
|
|
482
|
+
|
|
483
|
+
this.clearSelection();
|
|
484
|
+
this.lastLeftPress = null;
|
|
485
|
+
this.scrollOffset = nextOffset;
|
|
486
|
+
this.requestRender();
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
requestRepaint(): void {
|
|
494
|
+
if (this.disposed || this.hasVisibleOverlay()) return;
|
|
495
|
+
const rawRows = this.getRawRows();
|
|
496
|
+
const width = Math.max(1, this.terminal.columns || 80);
|
|
497
|
+
const cluster = this.getCluster(width, rawRows);
|
|
498
|
+
if (cluster.lines.length === 0) return;
|
|
499
|
+
|
|
500
|
+
this.originalWrite(
|
|
501
|
+
beginSynchronizedOutput()
|
|
502
|
+
+ buildFixedClusterPaint(this.decorateCluster(cluster), rawRows, width, this.getShowHardwareCursor())
|
|
503
|
+
+ endSynchronizedOutput(),
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
dispose(options: DisposeOptions = {}): void {
|
|
508
|
+
if (this.disposed) return;
|
|
509
|
+
this.disposed = true;
|
|
510
|
+
|
|
511
|
+
for (const patch of this.patchedRenders.splice(0)) {
|
|
512
|
+
patch.target.render = patch.originalRender;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
this.removeInputListener?.();
|
|
516
|
+
this.removeInputListener = null;
|
|
517
|
+
if (this.emergencyCleanup) {
|
|
518
|
+
process.removeListener("exit", this.emergencyCleanup);
|
|
519
|
+
this.emergencyCleanup = null;
|
|
520
|
+
}
|
|
521
|
+
if (this.mouseReportingResumeTimer) {
|
|
522
|
+
clearTimeout(this.mouseReportingResumeTimer);
|
|
523
|
+
this.mouseReportingResumeTimer = null;
|
|
524
|
+
}
|
|
525
|
+
if (this.clipboardRestoreTimer) {
|
|
526
|
+
clearTimeout(this.clipboardRestoreTimer);
|
|
527
|
+
this.clipboardRestoreTimer = null;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
this.terminal.write = this.originalWrite;
|
|
531
|
+
if (this.originalDoRender) {
|
|
532
|
+
this.tui.doRender = this.originalDoRender;
|
|
533
|
+
}
|
|
534
|
+
if (this.originalRender) {
|
|
535
|
+
this.tui.render = this.originalRender;
|
|
536
|
+
}
|
|
537
|
+
if (this.originalCompositeLineAt) {
|
|
538
|
+
this.tui.compositeLineAt = this.originalCompositeLineAt;
|
|
539
|
+
this.originalCompositeLineAt = null;
|
|
540
|
+
}
|
|
541
|
+
if (this.rowsDescriptor) {
|
|
542
|
+
Object.defineProperty(this.terminal, "rows", this.rowsDescriptor);
|
|
543
|
+
} else {
|
|
544
|
+
Reflect.deleteProperty(this.terminal, "rows");
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
this.restoreTerminalState(options);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
private getRawRows(): number {
|
|
551
|
+
return Math.max(2, readRows(this.terminal, this.rowsDescriptor));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
private getScrollableRows(): number {
|
|
555
|
+
if (this.disposed || this.writing || this.renderingCluster || this.checkingOverlay || this.hasVisibleOverlay()) {
|
|
556
|
+
return this.getRawRows();
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const rawRows = this.getRawRows();
|
|
560
|
+
const width = Math.max(1, this.terminal.columns || 80);
|
|
561
|
+
const cluster = this.getCluster(width, rawRows);
|
|
562
|
+
return Math.max(1, rawRows - cluster.lines.length);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
private renderScrollableRoot(width: number): string[] {
|
|
566
|
+
if (!this.originalRender || this.disposed || this.renderingScrollableRoot) {
|
|
567
|
+
return this.originalRender?.(width) ?? [];
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (this.hasVisibleOverlay()) {
|
|
571
|
+
return this.originalRender(width).map((line) => sanitizeOverlayBaseLine(line, Math.max(1, width)));
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
this.renderingScrollableRoot = true;
|
|
575
|
+
try {
|
|
576
|
+
const start = this.refreshRootWindow(width);
|
|
577
|
+
return this.visibleRootLines.map((line, index) => {
|
|
578
|
+
return this.renderSelectionHighlight(line, start + index, "root");
|
|
579
|
+
});
|
|
580
|
+
} finally {
|
|
581
|
+
this.renderingScrollableRoot = false;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
private refreshRootWindow(width: number): number {
|
|
586
|
+
if (!this.originalRender) return this.updateVisibleRootWindow();
|
|
587
|
+
|
|
588
|
+
const rawRows = this.getRawRows();
|
|
589
|
+
const renderWidth = Math.max(1, width);
|
|
590
|
+
const cluster = this.getCluster(renderWidth, rawRows);
|
|
591
|
+
const scrollableRows = Math.max(1, rawRows - cluster.lines.length);
|
|
592
|
+
const lines = this.originalRender(renderWidth);
|
|
593
|
+
this.rootLines = lines;
|
|
594
|
+
if (this.scrollOffset > 0 && this.lastRootLineCount > 0 && lines.length > this.lastRootLineCount) {
|
|
595
|
+
this.scrollOffset += lines.length - this.lastRootLineCount;
|
|
596
|
+
}
|
|
597
|
+
this.lastRootLineCount = lines.length;
|
|
598
|
+
this.maxScrollOffset = Math.max(0, lines.length - scrollableRows);
|
|
599
|
+
this.scrollOffset = Math.max(0, Math.min(this.scrollOffset, this.maxScrollOffset));
|
|
600
|
+
|
|
601
|
+
return this.updateVisibleRootWindow(scrollableRows);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
private handleInput(data: string): { consume?: boolean; data?: string } | undefined {
|
|
605
|
+
if (this.disposed || this.hasVisibleOverlay()) return undefined;
|
|
606
|
+
|
|
607
|
+
const mousePackets = this.mouseScroll ? parseSgrMousePackets(data) : null;
|
|
608
|
+
if (mousePackets) {
|
|
609
|
+
for (const packet of mousePackets) {
|
|
610
|
+
this.handleMousePacket(packet);
|
|
611
|
+
}
|
|
612
|
+
return { consume: true };
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
const keyboardDelta = parseKeyboardScrollDelta(data, this.keyboardScrollShortcuts);
|
|
616
|
+
if (keyboardDelta === 0) return undefined;
|
|
617
|
+
|
|
618
|
+
this.scrollBy(keyboardDelta);
|
|
619
|
+
return { consume: true };
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
private handleMousePacket(packet: SgrMousePacket): void {
|
|
623
|
+
const delta = mouseScrollDelta(packet);
|
|
624
|
+
if (delta !== 0) {
|
|
625
|
+
this.selectionDragging = false;
|
|
626
|
+
this.scrollBy(delta);
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
const location = this.selectionLocationForPacket(packet);
|
|
631
|
+
|
|
632
|
+
if (isRightPress(packet)) {
|
|
633
|
+
this.selectionDragging = false;
|
|
634
|
+
this.preserveSelectionFocusOnRelease = false;
|
|
635
|
+
const selectedText = this.isLocationInsideSelection(location) ? this.getSelectedText() : "";
|
|
636
|
+
if (selectedText) {
|
|
637
|
+
this.onCopySelection?.(selectedText);
|
|
638
|
+
this.lastLeftPress = null;
|
|
639
|
+
this.pauseMouseReportingForContextMenu(selectedText);
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
this.clearSelection();
|
|
644
|
+
this.lastLeftPress = null;
|
|
645
|
+
this.pauseMouseReportingForContextMenu();
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (this.scrollSelectionAtViewportEdge(packet)) return;
|
|
650
|
+
if (this.selectionDragging && isMouseRelease(packet)) {
|
|
651
|
+
this.finishSelection(packet, location);
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (!location) return;
|
|
656
|
+
|
|
657
|
+
if (isLeftPress(packet)) {
|
|
658
|
+
this.startSelection(location);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (this.selectionDragging && isLeftDrag(packet) && location.area === this.selectionArea) {
|
|
663
|
+
this.lastLeftPress = null;
|
|
664
|
+
this.preserveSelectionFocusOnRelease = false;
|
|
665
|
+
this.selectionFocus = location.point;
|
|
666
|
+
this.requestRender();
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
private updateVisibleRootWindow(scrollableRows = this.visibleScrollableRows): number {
|
|
672
|
+
const rows = Math.max(1, scrollableRows);
|
|
673
|
+
const start = Math.max(0, this.rootLines.length - rows - this.scrollOffset);
|
|
674
|
+
const visibleLines = this.rootLines.slice(start, start + rows);
|
|
675
|
+
while (visibleLines.length < rows) {
|
|
676
|
+
visibleLines.push("");
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
this.visibleRootStart = start;
|
|
680
|
+
this.visibleScrollableRows = rows;
|
|
681
|
+
this.visibleRootLines = visibleLines;
|
|
682
|
+
return start;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
private finishSelection(packet: SgrMousePacket, location: SelectionLocation | null): void {
|
|
686
|
+
if (!this.preserveSelectionFocusOnRelease) {
|
|
687
|
+
this.selectionFocus = location?.area === this.selectionArea
|
|
688
|
+
? location.point
|
|
689
|
+
: this.clampedSelectionPointForPacket(packet, this.selectionArea);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
this.preserveSelectionFocusOnRelease = false;
|
|
693
|
+
this.selectionDragging = false;
|
|
694
|
+
const selectedText = this.getSelectedText();
|
|
695
|
+
if (selectedText) {
|
|
696
|
+
this.lastLeftPress = null;
|
|
697
|
+
this.onCopySelection?.(selectedText);
|
|
698
|
+
} else {
|
|
699
|
+
this.clearSelection();
|
|
700
|
+
}
|
|
701
|
+
this.requestRender();
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
private startSelection(location: SelectionLocation): void {
|
|
705
|
+
const now = Date.now();
|
|
706
|
+
const line = location.point.line;
|
|
707
|
+
if (
|
|
708
|
+
this.lastLeftPress
|
|
709
|
+
&& this.lastLeftPress.area === location.area
|
|
710
|
+
&& this.lastLeftPress.line === line
|
|
711
|
+
&& now - this.lastLeftPress.at <= DOUBLE_CLICK_MS
|
|
712
|
+
) {
|
|
713
|
+
this.selectionArea = location.area;
|
|
714
|
+
this.selectionAnchor = { line, col: 0 };
|
|
715
|
+
this.selectionFocus = { line, col: this.selectionLineWidth(location.area, line) };
|
|
716
|
+
this.selectionDragging = true;
|
|
717
|
+
this.preserveSelectionFocusOnRelease = true;
|
|
718
|
+
this.lastLeftPress = null;
|
|
719
|
+
this.requestRender();
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
this.selectionArea = location.area;
|
|
724
|
+
this.selectionAnchor = location.point;
|
|
725
|
+
this.selectionFocus = location.point;
|
|
726
|
+
this.selectionDragging = true;
|
|
727
|
+
this.preserveSelectionFocusOnRelease = false;
|
|
728
|
+
this.lastLeftPress = { area: location.area, line, at: now };
|
|
729
|
+
this.requestRender();
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
private selectionLocationForPacket(packet: SgrMousePacket): SelectionLocation | null {
|
|
733
|
+
if (packet.row < 1) return null;
|
|
734
|
+
|
|
735
|
+
const col = Math.max(0, packet.col - 1);
|
|
736
|
+
if (packet.row <= this.visibleScrollableRows) {
|
|
737
|
+
return {
|
|
738
|
+
area: "root",
|
|
739
|
+
point: { line: this.visibleRootStart + packet.row - 1, col },
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const clusterLine = packet.row - this.visibleScrollableRows - 1;
|
|
744
|
+
if (clusterLine >= this.visibleClusterLines.length) return null;
|
|
745
|
+
|
|
746
|
+
return {
|
|
747
|
+
area: "cluster",
|
|
748
|
+
point: { line: clusterLine, col },
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
private scrollSelectionAtViewportEdge(packet: SgrMousePacket): boolean {
|
|
753
|
+
if (!this.selectionDragging || this.selectionArea !== "root" || !isLeftDrag(packet)) return false;
|
|
754
|
+
|
|
755
|
+
const delta = packet.row <= 1 ? 1 : packet.row >= this.visibleScrollableRows ? -1 : 0;
|
|
756
|
+
if (delta === 0) return false;
|
|
757
|
+
|
|
758
|
+
const nextOffset = Math.max(0, Math.min(this.scrollOffset + delta, this.maxScrollOffset));
|
|
759
|
+
if (nextOffset === this.scrollOffset) return false;
|
|
760
|
+
|
|
761
|
+
this.lastLeftPress = null;
|
|
762
|
+
this.preserveSelectionFocusOnRelease = true;
|
|
763
|
+
this.scrollOffset = nextOffset;
|
|
764
|
+
const start = this.updateVisibleRootWindow();
|
|
765
|
+
const edgeLine = delta > 0 ? start : start + Math.max(0, this.visibleScrollableRows - 1);
|
|
766
|
+
this.selectionFocus = {
|
|
767
|
+
line: edgeLine,
|
|
768
|
+
col: Math.max(0, packet.col - 1),
|
|
769
|
+
};
|
|
770
|
+
this.requestRender();
|
|
771
|
+
return true;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
private clampedSelectionPointForPacket(packet: SgrMousePacket, area: SelectionArea | null): SelectionPoint {
|
|
775
|
+
if (area === "cluster") {
|
|
776
|
+
return {
|
|
777
|
+
line: Math.max(0, Math.min(packet.row - this.visibleScrollableRows - 1, this.visibleClusterLines.length - 1)),
|
|
778
|
+
col: Math.max(0, packet.col - 1),
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
const row = Math.max(1, Math.min(packet.row, this.visibleScrollableRows));
|
|
783
|
+
return {
|
|
784
|
+
line: this.visibleRootStart + row - 1,
|
|
785
|
+
col: Math.max(0, packet.col - 1),
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
private renderSelectionHighlight(line: string, lineIndex: number, area: SelectionArea): string {
|
|
790
|
+
const range = this.getSelectionRangeForLine(lineIndex, area);
|
|
791
|
+
if (!range) return line;
|
|
792
|
+
|
|
793
|
+
const plain = stripAnsi(line);
|
|
794
|
+
const startCol = Math.max(0, Math.min(range.startCol, visibleWidth(plain)));
|
|
795
|
+
const endCol = Math.max(startCol, Math.min(range.endCol, visibleWidth(plain)));
|
|
796
|
+
if (startCol === endCol) return line;
|
|
797
|
+
|
|
798
|
+
const before = sliceColumns(plain, 0, startCol);
|
|
799
|
+
const selected = sliceColumns(plain, startCol, endCol);
|
|
800
|
+
const after = sliceColumns(plain, endCol, Number.POSITIVE_INFINITY);
|
|
801
|
+
return `${before}\x1b[7m${selected}\x1b[27m${after}`;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
private selectionLineWidth(area: SelectionArea, lineIndex: number): number {
|
|
805
|
+
const lines = area === "root" ? this.visibleRootLines : this.visibleClusterLines;
|
|
806
|
+
const firstLine = area === "root" ? this.visibleRootStart : 0;
|
|
807
|
+
return visibleWidth(stripAnsi(lines[lineIndex - firstLine] ?? ""));
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
private getSelectedText(): string {
|
|
811
|
+
if (!this.selectionArea || !this.selectionAnchor || !this.selectionFocus) return "";
|
|
812
|
+
|
|
813
|
+
const start = compareSelectionPoints(this.selectionAnchor, this.selectionFocus) <= 0
|
|
814
|
+
? this.selectionAnchor
|
|
815
|
+
: this.selectionFocus;
|
|
816
|
+
const end = start === this.selectionAnchor ? this.selectionFocus : this.selectionAnchor;
|
|
817
|
+
if (start.line === end.line && start.col === end.col) return "";
|
|
818
|
+
|
|
819
|
+
const lines = this.selectionArea === "root" ? this.rootLines : this.visibleClusterLines;
|
|
820
|
+
const selected: string[] = [];
|
|
821
|
+
for (let lineIndex = start.line; lineIndex <= end.line; lineIndex++) {
|
|
822
|
+
const line = stripAnsi(lines[lineIndex] ?? "");
|
|
823
|
+
const startCol = lineIndex === start.line ? start.col : 0;
|
|
824
|
+
const endCol = lineIndex === end.line ? end.col : Number.POSITIVE_INFINITY;
|
|
825
|
+
selected.push(sliceColumns(line, startCol, endCol));
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
return selected.join("\n").replace(/[ \t]+$/gm, "").trimEnd();
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
private getSelectionRangeForLine(lineIndex: number, area: SelectionArea): { startCol: number; endCol: number } | null {
|
|
832
|
+
if (this.selectionArea !== area || !this.selectionAnchor || !this.selectionFocus) return null;
|
|
833
|
+
|
|
834
|
+
const start = compareSelectionPoints(this.selectionAnchor, this.selectionFocus) <= 0
|
|
835
|
+
? this.selectionAnchor
|
|
836
|
+
: this.selectionFocus;
|
|
837
|
+
const end = start === this.selectionAnchor ? this.selectionFocus : this.selectionAnchor;
|
|
838
|
+
if (lineIndex < start.line || lineIndex > end.line) return null;
|
|
839
|
+
|
|
840
|
+
return {
|
|
841
|
+
startCol: lineIndex === start.line ? start.col : 0,
|
|
842
|
+
endCol: lineIndex === end.line ? end.col : Number.POSITIVE_INFINITY,
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
private isLocationInsideSelection(location: SelectionLocation | null): boolean {
|
|
847
|
+
if (!location || location.area !== this.selectionArea) return false;
|
|
848
|
+
const range = this.getSelectionRangeForLine(location.point.line, location.area);
|
|
849
|
+
return Boolean(range && location.point.col >= range.startCol && location.point.col < range.endCol);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
private scrollBy(delta: number): void {
|
|
853
|
+
const width = Math.max(1, this.terminal.columns || 80);
|
|
854
|
+
this.refreshRootWindow(width);
|
|
855
|
+
|
|
856
|
+
const nextOffset = Math.max(0, Math.min(this.scrollOffset + delta, this.maxScrollOffset));
|
|
857
|
+
if (nextOffset === this.scrollOffset) return;
|
|
858
|
+
|
|
859
|
+
this.clearSelection();
|
|
860
|
+
this.lastLeftPress = null;
|
|
861
|
+
this.scrollOffset = nextOffset;
|
|
862
|
+
this.repaintScrollableViewport(width);
|
|
863
|
+
this.requestRender();
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
private requestRender(): void {
|
|
867
|
+
if (typeof this.tui.requestRender === "function") {
|
|
868
|
+
this.tui.requestRender();
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
private repaintScrollableViewport(width: number): void {
|
|
873
|
+
if (this.disposed || this.writing || this.hasVisibleOverlay()) return;
|
|
874
|
+
|
|
875
|
+
const rawRows = this.getRawRows();
|
|
876
|
+
const cluster = this.getCluster(width, rawRows);
|
|
877
|
+
const scrollableRows = Math.max(1, rawRows - cluster.lines.length);
|
|
878
|
+
const start = this.updateVisibleRootWindow(scrollableRows);
|
|
879
|
+
let buffer = beginSynchronizedOutput() + setScrollRegion(1, scrollableRows) + moveCursor(1, 1);
|
|
880
|
+
|
|
881
|
+
for (let row = 0; row < scrollableRows; row++) {
|
|
882
|
+
if (row > 0) buffer += "\r\n";
|
|
883
|
+
buffer += clearLine();
|
|
884
|
+
buffer += sanitizeLine(this.renderSelectionHighlight(this.visibleRootLines[row] ?? "", start + row, "root"), width);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
buffer += buildFixedClusterPaint(this.decorateCluster(cluster), rawRows, width, this.getShowHardwareCursor());
|
|
888
|
+
buffer += endSynchronizedOutput();
|
|
889
|
+
this.originalWrite(buffer);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
private pauseMouseReportingForContextMenu(textToRestoreToClipboard: string | null = null): void {
|
|
893
|
+
if (this.mouseReportingResumeTimer) {
|
|
894
|
+
clearTimeout(this.mouseReportingResumeTimer);
|
|
895
|
+
}
|
|
896
|
+
if (this.clipboardRestoreTimer) {
|
|
897
|
+
clearTimeout(this.clipboardRestoreTimer);
|
|
898
|
+
this.clipboardRestoreTimer = null;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
this.originalWrite(beginSynchronizedOutput() + disableMouseReporting() + endSynchronizedOutput());
|
|
902
|
+
this.mouseReportingResumeTimer = setTimeout(() => {
|
|
903
|
+
this.mouseReportingResumeTimer = null;
|
|
904
|
+
if (!this.disposed) {
|
|
905
|
+
this.originalWrite(beginSynchronizedOutput() + enableMouseReporting() + endSynchronizedOutput());
|
|
906
|
+
}
|
|
907
|
+
}, CONTEXT_MENU_MOUSE_REPORTING_PAUSE_MS);
|
|
908
|
+
|
|
909
|
+
if (typeof this.mouseReportingResumeTimer === "object" && "unref" in this.mouseReportingResumeTimer) {
|
|
910
|
+
this.mouseReportingResumeTimer.unref();
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
const restoreClipboard = this.onCopySelection;
|
|
914
|
+
if (!textToRestoreToClipboard || !restoreClipboard) return;
|
|
915
|
+
|
|
916
|
+
let remainingRestores = Math.ceil(CONTEXT_MENU_SELECTION_RESTORE_WINDOW_MS / CONTEXT_MENU_CLIPBOARD_RESTORE_INTERVAL_MS);
|
|
917
|
+
const scheduleClipboardRestore = () => {
|
|
918
|
+
this.clipboardRestoreTimer = setTimeout(() => {
|
|
919
|
+
this.clipboardRestoreTimer = null;
|
|
920
|
+
if (this.disposed) return;
|
|
921
|
+
|
|
922
|
+
remainingRestores -= 1;
|
|
923
|
+
if (this.getSelectedText() !== textToRestoreToClipboard) return;
|
|
924
|
+
|
|
925
|
+
restoreClipboard(textToRestoreToClipboard);
|
|
926
|
+
if (remainingRestores > 0) {
|
|
927
|
+
scheduleClipboardRestore();
|
|
928
|
+
}
|
|
929
|
+
}, CONTEXT_MENU_CLIPBOARD_RESTORE_INTERVAL_MS);
|
|
930
|
+
|
|
931
|
+
if (typeof this.clipboardRestoreTimer === "object" && "unref" in this.clipboardRestoreTimer) {
|
|
932
|
+
this.clipboardRestoreTimer.unref();
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
scheduleClipboardRestore();
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
private clearSelection(): void {
|
|
940
|
+
this.selectionArea = null;
|
|
941
|
+
this.selectionAnchor = null;
|
|
942
|
+
this.selectionFocus = null;
|
|
943
|
+
this.selectionDragging = false;
|
|
944
|
+
this.preserveSelectionFocusOnRelease = false;
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
private activeExtendedKeyboardMode(): ExtendedKeyboardMode | null {
|
|
948
|
+
if (this.terminal.kittyProtocolActive === true) return "kitty";
|
|
949
|
+
if (Reflect.get(this.terminal, "_modifyOtherKeysActive") === true) return "modifyOtherKeys";
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
private enableAlternateScreenKeyboardMode(): string {
|
|
954
|
+
this.extendedKeyboardMode = this.activeExtendedKeyboardMode();
|
|
955
|
+
return this.extendedKeyboardMode ? enableExtendedKeyboardMode(this.extendedKeyboardMode) : "";
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
private restoreTerminalState(options: DisposeOptions = {}): void {
|
|
959
|
+
const activeMode = this.extendedKeyboardMode ?? this.activeExtendedKeyboardMode();
|
|
960
|
+
const restoreMainScreenMode = !options.resetExtendedKeyboardModes && this.extendedKeyboardMode === null && activeMode !== null;
|
|
961
|
+
|
|
962
|
+
this.originalWrite(
|
|
963
|
+
beginSynchronizedOutput()
|
|
964
|
+
+ resetScrollRegion()
|
|
965
|
+
+ (this.mouseScroll ? disableMouseReporting() : "")
|
|
966
|
+
+ (activeMode ? disableExtendedKeyboardMode(activeMode) : "")
|
|
967
|
+
+ enableAlternateScrollMode()
|
|
968
|
+
+ exitAlternateScreen()
|
|
969
|
+
+ (restoreMainScreenMode && activeMode ? enableExtendedKeyboardMode(activeMode) : "")
|
|
970
|
+
+ (options.resetExtendedKeyboardModes ? resetExtendedKeyboardModes() : "")
|
|
971
|
+
+ endSynchronizedOutput(),
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
private restoreTerminalStateForExit(): void {
|
|
976
|
+
try {
|
|
977
|
+
this.restoreTerminalState({ resetExtendedKeyboardModes: true });
|
|
978
|
+
} catch {
|
|
979
|
+
// Process-exit cleanup cannot report useful errors and must not throw.
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
private write(data: string): void {
|
|
984
|
+
if (this.disposed || this.writing || this.hasVisibleOverlay()) {
|
|
985
|
+
this.originalWrite(data);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
this.writing = true;
|
|
990
|
+
try {
|
|
991
|
+
const rawRows = this.getRawRows();
|
|
992
|
+
const width = Math.max(1, this.terminal.columns || 80);
|
|
993
|
+
const cluster = this.getCluster(width, rawRows);
|
|
994
|
+
const reservedRows = cluster.lines.length;
|
|
995
|
+
|
|
996
|
+
if (reservedRows === 0 || rawRows <= 2) {
|
|
997
|
+
this.originalWrite(data);
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
const scrollBottom = Math.max(1, rawRows - reservedRows);
|
|
1002
|
+
const hardwareCursorRow = typeof this.tui.hardwareCursorRow === "number"
|
|
1003
|
+
? this.tui.hardwareCursorRow
|
|
1004
|
+
: typeof this.tui.cursorRow === "number"
|
|
1005
|
+
? this.tui.cursorRow
|
|
1006
|
+
: 0;
|
|
1007
|
+
const viewportTop = typeof this.tui.previousViewportTop === "number" ? this.tui.previousViewportTop : 0;
|
|
1008
|
+
const screenRow = Math.max(1, Math.min(scrollBottom, hardwareCursorRow - viewportTop + 1));
|
|
1009
|
+
const buffer = beginSynchronizedOutput()
|
|
1010
|
+
+ setScrollRegion(1, scrollBottom)
|
|
1011
|
+
+ moveCursor(screenRow, 1)
|
|
1012
|
+
+ data
|
|
1013
|
+
+ buildFixedClusterPaint(this.decorateCluster(cluster), rawRows, width, this.getShowHardwareCursor())
|
|
1014
|
+
+ endSynchronizedOutput();
|
|
1015
|
+
|
|
1016
|
+
this.originalWrite(buffer);
|
|
1017
|
+
} finally {
|
|
1018
|
+
this.writing = false;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
private getCluster(width: number, terminalRows: number): FixedEditorClusterRender {
|
|
1023
|
+
if (
|
|
1024
|
+
this.renderPassActive &&
|
|
1025
|
+
this.renderPassCluster?.width === width &&
|
|
1026
|
+
this.renderPassCluster.terminalRows === terminalRows
|
|
1027
|
+
) {
|
|
1028
|
+
return this.renderPassCluster.cluster;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
const cluster = this.withClusterRender(() => this.renderCluster(width, terminalRows));
|
|
1032
|
+
this.visibleClusterLines = cluster.lines;
|
|
1033
|
+
if (this.renderPassActive) {
|
|
1034
|
+
this.renderPassCluster = { width, terminalRows, cluster };
|
|
1035
|
+
}
|
|
1036
|
+
return cluster;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
private decorateCluster(cluster: FixedEditorClusterRender): FixedEditorClusterRender {
|
|
1040
|
+
if (this.selectionArea !== "cluster") return cluster;
|
|
1041
|
+
|
|
1042
|
+
return {
|
|
1043
|
+
...cluster,
|
|
1044
|
+
lines: cluster.lines.map((line, index) => this.renderSelectionHighlight(line, index, "cluster")),
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
private withClusterRender<T>(render: () => T): T {
|
|
1049
|
+
const wasRenderingCluster = this.renderingCluster;
|
|
1050
|
+
this.renderingCluster = true;
|
|
1051
|
+
try {
|
|
1052
|
+
return render();
|
|
1053
|
+
} finally {
|
|
1054
|
+
this.renderingCluster = wasRenderingCluster;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
private hasVisibleOverlay(): boolean {
|
|
1059
|
+
if (this.checkingOverlay) return false;
|
|
1060
|
+
|
|
1061
|
+
this.checkingOverlay = true;
|
|
1062
|
+
try {
|
|
1063
|
+
if (typeof this.tui.hasOverlay === "function" && this.tui.hasOverlay()) {
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
const overlayStack = Reflect.get(this.tui, "overlayStack");
|
|
1068
|
+
if (!Array.isArray(overlayStack)) {
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
return overlayStack.some((entry) => entry && entry.hidden !== true);
|
|
1073
|
+
} finally {
|
|
1074
|
+
this.checkingOverlay = false;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|