@compilr-dev/cli 0.4.0 → 0.5.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 +30 -12
- package/dist/agent.d.ts +74 -1
- package/dist/agent.js +259 -76
- package/dist/anchors/index.d.ts +9 -0
- package/dist/anchors/index.js +9 -0
- package/dist/anchors/project-anchors.d.ts +79 -0
- package/dist/anchors/project-anchors.js +202 -0
- package/dist/commands/handler-types.d.ts +68 -0
- package/dist/commands/handler-types.js +8 -0
- package/dist/commands/handlers/agent-commands.d.ts +13 -0
- package/dist/commands/handlers/agent-commands.js +305 -0
- package/dist/commands/handlers/design-commands.d.ts +15 -0
- package/dist/commands/handlers/design-commands.js +334 -0
- package/dist/commands/handlers/index.d.ts +20 -0
- package/dist/commands/handlers/index.js +43 -0
- package/dist/commands/handlers/overlay-commands.d.ts +21 -0
- package/dist/commands/handlers/overlay-commands.js +287 -0
- package/dist/commands/handlers/project-commands.d.ts +11 -0
- package/dist/commands/handlers/project-commands.js +167 -0
- package/dist/commands/handlers/simple-commands.d.ts +19 -0
- package/dist/commands/handlers/simple-commands.js +144 -0
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/registry.d.ts +50 -0
- package/dist/commands/registry.js +75 -0
- package/dist/commands-v2/handlers/context.d.ts +13 -0
- package/dist/commands-v2/handlers/context.js +348 -0
- package/dist/commands-v2/handlers/core.d.ts +13 -0
- package/dist/commands-v2/handlers/core.js +165 -0
- package/dist/commands-v2/handlers/debug.d.ts +11 -0
- package/dist/commands-v2/handlers/debug.js +159 -0
- package/dist/commands-v2/handlers/index.d.ts +12 -0
- package/dist/commands-v2/handlers/index.js +24 -0
- package/dist/commands-v2/handlers/project.d.ts +22 -0
- package/dist/commands-v2/handlers/project.js +814 -0
- package/dist/commands-v2/handlers/settings.d.ts +15 -0
- package/dist/commands-v2/handlers/settings.js +235 -0
- package/dist/commands-v2/index.d.ts +13 -0
- package/dist/commands-v2/index.js +15 -0
- package/dist/commands-v2/registry.d.ts +37 -0
- package/dist/commands-v2/registry.js +80 -0
- package/dist/commands-v2/types.d.ts +75 -0
- package/dist/commands-v2/types.js +7 -0
- package/dist/commands.js +110 -7
- package/dist/index.js +288 -29
- package/dist/input-handlers/index.d.ts +7 -0
- package/dist/input-handlers/index.js +7 -0
- package/dist/input-handlers/memory-handler.d.ts +26 -0
- package/dist/input-handlers/memory-handler.js +68 -0
- package/dist/repl-helpers.d.ts +63 -0
- package/dist/repl-helpers.js +318 -0
- package/dist/repl-v2.d.ts +155 -0
- package/dist/repl-v2.js +774 -0
- package/dist/repl.d.ts +32 -4
- package/dist/repl.js +250 -977
- package/dist/settings/index.d.ts +23 -0
- package/dist/settings/index.js +48 -0
- package/dist/settings/paths.d.ts +110 -0
- package/dist/settings/paths.js +264 -0
- package/dist/templates/compilr-md.js +7 -4
- package/dist/templates/index.js +3 -4
- package/dist/themes/colors.js +3 -1
- package/dist/themes/registry.d.ts +5 -36
- package/dist/themes/registry.js +11 -95
- package/dist/themes/types.d.ts +3 -38
- package/dist/themes/types.js +2 -2
- package/dist/tools/anchor-tools.d.ts +31 -0
- package/dist/tools/anchor-tools.js +255 -0
- package/dist/tools/backlog-wrappers.d.ts +54 -0
- package/dist/tools/backlog-wrappers.js +338 -0
- package/dist/tools/backlog.js +1 -1
- package/dist/tools/db-tools.d.ts +65 -0
- package/dist/tools/db-tools.js +19 -0
- package/dist/tools/document-db.d.ts +43 -0
- package/dist/tools/document-db.js +220 -0
- package/dist/tools/project-db.d.ts +102 -0
- package/dist/tools/project-db.js +370 -0
- package/dist/tools/workitem-db.d.ts +103 -0
- package/dist/tools/workitem-db.js +549 -0
- package/dist/tools.js +13 -3
- package/dist/ui/agents-overlay-v2.d.ts +43 -0
- package/dist/ui/agents-overlay-v2.js +809 -0
- package/dist/ui/agents-overlay.d.ts +5 -5
- package/dist/ui/agents-overlay.js +782 -420
- package/dist/ui/anchors-overlay.d.ts +12 -0
- package/dist/ui/anchors-overlay.js +775 -0
- package/dist/ui/arch-type-overlay.d.ts +1 -6
- package/dist/ui/arch-type-overlay.js +175 -203
- package/dist/ui/ask-user-overlay-v2.d.ts +26 -0
- package/dist/ui/ask-user-overlay-v2.js +555 -0
- package/dist/ui/ask-user-overlay.d.ts +2 -2
- package/dist/ui/ask-user-overlay.js +443 -535
- package/dist/ui/ask-user-simple-overlay-v2.d.ts +25 -0
- package/dist/ui/ask-user-simple-overlay-v2.js +215 -0
- package/dist/ui/ask-user-simple-overlay.d.ts +2 -2
- package/dist/ui/ask-user-simple-overlay.js +182 -209
- package/dist/ui/backlog-overlay.d.ts +16 -1
- package/dist/ui/backlog-overlay.js +525 -659
- package/dist/ui/base/index.d.ts +26 -0
- package/dist/ui/base/index.js +33 -0
- package/dist/ui/base/inline-overlay-utils.d.ts +217 -0
- package/dist/ui/base/inline-overlay-utils.js +320 -0
- package/dist/ui/base/inline-overlay.d.ts +159 -0
- package/dist/ui/base/inline-overlay.js +257 -0
- package/dist/ui/base/key-utils.d.ts +15 -0
- package/dist/ui/base/key-utils.js +30 -0
- package/dist/ui/base/overlay-base-v2.d.ts +193 -0
- package/dist/ui/base/overlay-base-v2.js +246 -0
- package/dist/ui/base/overlay-base.d.ts +156 -0
- package/dist/ui/base/overlay-base.js +238 -0
- package/dist/ui/base/overlay-lifecycle.d.ts +65 -0
- package/dist/ui/base/overlay-lifecycle.js +159 -0
- package/dist/ui/base/overlay-types.d.ts +185 -0
- package/dist/ui/base/overlay-types.js +7 -0
- package/dist/ui/base/render-utils.d.ts +8 -0
- package/dist/ui/base/render-utils.js +11 -0
- package/dist/ui/base/screen-stack.d.ts +148 -0
- package/dist/ui/base/screen-stack.js +184 -0
- package/dist/ui/base/tabbed-list-overlay-v2.d.ts +103 -0
- package/dist/ui/base/tabbed-list-overlay-v2.js +317 -0
- package/dist/ui/base/tabbed-list-overlay.d.ts +153 -0
- package/dist/ui/base/tabbed-list-overlay.js +369 -0
- package/dist/ui/commands-overlay-v2.d.ts +33 -0
- package/dist/ui/commands-overlay-v2.js +441 -0
- package/dist/ui/commands-overlay.d.ts +7 -2
- package/dist/ui/commands-overlay.js +384 -355
- package/dist/ui/config-overlay.d.ts +5 -4
- package/dist/ui/config-overlay.js +243 -513
- package/dist/ui/conversation.d.ts +75 -4
- package/dist/ui/conversation.js +374 -161
- package/dist/ui/docs-overlay.d.ts +17 -0
- package/dist/ui/docs-overlay.js +303 -0
- package/dist/ui/ephemeral.d.ts +1 -1
- package/dist/ui/ephemeral.js +1 -1
- package/dist/ui/features/index.d.ts +34 -0
- package/dist/ui/features/index.js +34 -0
- package/dist/ui/features/input-feature.d.ts +85 -0
- package/dist/ui/features/input-feature.js +238 -0
- package/dist/ui/features/list-feature.d.ts +155 -0
- package/dist/ui/features/list-feature.js +244 -0
- package/dist/ui/features/pagination-feature.d.ts +154 -0
- package/dist/ui/features/pagination-feature.js +238 -0
- package/dist/ui/features/search-feature.d.ts +148 -0
- package/dist/ui/features/search-feature.js +185 -0
- package/dist/ui/features/tab-feature.d.ts +194 -0
- package/dist/ui/features/tab-feature.js +307 -0
- package/dist/ui/footer-v2.d.ts +222 -0
- package/dist/ui/footer-v2.js +1349 -0
- package/dist/ui/footer.d.ts +107 -0
- package/dist/ui/footer.js +359 -67
- package/dist/ui/guardrail-overlay.d.ts +29 -0
- package/dist/ui/guardrail-overlay.js +145 -0
- package/dist/ui/help-overlay-v2.d.ts +34 -0
- package/dist/ui/help-overlay-v2.js +309 -0
- package/dist/ui/help-overlay.d.ts +16 -0
- package/dist/ui/help-overlay.js +316 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -3
- package/dist/ui/init-overlay-v2.d.ts +34 -0
- package/dist/ui/init-overlay-v2.js +600 -0
- package/dist/ui/init-overlay.d.ts +12 -2
- package/dist/ui/init-overlay.js +349 -270
- package/dist/ui/input-prompt-v2.d.ts +1 -0
- package/dist/ui/input-prompt-v2.js +14 -6
- package/dist/ui/input-prompt.d.ts +116 -33
- package/dist/ui/input-prompt.js +536 -337
- package/dist/ui/iteration-limit-overlay-v2.d.ts +21 -0
- package/dist/ui/iteration-limit-overlay-v2.js +114 -0
- package/dist/ui/iteration-limit-overlay.d.ts +2 -2
- package/dist/ui/iteration-limit-overlay.js +92 -128
- package/dist/ui/keys-overlay-v2.d.ts +41 -0
- package/dist/ui/keys-overlay-v2.js +248 -0
- package/dist/ui/keys-overlay.d.ts +1 -0
- package/dist/ui/keys-overlay.js +203 -141
- package/dist/ui/line-utils.d.ts +88 -0
- package/dist/ui/line-utils.js +150 -0
- package/dist/ui/live-region.d.ts +161 -0
- package/dist/ui/live-region.js +387 -0
- package/dist/ui/mascot/expressions.d.ts +32 -0
- package/dist/ui/mascot/expressions.js +213 -0
- package/dist/ui/mascot/index.d.ts +8 -0
- package/dist/ui/mascot/index.js +8 -0
- package/dist/ui/mascot/renderer.d.ts +19 -0
- package/dist/ui/mascot/renderer.js +97 -0
- package/dist/ui/mascot-overlay-v2.d.ts +41 -0
- package/dist/ui/mascot-overlay-v2.js +138 -0
- package/dist/ui/mascot-overlay.d.ts +21 -0
- package/dist/ui/mascot-overlay.js +146 -0
- package/dist/ui/model-overlay-v2.d.ts +49 -0
- package/dist/ui/model-overlay-v2.js +118 -0
- package/dist/ui/model-overlay.d.ts +27 -0
- package/dist/ui/model-overlay.js +221 -0
- package/dist/ui/model-warning-overlay.js +3 -5
- package/dist/ui/new-overlay.d.ts +34 -0
- package/dist/ui/new-overlay.js +604 -0
- package/dist/ui/overlay/impl/agents-overlay-v2.d.ts +45 -0
- package/dist/ui/overlay/impl/agents-overlay-v2.js +825 -0
- package/dist/ui/overlay/impl/anchors-overlay-v2.d.ts +47 -0
- package/dist/ui/overlay/impl/anchors-overlay-v2.js +783 -0
- package/dist/ui/overlay/impl/arch-type-overlay-v2.d.ts +37 -0
- package/dist/ui/overlay/impl/arch-type-overlay-v2.js +240 -0
- package/dist/ui/overlay/impl/ask-user-overlay-v2.d.ts +72 -0
- package/dist/ui/overlay/impl/ask-user-overlay-v2.js +584 -0
- package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.d.ts +46 -0
- package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.js +204 -0
- package/dist/ui/overlay/impl/backlog-overlay-v2.d.ts +49 -0
- package/dist/ui/overlay/impl/backlog-overlay-v2.js +642 -0
- package/dist/ui/overlay/impl/commands-overlay-v2.d.ts +33 -0
- package/dist/ui/overlay/impl/commands-overlay-v2.js +441 -0
- package/dist/ui/overlay/impl/config-overlay-v2.d.ts +100 -0
- package/dist/ui/overlay/impl/config-overlay-v2.js +654 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.d.ts +55 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.js +359 -0
- package/dist/ui/overlay/impl/docs-overlay-v2.d.ts +45 -0
- package/dist/ui/overlay/impl/docs-overlay-v2.js +114 -0
- package/dist/ui/overlay/impl/document-detail-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/document-detail-overlay-v2.js +1071 -0
- package/dist/ui/overlay/impl/guardrail-overlay-v2.d.ts +43 -0
- package/dist/ui/overlay/impl/guardrail-overlay-v2.js +114 -0
- package/dist/ui/overlay/impl/help-overlay-v2.d.ts +34 -0
- package/dist/ui/overlay/impl/help-overlay-v2.js +309 -0
- package/dist/ui/overlay/impl/init-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/init-overlay-v2.js +593 -0
- package/dist/ui/overlay/impl/init-setup-overlay-v2.d.ts +25 -0
- package/dist/ui/overlay/impl/init-setup-overlay-v2.js +97 -0
- package/dist/ui/overlay/impl/iteration-limit-overlay-v2.d.ts +35 -0
- package/dist/ui/overlay/impl/iteration-limit-overlay-v2.js +105 -0
- package/dist/ui/overlay/impl/keys-overlay-v2.d.ts +41 -0
- package/dist/ui/overlay/impl/keys-overlay-v2.js +248 -0
- package/dist/ui/overlay/impl/mascot-overlay-v2.d.ts +41 -0
- package/dist/ui/overlay/impl/mascot-overlay-v2.js +138 -0
- package/dist/ui/overlay/impl/model-overlay-v2.d.ts +49 -0
- package/dist/ui/overlay/impl/model-overlay-v2.js +118 -0
- package/dist/ui/overlay/impl/model-warning-overlay-v2.d.ts +46 -0
- package/dist/ui/overlay/impl/model-warning-overlay-v2.js +132 -0
- package/dist/ui/overlay/impl/new-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/new-overlay-v2.js +593 -0
- package/dist/ui/overlay/impl/permission-overlay-v2.d.ts +36 -0
- package/dist/ui/overlay/impl/permission-overlay-v2.js +380 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.d.ts +36 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.js +499 -0
- package/dist/ui/overlay/impl/theme-overlay-v2.d.ts +42 -0
- package/dist/ui/overlay/impl/theme-overlay-v2.js +135 -0
- package/dist/ui/overlay/impl/tools-overlay-v2.d.ts +47 -0
- package/dist/ui/overlay/impl/tools-overlay-v2.js +218 -0
- package/dist/ui/overlay/impl/tutorial-overlay-v2.d.ts +31 -0
- package/dist/ui/overlay/impl/tutorial-overlay-v2.js +1035 -0
- package/dist/ui/overlay/impl/workflow-overlay-v2.d.ts +80 -0
- package/dist/ui/overlay/impl/workflow-overlay-v2.js +637 -0
- package/dist/ui/overlay/index.d.ts +33 -0
- package/dist/ui/overlay/index.js +35 -0
- package/dist/ui/overlay/key-utils.d.ts +6 -0
- package/dist/ui/overlay/key-utils.js +6 -0
- package/dist/ui/overlay/overlay-types.d.ts +128 -0
- package/dist/ui/overlay/overlay-types.js +22 -0
- package/dist/ui/overlay/types.d.ts +135 -0
- package/dist/ui/overlay/types.js +22 -0
- package/dist/ui/overlays/help-overlay-v2.d.ts +28 -0
- package/dist/ui/overlays/help-overlay-v2.js +198 -0
- package/dist/ui/overlays/index.d.ts +11 -0
- package/dist/ui/overlays/index.js +11 -0
- package/dist/ui/overlays.d.ts +0 -4
- package/dist/ui/overlays.js +0 -444
- package/dist/ui/permission-overlay-v2.d.ts +36 -0
- package/dist/ui/permission-overlay-v2.js +380 -0
- package/dist/ui/permission-overlay.d.ts +1 -1
- package/dist/ui/permission-overlay.js +186 -298
- package/dist/ui/projects-overlay.d.ts +19 -0
- package/dist/ui/projects-overlay.js +484 -0
- package/dist/ui/providers/types.d.ts +178 -0
- package/dist/ui/providers/types.js +9 -0
- package/dist/ui/render-modes.d.ts +36 -0
- package/dist/ui/render-modes.js +44 -0
- package/dist/ui/startup-menu.d.ts +36 -0
- package/dist/ui/startup-menu.js +236 -0
- package/dist/ui/subagent-renderer.d.ts +117 -0
- package/dist/ui/subagent-renderer.js +334 -0
- package/dist/ui/terminal-codes.d.ts +94 -0
- package/dist/ui/terminal-codes.js +124 -0
- package/dist/ui/terminal-renderer.d.ts +221 -0
- package/dist/ui/terminal-renderer.js +751 -0
- package/dist/ui/terminal-ui.d.ts +463 -0
- package/dist/ui/terminal-ui.js +2296 -0
- package/dist/ui/terminal.d.ts +20 -0
- package/dist/ui/terminal.js +72 -0
- package/dist/ui/theme-overlay-v2.d.ts +42 -0
- package/dist/ui/theme-overlay-v2.js +135 -0
- package/dist/ui/theme-overlay.d.ts +24 -0
- package/dist/ui/theme-overlay.js +127 -0
- package/dist/ui/todo-zone.js +53 -25
- package/dist/ui/tool-formatters.d.ts +16 -0
- package/dist/ui/tool-formatters.js +516 -0
- package/dist/ui/tools-overlay-v2.d.ts +47 -0
- package/dist/ui/tools-overlay-v2.js +218 -0
- package/dist/ui/tools-overlay.d.ts +10 -2
- package/dist/ui/tools-overlay.js +172 -220
- package/dist/ui/tutorial-overlay-v2.d.ts +31 -0
- package/dist/ui/tutorial-overlay-v2.js +1035 -0
- package/dist/ui/tutorial-overlay.d.ts +1 -0
- package/dist/ui/tutorial-overlay.js +400 -302
- package/dist/ui/workflow-overlay.d.ts +22 -0
- package/dist/ui/workflow-overlay.js +636 -0
- package/dist/utils/debug-log.d.ts +28 -0
- package/dist/utils/debug-log.js +57 -0
- package/dist/utils/model-tiers.js +1 -1
- package/dist/utils/path-safety.d.ts +56 -0
- package/dist/utils/path-safety.js +239 -0
- package/dist/workflow/guided-mode-injector.d.ts +42 -0
- package/dist/workflow/guided-mode-injector.js +191 -0
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.js +8 -0
- package/dist/workflow/step-criteria.d.ts +62 -0
- package/dist/workflow/step-criteria.js +150 -0
- package/dist/workflow/step-tracker.d.ts +92 -0
- package/dist/workflow/step-tracker.js +141 -0
- package/package.json +12 -5
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mascot Overlay
|
|
3
|
+
*
|
|
4
|
+
* Standalone mascot selection overlay.
|
|
5
|
+
* Accessible via /mascot command or from Config overlay.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - All mascot expressions
|
|
9
|
+
* - Live preview
|
|
10
|
+
* - Persists selection to settings
|
|
11
|
+
*/
|
|
12
|
+
import * as terminal from './terminal.js';
|
|
13
|
+
import { BaseOverlay, isEscape, isEnter, isSpace, isCtrlC, isNavigateUp, isNavigateDown, isClose, renderBorder, } from './base/index.js';
|
|
14
|
+
import { getSettings, setSetting } from '../settings/index.js';
|
|
15
|
+
import { MASCOT_OPTIONS, MASCOT_LABELS, EXPRESSIONS, } from './mascot/index.js';
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// Mascot Overlay Class
|
|
18
|
+
// =============================================================================
|
|
19
|
+
class MascotOverlay extends BaseOverlay {
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
const currentMascot = options.currentMascot ?? getSettings().mascot;
|
|
22
|
+
// Find current mascot in options list
|
|
23
|
+
let selectedIndex = 0;
|
|
24
|
+
const mascotIndex = MASCOT_OPTIONS.findIndex(m => m === currentMascot);
|
|
25
|
+
if (mascotIndex >= 0) {
|
|
26
|
+
selectedIndex = mascotIndex;
|
|
27
|
+
}
|
|
28
|
+
const initialState = {
|
|
29
|
+
lineCount: 0,
|
|
30
|
+
maxLineCount: 0,
|
|
31
|
+
selectedIndex,
|
|
32
|
+
currentMascot,
|
|
33
|
+
};
|
|
34
|
+
super(initialState, { minHeight: 18 });
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
const s = this.styles;
|
|
38
|
+
const cols = terminal.getTerminalWidth();
|
|
39
|
+
const border = renderBorder(cols, s);
|
|
40
|
+
const lines = [];
|
|
41
|
+
// Get preview lines for side-by-side layout
|
|
42
|
+
const selectedOption = MASCOT_OPTIONS[this.state.selectedIndex];
|
|
43
|
+
let previewLines = [];
|
|
44
|
+
let previewLabel = '';
|
|
45
|
+
if (selectedOption === 'none') {
|
|
46
|
+
previewLabel = '(No mascot)';
|
|
47
|
+
previewLines = ['', '', '', '', '', ''];
|
|
48
|
+
}
|
|
49
|
+
else if (selectedOption === 'random') {
|
|
50
|
+
previewLabel = '(Random on startup)';
|
|
51
|
+
previewLines = EXPRESSIONS.neutral;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
previewLabel = MASCOT_LABELS[selectedOption];
|
|
55
|
+
previewLines = EXPRESSIONS[selectedOption];
|
|
56
|
+
}
|
|
57
|
+
// Header
|
|
58
|
+
lines.push(border);
|
|
59
|
+
lines.push(` ${s.primaryBold('Select Mascot')}`);
|
|
60
|
+
lines.push('');
|
|
61
|
+
// Column widths
|
|
62
|
+
const listColWidth = 28; // Space for list items
|
|
63
|
+
const gap = 4; // Gap between columns
|
|
64
|
+
const previewColStart = listColWidth + gap;
|
|
65
|
+
// Build side-by-side layout
|
|
66
|
+
// Options list on left, preview on right
|
|
67
|
+
const optionCount = MASCOT_OPTIONS.length;
|
|
68
|
+
const previewHeight = previewLines.length;
|
|
69
|
+
// Calculate where to start the preview (vertically center it with the list)
|
|
70
|
+
const previewStartRow = Math.max(0, Math.floor((optionCount - previewHeight) / 2));
|
|
71
|
+
for (let i = 0; i < Math.max(optionCount, previewStartRow + previewHeight + 1); i++) {
|
|
72
|
+
let leftPart = '';
|
|
73
|
+
let rightPart = '';
|
|
74
|
+
// Left column: option list
|
|
75
|
+
if (i < optionCount) {
|
|
76
|
+
const option = MASCOT_OPTIONS[i];
|
|
77
|
+
const isSelected = i === this.state.selectedIndex;
|
|
78
|
+
const isCurrent = option === this.state.currentMascot;
|
|
79
|
+
const prefix = isSelected ? s.primary('❯ ') : ' ';
|
|
80
|
+
const num = `${(i + 1).toString().padStart(2)}. `;
|
|
81
|
+
const checkmark = isCurrent ? s.success(' ✓') : '';
|
|
82
|
+
const label = isSelected ? s.primary(MASCOT_LABELS[option]) : MASCOT_LABELS[option];
|
|
83
|
+
leftPart = ` ${prefix}${num}${label}${checkmark}`;
|
|
84
|
+
}
|
|
85
|
+
// Right column: preview
|
|
86
|
+
const previewRow = i - previewStartRow;
|
|
87
|
+
if (previewRow === -1) {
|
|
88
|
+
// Preview label above the mascot
|
|
89
|
+
rightPart = s.muted(previewLabel);
|
|
90
|
+
}
|
|
91
|
+
else if (previewRow >= 0 && previewRow < previewHeight) {
|
|
92
|
+
rightPart = s.secondary(previewLines[previewRow]);
|
|
93
|
+
}
|
|
94
|
+
// Combine columns with proper spacing
|
|
95
|
+
// Strip ANSI codes for width calculation
|
|
96
|
+
// eslint-disable-next-line no-control-regex
|
|
97
|
+
const leftPlain = leftPart.replace(/\x1b\[[0-9;]*m/g, '');
|
|
98
|
+
const padding = ' '.repeat(Math.max(0, previewColStart - leftPlain.length));
|
|
99
|
+
lines.push(leftPart + padding + rightPart);
|
|
100
|
+
}
|
|
101
|
+
// Footer
|
|
102
|
+
lines.push('');
|
|
103
|
+
lines.push(border);
|
|
104
|
+
lines.push(` ${s.muted('↑↓/jk Navigate · Enter/Space Select · q/Esc Close')}`);
|
|
105
|
+
lines.push(border);
|
|
106
|
+
return lines;
|
|
107
|
+
}
|
|
108
|
+
handleKey(data) {
|
|
109
|
+
const maxIndex = MASCOT_OPTIONS.length - 1;
|
|
110
|
+
// Ctrl+C always closes
|
|
111
|
+
if (isCtrlC(data)) {
|
|
112
|
+
this.close({});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// q or Esc closes
|
|
116
|
+
if (isEscape(data) || isClose(data)) {
|
|
117
|
+
this.close({});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Navigation
|
|
121
|
+
if (isNavigateUp(data) && this.state.selectedIndex > 0) {
|
|
122
|
+
this.state.selectedIndex--;
|
|
123
|
+
this.update();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (isNavigateDown(data) && this.state.selectedIndex < maxIndex) {
|
|
127
|
+
this.state.selectedIndex++;
|
|
128
|
+
this.update();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// Enter/Space to select
|
|
132
|
+
if (isEnter(data) || isSpace(data)) {
|
|
133
|
+
const selectedMascot = MASCOT_OPTIONS[this.state.selectedIndex];
|
|
134
|
+
setSetting('mascot', selectedMascot);
|
|
135
|
+
this.close({
|
|
136
|
+
mascotChanged: selectedMascot,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// =============================================================================
|
|
142
|
+
// Export Function
|
|
143
|
+
// =============================================================================
|
|
144
|
+
export async function showMascotOverlay(options = {}) {
|
|
145
|
+
return new MascotOverlay(options).show();
|
|
146
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Overlay V2
|
|
3
|
+
*
|
|
4
|
+
* Model selection overlay using TabbedListOverlayV2 for the new Overlay interface.
|
|
5
|
+
* Works with TerminalUI's overlay management.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Tabs by provider (Claude, OpenAI, Gemini, Ollama)
|
|
9
|
+
* - Hot-swap detection (same provider = immediate, different = restart)
|
|
10
|
+
* - API key status checking
|
|
11
|
+
* - Persists selection to settings
|
|
12
|
+
*/
|
|
13
|
+
import { TabbedListOverlayV2 } from './base/index.js';
|
|
14
|
+
interface ModelOption {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
provider: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ModelOverlayV2Options {
|
|
21
|
+
/** Current model ID */
|
|
22
|
+
currentModel?: string;
|
|
23
|
+
/** Current provider (for hot-swap detection) */
|
|
24
|
+
currentProvider?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ModelOverlayV2Result {
|
|
27
|
+
/** Selected model ID (if changed) */
|
|
28
|
+
modelChanged?: string;
|
|
29
|
+
/** Selected provider */
|
|
30
|
+
provider?: string;
|
|
31
|
+
/** Whether restart is required (different provider) */
|
|
32
|
+
requiresRestart?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Model selection overlay using the new Overlay interface.
|
|
36
|
+
* Displays available models in a tabbed list by provider.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ModelOverlayV2 extends TabbedListOverlayV2<ModelOption, ModelOverlayV2Result> {
|
|
39
|
+
readonly type: "inline";
|
|
40
|
+
readonly id = "model-overlay-v2";
|
|
41
|
+
private readonly currentModel;
|
|
42
|
+
private readonly currentProvider;
|
|
43
|
+
constructor(options?: ModelOverlayV2Options);
|
|
44
|
+
/**
|
|
45
|
+
* Override to handle model selection on Enter.
|
|
46
|
+
*/
|
|
47
|
+
protected onItemSelected(item: ModelOption): ModelOverlayV2Result | undefined;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Overlay V2
|
|
3
|
+
*
|
|
4
|
+
* Model selection overlay using TabbedListOverlayV2 for the new Overlay interface.
|
|
5
|
+
* Works with TerminalUI's overlay management.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Tabs by provider (Claude, OpenAI, Gemini, Ollama)
|
|
9
|
+
* - Hot-swap detection (same provider = immediate, different = restart)
|
|
10
|
+
* - API key status checking
|
|
11
|
+
* - Persists selection to settings
|
|
12
|
+
*/
|
|
13
|
+
import { TabbedListOverlayV2, } from './base/index.js';
|
|
14
|
+
import { setSetting } from '../settings/index.js';
|
|
15
|
+
import { hasApiKey, settingsProviderToCredentialKey } from '../utils/credentials.js';
|
|
16
|
+
// =============================================================================
|
|
17
|
+
// Constants
|
|
18
|
+
// =============================================================================
|
|
19
|
+
const PAGE_SIZE = 10;
|
|
20
|
+
const PROVIDER_TABS = [
|
|
21
|
+
{ id: 'claude', label: 'Claude' },
|
|
22
|
+
{ id: 'openai', label: 'OpenAI' },
|
|
23
|
+
{ id: 'gemini', label: 'Gemini' },
|
|
24
|
+
{ id: 'ollama', label: 'Ollama' },
|
|
25
|
+
];
|
|
26
|
+
const MODEL_OPTIONS = [
|
|
27
|
+
// Claude
|
|
28
|
+
{ id: 'claude-sonnet-4-20250514', name: 'Sonnet 4', description: 'Best for everyday tasks', provider: 'claude' },
|
|
29
|
+
{ id: 'claude-opus-4-20250514', name: 'Opus 4', description: 'Most capable for complex work', provider: 'claude' },
|
|
30
|
+
{ id: 'claude-3-5-haiku-20241022', name: 'Haiku 3.5', description: 'Fastest for quick answers', provider: 'claude' },
|
|
31
|
+
// OpenAI
|
|
32
|
+
{ id: 'gpt-4o', name: 'GPT-4o', description: 'Best overall', provider: 'openai' },
|
|
33
|
+
{ id: 'gpt-4o-mini', name: 'GPT-4o Mini', description: 'Fast and affordable', provider: 'openai' },
|
|
34
|
+
// Gemini
|
|
35
|
+
{ id: 'gemini-2.0-flash', name: 'Gemini 2.0 Flash', description: 'Fast multimodal', provider: 'gemini' },
|
|
36
|
+
{ id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash', description: 'Latest stable flash', provider: 'gemini' },
|
|
37
|
+
{ id: 'gemini-2.5-pro', name: 'Gemini 2.5 Pro', description: 'Most capable Gemini', provider: 'gemini' },
|
|
38
|
+
// Ollama
|
|
39
|
+
{ id: 'llama3.2', name: 'Llama 3.2', description: 'Local model', provider: 'ollama' },
|
|
40
|
+
{ id: 'mistral', name: 'Mistral', description: 'Local model', provider: 'ollama' },
|
|
41
|
+
{ id: 'codellama', name: 'Code Llama', description: 'Code-focused local model', provider: 'ollama' },
|
|
42
|
+
];
|
|
43
|
+
// =============================================================================
|
|
44
|
+
// Model Overlay V2 Class
|
|
45
|
+
// =============================================================================
|
|
46
|
+
/**
|
|
47
|
+
* Model selection overlay using the new Overlay interface.
|
|
48
|
+
* Displays available models in a tabbed list by provider.
|
|
49
|
+
*/
|
|
50
|
+
export class ModelOverlayV2 extends TabbedListOverlayV2 {
|
|
51
|
+
type = 'inline';
|
|
52
|
+
id = 'model-overlay-v2';
|
|
53
|
+
currentModel;
|
|
54
|
+
currentProvider;
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
const currentModel = options.currentModel ?? 'claude-sonnet-4-20250514';
|
|
57
|
+
const currentProvider = options.currentProvider ?? 'claude';
|
|
58
|
+
// Find the initial tab based on current provider
|
|
59
|
+
const initialTabIndex = PROVIDER_TABS.findIndex((t) => t.id === currentProvider);
|
|
60
|
+
super({
|
|
61
|
+
title: 'Select Model',
|
|
62
|
+
tabs: PROVIDER_TABS,
|
|
63
|
+
items: MODEL_OPTIONS,
|
|
64
|
+
pageSize: PAGE_SIZE,
|
|
65
|
+
filterByTab: (item, tabId) => item.provider === tabId,
|
|
66
|
+
getSearchText: (item) => `${item.name} ${item.description} ${item.id}`,
|
|
67
|
+
renderItem: (item, isSelected, styles) => {
|
|
68
|
+
const isCurrent = item.id === currentModel;
|
|
69
|
+
const prefix = isSelected ? styles.primary(' > ') : ' ';
|
|
70
|
+
// Check API key status for this provider
|
|
71
|
+
const providerType = item.provider;
|
|
72
|
+
const credKey = settingsProviderToCredentialKey(providerType);
|
|
73
|
+
const hasKey = item.provider === 'ollama' || hasApiKey(credKey);
|
|
74
|
+
const keyIndicator = hasKey ? styles.success('●') : styles.error('○');
|
|
75
|
+
const name = isSelected
|
|
76
|
+
? styles.primary(item.name.padEnd(18))
|
|
77
|
+
: styles.muted(item.name.padEnd(18));
|
|
78
|
+
const desc = styles.muted(item.description);
|
|
79
|
+
const currentBadge = isCurrent ? styles.success(' (current)') : '';
|
|
80
|
+
return `${prefix}${keyIndicator} ${name}${desc}${currentBadge}`;
|
|
81
|
+
},
|
|
82
|
+
footerHints: (searchMode) => {
|
|
83
|
+
if (searchMode) {
|
|
84
|
+
return 'Type to filter · ↑↓/jk Navigate · Enter Select · Esc Exit search';
|
|
85
|
+
}
|
|
86
|
+
return 'Tab Provider · ↑↓/jk · / Search · Enter Select · q/Esc Close';
|
|
87
|
+
},
|
|
88
|
+
emptyMessage: 'No models available for this provider.',
|
|
89
|
+
noResultsMessage: 'No models match the search.',
|
|
90
|
+
});
|
|
91
|
+
this.currentModel = currentModel;
|
|
92
|
+
this.currentProvider = currentProvider;
|
|
93
|
+
// Set initial tab based on current provider
|
|
94
|
+
if (initialTabIndex >= 0) {
|
|
95
|
+
this.state.currentTab = initialTabIndex;
|
|
96
|
+
// Re-filter items for the selected tab
|
|
97
|
+
this.state.filteredItems = MODEL_OPTIONS.filter((item) => item.provider === PROVIDER_TABS[initialTabIndex]?.id);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Override to handle model selection on Enter.
|
|
102
|
+
*/
|
|
103
|
+
onItemSelected(item) {
|
|
104
|
+
if (item.id === this.currentModel) {
|
|
105
|
+
// Same model, no change
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
// Save to settings
|
|
109
|
+
setSetting('defaultModel', item.id);
|
|
110
|
+
setSetting('defaultProvider', item.provider);
|
|
111
|
+
const requiresRestart = item.provider !== this.currentProvider;
|
|
112
|
+
return {
|
|
113
|
+
modelChanged: item.id,
|
|
114
|
+
provider: item.provider,
|
|
115
|
+
requiresRestart,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Overlay
|
|
3
|
+
*
|
|
4
|
+
* Standalone model selection overlay with tabbed provider interface.
|
|
5
|
+
* Accessible via /model command or from Config overlay.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Tabbed by provider (Claude, OpenAI, Gemini, Ollama)
|
|
9
|
+
* - Hot-swap detection (same provider = immediate, different = restart)
|
|
10
|
+
* - API key status checking
|
|
11
|
+
* - Persists selection to settings
|
|
12
|
+
*/
|
|
13
|
+
export interface ModelOverlayOptions {
|
|
14
|
+
/** Current model ID */
|
|
15
|
+
currentModel?: string;
|
|
16
|
+
/** Current provider (for hot-swap detection) */
|
|
17
|
+
currentProvider?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ModelOverlayResult {
|
|
20
|
+
/** Selected model ID (if changed) */
|
|
21
|
+
modelChanged?: string;
|
|
22
|
+
/** Selected provider */
|
|
23
|
+
provider?: string;
|
|
24
|
+
/** Whether restart is required (different provider) */
|
|
25
|
+
requiresRestart?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function showModelOverlay(options?: ModelOverlayOptions): Promise<ModelOverlayResult>;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Overlay
|
|
3
|
+
*
|
|
4
|
+
* Standalone model selection overlay with tabbed provider interface.
|
|
5
|
+
* Accessible via /model command or from Config overlay.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Tabbed by provider (Claude, OpenAI, Gemini, Ollama)
|
|
9
|
+
* - Hot-swap detection (same provider = immediate, different = restart)
|
|
10
|
+
* - API key status checking
|
|
11
|
+
* - Persists selection to settings
|
|
12
|
+
*/
|
|
13
|
+
import * as terminal from './terminal.js';
|
|
14
|
+
import { BaseOverlay, isEscape, isTab, isShiftTab, isEnter, isCtrlC, isNavigateUp, isNavigateDown, isClose, extractPrintable, renderBorder, } from './base/index.js';
|
|
15
|
+
import { TabFeature } from './features/tab-feature.js';
|
|
16
|
+
import { setSetting } from '../settings/index.js';
|
|
17
|
+
import { hasApiKey, settingsProviderToCredentialKey } from '../utils/credentials.js';
|
|
18
|
+
// =============================================================================
|
|
19
|
+
// Constants
|
|
20
|
+
// =============================================================================
|
|
21
|
+
const PROVIDER_TABS = [
|
|
22
|
+
{ id: 'claude', label: 'Claude' },
|
|
23
|
+
{ id: 'openai', label: 'OpenAI' },
|
|
24
|
+
{ id: 'gemini', label: 'Gemini' },
|
|
25
|
+
{ id: 'ollama', label: 'Ollama' },
|
|
26
|
+
];
|
|
27
|
+
const MODEL_OPTIONS = [
|
|
28
|
+
// Claude
|
|
29
|
+
{ id: 'claude-sonnet-4-20250514', name: 'Sonnet 4', description: 'Best for everyday tasks', provider: 'claude' },
|
|
30
|
+
{ id: 'claude-opus-4-20250514', name: 'Opus 4', description: 'Most capable for complex work', provider: 'claude' },
|
|
31
|
+
{ id: 'claude-3-5-haiku-20241022', name: 'Haiku 3.5', description: 'Fastest for quick answers', provider: 'claude' },
|
|
32
|
+
// OpenAI
|
|
33
|
+
{ id: 'gpt-4o', name: 'GPT-4o', description: 'Best overall', provider: 'openai' },
|
|
34
|
+
{ id: 'gpt-4o-mini', name: 'GPT-4o Mini', description: 'Fast and affordable', provider: 'openai' },
|
|
35
|
+
// Gemini
|
|
36
|
+
{ id: 'gemini-2.0-flash', name: 'Gemini 2.0 Flash', description: 'Fast multimodal', provider: 'gemini' },
|
|
37
|
+
{ id: 'gemini-2.5-flash', name: 'Gemini 2.5 Flash', description: 'Latest stable flash', provider: 'gemini' },
|
|
38
|
+
{ id: 'gemini-2.5-pro', name: 'Gemini 2.5 Pro', description: 'Most capable Gemini', provider: 'gemini' },
|
|
39
|
+
// Ollama
|
|
40
|
+
{ id: 'llama3.2', name: 'Llama 3.2', description: 'Local model', provider: 'ollama' },
|
|
41
|
+
{ id: 'mistral', name: 'Mistral', description: 'Local model', provider: 'ollama' },
|
|
42
|
+
{ id: 'codellama', name: 'Code Llama', description: 'Code-focused local model', provider: 'ollama' },
|
|
43
|
+
];
|
|
44
|
+
// =============================================================================
|
|
45
|
+
// Helper Functions
|
|
46
|
+
// =============================================================================
|
|
47
|
+
function getModelsForProvider(providerId) {
|
|
48
|
+
return MODEL_OPTIONS.filter(m => m.provider === providerId);
|
|
49
|
+
}
|
|
50
|
+
function findModelById(modelId) {
|
|
51
|
+
return MODEL_OPTIONS.find(m => m.id === modelId);
|
|
52
|
+
}
|
|
53
|
+
function getProviderTabIndex(providerId) {
|
|
54
|
+
const index = PROVIDER_TABS.findIndex(p => p.id === providerId);
|
|
55
|
+
return index >= 0 ? index : 0;
|
|
56
|
+
}
|
|
57
|
+
// =============================================================================
|
|
58
|
+
// Model Overlay Class
|
|
59
|
+
// =============================================================================
|
|
60
|
+
class ModelOverlay extends BaseOverlay {
|
|
61
|
+
tabFeature;
|
|
62
|
+
constructor(options = {}) {
|
|
63
|
+
const currentModel = findModelById(options.currentModel ?? '');
|
|
64
|
+
const currentProvider = options.currentProvider ?? currentModel?.provider ?? 'claude';
|
|
65
|
+
// Find initial tab and model index
|
|
66
|
+
const initialTab = getProviderTabIndex(currentProvider);
|
|
67
|
+
const providerModels = getModelsForProvider(PROVIDER_TABS[initialTab].id);
|
|
68
|
+
const modelIndex = currentModel
|
|
69
|
+
? providerModels.findIndex(m => m.id === currentModel.id)
|
|
70
|
+
: 0;
|
|
71
|
+
const initialState = {
|
|
72
|
+
lineCount: 0,
|
|
73
|
+
maxLineCount: 0,
|
|
74
|
+
selectedIndex: modelIndex >= 0 ? modelIndex : 0,
|
|
75
|
+
currentTab: initialTab,
|
|
76
|
+
activeProvider: currentProvider,
|
|
77
|
+
currentModelId: options.currentModel ?? '',
|
|
78
|
+
};
|
|
79
|
+
super(initialState, { minHeight: 16 });
|
|
80
|
+
this.tabFeature = new TabFeature(PROVIDER_TABS, () => {
|
|
81
|
+
// Reset selection when tab changes
|
|
82
|
+
this.state.selectedIndex = 0;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
render() {
|
|
86
|
+
const s = this.styles;
|
|
87
|
+
const cols = terminal.getTerminalWidth();
|
|
88
|
+
const border = renderBorder(cols, s);
|
|
89
|
+
const lines = [];
|
|
90
|
+
const currentProviderTab = PROVIDER_TABS[this.state.currentTab];
|
|
91
|
+
const providerModels = getModelsForProvider(currentProviderTab.id);
|
|
92
|
+
const isActiveProvider = currentProviderTab.id === this.state.activeProvider;
|
|
93
|
+
// Header
|
|
94
|
+
lines.push(border);
|
|
95
|
+
lines.push(` ${s.primaryBold('Select Model')}`);
|
|
96
|
+
lines.push('');
|
|
97
|
+
// Provider tabs with checkmark on active
|
|
98
|
+
let tabLine = ' ';
|
|
99
|
+
for (let i = 0; i < PROVIDER_TABS.length; i++) {
|
|
100
|
+
const tab = PROVIDER_TABS[i];
|
|
101
|
+
const isActive = tab.id === this.state.activeProvider;
|
|
102
|
+
const indicator = isActive ? ' ✓' : '';
|
|
103
|
+
if (i === this.state.currentTab) {
|
|
104
|
+
tabLine += s.selected(` ${tab.label}${indicator} `) + ' ';
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
tabLine += s.muted(` ${tab.label}${indicator} `) + ' ';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
tabLine += s.muted('(Tab · 1-4)');
|
|
111
|
+
lines.push(tabLine);
|
|
112
|
+
lines.push('');
|
|
113
|
+
// Provider status message
|
|
114
|
+
if (isActiveProvider) {
|
|
115
|
+
lines.push(` ${s.success('Current provider - changes apply immediately')}`);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
lines.push(` ${s.warning('Different provider - restart required to apply')}`);
|
|
119
|
+
}
|
|
120
|
+
// API key status (not needed for Ollama)
|
|
121
|
+
if (currentProviderTab.id !== 'ollama') {
|
|
122
|
+
const credKey = settingsProviderToCredentialKey(currentProviderTab.id);
|
|
123
|
+
if (!hasApiKey(credKey)) {
|
|
124
|
+
lines.push(` ${s.error('⚠ No API key configured - use /keys to set it')}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
lines.push('');
|
|
128
|
+
// Model list
|
|
129
|
+
for (let i = 0; i < providerModels.length; i++) {
|
|
130
|
+
const model = providerModels[i];
|
|
131
|
+
const isSelected = i === this.state.selectedIndex;
|
|
132
|
+
const isCurrent = model.id === this.state.currentModelId;
|
|
133
|
+
const prefix = isSelected ? s.primary('❯ ') : ' ';
|
|
134
|
+
const checkmark = isCurrent ? s.success(' ✓') : '';
|
|
135
|
+
const label = isSelected ? s.primary(model.name) : model.name;
|
|
136
|
+
const desc = s.muted(` · ${model.description}`);
|
|
137
|
+
lines.push(` ${prefix}${label.padEnd(20)}${desc}${checkmark}`);
|
|
138
|
+
}
|
|
139
|
+
// Pad for consistent height
|
|
140
|
+
const minModelLines = 4;
|
|
141
|
+
for (let i = providerModels.length; i < minModelLines; i++) {
|
|
142
|
+
lines.push('');
|
|
143
|
+
}
|
|
144
|
+
// Footer
|
|
145
|
+
lines.push('');
|
|
146
|
+
lines.push(border);
|
|
147
|
+
lines.push(` ${s.muted('Tab/1-4 Provider · ↑↓/jk Model · Enter Select · q/Esc Close')}`);
|
|
148
|
+
lines.push(border);
|
|
149
|
+
return lines;
|
|
150
|
+
}
|
|
151
|
+
handleKey(data) {
|
|
152
|
+
const currentProviderTab = PROVIDER_TABS[this.state.currentTab];
|
|
153
|
+
const providerModels = getModelsForProvider(currentProviderTab.id);
|
|
154
|
+
const maxModelIndex = providerModels.length - 1;
|
|
155
|
+
// Ctrl+C always closes
|
|
156
|
+
if (isCtrlC(data)) {
|
|
157
|
+
this.close({});
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
// q or Esc closes
|
|
161
|
+
if (isEscape(data) || isClose(data)) {
|
|
162
|
+
this.close({});
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
// Tab switching: Tab for next, Shift+Tab for previous
|
|
166
|
+
if (isTab(data)) {
|
|
167
|
+
this.state.currentTab = (this.state.currentTab + 1) % PROVIDER_TABS.length;
|
|
168
|
+
this.state.selectedIndex = 0;
|
|
169
|
+
this.update();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (isShiftTab(data)) {
|
|
173
|
+
this.state.currentTab = (this.state.currentTab - 1 + PROVIDER_TABS.length) % PROVIDER_TABS.length;
|
|
174
|
+
this.state.selectedIndex = 0;
|
|
175
|
+
this.update();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// Number keys 1-4 for provider tabs
|
|
179
|
+
const char = extractPrintable(data);
|
|
180
|
+
if (char && char >= '1' && char <= '4') {
|
|
181
|
+
const tabNum = parseInt(char, 10) - 1;
|
|
182
|
+
if (tabNum < PROVIDER_TABS.length) {
|
|
183
|
+
this.state.currentTab = tabNum;
|
|
184
|
+
this.state.selectedIndex = 0;
|
|
185
|
+
this.update();
|
|
186
|
+
}
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
// Navigation (↑↓ or j/k)
|
|
190
|
+
if (isNavigateUp(data) && this.state.selectedIndex > 0) {
|
|
191
|
+
this.state.selectedIndex--;
|
|
192
|
+
this.update();
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (isNavigateDown(data) && this.state.selectedIndex < maxModelIndex) {
|
|
196
|
+
this.state.selectedIndex++;
|
|
197
|
+
this.update();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Enter - select model
|
|
201
|
+
if (isEnter(data) && providerModels.length > 0) {
|
|
202
|
+
const selectedModel = providerModels[this.state.selectedIndex];
|
|
203
|
+
const isCurrentProvider = selectedModel.provider === this.state.activeProvider;
|
|
204
|
+
// Persist to settings
|
|
205
|
+
setSetting('defaultProvider', selectedModel.provider);
|
|
206
|
+
setSetting('defaultModel', selectedModel.id);
|
|
207
|
+
this.close({
|
|
208
|
+
modelChanged: selectedModel.id,
|
|
209
|
+
provider: selectedModel.provider,
|
|
210
|
+
requiresRestart: !isCurrentProvider,
|
|
211
|
+
});
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// =============================================================================
|
|
217
|
+
// Export Function
|
|
218
|
+
// =============================================================================
|
|
219
|
+
export async function showModelOverlay(options = {}) {
|
|
220
|
+
return new ModelOverlay(options).show();
|
|
221
|
+
}
|
|
@@ -105,10 +105,9 @@ export async function showModelWarningOverlay(options) {
|
|
|
105
105
|
let selectedIndex = 0;
|
|
106
106
|
let lineCount = 0;
|
|
107
107
|
let maxLineCount = 0;
|
|
108
|
-
// Pause footer animation
|
|
108
|
+
// Pause footer animation (this overlay is called from repl.ts, not agent tools)
|
|
109
109
|
pauseForOverlay();
|
|
110
|
-
//
|
|
111
|
-
terminal.clearToEndOfScreen();
|
|
110
|
+
// Ensure we start from a fresh line
|
|
112
111
|
terminal.writeLine('');
|
|
113
112
|
terminal.hideCursor();
|
|
114
113
|
const wasRawMode = process.stdin.isRaw;
|
|
@@ -116,8 +115,6 @@ export async function showModelWarningOverlay(options) {
|
|
|
116
115
|
// Initial render
|
|
117
116
|
lineCount = render(options, selectedIndex, 0);
|
|
118
117
|
maxLineCount = Math.max(maxLineCount, lineCount);
|
|
119
|
-
// Re-render to stabilize
|
|
120
|
-
lineCount = render(options, selectedIndex, lineCount, lineCount);
|
|
121
118
|
return new Promise((resolve) => {
|
|
122
119
|
const cleanup = () => {
|
|
123
120
|
terminal.clearLinesAbove(maxLineCount);
|
|
@@ -127,6 +124,7 @@ export async function showModelWarningOverlay(options) {
|
|
|
127
124
|
terminal.disableRawMode();
|
|
128
125
|
}
|
|
129
126
|
process.stdin.removeListener('data', handleData);
|
|
127
|
+
// Resume footer (this overlay handles its own pause/resume)
|
|
130
128
|
resumeAfterOverlay();
|
|
131
129
|
};
|
|
132
130
|
const handleData = (data) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New Project Overlay
|
|
3
|
+
*
|
|
4
|
+
* Modal overlay for the /new wizard - creates new projects with structured workflow.
|
|
5
|
+
* Uses InlineOverlay base class for consistent lifecycle management.
|
|
6
|
+
*
|
|
7
|
+
* Steps:
|
|
8
|
+
* 0. Project type (new vs existing)
|
|
9
|
+
* 1. Project name
|
|
10
|
+
* 2. Description
|
|
11
|
+
* 3. Repo pattern (single vs two-repo)
|
|
12
|
+
* 4. Tech stack
|
|
13
|
+
* 5. Coding standards
|
|
14
|
+
* 6. Initialize git?
|
|
15
|
+
* 7. Track with project database?
|
|
16
|
+
* 8. Workflow mode (if tracking enabled)
|
|
17
|
+
* 9. Confirmation
|
|
18
|
+
*/
|
|
19
|
+
type WorkflowMode = 'flexible' | 'guided';
|
|
20
|
+
export interface NewProjectResult {
|
|
21
|
+
created: boolean;
|
|
22
|
+
projectPath?: string;
|
|
23
|
+
docsPath?: string;
|
|
24
|
+
filesCreated?: string[];
|
|
25
|
+
trackInDatabase?: boolean;
|
|
26
|
+
workflowMode?: WorkflowMode;
|
|
27
|
+
projectName?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Show the init wizard overlay
|
|
32
|
+
*/
|
|
33
|
+
export declare function showNewProjectOverlay(): Promise<NewProjectResult>;
|
|
34
|
+
export {};
|