erosolar-cli 2.1.52 → 2.1.53
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/dist/capabilities/askUserCapability.d.ts.map +1 -1
- package/dist/capabilities/askUserCapability.js +32 -49
- package/dist/capabilities/askUserCapability.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +6 -2
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/systemPrompt.js +1 -1
- package/dist/shell/systemPrompt.js.map +1 -1
- package/dist/tools/interactionTools.d.ts.map +1 -1
- package/dist/tools/interactionTools.js +6 -23
- package/dist/tools/interactionTools.js.map +1 -1
- package/dist/ui/UnifiedUIRenderer.d.ts +14 -2
- package/dist/ui/UnifiedUIRenderer.d.ts.map +1 -1
- package/dist/ui/UnifiedUIRenderer.js +191 -58
- package/dist/ui/UnifiedUIRenderer.js.map +1 -1
- package/dist/ui/display.d.ts +9 -0
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +26 -0
- package/dist/ui/display.js.map +1 -1
- package/dist/utils/askUserPrompt.d.ts.map +1 -1
- package/dist/utils/askUserPrompt.js +15 -5
- package/dist/utils/askUserPrompt.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ You own this repo and must act with tools; do not treat this as a chatbot conver
|
|
|
11
11
|
'✓ Tool usage is narrated to the operator in real time',
|
|
12
12
|
];
|
|
13
13
|
const behaviorGuidelines = [
|
|
14
|
-
'
|
|
14
|
+
'Default to acting with a stated assumption instead of asking; pause for clarification only when requests conflict, are unsafe, or would cause high-risk work. For common tasks (e.g., bump/publish, run tests, open file) assume the standard meaning and act.',
|
|
15
15
|
'Loop: analyze → plan → implement → validate. Keep plans minimal and only when the work is multi-step or risky.',
|
|
16
16
|
'State a validation plan up front; prefer quick_typecheck while iterating and validate_all_changes to finish. Fix failures before reporting done.',
|
|
17
17
|
'Default to a smart test->build->fix loop for every prompt: propose fast checks, run the build/tests, fix errors, then rerun until clean.',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemPrompt.js","sourceRoot":"","sources":["../../src/shell/systemPrompt.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,4BAA4B,CAC1C,UAAkB,EAClB,YAAoB,EACpB,KAA+B,EAC/B,YAAqB;IAErB,MAAM,IAAI,GAAG,YAAY,IAAI,cAAc,CAAC;IAC5C,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEhD,MAAM,aAAa,GAAG,WAAW,IAAI,uDAAuD,SAAS;wFACf,CAAC;IAEvF,MAAM,eAAe,GAAG;QACtB,4DAA4D;QAC5D,oCAAoC;QACpC,0CAA0C;QAC1C,uDAAuD;KACxD,CAAC;IAEF,MAAM,kBAAkB,GAAG;QACzB,
|
|
1
|
+
{"version":3,"file":"systemPrompt.js","sourceRoot":"","sources":["../../src/shell/systemPrompt.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,4BAA4B,CAC1C,UAAkB,EAClB,YAAoB,EACpB,KAA+B,EAC/B,YAAqB;IAErB,MAAM,IAAI,GAAG,YAAY,IAAI,cAAc,CAAC;IAC5C,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEhD,MAAM,aAAa,GAAG,WAAW,IAAI,uDAAuD,SAAS;wFACf,CAAC;IAEvF,MAAM,eAAe,GAAG;QACtB,4DAA4D;QAC5D,oCAAoC;QACpC,0CAA0C;QAC1C,uDAAuD;KACxD,CAAC;IAEF,MAAM,kBAAkB,GAAG;QACzB,gQAAgQ;QAChQ,gHAAgH;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,CAAC,SAAS,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;IAC9C,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC;AACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionTools.d.ts","sourceRoot":"","sources":["../../src/tools/interactionTools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interactionTools.d.ts","sourceRoot":"","sources":["../../src/tools/interactionTools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAM7D,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,2BAA2B,CAAC;AAInC,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC;AAC3C,MAAM,MAAM,QAAQ,GAAG,eAAe,CAAC;AAEvC,wBAAgB,sBAAsB,IAAI,cAAc,EAAE,CAyNzD"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as readline from 'node:readline';
|
|
2
1
|
import { listSecretDefinitions, setSecretValue, } from '../core/secretStore.js';
|
|
3
2
|
import { formatAskUserPrompt, MAX_ASK_USER_OPTIONS, } from '../utils/askUserPrompt.js';
|
|
4
3
|
import { display } from '../ui/display.js';
|
|
@@ -87,20 +86,14 @@ Usage notes:
|
|
|
87
86
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
88
87
|
return 'Interactive input is unavailable (non-TTY).';
|
|
89
88
|
}
|
|
90
|
-
// Interactive mode - ask questions via terminal
|
|
91
|
-
const rl = readline.createInterface({
|
|
92
|
-
input: process.stdin,
|
|
93
|
-
output: process.stdout,
|
|
94
|
-
});
|
|
95
89
|
const userAnswers = {};
|
|
96
90
|
try {
|
|
97
91
|
const askInput = async (promptLine) => {
|
|
98
92
|
if (promptLine) {
|
|
99
93
|
display.showInlinePanel([promptLine]);
|
|
100
94
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
95
|
+
const answer = await display.captureUserInput({ trim: true, resetBuffer: true });
|
|
96
|
+
return answer.trim();
|
|
104
97
|
};
|
|
105
98
|
for (let i = 0; i < questions.length; i++) {
|
|
106
99
|
const q = questions[i];
|
|
@@ -163,7 +156,6 @@ Usage notes:
|
|
|
163
156
|
}
|
|
164
157
|
finally {
|
|
165
158
|
display.clearInlinePanel();
|
|
166
|
-
rl.close();
|
|
167
159
|
}
|
|
168
160
|
},
|
|
169
161
|
},
|
|
@@ -209,18 +201,9 @@ Usage notes:
|
|
|
209
201
|
];
|
|
210
202
|
}
|
|
211
203
|
async function askSingleQuestion(message) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
try {
|
|
217
|
-
const answer = await new Promise((resolve) => {
|
|
218
|
-
rl.question(message, (input) => resolve(input.trim()));
|
|
219
|
-
});
|
|
220
|
-
return answer;
|
|
221
|
-
}
|
|
222
|
-
finally {
|
|
223
|
-
rl.close();
|
|
224
|
-
}
|
|
204
|
+
display.showInlinePanel([message]);
|
|
205
|
+
const answer = await display.captureUserInput({ trim: true, resetBuffer: true });
|
|
206
|
+
display.clearInlinePanel();
|
|
207
|
+
return answer.trim();
|
|
225
208
|
}
|
|
226
209
|
//# sourceMappingURL=interactionTools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionTools.js","sourceRoot":"","sources":["../../src/tools/interactionTools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interactionTools.js","sourceRoot":"","sources":["../../src/tools/interactionTools.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,cAAc,GAEf,MAAM,wBAAwB,CAAC;AAChC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-37,6 +37,7 @@ export declare class UnifiedUIRenderer extends EventEmitter {
|
|
|
37
37
|
private readonly interactive;
|
|
38
38
|
private rows;
|
|
39
39
|
private cols;
|
|
40
|
+
private lastRenderWidth;
|
|
40
41
|
private eventQueue;
|
|
41
42
|
private isProcessingQueue;
|
|
42
43
|
private buffer;
|
|
@@ -73,6 +74,7 @@ export declare class UnifiedUIRenderer extends EventEmitter {
|
|
|
73
74
|
private hasEverRenderedOverlay;
|
|
74
75
|
private lastOverlay;
|
|
75
76
|
private allowPromptRender;
|
|
77
|
+
private inputCapture;
|
|
76
78
|
constructor(output?: NodeJS.WriteStream, input?: NodeJS.ReadStream, options?: UnifiedUIRendererOptions);
|
|
77
79
|
initialize(): void;
|
|
78
80
|
cleanup(): void;
|
|
@@ -136,14 +138,24 @@ export declare class UnifiedUIRenderer extends EventEmitter {
|
|
|
136
138
|
private buildOverlayLines;
|
|
137
139
|
private buildChromeLines;
|
|
138
140
|
private abbreviatePath;
|
|
139
|
-
private
|
|
140
|
-
private
|
|
141
|
+
private buildStatusBlock;
|
|
142
|
+
private buildMetaBlock;
|
|
143
|
+
private composeStatusLabel;
|
|
144
|
+
private formatMetaSegment;
|
|
145
|
+
private applyTone;
|
|
146
|
+
private wrapSegments;
|
|
141
147
|
private buildControlLines;
|
|
142
148
|
private buildToggleLine;
|
|
143
149
|
private buildShortcutLine;
|
|
144
150
|
private buildInputLine;
|
|
145
151
|
private buildInputWindow;
|
|
146
152
|
private expandCollapsedPaste;
|
|
153
|
+
captureInput(options?: {
|
|
154
|
+
allowEmpty?: boolean;
|
|
155
|
+
trim?: boolean;
|
|
156
|
+
resetBuffer?: boolean;
|
|
157
|
+
}): Promise<string>;
|
|
158
|
+
private cancelInputCapture;
|
|
147
159
|
private safeWidth;
|
|
148
160
|
private visibleLength;
|
|
149
161
|
private stripAnsi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnifiedUIRenderer.d.ts","sourceRoot":"","sources":["../../src/ui/U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,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IA0B5G,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,YAAY;IAyCpB,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;IAInB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IASjD,WAAW,IAAI,IAAI;IAUnB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAI1C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAWzB,MAAM,IAAI,IAAI;IAId,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,kBAAkB;CAM3B"}
|
|
@@ -13,7 +13,7 @@ import { EventEmitter } from 'node:events';
|
|
|
13
13
|
import { homedir } from 'node:os';
|
|
14
14
|
import { theme } from './theme.js';
|
|
15
15
|
import { isPlainOutputMode } from './outputMode.js';
|
|
16
|
-
import { renderDivider
|
|
16
|
+
import { renderDivider } from './unified/layout.js';
|
|
17
17
|
const ESC = {
|
|
18
18
|
HIDE_CURSOR: '\x1b[?25l',
|
|
19
19
|
SHOW_CURSOR: '\x1b[?25h',
|
|
@@ -38,6 +38,7 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
38
38
|
interactive;
|
|
39
39
|
rows = 24;
|
|
40
40
|
cols = 80;
|
|
41
|
+
lastRenderWidth = null;
|
|
41
42
|
eventQueue = [];
|
|
42
43
|
isProcessingQueue = false;
|
|
43
44
|
buffer = '';
|
|
@@ -83,6 +84,7 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
83
84
|
hasEverRenderedOverlay = false; // Track if we've ever rendered to prevent first-render scrollback pollution
|
|
84
85
|
lastOverlay = null;
|
|
85
86
|
allowPromptRender = true;
|
|
87
|
+
inputCapture = null;
|
|
86
88
|
constructor(output = process.stdout, input = process.stdin, options) {
|
|
87
89
|
super();
|
|
88
90
|
this.output = output;
|
|
@@ -131,6 +133,7 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
131
133
|
this.renderPrompt();
|
|
132
134
|
}
|
|
133
135
|
cleanup() {
|
|
136
|
+
this.cancelInputCapture(new Error('Renderer disposed'));
|
|
134
137
|
if (!this.interactive) {
|
|
135
138
|
this.rl.close();
|
|
136
139
|
return;
|
|
@@ -174,6 +177,11 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
174
177
|
if (this.handleBracketedPaste(str, key)) {
|
|
175
178
|
return;
|
|
176
179
|
}
|
|
180
|
+
if (this.inputCapture && key.ctrl && (key.name === 'c' || key.name === 'd')) {
|
|
181
|
+
this.cancelInputCapture(new Error('Input capture cancelled'));
|
|
182
|
+
this.clearBuffer();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
177
185
|
if (key.ctrl && key.shift && key.name?.toLowerCase() === 'a') {
|
|
178
186
|
this.emit('toggle-critical-approval');
|
|
179
187
|
return;
|
|
@@ -384,6 +392,24 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
384
392
|
this.expandCollapsedPaste();
|
|
385
393
|
return;
|
|
386
394
|
}
|
|
395
|
+
if (this.inputCapture) {
|
|
396
|
+
const shouldTrim = this.inputCapture.options.trim;
|
|
397
|
+
const normalizedCapture = shouldTrim ? text.trim() : text;
|
|
398
|
+
if (!this.inputCapture.options.allowEmpty && !normalizedCapture) {
|
|
399
|
+
this.renderPrompt();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
const resolver = this.inputCapture;
|
|
403
|
+
this.inputCapture = null;
|
|
404
|
+
this.buffer = '';
|
|
405
|
+
this.cursor = 0;
|
|
406
|
+
this.inputRenderOffset = 0;
|
|
407
|
+
this.resetSuggestions();
|
|
408
|
+
this.renderPrompt();
|
|
409
|
+
this.emitInputChange();
|
|
410
|
+
resolver.resolve(normalizedCapture);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
387
413
|
const normalized = text.trim();
|
|
388
414
|
if (!normalized) {
|
|
389
415
|
this.renderPrompt();
|
|
@@ -785,16 +811,24 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
785
811
|
}
|
|
786
812
|
// Rich mode: inline overlay anchored to current scrollback (no full-screen clear)
|
|
787
813
|
this.updateTerminalSize();
|
|
814
|
+
const maxWidth = this.safeWidth();
|
|
815
|
+
if (this.lastRenderWidth !== null && maxWidth !== this.lastRenderWidth) {
|
|
816
|
+
// Terminal resized; force a clean anchor so the overlay doesn't jitter.
|
|
817
|
+
this.overlayInvalidated = true;
|
|
818
|
+
}
|
|
819
|
+
this.lastRenderWidth = maxWidth;
|
|
788
820
|
const overlay = this.buildOverlayLines();
|
|
789
821
|
if (!overlay.lines.length) {
|
|
790
822
|
return;
|
|
791
823
|
}
|
|
792
|
-
const
|
|
793
|
-
const promptIndex = Math.max(0, Math.min(overlay.promptIndex,
|
|
794
|
-
const height =
|
|
795
|
-
const
|
|
824
|
+
const renderedLines = overlay.lines.map(line => this.truncateLine(line, maxWidth));
|
|
825
|
+
const promptIndex = Math.max(0, Math.min(overlay.promptIndex, renderedLines.length - 1));
|
|
826
|
+
const height = renderedLines.length;
|
|
827
|
+
const prevLines = this.lastOverlay?.lines ?? [];
|
|
828
|
+
const prevHeight = prevLines.length || this.lastOverlayHeight || 0;
|
|
796
829
|
const prevPromptIndex = this.lastOverlay?.promptIndex ?? this.lastPromptIndex ?? promptIndex;
|
|
797
830
|
const needsFreshAnchor = this.overlayInvalidated || !this.hasRenderedPrompt;
|
|
831
|
+
const effectiveRowCount = needsFreshAnchor ? height : Math.max(prevHeight, height);
|
|
798
832
|
// For first render, ensure we start on a fresh line
|
|
799
833
|
if (needsFreshAnchor) {
|
|
800
834
|
if (!this.lastOutputEndedWithNewline) {
|
|
@@ -811,6 +845,16 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
811
845
|
this.write(`\x1b[${height}A`);
|
|
812
846
|
}
|
|
813
847
|
this.write('\r');
|
|
848
|
+
for (let idx = 0; idx < height; idx++) {
|
|
849
|
+
const line = renderedLines[idx] ?? '';
|
|
850
|
+
this.write(ESC.CLEAR_LINE);
|
|
851
|
+
if (line) {
|
|
852
|
+
this.write(line);
|
|
853
|
+
}
|
|
854
|
+
if (idx < height - 1) {
|
|
855
|
+
this.write('\n');
|
|
856
|
+
}
|
|
857
|
+
}
|
|
814
858
|
}
|
|
815
859
|
else {
|
|
816
860
|
// Move to the top of the previous overlay relative to the prompt row
|
|
@@ -818,35 +862,33 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
818
862
|
this.write(`\x1b[${prevPromptIndex}A`);
|
|
819
863
|
}
|
|
820
864
|
this.write('\r');
|
|
821
|
-
//
|
|
822
|
-
const
|
|
823
|
-
for (let idx = 0; idx <
|
|
824
|
-
|
|
825
|
-
|
|
865
|
+
// Render only the lines that changed to keep dynamic growth smooth
|
|
866
|
+
const rowsToRender = Math.max(prevHeight, height);
|
|
867
|
+
for (let idx = 0; idx < rowsToRender; idx++) {
|
|
868
|
+
const nextLine = idx < height ? renderedLines[idx] ?? '' : '';
|
|
869
|
+
const prevLine = idx < prevLines.length ? prevLines[idx] ?? '' : '';
|
|
870
|
+
const needsClear = idx >= height;
|
|
871
|
+
const needsUpdate = needsClear || nextLine !== prevLine;
|
|
872
|
+
if (needsUpdate) {
|
|
873
|
+
this.write(ESC.CLEAR_LINE);
|
|
874
|
+
if (!needsClear && nextLine) {
|
|
875
|
+
this.write(nextLine);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (idx < rowsToRender - 1) {
|
|
826
879
|
this.write('\n');
|
|
827
880
|
}
|
|
828
881
|
}
|
|
829
|
-
|
|
830
|
-
this.write(`\x1b[${rowsToClear - 1}A`);
|
|
831
|
-
}
|
|
832
|
-
this.write('\r');
|
|
833
|
-
}
|
|
834
|
-
// Write overlay lines in place (relative to current scrollback)
|
|
835
|
-
for (let idx = 0; idx < height; idx++) {
|
|
836
|
-
const line = this.truncateLine(lines[idx] ?? '', this.safeWidth());
|
|
837
|
-
this.write(ESC.CLEAR_LINE);
|
|
838
|
-
this.write(line);
|
|
839
|
-
if (idx < height - 1) {
|
|
840
|
-
this.write('\n');
|
|
841
|
-
}
|
|
882
|
+
// After incremental render we're sitting at the bottom of the overlay footprint
|
|
842
883
|
}
|
|
843
884
|
// Position cursor at prompt row/col
|
|
844
|
-
const
|
|
845
|
-
|
|
846
|
-
|
|
885
|
+
const currentRowFromTop = effectiveRowCount > 0 ? effectiveRowCount - 1 : 0;
|
|
886
|
+
const deltaRows = currentRowFromTop - promptIndex;
|
|
887
|
+
if (deltaRows > 0) {
|
|
888
|
+
this.write(`\x1b[${deltaRows}A`);
|
|
847
889
|
}
|
|
848
|
-
else if (
|
|
849
|
-
this.write(`\x1b[${-
|
|
890
|
+
else if (deltaRows < 0) {
|
|
891
|
+
this.write(`\x1b[${-deltaRows}B`);
|
|
850
892
|
}
|
|
851
893
|
const promptCol = Math.min(Math.max(1, 3 + this.cursor), this.cols);
|
|
852
894
|
this.write('\r');
|
|
@@ -857,7 +899,7 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
857
899
|
this.isPromptActive = true;
|
|
858
900
|
this.lastOverlayHeight = height;
|
|
859
901
|
this.lastPromptIndex = promptIndex;
|
|
860
|
-
this.lastOverlay = { lines, promptIndex };
|
|
902
|
+
this.lastOverlay = { lines: renderedLines, promptIndex };
|
|
861
903
|
this.overlayInvalidated = false;
|
|
862
904
|
this.lastOutputEndedWithNewline = true;
|
|
863
905
|
this.promptHeight = height;
|
|
@@ -895,12 +937,10 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
895
937
|
return { lines, promptIndex };
|
|
896
938
|
}
|
|
897
939
|
buildChromeLines() {
|
|
898
|
-
const parts = [...this.buildStatusParts(), ...this.buildMetaParts()];
|
|
899
|
-
if (parts.length === 0) {
|
|
900
|
-
return [];
|
|
901
|
-
}
|
|
902
940
|
const maxWidth = this.safeWidth();
|
|
903
|
-
|
|
941
|
+
const statusLines = this.buildStatusBlock(maxWidth);
|
|
942
|
+
const metaLines = this.buildMetaBlock(maxWidth);
|
|
943
|
+
return [...statusLines, ...metaLines];
|
|
904
944
|
}
|
|
905
945
|
abbreviatePath(pathValue) {
|
|
906
946
|
const home = homedir();
|
|
@@ -909,54 +949,116 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
909
949
|
}
|
|
910
950
|
return pathValue;
|
|
911
951
|
}
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
const
|
|
952
|
+
buildStatusBlock(maxWidth) {
|
|
953
|
+
const statusLabel = this.composeStatusLabel();
|
|
954
|
+
if (!statusLabel) {
|
|
955
|
+
return [];
|
|
956
|
+
}
|
|
957
|
+
const segments = [];
|
|
958
|
+
segments.push(`${theme.ui.muted('status')} ${this.applyTone(statusLabel.text, statusLabel.tone)}`);
|
|
918
959
|
if (this.statusMeta.sessionTime) {
|
|
919
|
-
|
|
960
|
+
segments.push(`${theme.ui.muted('runtime')} ${theme.ui.muted(this.statusMeta.sessionTime)}`);
|
|
920
961
|
}
|
|
921
962
|
if (this.statusMeta.contextPercent !== undefined) {
|
|
922
963
|
const ctx = this.statusMeta.contextPercent;
|
|
923
|
-
const
|
|
924
|
-
|
|
964
|
+
const tone = ctx > 90 ? 'error' : ctx > 70 ? 'warn' : 'muted';
|
|
965
|
+
const color = tone === 'error' ? theme.error : tone === 'warn' ? theme.warning : theme.ui.muted;
|
|
966
|
+
segments.push(`${theme.ui.muted('ctx')} ${color(`${ctx}%`)}`);
|
|
925
967
|
}
|
|
926
|
-
return
|
|
968
|
+
return this.wrapSegments(segments, maxWidth);
|
|
927
969
|
}
|
|
928
|
-
|
|
929
|
-
const
|
|
970
|
+
buildMetaBlock(maxWidth) {
|
|
971
|
+
const segments = [];
|
|
930
972
|
if (this.statusMeta.profile) {
|
|
931
|
-
|
|
973
|
+
segments.push(this.formatMetaSegment('profile', this.statusMeta.profile, 'info'));
|
|
932
974
|
}
|
|
933
975
|
const model = this.statusMeta.provider && this.statusMeta.model
|
|
934
|
-
? `${this.statusMeta.provider}
|
|
976
|
+
? `${this.statusMeta.provider} / ${this.statusMeta.model}`
|
|
935
977
|
: this.statusMeta.model || this.statusMeta.provider;
|
|
936
978
|
if (model) {
|
|
937
|
-
|
|
979
|
+
segments.push(this.formatMetaSegment('model', model, 'info'));
|
|
938
980
|
}
|
|
939
981
|
const workspace = this.statusMeta.workspace || this.statusMeta.directory;
|
|
940
982
|
if (workspace) {
|
|
941
|
-
|
|
983
|
+
segments.push(this.formatMetaSegment('dir', this.abbreviatePath(workspace), 'muted'));
|
|
942
984
|
}
|
|
943
985
|
if (this.statusMeta.writes) {
|
|
944
|
-
|
|
986
|
+
segments.push(this.formatMetaSegment('writes', this.statusMeta.writes, 'muted'));
|
|
945
987
|
}
|
|
946
988
|
if (this.statusMeta.toolSummary) {
|
|
947
|
-
|
|
989
|
+
segments.push(this.formatMetaSegment('tools', this.statusMeta.toolSummary, 'muted'));
|
|
948
990
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
parts.push({ text: `session ${sessionLabel}`, tone: 'muted' });
|
|
991
|
+
if (this.statusMeta.sessionLabel) {
|
|
992
|
+
segments.push(this.formatMetaSegment('session', this.statusMeta.sessionLabel, 'muted'));
|
|
952
993
|
}
|
|
953
994
|
if (this.statusMeta.version) {
|
|
954
|
-
|
|
995
|
+
segments.push(this.formatMetaSegment('build', `v${this.statusMeta.version}`, 'muted'));
|
|
955
996
|
}
|
|
956
|
-
if (
|
|
997
|
+
if (segments.length === 0) {
|
|
957
998
|
return [];
|
|
958
999
|
}
|
|
959
|
-
return
|
|
1000
|
+
return this.wrapSegments(segments, maxWidth);
|
|
1001
|
+
}
|
|
1002
|
+
composeStatusLabel() {
|
|
1003
|
+
const statuses = [this.statusStreaming, this.statusOverride, this.statusMessage].filter((value, index, arr) => Boolean(value) && arr.indexOf(value) === index);
|
|
1004
|
+
const text = statuses.length > 0 ? statuses.join(' / ') : 'Ready for prompts';
|
|
1005
|
+
if (!text.trim()) {
|
|
1006
|
+
return null;
|
|
1007
|
+
}
|
|
1008
|
+
const normalized = text.toLowerCase();
|
|
1009
|
+
const tone = normalized.includes('ready') ? 'success' : 'info';
|
|
1010
|
+
return { text, tone };
|
|
1011
|
+
}
|
|
1012
|
+
formatMetaSegment(label, value, tone) {
|
|
1013
|
+
const colorizer = tone === 'success'
|
|
1014
|
+
? theme.success
|
|
1015
|
+
: tone === 'warn'
|
|
1016
|
+
? theme.warning
|
|
1017
|
+
: tone === 'error'
|
|
1018
|
+
? theme.error
|
|
1019
|
+
: tone === 'muted'
|
|
1020
|
+
? theme.ui.muted
|
|
1021
|
+
: theme.info;
|
|
1022
|
+
return `${theme.ui.muted(label)} ${colorizer(value)}`;
|
|
1023
|
+
}
|
|
1024
|
+
applyTone(text, tone) {
|
|
1025
|
+
switch (tone) {
|
|
1026
|
+
case 'success':
|
|
1027
|
+
return theme.success(text);
|
|
1028
|
+
case 'warn':
|
|
1029
|
+
return theme.warning(text);
|
|
1030
|
+
case 'error':
|
|
1031
|
+
return theme.error(text);
|
|
1032
|
+
case 'info':
|
|
1033
|
+
default:
|
|
1034
|
+
return theme.info(text);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
wrapSegments(segments, maxWidth) {
|
|
1038
|
+
const lines = [];
|
|
1039
|
+
const separator = theme.ui.muted(' | ');
|
|
1040
|
+
let current = '';
|
|
1041
|
+
for (const segment of segments) {
|
|
1042
|
+
const normalized = segment.trim();
|
|
1043
|
+
if (!normalized)
|
|
1044
|
+
continue;
|
|
1045
|
+
if (!current) {
|
|
1046
|
+
current = this.truncateLine(normalized, maxWidth);
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
const candidate = `${current}${separator}${normalized}`;
|
|
1050
|
+
if (this.visibleLength(candidate) <= maxWidth) {
|
|
1051
|
+
current = candidate;
|
|
1052
|
+
}
|
|
1053
|
+
else {
|
|
1054
|
+
lines.push(this.truncateLine(current, maxWidth));
|
|
1055
|
+
current = this.truncateLine(normalized, maxWidth);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
if (current) {
|
|
1059
|
+
lines.push(this.truncateLine(current, maxWidth));
|
|
1060
|
+
}
|
|
1061
|
+
return lines;
|
|
960
1062
|
}
|
|
961
1063
|
buildControlLines() {
|
|
962
1064
|
const lines = [];
|
|
@@ -1084,6 +1186,37 @@ export class UnifiedUIRenderer extends EventEmitter {
|
|
|
1084
1186
|
this.renderPrompt();
|
|
1085
1187
|
this.emitInputChange();
|
|
1086
1188
|
}
|
|
1189
|
+
captureInput(options = {}) {
|
|
1190
|
+
if (this.inputCapture) {
|
|
1191
|
+
return Promise.reject(new Error('Input capture already in progress'));
|
|
1192
|
+
}
|
|
1193
|
+
if (options.resetBuffer) {
|
|
1194
|
+
this.buffer = '';
|
|
1195
|
+
this.cursor = 0;
|
|
1196
|
+
this.inputRenderOffset = 0;
|
|
1197
|
+
this.resetSuggestions();
|
|
1198
|
+
this.renderPrompt();
|
|
1199
|
+
this.emitInputChange();
|
|
1200
|
+
}
|
|
1201
|
+
return new Promise((resolve, reject) => {
|
|
1202
|
+
this.inputCapture = {
|
|
1203
|
+
resolve,
|
|
1204
|
+
reject,
|
|
1205
|
+
options: {
|
|
1206
|
+
trim: options.trim !== false,
|
|
1207
|
+
allowEmpty: options.allowEmpty ?? false,
|
|
1208
|
+
},
|
|
1209
|
+
};
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
cancelInputCapture(reason) {
|
|
1213
|
+
if (!this.inputCapture) {
|
|
1214
|
+
return;
|
|
1215
|
+
}
|
|
1216
|
+
const capture = this.inputCapture;
|
|
1217
|
+
this.inputCapture = null;
|
|
1218
|
+
capture.reject?.(reason ?? new Error('Input capture cancelled'));
|
|
1219
|
+
}
|
|
1087
1220
|
// ------------ Helpers ------------
|
|
1088
1221
|
safeWidth() {
|
|
1089
1222
|
const cols = this.output.isTTY ? this.cols || 80 : 80;
|