centaurus-cli 2.9.3 → 2.9.5
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/cli-adapter.d.ts +74 -10
- package/dist/cli-adapter.d.ts.map +1 -1
- package/dist/cli-adapter.js +898 -244
- package/dist/cli-adapter.js.map +1 -1
- package/dist/commands/CommandParser.d.ts +1 -1
- package/dist/commands/CommandParser.d.ts.map +1 -1
- package/dist/commands/CommandParser.js +113 -0
- package/dist/commands/CommandParser.js.map +1 -1
- package/dist/config/slash-commands.d.ts +2 -0
- package/dist/config/slash-commands.d.ts.map +1 -1
- package/dist/config/slash-commands.js +28 -0
- package/dist/config/slash-commands.js.map +1 -1
- package/dist/context/context-manager.d.ts +7 -1
- package/dist/context/context-manager.d.ts.map +1 -1
- package/dist/context/context-manager.js +14 -1
- package/dist/context/context-manager.js.map +1 -1
- package/dist/context/handlers/docker-handler.d.ts +11 -0
- package/dist/context/handlers/docker-handler.d.ts.map +1 -1
- package/dist/context/handlers/docker-handler.js +159 -14
- package/dist/context/handlers/docker-handler.js.map +1 -1
- package/dist/context/handlers/ssh-handler.d.ts +20 -0
- package/dist/context/handlers/ssh-handler.d.ts.map +1 -1
- package/dist/context/handlers/ssh-handler.js +129 -1
- package/dist/context/handlers/ssh-handler.js.map +1 -1
- package/dist/context/subshell-handler.d.ts +15 -0
- package/dist/context/subshell-handler.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/services/ai-service-client.d.ts.map +1 -1
- package/dist/services/ai-service-client.js +33 -11
- package/dist/services/ai-service-client.js.map +1 -1
- package/dist/services/api-client.js +1 -1
- package/dist/services/api-client.js.map +1 -1
- package/dist/services/local-chat-storage.d.ts +3 -1
- package/dist/services/local-chat-storage.d.ts.map +1 -1
- package/dist/services/local-chat-storage.js +8 -3
- package/dist/services/local-chat-storage.js.map +1 -1
- package/dist/services/warpify-detector.d.ts +43 -0
- package/dist/services/warpify-detector.d.ts.map +1 -0
- package/dist/services/warpify-detector.js +203 -0
- package/dist/services/warpify-detector.js.map +1 -0
- package/dist/services/workflow-storage.d.ts +72 -0
- package/dist/services/workflow-storage.d.ts.map +1 -0
- package/dist/services/workflow-storage.js +239 -0
- package/dist/services/workflow-storage.js.map +1 -0
- package/dist/tools/command.d.ts.map +1 -1
- package/dist/tools/command.js +106 -38
- package/dist/tools/command.js.map +1 -1
- package/dist/tools/enter-remote-session.d.ts +13 -0
- package/dist/tools/enter-remote-session.d.ts.map +1 -0
- package/dist/tools/enter-remote-session.js +226 -0
- package/dist/tools/enter-remote-session.js.map +1 -0
- package/dist/tools/find-files.d.ts.map +1 -1
- package/dist/tools/find-files.js +9 -2
- package/dist/tools/find-files.js.map +1 -1
- package/dist/tools/grep-search.d.ts +104 -31
- package/dist/tools/grep-search.d.ts.map +1 -1
- package/dist/tools/grep-search.js +779 -431
- package/dist/tools/grep-search.js.map +1 -1
- package/dist/tools/workflow-tool.d.ts +11 -0
- package/dist/tools/workflow-tool.d.ts.map +1 -0
- package/dist/tools/workflow-tool.js +87 -0
- package/dist/tools/workflow-tool.js.map +1 -0
- package/dist/types/workflow.d.ts +110 -0
- package/dist/types/workflow.d.ts.map +1 -0
- package/dist/types/workflow.js +8 -0
- package/dist/types/workflow.js.map +1 -0
- package/dist/ui/components/App.d.ts +10 -1
- package/dist/ui/components/App.d.ts.map +1 -1
- package/dist/ui/components/App.js +135 -8
- package/dist/ui/components/App.js.map +1 -1
- package/dist/ui/components/Breadcrumbs.d.ts +4 -3
- package/dist/ui/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/ui/components/Breadcrumbs.js +80 -54
- package/dist/ui/components/Breadcrumbs.js.map +1 -1
- package/dist/ui/components/ConnectionStatusMessage.js +2 -2
- package/dist/ui/components/ConnectionStatusMessage.js.map +1 -1
- package/dist/ui/components/InputBox.d.ts +1 -0
- package/dist/ui/components/InputBox.d.ts.map +1 -1
- package/dist/ui/components/InputBox.js +226 -19
- package/dist/ui/components/InputBox.js.map +1 -1
- package/dist/ui/components/InteractiveShell.d.ts +4 -0
- package/dist/ui/components/InteractiveShell.d.ts.map +1 -1
- package/dist/ui/components/InteractiveShell.js +52 -15
- package/dist/ui/components/InteractiveShell.js.map +1 -1
- package/dist/ui/components/KeyboardHelp.d.ts.map +1 -1
- package/dist/ui/components/KeyboardHelp.js +14 -6
- package/dist/ui/components/KeyboardHelp.js.map +1 -1
- package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -1
- package/dist/ui/components/ToolExecutionMessage.js +165 -27
- package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
- package/dist/ui/components/WorkflowCreatorScreen.d.ts +25 -0
- package/dist/ui/components/WorkflowCreatorScreen.d.ts.map +1 -0
- package/dist/ui/components/WorkflowCreatorScreen.js +164 -0
- package/dist/ui/components/WorkflowCreatorScreen.js.map +1 -0
- package/dist/utils/ansi-encoder.d.ts.map +1 -1
- package/dist/utils/ansi-encoder.js +7 -0
- package/dist/utils/ansi-encoder.js.map +1 -1
- package/dist/utils/editor-utils.d.ts +9 -0
- package/dist/utils/editor-utils.d.ts.map +1 -1
- package/dist/utils/editor-utils.js +105 -0
- package/dist/utils/editor-utils.js.map +1 -1
- package/dist/utils/input-classifier.d.ts.map +1 -1
- package/dist/utils/input-classifier.js +2 -1
- package/dist/utils/input-classifier.js.map +1 -1
- package/dist/utils/terminal-output.d.ts +3 -1
- package/dist/utils/terminal-output.d.ts.map +1 -1
- package/dist/utils/terminal-output.js +138 -157
- package/dist/utils/terminal-output.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,71 +7,6 @@
|
|
|
7
7
|
* This module provides functions to correctly process such output so that only the
|
|
8
8
|
* final rendered state is preserved (not intermediate states that should be overwritten).
|
|
9
9
|
*/
|
|
10
|
-
/**
|
|
11
|
-
* Process backspace and carriage return characters to simulate terminal buffer behavior.
|
|
12
|
-
*
|
|
13
|
-
* This is critical for proper display of progress bars and spinners:
|
|
14
|
-
* - \x08 (backspace) moves cursor left
|
|
15
|
-
* - \r (carriage return) moves cursor to start of line (overwrites from beginning)
|
|
16
|
-
* - \n (newline) moves to next line
|
|
17
|
-
*
|
|
18
|
-
* @param input - String containing control characters
|
|
19
|
-
* @returns String with control characters applied (simulating terminal display)
|
|
20
|
-
*/
|
|
21
|
-
function processBackspaces(input) {
|
|
22
|
-
if (!input.includes('\x08') && !input.includes('\r'))
|
|
23
|
-
return input;
|
|
24
|
-
// Process the string character by character, simulating a terminal buffer
|
|
25
|
-
const lines = [];
|
|
26
|
-
let currentLine = '';
|
|
27
|
-
let cursorPos = 0;
|
|
28
|
-
for (let i = 0; i < input.length; i++) {
|
|
29
|
-
const char = input[i];
|
|
30
|
-
if (char === '\x08') {
|
|
31
|
-
// Backspace: move cursor left (but not past beginning)
|
|
32
|
-
if (cursorPos > 0) {
|
|
33
|
-
cursorPos--;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else if (char === '\r') {
|
|
37
|
-
// Carriage return: reset cursor to start of line
|
|
38
|
-
// This simulates progress bars that overwrite the same line
|
|
39
|
-
// DO NOT append \r to output - just reset cursor position
|
|
40
|
-
cursorPos = 0;
|
|
41
|
-
}
|
|
42
|
-
else if (char === '\n') {
|
|
43
|
-
// Newline: finalize current line and start new one
|
|
44
|
-
// Trim to cursor position to remove orphaned content after \r overwrites
|
|
45
|
-
if (cursorPos < currentLine.length) {
|
|
46
|
-
currentLine = currentLine.substring(0, cursorPos);
|
|
47
|
-
}
|
|
48
|
-
lines.push(currentLine);
|
|
49
|
-
currentLine = '';
|
|
50
|
-
cursorPos = 0;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
// Regular character: insert/overwrite at cursor position
|
|
54
|
-
if (cursorPos < currentLine.length) {
|
|
55
|
-
// Overwrite existing character
|
|
56
|
-
currentLine = currentLine.substring(0, cursorPos) + char + currentLine.substring(cursorPos + 1);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
// Append to line
|
|
60
|
-
currentLine += char;
|
|
61
|
-
}
|
|
62
|
-
cursorPos++;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Add any remaining content in the current line
|
|
66
|
-
if (currentLine.length > 0) {
|
|
67
|
-
// Trim to cursor position in case of trailing orphaned content
|
|
68
|
-
if (cursorPos < currentLine.length) {
|
|
69
|
-
currentLine = currentLine.substring(0, cursorPos);
|
|
70
|
-
}
|
|
71
|
-
lines.push(currentLine);
|
|
72
|
-
}
|
|
73
|
-
return lines.join('\n');
|
|
74
|
-
}
|
|
75
10
|
/**
|
|
76
11
|
* Process terminal output to properly handle carriage returns and ANSI sequences.
|
|
77
12
|
*
|
|
@@ -84,188 +19,234 @@ function processBackspaces(input) {
|
|
|
84
19
|
* @param raw - Raw terminal output with potential \r and ANSI sequences
|
|
85
20
|
* @returns Processed output with only the final rendered state
|
|
86
21
|
*/
|
|
87
|
-
export function processTerminalOutput(raw) {
|
|
22
|
+
export function processTerminalOutput(raw, options) {
|
|
88
23
|
if (!raw)
|
|
89
24
|
return '';
|
|
90
|
-
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
|
|
94
|
-
const SCREEN_COLS = 200; // Wide enough for most outputs
|
|
95
|
-
// Initialize screen buffer - array of strings representing each row
|
|
25
|
+
const SCREEN_ROWS = 500;
|
|
26
|
+
// const SCREEN_COLS = 200; // Dynamic columns not needed for array-based storage
|
|
27
|
+
// Initialize screen buffer - array of arrays of Cells
|
|
28
|
+
// We use a sparse approach: rows are created as needed
|
|
96
29
|
const screen = [];
|
|
30
|
+
// Ensure initial rows exist
|
|
97
31
|
for (let i = 0; i < SCREEN_ROWS; i++) {
|
|
98
|
-
screen[i] =
|
|
32
|
+
screen[i] = [];
|
|
99
33
|
}
|
|
100
34
|
let cursorRow = 0;
|
|
101
35
|
let cursorCol = 0;
|
|
102
|
-
let maxRowUsed = 0;
|
|
103
|
-
|
|
36
|
+
let maxRowUsed = 0;
|
|
37
|
+
let currentStyle = ''; // Current accumulated ANSI style sequence
|
|
38
|
+
// Pre-processing: Strip only non-SGR sequences that we don't handle
|
|
39
|
+
// We keep \x1b[...m (SGR) for colors
|
|
104
40
|
let input = raw
|
|
105
|
-
// OSC sequences
|
|
41
|
+
// OSC sequences
|
|
106
42
|
.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, '')
|
|
107
|
-
|
|
108
|
-
// Alternate screen buffer - we don't support alternate screens
|
|
43
|
+
// Alternate screen buffer
|
|
109
44
|
.replace(/\x1b\[\?(?:1049|47)[hl]/g, '')
|
|
110
|
-
// Hide/show cursor
|
|
45
|
+
// Hide/show cursor
|
|
111
46
|
.replace(/\x1b\[\?\d+[hl]/g, '')
|
|
112
47
|
// DEC private mode sequences
|
|
113
48
|
.replace(/\x1b\[\?[\d;]+[a-zA-Z]/g, '')
|
|
114
|
-
// Set/reset mode
|
|
49
|
+
// Set/reset mode (except potentially relevant ones, but mostly safe to strip for basic output)
|
|
115
50
|
.replace(/\x1b\[\d*[hl]/g, '')
|
|
116
|
-
// SGR (colors/styles) - strip for clean text output
|
|
117
|
-
.replace(/\x1b\[[\d;]*m/g, '')
|
|
118
|
-
.replace(/\x1b\[m/g, '')
|
|
119
|
-
// Cursor save/restore - we'll handle positioning manually
|
|
120
|
-
.replace(/\x1b\[[su]/g, '')
|
|
121
|
-
.replace(/\x1b[78]/g, '')
|
|
122
51
|
// Scroll up/down
|
|
123
52
|
.replace(/\x1b\[\d*[ST]/g, '')
|
|
124
53
|
// Character set designations
|
|
125
54
|
.replace(/\x1b[()#][0-9A-Za-z]/g, '')
|
|
126
|
-
|
|
127
|
-
// BEL and Form Feed
|
|
55
|
+
// BEL and Form Feed (ignore for layout)
|
|
128
56
|
.replace(/\x07/g, '')
|
|
129
57
|
.replace(/\x0C/g, '')
|
|
130
|
-
// DEL
|
|
58
|
+
// DEL
|
|
131
59
|
.replace(/\x7F/g, '');
|
|
132
|
-
//
|
|
60
|
+
// NOTE: We do NOT strip SGR codes (\x1b[...m) anymore!
|
|
133
61
|
let i = 0;
|
|
134
62
|
while (i < input.length) {
|
|
135
63
|
// Check for escape sequences
|
|
136
64
|
if (input[i] === '\x1b' && i + 1 < input.length && input[i + 1] === '[') {
|
|
137
|
-
// CSI sequence
|
|
65
|
+
// CSI sequence
|
|
138
66
|
let j = i + 2;
|
|
139
67
|
let params = '';
|
|
140
|
-
// Collect parameters (digits and semicolons)
|
|
141
68
|
while (j < input.length && /[\d;]/.test(input[j])) {
|
|
142
69
|
params += input[j];
|
|
143
70
|
j++;
|
|
144
71
|
}
|
|
145
|
-
// Get the command character
|
|
146
72
|
const cmd = j < input.length ? input[j] : '';
|
|
147
|
-
// Parse numeric parameters
|
|
148
73
|
const numbers = params.split(';').map(s => parseInt(s) || 0);
|
|
149
74
|
switch (cmd) {
|
|
150
|
-
case '
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
75
|
+
case 'm': // SGR - Select Graphic Rendition (Colors!)
|
|
76
|
+
if (params === '' || params === '0') {
|
|
77
|
+
currentStyle = ''; // Reset
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Accumulate style. Note: simplified handling.
|
|
81
|
+
// A real terminal emulator parses these deeper, but passing them through
|
|
82
|
+
// is often sufficient if we just append the new code.
|
|
83
|
+
// However, to keep it clean, we'll store the full sequence.
|
|
84
|
+
// For simplicity in this emulator, we just set the current style
|
|
85
|
+
// to the raw sequence found. If it's a composite (e.g. 1;31), it works.
|
|
86
|
+
// Ideally we merge with existing style, but resetting on each new code
|
|
87
|
+
// and blindly applying it works for most CLI outputs that set all attributes at once.
|
|
88
|
+
// BETTER APPROACH: Append to current style so distinct attributes (bold + red) work.
|
|
89
|
+
// If it's a reset (0), clear it.
|
|
90
|
+
if (numbers.includes(0)) {
|
|
91
|
+
currentStyle = '';
|
|
92
|
+
// Re-add non-reset codes if any? Complex.
|
|
93
|
+
// Let's assume 0 clears everything.
|
|
94
|
+
// If there are other codes after 0 (e.g. 0;31), we should apply them.
|
|
95
|
+
// Simple heuristic: just use the whole sequence as the style for now.
|
|
96
|
+
// It's not perfect but handles 90% of cases.
|
|
97
|
+
currentStyle = `\x1b[${params}m`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// It's a color or style addition.
|
|
101
|
+
// If we already have a style, we append this one (cascading).
|
|
102
|
+
// But naively appending can make strings huge.
|
|
103
|
+
// Let's just use the latest sequence for this cell,
|
|
104
|
+
// OR, if we want to be smart, we only keep the active SGR sequence.
|
|
105
|
+
// Since we are storing "style" per cell, we can just store the
|
|
106
|
+
// ANSI escape code string needed to produce this style.
|
|
107
|
+
currentStyle += `\x1b[${params}m`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case 'H': // Cursor Home
|
|
112
|
+
case 'f':
|
|
113
|
+
cursorRow = Math.max(0, (numbers[0] || 1) - 1);
|
|
154
114
|
cursorCol = Math.max(0, (numbers[1] || 1) - 1);
|
|
155
115
|
break;
|
|
156
|
-
case 'A': //
|
|
116
|
+
case 'A': // Up
|
|
157
117
|
cursorRow = Math.max(0, cursorRow - (numbers[0] || 1));
|
|
158
118
|
break;
|
|
159
|
-
case 'B': //
|
|
119
|
+
case 'B': // Down
|
|
160
120
|
cursorRow = cursorRow + (numbers[0] || 1);
|
|
161
121
|
break;
|
|
162
|
-
case 'C': //
|
|
122
|
+
case 'C': // Right
|
|
163
123
|
cursorCol = cursorCol + (numbers[0] || 1);
|
|
164
124
|
break;
|
|
165
|
-
case 'D': //
|
|
125
|
+
case 'D': // Left
|
|
166
126
|
cursorCol = Math.max(0, cursorCol - (numbers[0] || 1));
|
|
167
127
|
break;
|
|
168
|
-
case '
|
|
169
|
-
// 0 = cursor to end, 1 = start to cursor, 2 = entire screen, 3 = scrollback
|
|
170
|
-
// For our purposes, just ignore - we want to keep all content
|
|
171
|
-
break;
|
|
172
|
-
case 'K': // Erase in line
|
|
128
|
+
case 'K': // Erase Line
|
|
173
129
|
{
|
|
174
130
|
const mode = numbers[0] || 0;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
screen[cursorRow]
|
|
131
|
+
if (!screen[cursorRow])
|
|
132
|
+
screen[cursorRow] = [];
|
|
133
|
+
if (mode === 0) { // Cursor to end
|
|
134
|
+
screen[cursorRow].splice(cursorCol);
|
|
179
135
|
}
|
|
180
|
-
else if (mode === 1) {
|
|
181
|
-
|
|
182
|
-
|
|
136
|
+
else if (mode === 1) { // Start to cursor
|
|
137
|
+
for (let k = 0; k <= cursorCol; k++) {
|
|
138
|
+
if (k < screen[cursorRow].length) {
|
|
139
|
+
screen[cursorRow][k] = { char: ' ', style: '' };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
183
142
|
}
|
|
184
|
-
else if (mode === 2) {
|
|
185
|
-
|
|
186
|
-
screen[cursorRow] = '';
|
|
143
|
+
else if (mode === 2) { // Entire line
|
|
144
|
+
screen[cursorRow] = [];
|
|
187
145
|
}
|
|
188
146
|
}
|
|
189
147
|
break;
|
|
190
|
-
case '
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const line = screen[cursorRow] || '';
|
|
194
|
-
// Replace 'count' characters with spaces starting at cursor
|
|
195
|
-
screen[cursorRow] = line.substring(0, cursorCol) +
|
|
196
|
-
' '.repeat(count) +
|
|
197
|
-
line.substring(cursorCol + count);
|
|
198
|
-
}
|
|
148
|
+
case 'J': // Erase Display
|
|
149
|
+
// Usually ignored in this simple processor to preserve history,
|
|
150
|
+
// but technically should clear screen. Sticking to ignore for now.
|
|
199
151
|
break;
|
|
200
152
|
default:
|
|
201
|
-
//
|
|
153
|
+
// Ignore other CSI codes
|
|
202
154
|
break;
|
|
203
155
|
}
|
|
204
|
-
i = j + 1;
|
|
156
|
+
i = j + 1;
|
|
205
157
|
continue;
|
|
206
158
|
}
|
|
207
|
-
// Handle control characters
|
|
208
159
|
const char = input[i];
|
|
209
160
|
if (char === '\r') {
|
|
210
|
-
// Carriage return - move to start of line
|
|
211
161
|
cursorCol = 0;
|
|
212
162
|
}
|
|
213
163
|
else if (char === '\n') {
|
|
214
|
-
// Newline - move to next line
|
|
215
164
|
cursorRow++;
|
|
216
165
|
cursorCol = 0;
|
|
217
166
|
}
|
|
218
|
-
else if (char === '\x08') {
|
|
219
|
-
|
|
220
|
-
if (cursorCol > 0) {
|
|
167
|
+
else if (char === '\x08') { // Backspace
|
|
168
|
+
if (cursorCol > 0)
|
|
221
169
|
cursorCol--;
|
|
222
|
-
}
|
|
223
170
|
}
|
|
224
171
|
else if (char === '\t') {
|
|
225
|
-
// Tab - move to next tab stop (every 8 columns)
|
|
226
172
|
cursorCol = Math.floor(cursorCol / 8 + 1) * 8;
|
|
227
173
|
}
|
|
228
174
|
else if (char >= ' ' || char === '\x00') {
|
|
229
|
-
// Skip null bytes
|
|
230
175
|
if (char === '\x00') {
|
|
231
176
|
i++;
|
|
232
177
|
continue;
|
|
233
178
|
}
|
|
234
|
-
//
|
|
235
|
-
// Ensure we have enough rows
|
|
179
|
+
// Ensure row exists
|
|
236
180
|
while (cursorRow >= screen.length) {
|
|
237
|
-
screen.push(
|
|
181
|
+
screen.push([]);
|
|
238
182
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
183
|
+
if (!screen[cursorRow])
|
|
184
|
+
screen[cursorRow] = [];
|
|
185
|
+
// Pad with spaces if needed
|
|
186
|
+
while (screen[cursorRow].length < cursorCol) {
|
|
187
|
+
screen[cursorRow].push({ char: ' ', style: '' });
|
|
243
188
|
}
|
|
244
|
-
// Write
|
|
245
|
-
|
|
246
|
-
screen[cursorRow] = currentLine.substring(0, cursorCol) + char + currentLine.substring(cursorCol + 1);
|
|
189
|
+
// Write cell with current style
|
|
190
|
+
screen[cursorRow][cursorCol] = { char: char, style: currentStyle };
|
|
247
191
|
cursorCol++;
|
|
248
|
-
|
|
249
|
-
if (cursorRow > maxRowUsed) {
|
|
192
|
+
if (cursorRow > maxRowUsed)
|
|
250
193
|
maxRowUsed = cursorRow;
|
|
251
|
-
}
|
|
252
194
|
}
|
|
253
|
-
// Skip other control characters (0x01-0x1A except those handled above)
|
|
254
195
|
i++;
|
|
255
196
|
}
|
|
256
|
-
//
|
|
197
|
+
// ... (previous code)
|
|
198
|
+
// Render to string with optimization
|
|
257
199
|
const outputLines = [];
|
|
200
|
+
let lastRenderedStyle = '';
|
|
258
201
|
for (let row = 0; row <= maxRowUsed; row++) {
|
|
259
|
-
|
|
202
|
+
let lineStr = '';
|
|
203
|
+
const rowCells = screen[row] || [];
|
|
204
|
+
// Ensure we process up to cursor column if this is the cursor row
|
|
205
|
+
// This ensures the cursor is drawn even if it's past the end of text
|
|
206
|
+
const effectiveLength = (options?.highlightCursor && row === cursorRow)
|
|
207
|
+
? Math.max(rowCells.length, cursorCol + 1)
|
|
208
|
+
: rowCells.length;
|
|
209
|
+
for (let col = 0; col < effectiveLength; col++) {
|
|
210
|
+
let cell = rowCells[col] || { char: ' ', style: '' };
|
|
211
|
+
// Apply cursor highlighting
|
|
212
|
+
if (options?.highlightCursor && row === cursorRow && col === cursorCol) {
|
|
213
|
+
// Invert colors for cursor
|
|
214
|
+
// Standard ANSI invert is 7
|
|
215
|
+
// We append it to the current style
|
|
216
|
+
// If style is empty, it becomes \x1b[7m
|
|
217
|
+
// If style is \x1b[31m, it becomes \x1b[31m\x1b[7m
|
|
218
|
+
// We create a temporary cell for rendering
|
|
219
|
+
cell = {
|
|
220
|
+
char: cell.char || ' ', // Ensure visible char for cursor block
|
|
221
|
+
style: cell.style + '\x1b[7m'
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
// If style changed, emit ANSI code
|
|
225
|
+
if (cell.style !== lastRenderedStyle) {
|
|
226
|
+
if (cell.style === '') {
|
|
227
|
+
lineStr += '\x1b[0m';
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
lineStr += '\x1b[0m' + cell.style;
|
|
231
|
+
}
|
|
232
|
+
lastRenderedStyle = cell.style;
|
|
233
|
+
}
|
|
234
|
+
lineStr += cell.char;
|
|
235
|
+
}
|
|
236
|
+
// Reset at end of line
|
|
237
|
+
if (lastRenderedStyle !== '') {
|
|
238
|
+
lineStr += '\x1b[0m';
|
|
239
|
+
lastRenderedStyle = '';
|
|
240
|
+
}
|
|
241
|
+
outputLines.push(lineStr);
|
|
260
242
|
}
|
|
261
|
-
// Join lines and clean up
|
|
262
243
|
let result = outputLines.join('\n');
|
|
263
|
-
//
|
|
244
|
+
// Cleanup
|
|
264
245
|
result = result.replace(/\n{3,}/g, '\n\n');
|
|
265
|
-
// Remove leading empty lines
|
|
266
246
|
result = result.replace(/^\n+/, '');
|
|
267
|
-
// Trim trailing whitespace
|
|
268
247
|
result = result.trimEnd();
|
|
248
|
+
// Ensure final reset
|
|
249
|
+
result += '\x1b[0m';
|
|
269
250
|
return result;
|
|
270
251
|
}
|
|
271
252
|
//# sourceMappingURL=terminal-output.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-output.js","sourceRoot":"","sources":["../../src/utils/terminal-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"terminal-output.js","sourceRoot":"","sources":["../../src/utils/terminal-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAW,EAAE,OAAuC;IACtF,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IAUpB,MAAM,WAAW,GAAG,GAAG,CAAC;IACxB,iFAAiF;IAEjF,sDAAsD;IACtD,uDAAuD;IACvD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,4BAA4B;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;QACnC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,SAA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