@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
package/dist/ui/overlays.js
CHANGED
|
@@ -9,451 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import chalk from 'chalk';
|
|
11
11
|
import * as terminal from './terminal.js';
|
|
12
|
-
import { getHelpCommands, getCommandByIndex } from '../commands.js';
|
|
13
|
-
import { getCustomCommandRegistry } from '../commands/index.js';
|
|
14
12
|
import { getStyles } from '../themes/index.js';
|
|
15
|
-
// =============================================================================
|
|
16
|
-
// Version
|
|
17
|
-
// =============================================================================
|
|
18
|
-
const VERSION = 'compilr.dev/agent';
|
|
19
|
-
const TABS = [
|
|
20
|
-
{ id: 'general', label: 'general' },
|
|
21
|
-
{ id: 'commands', label: 'commands' },
|
|
22
|
-
{ id: 'custom-commands', label: 'custom-commands' },
|
|
23
|
-
];
|
|
24
|
-
// Use central command registry
|
|
25
|
-
const COMMANDS = getHelpCommands();
|
|
26
|
-
const MAX_VISIBLE_COMMANDS = 10; // Maximum commands to show at once
|
|
27
|
-
function renderHelpHeader(state) {
|
|
28
|
-
const s = getStyles();
|
|
29
|
-
const lines = [];
|
|
30
|
-
const cols = terminal.getTerminalWidth();
|
|
31
|
-
lines.push(s.muted('─'.repeat(Math.max(1, cols - 1))));
|
|
32
|
-
let tabLine = ' ' + s.primaryBold(VERSION) + ' ';
|
|
33
|
-
for (let i = 0; i < TABS.length; i++) {
|
|
34
|
-
const tab = TABS[i];
|
|
35
|
-
if (i === state.currentTab) {
|
|
36
|
-
tabLine += s.selected(` ${tab.label} `) + ' ';
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
tabLine += s.muted(` ${tab.label} `) + ' ';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
tabLine += s.muted('(tab to cycle)');
|
|
43
|
-
lines.push(tabLine);
|
|
44
|
-
lines.push('');
|
|
45
|
-
return lines;
|
|
46
|
-
}
|
|
47
|
-
function renderGeneralTab() {
|
|
48
|
-
const s = getStyles();
|
|
49
|
-
const lines = [];
|
|
50
|
-
lines.push(' An AI assistant that understands your codebase, makes edits with your permission, and executes commands — right from your terminal.');
|
|
51
|
-
lines.push('');
|
|
52
|
-
lines.push(chalk.bold(' Shortcuts'));
|
|
53
|
-
const shortcuts = [
|
|
54
|
-
['/ for commands', 'Enter to submit'],
|
|
55
|
-
['↑↓ for history', 'Esc to cancel'],
|
|
56
|
-
['Tab to autocomplete', 'Ctrl+C to exit'],
|
|
57
|
-
];
|
|
58
|
-
for (const [left, right] of shortcuts) {
|
|
59
|
-
lines.push(' ' + s.primary(left.padEnd(25)) + s.primary(right));
|
|
60
|
-
}
|
|
61
|
-
lines.push('');
|
|
62
|
-
lines.push(chalk.bold(' Features'));
|
|
63
|
-
lines.push(' ' + s.muted('• Multi-LLM support (Claude, OpenAI, Gemini, Ollama)'));
|
|
64
|
-
lines.push(' ' + s.muted('• Tool execution with permission prompts'));
|
|
65
|
-
lines.push(' ' + s.muted('• Context management and compaction'));
|
|
66
|
-
lines.push(' ' + s.muted('• Slash command autocomplete'));
|
|
67
|
-
lines.push(''); // Padding to match commands tab height
|
|
68
|
-
lines.push('');
|
|
69
|
-
return lines;
|
|
70
|
-
}
|
|
71
|
-
function renderCommandsTab(state) {
|
|
72
|
-
const s = getStyles();
|
|
73
|
-
const lines = [];
|
|
74
|
-
const totalCommands = COMMANDS.length;
|
|
75
|
-
const visibleCount = Math.min(MAX_VISIBLE_COMMANDS, totalCommands);
|
|
76
|
-
lines.push(chalk.bold(' Browse available commands:') + s.muted(` (${String(totalCommands)} total)`));
|
|
77
|
-
lines.push('');
|
|
78
|
-
// Show up arrow if can scroll up
|
|
79
|
-
if (state.scrollOffset > 0) {
|
|
80
|
-
lines.push(s.muted(' ↑ more above'));
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
lines.push('');
|
|
84
|
-
}
|
|
85
|
-
const visibleCommands = COMMANDS.slice(state.scrollOffset, state.scrollOffset + visibleCount);
|
|
86
|
-
for (let i = 0; i < visibleCommands.length; i++) {
|
|
87
|
-
const cmd = visibleCommands[i];
|
|
88
|
-
const globalIndex = state.scrollOffset + i;
|
|
89
|
-
const isSelected = globalIndex === state.selectedCommand;
|
|
90
|
-
const prefix = isSelected ? s.primary(' ❯ ') : ' ';
|
|
91
|
-
const name = isSelected ? s.primary(cmd.name.padEnd(20)) : s.muted(cmd.name.padEnd(20));
|
|
92
|
-
const desc = s.muted(cmd.description);
|
|
93
|
-
lines.push(prefix + name + desc);
|
|
94
|
-
}
|
|
95
|
-
// Pad to fixed height when fewer commands than max
|
|
96
|
-
for (let i = visibleCommands.length; i < visibleCount; i++) {
|
|
97
|
-
lines.push('');
|
|
98
|
-
}
|
|
99
|
-
// Show down arrow if can scroll down
|
|
100
|
-
if (state.scrollOffset + visibleCount < totalCommands) {
|
|
101
|
-
lines.push(s.muted(' ↓ more below'));
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
lines.push('');
|
|
105
|
-
}
|
|
106
|
-
return lines;
|
|
107
|
-
}
|
|
108
|
-
function renderCustomCommandsTab(state) {
|
|
109
|
-
const s = getStyles();
|
|
110
|
-
const lines = [];
|
|
111
|
-
const registry = getCustomCommandRegistry();
|
|
112
|
-
const commands = registry.getAll();
|
|
113
|
-
const totalCommands = commands.length;
|
|
114
|
-
const visibleCount = Math.min(MAX_VISIBLE_COMMANDS, totalCommands);
|
|
115
|
-
lines.push(chalk.bold(' Custom commands:') + (totalCommands > 0 ? s.muted(` (${String(totalCommands)} total)`) : ''));
|
|
116
|
-
lines.push('');
|
|
117
|
-
if (commands.length === 0) {
|
|
118
|
-
lines.push(s.muted(' No custom commands found'));
|
|
119
|
-
lines.push('');
|
|
120
|
-
lines.push(s.muted(' Create commands with /commands'));
|
|
121
|
-
lines.push(s.muted(' or add .md files to:'));
|
|
122
|
-
lines.push(s.muted(` ${registry.getProjectDir()}/`));
|
|
123
|
-
lines.push(s.muted(` ${registry.getUserDir()}/`));
|
|
124
|
-
// Pad to match expected height
|
|
125
|
-
for (let i = 0; i < 6; i++) {
|
|
126
|
-
lines.push('');
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
// Show up arrow if can scroll up
|
|
131
|
-
if (state.customScrollOffset > 0) {
|
|
132
|
-
lines.push(s.muted(' ↑ more above'));
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
lines.push('');
|
|
136
|
-
}
|
|
137
|
-
const visibleCommands = commands.slice(state.customScrollOffset, state.customScrollOffset + visibleCount);
|
|
138
|
-
for (let i = 0; i < visibleCommands.length; i++) {
|
|
139
|
-
const cmd = visibleCommands[i];
|
|
140
|
-
const globalIndex = state.customScrollOffset + i;
|
|
141
|
-
const isSelected = globalIndex === state.selectedCustomCommand;
|
|
142
|
-
const prefix = isSelected ? s.primary(' ❯ ') : ' ';
|
|
143
|
-
const name = `/${cmd.name}`.padEnd(18);
|
|
144
|
-
const desc = cmd.description.slice(0, 35) + (cmd.description.length > 35 ? '...' : '');
|
|
145
|
-
const location = ` (${cmd.location})`;
|
|
146
|
-
if (isSelected) {
|
|
147
|
-
lines.push(prefix + s.primary(name) + s.muted(desc) + s.muted(location));
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
lines.push(prefix + s.muted(name + desc + location));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
// Pad to fixed height when fewer commands than max
|
|
154
|
-
for (let i = visibleCommands.length; i < visibleCount; i++) {
|
|
155
|
-
lines.push('');
|
|
156
|
-
}
|
|
157
|
-
// Show down arrow if can scroll down
|
|
158
|
-
if (state.customScrollOffset + visibleCount < totalCommands) {
|
|
159
|
-
lines.push(s.muted(' ↓ more below'));
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
lines.push('');
|
|
163
|
-
}
|
|
164
|
-
lines.push('');
|
|
165
|
-
lines.push(s.muted(' Use /commands to manage custom commands'));
|
|
166
|
-
}
|
|
167
|
-
return lines;
|
|
168
|
-
}
|
|
169
|
-
function renderCommandDetail(commandIndex) {
|
|
170
|
-
const s = getStyles();
|
|
171
|
-
const lines = [];
|
|
172
|
-
const cols = terminal.getTerminalWidth();
|
|
173
|
-
const maxLineWidth = cols - 2; // Leave margin for safety
|
|
174
|
-
const cmd = getCommandByIndex(commandIndex);
|
|
175
|
-
// Helper to truncate a line to prevent wrapping
|
|
176
|
-
const truncate = (line, max = maxLineWidth) => {
|
|
177
|
-
// Strip ANSI codes for length calculation
|
|
178
|
-
// eslint-disable-next-line no-control-regex
|
|
179
|
-
const stripped = line.replace(/\x1b\[[0-9;]*m/g, '');
|
|
180
|
-
if (stripped.length <= max)
|
|
181
|
-
return line;
|
|
182
|
-
// Find where to cut (accounting for ANSI codes)
|
|
183
|
-
let visibleLen = 0;
|
|
184
|
-
let cutIndex = 0;
|
|
185
|
-
for (let i = 0; i < line.length; i++) {
|
|
186
|
-
if (line[i] === '\x1b') {
|
|
187
|
-
// Skip ANSI sequence
|
|
188
|
-
const end = line.indexOf('m', i);
|
|
189
|
-
if (end !== -1) {
|
|
190
|
-
i = end;
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
visibleLen++;
|
|
195
|
-
if (visibleLen >= max - 3) {
|
|
196
|
-
cutIndex = i + 1;
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return line.slice(0, cutIndex) + '...';
|
|
201
|
-
};
|
|
202
|
-
if (!cmd) {
|
|
203
|
-
lines.push(s.error(' Command not found'));
|
|
204
|
-
return lines;
|
|
205
|
-
}
|
|
206
|
-
// Command name header
|
|
207
|
-
lines.push(chalk.bold(` /${cmd.name}`));
|
|
208
|
-
lines.push('');
|
|
209
|
-
// Description
|
|
210
|
-
lines.push(' ' + s.primary('DESCRIPTION'));
|
|
211
|
-
lines.push(truncate(' ' + cmd.description));
|
|
212
|
-
lines.push('');
|
|
213
|
-
// Details (word-wrapped)
|
|
214
|
-
if (cmd.details) {
|
|
215
|
-
lines.push(' ' + s.primary('ABOUT'));
|
|
216
|
-
const maxWidth = Math.min(cols - 6, 70); // Cap at 70 chars for readability
|
|
217
|
-
const words = cmd.details.split(' ');
|
|
218
|
-
let currentLine = ' ';
|
|
219
|
-
for (const word of words) {
|
|
220
|
-
if (currentLine.length + word.length + 1 > maxWidth) {
|
|
221
|
-
lines.push(truncate(currentLine));
|
|
222
|
-
currentLine = ' ' + word;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
currentLine += (currentLine.length > 3 ? ' ' : '') + word;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (currentLine.length > 3) {
|
|
229
|
-
lines.push(truncate(currentLine));
|
|
230
|
-
}
|
|
231
|
-
lines.push('');
|
|
232
|
-
}
|
|
233
|
-
// Aliases
|
|
234
|
-
if (cmd.aliases && cmd.aliases.length > 0) {
|
|
235
|
-
lines.push(' ' + s.primary('ALIASES'));
|
|
236
|
-
lines.push(truncate(' ' + cmd.aliases.map(a => `/${a}`).join(', ')));
|
|
237
|
-
lines.push('');
|
|
238
|
-
}
|
|
239
|
-
// Examples (structured format)
|
|
240
|
-
if (cmd.examples && cmd.examples.length > 0) {
|
|
241
|
-
lines.push(' ' + s.primary('EXAMPLES'));
|
|
242
|
-
for (const example of cmd.examples) {
|
|
243
|
-
if (example.description) {
|
|
244
|
-
// Format: /command · description
|
|
245
|
-
// Pad the raw string before applying styles
|
|
246
|
-
const paddedCode = example.code.padEnd(22);
|
|
247
|
-
const exLine = ` ${s.muted(paddedCode)}${s.muted('·')} ${example.description}`;
|
|
248
|
-
lines.push(truncate(exLine));
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
lines.push(truncate(' ' + s.muted(example.code)));
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
lines.push('');
|
|
255
|
-
}
|
|
256
|
-
// Interactions (new section)
|
|
257
|
-
if (cmd.interactions && cmd.interactions.length > 0) {
|
|
258
|
-
lines.push(' ' + s.primary('INTERACTIONS'));
|
|
259
|
-
for (const hint of cmd.interactions) {
|
|
260
|
-
lines.push(truncate(' ' + s.muted('• ' + hint)));
|
|
261
|
-
}
|
|
262
|
-
lines.push('');
|
|
263
|
-
}
|
|
264
|
-
// Pad to consistent height (at least 12 lines for content)
|
|
265
|
-
while (lines.length < 12) {
|
|
266
|
-
lines.push('');
|
|
267
|
-
}
|
|
268
|
-
return lines;
|
|
269
|
-
}
|
|
270
|
-
function renderHelpFooter(showingDetail) {
|
|
271
|
-
const s = getStyles();
|
|
272
|
-
const lines = [];
|
|
273
|
-
lines.push('');
|
|
274
|
-
if (showingDetail) {
|
|
275
|
-
lines.push(s.muted(' Esc to go back'));
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
lines.push(s.muted(' For more help: https://github.com/scozzola/compilr-dev-cli'));
|
|
279
|
-
lines.push('');
|
|
280
|
-
lines.push(s.muted(' Enter for details · Esc to exit'));
|
|
281
|
-
}
|
|
282
|
-
return lines;
|
|
283
|
-
}
|
|
284
|
-
function buildHelpLines(state) {
|
|
285
|
-
const allLines = [];
|
|
286
|
-
const s = getStyles();
|
|
287
|
-
const cols = terminal.getTerminalWidth();
|
|
288
|
-
// If showing command detail, render that instead
|
|
289
|
-
if (state.showingDetail) {
|
|
290
|
-
allLines.push(s.muted('─'.repeat(Math.max(1, cols - 1))));
|
|
291
|
-
allLines.push(' ' + s.primaryBold('Command Reference'));
|
|
292
|
-
allLines.push('');
|
|
293
|
-
allLines.push(...renderCommandDetail(state.detailCommandIndex));
|
|
294
|
-
allLines.push(...renderHelpFooter(true));
|
|
295
|
-
return allLines;
|
|
296
|
-
}
|
|
297
|
-
allLines.push(...renderHelpHeader(state));
|
|
298
|
-
switch (TABS[state.currentTab].id) {
|
|
299
|
-
case 'general':
|
|
300
|
-
allLines.push(...renderGeneralTab());
|
|
301
|
-
break;
|
|
302
|
-
case 'commands':
|
|
303
|
-
allLines.push(...renderCommandsTab(state));
|
|
304
|
-
break;
|
|
305
|
-
case 'custom-commands':
|
|
306
|
-
allLines.push(...renderCustomCommandsTab(state));
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
allLines.push(...renderHelpFooter(false));
|
|
310
|
-
return allLines;
|
|
311
|
-
}
|
|
312
|
-
function renderHelpMenu(state, prevLineCount) {
|
|
313
|
-
const lines = buildHelpLines(state);
|
|
314
|
-
if (prevLineCount > 0) {
|
|
315
|
-
terminal.moveCursorToLineStart();
|
|
316
|
-
if (prevLineCount > 1) {
|
|
317
|
-
terminal.moveCursorUp(prevLineCount - 1);
|
|
318
|
-
}
|
|
319
|
-
terminal.clearToEndOfScreen();
|
|
320
|
-
}
|
|
321
|
-
terminal.write(lines.join('\n'));
|
|
322
|
-
return lines.length;
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Show the tabbed help menu
|
|
326
|
-
*/
|
|
327
|
-
export function showHelp() {
|
|
328
|
-
return new Promise((resolve) => {
|
|
329
|
-
const state = {
|
|
330
|
-
currentTab: 0,
|
|
331
|
-
selectedCommand: 0,
|
|
332
|
-
scrollOffset: 0,
|
|
333
|
-
selectedCustomCommand: 0,
|
|
334
|
-
customScrollOffset: 0,
|
|
335
|
-
showingDetail: false,
|
|
336
|
-
detailCommandIndex: 0,
|
|
337
|
-
};
|
|
338
|
-
let lineCount = 0;
|
|
339
|
-
terminal.writeLine('');
|
|
340
|
-
terminal.hideCursor();
|
|
341
|
-
const wasRawMode = process.stdin.isRaw;
|
|
342
|
-
terminal.enableRawMode();
|
|
343
|
-
lineCount = renderHelpMenu(state, 0);
|
|
344
|
-
const cleanup = () => {
|
|
345
|
-
if (lineCount > 0) {
|
|
346
|
-
terminal.moveCursorUp(lineCount);
|
|
347
|
-
terminal.clearToEndOfScreen();
|
|
348
|
-
}
|
|
349
|
-
terminal.writeLine('');
|
|
350
|
-
terminal.showCursor();
|
|
351
|
-
if (!wasRawMode) {
|
|
352
|
-
terminal.disableRawMode();
|
|
353
|
-
}
|
|
354
|
-
process.stdin.removeListener('data', onData);
|
|
355
|
-
process.stdout.removeListener('resize', onResize);
|
|
356
|
-
};
|
|
357
|
-
const onData = (data) => {
|
|
358
|
-
const isEscape = data.length === 1 && data[0] === 0x1b;
|
|
359
|
-
const isTab = data.length === 1 && data[0] === 0x09;
|
|
360
|
-
const isUpArrow = data.length === 3 && data[0] === 0x1b && data[1] === 0x5b && data[2] === 0x41;
|
|
361
|
-
const isDownArrow = data.length === 3 && data[0] === 0x1b && data[1] === 0x5b && data[2] === 0x42;
|
|
362
|
-
const isCtrlC = data.length === 1 && data[0] === 0x03;
|
|
363
|
-
const isEnter = data.length === 1 && (data[0] === 0x0d || data[0] === 0x0a);
|
|
364
|
-
// Ctrl+C always exits
|
|
365
|
-
if (isCtrlC) {
|
|
366
|
-
cleanup();
|
|
367
|
-
resolve();
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
// If showing command detail view
|
|
371
|
-
if (state.showingDetail) {
|
|
372
|
-
if (isEscape) {
|
|
373
|
-
// Go back to commands list
|
|
374
|
-
state.showingDetail = false;
|
|
375
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
// Ignore other keys in detail view
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
// Escape exits the help menu (when not in detail view)
|
|
382
|
-
if (isEscape) {
|
|
383
|
-
cleanup();
|
|
384
|
-
resolve();
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
// Enter shows command detail (for commands tab only)
|
|
388
|
-
if (isEnter && TABS[state.currentTab].id === 'commands') {
|
|
389
|
-
state.showingDetail = true;
|
|
390
|
-
state.detailCommandIndex = state.selectedCommand;
|
|
391
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
if (isTab) {
|
|
395
|
-
state.currentTab = (state.currentTab + 1) % TABS.length;
|
|
396
|
-
// Reset scroll when switching tabs
|
|
397
|
-
if (TABS[state.currentTab].id === 'commands') {
|
|
398
|
-
state.selectedCommand = 0;
|
|
399
|
-
state.scrollOffset = 0;
|
|
400
|
-
}
|
|
401
|
-
else if (TABS[state.currentTab].id === 'custom-commands') {
|
|
402
|
-
state.selectedCustomCommand = 0;
|
|
403
|
-
state.customScrollOffset = 0;
|
|
404
|
-
}
|
|
405
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
// Handle arrow navigation for commands tab
|
|
409
|
-
if (TABS[state.currentTab].id === 'commands') {
|
|
410
|
-
const visibleCount = Math.min(MAX_VISIBLE_COMMANDS, COMMANDS.length);
|
|
411
|
-
if (isUpArrow && state.selectedCommand > 0) {
|
|
412
|
-
state.selectedCommand--;
|
|
413
|
-
if (state.selectedCommand < state.scrollOffset) {
|
|
414
|
-
state.scrollOffset = state.selectedCommand;
|
|
415
|
-
}
|
|
416
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
417
|
-
}
|
|
418
|
-
if (isDownArrow && state.selectedCommand < COMMANDS.length - 1) {
|
|
419
|
-
state.selectedCommand++;
|
|
420
|
-
if (state.selectedCommand >= state.scrollOffset + visibleCount) {
|
|
421
|
-
state.scrollOffset = state.selectedCommand - visibleCount + 1;
|
|
422
|
-
}
|
|
423
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
// Handle arrow navigation for custom commands tab
|
|
427
|
-
if (TABS[state.currentTab].id === 'custom-commands') {
|
|
428
|
-
const registry = getCustomCommandRegistry();
|
|
429
|
-
const customCommands = registry.getAll();
|
|
430
|
-
const totalCustom = customCommands.length;
|
|
431
|
-
if (totalCustom > 0) {
|
|
432
|
-
const visibleCount = Math.min(MAX_VISIBLE_COMMANDS, totalCustom);
|
|
433
|
-
if (isUpArrow && state.selectedCustomCommand > 0) {
|
|
434
|
-
state.selectedCustomCommand--;
|
|
435
|
-
if (state.selectedCustomCommand < state.customScrollOffset) {
|
|
436
|
-
state.customScrollOffset = state.selectedCustomCommand;
|
|
437
|
-
}
|
|
438
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
439
|
-
}
|
|
440
|
-
if (isDownArrow && state.selectedCustomCommand < totalCustom - 1) {
|
|
441
|
-
state.selectedCustomCommand++;
|
|
442
|
-
if (state.selectedCustomCommand >= state.customScrollOffset + visibleCount) {
|
|
443
|
-
state.customScrollOffset = state.selectedCustomCommand - visibleCount + 1;
|
|
444
|
-
}
|
|
445
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
const onResize = () => {
|
|
451
|
-
lineCount = renderHelpMenu(state, lineCount);
|
|
452
|
-
};
|
|
453
|
-
process.stdin.on('data', onData);
|
|
454
|
-
process.stdout.on('resize', onResize);
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
13
|
/**
|
|
458
14
|
* Show a confirmation dialog
|
|
459
15
|
*/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permission Overlay V2
|
|
3
|
+
*
|
|
4
|
+
* Modal overlay for tool permission requests.
|
|
5
|
+
* Uses BaseOverlayV2 for the new TerminalUI-based REPL.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseOverlayV2 } from './base/index.js';
|
|
8
|
+
import type { RenderContext, OverlayAction, KeyEvent } from './overlay/index.js';
|
|
9
|
+
export type PermissionResult = 'allow' | 'deny' | 'allow-always';
|
|
10
|
+
export interface PermissionOverlayV2Options {
|
|
11
|
+
toolName: string;
|
|
12
|
+
args: Record<string, unknown>;
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Pre-rendered diff lines (for edit tool) */
|
|
15
|
+
diffLines?: string[];
|
|
16
|
+
}
|
|
17
|
+
interface PermissionState {
|
|
18
|
+
selectedIndex: number;
|
|
19
|
+
showingDetail: boolean;
|
|
20
|
+
detailScrollOffset: number;
|
|
21
|
+
detailContentLines: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare class PermissionOverlayV2 extends BaseOverlayV2<PermissionState, PermissionResult> {
|
|
24
|
+
readonly type: "inline";
|
|
25
|
+
readonly id = "permission-overlay-v2";
|
|
26
|
+
private readonly options;
|
|
27
|
+
constructor(options: PermissionOverlayV2Options);
|
|
28
|
+
protected renderContent(context: RenderContext): string[];
|
|
29
|
+
private renderMainView;
|
|
30
|
+
private renderDetailView;
|
|
31
|
+
handleKey(key: KeyEvent): OverlayAction<PermissionResult>;
|
|
32
|
+
private handleMainKey;
|
|
33
|
+
private handleDetailKey;
|
|
34
|
+
getCloseSummary(result: PermissionResult): string | null;
|
|
35
|
+
}
|
|
36
|
+
export {};
|