@causyne/agent 1.20.9 → 1.20.11
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/package.json +2 -1
- package/src/agentLoop.js +127 -72
- package/src/agentLoop.ts +137 -75
- package/src/browser/causyneBrowser.js +36 -0
- package/src/browser/causyneBrowser.ts +36 -1
- package/src/commands.js +25 -0
- package/src/contextManager.js +16 -0
- package/src/providers/antigravity.js +63 -11
- package/src/providers/antigravity.ts +62 -12
- package/src/provisioning/capabilityProvisioner.js +2 -7
- package/src/provisioning/npmInstall.js +19 -0
- package/src/provisioning/npmInstall.ts +19 -0
- package/src/smartToolsUse.js +20 -0
- package/src/smartToolsUse.ts +21 -0
- package/src/stallGuard.js +347 -0
- package/src/stallGuard.ts +423 -0
- package/src/tools/browserAutomator.js +3 -3
- package/src/tools/browserAutomator.ts +3 -3
- package/src/tools/fsRead.js +91 -80
- package/src/tools/fsRead.ts +125 -0
- package/src/tools/peerAgent.js +1 -1
- package/src/tools/peerAgent.ts +1 -1
- package/src/tools/screenshot.js +5 -1
- package/src/tools/screenshot.ts +5 -1
- package/src/tools/toolScanner.js +19 -0
- package/src/tools/toolScanner.ts +17 -0
- package/src/tools/toolSelfRepair.js +63 -1
- package/src/tools/toolSelfRepair.ts +61 -1
- package/src/tools/visionInspector.js +80 -142
- package/src/tools/visionInspector.ts +110 -0
- package/src/tui/chatboxClipboard.js +152 -0
- package/src/tui/chatboxClipboard.ts +201 -0
- package/src/tui/clipboardSync.js +38 -7
- package/src/tui/clipboardSync.ts +39 -7
- package/src/tui/codeProgress.js +89 -18
- package/src/tui/codeProgress.ts +102 -17
- package/src/tui/codeStreamRenderer.js +7 -2
- package/src/tui/codeStreamRenderer.ts +7 -2
- package/src/tui/composerControls.js +9 -0
- package/src/tui/composerControls.ts +9 -0
- package/src/tui/dialogs.js +8 -3
- package/src/tui/diff.d.ts +1 -0
- package/src/tui/lineEditor.js +166 -14
- package/src/tui/mouseHover.js +6 -2
- package/src/tui/mouseHover.ts +7 -2
- package/src/tui/prompt.js +96 -19
- package/src/tui/stageSurface.js +3 -1
package/src/tui/lineEditor.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
// Pure Node. No dependency, no shell.
|
|
16
16
|
|
|
17
17
|
import { visibleWidth } from './text.js';
|
|
18
|
+
import { writeClipboardSync, readClipboardSync } from './clipboardSync.js';
|
|
18
19
|
|
|
19
20
|
/** Split into code points, so one emoji is one editable unit. */
|
|
20
21
|
function toCodePoints(text) {
|
|
@@ -25,10 +26,21 @@ function toCodePoints(text) {
|
|
|
25
26
|
// path segment and a flag should each move as one unit.
|
|
26
27
|
const WORD_CHARACTER = /[\p{L}\p{N}_-]/u;
|
|
27
28
|
|
|
29
|
+
function isInsideRange(lineIdx, colIdx, { start, end }) {
|
|
30
|
+
if (lineIdx < start.line || lineIdx > end.line) return false;
|
|
31
|
+
if (lineIdx === start.line && lineIdx === end.line) {
|
|
32
|
+
return colIdx >= start.col && colIdx < end.col;
|
|
33
|
+
}
|
|
34
|
+
if (lineIdx === start.line) return colIdx >= start.col;
|
|
35
|
+
if (lineIdx === end.line) return colIdx < end.col;
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
export class LineEditor {
|
|
29
40
|
constructor(initial = '') {
|
|
30
41
|
this.setText(initial);
|
|
31
42
|
this.killRing = '';
|
|
43
|
+
this.selectionAnchor = null;
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
// -------------------------------------------------------------------------
|
|
@@ -40,6 +52,7 @@ export class LineEditor {
|
|
|
40
52
|
if (this.lines.length === 0) this.lines = [[]];
|
|
41
53
|
this.line = this.lines.length - 1;
|
|
42
54
|
this.col = this.lines[this.line].length;
|
|
55
|
+
this.selectionAnchor = null;
|
|
43
56
|
}
|
|
44
57
|
|
|
45
58
|
getText() {
|
|
@@ -50,15 +63,77 @@ export class LineEditor {
|
|
|
50
63
|
return this.lines.length === 1 && this.lines[0].length === 0;
|
|
51
64
|
}
|
|
52
65
|
|
|
66
|
+
get hasSelection() {
|
|
67
|
+
return Boolean(
|
|
68
|
+
this.selectionAnchor &&
|
|
69
|
+
(this.selectionAnchor.line !== this.line || this.selectionAnchor.col !== this.col)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getSelectionRange() {
|
|
74
|
+
if (!this.hasSelection || !this.selectionAnchor) return null;
|
|
75
|
+
const a = this.selectionAnchor;
|
|
76
|
+
const b = { line: this.line, col: this.col };
|
|
77
|
+
if (a.line < b.line || (a.line === b.line && a.col <= b.col)) {
|
|
78
|
+
return { start: { line: a.line, col: a.col }, end: { line: b.line, col: b.col } };
|
|
79
|
+
}
|
|
80
|
+
return { start: { line: b.line, col: b.col }, end: { line: a.line, col: a.col } };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getSelectedText() {
|
|
84
|
+
const range = this.getSelectionRange();
|
|
85
|
+
if (!range) return '';
|
|
86
|
+
const { start, end } = range;
|
|
87
|
+
if (start.line === end.line) {
|
|
88
|
+
return this.lines[start.line].slice(start.col, end.col).join('');
|
|
89
|
+
}
|
|
90
|
+
const parts = [];
|
|
91
|
+
parts.push(this.lines[start.line].slice(start.col).join(''));
|
|
92
|
+
for (let i = start.line + 1; i < end.line; i++) {
|
|
93
|
+
parts.push(this.lines[i].join(''));
|
|
94
|
+
}
|
|
95
|
+
parts.push(this.lines[end.line].slice(0, end.col).join(''));
|
|
96
|
+
return parts.join('\n');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
clearSelection() {
|
|
100
|
+
this.selectionAnchor = null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
deleteSelection() {
|
|
104
|
+
const range = this.getSelectionRange();
|
|
105
|
+
if (!range) return false;
|
|
106
|
+
const { start, end } = range;
|
|
107
|
+
const firstLine = this.lines[start.line].slice(0, start.col);
|
|
108
|
+
const lastLine = this.lines[end.line].slice(end.col);
|
|
109
|
+
const merged = firstLine.concat(lastLine);
|
|
110
|
+
this.lines.splice(start.line, end.line - start.line + 1, merged);
|
|
111
|
+
if (this.lines.length === 0) this.lines = [[]];
|
|
112
|
+
this.line = start.line;
|
|
113
|
+
this.col = start.col;
|
|
114
|
+
this.selectionAnchor = null;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
selectAll() {
|
|
119
|
+
if (this.isEmpty) return;
|
|
120
|
+
this.selectionAnchor = { line: 0, col: 0 };
|
|
121
|
+
this.line = this.lines.length - 1;
|
|
122
|
+
this.col = this.lines[this.line].length;
|
|
123
|
+
}
|
|
124
|
+
|
|
53
125
|
clear() {
|
|
54
126
|
this.lines = [[]];
|
|
55
127
|
this.line = 0;
|
|
56
128
|
this.col = 0;
|
|
129
|
+
this.selectionAnchor = null;
|
|
57
130
|
}
|
|
58
131
|
|
|
59
132
|
/** Insert text at the cursor. Embedded newlines split the line, as a paste does. */
|
|
60
133
|
insert(text) {
|
|
61
|
-
|
|
134
|
+
if (this.hasSelection) this.deleteSelection();
|
|
135
|
+
const normalized = String(text == null ? '' : text).replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
136
|
+
const parts = normalized.split('\n');
|
|
62
137
|
const current = this.lines[this.line];
|
|
63
138
|
const before = current.slice(0, this.col);
|
|
64
139
|
const after = current.slice(this.col);
|
|
@@ -80,6 +155,7 @@ export class LineEditor {
|
|
|
80
155
|
}
|
|
81
156
|
|
|
82
157
|
newline() {
|
|
158
|
+
if (this.hasSelection) this.deleteSelection();
|
|
83
159
|
const current = this.lines[this.line];
|
|
84
160
|
const before = current.slice(0, this.col);
|
|
85
161
|
const after = current.slice(this.col);
|
|
@@ -89,6 +165,10 @@ export class LineEditor {
|
|
|
89
165
|
}
|
|
90
166
|
|
|
91
167
|
backspace() {
|
|
168
|
+
if (this.hasSelection) {
|
|
169
|
+
this.deleteSelection();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
92
172
|
if (this.col > 0) {
|
|
93
173
|
this.lines[this.line].splice(this.col - 1, 1);
|
|
94
174
|
this.col -= 1;
|
|
@@ -103,6 +183,10 @@ export class LineEditor {
|
|
|
103
183
|
}
|
|
104
184
|
|
|
105
185
|
deleteForward() {
|
|
186
|
+
if (this.hasSelection) {
|
|
187
|
+
this.deleteSelection();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
106
190
|
const current = this.lines[this.line];
|
|
107
191
|
if (this.col < current.length) {
|
|
108
192
|
current.splice(this.col, 1);
|
|
@@ -117,45 +201,86 @@ export class LineEditor {
|
|
|
117
201
|
// Movement
|
|
118
202
|
// -------------------------------------------------------------------------
|
|
119
203
|
|
|
120
|
-
|
|
204
|
+
_trackSelection(extend) {
|
|
205
|
+
if (extend) {
|
|
206
|
+
if (!this.selectionAnchor) {
|
|
207
|
+
this.selectionAnchor = { line: this.line, col: this.col };
|
|
208
|
+
}
|
|
209
|
+
} else if (this.selectionAnchor) {
|
|
210
|
+
this.selectionAnchor = null;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
moveTo(line, col, extend = false) {
|
|
215
|
+
this._trackSelection(extend);
|
|
216
|
+
this.line = Math.max(0, Math.min(this.lines.length - 1, line));
|
|
217
|
+
this.col = Math.max(0, Math.min(this.lines[this.line].length, col));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
moveLeft(extend = false) {
|
|
221
|
+
this._trackSelection(extend);
|
|
121
222
|
if (this.col > 0) { this.col -= 1; return; }
|
|
122
223
|
if (this.line > 0) { this.line -= 1; this.col = this.lines[this.line].length; }
|
|
123
224
|
}
|
|
124
225
|
|
|
125
|
-
moveRight() {
|
|
226
|
+
moveRight(extend = false) {
|
|
227
|
+
this._trackSelection(extend);
|
|
126
228
|
if (this.col < this.lines[this.line].length) { this.col += 1; return; }
|
|
127
229
|
if (this.line < this.lines.length - 1) { this.line += 1; this.col = 0; }
|
|
128
230
|
}
|
|
129
231
|
|
|
130
|
-
moveUp() {
|
|
131
|
-
|
|
232
|
+
moveUp(extend = false) {
|
|
233
|
+
this._trackSelection(extend);
|
|
234
|
+
if (this.line === 0) {
|
|
235
|
+
if (extend) this.col = 0;
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
132
238
|
this.line -= 1;
|
|
133
239
|
this.col = Math.min(this.col, this.lines[this.line].length);
|
|
134
240
|
return true;
|
|
135
241
|
}
|
|
136
242
|
|
|
137
|
-
moveDown() {
|
|
138
|
-
|
|
243
|
+
moveDown(extend = false) {
|
|
244
|
+
this._trackSelection(extend);
|
|
245
|
+
if (this.line >= this.lines.length - 1) {
|
|
246
|
+
if (extend) this.col = this.lines[this.line].length;
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
139
249
|
this.line += 1;
|
|
140
250
|
this.col = Math.min(this.col, this.lines[this.line].length);
|
|
141
251
|
return true;
|
|
142
252
|
}
|
|
143
253
|
|
|
144
|
-
moveHome(
|
|
145
|
-
|
|
254
|
+
moveHome(extend = false) {
|
|
255
|
+
this._trackSelection(extend);
|
|
256
|
+
this.col = 0;
|
|
257
|
+
}
|
|
146
258
|
|
|
147
|
-
|
|
259
|
+
moveEnd(extend = false) {
|
|
260
|
+
this._trackSelection(extend);
|
|
261
|
+
this.col = this.lines[this.line].length;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
moveWordLeft(extend = false) {
|
|
265
|
+
this._trackSelection(extend);
|
|
148
266
|
const line = this.lines[this.line];
|
|
149
|
-
if (this.col === 0) {
|
|
267
|
+
if (this.col === 0) {
|
|
268
|
+
if (this.line > 0) { this.line -= 1; this.col = this.lines[this.line].length; }
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
150
271
|
let index = this.col;
|
|
151
272
|
while (index > 0 && !WORD_CHARACTER.test(line[index - 1])) index -= 1;
|
|
152
273
|
while (index > 0 && WORD_CHARACTER.test(line[index - 1])) index -= 1;
|
|
153
274
|
this.col = index;
|
|
154
275
|
}
|
|
155
276
|
|
|
156
|
-
moveWordRight() {
|
|
277
|
+
moveWordRight(extend = false) {
|
|
278
|
+
this._trackSelection(extend);
|
|
157
279
|
const line = this.lines[this.line];
|
|
158
|
-
if (this.col === line.length) {
|
|
280
|
+
if (this.col === line.length) {
|
|
281
|
+
if (this.line < this.lines.length - 1) { this.line += 1; this.col = 0; }
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
159
284
|
let index = this.col;
|
|
160
285
|
while (index < line.length && !WORD_CHARACTER.test(line[index])) index += 1;
|
|
161
286
|
while (index < line.length && WORD_CHARACTER.test(line[index])) index += 1;
|
|
@@ -168,27 +293,52 @@ export class LineEditor {
|
|
|
168
293
|
// -------------------------------------------------------------------------
|
|
169
294
|
|
|
170
295
|
killToEnd() {
|
|
296
|
+
if (this.hasSelection) {
|
|
297
|
+
this.killRing = this.getSelectedText();
|
|
298
|
+
this.deleteSelection();
|
|
299
|
+
if (this.killRing) writeClipboardSync(this.killRing);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
171
302
|
const line = this.lines[this.line];
|
|
172
303
|
this.killRing = line.slice(this.col).join('');
|
|
173
304
|
this.lines[this.line] = line.slice(0, this.col);
|
|
305
|
+
if (this.killRing) writeClipboardSync(this.killRing);
|
|
174
306
|
}
|
|
175
307
|
|
|
176
308
|
killToStart() {
|
|
309
|
+
if (this.hasSelection) {
|
|
310
|
+
this.killRing = this.getSelectedText();
|
|
311
|
+
this.deleteSelection();
|
|
312
|
+
if (this.killRing) writeClipboardSync(this.killRing);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
177
315
|
const line = this.lines[this.line];
|
|
178
316
|
this.killRing = line.slice(0, this.col).join('');
|
|
179
317
|
this.lines[this.line] = line.slice(this.col);
|
|
180
318
|
this.col = 0;
|
|
319
|
+
if (this.killRing) writeClipboardSync(this.killRing);
|
|
181
320
|
}
|
|
182
321
|
|
|
183
322
|
killWordLeft() {
|
|
323
|
+
if (this.hasSelection) {
|
|
324
|
+
this.killRing = this.getSelectedText();
|
|
325
|
+
this.deleteSelection();
|
|
326
|
+
if (this.killRing) writeClipboardSync(this.killRing);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
184
329
|
const start = this.col;
|
|
185
330
|
this.moveWordLeft();
|
|
186
331
|
const line = this.lines[this.line];
|
|
187
332
|
this.killRing = line.slice(this.col, start).join('');
|
|
188
333
|
line.splice(this.col, start - this.col);
|
|
334
|
+
if (this.killRing) writeClipboardSync(this.killRing);
|
|
189
335
|
}
|
|
190
336
|
|
|
191
337
|
yank() {
|
|
338
|
+
if (!this.killRing) {
|
|
339
|
+
const clip = readClipboardSync();
|
|
340
|
+
if (clip) this.killRing = clip;
|
|
341
|
+
}
|
|
192
342
|
if (this.killRing) this.insert(this.killRing);
|
|
193
343
|
}
|
|
194
344
|
|
|
@@ -209,6 +359,7 @@ export class LineEditor {
|
|
|
209
359
|
const rows = [];
|
|
210
360
|
let cursorRow = 0;
|
|
211
361
|
let cursorCol = 0;
|
|
362
|
+
const range = this.getSelectionRange();
|
|
212
363
|
|
|
213
364
|
for (let index = 0; index < this.lines.length; index++) {
|
|
214
365
|
const prefix = index === 0 ? '' : continuation;
|
|
@@ -240,7 +391,8 @@ export class LineEditor {
|
|
|
240
391
|
cursorCol = prefixWidth;
|
|
241
392
|
}
|
|
242
393
|
}
|
|
243
|
-
|
|
394
|
+
const isSelected = range ? isInsideRange(index, position, range) : false;
|
|
395
|
+
row += isSelected ? `\x1b[7m${character}\x1b[27m` : character;
|
|
244
396
|
used += charWidth;
|
|
245
397
|
}
|
|
246
398
|
|
package/src/tui/mouseHover.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Terminal-wide motion reports (?1003h) allow hover feedback, but hijack native mouse selection.
|
|
3
|
+
* Disabled by default so users can freely select, drag, and copy text in the terminal.
|
|
4
|
+
* Opt-in via CAUSYNE_MOUSE_HOVER=1.
|
|
5
|
+
*/
|
|
2
6
|
export function mouseHoverTracking(enabled, env = process.env) {
|
|
3
|
-
if (String(env.CAUSYNE_MOUSE_HOVER ?? '
|
|
7
|
+
if (String(env.CAUSYNE_MOUSE_HOVER ?? '0') !== '1')
|
|
4
8
|
return '';
|
|
5
9
|
return enabled ? '\x1b[?1003h' : '\x1b[?1003l';
|
|
6
10
|
}
|
package/src/tui/mouseHover.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Terminal-wide motion reports (?1003h) allow hover feedback, but hijack native mouse selection.
|
|
3
|
+
* Disabled by default so users can freely select, drag, and copy text in the terminal.
|
|
4
|
+
* Opt-in via CAUSYNE_MOUSE_HOVER=1.
|
|
5
|
+
*/
|
|
2
6
|
export function mouseHoverTracking(enabled: boolean, env: NodeJS.ProcessEnv = process.env): string {
|
|
3
|
-
if (String(env.CAUSYNE_MOUSE_HOVER ?? '
|
|
7
|
+
if (String(env.CAUSYNE_MOUSE_HOVER ?? '0') !== '1') return '';
|
|
4
8
|
return enabled ? '\x1b[?1003h' : '\x1b[?1003l';
|
|
5
9
|
}
|
|
10
|
+
|
package/src/tui/prompt.js
CHANGED
|
@@ -28,7 +28,7 @@ import { pickExample, fitHints } from './banner.js';
|
|
|
28
28
|
import { panelRows } from './overlay.js';
|
|
29
29
|
import { commandPalette, skillPicker, ApprovalLayer, DecisionLayer, ConfirmLayer, HomeLayer, TextLayer } from './dialogs.js';
|
|
30
30
|
import { describeTool } from './toolDisplay.js';
|
|
31
|
-
import { readClipboardSync } from './clipboardSync.js';
|
|
31
|
+
import { readClipboardSync, writeClipboardSync } from './clipboardSync.js';
|
|
32
32
|
import { handleViewportWheel, handleScrollbarMouse } from './scrollInteraction.js';
|
|
33
33
|
import { centerRows, sessionRows, dialogWidth, dialogHeight } from './layout.js';
|
|
34
34
|
import { settleStageResize } from './resizeRecovery.js';
|
|
@@ -690,17 +690,15 @@ export class ChatPrompt {
|
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
if (key.ctrl && key.name === 'c') {
|
|
693
|
-
// A modal owns the screen, so ctrl+c must dismiss THAT before it touches
|
|
694
|
-
// the turn behind it. closeLayer() answers false, which is what makes
|
|
695
|
-
// this safe: the pending approval resolves as a denial.
|
|
696
|
-
//
|
|
697
|
-
// It shipped the other way round. With an approval up, ctrl+c fell
|
|
698
|
-
// straight through to handleCtrlC(), saw `busy`, and interrupted the
|
|
699
|
-
// turn — while the modal stayed on screen and its promise was never
|
|
700
|
-
// resolved. The loop then waited forever for an answer that could no
|
|
701
|
-
// longer be given, which is why ctrl+c "did nothing" and only escape
|
|
702
|
-
// ever got the user out.
|
|
703
693
|
if (this.layer) { this.closeLayer(); return; }
|
|
694
|
+
if (this.editor.hasSelection) {
|
|
695
|
+
const text = this.editor.getSelectedText();
|
|
696
|
+
writeClipboardSync(text);
|
|
697
|
+
this.editor.killRing = text;
|
|
698
|
+
this.notice = `copied selection (${text.length} chars) to clipboard`;
|
|
699
|
+
this.scheduleDraw();
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
704
702
|
return this.handleCtrlC();
|
|
705
703
|
}
|
|
706
704
|
if (key.ctrl && key.name === 'd' && this.editor.isEmpty) return this.onExit();
|
|
@@ -765,12 +763,22 @@ export class ChatPrompt {
|
|
|
765
763
|
if (key.alt) this.editor.killWordLeft(); else this.editor.backspace();
|
|
766
764
|
return this.refreshCompletion();
|
|
767
765
|
case 'delete': this.editor.deleteForward(); return this.refreshCompletion();
|
|
768
|
-
case 'left': return key.ctrl || key.alt ? this.editor.moveWordLeft() : this.editor.moveLeft();
|
|
769
|
-
case 'right': return key.ctrl || key.alt ? this.editor.moveWordRight() : this.editor.moveRight();
|
|
770
|
-
case 'home': return this.editor.moveHome();
|
|
771
|
-
case 'end': return this.editor.moveEnd();
|
|
772
|
-
case 'up':
|
|
773
|
-
|
|
766
|
+
case 'left': return (key.ctrl || key.alt) ? this.editor.moveWordLeft(Boolean(key.shift)) : this.editor.moveLeft(Boolean(key.shift));
|
|
767
|
+
case 'right': return (key.ctrl || key.alt) ? this.editor.moveWordRight(Boolean(key.shift)) : this.editor.moveRight(Boolean(key.shift));
|
|
768
|
+
case 'home': return this.editor.moveHome(Boolean(key.shift));
|
|
769
|
+
case 'end': return this.editor.moveEnd(Boolean(key.shift));
|
|
770
|
+
case 'up':
|
|
771
|
+
if (key.shift) return this.editor.moveUp(true);
|
|
772
|
+
return this.historyOrMove(-1);
|
|
773
|
+
case 'down':
|
|
774
|
+
if (key.shift) return this.editor.moveDown(true);
|
|
775
|
+
return this.historyOrMove(1);
|
|
776
|
+
case 'pageup':
|
|
777
|
+
if (key.shift) { this.editor.moveHome(true); this.editor.line = 0; return; }
|
|
778
|
+
break;
|
|
779
|
+
case 'pagedown':
|
|
780
|
+
if (key.shift) { this.editor.moveEnd(true); this.editor.line = this.editor.lines.length - 1; return; }
|
|
781
|
+
break;
|
|
774
782
|
case 'char': this.editor.insert(key.text); return this.refreshCompletion();
|
|
775
783
|
default: break;
|
|
776
784
|
}
|
|
@@ -783,6 +791,18 @@ export class ChatPrompt {
|
|
|
783
791
|
case 'u': return this.editor.killToStart();
|
|
784
792
|
case 'w': this.editor.killWordLeft(); return this.refreshCompletion();
|
|
785
793
|
case 'y': this.editor.yank(); return this.refreshCompletion();
|
|
794
|
+
case 'x': {
|
|
795
|
+
if (this.editor.hasSelection) {
|
|
796
|
+
const text = this.editor.getSelectedText();
|
|
797
|
+
writeClipboardSync(text);
|
|
798
|
+
this.editor.killRing = text;
|
|
799
|
+
this.editor.deleteSelection();
|
|
800
|
+
this.notice = `cut selection (${text.length} chars) to clipboard`;
|
|
801
|
+
this.scheduleDraw();
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
786
806
|
case 'p': return this.openPalette();
|
|
787
807
|
case 'l': return this.clearScreen();
|
|
788
808
|
case 'o': return this.expand();
|
|
@@ -791,12 +811,61 @@ export class ChatPrompt {
|
|
|
791
811
|
if (text) {
|
|
792
812
|
this.editor.insert(text);
|
|
793
813
|
this.refreshCompletion();
|
|
814
|
+
this.notice = 'pasted from clipboard';
|
|
815
|
+
} else {
|
|
816
|
+
this.notice = 'clipboard is empty';
|
|
794
817
|
}
|
|
818
|
+
this.scheduleDraw();
|
|
795
819
|
return;
|
|
796
820
|
}
|
|
797
821
|
default: break;
|
|
798
822
|
}
|
|
799
823
|
}
|
|
824
|
+
if (key.alt && key.name === 'a') {
|
|
825
|
+
this.editor.selectAll();
|
|
826
|
+
this.notice = 'selected all input text';
|
|
827
|
+
this.scheduleDraw();
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
if (key.alt && key.name === 'x') {
|
|
831
|
+
if (this.editor.hasSelection) {
|
|
832
|
+
const text = this.editor.getSelectedText();
|
|
833
|
+
writeClipboardSync(text);
|
|
834
|
+
this.editor.killRing = text;
|
|
835
|
+
this.editor.deleteSelection();
|
|
836
|
+
this.notice = `cut selection (${text.length} chars) to clipboard`;
|
|
837
|
+
this.scheduleDraw();
|
|
838
|
+
return;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (key.alt && (key.name === 'c' || key.name === 'w')) {
|
|
842
|
+
const text = this.editor.hasSelection
|
|
843
|
+
? this.editor.getSelectedText()
|
|
844
|
+
: this.editor.getText();
|
|
845
|
+
if (text) {
|
|
846
|
+
writeClipboardSync(text);
|
|
847
|
+
this.editor.killRing = text;
|
|
848
|
+
this.notice = this.editor.hasSelection
|
|
849
|
+
? `copied selection (${text.length} chars) to clipboard`
|
|
850
|
+
: 'copied input to clipboard';
|
|
851
|
+
} else {
|
|
852
|
+
this.notice = 'input is empty (nothing to copy)';
|
|
853
|
+
}
|
|
854
|
+
this.scheduleDraw();
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
if (key.alt && key.name === 'v') {
|
|
858
|
+
const text = readClipboardSync();
|
|
859
|
+
if (text) {
|
|
860
|
+
this.editor.insert(text);
|
|
861
|
+
this.refreshCompletion();
|
|
862
|
+
this.notice = 'pasted from clipboard';
|
|
863
|
+
} else {
|
|
864
|
+
this.notice = 'clipboard is empty';
|
|
865
|
+
}
|
|
866
|
+
this.scheduleDraw();
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
800
869
|
if (key.alt && key.name === 'b') return this.editor.moveWordLeft();
|
|
801
870
|
if (key.alt && key.name === 'f') return this.editor.moveWordRight();
|
|
802
871
|
}
|
|
@@ -856,8 +925,16 @@ export class ChatPrompt {
|
|
|
856
925
|
if (key.shift) viewport.toBottom(); else viewport.pageDown();
|
|
857
926
|
return true;
|
|
858
927
|
}
|
|
859
|
-
if (key.shift && key.name === 'up') {
|
|
860
|
-
|
|
928
|
+
if (key.shift && key.name === 'up') {
|
|
929
|
+
if (!this.editor.isEmpty) return false;
|
|
930
|
+
viewport.lineUp();
|
|
931
|
+
return true;
|
|
932
|
+
}
|
|
933
|
+
if (key.shift && key.name === 'down') {
|
|
934
|
+
if (!this.editor.isEmpty) return false;
|
|
935
|
+
viewport.lineDown();
|
|
936
|
+
return true;
|
|
937
|
+
}
|
|
861
938
|
if (key.alt && key.ctrl && key.name === 'u') { viewport.halfPageUp(); return true; }
|
|
862
939
|
if (key.alt && key.ctrl && key.name === 'd') { viewport.halfPageDown(); return true; }
|
|
863
940
|
|
package/src/tui/stageSurface.js
CHANGED
|
@@ -208,6 +208,7 @@ export class StageSurface {
|
|
|
208
208
|
/** Keep Home distinct from a selected or newly started conversation. */
|
|
209
209
|
enterHome(info) {
|
|
210
210
|
this.homeInfo = info;
|
|
211
|
+
this.disableMouse();
|
|
211
212
|
this.homeSessionSelected = false;
|
|
212
213
|
this.sessionInfo = { title: 'Untitled', cwd: info?.cwd, provider: info?.provider, model: info?.model };
|
|
213
214
|
this.fullSession = true;
|
|
@@ -217,6 +218,7 @@ export class StageSurface {
|
|
|
217
218
|
leaveHome(sessionSelected = false) {
|
|
218
219
|
if (this.homeInfo) this.stage.invalidate();
|
|
219
220
|
this.homeInfo = null;
|
|
221
|
+
this.enableMouse();
|
|
220
222
|
if (sessionSelected) this.homeSessionSelected = true;
|
|
221
223
|
}
|
|
222
224
|
|
|
@@ -242,7 +244,7 @@ export class StageSurface {
|
|
|
242
244
|
// the user had typed anything, and 73 of the 77 claimed rows were empty.
|
|
243
245
|
// present() grows it to fit what there actually is.
|
|
244
246
|
if (!this.stage.reserve(1)) return false;
|
|
245
|
-
this.enableMouse();
|
|
247
|
+
if (!this.homeInfo) this.enableMouse();
|
|
246
248
|
this.armTeardown();
|
|
247
249
|
return true;
|
|
248
250
|
}
|