@oh-my-pi/pi-tui 18.2.4 → 18.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +43 -0
- package/dist/types/app-keybindings.d.ts +395 -0
- package/dist/types/apps/autoresearch-dashboard.d.ts +43 -0
- package/dist/types/apps/autoresearch-data.d.ts +15 -0
- package/dist/types/apps/cleanse-board.d.ts +66 -0
- package/dist/types/apps/cleanse-picker.d.ts +23 -0
- package/dist/types/apps/debug/log-formatting.d.ts +6 -0
- package/dist/types/apps/debug/log-viewer.d.ts +81 -0
- package/dist/types/apps/debug/protocol-probe.d.ts +42 -0
- package/dist/types/apps/debug/raw-sse-buffer.d.ts +58 -0
- package/dist/types/apps/debug/raw-sse.d.ts +26 -0
- package/dist/types/apps/debug/terminal-info.d.ts +34 -0
- package/dist/types/apps/debug/viewer-frame.d.ts +52 -0
- package/dist/types/apps/git/avatar.d.ts +9 -0
- package/dist/types/apps/git/colors.d.ts +49 -0
- package/dist/types/apps/git/diff-pane.d.ts +188 -0
- package/dist/types/apps/git/git-tui.d.ts +66 -0
- package/dist/types/apps/git/sidebar.d.ts +149 -0
- package/dist/types/apps/git/state.d.ts +117 -0
- package/dist/types/apps/if-bench-board.d.ts +75 -0
- package/dist/types/apps/live-visualizer.d.ts +33 -0
- package/dist/types/apps/ps-data.d.ts +51 -0
- package/dist/types/apps/ps-top.d.ts +33 -0
- package/dist/types/apps/session-picker.d.ts +26 -0
- package/dist/types/apps/setup-model-picker.d.ts +13 -0
- package/dist/types/apps/standalone-picker.d.ts +42 -0
- package/dist/types/autocomplete.d.ts +4 -0
- package/dist/types/chat/advisor-message.d.ts +11 -0
- package/dist/types/chat/assistant-message.d.ts +106 -0
- package/dist/types/chat/background-tan-message.d.ts +9 -0
- package/dist/types/chat/bash-execution.d.ts +47 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +50 -0
- package/dist/types/chat/chat-transcript-builder.d.ts +50 -0
- package/dist/types/chat/collab-prompt-message.d.ts +10 -0
- package/dist/types/chat/compaction-summary-message.d.ts +54 -0
- package/dist/types/chat/custom-message.d.ts +10 -0
- package/dist/types/chat/display-preferences.d.ts +13 -0
- package/dist/types/chat/eval-execution.d.ts +29 -0
- package/dist/types/chat/execution-shared.d.ts +51 -0
- package/dist/types/chat/extension-types.d.ts +28 -0
- package/dist/types/chat/hook-message.d.ts +10 -0
- package/dist/types/chat/image-loading.d.ts +46 -0
- package/dist/types/chat/late-diagnostics-message.d.ts +21 -0
- package/dist/types/chat/messages.d.ts +189 -0
- package/dist/types/chat/reaction.d.ts +30 -0
- package/dist/types/chat/read-target.d.ts +4 -0
- package/dist/types/chat/read-tool-group.d.ts +67 -0
- package/dist/types/chat/served-model-marker.d.ts +47 -0
- package/dist/types/chat/skill-message.d.ts +33 -0
- package/dist/types/chat/skill-title-input.d.ts +14 -0
- package/dist/types/chat/stripped-tool-calls-placeholder.d.ts +12 -0
- package/dist/types/chat/thinking-display.d.ts +12 -0
- package/dist/types/chat/todo-reminder.d.ts +13 -0
- package/dist/types/chat/tool-execution.d.ts +138 -0
- package/dist/types/chat/transcript-browser.d.ts +93 -0
- package/dist/types/chat/transcript-entry.d.ts +45 -0
- package/dist/types/chat/transcript-outline.d.ts +86 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +92 -0
- package/dist/types/chat/ttsr-notification.d.ts +23 -0
- package/dist/types/chat/user-message.d.ts +52 -0
- package/dist/types/chrome/chat-block.d.ts +64 -0
- package/dist/types/chrome/collab-qrcode.d.ts +28 -0
- package/dist/types/chrome/context-thresholds.d.ts +10 -0
- package/dist/types/chrome/countdown-timer.d.ts +14 -0
- package/dist/types/chrome/diff.d.ts +14 -0
- package/dist/types/chrome/dynamic-border.d.ts +16 -0
- package/dist/types/chrome/error-block.d.ts +17 -0
- package/dist/types/chrome/form-theme.d.ts +3 -0
- package/dist/types/chrome/format.d.ts +12 -0
- package/dist/types/chrome/index.d.ts +20 -0
- package/dist/types/chrome/keybinding-hints.d.ts +40 -0
- package/dist/types/chrome/live-board.d.ts +23 -0
- package/dist/types/chrome/local-date.d.ts +4 -0
- package/dist/types/chrome/message-divider.d.ts +22 -0
- package/dist/types/chrome/message-frame.d.ts +52 -0
- package/dist/types/chrome/message-notice.d.ts +35 -0
- package/dist/types/chrome/overlay-box.d.ts +74 -0
- package/dist/types/chrome/qrcode.d.ts +48 -0
- package/dist/types/chrome/segment-track.d.ts +27 -0
- package/dist/types/chrome/select-list-mouse-routing.d.ts +4 -0
- package/dist/types/chrome/selector-helpers.d.ts +52 -0
- package/dist/types/chrome/shared.d.ts +5 -0
- package/dist/types/chrome/streaming-panel.d.ts +19 -0
- package/dist/types/chrome/tool-activity.d.ts +17 -0
- package/dist/types/chrome/transcript-container.d.ts +129 -0
- package/dist/types/chrome/transcript-status.d.ts +12 -0
- package/dist/types/chrome/visual-truncate.d.ts +19 -0
- package/dist/types/components/disclosure.d.ts +42 -0
- package/dist/types/components/form.d.ts +130 -0
- package/dist/types/components/key-value-list.d.ts +24 -0
- package/dist/types/components/layout/geometry.d.ts +73 -0
- package/dist/types/components/layout/row.d.ts +55 -0
- package/dist/types/components/layout/split-pane.d.ts +80 -0
- package/dist/types/components/layout/stack.d.ts +50 -0
- package/dist/types/components/menu-selection.d.ts +71 -0
- package/dist/types/components/metric.d.ts +44 -0
- package/dist/types/components/progress-bar.d.ts +36 -0
- package/dist/types/components/scroll-view.d.ts +53 -19
- package/dist/types/components/scroll-viewport.d.ts +46 -0
- package/dist/types/components/section.d.ts +19 -0
- package/dist/types/components/select-list.d.ts +46 -2
- package/dist/types/components/settings-list.d.ts +20 -0
- package/dist/types/components/table.d.ts +32 -0
- package/dist/types/components/tree-view.d.ts +130 -0
- package/dist/types/components/wizard-step.d.ts +60 -0
- package/dist/types/hotkeys-markdown.d.ts +7 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/keybinding-matchers.d.ts +35 -0
- package/dist/types/keys.d.ts +2 -2
- package/dist/types/lang-from-path.d.ts +9 -0
- package/dist/types/overlays/advisor-config.d.ts +114 -0
- package/dist/types/overlays/agent-activity.d.ts +41 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +33 -0
- package/dist/types/overlays/agent-hub-renderer.d.ts +53 -0
- package/dist/types/overlays/agent-hub-types.d.ts +99 -0
- package/dist/types/overlays/agent-hub.d.ts +126 -0
- package/dist/types/overlays/agent-transcript-viewer.d.ts +71 -0
- package/dist/types/overlays/agents-hub.d.ts +72 -0
- package/dist/types/overlays/ask-dialog.d.ts +88 -0
- package/dist/types/overlays/bordered-loader.d.ts +11 -0
- package/dist/types/overlays/btw-history-panel.d.ts +29 -0
- package/dist/types/overlays/btw-history.d.ts +17 -0
- package/dist/types/overlays/btw-panel.d.ts +26 -0
- package/dist/types/overlays/cleanse-panel.d.ts +36 -0
- package/dist/types/overlays/codex-reset-fireworks.d.ts +52 -0
- package/dist/types/overlays/composer-shape-preview.d.ts +47 -0
- package/dist/types/overlays/composer-shape-registry.d.ts +50 -0
- package/dist/types/overlays/copy-selector.d.ts +48 -0
- package/dist/types/overlays/copy-targets.d.ts +63 -0
- package/dist/types/overlays/error-banner.d.ts +13 -0
- package/dist/types/overlays/extensions/display-text.d.ts +10 -0
- package/dist/types/overlays/extensions/extension-dashboard.d.ts +63 -0
- package/dist/types/overlays/extensions/extension-list.d.ts +54 -0
- package/dist/types/overlays/extensions/inspector-model.d.ts +109 -0
- package/dist/types/overlays/extensions/inspector-panel.d.ts +17 -0
- package/dist/types/overlays/extensions/live-tool-session.d.ts +28 -0
- package/dist/types/overlays/extensions/mcp-runtime.d.ts +107 -0
- package/dist/types/overlays/extensions/state-manager.d.ts +42 -0
- package/dist/types/overlays/extensions/types.d.ts +165 -0
- package/dist/types/overlays/history-search.d.ts +16 -0
- package/dist/types/overlays/hook-editor.d.ts +44 -0
- package/dist/types/overlays/hook-input.d.ts +20 -0
- package/dist/types/overlays/hook-selector.d.ts +71 -0
- package/dist/types/overlays/hub-frame.d.ts +77 -0
- package/dist/types/overlays/login-dialog.d.ts +43 -0
- package/dist/types/overlays/logout-account-selector.d.ts +15 -0
- package/dist/types/overlays/mcp-add-wizard.d.ts +87 -0
- package/dist/types/overlays/model-browser.d.ts +213 -0
- package/dist/types/overlays/model-hub.d.ts +72 -0
- package/dist/types/overlays/model-picker.d.ts +74 -0
- package/dist/types/overlays/model-selector.d.ts +52 -0
- package/dist/types/overlays/move-overlay.d.ts +39 -0
- package/dist/types/overlays/oauth-selector.d.ts +41 -0
- package/dist/types/overlays/omfg-panel.d.ts +20 -0
- package/dist/types/overlays/pause-screen.d.ts +43 -0
- package/dist/types/overlays/plan-review-overlay.d.ts +89 -0
- package/dist/types/overlays/plan-save-overlay.d.ts +19 -0
- package/dist/types/overlays/plan-toc.d.ts +41 -0
- package/dist/types/overlays/plugin-selector.d.ts +28 -0
- package/dist/types/overlays/plugin-settings.d.ts +180 -0
- package/dist/types/overlays/queue-mode-selector.d.ts +11 -0
- package/dist/types/overlays/reset-usage-selector.d.ts +23 -0
- package/dist/types/overlays/rewind-selector.d.ts +61 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +6 -0
- package/dist/types/overlays/session-account-selector.d.ts +24 -0
- package/dist/types/overlays/session-info-overlay.d.ts +17 -0
- package/dist/types/overlays/session-observer-registry.d.ts +77 -0
- package/dist/types/overlays/session-selector.d.ts +131 -0
- package/dist/types/overlays/settings-defs.d.ts +119 -0
- package/dist/types/overlays/settings-selector.d.ts +73 -0
- package/dist/types/overlays/show-images-selector.d.ts +11 -0
- package/dist/types/overlays/snapcompact-shape-preview.d.ts +31 -0
- package/dist/types/overlays/theme-selector.d.ts +12 -0
- package/dist/types/overlays/thinking-selector.d.ts +12 -0
- package/dist/types/overlays/tiny-title-download-progress.d.ts +21 -0
- package/dist/types/overlays/tree-selector.d.ts +92 -0
- package/dist/types/overlays/usage-dashboard.d.ts +94 -0
- package/dist/types/overlays/usage-display.d.ts +5 -0
- package/dist/types/overlays/usage-row.d.ts +17 -0
- package/dist/types/prompt/attachment-chips.d.ts +19 -0
- package/dist/types/prompt/composer-attachments.d.ts +71 -0
- package/dist/types/prompt/composer-cache.d.ts +37 -0
- package/dist/types/prompt/composer.d.ts +159 -0
- package/dist/types/prompt/custom-editor.d.ts +261 -0
- package/dist/types/prompt/editor-top-gap.d.ts +18 -0
- package/dist/types/prompt/emoji-autocomplete.d.ts +16 -0
- package/dist/types/prompt/github-ref-autocomplete.d.ts +35 -0
- package/dist/types/prompt/gradient-highlight.d.ts +32 -0
- package/dist/types/prompt/image-format.d.ts +4 -0
- package/dist/types/prompt/image-references.d.ts +26 -0
- package/dist/types/prompt/interactive-context-helpers.d.ts +43 -0
- package/dist/types/prompt/internal-url-autocomplete.d.ts +56 -0
- package/dist/types/prompt/macos-spelling.d.ts +44 -0
- package/dist/types/prompt/magic-keyword-boundary.d.ts +9 -0
- package/dist/types/prompt/magic-keywords.d.ts +26 -0
- package/dist/types/prompt/markdown-prose.d.ts +15 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +25 -0
- package/dist/types/prompt/model-mention-syntax.d.ts +24 -0
- package/dist/types/prompt/orchestrate.d.ts +13 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +56 -0
- package/dist/types/prompt/queue-input.d.ts +8 -0
- package/dist/types/prompt/skill-tokens.d.ts +13 -0
- package/dist/types/prompt/tools-markdown.d.ts +12 -0
- package/dist/types/prompt/ultrathink.d.ts +13 -0
- package/dist/types/prompt/usage-amounts.d.ts +26 -0
- package/dist/types/prompt/video.d.ts +18 -0
- package/dist/types/prompt/welcome.d.ts +83 -0
- package/dist/types/prompt/workflow.d.ts +13 -0
- package/dist/types/render/code-cell.d.ts +51 -0
- package/dist/types/render/file-list.d.ts +22 -0
- package/dist/types/render/hyperlink.d.ts +80 -0
- package/dist/types/render/index.d.ts +16 -0
- package/dist/types/render/output-block.d.ts +54 -0
- package/dist/types/render/output-pane.d.ts +80 -0
- package/dist/types/render/render-utils.d.ts +312 -0
- package/dist/types/render/sixel.d.ts +21 -0
- package/dist/types/render/status-line.d.ts +23 -0
- package/dist/types/render/tool-card.d.ts +71 -0
- package/dist/types/render/tree-list.d.ts +29 -0
- package/dist/types/render/types.d.ts +17 -0
- package/dist/types/render/utils.d.ts +43 -0
- package/dist/types/render/width-aware-text.d.ts +23 -0
- package/dist/types/setup/lazy.d.ts +3 -0
- package/dist/types/setup/scenes/composer.d.ts +3 -0
- package/dist/types/setup/scenes/glyph.d.ts +3 -0
- package/dist/types/setup/scenes/model.d.ts +3 -0
- package/dist/types/setup/scenes/outro.d.ts +2 -0
- package/dist/types/setup/scenes/providers.d.ts +3 -0
- package/dist/types/setup/scenes/sign-in.d.ts +21 -0
- package/dist/types/setup/scenes/splash.d.ts +11 -0
- package/dist/types/setup/scenes/theme.d.ts +3 -0
- package/dist/types/setup/scenes/types.d.ts +110 -0
- package/dist/types/setup/scenes/web-search.d.ts +22 -0
- package/dist/types/setup/setup-version.d.ts +11 -0
- package/dist/types/setup/startup-splash.d.ts +9 -0
- package/dist/types/setup/wizard-overlay.d.ts +16 -0
- package/dist/types/setup/wizard.d.ts +25 -0
- package/dist/types/status-line/component.d.ts +182 -0
- package/dist/types/status-line/context-usage.d.ts +156 -0
- package/dist/types/status-line/footer.d.ts +30 -0
- package/dist/types/status-line/git-utils.d.ts +22 -0
- package/dist/types/status-line/host.d.ts +129 -0
- package/dist/types/status-line/index.d.ts +6 -0
- package/dist/types/status-line/loop.d.ts +18 -0
- package/dist/types/status-line/metrics.d.ts +21 -0
- package/dist/types/status-line/presets.d.ts +3 -0
- package/dist/types/status-line/schema.d.ts +15 -0
- package/dist/types/status-line/segments.d.ts +5 -0
- package/dist/types/status-line/separators.d.ts +3 -0
- package/dist/types/status-line/types.d.ts +236 -0
- package/dist/types/stdin-buffer.d.ts +4 -0
- package/dist/types/theme/color.d.ts +24 -0
- package/dist/types/theme/defaults/index.d.ts +9489 -0
- package/dist/types/theme/index.d.ts +4 -0
- package/dist/types/theme/loader.d.ts +23 -0
- package/dist/types/theme/mermaid-cache.d.ts +26 -0
- package/dist/types/theme/schema-validation.d.ts +3 -0
- package/dist/types/theme/schema.d.ts +25 -0
- package/dist/types/theme/session-color.d.ts +43 -0
- package/dist/types/theme/shimmer.d.ts +44 -0
- package/dist/types/theme/symbols.d.ts +34 -0
- package/dist/types/theme/theme-class.d.ts +299 -0
- package/dist/types/theme/theme.d.ts +111 -0
- package/dist/types/theme/tui-adapters.d.ts +30 -0
- package/dist/types/thinking.d.ts +165 -0
- package/dist/types/tools/agent-tree.d.ts +36 -0
- package/dist/types/tools/ask.d.ts +67 -0
- package/dist/types/tools/ast-edit.d.ts +53 -0
- package/dist/types/tools/ast-grep.d.ts +52 -0
- package/dist/types/tools/autoresearch.d.ts +156 -0
- package/dist/types/tools/bash-interactive.d.ts +28 -0
- package/dist/types/tools/bash.d.ts +103 -0
- package/dist/types/tools/conflict-detect.d.ts +43 -0
- package/dist/types/tools/debug.d.ts +60 -0
- package/dist/types/tools/default-renderer.d.ts +24 -0
- package/dist/types/tools/edit.d.ts +158 -0
- package/dist/types/tools/eval-format/code-mode-declarations.d.ts +5 -0
- package/dist/types/tools/eval-format/index.d.ts +5 -0
- package/dist/types/tools/eval-format/javascript.d.ts +2 -0
- package/dist/types/tools/eval-format/python.d.ts +2 -0
- package/dist/types/tools/eval.d.ts +94 -0
- package/dist/types/tools/fetch.d.ts +42 -0
- package/dist/types/tools/gh-format.d.ts +8 -0
- package/dist/types/tools/github.d.ts +144 -0
- package/dist/types/tools/glob.d.ts +44 -0
- package/dist/types/tools/goal.d.ts +42 -0
- package/dist/types/tools/grep.d.ts +64 -0
- package/dist/types/tools/grouped-file-output.d.ts +71 -0
- package/dist/types/tools/hashline-format.d.ts +28 -0
- package/dist/types/tools/hub.d.ts +340 -0
- package/dist/types/tools/index.d.ts +4 -0
- package/dist/types/tools/json-tree.d.ts +59 -0
- package/dist/types/tools/line-ranges.d.ts +29 -0
- package/dist/types/tools/list-limit.d.ts +15 -0
- package/dist/types/tools/lsp.d.ts +72 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/mcp.d.ts +81 -0
- package/dist/types/tools/memory.d.ts +67 -0
- package/dist/types/tools/output-meta.d.ts +151 -0
- package/dist/types/tools/read.d.ts +139 -0
- package/dist/types/tools/renderer.d.ts +98 -0
- package/dist/types/tools/report-tool-issue.d.ts +8 -0
- package/dist/types/tools/resolve.d.ts +47 -0
- package/dist/types/tools/streaming-output.d.ts +282 -0
- package/dist/types/tools/subprocess.d.ts +24 -0
- package/dist/types/tools/task-repair-args.d.ts +53 -0
- package/dist/types/tools/task-yield-assembly.d.ts +20 -0
- package/dist/types/tools/task.d.ts +425 -0
- package/dist/types/tools/terminal-output.d.ts +8 -0
- package/dist/types/tools/think.d.ts +13 -0
- package/dist/types/tools/todo.d.ts +118 -0
- package/dist/types/tools/tool-errors.d.ts +7 -0
- package/dist/types/tools/vibe.d.ts +120 -0
- package/dist/types/tools/web-search.d.ts +195 -0
- package/dist/types/tools/write.d.ts +76 -0
- package/dist/types/tools/xd-url.d.ts +13 -0
- package/dist/types/tools/xdev.d.ts +52 -0
- package/dist/types/tui.d.ts +18 -0
- package/dist/types/utils.d.ts +2 -0
- package/package.json +37 -3
- package/src/app-keybindings.ts +760 -0
- package/src/apps/autoresearch-dashboard.ts +500 -0
- package/src/apps/autoresearch-data.ts +64 -0
- package/src/apps/cleanse-board.ts +341 -0
- package/src/apps/cleanse-picker.ts +57 -0
- package/src/apps/debug/log-formatting.ts +53 -0
- package/src/apps/debug/log-viewer.ts +868 -0
- package/src/apps/debug/protocol-probe.ts +267 -0
- package/src/apps/debug/raw-sse-buffer.ts +449 -0
- package/src/apps/debug/raw-sse.ts +282 -0
- package/src/apps/debug/terminal-info.ts +115 -0
- package/src/apps/debug/viewer-frame.ts +174 -0
- package/src/apps/git/avatar.ts +52 -0
- package/src/apps/git/colors.ts +109 -0
- package/src/apps/git/diff-pane.ts +1512 -0
- package/src/apps/git/git-tui.ts +889 -0
- package/src/apps/git/sidebar.ts +1204 -0
- package/src/apps/git/state.ts +113 -0
- package/src/apps/if-bench-board.ts +324 -0
- package/src/apps/live-visualizer.ts +238 -0
- package/src/apps/ps-data.ts +116 -0
- package/src/apps/ps-top.ts +422 -0
- package/src/apps/session-picker.ts +95 -0
- package/src/apps/setup-model-picker.ts +21 -0
- package/src/apps/standalone-picker.ts +111 -0
- package/src/autocomplete.ts +9 -13
- package/src/chat/advisor-message.ts +175 -0
- package/src/chat/assistant-message.ts +1214 -0
- package/src/chat/background-tan-message.ts +35 -0
- package/src/chat/bash-execution.ts +394 -0
- package/src/chat/cache-invalidation-marker.ts +94 -0
- package/src/chat/chat-transcript-builder.ts +593 -0
- package/src/chat/collab-prompt-message.ts +34 -0
- package/src/chat/compaction-summary-message.ts +261 -0
- package/src/chat/custom-message.ts +23 -0
- package/src/chat/display-preferences.ts +24 -0
- package/src/chat/eval-execution.ts +172 -0
- package/src/chat/execution-shared.ts +113 -0
- package/src/chat/extension-types.ts +46 -0
- package/src/chat/hook-message.ts +20 -0
- package/src/chat/image-loading.ts +122 -0
- package/src/chat/late-diagnostics-message.ts +92 -0
- package/src/chat/messages.ts +305 -0
- package/src/chat/reaction.ts +65 -0
- package/src/chat/read-target.ts +7 -0
- package/src/chat/read-tool-group.ts +873 -0
- package/src/chat/served-model-marker.ts +91 -0
- package/src/chat/skill-message.ts +220 -0
- package/src/chat/skill-title-input.ts +41 -0
- package/src/chat/stripped-tool-calls-placeholder.ts +35 -0
- package/src/chat/thinking-display.ts +312 -0
- package/src/chat/todo-reminder.ts +33 -0
- package/src/chat/tool-execution.ts +1395 -0
- package/src/chat/transcript-browser.ts +268 -0
- package/src/chat/transcript-entry.ts +96 -0
- package/src/chat/transcript-outline.ts +260 -0
- package/src/chat/transcript-render-helpers.ts +315 -0
- package/src/chat/ttsr-notification.ts +123 -0
- package/src/chat/user-message.ts +287 -0
- package/src/chrome/chat-block.ts +110 -0
- package/src/chrome/collab-qrcode.ts +74 -0
- package/src/chrome/context-thresholds.ts +85 -0
- package/src/chrome/countdown-timer.ts +74 -0
- package/src/chrome/diff.ts +266 -0
- package/src/chrome/dynamic-border.ts +36 -0
- package/src/chrome/error-block.ts +63 -0
- package/src/chrome/form-theme.ts +10 -0
- package/src/chrome/format.ts +66 -0
- package/src/chrome/index.ts +21 -0
- package/src/chrome/keybinding-hints.ts +55 -0
- package/src/chrome/live-board.ts +123 -0
- package/src/chrome/local-date.ts +20 -0
- package/src/chrome/message-divider.ts +51 -0
- package/src/chrome/message-frame.ts +164 -0
- package/src/chrome/message-notice.ts +103 -0
- package/src/chrome/overlay-box.ts +301 -0
- package/src/chrome/qrcode.ts +539 -0
- package/src/chrome/segment-track.ts +86 -0
- package/src/chrome/select-list-mouse-routing.ts +11 -0
- package/src/chrome/selector-helpers.ts +119 -0
- package/src/chrome/shared.ts +27 -0
- package/src/chrome/streaming-panel.ts +72 -0
- package/src/chrome/tool-activity.ts +44 -0
- package/src/chrome/transcript-container.ts +902 -0
- package/src/chrome/transcript-status.ts +27 -0
- package/src/chrome/visual-truncate.ts +70 -0
- package/src/components/disclosure.ts +235 -0
- package/src/components/editor.ts +10 -12
- package/src/components/form.ts +566 -0
- package/src/components/input.ts +6 -27
- package/src/components/key-value-list.ts +88 -0
- package/src/components/layout/geometry.ts +202 -0
- package/src/components/layout/row.ts +283 -0
- package/src/components/layout/split-pane.ts +349 -0
- package/src/components/layout/stack.ts +261 -0
- package/src/components/markdown.ts +16 -12
- package/src/components/menu-selection.ts +248 -0
- package/src/components/metric.ts +132 -0
- package/src/components/progress-bar.ts +140 -0
- package/src/components/scroll-view.ts +372 -70
- package/src/components/scroll-viewport.ts +154 -0
- package/src/components/section.ts +77 -0
- package/src/components/select-list.ts +238 -159
- package/src/components/settings-list.ts +103 -80
- package/src/components/table.ts +127 -0
- package/src/components/tree-view.ts +481 -0
- package/src/components/wizard-step.ts +229 -0
- package/src/deccara.ts +1 -3
- package/src/hotkeys-markdown.ts +100 -0
- package/src/index.ts +18 -0
- package/src/keybinding-matchers.ts +99 -0
- package/src/keys.ts +2 -2
- package/src/lang-from-path.ts +252 -0
- package/src/overlays/advisor-config.ts +761 -0
- package/src/overlays/agent-activity.ts +113 -0
- package/src/overlays/agent-hub-projection.ts +250 -0
- package/src/overlays/agent-hub-renderer.ts +281 -0
- package/src/overlays/agent-hub-types.ts +74 -0
- package/src/overlays/agent-hub.ts +1562 -0
- package/src/overlays/agent-transcript-viewer.ts +669 -0
- package/src/overlays/agents-hub.ts +1203 -0
- package/src/overlays/ask-dialog.ts +1202 -0
- package/src/overlays/bordered-loader.ts +41 -0
- package/src/overlays/btw-history-panel.ts +591 -0
- package/src/overlays/btw-history.ts +33 -0
- package/src/overlays/btw-panel.ts +167 -0
- package/src/overlays/cleanse-panel.ts +167 -0
- package/src/overlays/codex-reset-fireworks.ts +375 -0
- package/src/overlays/composer-shape-preview.ts +137 -0
- package/src/overlays/composer-shape-registry.ts +82 -0
- package/src/overlays/copy-selector.ts +618 -0
- package/src/overlays/copy-targets.ts +210 -0
- package/src/overlays/error-banner.ts +39 -0
- package/src/overlays/extensions/display-text.ts +39 -0
- package/src/overlays/extensions/extension-dashboard.ts +645 -0
- package/src/overlays/extensions/extension-list.ts +667 -0
- package/src/overlays/extensions/inspector-model.ts +484 -0
- package/src/overlays/extensions/inspector-panel.ts +669 -0
- package/src/overlays/extensions/live-tool-session.ts +67 -0
- package/src/overlays/extensions/mcp-runtime.ts +289 -0
- package/src/overlays/extensions/state-manager.ts +337 -0
- package/src/overlays/extensions/types.ts +208 -0
- package/src/overlays/history-search.ts +268 -0
- package/src/overlays/hook-editor.ts +272 -0
- package/src/overlays/hook-input.ts +84 -0
- package/src/overlays/hook-selector.ts +635 -0
- package/src/overlays/hub-frame.ts +262 -0
- package/src/overlays/login-dialog.ts +231 -0
- package/src/overlays/logout-account-selector.ts +115 -0
- package/src/overlays/mcp-add-wizard.ts +1436 -0
- package/src/overlays/model-browser.ts +1176 -0
- package/src/overlays/model-hub.ts +2279 -0
- package/src/overlays/model-picker.ts +285 -0
- package/src/overlays/model-selector.ts +107 -0
- package/src/overlays/move-overlay.ts +197 -0
- package/src/overlays/oauth-selector.ts +446 -0
- package/src/overlays/omfg-panel.ts +136 -0
- package/src/overlays/pause-screen.ts +198 -0
- package/src/overlays/plan-review-overlay.ts +1227 -0
- package/src/overlays/plan-save-overlay.ts +74 -0
- package/src/overlays/plan-toc.ts +139 -0
- package/src/overlays/plugin-selector.ts +97 -0
- package/src/overlays/plugin-settings.ts +839 -0
- package/src/overlays/queue-mode-selector.ts +55 -0
- package/src/overlays/reset-usage-selector.ts +170 -0
- package/src/overlays/rewind-selector.ts +499 -0
- package/src/overlays/running-subagent-badge.ts +19 -0
- package/src/overlays/session-account-selector.ts +68 -0
- package/src/overlays/session-info-overlay.ts +96 -0
- package/src/overlays/session-observer-registry.ts +289 -0
- package/src/overlays/session-selector.ts +1137 -0
- package/src/overlays/settings-defs.ts +315 -0
- package/src/overlays/settings-selector.ts +1415 -0
- package/src/overlays/show-images-selector.ts +44 -0
- package/src/overlays/snapcompact-shape-preview-doc.md +14 -0
- package/src/overlays/snapcompact-shape-preview.ts +192 -0
- package/src/overlays/theme-selector.ts +62 -0
- package/src/overlays/thinking-selector.ts +51 -0
- package/src/overlays/tiny-title-download-progress.ts +102 -0
- package/src/overlays/tree-selector.ts +1121 -0
- package/src/overlays/usage-dashboard.ts +629 -0
- package/src/overlays/usage-display.ts +45 -0
- package/src/overlays/usage-row.ts +118 -0
- package/src/prompt/attachment-chips.ts +201 -0
- package/src/prompt/composer-attachments.ts +280 -0
- package/src/prompt/composer-cache.ts +304 -0
- package/src/prompt/composer.ts +934 -0
- package/src/prompt/custom-editor.ts +1392 -0
- package/src/prompt/data/emojis.json +1 -0
- package/src/prompt/editor-top-gap.ts +28 -0
- package/src/prompt/emoji-autocomplete.ts +285 -0
- package/src/prompt/github-ref-autocomplete.ts +75 -0
- package/src/prompt/gradient-highlight.ts +101 -0
- package/src/prompt/image-format.ts +28 -0
- package/src/prompt/image-references.ts +102 -0
- package/src/prompt/interactive-context-helpers.ts +126 -0
- package/src/prompt/internal-url-autocomplete.ts +155 -0
- package/src/prompt/macos-spelling.ts +456 -0
- package/src/prompt/magic-keyword-boundary.ts +23 -0
- package/src/prompt/magic-keywords.ts +42 -0
- package/src/prompt/markdown-prose.ts +245 -0
- package/src/prompt/model-mention-autocomplete.ts +94 -0
- package/src/prompt/model-mention-syntax.ts +41 -0
- package/src/prompt/orchestrate.ts +26 -0
- package/src/prompt/prompt-action-autocomplete.ts +337 -0
- package/src/prompt/queue-input.ts +132 -0
- package/src/prompt/skill-tokens.ts +36 -0
- package/src/prompt/tips.txt +27 -0
- package/src/prompt/tools-markdown.ts +29 -0
- package/src/prompt/ultrathink.ts +26 -0
- package/src/prompt/usage-amounts.ts +99 -0
- package/src/prompt/video.ts +47 -0
- package/src/prompt/welcome.ts +605 -0
- package/src/prompt/workflow.ts +26 -0
- package/src/render/code-cell.ts +244 -0
- package/src/render/file-list.ts +58 -0
- package/src/render/hyperlink.ts +192 -0
- package/src/render/index.ts +17 -0
- package/src/render/output-block.ts +267 -0
- package/src/render/output-pane.ts +299 -0
- package/src/render/render-utils.ts +1182 -0
- package/src/render/sixel.ts +69 -0
- package/src/render/status-line.ts +55 -0
- package/src/render/tool-card.ts +272 -0
- package/src/render/tree-list.ts +188 -0
- package/src/render/types.ts +19 -0
- package/src/render/utils.ts +109 -0
- package/src/render/width-aware-text.ts +60 -0
- package/src/setup/lazy.ts +17 -0
- package/src/setup/scenes/composer.ts +127 -0
- package/src/setup/scenes/glyph.ts +120 -0
- package/src/setup/scenes/model.ts +138 -0
- package/src/setup/scenes/outro.ts +24 -0
- package/src/setup/scenes/providers.ts +107 -0
- package/src/setup/scenes/sign-in.ts +373 -0
- package/src/setup/scenes/splash.ts +192 -0
- package/src/setup/scenes/theme.ts +343 -0
- package/src/setup/scenes/types.ts +111 -0
- package/src/setup/scenes/web-search.ts +165 -0
- package/src/setup/setup-version.ts +11 -0
- package/src/setup/startup-splash.ts +107 -0
- package/src/setup/wizard-overlay.ts +319 -0
- package/src/setup/wizard.ts +101 -0
- package/src/status-line/component.ts +3003 -0
- package/src/status-line/context-usage.ts +688 -0
- package/src/status-line/footer.ts +323 -0
- package/src/status-line/git-utils.ts +42 -0
- package/src/status-line/host.ts +97 -0
- package/src/status-line/index.ts +6 -0
- package/src/status-line/loop.ts +28 -0
- package/src/status-line/metrics.ts +94 -0
- package/src/status-line/presets.ts +107 -0
- package/src/status-line/schema.ts +57 -0
- package/src/status-line/segments.ts +934 -0
- package/src/status-line/separators.ts +55 -0
- package/src/status-line/types.ts +227 -0
- package/src/stdin-buffer.ts +4 -2
- package/src/theme/color.ts +95 -0
- package/src/theme/dark.json +95 -0
- package/src/theme/defaults/alabaster.json +93 -0
- package/src/theme/defaults/amethyst.json +96 -0
- package/src/theme/defaults/anthracite.json +93 -0
- package/src/theme/defaults/basalt.json +91 -0
- package/src/theme/defaults/birch.json +95 -0
- package/src/theme/defaults/dark-abyss.json +91 -0
- package/src/theme/defaults/dark-arctic.json +104 -0
- package/src/theme/defaults/dark-aurora.json +95 -0
- package/src/theme/defaults/dark-catppuccin.json +107 -0
- package/src/theme/defaults/dark-cavern.json +91 -0
- package/src/theme/defaults/dark-celestial.json +106 -0
- package/src/theme/defaults/dark-copper.json +95 -0
- package/src/theme/defaults/dark-cosmos.json +90 -0
- package/src/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/theme/defaults/dark-dracula.json +98 -0
- package/src/theme/defaults/dark-eclipse.json +91 -0
- package/src/theme/defaults/dark-ember.json +95 -0
- package/src/theme/defaults/dark-equinox.json +90 -0
- package/src/theme/defaults/dark-forest.json +96 -0
- package/src/theme/defaults/dark-github.json +105 -0
- package/src/theme/defaults/dark-gruvbox.json +112 -0
- package/src/theme/defaults/dark-lavender.json +95 -0
- package/src/theme/defaults/dark-lunar.json +89 -0
- package/src/theme/defaults/dark-midnight.json +95 -0
- package/src/theme/defaults/dark-monochrome.json +94 -0
- package/src/theme/defaults/dark-monokai.json +98 -0
- package/src/theme/defaults/dark-nebula.json +90 -0
- package/src/theme/defaults/dark-nord.json +98 -0
- package/src/theme/defaults/dark-ocean.json +101 -0
- package/src/theme/defaults/dark-one.json +100 -0
- package/src/theme/defaults/dark-poimandres.json +115 -0
- package/src/theme/defaults/dark-rainforest.json +91 -0
- package/src/theme/defaults/dark-reef.json +91 -0
- package/src/theme/defaults/dark-retro.json +92 -0
- package/src/theme/defaults/dark-rose-pine.json +96 -0
- package/src/theme/defaults/dark-sakura.json +95 -0
- package/src/theme/defaults/dark-slate.json +95 -0
- package/src/theme/defaults/dark-solarized.json +97 -0
- package/src/theme/defaults/dark-solstice.json +90 -0
- package/src/theme/defaults/dark-starfall.json +91 -0
- package/src/theme/defaults/dark-sunset.json +99 -0
- package/src/theme/defaults/dark-swamp.json +90 -0
- package/src/theme/defaults/dark-synthwave.json +103 -0
- package/src/theme/defaults/dark-taiga.json +91 -0
- package/src/theme/defaults/dark-terminal.json +95 -0
- package/src/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/theme/defaults/dark-tundra.json +91 -0
- package/src/theme/defaults/dark-twilight.json +91 -0
- package/src/theme/defaults/dark-volcanic.json +91 -0
- package/src/theme/defaults/graphite.json +92 -0
- package/src/theme/defaults/index.ts +201 -0
- package/src/theme/defaults/light-arctic.json +107 -0
- package/src/theme/defaults/light-aurora-day.json +91 -0
- package/src/theme/defaults/light-canyon.json +91 -0
- package/src/theme/defaults/light-catppuccin.json +106 -0
- package/src/theme/defaults/light-cirrus.json +90 -0
- package/src/theme/defaults/light-coral.json +95 -0
- package/src/theme/defaults/light-cyberpunk.json +96 -0
- package/src/theme/defaults/light-dawn.json +90 -0
- package/src/theme/defaults/light-dunes.json +91 -0
- package/src/theme/defaults/light-eucalyptus.json +95 -0
- package/src/theme/defaults/light-forest.json +100 -0
- package/src/theme/defaults/light-frost.json +95 -0
- package/src/theme/defaults/light-github.json +115 -0
- package/src/theme/defaults/light-glacier.json +91 -0
- package/src/theme/defaults/light-gruvbox.json +108 -0
- package/src/theme/defaults/light-haze.json +90 -0
- package/src/theme/defaults/light-honeycomb.json +95 -0
- package/src/theme/defaults/light-lagoon.json +91 -0
- package/src/theme/defaults/light-lavender.json +95 -0
- package/src/theme/defaults/light-meadow.json +91 -0
- package/src/theme/defaults/light-mint.json +95 -0
- package/src/theme/defaults/light-monochrome.json +101 -0
- package/src/theme/defaults/light-ocean.json +99 -0
- package/src/theme/defaults/light-one.json +99 -0
- package/src/theme/defaults/light-opal.json +91 -0
- package/src/theme/defaults/light-orchard.json +91 -0
- package/src/theme/defaults/light-paper.json +95 -0
- package/src/theme/defaults/light-poimandres.json +115 -0
- package/src/theme/defaults/light-prism.json +90 -0
- package/src/theme/defaults/light-retro.json +98 -0
- package/src/theme/defaults/light-sand.json +95 -0
- package/src/theme/defaults/light-savanna.json +91 -0
- package/src/theme/defaults/light-solarized.json +102 -0
- package/src/theme/defaults/light-soleil.json +90 -0
- package/src/theme/defaults/light-sunset.json +99 -0
- package/src/theme/defaults/light-synthwave.json +98 -0
- package/src/theme/defaults/light-tokyo-night.json +111 -0
- package/src/theme/defaults/light-wetland.json +91 -0
- package/src/theme/defaults/light-zenith.json +89 -0
- package/src/theme/defaults/limestone.json +94 -0
- package/src/theme/defaults/mahogany.json +97 -0
- package/src/theme/defaults/marble.json +93 -0
- package/src/theme/defaults/obsidian.json +91 -0
- package/src/theme/defaults/onyx.json +91 -0
- package/src/theme/defaults/pearl.json +93 -0
- package/src/theme/defaults/porcelain.json +91 -0
- package/src/theme/defaults/quartz.json +96 -0
- package/src/theme/defaults/sandstone.json +95 -0
- package/src/theme/defaults/titanium.json +90 -0
- package/src/theme/index.ts +5 -0
- package/src/theme/light.json +93 -0
- package/src/theme/loader.ts +200 -0
- package/src/theme/mermaid-cache.ts +92 -0
- package/src/theme/schema-validation.ts +119 -0
- package/src/theme/schema.ts +168 -0
- package/src/theme/session-color.ts +253 -0
- package/src/theme/shimmer.ts +307 -0
- package/src/theme/symbols.ts +1433 -0
- package/src/theme/theme-class.ts +787 -0
- package/src/theme/theme-schema.json +463 -0
- package/src/theme/theme.ts +810 -0
- package/src/theme/tui-adapters.ts +339 -0
- package/src/thinking.ts +380 -0
- package/src/tools/agent-tree.ts +128 -0
- package/src/tools/ask.ts +482 -0
- package/src/tools/ast-edit.ts +210 -0
- package/src/tools/ast-grep.ts +171 -0
- package/src/tools/autoresearch.ts +287 -0
- package/src/tools/bash-interactive.ts +295 -0
- package/src/tools/bash.ts +468 -0
- package/src/tools/conflict-detect.ts +77 -0
- package/src/tools/debug.ts +167 -0
- package/src/tools/default-renderer.ts +172 -0
- package/src/tools/edit.ts +1258 -0
- package/src/tools/eval-format/code-mode-declarations.ts +61 -0
- package/src/tools/eval-format/index.ts +16 -0
- package/src/tools/eval-format/javascript.ts +952 -0
- package/src/tools/eval-format/python.ts +544 -0
- package/src/tools/eval.ts +835 -0
- package/src/tools/fetch.ts +226 -0
- package/src/tools/gh-format.ts +18 -0
- package/src/tools/github.ts +686 -0
- package/src/tools/glob.ts +213 -0
- package/src/tools/goal.ts +153 -0
- package/src/tools/grep.ts +385 -0
- package/src/tools/grouped-file-output.ts +211 -0
- package/src/tools/hashline-format.ts +59 -0
- package/src/tools/hub.ts +1488 -0
- package/src/tools/index.ts +71 -0
- package/src/tools/json-tree.ts +388 -0
- package/src/tools/line-ranges.ts +98 -0
- package/src/tools/list-limit.ts +43 -0
- package/src/tools/lsp.ts +702 -0
- package/src/tools/match-line-format.ts +20 -0
- package/src/tools/mcp.ts +309 -0
- package/src/tools/memory.ts +220 -0
- package/src/tools/output-meta.ts +367 -0
- package/src/tools/read.ts +628 -0
- package/src/tools/renderer.ts +107 -0
- package/src/tools/report-tool-issue.ts +13 -0
- package/src/tools/resolve.ts +139 -0
- package/src/tools/streaming-output.ts +1576 -0
- package/src/tools/subprocess.ts +39 -0
- package/src/tools/task-repair-args.ts +118 -0
- package/src/tools/task-yield-assembly.ts +147 -0
- package/src/tools/task.ts +2110 -0
- package/src/tools/terminal-output.ts +153 -0
- package/src/tools/think.ts +28 -0
- package/src/tools/todo.ts +580 -0
- package/src/tools/tool-errors.ts +15 -0
- package/src/tools/vibe.ts +420 -0
- package/src/tools/web-search.ts +409 -0
- package/src/tools/write.ts +511 -0
- package/src/tools/xd-url.ts +28 -0
- package/src/tools/xdev.ts +201 -0
- package/src/tui.ts +57 -4
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,1203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fullscreen /agents hub, shown on the alternate screen like /models.
|
|
3
|
+
*
|
|
4
|
+
* Layout mirrors the model hub: a sidebar of scopes (All agents, per-source
|
|
5
|
+
* groups, "+ New agent"), a body listing agents with type-to-filter search,
|
|
6
|
+
* and a footer that turns into a chip strip while configuring. Enter on an
|
|
7
|
+
* agent opens its property strip (enabled / model / prewalk / advisor); a
|
|
8
|
+
* property opens a value strip whose "pick model…" chip dives into the real
|
|
9
|
+
* ModelBrowser and whose "pattern…" chip opens an inline pattern input, so
|
|
10
|
+
* every per-agent knob is picked instead of memorized.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { Model } from "@oh-my-pi/pi-ai";
|
|
14
|
+
import {
|
|
15
|
+
type Component,
|
|
16
|
+
Editor,
|
|
17
|
+
fuzzyMatch,
|
|
18
|
+
Input,
|
|
19
|
+
matchesKey,
|
|
20
|
+
replaceTabs,
|
|
21
|
+
routeSgrMouseInput,
|
|
22
|
+
type SgrMouseEvent,
|
|
23
|
+
type TUI,
|
|
24
|
+
truncateToWidth,
|
|
25
|
+
visibleWidth,
|
|
26
|
+
wrapTextWithAnsi,
|
|
27
|
+
} from "../index";
|
|
28
|
+
import type { AgentSource } from "../tools/task";
|
|
29
|
+
import { shortenPath } from "../render/render-utils";
|
|
30
|
+
import { getEditorTheme, theme } from "../theme";
|
|
31
|
+
import { matchesAppFollowUp, matchesSelectCancel, matchesSelectDown, matchesSelectUp } from "../keybinding-matchers";
|
|
32
|
+
import {
|
|
33
|
+
buildBrowserItems,
|
|
34
|
+
ModelBrowser,
|
|
35
|
+
type ModelBrowserItem,
|
|
36
|
+
type ModelBrowserSource,
|
|
37
|
+
sortModelItems,
|
|
38
|
+
} from "./model-browser";
|
|
39
|
+
import {
|
|
40
|
+
HubFrame,
|
|
41
|
+
moveStripSelection,
|
|
42
|
+
type SidebarEntry as HubSidebarEntry,
|
|
43
|
+
type SidebarStyle,
|
|
44
|
+
type StripChip as HubStripChip,
|
|
45
|
+
type StripState as HubStripState,
|
|
46
|
+
} from "./hub-frame";
|
|
47
|
+
|
|
48
|
+
/** One agent with its per-agent settings overrides resolved for display. */
|
|
49
|
+
export interface HubAgent {
|
|
50
|
+
name: string;
|
|
51
|
+
description: string;
|
|
52
|
+
systemPrompt: string;
|
|
53
|
+
source: AgentSource;
|
|
54
|
+
filePath?: string;
|
|
55
|
+
model?: string[];
|
|
56
|
+
prewalk?: boolean | string;
|
|
57
|
+
advisor?: boolean | string;
|
|
58
|
+
disabled: boolean;
|
|
59
|
+
/** `task.agentModelOverrides[name]` as a comma-joined pattern list. */
|
|
60
|
+
overrideModel?: string;
|
|
61
|
+
/** `task.agentPrewalk[name]`: "on", "off", or a model pattern. */
|
|
62
|
+
prewalkOverride?: string;
|
|
63
|
+
/** `task.agentAdvisor[name]`: "on", "off", or a model pattern. */
|
|
64
|
+
advisorOverride?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const SOURCE_LABEL: Record<AgentSource, string> = {
|
|
68
|
+
project: "Project",
|
|
69
|
+
user: "User",
|
|
70
|
+
bundled: "Bundled",
|
|
71
|
+
};
|
|
72
|
+
const SOURCE_ORDER: Record<AgentSource, number> = { project: 0, user: 1, bundled: 2 };
|
|
73
|
+
|
|
74
|
+
interface SidebarEntry extends HubSidebarEntry<"all" | "source" | "new" | "separator"> {
|
|
75
|
+
source?: AgentSource;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A body row of the agent list: an agent or the trailing "+ New agent…". */
|
|
79
|
+
type ListRow = { kind: "agent"; agent: HubAgent } | { kind: "new" };
|
|
80
|
+
|
|
81
|
+
/** The per-agent knob a strip or the model browser is editing. */
|
|
82
|
+
type PropertyKind = "model" | "prewalk" | "advisor";
|
|
83
|
+
|
|
84
|
+
type StripChip = HubStripChip<
|
|
85
|
+
| { kind: "toggle" }
|
|
86
|
+
| { kind: "property"; property: PropertyKind }
|
|
87
|
+
| { kind: "set"; property: PropertyKind; value: string | undefined }
|
|
88
|
+
| { kind: "pick"; property: PropertyKind }
|
|
89
|
+
| { kind: "pattern"; property: PropertyKind }
|
|
90
|
+
>;
|
|
91
|
+
|
|
92
|
+
type StripState =
|
|
93
|
+
| (HubStripState<StripChip> & { kind: "chips"; agent: HubAgent; property?: PropertyKind })
|
|
94
|
+
| { kind: "pattern"; agent: HubAgent; property: PropertyKind; input: Input };
|
|
95
|
+
|
|
96
|
+
export interface GeneratedAgentSpec {
|
|
97
|
+
identifier: string;
|
|
98
|
+
whenToUse: string;
|
|
99
|
+
systemPrompt: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Runtime-owned discovery, settings, generation and persistence. */
|
|
103
|
+
export interface AgentsHubDeps {
|
|
104
|
+
browserSource: ModelBrowserSource;
|
|
105
|
+
loadAgents: () => Promise<HubAgent[]>;
|
|
106
|
+
getAvailableModels: () => Model[];
|
|
107
|
+
effectiveModelPatterns: (agent: HubAgent) => string[];
|
|
108
|
+
resolvePatterns: (patterns: string[]) => string | undefined;
|
|
109
|
+
effectivePrewalkPattern: (agent: HubAgent) => string | undefined;
|
|
110
|
+
effectiveAdvisorPattern: (agent: HubAgent) => string | undefined;
|
|
111
|
+
setDisabledAgents: (names: string[]) => void;
|
|
112
|
+
setOverrides: (property: PropertyKind, overrides: Record<string, string>) => void;
|
|
113
|
+
generateAgent: (description: string, onText: (text: string) => void) => Promise<string>;
|
|
114
|
+
saveAgent: (scope: "project" | "user", spec: GeneratedAgentSpec) => Promise<string>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface AgentsHubCallbacks {
|
|
118
|
+
onCancel: () => void;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const IDENTIFIER_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+){1,5}$/;
|
|
122
|
+
|
|
123
|
+
function extractJsonObject(raw: string): string {
|
|
124
|
+
const fenceMatch = raw.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
125
|
+
if (fenceMatch?.[1]) return fenceMatch[1].trim();
|
|
126
|
+
const start = raw.indexOf("{");
|
|
127
|
+
const end = raw.lastIndexOf("}");
|
|
128
|
+
if (start >= 0 && end >= start) return raw.slice(start, end + 1).trim();
|
|
129
|
+
return raw.trim();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function parseGeneratedAgentSpec(raw: string): GeneratedAgentSpec {
|
|
133
|
+
const parsed = JSON.parse(extractJsonObject(raw)) as Partial<GeneratedAgentSpec>;
|
|
134
|
+
if (!parsed || typeof parsed !== "object") {
|
|
135
|
+
throw new Error("Model output is not a JSON object");
|
|
136
|
+
}
|
|
137
|
+
if (
|
|
138
|
+
typeof parsed.identifier !== "string" ||
|
|
139
|
+
typeof parsed.whenToUse !== "string" ||
|
|
140
|
+
typeof parsed.systemPrompt !== "string"
|
|
141
|
+
) {
|
|
142
|
+
throw new Error("Model output is missing required fields (identifier, whenToUse, systemPrompt)");
|
|
143
|
+
}
|
|
144
|
+
const identifier = parsed.identifier.trim();
|
|
145
|
+
const whenToUse = parsed.whenToUse.trim();
|
|
146
|
+
const systemPrompt = parsed.systemPrompt.trim();
|
|
147
|
+
if (!IDENTIFIER_PATTERN.test(identifier)) {
|
|
148
|
+
throw new Error("Generated identifier is invalid (must be lowercase kebab-case, 2+ words)");
|
|
149
|
+
}
|
|
150
|
+
if (!whenToUse.toLowerCase().startsWith("use this agent when")) {
|
|
151
|
+
throw new Error("Generated whenToUse must start with 'Use this agent when...'");
|
|
152
|
+
}
|
|
153
|
+
if (!systemPrompt) {
|
|
154
|
+
throw new Error("Generated systemPrompt is empty");
|
|
155
|
+
}
|
|
156
|
+
return { identifier, whenToUse, systemPrompt };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function matchAgent(agent: HubAgent, query: string): boolean {
|
|
160
|
+
const text = `${agent.name} ${agent.description} ${SOURCE_LABEL[agent.source]} ${agent.overrideModel ?? ""}`;
|
|
161
|
+
return query
|
|
162
|
+
.trim()
|
|
163
|
+
.split(/\s+/)
|
|
164
|
+
.every(token => fuzzyMatch(token, text).matches);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The fullscreen agents hub component. Hosted via
|
|
169
|
+
* `ui.showOverlay(..., { fullscreen: true })`; the host must call
|
|
170
|
+
* {@link AgentsHubComponent.dispose} when the overlay closes.
|
|
171
|
+
*/
|
|
172
|
+
export class AgentsHubComponent implements Component {
|
|
173
|
+
#tui: TUI;
|
|
174
|
+
#deps: AgentsHubDeps;
|
|
175
|
+
#callbacks: AgentsHubCallbacks;
|
|
176
|
+
|
|
177
|
+
#allAgents: HubAgent[] = [];
|
|
178
|
+
#entries: SidebarEntry[] = [];
|
|
179
|
+
#activeEntryId = "all";
|
|
180
|
+
#focus: "scope" | "list" = "list";
|
|
181
|
+
|
|
182
|
+
#rows: ListRow[] = [];
|
|
183
|
+
#rowIndex = 0;
|
|
184
|
+
#rowHover: number | null = null;
|
|
185
|
+
#listScroll = 0;
|
|
186
|
+
#searchQuery = "";
|
|
187
|
+
#notice: string | null = null;
|
|
188
|
+
#loadError: string | null = null;
|
|
189
|
+
|
|
190
|
+
#strip: StripState | null = null;
|
|
191
|
+
/** Non-null while the body shows the model browser for one agent property. */
|
|
192
|
+
#assigning: { agent: HubAgent; property: PropertyKind } | null = null;
|
|
193
|
+
#browser: ModelBrowser;
|
|
194
|
+
|
|
195
|
+
// Create flow (AI-generated agent definition).
|
|
196
|
+
#createInput: Editor | null = null;
|
|
197
|
+
#createDescription = "";
|
|
198
|
+
#createScope: "project" | "user" = "project";
|
|
199
|
+
#createGenerating = false;
|
|
200
|
+
#createSpec: GeneratedAgentSpec | null = null;
|
|
201
|
+
#createError: string | null = null;
|
|
202
|
+
#createStreamingText = "";
|
|
203
|
+
|
|
204
|
+
#renderBodyPane = (width: number, height: number | undefined): readonly string[] => {
|
|
205
|
+
const rows = Math.max(1, Math.floor(height ?? 10));
|
|
206
|
+
const lines: string[] = [this.#statusRow(width)];
|
|
207
|
+
if (this.#createActive) {
|
|
208
|
+
lines.push(...this.#renderCreate(width, rows - 1));
|
|
209
|
+
} else if (this.#assigning) {
|
|
210
|
+
this.#browser.setMaxVisible(rows - 1 - 5);
|
|
211
|
+
this.#browser.setFocused(true);
|
|
212
|
+
lines.push(...this.#browser.render(width));
|
|
213
|
+
} else {
|
|
214
|
+
lines.push(...this.#renderList(width, rows - 1));
|
|
215
|
+
}
|
|
216
|
+
while (lines.length < rows) lines.push("");
|
|
217
|
+
return lines.slice(0, rows);
|
|
218
|
+
};
|
|
219
|
+
readonly #frame: HubFrame = new HubFrame(
|
|
220
|
+
"Agents",
|
|
221
|
+
{ min: 16, max: 24 },
|
|
222
|
+
(width, rows) =>
|
|
223
|
+
this.#frame.renderSidebar(
|
|
224
|
+
this.#entries,
|
|
225
|
+
width,
|
|
226
|
+
rows,
|
|
227
|
+
{ id: this.#activeEntryId, focused: this.#focus === "scope", follow: true, clamp: false },
|
|
228
|
+
this.#sidebarStyle,
|
|
229
|
+
),
|
|
230
|
+
this.#renderBodyPane,
|
|
231
|
+
);
|
|
232
|
+
/** First agent-list row's offset in body-line coordinates (after the status row). */
|
|
233
|
+
#listRowStart = 2;
|
|
234
|
+
|
|
235
|
+
private constructor(tui: TUI, deps: AgentsHubDeps, callbacks: AgentsHubCallbacks) {
|
|
236
|
+
this.#tui = tui;
|
|
237
|
+
this.#deps = deps;
|
|
238
|
+
this.#callbacks = callbacks;
|
|
239
|
+
this.#browser = new ModelBrowser(deps.browserSource, {
|
|
240
|
+
emptyText: () => " No models available — configure a provider in /models first.",
|
|
241
|
+
});
|
|
242
|
+
this.#browser.setShowProvider(true);
|
|
243
|
+
this.#browser.onActivate = item => this.#commitPickedModel(item);
|
|
244
|
+
this.#browser.onCancel = () => this.#cancelAssign();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
static async create(
|
|
248
|
+
tui: TUI,
|
|
249
|
+
deps: AgentsHubDeps,
|
|
250
|
+
callbacks: AgentsHubCallbacks = { onCancel: () => {} },
|
|
251
|
+
): Promise<AgentsHubComponent> {
|
|
252
|
+
const hub = new AgentsHubComponent(tui, deps, callbacks);
|
|
253
|
+
await hub.#reload();
|
|
254
|
+
return hub;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
dispose(): void {}
|
|
258
|
+
invalidate(): void {
|
|
259
|
+
this.#frame.invalidate();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
263
|
+
// Data pipeline
|
|
264
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
265
|
+
|
|
266
|
+
async #reload(): Promise<void> {
|
|
267
|
+
this.#loadError = null;
|
|
268
|
+
try {
|
|
269
|
+
const selectedName = this.#selectedAgent()?.name;
|
|
270
|
+
this.#allAgents = (await this.#deps.loadAgents()).sort((a, b) => {
|
|
271
|
+
const sourceCmp = SOURCE_ORDER[a.source] - SOURCE_ORDER[b.source];
|
|
272
|
+
return sourceCmp !== 0 ? sourceCmp : a.name.localeCompare(b.name);
|
|
273
|
+
});
|
|
274
|
+
this.#buildSidebar();
|
|
275
|
+
this.#buildRows();
|
|
276
|
+
if (selectedName) {
|
|
277
|
+
const index = this.#rows.findIndex(r => r.kind === "agent" && r.agent.name === selectedName);
|
|
278
|
+
if (index >= 0) this.#rowIndex = index;
|
|
279
|
+
}
|
|
280
|
+
this.#clampRowIndex();
|
|
281
|
+
} catch (error) {
|
|
282
|
+
this.#allAgents = [];
|
|
283
|
+
this.#buildSidebar();
|
|
284
|
+
this.#buildRows();
|
|
285
|
+
this.#loadError = error instanceof Error ? error.message : String(error);
|
|
286
|
+
}
|
|
287
|
+
this.#tui.requestRender();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
#buildSidebar(): void {
|
|
291
|
+
const counts: Record<AgentSource, number> = { project: 0, user: 0, bundled: 0 };
|
|
292
|
+
for (const agent of this.#allAgents) counts[agent.source]++;
|
|
293
|
+
const entries: SidebarEntry[] = [
|
|
294
|
+
{ id: "all", kind: "all", label: "All agents", annotation: String(this.#allAgents.length) },
|
|
295
|
+
];
|
|
296
|
+
const sources = (["project", "user", "bundled"] as const).filter(source => counts[source] > 0);
|
|
297
|
+
if (sources.length > 0) {
|
|
298
|
+
entries.push({ id: "sep:sources", kind: "separator", label: "" });
|
|
299
|
+
for (const source of sources) {
|
|
300
|
+
entries.push({
|
|
301
|
+
id: `source:${source}`,
|
|
302
|
+
kind: "source",
|
|
303
|
+
label: SOURCE_LABEL[source],
|
|
304
|
+
source,
|
|
305
|
+
annotation: String(counts[source]),
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
entries.push({ id: "sep:actions", kind: "separator", label: "" });
|
|
310
|
+
entries.push({ id: "new", kind: "new", label: "New agent" });
|
|
311
|
+
this.#entries = entries;
|
|
312
|
+
if (!entries.some(entry => entry.id === this.#activeEntryId)) this.#activeEntryId = "all";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
#activeEntry(): SidebarEntry {
|
|
316
|
+
return this.#entries.find(entry => entry.id === this.#activeEntryId) ?? this.#entries[0];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
#buildRows(): void {
|
|
320
|
+
const entry = this.#activeEntry();
|
|
321
|
+
const scoped =
|
|
322
|
+
entry.kind === "source" ? this.#allAgents.filter(agent => agent.source === entry.source) : this.#allAgents;
|
|
323
|
+
const filtered = this.#searchQuery ? scoped.filter(agent => matchAgent(agent, this.#searchQuery)) : scoped;
|
|
324
|
+
this.#rows = [...filtered.map(agent => ({ kind: "agent", agent }) as ListRow), { kind: "new" }];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
#clampRowIndex(): void {
|
|
328
|
+
this.#rowIndex = Math.max(0, Math.min(this.#rowIndex, this.#rows.length - 1));
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
#selectedAgent(): HubAgent | undefined {
|
|
332
|
+
const rowDef = this.#rows[this.#rowIndex];
|
|
333
|
+
return rowDef?.kind === "agent" ? rowDef.agent : undefined;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
337
|
+
// Mutations
|
|
338
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
339
|
+
|
|
340
|
+
#toggleAgent(agent: HubAgent): void {
|
|
341
|
+
agent.disabled = !agent.disabled;
|
|
342
|
+
const disabled = this.#allAgents
|
|
343
|
+
.filter(entry => entry.disabled)
|
|
344
|
+
.map(entry => entry.name)
|
|
345
|
+
.sort((a, b) => a.localeCompare(b));
|
|
346
|
+
this.#deps.setDisabledAgents(disabled);
|
|
347
|
+
this.#notice = `${agent.name} ${agent.disabled ? "disabled" : "enabled"}`;
|
|
348
|
+
this.#tui.requestRender();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#persistRecord(property: PropertyKind): void {
|
|
352
|
+
const overrides: Record<string, string> = {};
|
|
353
|
+
for (const agent of this.#allAgents) {
|
|
354
|
+
const value = this.#overrideFor(agent, property)?.trim();
|
|
355
|
+
if (value) overrides[agent.name] = value;
|
|
356
|
+
}
|
|
357
|
+
this.#deps.setOverrides(property, overrides);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
#overrideFor(agent: HubAgent, property: PropertyKind): string | undefined {
|
|
361
|
+
switch (property) {
|
|
362
|
+
case "model":
|
|
363
|
+
return agent.overrideModel;
|
|
364
|
+
case "prewalk":
|
|
365
|
+
return agent.prewalkOverride;
|
|
366
|
+
case "advisor":
|
|
367
|
+
return agent.advisorOverride;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
#setOverride(agent: HubAgent, property: PropertyKind, value: string | undefined): void {
|
|
372
|
+
const trimmed = value?.trim() || undefined;
|
|
373
|
+
switch (property) {
|
|
374
|
+
case "model":
|
|
375
|
+
agent.overrideModel = trimmed;
|
|
376
|
+
break;
|
|
377
|
+
case "prewalk":
|
|
378
|
+
agent.prewalkOverride = trimmed;
|
|
379
|
+
break;
|
|
380
|
+
case "advisor":
|
|
381
|
+
agent.advisorOverride = trimmed;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
this.#persistRecord(property);
|
|
385
|
+
this.#notice = this.#describeProperty(agent, property);
|
|
386
|
+
this.#tui.requestRender();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** One-line effective description used for notices and the status row. */
|
|
390
|
+
#describeProperty(agent: HubAgent, property: PropertyKind): string {
|
|
391
|
+
switch (property) {
|
|
392
|
+
case "model": {
|
|
393
|
+
const patterns = this.#deps.effectiveModelPatterns(agent);
|
|
394
|
+
const resolved = this.#deps.resolvePatterns(patterns);
|
|
395
|
+
const base = agent.overrideModel ?? (patterns.length > 0 ? patterns.join(",") : "session model");
|
|
396
|
+
return `${agent.name} model: ${base}${resolved ? ` → ${resolved}` : ""}`;
|
|
397
|
+
}
|
|
398
|
+
case "prewalk": {
|
|
399
|
+
const pattern = this.#deps.effectivePrewalkPattern(agent);
|
|
400
|
+
return `${agent.name} prewalk: ${pattern ? `on (${pattern})` : "off"}`;
|
|
401
|
+
}
|
|
402
|
+
case "advisor": {
|
|
403
|
+
const pattern = this.#deps.effectiveAdvisorPattern(agent);
|
|
404
|
+
return `${agent.name} advisor: ${pattern ? `on (${pattern})` : "off"}`;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
410
|
+
// Strips
|
|
411
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
412
|
+
|
|
413
|
+
#propertySummary(agent: HubAgent, property: PropertyKind): string {
|
|
414
|
+
switch (property) {
|
|
415
|
+
case "model":
|
|
416
|
+
return agent.overrideModel ?? "auto";
|
|
417
|
+
case "prewalk": {
|
|
418
|
+
const pattern = this.#deps.effectivePrewalkPattern(agent);
|
|
419
|
+
return pattern ?? "off";
|
|
420
|
+
}
|
|
421
|
+
case "advisor": {
|
|
422
|
+
const pattern = this.#deps.effectiveAdvisorPattern(agent);
|
|
423
|
+
return pattern ?? "off";
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** Level-1 strip: pick which knob of `agent` to change. */
|
|
429
|
+
#openAgentStrip(agent: HubAgent): void {
|
|
430
|
+
const enabledChip: StripChip = {
|
|
431
|
+
label: agent.disabled ? "enable" : "disable",
|
|
432
|
+
styled: agent.disabled
|
|
433
|
+
? theme.fg("success", `${theme.status.enabled} enable`)
|
|
434
|
+
: theme.fg("dim", `${theme.status.disabled} disable`),
|
|
435
|
+
action: { kind: "toggle" },
|
|
436
|
+
};
|
|
437
|
+
const propertyChip = (property: PropertyKind): StripChip => {
|
|
438
|
+
const summary = this.#propertySummary(agent, property);
|
|
439
|
+
return {
|
|
440
|
+
label: property,
|
|
441
|
+
styled: `${theme.fg("accent", property)}${theme.fg("dim", `: ${summary}`)}`,
|
|
442
|
+
action: { kind: "property", property },
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
this.#strip = {
|
|
446
|
+
kind: "chips",
|
|
447
|
+
agent,
|
|
448
|
+
chips: [enabledChip, propertyChip("model"), propertyChip("prewalk"), propertyChip("advisor")],
|
|
449
|
+
index: 1,
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Level-2 strip: value choices for one property of `agent`. */
|
|
454
|
+
#openPropertyStrip(agent: HubAgent, property: PropertyKind): void {
|
|
455
|
+
const current = this.#overrideFor(agent, property)?.toLowerCase();
|
|
456
|
+
const chips: StripChip[] = [];
|
|
457
|
+
const mark = (label: string, active: boolean, color: "accent" | "muted" = "muted"): string =>
|
|
458
|
+
active ? theme.fg("accent", `${theme.status.enabled} ${label}`) : theme.fg(color, label);
|
|
459
|
+
if (property === "model") {
|
|
460
|
+
chips.push({
|
|
461
|
+
label: "pick model…",
|
|
462
|
+
styled: theme.fg("accent", "pick model…"),
|
|
463
|
+
action: { kind: "pick", property },
|
|
464
|
+
});
|
|
465
|
+
chips.push({
|
|
466
|
+
label: "pattern…",
|
|
467
|
+
styled: theme.fg("muted", "pattern…"),
|
|
468
|
+
action: { kind: "pattern", property },
|
|
469
|
+
});
|
|
470
|
+
if (agent.overrideModel) {
|
|
471
|
+
chips.push({
|
|
472
|
+
label: "clear override",
|
|
473
|
+
styled: theme.fg("warning", "clear override"),
|
|
474
|
+
action: { kind: "set", property, value: undefined },
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
chips.push({
|
|
479
|
+
label: "agent default",
|
|
480
|
+
styled: mark("agent default", current === undefined),
|
|
481
|
+
action: { kind: "set", property, value: undefined },
|
|
482
|
+
});
|
|
483
|
+
chips.push({
|
|
484
|
+
label: "on",
|
|
485
|
+
styled: mark("on", current === "on"),
|
|
486
|
+
action: { kind: "set", property, value: "on" },
|
|
487
|
+
});
|
|
488
|
+
chips.push({
|
|
489
|
+
label: "off",
|
|
490
|
+
styled: mark("off", current === "off"),
|
|
491
|
+
action: { kind: "set", property, value: "off" },
|
|
492
|
+
});
|
|
493
|
+
chips.push({
|
|
494
|
+
label: "pick model…",
|
|
495
|
+
styled: theme.fg("accent", "pick model…"),
|
|
496
|
+
action: { kind: "pick", property },
|
|
497
|
+
});
|
|
498
|
+
chips.push({
|
|
499
|
+
label: "pattern…",
|
|
500
|
+
styled: theme.fg("muted", "pattern…"),
|
|
501
|
+
action: { kind: "pattern", property },
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
this.#strip = { kind: "chips", agent, property, chips, index: 0 };
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
#openPatternStrip(agent: HubAgent, property: PropertyKind): void {
|
|
508
|
+
const input = new Input();
|
|
509
|
+
const current = this.#overrideFor(agent, property);
|
|
510
|
+
if (current) input.setValue(current);
|
|
511
|
+
this.#strip = { kind: "pattern", agent, property, input };
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
#closeStrip(): void {
|
|
515
|
+
this.#strip = null;
|
|
516
|
+
this.#frame.chipRanges = [];
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
#activateStripChip(): void {
|
|
520
|
+
const strip = this.#strip;
|
|
521
|
+
if (strip?.kind !== "chips") return;
|
|
522
|
+
const chip = strip.chips[strip.index];
|
|
523
|
+
if (!chip) return;
|
|
524
|
+
const action = chip.action;
|
|
525
|
+
switch (action.kind) {
|
|
526
|
+
case "toggle":
|
|
527
|
+
this.#toggleAgent(strip.agent);
|
|
528
|
+
this.#closeStrip();
|
|
529
|
+
return;
|
|
530
|
+
case "property":
|
|
531
|
+
this.#openPropertyStrip(strip.agent, action.property);
|
|
532
|
+
return;
|
|
533
|
+
case "set":
|
|
534
|
+
this.#setOverride(strip.agent, action.property, action.value);
|
|
535
|
+
this.#closeStrip();
|
|
536
|
+
return;
|
|
537
|
+
case "pick":
|
|
538
|
+
this.#closeStrip();
|
|
539
|
+
this.#startAssign(strip.agent, action.property);
|
|
540
|
+
return;
|
|
541
|
+
case "pattern":
|
|
542
|
+
this.#openPatternStrip(strip.agent, action.property);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
#submitPattern(): void {
|
|
548
|
+
const strip = this.#strip;
|
|
549
|
+
if (strip?.kind !== "pattern") return;
|
|
550
|
+
this.#setOverride(strip.agent, strip.property, strip.input.getValue());
|
|
551
|
+
this.#closeStrip();
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
555
|
+
// Model browser assign mode
|
|
556
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
557
|
+
|
|
558
|
+
#startAssign(agent: HubAgent, property: PropertyKind): void {
|
|
559
|
+
const items = buildBrowserItems(this.#deps.getAvailableModels());
|
|
560
|
+
sortModelItems(items, { mruOrder: this.#deps.browserSource.mruOrder });
|
|
561
|
+
this.#assigning = { agent, property };
|
|
562
|
+
this.#browser.setItems(items);
|
|
563
|
+
this.#browser.setQuery("");
|
|
564
|
+
const current = this.#overrideFor(agent, property);
|
|
565
|
+
if (current) this.#browser.selectSelector(current);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
#commitPickedModel(item: ModelBrowserItem): void {
|
|
569
|
+
const target = this.#assigning;
|
|
570
|
+
if (!target) return;
|
|
571
|
+
this.#assigning = null;
|
|
572
|
+
this.#browser.setQuery("");
|
|
573
|
+
this.#setOverride(target.agent, target.property, item.selector);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
#cancelAssign(): void {
|
|
577
|
+
this.#assigning = null;
|
|
578
|
+
this.#browser.setQuery("");
|
|
579
|
+
this.#tui.requestRender();
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
583
|
+
// Create flow
|
|
584
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
585
|
+
|
|
586
|
+
get #createActive(): boolean {
|
|
587
|
+
return this.#createInput !== null || this.#createGenerating || this.#createSpec !== null;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
#beginCreateFlow(): void {
|
|
591
|
+
if (this.#createGenerating) return;
|
|
592
|
+
this.#createError = null;
|
|
593
|
+
this.#createSpec = null;
|
|
594
|
+
this.#createDescription = "";
|
|
595
|
+
const editor = new Editor(getEditorTheme());
|
|
596
|
+
editor.setBorderVisible(false);
|
|
597
|
+
editor.setPromptGutter("> ");
|
|
598
|
+
editor.setMaxHeight(Math.max(3, Math.min(8, this.#terminalRows() - 12)));
|
|
599
|
+
editor.disableSubmit = true;
|
|
600
|
+
editor.onChange = value => {
|
|
601
|
+
this.#createDescription = value;
|
|
602
|
+
};
|
|
603
|
+
this.#createInput = editor;
|
|
604
|
+
this.#tui.requestRender();
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
#clearCreateFlow(): void {
|
|
608
|
+
this.#createInput = null;
|
|
609
|
+
this.#createDescription = "";
|
|
610
|
+
this.#createGenerating = false;
|
|
611
|
+
this.#createSpec = null;
|
|
612
|
+
this.#createError = null;
|
|
613
|
+
this.#createStreamingText = "";
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
async #generateAgentFromDescription(rawDescription: string): Promise<void> {
|
|
617
|
+
const description = rawDescription.trim();
|
|
618
|
+
this.#createDescription = description;
|
|
619
|
+
if (!description) {
|
|
620
|
+
this.#createError = "Description is required.";
|
|
621
|
+
this.#tui.requestRender();
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
this.#createGenerating = true;
|
|
625
|
+
this.#createError = null;
|
|
626
|
+
this.#createSpec = null;
|
|
627
|
+
this.#createStreamingText = "";
|
|
628
|
+
this.#tui.requestRender();
|
|
629
|
+
try {
|
|
630
|
+
const spec = await this.#runAgentCreationArchitect(description);
|
|
631
|
+
this.#createSpec = spec;
|
|
632
|
+
this.#notice = null;
|
|
633
|
+
} catch (error) {
|
|
634
|
+
this.#createError = error instanceof Error ? error.message : String(error);
|
|
635
|
+
} finally {
|
|
636
|
+
this.#createGenerating = false;
|
|
637
|
+
this.#tui.requestRender();
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
async #runAgentCreationArchitect(description: string): Promise<GeneratedAgentSpec> {
|
|
642
|
+
const raw = await this.#deps.generateAgent(description, text => {
|
|
643
|
+
this.#createStreamingText += text;
|
|
644
|
+
this.#tui.requestRender();
|
|
645
|
+
});
|
|
646
|
+
return parseGeneratedAgentSpec(raw);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
async #saveGeneratedAgent(): Promise<void> {
|
|
650
|
+
const spec = this.#createSpec;
|
|
651
|
+
if (!spec) return;
|
|
652
|
+
const filePath = await this.#deps.saveAgent(this.#createScope, spec);
|
|
653
|
+
this.#clearCreateFlow();
|
|
654
|
+
this.#notice = `Created agent ${spec.identifier} at ${shortenPath(filePath)}`;
|
|
655
|
+
await this.#reload();
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
659
|
+
// Input
|
|
660
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
661
|
+
|
|
662
|
+
handleInput(data: string): void {
|
|
663
|
+
if (data.startsWith("\x1b[<")) {
|
|
664
|
+
routeSgrMouseInput(data, event => this.#routeMouseEvent(event));
|
|
665
|
+
this.#tui.requestRender();
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
if (this.#strip) {
|
|
670
|
+
this.#handleStripInput(data);
|
|
671
|
+
this.#tui.requestRender();
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (this.#createActive) {
|
|
676
|
+
this.#handleCreateInput(data);
|
|
677
|
+
this.#tui.requestRender();
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
if (matchesSelectCancel(data)) {
|
|
682
|
+
if (this.#assigning) {
|
|
683
|
+
this.#cancelAssign();
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (this.#searchQuery.length > 0) {
|
|
687
|
+
this.#searchQuery = "";
|
|
688
|
+
this.#buildRows();
|
|
689
|
+
this.#clampRowIndex();
|
|
690
|
+
this.#tui.requestRender();
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
this.#callbacks.onCancel();
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (this.#assigning) {
|
|
698
|
+
this.#browser.handleInput(data);
|
|
699
|
+
this.#tui.requestRender();
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (matchesKey(data, "ctrl+r")) {
|
|
704
|
+
void this.#reload();
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (matchesKey(data, "tab") || matchesKey(data, "shift+tab")) {
|
|
709
|
+
this.#focus = this.#focus === "scope" ? "list" : "scope";
|
|
710
|
+
this.#tui.requestRender();
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
if (matchesKey(data, "left")) {
|
|
714
|
+
this.#focus = "scope";
|
|
715
|
+
this.#tui.requestRender();
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
if (matchesKey(data, "right")) {
|
|
719
|
+
this.#focus = "list";
|
|
720
|
+
this.#tui.requestRender();
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (this.#focus === "scope") {
|
|
725
|
+
if (matchesSelectUp(data)) {
|
|
726
|
+
this.#moveSidebar(-1);
|
|
727
|
+
this.#tui.requestRender();
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
if (matchesSelectDown(data)) {
|
|
731
|
+
this.#moveSidebar(1);
|
|
732
|
+
this.#tui.requestRender();
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
if (matchesKey(data, "enter") || matchesKey(data, "return") || data === "\n") {
|
|
736
|
+
if (this.#activeEntry().kind === "new") {
|
|
737
|
+
this.#beginCreateFlow();
|
|
738
|
+
} else {
|
|
739
|
+
this.#focus = "list";
|
|
740
|
+
}
|
|
741
|
+
this.#tui.requestRender();
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (matchesSelectUp(data)) {
|
|
747
|
+
this.#rowIndex = Math.max(0, this.#rowIndex - 1);
|
|
748
|
+
this.#tui.requestRender();
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (matchesSelectDown(data)) {
|
|
752
|
+
this.#rowIndex = Math.min(this.#rows.length - 1, this.#rowIndex + 1);
|
|
753
|
+
this.#tui.requestRender();
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (matchesKey(data, "enter") || matchesKey(data, "return") || data === "\n") {
|
|
757
|
+
this.#activateRow(this.#rows[this.#rowIndex]);
|
|
758
|
+
this.#tui.requestRender();
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
if (data === " " && this.#searchQuery.length === 0) {
|
|
762
|
+
const agent = this.#selectedAgent();
|
|
763
|
+
if (agent) this.#toggleAgent(agent);
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
if (matchesKey(data, "backspace")) {
|
|
767
|
+
if (this.#searchQuery.length > 0) {
|
|
768
|
+
this.#searchQuery = this.#searchQuery.slice(0, -1);
|
|
769
|
+
this.#buildRows();
|
|
770
|
+
this.#clampRowIndex();
|
|
771
|
+
this.#tui.requestRender();
|
|
772
|
+
}
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
// Type-to-filter: any printable character extends the query.
|
|
776
|
+
if (data.length === 1 && data >= " " && data !== "\x7f") {
|
|
777
|
+
this.#searchQuery += data;
|
|
778
|
+
this.#focus = "list";
|
|
779
|
+
this.#buildRows();
|
|
780
|
+
this.#rowIndex = 0;
|
|
781
|
+
this.#listScroll = 0;
|
|
782
|
+
this.#tui.requestRender();
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
#activateRow(rowDef: ListRow | undefined): void {
|
|
787
|
+
if (!rowDef) return;
|
|
788
|
+
if (rowDef.kind === "new") {
|
|
789
|
+
this.#beginCreateFlow();
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
this.#openAgentStrip(rowDef.agent);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
#handleStripInput(data: string): void {
|
|
796
|
+
const strip = this.#strip;
|
|
797
|
+
if (!strip) return;
|
|
798
|
+
if (matchesSelectCancel(data)) {
|
|
799
|
+
// A property strip steps back up to the agent strip instead of closing.
|
|
800
|
+
if (strip.kind === "chips" && strip.property) {
|
|
801
|
+
this.#openAgentStrip(strip.agent);
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
if (strip.kind === "pattern") {
|
|
805
|
+
this.#openPropertyStrip(strip.agent, strip.property);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
this.#closeStrip();
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
if (strip.kind === "pattern") {
|
|
812
|
+
if (matchesKey(data, "enter") || matchesKey(data, "return") || data === "\n") {
|
|
813
|
+
this.#submitPattern();
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
strip.input.handleInput(data);
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (moveStripSelection(strip, data)) return;
|
|
820
|
+
if (matchesKey(data, "enter") || matchesKey(data, "return") || data === "\n") {
|
|
821
|
+
this.#activateStripChip();
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
#handleCreateInput(data: string): void {
|
|
827
|
+
if (this.#createSpec) {
|
|
828
|
+
if (matchesSelectCancel(data)) {
|
|
829
|
+
this.#clearCreateFlow();
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
if (matchesKey(data, "tab") || matchesKey(data, "shift+tab")) {
|
|
833
|
+
this.#createScope = this.#createScope === "project" ? "user" : "project";
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
if (data.toLowerCase() === "r") {
|
|
837
|
+
void this.#generateAgentFromDescription(this.#createDescription);
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
if (matchesKey(data, "enter") || matchesKey(data, "return") || data === "\n") {
|
|
841
|
+
void this.#saveGeneratedAgent().catch(error => {
|
|
842
|
+
this.#createError = error instanceof Error ? error.message : String(error);
|
|
843
|
+
this.#tui.requestRender();
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
if (matchesSelectCancel(data)) {
|
|
849
|
+
if (!this.#createGenerating) this.#clearCreateFlow();
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
if (this.#createGenerating) return;
|
|
853
|
+
if (matchesAppFollowUp(data)) {
|
|
854
|
+
void this.#generateAgentFromDescription(this.#createInput?.getExpandedText() ?? this.#createDescription);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
if (matchesKey(data, "tab") || matchesKey(data, "shift+tab")) {
|
|
858
|
+
this.#createScope = this.#createScope === "project" ? "user" : "project";
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
if (matchesKey(data, "enter") || matchesKey(data, "return") || data === "\n") {
|
|
862
|
+
this.#createInput?.handleInput("\n");
|
|
863
|
+
this.#createDescription = this.#createInput?.getExpandedText() ?? "";
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
this.#createInput?.handleInput(data);
|
|
867
|
+
this.#createDescription = this.#createInput?.getExpandedText() ?? "";
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
#moveSidebar(delta: number): void {
|
|
871
|
+
const count = this.#entries.length;
|
|
872
|
+
if (count === 0) return;
|
|
873
|
+
let index = this.#entries.findIndex(entry => entry.id === this.#activeEntryId);
|
|
874
|
+
if (index < 0) index = 0;
|
|
875
|
+
for (let step = 0; step < count; step++) {
|
|
876
|
+
index = (index + delta + count) % count;
|
|
877
|
+
const entry = this.#entries[index];
|
|
878
|
+
if (entry && entry.kind !== "separator") {
|
|
879
|
+
this.#activeEntryId = entry.id;
|
|
880
|
+
if (entry.kind !== "new") {
|
|
881
|
+
this.#buildRows();
|
|
882
|
+
this.#rowIndex = 0;
|
|
883
|
+
this.#listScroll = 0;
|
|
884
|
+
}
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
891
|
+
// Mouse
|
|
892
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
893
|
+
|
|
894
|
+
#routeMouseEvent(event: SgrMouseEvent): boolean {
|
|
895
|
+
const { footerColumn, bodyHeight, contentLine, overSidebar, overBody, bodyLine } = this.#frame.locate(
|
|
896
|
+
event.row,
|
|
897
|
+
event.col,
|
|
898
|
+
);
|
|
899
|
+
|
|
900
|
+
if (footerColumn !== undefined && this.#strip?.kind === "chips") {
|
|
901
|
+
const strip = this.#strip;
|
|
902
|
+
if (event.leftClick && this.#frame.selectChipAt(strip, footerColumn)) {
|
|
903
|
+
this.#activateStripChip();
|
|
904
|
+
}
|
|
905
|
+
return true;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
if (this.#assigning) {
|
|
909
|
+
if (overBody) this.#browser.routeMouse(event, bodyLine);
|
|
910
|
+
return true;
|
|
911
|
+
}
|
|
912
|
+
if (this.#createActive || this.#strip) return true;
|
|
913
|
+
|
|
914
|
+
if (event.wheel !== null) {
|
|
915
|
+
if (overSidebar) {
|
|
916
|
+
this.#frame.scrollSidebar(event.wheel, bodyHeight, this.#entries.length);
|
|
917
|
+
} else if (overBody) {
|
|
918
|
+
this.#rowIndex = Math.max(0, Math.min(this.#rows.length - 1, this.#rowIndex + event.wheel));
|
|
919
|
+
}
|
|
920
|
+
return true;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
if (event.motion) {
|
|
924
|
+
// Hover is stored as an absolute row index so paint and click agree.
|
|
925
|
+
const hoverRow = bodyLine - this.#listRowStart + this.#listScroll;
|
|
926
|
+
this.#rowHover = overBody && hoverRow >= 0 && hoverRow < this.#rows.length ? hoverRow : null;
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
if (!event.leftClick) return true;
|
|
931
|
+
|
|
932
|
+
if (overSidebar) {
|
|
933
|
+
const index = this.#frame.sidebarScroll + contentLine;
|
|
934
|
+
const clicked = this.#entries[index];
|
|
935
|
+
if (clicked && clicked.kind !== "separator") {
|
|
936
|
+
if (clicked.kind === "new") {
|
|
937
|
+
this.#beginCreateFlow();
|
|
938
|
+
} else {
|
|
939
|
+
this.#activeEntryId = clicked.id;
|
|
940
|
+
this.#buildRows();
|
|
941
|
+
this.#rowIndex = 0;
|
|
942
|
+
this.#focus = "scope";
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return true;
|
|
946
|
+
}
|
|
947
|
+
if (overBody) {
|
|
948
|
+
this.#focus = "list";
|
|
949
|
+
const listLine = bodyLine - this.#listRowStart + this.#listScroll;
|
|
950
|
+
if (listLine >= 0 && listLine < this.#rows.length) {
|
|
951
|
+
if (listLine === this.#rowIndex) {
|
|
952
|
+
this.#activateRow(this.#rows[listLine]);
|
|
953
|
+
} else {
|
|
954
|
+
this.#rowIndex = listLine;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return true;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
962
|
+
// Rendering
|
|
963
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
964
|
+
|
|
965
|
+
#terminalRows(): number {
|
|
966
|
+
return Math.max(16, this.#tui.terminal?.rows || process.stdout.rows || 40);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
#sidebarStyle = (entry: SidebarEntry): SidebarStyle => {
|
|
970
|
+
const icon = entry.kind === "all" ? theme.icon.model : entry.kind === "new" ? "+" : theme.status.enabled;
|
|
971
|
+
return {
|
|
972
|
+
icon: theme.fg(entry.kind === "new" ? "dim" : "accent", icon),
|
|
973
|
+
annotation: theme.fg("dim", entry.annotation ?? ""),
|
|
974
|
+
};
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
#statusRow(width: number): string {
|
|
978
|
+
if (this.#loadError) return truncateToWidth(theme.fg("error", ` ${this.#loadError}`), width);
|
|
979
|
+
if (this.#assigning) {
|
|
980
|
+
const { agent, property } = this.#assigning;
|
|
981
|
+
const what = property === "model" ? "model override" : `${property} model`;
|
|
982
|
+
return truncateToWidth(
|
|
983
|
+
theme.fg("accent", ` Picking ${what} for ${theme.bold(agent.name)} — Enter assigns, Esc cancels`),
|
|
984
|
+
width,
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
if (this.#createActive) {
|
|
988
|
+
return truncateToWidth(theme.fg("accent", " New agent — describe it and let the architect draft it"), width);
|
|
989
|
+
}
|
|
990
|
+
if (this.#notice) return truncateToWidth(theme.fg("success", ` ${this.#notice}`), width);
|
|
991
|
+
const entry = this.#activeEntry();
|
|
992
|
+
const scopeLabel = entry.kind === "source" ? `${entry.label} agents` : "All agents";
|
|
993
|
+
const count = this.#rows.filter(rowDef => rowDef.kind === "agent").length;
|
|
994
|
+
return truncateToWidth(theme.fg("muted", ` ${scopeLabel} · ${count}`), width);
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
#renderList(width: number, rows: number): string[] {
|
|
998
|
+
const lines: string[] = [];
|
|
999
|
+
const searchText = this.#searchQuery ? theme.fg("accent", this.#searchQuery) : theme.fg("dim", "type to filter");
|
|
1000
|
+
lines.push(truncateToWidth(` ${theme.fg("muted", "search:")} ${searchText}`, width));
|
|
1001
|
+
lines.push("");
|
|
1002
|
+
this.#listRowStart = lines.length;
|
|
1003
|
+
|
|
1004
|
+
const detailRows = 4;
|
|
1005
|
+
const visibleRows = Math.max(3, rows - lines.length - detailRows);
|
|
1006
|
+
if (this.#rowIndex < this.#listScroll) this.#listScroll = this.#rowIndex;
|
|
1007
|
+
else if (this.#rowIndex >= this.#listScroll + visibleRows) this.#listScroll = this.#rowIndex - visibleRows + 1;
|
|
1008
|
+
this.#listScroll = Math.max(0, Math.min(this.#listScroll, Math.max(0, this.#rows.length - visibleRows)));
|
|
1009
|
+
|
|
1010
|
+
let nameWidth = 0;
|
|
1011
|
+
for (const rowDef of this.#rows) {
|
|
1012
|
+
if (rowDef.kind === "agent") nameWidth = Math.max(nameWidth, visibleWidth(rowDef.agent.name));
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
const listFocused = this.#focus === "list";
|
|
1016
|
+
for (let i = this.#listScroll; i < Math.min(this.#rows.length, this.#listScroll + visibleRows); i++) {
|
|
1017
|
+
const rowDef = this.#rows[i];
|
|
1018
|
+
if (!rowDef) continue;
|
|
1019
|
+
const selected = i === this.#rowIndex;
|
|
1020
|
+
const hovered = i === this.#rowHover;
|
|
1021
|
+
const cursor = selected && listFocused ? theme.fg("accent", theme.nav.cursor) : " ";
|
|
1022
|
+
if (rowDef.kind === "new") {
|
|
1023
|
+
let line = ` ${cursor} ${theme.fg(selected ? "accent" : "dim", "+ New agent…")}`;
|
|
1024
|
+
if (hovered) line = theme.bg("selectedBg", line);
|
|
1025
|
+
lines.push(truncateToWidth(line, width));
|
|
1026
|
+
continue;
|
|
1027
|
+
}
|
|
1028
|
+
const agent = rowDef.agent;
|
|
1029
|
+
const dot = agent.disabled
|
|
1030
|
+
? theme.fg("dim", theme.status.disabled)
|
|
1031
|
+
: theme.fg("success", theme.status.enabled);
|
|
1032
|
+
const name = replaceTabs(agent.name).padEnd(nameWidth);
|
|
1033
|
+
const nameStyled = agent.disabled
|
|
1034
|
+
? theme.fg("dim", name)
|
|
1035
|
+
: selected
|
|
1036
|
+
? theme.bold(theme.fg("accent", name))
|
|
1037
|
+
: name;
|
|
1038
|
+
const badges: string[] = [];
|
|
1039
|
+
if (agent.overrideModel) badges.push(theme.fg("warning", agent.overrideModel));
|
|
1040
|
+
const prewalk = this.#deps.effectivePrewalkPattern(agent);
|
|
1041
|
+
if (prewalk) badges.push(theme.fg("dim", `pre:${prewalk}`));
|
|
1042
|
+
const advisor = this.#deps.effectiveAdvisorPattern(agent);
|
|
1043
|
+
if (advisor) badges.push(theme.fg("dim", `adv:${advisor}`));
|
|
1044
|
+
const sourceTag = theme.fg("dim", SOURCE_LABEL[agent.source].toLowerCase());
|
|
1045
|
+
let line = ` ${cursor} ${dot} ${nameStyled} ${sourceTag}`;
|
|
1046
|
+
const right = badges.join(" ");
|
|
1047
|
+
const rightWidth = visibleWidth(right);
|
|
1048
|
+
const lineWidth = visibleWidth(line);
|
|
1049
|
+
if (rightWidth > 0 && lineWidth + rightWidth + 2 <= width) {
|
|
1050
|
+
line = `${line}${" ".repeat(width - lineWidth - rightWidth - 1)}${right}`;
|
|
1051
|
+
}
|
|
1052
|
+
line = truncateToWidth(line, width);
|
|
1053
|
+
if (hovered) {
|
|
1054
|
+
const w = visibleWidth(line);
|
|
1055
|
+
if (w < width) line += " ".repeat(width - w);
|
|
1056
|
+
line = theme.bg("selectedBg", line);
|
|
1057
|
+
}
|
|
1058
|
+
lines.push(line);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
// Selected-agent detail block pinned to the bottom of the body pane.
|
|
1062
|
+
while (lines.length < rows - detailRows) lines.push("");
|
|
1063
|
+
const agent = this.#selectedAgent();
|
|
1064
|
+
lines.push(theme.fg("border", "─".repeat(Math.max(1, width))));
|
|
1065
|
+
if (agent) {
|
|
1066
|
+
lines.push(truncateToWidth(` ${theme.fg("dim", replaceTabs(agent.description))}`, width));
|
|
1067
|
+
const patterns = this.#deps.effectiveModelPatterns(agent);
|
|
1068
|
+
const resolved = this.#deps.resolvePatterns(patterns);
|
|
1069
|
+
const modelLine = `${theme.fg("muted", "model:")} ${patterns.length > 0 ? replaceTabs(patterns.join(",")) : theme.fg("dim", "(session model)")}${resolved ? ` ${theme.fg("dim", "→")} ${theme.fg("success", resolved)}` : ""}`;
|
|
1070
|
+
lines.push(truncateToWidth(` ${modelLine}`, width));
|
|
1071
|
+
const prewalk = this.#deps.effectivePrewalkPattern(agent);
|
|
1072
|
+
const advisor = this.#deps.effectiveAdvisorPattern(agent);
|
|
1073
|
+
const flagLine = [
|
|
1074
|
+
`${theme.fg("muted", "prewalk:")} ${prewalk ? theme.fg("success", prewalk) : theme.fg("dim", "off")}`,
|
|
1075
|
+
`${theme.fg("muted", "advisor:")} ${advisor ? theme.fg("success", advisor) : theme.fg("dim", "off")}`,
|
|
1076
|
+
agent.filePath ? theme.fg("dim", shortenPath(agent.filePath)) : "",
|
|
1077
|
+
]
|
|
1078
|
+
.filter(Boolean)
|
|
1079
|
+
.join(" ");
|
|
1080
|
+
lines.push(truncateToWidth(` ${flagLine}`, width));
|
|
1081
|
+
} else {
|
|
1082
|
+
lines.push(theme.fg("dim", " Select an agent to inspect"));
|
|
1083
|
+
lines.push("");
|
|
1084
|
+
lines.push("");
|
|
1085
|
+
}
|
|
1086
|
+
return lines.slice(0, rows);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
#renderCreate(width: number, rows: number): string[] {
|
|
1090
|
+
const lines: string[] = [];
|
|
1091
|
+
lines.push("");
|
|
1092
|
+
if (this.#createSpec) {
|
|
1093
|
+
const spec = this.#createSpec;
|
|
1094
|
+
lines.push(truncateToWidth(theme.bold(theme.fg("accent", " Review generated agent")), width));
|
|
1095
|
+
lines.push("");
|
|
1096
|
+
lines.push(truncateToWidth(theme.fg("muted", ` Identifier: ${spec.identifier}`), width));
|
|
1097
|
+
lines.push(truncateToWidth(theme.fg("muted", ` Scope: ${this.#createScope}`), width));
|
|
1098
|
+
lines.push("");
|
|
1099
|
+
lines.push(theme.fg("muted", " whenToUse:"));
|
|
1100
|
+
for (const line of wrapTextWithAnsi(replaceTabs(spec.whenToUse), Math.max(20, width - 2)).slice(0, 6)) {
|
|
1101
|
+
lines.push(truncateToWidth(` ${line}`, width));
|
|
1102
|
+
}
|
|
1103
|
+
lines.push("");
|
|
1104
|
+
lines.push(theme.fg("muted", " systemPrompt preview:"));
|
|
1105
|
+
const promptWidth = Math.max(20, width - 4);
|
|
1106
|
+
const wrapped: string[] = [];
|
|
1107
|
+
for (const raw of spec.systemPrompt.split("\n")) {
|
|
1108
|
+
for (const w of wrapTextWithAnsi(replaceTabs(raw), promptWidth)) wrapped.push(w);
|
|
1109
|
+
}
|
|
1110
|
+
const budget = Math.max(3, rows - lines.length - 3);
|
|
1111
|
+
for (const line of wrapped.slice(0, budget)) {
|
|
1112
|
+
lines.push(truncateToWidth(` ${theme.fg("dim", line)}`, width));
|
|
1113
|
+
}
|
|
1114
|
+
if (wrapped.length > budget) {
|
|
1115
|
+
lines.push(theme.fg("dim", ` … ${wrapped.length - budget} more lines`));
|
|
1116
|
+
}
|
|
1117
|
+
} else {
|
|
1118
|
+
lines.push(truncateToWidth(theme.bold(theme.fg("accent", " Create new agent")), width));
|
|
1119
|
+
lines.push("");
|
|
1120
|
+
lines.push(
|
|
1121
|
+
truncateToWidth(
|
|
1122
|
+
theme.fg("muted", " Describe what the agent should do; scope: ") + theme.fg("accent", this.#createScope),
|
|
1123
|
+
width,
|
|
1124
|
+
),
|
|
1125
|
+
);
|
|
1126
|
+
lines.push("");
|
|
1127
|
+
if (this.#createInput && !this.#createGenerating) {
|
|
1128
|
+
for (const line of this.#createInput.render(Math.max(20, width - 2))) {
|
|
1129
|
+
lines.push(truncateToWidth(line, width));
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
if (this.#createGenerating) {
|
|
1133
|
+
lines.push(theme.fg("muted", " Generating…"));
|
|
1134
|
+
lines.push("");
|
|
1135
|
+
const contentWidth = Math.max(20, width - 4);
|
|
1136
|
+
const wrapped: string[] = [];
|
|
1137
|
+
for (const raw of this.#createStreamingText.split("\n")) {
|
|
1138
|
+
for (const w of wrapTextWithAnsi(replaceTabs(raw), contentWidth)) wrapped.push(w);
|
|
1139
|
+
}
|
|
1140
|
+
const budget = Math.max(3, rows - lines.length - 2);
|
|
1141
|
+
for (const line of wrapped.slice(-budget)) {
|
|
1142
|
+
lines.push(truncateToWidth(` ${theme.fg("dim", line)}`, width));
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
if (this.#createError) {
|
|
1147
|
+
lines.push("");
|
|
1148
|
+
lines.push(truncateToWidth(theme.fg("error", ` ${replaceTabs(this.#createError)}`), width));
|
|
1149
|
+
}
|
|
1150
|
+
while (lines.length < rows) lines.push("");
|
|
1151
|
+
return lines.slice(0, rows);
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
#footerHint(): string {
|
|
1155
|
+
if (this.#strip) {
|
|
1156
|
+
if (this.#strip.kind === "pattern") {
|
|
1157
|
+
const property = this.#strip.property;
|
|
1158
|
+
const values = property === "model" ? "a model pattern" : '"on", "off", or a model pattern';
|
|
1159
|
+
return `Enter ${values} (role aliases like @smol and :level suffixes work; empty clears) · Esc back`;
|
|
1160
|
+
}
|
|
1161
|
+
return this.#strip.property ? "←/→ choose · Enter apply · Esc back" : "←/→ choose · Enter open · Esc cancel";
|
|
1162
|
+
}
|
|
1163
|
+
if (this.#assigning) {
|
|
1164
|
+
return "Enter pick · ↑/↓ models · type to search · Esc cancel";
|
|
1165
|
+
}
|
|
1166
|
+
if (this.#createActive) {
|
|
1167
|
+
if (this.#createSpec) return "Enter save · Tab scope · r regenerate · Esc cancel";
|
|
1168
|
+
if (this.#createGenerating) return "Generating…";
|
|
1169
|
+
return "Ctrl+Q/Ctrl+Enter generate · Enter newline · Tab scope · Esc cancel";
|
|
1170
|
+
}
|
|
1171
|
+
if (this.#focus === "scope") {
|
|
1172
|
+
return "↑/↓ scopes · →/Enter agents · Esc close";
|
|
1173
|
+
}
|
|
1174
|
+
return "Enter configure · Space enable/disable · ↑/↓ rows · type to search · Ctrl+R reload · Esc close";
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
#renderFooter(width: number): string {
|
|
1178
|
+
const strip = this.#strip;
|
|
1179
|
+
return this.#frame.renderFooter(
|
|
1180
|
+
width,
|
|
1181
|
+
this.#footerHint(),
|
|
1182
|
+
strip ? () => this.#renderStrip(width, strip) : undefined,
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
#renderStrip(width: number, strip: StripState): string {
|
|
1187
|
+
if (strip.kind === "pattern") {
|
|
1188
|
+
const label = theme.fg("accent", `${strip.agent.name} ${strip.property} pattern:`);
|
|
1189
|
+
const labelWidth = visibleWidth(`${strip.agent.name} ${strip.property} pattern:`);
|
|
1190
|
+
const inputWidth = Math.max(8, Math.min(40, width - labelWidth - 4));
|
|
1191
|
+
const inputLine = strip.input.render(inputWidth)[0] ?? "";
|
|
1192
|
+
return truncateToWidth(`${label} ${inputLine}`, width);
|
|
1193
|
+
}
|
|
1194
|
+
const prefix = strip.property
|
|
1195
|
+
? `${theme.fg("accent", strip.agent.name)}${theme.fg("dim", ` · ${strip.property} →`)} `
|
|
1196
|
+
: `${theme.fg("accent", strip.agent.name)}${theme.fg("dim", " →")} `;
|
|
1197
|
+
return this.#frame.renderChips(width, prefix, strip);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
render(width: number): readonly string[] {
|
|
1201
|
+
return this.#frame.render(width, this.#terminalRows(), this.#entries, this.#renderFooter(width - 4));
|
|
1202
|
+
}
|
|
1203
|
+
}
|