@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,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InlineOverlay Base Class
|
|
3
|
+
*
|
|
4
|
+
* Base class for "in-conversation" overlays that render above the footer.
|
|
5
|
+
* These overlays differ from full-screen overlays (BaseOverlay) in that they:
|
|
6
|
+
* - Render inline within the conversation
|
|
7
|
+
* - Use line-based clearing (clearLinesAbove) instead of full screen clear
|
|
8
|
+
* - Track line counts to prevent ghost lines and cursor drift
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT: Footer pause/resume should be handled by the CALLER (index.ts),
|
|
11
|
+
* not by the overlay itself. This prevents double-pause issues when
|
|
12
|
+
* overlays are triggered by agent tools.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* class MyOverlay extends InlineOverlay<MyState, MyResult> {
|
|
17
|
+
* constructor(private options: MyOptions) {
|
|
18
|
+
* super();
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* getInitialState(): MyState {
|
|
22
|
+
* return { selectedIndex: 0 };
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* render(): string[] {
|
|
26
|
+
* return ['Line 1', 'Line 2', ...];
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* handleKey(data: Buffer): InlineAction<MyResult> {
|
|
30
|
+
* if (isEnterKey(data)) {
|
|
31
|
+
* return { type: 'close', result: this.state.selectedValue };
|
|
32
|
+
* }
|
|
33
|
+
* return { type: 'continue' };
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* // Usage
|
|
38
|
+
* const overlay = new MyOverlay(options);
|
|
39
|
+
* const result = await overlay.show();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import { type InlineOverlayContext, isEscapeKey, isCtrlCKey, isEnterKey, isUpArrowKey, isDownArrowKey, isLeftArrowKey, isRightArrowKey, isTabKey, isSpaceKey, isBackspaceKey, isPrintableChar, getPrintableChar } from './inline-overlay-utils.js';
|
|
43
|
+
/**
|
|
44
|
+
* Action returned by handleKey to control overlay flow.
|
|
45
|
+
*/
|
|
46
|
+
export type InlineAction<TResult> = {
|
|
47
|
+
type: 'continue';
|
|
48
|
+
} | {
|
|
49
|
+
type: 'close';
|
|
50
|
+
result: TResult;
|
|
51
|
+
} | {
|
|
52
|
+
type: 'suspend';
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Options for cleanup behavior.
|
|
56
|
+
*/
|
|
57
|
+
export interface CleanupOptions {
|
|
58
|
+
/** Summary line to show after cleanup (optional) */
|
|
59
|
+
summaryLine?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Abstract base class for inline overlays.
|
|
63
|
+
*
|
|
64
|
+
* @template TState - The overlay's internal state type
|
|
65
|
+
* @template TResult - The result type returned when the overlay closes
|
|
66
|
+
*/
|
|
67
|
+
export declare abstract class InlineOverlay<TState, TResult> {
|
|
68
|
+
/** Current overlay state */
|
|
69
|
+
protected state: TState;
|
|
70
|
+
/** Render context (line counts, raw mode tracking) */
|
|
71
|
+
protected ctx: InlineOverlayContext;
|
|
72
|
+
/** Whether the overlay is currently suspended (for sub-overlays) */
|
|
73
|
+
protected isSuspended: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Return the initial state for the overlay.
|
|
76
|
+
*/
|
|
77
|
+
abstract getInitialState(): TState;
|
|
78
|
+
/**
|
|
79
|
+
* Render the overlay and return an array of lines.
|
|
80
|
+
* Each element in the array is one line of output.
|
|
81
|
+
* Lines should NOT include trailing newlines.
|
|
82
|
+
*/
|
|
83
|
+
abstract render(): string[];
|
|
84
|
+
/**
|
|
85
|
+
* Handle a keypress and return an action.
|
|
86
|
+
* Can be async to support sub-overlays or other async operations.
|
|
87
|
+
*
|
|
88
|
+
* @param data - The raw keypress buffer
|
|
89
|
+
* @returns Action to take (continue, close, or suspend)
|
|
90
|
+
*/
|
|
91
|
+
abstract handleKey(data: Buffer): InlineAction<TResult> | Promise<InlineAction<TResult>>;
|
|
92
|
+
/**
|
|
93
|
+
* Return a summary line to display after the overlay closes.
|
|
94
|
+
* Return null to skip the summary.
|
|
95
|
+
*
|
|
96
|
+
* @param result - The result being returned
|
|
97
|
+
*/
|
|
98
|
+
protected getCleanupSummary(_result: TResult): string | null;
|
|
99
|
+
/**
|
|
100
|
+
* Called during setup, before initial render.
|
|
101
|
+
* Override to perform additional setup.
|
|
102
|
+
*/
|
|
103
|
+
protected onSetup(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Called during cleanup, before resolving.
|
|
106
|
+
* Override to perform additional cleanup.
|
|
107
|
+
*/
|
|
108
|
+
protected onCleanup(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Get terminal width for layout calculations.
|
|
111
|
+
*/
|
|
112
|
+
protected getTerminalWidth(): number;
|
|
113
|
+
/**
|
|
114
|
+
* Trigger a re-render.
|
|
115
|
+
* Call this after updating state in handleKey.
|
|
116
|
+
*/
|
|
117
|
+
protected requestRender(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Suspend the overlay temporarily (e.g., to show a sub-overlay).
|
|
120
|
+
* The overlay will not process keys while suspended.
|
|
121
|
+
* Call resume() when the sub-overlay is done.
|
|
122
|
+
*/
|
|
123
|
+
protected suspend(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Resume the overlay after suspension.
|
|
126
|
+
* This clears the current render and re-renders.
|
|
127
|
+
*/
|
|
128
|
+
protected resume(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Clear all rendered lines (useful before showing a sub-overlay).
|
|
131
|
+
*/
|
|
132
|
+
protected clearRender(): void;
|
|
133
|
+
protected isEscapeKey: typeof isEscapeKey;
|
|
134
|
+
protected isCtrlCKey: typeof isCtrlCKey;
|
|
135
|
+
protected isEnterKey: typeof isEnterKey;
|
|
136
|
+
protected isUpArrowKey: typeof isUpArrowKey;
|
|
137
|
+
protected isDownArrowKey: typeof isDownArrowKey;
|
|
138
|
+
protected isLeftArrowKey: typeof isLeftArrowKey;
|
|
139
|
+
protected isRightArrowKey: typeof isRightArrowKey;
|
|
140
|
+
protected isTabKey: typeof isTabKey;
|
|
141
|
+
protected isSpaceKey: typeof isSpaceKey;
|
|
142
|
+
protected isBackspaceKey: typeof isBackspaceKey;
|
|
143
|
+
protected isPrintableChar: typeof isPrintableChar;
|
|
144
|
+
protected getPrintableChar: typeof getPrintableChar;
|
|
145
|
+
/**
|
|
146
|
+
* Show the overlay and wait for user interaction.
|
|
147
|
+
* Returns the result when the user closes the overlay.
|
|
148
|
+
*/
|
|
149
|
+
show(): Promise<TResult>;
|
|
150
|
+
/**
|
|
151
|
+
* Perform a render cycle.
|
|
152
|
+
*/
|
|
153
|
+
private doRender;
|
|
154
|
+
/**
|
|
155
|
+
* Clean up the overlay.
|
|
156
|
+
*/
|
|
157
|
+
private cleanup;
|
|
158
|
+
}
|
|
159
|
+
export { type InlineOverlayContext, createInlineOverlayContext, isEscapeKey, isCtrlCKey, isEnterKey, isUpArrowKey, isDownArrowKey, isLeftArrowKey, isRightArrowKey, isTabKey, isSpaceKey, isBackspaceKey, isPrintableChar, getPrintableChar, } from './inline-overlay-utils.js';
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InlineOverlay Base Class
|
|
3
|
+
*
|
|
4
|
+
* Base class for "in-conversation" overlays that render above the footer.
|
|
5
|
+
* These overlays differ from full-screen overlays (BaseOverlay) in that they:
|
|
6
|
+
* - Render inline within the conversation
|
|
7
|
+
* - Use line-based clearing (clearLinesAbove) instead of full screen clear
|
|
8
|
+
* - Track line counts to prevent ghost lines and cursor drift
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT: Footer pause/resume should be handled by the CALLER (index.ts),
|
|
11
|
+
* not by the overlay itself. This prevents double-pause issues when
|
|
12
|
+
* overlays are triggered by agent tools.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```typescript
|
|
16
|
+
* class MyOverlay extends InlineOverlay<MyState, MyResult> {
|
|
17
|
+
* constructor(private options: MyOptions) {
|
|
18
|
+
* super();
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* getInitialState(): MyState {
|
|
22
|
+
* return { selectedIndex: 0 };
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* render(): string[] {
|
|
26
|
+
* return ['Line 1', 'Line 2', ...];
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* handleKey(data: Buffer): InlineAction<MyResult> {
|
|
30
|
+
* if (isEnterKey(data)) {
|
|
31
|
+
* return { type: 'close', result: this.state.selectedValue };
|
|
32
|
+
* }
|
|
33
|
+
* return { type: 'continue' };
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* // Usage
|
|
38
|
+
* const overlay = new MyOverlay(options);
|
|
39
|
+
* const result = await overlay.show();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import * as terminal from '../terminal.js';
|
|
43
|
+
import { createInlineOverlayContext, isEscapeKey, isCtrlCKey, isEnterKey, isUpArrowKey, isDownArrowKey, isLeftArrowKey, isRightArrowKey, isTabKey, isSpaceKey, isBackspaceKey, isPrintableChar, getPrintableChar, } from './inline-overlay-utils.js';
|
|
44
|
+
// =============================================================================
|
|
45
|
+
// Base Class
|
|
46
|
+
// =============================================================================
|
|
47
|
+
/**
|
|
48
|
+
* Abstract base class for inline overlays.
|
|
49
|
+
*
|
|
50
|
+
* @template TState - The overlay's internal state type
|
|
51
|
+
* @template TResult - The result type returned when the overlay closes
|
|
52
|
+
*/
|
|
53
|
+
export class InlineOverlay {
|
|
54
|
+
/** Current overlay state */
|
|
55
|
+
state;
|
|
56
|
+
/** Render context (line counts, raw mode tracking) */
|
|
57
|
+
ctx;
|
|
58
|
+
/** Whether the overlay is currently suspended (for sub-overlays) */
|
|
59
|
+
isSuspended = false;
|
|
60
|
+
// ===========================================================================
|
|
61
|
+
// Optional Hooks - Can be overridden by subclasses
|
|
62
|
+
// ===========================================================================
|
|
63
|
+
/**
|
|
64
|
+
* Return a summary line to display after the overlay closes.
|
|
65
|
+
* Return null to skip the summary.
|
|
66
|
+
*
|
|
67
|
+
* @param result - The result being returned
|
|
68
|
+
*/
|
|
69
|
+
getCleanupSummary(_result) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Called during setup, before initial render.
|
|
74
|
+
* Override to perform additional setup.
|
|
75
|
+
*/
|
|
76
|
+
onSetup() {
|
|
77
|
+
// Default: no-op
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Called during cleanup, before resolving.
|
|
81
|
+
* Override to perform additional cleanup.
|
|
82
|
+
*/
|
|
83
|
+
onCleanup() {
|
|
84
|
+
// Default: no-op
|
|
85
|
+
}
|
|
86
|
+
// ===========================================================================
|
|
87
|
+
// Protected Utilities - For use by subclasses
|
|
88
|
+
// ===========================================================================
|
|
89
|
+
/**
|
|
90
|
+
* Get terminal width for layout calculations.
|
|
91
|
+
*/
|
|
92
|
+
getTerminalWidth() {
|
|
93
|
+
return terminal.getTerminalWidth();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Trigger a re-render.
|
|
97
|
+
* Call this after updating state in handleKey.
|
|
98
|
+
*/
|
|
99
|
+
requestRender() {
|
|
100
|
+
this.doRender();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Suspend the overlay temporarily (e.g., to show a sub-overlay).
|
|
104
|
+
* The overlay will not process keys while suspended.
|
|
105
|
+
* Call resume() when the sub-overlay is done.
|
|
106
|
+
*/
|
|
107
|
+
suspend() {
|
|
108
|
+
this.isSuspended = true;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Resume the overlay after suspension.
|
|
112
|
+
* This clears the current render and re-renders.
|
|
113
|
+
*/
|
|
114
|
+
resume() {
|
|
115
|
+
this.isSuspended = false;
|
|
116
|
+
// After sub-overlay, we need to re-render from scratch
|
|
117
|
+
// Clear whatever the sub-overlay left and render fresh
|
|
118
|
+
this.doRender();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Clear all rendered lines (useful before showing a sub-overlay).
|
|
122
|
+
*/
|
|
123
|
+
clearRender() {
|
|
124
|
+
if (this.ctx.maxLineCount > 0) {
|
|
125
|
+
terminal.clearLinesAbove(this.ctx.maxLineCount);
|
|
126
|
+
}
|
|
127
|
+
this.ctx.lineCount = 0;
|
|
128
|
+
this.ctx.maxLineCount = 0;
|
|
129
|
+
}
|
|
130
|
+
// ===========================================================================
|
|
131
|
+
// Key Detection Utilities - Re-exported for convenience
|
|
132
|
+
// ===========================================================================
|
|
133
|
+
isEscapeKey = isEscapeKey;
|
|
134
|
+
isCtrlCKey = isCtrlCKey;
|
|
135
|
+
isEnterKey = isEnterKey;
|
|
136
|
+
isUpArrowKey = isUpArrowKey;
|
|
137
|
+
isDownArrowKey = isDownArrowKey;
|
|
138
|
+
isLeftArrowKey = isLeftArrowKey;
|
|
139
|
+
isRightArrowKey = isRightArrowKey;
|
|
140
|
+
isTabKey = isTabKey;
|
|
141
|
+
isSpaceKey = isSpaceKey;
|
|
142
|
+
isBackspaceKey = isBackspaceKey;
|
|
143
|
+
isPrintableChar = isPrintableChar;
|
|
144
|
+
getPrintableChar = getPrintableChar;
|
|
145
|
+
// ===========================================================================
|
|
146
|
+
// Main Entry Point
|
|
147
|
+
// ===========================================================================
|
|
148
|
+
/**
|
|
149
|
+
* Show the overlay and wait for user interaction.
|
|
150
|
+
* Returns the result when the user closes the overlay.
|
|
151
|
+
*/
|
|
152
|
+
async show() {
|
|
153
|
+
// Initialize
|
|
154
|
+
this.ctx = createInlineOverlayContext();
|
|
155
|
+
this.state = this.getInitialState();
|
|
156
|
+
// Setup
|
|
157
|
+
this.ctx.wasRawMode = process.stdin.isRaw;
|
|
158
|
+
terminal.writeLine(''); // Start from fresh line
|
|
159
|
+
terminal.hideCursor();
|
|
160
|
+
terminal.enableRawMode();
|
|
161
|
+
this.onSetup();
|
|
162
|
+
// Initial render
|
|
163
|
+
this.doRender();
|
|
164
|
+
// Event loop
|
|
165
|
+
return new Promise((resolve) => {
|
|
166
|
+
const handleData = (data) => {
|
|
167
|
+
// Ignore keys while suspended
|
|
168
|
+
if (this.isSuspended) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// Handle both sync and async handleKey
|
|
172
|
+
const processAction = (action) => {
|
|
173
|
+
switch (action.type) {
|
|
174
|
+
case 'continue':
|
|
175
|
+
this.doRender();
|
|
176
|
+
break;
|
|
177
|
+
case 'close':
|
|
178
|
+
this.cleanup(action.result);
|
|
179
|
+
process.stdin.removeListener('data', handleData);
|
|
180
|
+
resolve(action.result);
|
|
181
|
+
break;
|
|
182
|
+
case 'suspend':
|
|
183
|
+
// Subclass will call resume() when ready
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
try {
|
|
188
|
+
const result = this.handleKey(data);
|
|
189
|
+
// Check if result is a Promise
|
|
190
|
+
if (result instanceof Promise) {
|
|
191
|
+
void result.then(processAction).catch((error) => {
|
|
192
|
+
console.error('Error in handleKey:', error);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
processAction(result);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
// Log error but don't crash
|
|
201
|
+
console.error('Error in handleKey:', error);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
process.stdin.on('data', handleData);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// ===========================================================================
|
|
208
|
+
// Private Methods
|
|
209
|
+
// ===========================================================================
|
|
210
|
+
/**
|
|
211
|
+
* Perform a render cycle.
|
|
212
|
+
*/
|
|
213
|
+
doRender() {
|
|
214
|
+
// Clear previous render
|
|
215
|
+
if (this.ctx.maxLineCount > 0) {
|
|
216
|
+
terminal.clearLinesAbove(this.ctx.maxLineCount);
|
|
217
|
+
}
|
|
218
|
+
// Get lines from subclass
|
|
219
|
+
const lines = this.render();
|
|
220
|
+
// Pad to consistent height (prevents cursor drift)
|
|
221
|
+
while (lines.length < this.ctx.maxLineCount) {
|
|
222
|
+
lines.push('');
|
|
223
|
+
}
|
|
224
|
+
// Render
|
|
225
|
+
terminal.write(lines.join('\n'));
|
|
226
|
+
// Update context
|
|
227
|
+
this.ctx.lineCount = lines.length;
|
|
228
|
+
this.ctx.maxLineCount = Math.max(this.ctx.maxLineCount, lines.length);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Clean up the overlay.
|
|
232
|
+
*/
|
|
233
|
+
cleanup(result) {
|
|
234
|
+
// Call subclass cleanup hook
|
|
235
|
+
this.onCleanup();
|
|
236
|
+
// Clear all lines
|
|
237
|
+
if (this.ctx.maxLineCount > 0) {
|
|
238
|
+
terminal.clearLinesAbove(this.ctx.maxLineCount);
|
|
239
|
+
}
|
|
240
|
+
// Show summary if provided
|
|
241
|
+
const summary = this.getCleanupSummary(result);
|
|
242
|
+
if (summary) {
|
|
243
|
+
terminal.writeLine(summary);
|
|
244
|
+
terminal.writeLine(''); // Blank line for separation
|
|
245
|
+
}
|
|
246
|
+
// Show cursor
|
|
247
|
+
terminal.showCursor();
|
|
248
|
+
// Restore raw mode
|
|
249
|
+
if (!this.ctx.wasRawMode) {
|
|
250
|
+
terminal.disableRawMode();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// =============================================================================
|
|
255
|
+
// Re-exports for convenience
|
|
256
|
+
// =============================================================================
|
|
257
|
+
export { createInlineOverlayContext, isEscapeKey, isCtrlCKey, isEnterKey, isUpArrowKey, isDownArrowKey, isLeftArrowKey, isRightArrowKey, isTabKey, isSpaceKey, isBackspaceKey, isPrintableChar, getPrintableChar, } from './inline-overlay-utils.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key Utilities
|
|
3
|
+
*
|
|
4
|
+
* Re-exports key detection functions from @compilr-dev/ui-core.
|
|
5
|
+
* This provides consistent key detection for all overlays.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { isEscape, isEnter, isNextTab } from './base/key-utils.js';
|
|
9
|
+
*
|
|
10
|
+
* const onData = (data: Buffer): void => {
|
|
11
|
+
* if (isEscape(data)) { cleanup(); return; }
|
|
12
|
+
* if (isNextTab(data)) { state.currentTab++; }
|
|
13
|
+
* };
|
|
14
|
+
*/
|
|
15
|
+
export { KEY, isEscape, isEnter, isTab, isShiftTab, isUpArrow, isDownArrow, isRightArrow, isLeftArrow, isCtrlC, isBackspace, isSpace, isPageUp, isPageDown, isHome, isEnd, isDelete, isCtrlA, isCtrlE, isWordLeft, isWordRight, getNumberKey, isNumberKey, getLetterKey, isVimUp, isVimDown, isVimLeft, isVimRight, isQuit, isN, isD, isE, isS, isSlash, isY, isA, isNavigateUp, isNavigateDown, isNavigateLeft, isNavigateRight, isNextTab, isPrevTab, isClose, isConfirm, isPrintable, getPrintableChar, extractPrintable, parseKey, } from '@compilr-dev/ui-core/utils';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Key Utilities
|
|
3
|
+
*
|
|
4
|
+
* Re-exports key detection functions from @compilr-dev/ui-core.
|
|
5
|
+
* This provides consistent key detection for all overlays.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { isEscape, isEnter, isNextTab } from './base/key-utils.js';
|
|
9
|
+
*
|
|
10
|
+
* const onData = (data: Buffer): void => {
|
|
11
|
+
* if (isEscape(data)) { cleanup(); return; }
|
|
12
|
+
* if (isNextTab(data)) { state.currentTab++; }
|
|
13
|
+
* };
|
|
14
|
+
*/
|
|
15
|
+
// Re-export everything from ui-core
|
|
16
|
+
export {
|
|
17
|
+
// Key constants
|
|
18
|
+
KEY,
|
|
19
|
+
// Basic key detection
|
|
20
|
+
isEscape, isEnter, isTab, isShiftTab, isUpArrow, isDownArrow, isRightArrow, isLeftArrow, isCtrlC, isBackspace, isSpace, isPageUp, isPageDown, isHome, isEnd, isDelete, isCtrlA, isCtrlE, isWordLeft, isWordRight,
|
|
21
|
+
// Number keys
|
|
22
|
+
getNumberKey, isNumberKey,
|
|
23
|
+
// Letter keys
|
|
24
|
+
getLetterKey, isVimUp, isVimDown, isVimLeft, isVimRight, isQuit, isN, isD, isE, isS, isSlash, isY, isA,
|
|
25
|
+
// Composite helpers
|
|
26
|
+
isNavigateUp, isNavigateDown, isNavigateLeft, isNavigateRight, isNextTab, isPrevTab, isClose, isConfirm,
|
|
27
|
+
// Utility
|
|
28
|
+
isPrintable, getPrintableChar, extractPrintable,
|
|
29
|
+
// Key event parsing (bonus from ui-core)
|
|
30
|
+
parseKey, } from '@compilr-dev/ui-core/utils';
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Overlay V2
|
|
3
|
+
*
|
|
4
|
+
* Abstract base class for overlays using the new Overlay interface.
|
|
5
|
+
* Designed to work with TerminalUI's overlay management.
|
|
6
|
+
*
|
|
7
|
+
* Key differences from BaseOverlay:
|
|
8
|
+
* - render() returns OverlayContent, not string[]
|
|
9
|
+
* - handleKey() returns OverlayAction, not void
|
|
10
|
+
* - TerminalUI manages the render loop (not the overlay itself)
|
|
11
|
+
* - Lifecycle via onMount()/onUnmount() instead of show()/close()
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* interface MyState {
|
|
16
|
+
* selectedIndex: number;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* class MyOverlay extends BaseOverlayV2<MyState, string | null> {
|
|
20
|
+
* readonly type = 'inline';
|
|
21
|
+
* readonly id = 'my-overlay';
|
|
22
|
+
*
|
|
23
|
+
* constructor() {
|
|
24
|
+
* super({ selectedIndex: 0 });
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* protected renderContent(context: RenderContext): string[] {
|
|
28
|
+
* return [
|
|
29
|
+
* ...this.renderHeader('My Overlay'),
|
|
30
|
+
* ' Content here...',
|
|
31
|
+
* ...this.renderFooter('↑↓ Navigate · Enter Select · q/Esc Cancel')
|
|
32
|
+
* ];
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* handleKey(key: KeyEvent): OverlayAction<string | null> {
|
|
36
|
+
* if (key.name === 'escape' || key.name === 'q') {
|
|
37
|
+
* return this.close(null);
|
|
38
|
+
* }
|
|
39
|
+
* // ...
|
|
40
|
+
* return this.rerender();
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
import type { Overlay, RenderContext, OverlayContent, OverlayAction, KeyEvent } from '../overlay/index.js';
|
|
46
|
+
import type { ThemeStyleFunctions } from '../../themes/index.js';
|
|
47
|
+
/**
|
|
48
|
+
* Abstract base class for overlays using the new Overlay interface.
|
|
49
|
+
*
|
|
50
|
+
* @template TState - State interface for the overlay
|
|
51
|
+
* @template TResult - Return type when overlay closes
|
|
52
|
+
*/
|
|
53
|
+
export declare abstract class BaseOverlayV2<TState = unknown, TResult = void> implements Overlay<TState, TResult> {
|
|
54
|
+
/** Overlay type - must be set by subclass */
|
|
55
|
+
abstract readonly type: 'fullscreen' | 'inline';
|
|
56
|
+
/** Unique overlay ID - must be set by subclass */
|
|
57
|
+
abstract readonly id: string;
|
|
58
|
+
/** Current overlay state */
|
|
59
|
+
protected state: TState;
|
|
60
|
+
/** Cached styles from last render context */
|
|
61
|
+
protected styles: ThemeStyleFunctions | null;
|
|
62
|
+
/** Cached terminal width from last render context */
|
|
63
|
+
protected termWidth: number;
|
|
64
|
+
/** Minimum height for stable rendering (prevents visual jitter) */
|
|
65
|
+
protected minHeight: number;
|
|
66
|
+
/**
|
|
67
|
+
* Create a new overlay instance.
|
|
68
|
+
*
|
|
69
|
+
* @param initialState - Initial state
|
|
70
|
+
*/
|
|
71
|
+
constructor(initialState: TState);
|
|
72
|
+
/**
|
|
73
|
+
* Get current state.
|
|
74
|
+
*/
|
|
75
|
+
getState(): TState;
|
|
76
|
+
/**
|
|
77
|
+
* Render the overlay.
|
|
78
|
+
* Calls renderContent() and wraps in OverlayContent.
|
|
79
|
+
*/
|
|
80
|
+
render(context: RenderContext): OverlayContent;
|
|
81
|
+
/**
|
|
82
|
+
* Handle key press - must be implemented by subclass.
|
|
83
|
+
* Can be sync or async (for overlays that need to do async work).
|
|
84
|
+
*/
|
|
85
|
+
abstract handleKey(key: KeyEvent): OverlayAction<TResult> | Promise<OverlayAction<TResult>>;
|
|
86
|
+
/**
|
|
87
|
+
* Optional lifecycle hook when overlay mounts.
|
|
88
|
+
*/
|
|
89
|
+
onMount?(): void | Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Optional lifecycle hook when overlay unmounts.
|
|
92
|
+
*/
|
|
93
|
+
onUnmount?(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Optional summary to show after overlay closes.
|
|
96
|
+
*/
|
|
97
|
+
getCloseSummary?(result: TResult): string | null;
|
|
98
|
+
/**
|
|
99
|
+
* Return action to close with result.
|
|
100
|
+
*/
|
|
101
|
+
protected close(result: TResult): OverlayAction<TResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Return action to close as cancelled.
|
|
104
|
+
*/
|
|
105
|
+
protected cancel(): OverlayAction<TResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Return action to re-render.
|
|
108
|
+
*/
|
|
109
|
+
protected rerender(): OverlayAction<TResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Return action for no change.
|
|
112
|
+
*/
|
|
113
|
+
protected noAction(): OverlayAction<TResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Return action to push a sub-overlay.
|
|
116
|
+
*/
|
|
117
|
+
protected push(overlay: Overlay): OverlayAction<TResult>;
|
|
118
|
+
/**
|
|
119
|
+
* Return action to pop back to parent.
|
|
120
|
+
*/
|
|
121
|
+
protected pop(): OverlayAction<TResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Render the overlay content.
|
|
124
|
+
* Must be implemented by subclass.
|
|
125
|
+
*
|
|
126
|
+
* @param context - Render context with width, height, styles
|
|
127
|
+
* @returns Array of lines to render
|
|
128
|
+
*/
|
|
129
|
+
protected abstract renderContent(context: RenderContext): string[];
|
|
130
|
+
/**
|
|
131
|
+
* Get the cached styles (or throw if not available).
|
|
132
|
+
*/
|
|
133
|
+
protected getStyles(): ThemeStyleFunctions;
|
|
134
|
+
/**
|
|
135
|
+
* Render a standard header with border and title.
|
|
136
|
+
*
|
|
137
|
+
* @param title - Main title
|
|
138
|
+
* @param subtitle - Optional subtitle (shown in muted)
|
|
139
|
+
* @returns Array of lines
|
|
140
|
+
*/
|
|
141
|
+
protected renderHeader(title: string, subtitle?: string): string[];
|
|
142
|
+
/**
|
|
143
|
+
* Render a standard footer with hints and border.
|
|
144
|
+
*
|
|
145
|
+
* @param hints - Keyboard hints string (e.g., "↑↓ Navigate · Enter Select")
|
|
146
|
+
* @returns Array of lines
|
|
147
|
+
*/
|
|
148
|
+
protected renderFooter(hints: string): string[];
|
|
149
|
+
/**
|
|
150
|
+
* Render a border line spanning terminal width.
|
|
151
|
+
*/
|
|
152
|
+
protected renderBorder(): string;
|
|
153
|
+
/**
|
|
154
|
+
* Check if key is a close key (escape or 'q').
|
|
155
|
+
*/
|
|
156
|
+
protected isCloseKey(key: KeyEvent): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Check if key is Ctrl+C.
|
|
159
|
+
*/
|
|
160
|
+
protected isInterruptKey(key: KeyEvent): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Check if key is Enter/Return.
|
|
163
|
+
*/
|
|
164
|
+
protected isEnterKey(key: KeyEvent): boolean;
|
|
165
|
+
/**
|
|
166
|
+
* Check if key is up arrow or 'k' (vim).
|
|
167
|
+
*/
|
|
168
|
+
protected isUpKey(key: KeyEvent): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Check if key is down arrow or 'j' (vim).
|
|
171
|
+
*/
|
|
172
|
+
protected isDownKey(key: KeyEvent): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Check if key is left arrow or 'h' (vim).
|
|
175
|
+
*/
|
|
176
|
+
protected isLeftKey(key: KeyEvent): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Check if key is right arrow or 'l' (vim).
|
|
179
|
+
*/
|
|
180
|
+
protected isRightKey(key: KeyEvent): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Check if key is Tab.
|
|
183
|
+
*/
|
|
184
|
+
protected isTabKey(key: KeyEvent): boolean;
|
|
185
|
+
/**
|
|
186
|
+
* Check if key is Shift+Tab.
|
|
187
|
+
*/
|
|
188
|
+
protected isShiftTabKey(key: KeyEvent): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Get number if key is 1-9.
|
|
191
|
+
*/
|
|
192
|
+
protected getNumberKey(key: KeyEvent): number | null;
|
|
193
|
+
}
|