@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,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Renderer
|
|
3
|
+
*
|
|
4
|
+
* Renders subagent status in Claude Code style:
|
|
5
|
+
* - Single agent: bullet with status and last action
|
|
6
|
+
* - Multiple agents: tree structure with all agents listed
|
|
7
|
+
* - Live updates as tools execute
|
|
8
|
+
*
|
|
9
|
+
* Visual style:
|
|
10
|
+
* ● Explore(Find CLI entry points)
|
|
11
|
+
* ⎿ Read 67 lines
|
|
12
|
+
* Found 100 files
|
|
13
|
+
* +3 more tool uses (ctrl+o to expand)
|
|
14
|
+
*
|
|
15
|
+
* ● Running 3 Explore agents... (ctrl+o to expand)
|
|
16
|
+
* ├─ Find state management · 3 tool uses · 20.7k tokens
|
|
17
|
+
* │ ⎿ Bash: List TypeScript files
|
|
18
|
+
* └─ Find utility functions · 5 tool uses · 18.9k tokens
|
|
19
|
+
* ⎿ Read: src/utils/project-memory.ts
|
|
20
|
+
*/
|
|
21
|
+
import { getStyles } from '../themes/index.js';
|
|
22
|
+
import { debugRender } from '../utils/debug-log.js';
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// Formatting Helpers
|
|
25
|
+
// =============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Format duration in human-readable format (e.g., "1m 23s", "45s", "19.2s")
|
|
28
|
+
*/
|
|
29
|
+
function formatDuration(ms) {
|
|
30
|
+
const seconds = ms / 1000;
|
|
31
|
+
if (seconds < 60) {
|
|
32
|
+
return seconds < 10 ? `${seconds.toFixed(1)}s` : `${String(Math.floor(seconds))}s`;
|
|
33
|
+
}
|
|
34
|
+
const minutes = Math.floor(seconds / 60);
|
|
35
|
+
const remainingSeconds = Math.floor(seconds % 60);
|
|
36
|
+
return `${String(minutes)}m ${String(remainingSeconds)}s`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Format token count (e.g., "18.1k", "500")
|
|
40
|
+
*/
|
|
41
|
+
function formatTokens(tokens) {
|
|
42
|
+
if (tokens >= 1000) {
|
|
43
|
+
return `${(tokens / 1000).toFixed(1)}k`;
|
|
44
|
+
}
|
|
45
|
+
return tokens.toString();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Capitalize first letter
|
|
49
|
+
*/
|
|
50
|
+
function capitalize(str) {
|
|
51
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Truncate string to max length with ellipsis
|
|
55
|
+
*/
|
|
56
|
+
function truncate(str, maxLen) {
|
|
57
|
+
if (str.length <= maxLen)
|
|
58
|
+
return str;
|
|
59
|
+
return str.slice(0, maxLen - 1) + '…';
|
|
60
|
+
}
|
|
61
|
+
// =============================================================================
|
|
62
|
+
// Tree Characters (Unicode box drawing)
|
|
63
|
+
// =============================================================================
|
|
64
|
+
const TREE = {
|
|
65
|
+
branch: '├─', // Non-last item
|
|
66
|
+
end: '└─', // Last item
|
|
67
|
+
vertical: '│', // Vertical continuation
|
|
68
|
+
result: '⎿', // Result/action marker
|
|
69
|
+
bullet: '●', // Header bullet
|
|
70
|
+
};
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// Subagent Renderer Class
|
|
73
|
+
// =============================================================================
|
|
74
|
+
export class SubagentRenderer {
|
|
75
|
+
agents = new Map();
|
|
76
|
+
isExpanded = false;
|
|
77
|
+
maxDetailLines;
|
|
78
|
+
showTokens;
|
|
79
|
+
// Callback for when state changes (trigger re-render)
|
|
80
|
+
onUpdate = null;
|
|
81
|
+
constructor(options = {}) {
|
|
82
|
+
this.maxDetailLines = options.maxDetailLines ?? 1;
|
|
83
|
+
this.showTokens = options.showTokens ?? true;
|
|
84
|
+
}
|
|
85
|
+
// ===========================================================================
|
|
86
|
+
// Public API
|
|
87
|
+
// ===========================================================================
|
|
88
|
+
/**
|
|
89
|
+
* Called when a subagent starts
|
|
90
|
+
*/
|
|
91
|
+
onSubagentStart(id, type, description) {
|
|
92
|
+
this.agents.set(id, {
|
|
93
|
+
id,
|
|
94
|
+
type,
|
|
95
|
+
description: truncate(description, 50),
|
|
96
|
+
status: 'running',
|
|
97
|
+
toolCount: 0,
|
|
98
|
+
tokenCount: 0,
|
|
99
|
+
lastAction: '',
|
|
100
|
+
lastActionDetails: [],
|
|
101
|
+
startTime: Date.now(),
|
|
102
|
+
});
|
|
103
|
+
this.triggerUpdate();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Called when a subagent uses a tool
|
|
107
|
+
*/
|
|
108
|
+
onToolUse(agentId, toolName, summary) {
|
|
109
|
+
const agent = this.agents.get(agentId);
|
|
110
|
+
if (!agent)
|
|
111
|
+
return;
|
|
112
|
+
agent.toolCount++;
|
|
113
|
+
agent.lastAction = summary
|
|
114
|
+
? `${capitalize(toolName)}: ${truncate(summary, 40)}`
|
|
115
|
+
: capitalize(toolName);
|
|
116
|
+
this.triggerUpdate();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Called when a subagent completes
|
|
120
|
+
*/
|
|
121
|
+
onSubagentEnd(id, success, tokenCount, error) {
|
|
122
|
+
const agent = this.agents.get(id);
|
|
123
|
+
if (!agent)
|
|
124
|
+
return;
|
|
125
|
+
agent.status = success ? 'done' : 'error';
|
|
126
|
+
agent.tokenCount = tokenCount;
|
|
127
|
+
agent.endTime = Date.now();
|
|
128
|
+
agent.error = error;
|
|
129
|
+
agent.lastAction = success ? 'Done' : `Error: ${error || 'Unknown'}`;
|
|
130
|
+
this.triggerUpdate();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Toggle expanded/collapsed view (Ctrl+O)
|
|
134
|
+
*/
|
|
135
|
+
toggleExpand() {
|
|
136
|
+
this.isExpanded = !this.isExpanded;
|
|
137
|
+
this.triggerUpdate();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Check if there are any active subagents
|
|
141
|
+
*/
|
|
142
|
+
hasActiveSubagents() {
|
|
143
|
+
return Array.from(this.agents.values()).some(a => a.status === 'running');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Check if there are any subagents to display
|
|
147
|
+
*/
|
|
148
|
+
hasSubagents() {
|
|
149
|
+
return this.agents.size > 0;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get count of agents by status
|
|
153
|
+
*/
|
|
154
|
+
getCounts() {
|
|
155
|
+
let running = 0, done = 0, error = 0;
|
|
156
|
+
for (const agent of this.agents.values()) {
|
|
157
|
+
if (agent.status === 'running')
|
|
158
|
+
running++;
|
|
159
|
+
else if (agent.status === 'done')
|
|
160
|
+
done++;
|
|
161
|
+
else
|
|
162
|
+
error++;
|
|
163
|
+
}
|
|
164
|
+
return { running, done, error, total: this.agents.size };
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get the last agent's stats (for persisting to scrolling zone)
|
|
168
|
+
* Returns null if no agents tracked
|
|
169
|
+
*/
|
|
170
|
+
getLastAgentStats() {
|
|
171
|
+
const agents = Array.from(this.agents.values());
|
|
172
|
+
if (agents.length === 0)
|
|
173
|
+
return null;
|
|
174
|
+
// Get the most recently added agent
|
|
175
|
+
const agent = agents[agents.length - 1];
|
|
176
|
+
const endTime = agent.endTime ?? Date.now();
|
|
177
|
+
const durationMs = endTime - agent.startTime;
|
|
178
|
+
return {
|
|
179
|
+
type: agent.type,
|
|
180
|
+
description: agent.description,
|
|
181
|
+
toolCount: agent.toolCount,
|
|
182
|
+
tokenCount: agent.tokenCount,
|
|
183
|
+
durationMs,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Clear all agents (after rendering final output to scrolling zone)
|
|
188
|
+
*/
|
|
189
|
+
clear() {
|
|
190
|
+
this.agents.clear();
|
|
191
|
+
this.isExpanded = false;
|
|
192
|
+
this.triggerUpdate();
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Set callback for state updates
|
|
196
|
+
*/
|
|
197
|
+
setUpdateCallback(callback) {
|
|
198
|
+
this.onUpdate = callback;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Render the subagent zone - returns array of lines
|
|
202
|
+
* Only renders running agents - completed agents are shown via printSubagentResponse
|
|
203
|
+
*/
|
|
204
|
+
render() {
|
|
205
|
+
if (this.agents.size === 0) {
|
|
206
|
+
debugRender('Subagent:render', 'no agents, returning []');
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
// Filter to only running agents - completed agents are shown via printSubagentResponse
|
|
210
|
+
const runningAgents = Array.from(this.agents.values()).filter(a => a.status === 'running');
|
|
211
|
+
const allStatuses = Array.from(this.agents.values()).map(a => `${a.id}:${a.status}`);
|
|
212
|
+
debugRender('Subagent:render', `total=${String(this.agents.size)} running=${String(runningAgents.length)} statuses=[${allStatuses.join(',')}]`);
|
|
213
|
+
if (runningAgents.length === 0) {
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
const s = getStyles();
|
|
217
|
+
// Single agent - simpler display
|
|
218
|
+
if (runningAgents.length === 1) {
|
|
219
|
+
const lines = this.renderSingleAgent(runningAgents[0], s);
|
|
220
|
+
debugRender('Subagent:render', `single agent, returning ${String(lines.length)} lines`);
|
|
221
|
+
return lines;
|
|
222
|
+
}
|
|
223
|
+
// Multiple agents - tree display
|
|
224
|
+
const counts = this.getCounts();
|
|
225
|
+
const lines = this.renderMultipleAgents(runningAgents, counts, s);
|
|
226
|
+
debugRender('Subagent:render', `multiple agents, returning ${String(lines.length)} lines`);
|
|
227
|
+
return lines;
|
|
228
|
+
}
|
|
229
|
+
// ===========================================================================
|
|
230
|
+
// Private Methods
|
|
231
|
+
// ===========================================================================
|
|
232
|
+
triggerUpdate() {
|
|
233
|
+
if (this.onUpdate) {
|
|
234
|
+
this.onUpdate();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Render single agent display
|
|
239
|
+
*/
|
|
240
|
+
renderSingleAgent(agent, s) {
|
|
241
|
+
const lines = [];
|
|
242
|
+
const typeLabel = capitalize(agent.type);
|
|
243
|
+
// Header line: ● Explore(Find CLI entry points)
|
|
244
|
+
const header = `${TREE.bullet} ${typeLabel}(${agent.description})`;
|
|
245
|
+
if (agent.status === 'done') {
|
|
246
|
+
// Completed: show stats
|
|
247
|
+
const duration = formatDuration((agent.endTime ?? Date.now()) - agent.startTime);
|
|
248
|
+
const stats = this.showTokens
|
|
249
|
+
? `${String(agent.toolCount)} tool uses · ${formatTokens(agent.tokenCount)} tokens · ${duration}`
|
|
250
|
+
: `${String(agent.toolCount)} tool uses · ${duration}`;
|
|
251
|
+
lines.push(s.primary(header));
|
|
252
|
+
lines.push(s.muted(` ${TREE.result} Done (${stats})`));
|
|
253
|
+
}
|
|
254
|
+
else if (agent.status === 'error') {
|
|
255
|
+
lines.push(s.error(header));
|
|
256
|
+
lines.push(s.error(` ${TREE.result} ${agent.lastAction}`));
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
// Running: show last action
|
|
260
|
+
lines.push(s.primary(header));
|
|
261
|
+
if (agent.lastAction) {
|
|
262
|
+
lines.push(s.muted(` ${TREE.result} ${agent.lastAction}`));
|
|
263
|
+
}
|
|
264
|
+
if (agent.toolCount > 1) {
|
|
265
|
+
lines.push(s.muted(` +${String(agent.toolCount - 1)} more tool uses (ctrl+o to expand)`));
|
|
266
|
+
}
|
|
267
|
+
lines.push(s.muted(' ctrl+b to run in background'));
|
|
268
|
+
}
|
|
269
|
+
return lines;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Render multiple agents in tree display
|
|
273
|
+
*/
|
|
274
|
+
renderMultipleAgents(agents, counts, s) {
|
|
275
|
+
const lines = [];
|
|
276
|
+
// Header line
|
|
277
|
+
let headerText;
|
|
278
|
+
if (counts.running > 0 && counts.done > 0) {
|
|
279
|
+
// Mixed states
|
|
280
|
+
headerText = `${TREE.bullet} ${String(counts.total)} agents (${String(counts.running)} running, ${String(counts.done)} done)`;
|
|
281
|
+
}
|
|
282
|
+
else if (counts.running > 0) {
|
|
283
|
+
// All running
|
|
284
|
+
const typeLabel = this.getCommonTypeLabel(agents);
|
|
285
|
+
headerText = `${TREE.bullet} Running ${String(counts.total)} ${typeLabel} agents… (ctrl+o to expand)`;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
// All done
|
|
289
|
+
const typeLabel = this.getCommonTypeLabel(agents);
|
|
290
|
+
headerText = `${TREE.bullet} ${String(counts.total)} ${typeLabel} agents finished (ctrl+o to expand)`;
|
|
291
|
+
}
|
|
292
|
+
lines.push(s.primary(headerText));
|
|
293
|
+
// Render each agent in tree
|
|
294
|
+
for (let i = 0; i < agents.length; i++) {
|
|
295
|
+
const agent = agents[i];
|
|
296
|
+
const isLast = i === agents.length - 1;
|
|
297
|
+
const branch = isLast ? TREE.end : TREE.branch;
|
|
298
|
+
const continuation = isLast ? ' ' : `${TREE.vertical} `;
|
|
299
|
+
// Agent line: ├─ Find state management · 3 tool uses · 20.7k tokens
|
|
300
|
+
const toolCountStr = String(agent.toolCount);
|
|
301
|
+
const stats = this.showTokens
|
|
302
|
+
? `${toolCountStr} tool ${agent.toolCount === 1 ? 'use' : 'uses'} · ${formatTokens(agent.tokenCount)} tokens`
|
|
303
|
+
: `${toolCountStr} tool ${agent.toolCount === 1 ? 'use' : 'uses'}`;
|
|
304
|
+
const agentLine = ` ${branch} ${agent.description} · ${stats}`;
|
|
305
|
+
if (agent.status === 'error') {
|
|
306
|
+
lines.push(s.error(agentLine));
|
|
307
|
+
}
|
|
308
|
+
else if (agent.status === 'done') {
|
|
309
|
+
lines.push(s.muted(agentLine));
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
lines.push(agentLine);
|
|
313
|
+
}
|
|
314
|
+
// Last action line: │ ⎿ Read: src/auth.ts
|
|
315
|
+
const actionLine = ` ${continuation}${TREE.result} ${agent.lastAction || (agent.status === 'done' ? 'Done' : 'Starting...')}`;
|
|
316
|
+
lines.push(s.muted(actionLine));
|
|
317
|
+
}
|
|
318
|
+
// Footer hint for running agents
|
|
319
|
+
if (counts.running > 0) {
|
|
320
|
+
lines.push(s.muted(' ctrl+b to run in background'));
|
|
321
|
+
}
|
|
322
|
+
return lines;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Get common type label if all agents are same type, otherwise "mixed"
|
|
326
|
+
*/
|
|
327
|
+
getCommonTypeLabel(agents) {
|
|
328
|
+
if (agents.length === 0)
|
|
329
|
+
return '';
|
|
330
|
+
const firstType = agents[0].type;
|
|
331
|
+
const allSame = agents.every(a => a.type === firstType);
|
|
332
|
+
return allSame ? capitalize(firstType) : '';
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal ANSI Escape Codes
|
|
3
|
+
*
|
|
4
|
+
* Constants and helper functions for ANSI escape sequences.
|
|
5
|
+
* Used by TerminalRenderer for cursor movement, scroll regions, clearing, etc.
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://en.wikipedia.org/wiki/ANSI_escape_code
|
|
8
|
+
*/
|
|
9
|
+
/** Control Sequence Introducer */
|
|
10
|
+
export declare const CSI = "\u001B[";
|
|
11
|
+
/** Operating System Command (for title, etc.) */
|
|
12
|
+
export declare const OSC = "\u001B]";
|
|
13
|
+
/** String Terminator */
|
|
14
|
+
export declare const ST = "\u0007";
|
|
15
|
+
/** Move cursor up N lines */
|
|
16
|
+
export declare const cursorUp: (n: number) => string;
|
|
17
|
+
/** Move cursor down N lines */
|
|
18
|
+
export declare const cursorDown: (n: number) => string;
|
|
19
|
+
/** Move cursor forward (right) N columns */
|
|
20
|
+
export declare const cursorForward: (n: number) => string;
|
|
21
|
+
/** Move cursor back (left) N columns */
|
|
22
|
+
export declare const cursorBack: (n: number) => string;
|
|
23
|
+
/** Move cursor to specific row and column (1-indexed) */
|
|
24
|
+
export declare const cursorTo: (row: number, col: number) => string;
|
|
25
|
+
/** Move cursor to beginning of line */
|
|
26
|
+
export declare const cursorToLineStart = "\r";
|
|
27
|
+
/** Move cursor to specific column (1-indexed) */
|
|
28
|
+
export declare const cursorToColumn: (col: number) => string;
|
|
29
|
+
/** Save cursor position */
|
|
30
|
+
export declare const saveCursor = "\u001B[s";
|
|
31
|
+
/** Restore cursor position */
|
|
32
|
+
export declare const restoreCursor = "\u001B[u";
|
|
33
|
+
/** Hide cursor */
|
|
34
|
+
export declare const hideCursor = "\u001B[?25l";
|
|
35
|
+
/** Show cursor */
|
|
36
|
+
export declare const showCursor = "\u001B[?25h";
|
|
37
|
+
/**
|
|
38
|
+
* Set scroll region (DECSTBM - DEC Set Top and Bottom Margins)
|
|
39
|
+
*
|
|
40
|
+
* @param top - Top row of scroll region (1-indexed, inclusive)
|
|
41
|
+
* @param bottom - Bottom row of scroll region (1-indexed, inclusive)
|
|
42
|
+
*
|
|
43
|
+
* When set, scrolling only affects rows within this region.
|
|
44
|
+
* Text printed in the scroll region that would overflow scrolls the region.
|
|
45
|
+
* Content outside the region is not affected.
|
|
46
|
+
*/
|
|
47
|
+
export declare const setScrollRegion: (top: number, bottom: number) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Reset scroll region to full screen
|
|
50
|
+
*
|
|
51
|
+
* Removes any scroll region restrictions.
|
|
52
|
+
* Scrolling affects the entire terminal again.
|
|
53
|
+
*/
|
|
54
|
+
export declare const resetScrollRegion = "\u001B[r";
|
|
55
|
+
/** Clear from cursor to end of line */
|
|
56
|
+
export declare const clearToEndOfLine = "\u001B[K";
|
|
57
|
+
/** Clear from cursor to start of line */
|
|
58
|
+
export declare const clearToStartOfLine = "\u001B[1K";
|
|
59
|
+
/** Clear entire line */
|
|
60
|
+
export declare const clearLine = "\u001B[2K";
|
|
61
|
+
/** Clear from cursor to end of screen */
|
|
62
|
+
export declare const clearToEndOfScreen = "\u001B[J";
|
|
63
|
+
/** Clear from cursor to start of screen */
|
|
64
|
+
export declare const clearToStartOfScreen = "\u001B[1J";
|
|
65
|
+
/** Clear entire screen (cursor position unchanged) */
|
|
66
|
+
export declare const clearScreen = "\u001B[2J";
|
|
67
|
+
/** Clear entire screen and move cursor to top-left */
|
|
68
|
+
export declare const clearScreenAndHome = "\u001B[2J\u001B[H";
|
|
69
|
+
/**
|
|
70
|
+
* Enter alternate screen buffer.
|
|
71
|
+
* Content shown here doesn't go to main scrollback.
|
|
72
|
+
* Used for modal UIs like menus, editors.
|
|
73
|
+
*/
|
|
74
|
+
export declare const enterAlternateScreen = "\u001B[?1049h";
|
|
75
|
+
/**
|
|
76
|
+
* Leave alternate screen buffer.
|
|
77
|
+
* Returns to main screen (previous content restored).
|
|
78
|
+
*/
|
|
79
|
+
export declare const leaveAlternateScreen = "\u001B[?1049l";
|
|
80
|
+
/** Disable all mouse tracking modes */
|
|
81
|
+
export declare const disableMouseTracking = "\u001B[?1000l\u001B[?1002l\u001B[?1003l";
|
|
82
|
+
/** Set terminal window title */
|
|
83
|
+
export declare const setTitle: (title: string) => string;
|
|
84
|
+
/** Ring terminal bell */
|
|
85
|
+
export declare const bell = "\u0007";
|
|
86
|
+
/**
|
|
87
|
+
* Position cursor at a specific location and clear to end of screen
|
|
88
|
+
* Useful for redrawing from a known position
|
|
89
|
+
*/
|
|
90
|
+
export declare const positionAndClear: (row: number, col: number) => string;
|
|
91
|
+
/**
|
|
92
|
+
* Move to row 1, column 1 (home position)
|
|
93
|
+
*/
|
|
94
|
+
export declare const cursorHome = "\u001B[H";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal ANSI Escape Codes
|
|
3
|
+
*
|
|
4
|
+
* Constants and helper functions for ANSI escape sequences.
|
|
5
|
+
* Used by TerminalRenderer for cursor movement, scroll regions, clearing, etc.
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://en.wikipedia.org/wiki/ANSI_escape_code
|
|
8
|
+
*/
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Escape Sequence Base
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/** Control Sequence Introducer */
|
|
13
|
+
export const CSI = '\x1b[';
|
|
14
|
+
/** Operating System Command (for title, etc.) */
|
|
15
|
+
export const OSC = '\x1b]';
|
|
16
|
+
/** String Terminator */
|
|
17
|
+
export const ST = '\x07';
|
|
18
|
+
// =============================================================================
|
|
19
|
+
// Cursor Movement
|
|
20
|
+
// =============================================================================
|
|
21
|
+
/** Move cursor up N lines */
|
|
22
|
+
export const cursorUp = (n) => (n > 0 ? `${CSI}${String(n)}A` : '');
|
|
23
|
+
/** Move cursor down N lines */
|
|
24
|
+
export const cursorDown = (n) => (n > 0 ? `${CSI}${String(n)}B` : '');
|
|
25
|
+
/** Move cursor forward (right) N columns */
|
|
26
|
+
export const cursorForward = (n) => (n > 0 ? `${CSI}${String(n)}C` : '');
|
|
27
|
+
/** Move cursor back (left) N columns */
|
|
28
|
+
export const cursorBack = (n) => (n > 0 ? `${CSI}${String(n)}D` : '');
|
|
29
|
+
/** Move cursor to specific row and column (1-indexed) */
|
|
30
|
+
export const cursorTo = (row, col) => `${CSI}${String(row)};${String(col)}H`;
|
|
31
|
+
/** Move cursor to beginning of line */
|
|
32
|
+
export const cursorToLineStart = '\r';
|
|
33
|
+
/** Move cursor to specific column (1-indexed) */
|
|
34
|
+
export const cursorToColumn = (col) => `${CSI}${String(col)}G`;
|
|
35
|
+
/** Save cursor position */
|
|
36
|
+
export const saveCursor = `${CSI}s`;
|
|
37
|
+
/** Restore cursor position */
|
|
38
|
+
export const restoreCursor = `${CSI}u`;
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// Cursor Visibility
|
|
41
|
+
// =============================================================================
|
|
42
|
+
/** Hide cursor */
|
|
43
|
+
export const hideCursor = `${CSI}?25l`;
|
|
44
|
+
/** Show cursor */
|
|
45
|
+
export const showCursor = `${CSI}?25h`;
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// Scroll Regions
|
|
48
|
+
// =============================================================================
|
|
49
|
+
/**
|
|
50
|
+
* Set scroll region (DECSTBM - DEC Set Top and Bottom Margins)
|
|
51
|
+
*
|
|
52
|
+
* @param top - Top row of scroll region (1-indexed, inclusive)
|
|
53
|
+
* @param bottom - Bottom row of scroll region (1-indexed, inclusive)
|
|
54
|
+
*
|
|
55
|
+
* When set, scrolling only affects rows within this region.
|
|
56
|
+
* Text printed in the scroll region that would overflow scrolls the region.
|
|
57
|
+
* Content outside the region is not affected.
|
|
58
|
+
*/
|
|
59
|
+
export const setScrollRegion = (top, bottom) => `${CSI}${String(top)};${String(bottom)}r`;
|
|
60
|
+
/**
|
|
61
|
+
* Reset scroll region to full screen
|
|
62
|
+
*
|
|
63
|
+
* Removes any scroll region restrictions.
|
|
64
|
+
* Scrolling affects the entire terminal again.
|
|
65
|
+
*/
|
|
66
|
+
export const resetScrollRegion = `${CSI}r`;
|
|
67
|
+
// =============================================================================
|
|
68
|
+
// Clearing
|
|
69
|
+
// =============================================================================
|
|
70
|
+
/** Clear from cursor to end of line */
|
|
71
|
+
export const clearToEndOfLine = `${CSI}K`;
|
|
72
|
+
/** Clear from cursor to start of line */
|
|
73
|
+
export const clearToStartOfLine = `${CSI}1K`;
|
|
74
|
+
/** Clear entire line */
|
|
75
|
+
export const clearLine = `${CSI}2K`;
|
|
76
|
+
/** Clear from cursor to end of screen */
|
|
77
|
+
export const clearToEndOfScreen = `${CSI}J`;
|
|
78
|
+
/** Clear from cursor to start of screen */
|
|
79
|
+
export const clearToStartOfScreen = `${CSI}1J`;
|
|
80
|
+
/** Clear entire screen (cursor position unchanged) */
|
|
81
|
+
export const clearScreen = `${CSI}2J`;
|
|
82
|
+
/** Clear entire screen and move cursor to top-left */
|
|
83
|
+
export const clearScreenAndHome = `${CSI}2J${CSI}H`;
|
|
84
|
+
// =============================================================================
|
|
85
|
+
// Alternate Screen Buffer
|
|
86
|
+
// =============================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Enter alternate screen buffer.
|
|
89
|
+
* Content shown here doesn't go to main scrollback.
|
|
90
|
+
* Used for modal UIs like menus, editors.
|
|
91
|
+
*/
|
|
92
|
+
export const enterAlternateScreen = `${CSI}?1049h`;
|
|
93
|
+
/**
|
|
94
|
+
* Leave alternate screen buffer.
|
|
95
|
+
* Returns to main screen (previous content restored).
|
|
96
|
+
*/
|
|
97
|
+
export const leaveAlternateScreen = `${CSI}?1049l`;
|
|
98
|
+
// =============================================================================
|
|
99
|
+
// Mouse Tracking (disabled for CLI)
|
|
100
|
+
// =============================================================================
|
|
101
|
+
/** Disable all mouse tracking modes */
|
|
102
|
+
export const disableMouseTracking = `${CSI}?1000l${CSI}?1002l${CSI}?1003l`;
|
|
103
|
+
// =============================================================================
|
|
104
|
+
// Terminal Title
|
|
105
|
+
// =============================================================================
|
|
106
|
+
/** Set terminal window title */
|
|
107
|
+
export const setTitle = (title) => `${OSC}0;${title}${ST}`;
|
|
108
|
+
// =============================================================================
|
|
109
|
+
// Bell
|
|
110
|
+
// =============================================================================
|
|
111
|
+
/** Ring terminal bell */
|
|
112
|
+
export const bell = '\x07';
|
|
113
|
+
// =============================================================================
|
|
114
|
+
// Composite Helpers
|
|
115
|
+
// =============================================================================
|
|
116
|
+
/**
|
|
117
|
+
* Position cursor at a specific location and clear to end of screen
|
|
118
|
+
* Useful for redrawing from a known position
|
|
119
|
+
*/
|
|
120
|
+
export const positionAndClear = (row, col) => `${cursorTo(row, col)}${clearToEndOfScreen}`;
|
|
121
|
+
/**
|
|
122
|
+
* Move to row 1, column 1 (home position)
|
|
123
|
+
*/
|
|
124
|
+
export const cursorHome = `${CSI}H`;
|