strands-darwin 0.0.45 → 0.0.47
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 +4 -2
- package/README.zh-CN.md +4 -2
- package/dist/src/agent/permission.js +19 -2
- package/dist/src/agent/permission.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +35 -1
- package/dist/src/agent/runtime.js +52 -3
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/cli-completion.d.ts +13 -0
- package/dist/src/cli-completion.js +161 -0
- package/dist/src/cli-completion.js.map +1 -0
- package/dist/src/cli-usage.d.ts +1 -1
- package/dist/src/cli-usage.js +1 -0
- package/dist/src/cli-usage.js.map +1 -1
- package/dist/src/cli.js +5 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/custom-commands.d.ts +7 -0
- package/dist/src/commands/custom-commands.js +20 -0
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/dev-repl.js +4 -1
- package/dist/src/dev-repl.js.map +1 -1
- package/dist/src/headless-protocol.d.ts +1 -1
- package/dist/src/headless-protocol.js +5 -0
- package/dist/src/headless-protocol.js.map +1 -1
- package/dist/src/headless-runner.js +5 -0
- package/dist/src/headless-runner.js.map +1 -1
- package/dist/src/headless.js +5 -0
- package/dist/src/headless.js.map +1 -1
- package/dist/src/mcp/prompts.d.ts +179 -0
- package/dist/src/mcp/prompts.js +349 -0
- package/dist/src/mcp/prompts.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +8 -1
- package/dist/src/mcp/registry.js +3 -1
- package/dist/src/mcp/registry.js.map +1 -1
- package/dist/src/tui/App.js +187 -12
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +7 -1
- package/dist/src/tui/InputBox.js +5 -3
- package/dist/src/tui/InputBox.js.map +1 -1
- package/dist/src/tui/external-editor.d.ts +143 -0
- package/dist/src/tui/external-editor.js +482 -0
- package/dist/src/tui/external-editor.js.map +1 -0
- package/dist/src/tui/help-format.js +2 -2
- package/dist/src/tui/help-format.js.map +1 -1
- package/dist/src/tui/mcp-format.d.ts +2 -0
- package/dist/src/tui/mcp-format.js +23 -1
- package/dist/src/tui/mcp-format.js.map +1 -1
- package/dist/src/tui/prompt-editor.d.ts +6 -0
- package/dist/src/tui/prompt-editor.js +10 -0
- package/dist/src/tui/prompt-editor.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ctrl+G external prompt editing (SER-113): the exact unsent composer text, edited in
|
|
3
|
+
* the user's own `VISUAL` (else `EDITOR`), returned to the composer unsent.
|
|
4
|
+
*
|
|
5
|
+
* Policy. This is explicit user-authorized input editing, not a model tool: it never
|
|
6
|
+
* enters the permission gate (whose subject is model tool calls), never reads
|
|
7
|
+
* repository editor configuration, and never guesses an installed editor. The value is
|
|
8
|
+
* parsed into a bounded argv and spawned **without a shell**; shell operators and
|
|
9
|
+
* substitutions are refused, never interpreted. The child gets darwin's existing
|
|
10
|
+
* sanitized child environment (`scrubShellEnv` + `withDarwinMarker`, the map the
|
|
11
|
+
* model's `bash` gets) and the session cwd; the caller supplies both.
|
|
12
|
+
*
|
|
13
|
+
* Storage. One private random directory (0700) holding one regular file (0600) under
|
|
14
|
+
* the OS temp root, refused if that resolves inside the project. Input and output are
|
|
15
|
+
* capped at {@link EXTERNAL_EDITOR_MAX_CODE_POINTS} code points and
|
|
16
|
+
* {@link EXTERNAL_EDITOR_MAX_BYTES} UTF-8 bytes — oversize is refused, never
|
|
17
|
+
* truncated. The result is read through one bounded descriptor (`O_NOFOLLOW`,
|
|
18
|
+
* `O_NONBLOCK`, regular-file check, at most cap+1 bytes even while the file grows) and
|
|
19
|
+
* decoded as strict UTF-8; only the composer's own `normalizeDraftText` policy is
|
|
20
|
+
* applied. The directory is removed on every settlement path. Editors themselves may
|
|
21
|
+
* write swap/backup files elsewhere; darwin cannot guarantee those are erased.
|
|
22
|
+
*
|
|
23
|
+
* Lifetime. No editing deadline and no automatic retry: editing is a human action.
|
|
24
|
+
* `kill()` (darwin shutdown) TERMs the editor, KILLs it after a grace, and removes the
|
|
25
|
+
* storage synchronously. The editor shares darwin's process group so it owns the
|
|
26
|
+
* foreground terminal; while it runs darwin holds its own SIGINT/SIGQUIT listeners
|
|
27
|
+
* aside (one no-op handles them), so a Ctrl+C typed into a cooked-mode editor ends
|
|
28
|
+
* only the editor and the composer comes back.
|
|
29
|
+
*/
|
|
30
|
+
import { spawn } from 'node:child_process';
|
|
31
|
+
import { constants as fsConstants, rmSync } from 'node:fs';
|
|
32
|
+
import { chmod, mkdtemp, open, realpath, rm } from 'node:fs/promises';
|
|
33
|
+
import os from 'node:os';
|
|
34
|
+
import path from 'node:path';
|
|
35
|
+
/** Draft and result cap in Unicode code points — the composer stash/yank cap. */
|
|
36
|
+
export const EXTERNAL_EDITOR_MAX_CODE_POINTS = 65_536;
|
|
37
|
+
/** Draft and result cap in UTF-8 bytes (256 KiB). */
|
|
38
|
+
export const EXTERNAL_EDITOR_MAX_BYTES = 262_144;
|
|
39
|
+
/** Longest `VISUAL`/`EDITOR` value parsed, in code points. */
|
|
40
|
+
export const EDITOR_COMMAND_MAX_CODE_POINTS = 1_024;
|
|
41
|
+
/** Most argv entries (executable included) one editor command may yield. */
|
|
42
|
+
export const EDITOR_COMMAND_MAX_ARGS = 32;
|
|
43
|
+
/** Grace between the editor's SIGTERM and SIGKILL on darwin shutdown. */
|
|
44
|
+
export const EDITOR_KILL_GRACE_MS = 2_000;
|
|
45
|
+
/** How long darwin keeps holding SIGINT/SIGQUIT listeners after the editor exits. */
|
|
46
|
+
export const TERMINAL_SIGNAL_GRACE_MS = 500;
|
|
47
|
+
/** Temporary directory prefix under the OS temp root; the file inside is fixed. */
|
|
48
|
+
export const EDITOR_TEMP_PREFIX = 'darwin-editor-';
|
|
49
|
+
export const EDITOR_TEMP_FILE = 'prompt.md';
|
|
50
|
+
/** The guidance when neither variable is set: no editor is ever guessed. */
|
|
51
|
+
export const EXTERNAL_EDITOR_UNSET_NOTICE = 'Ctrl+G needs an external editor: set VISUAL or EDITOR (for example VISUAL="code --wait") ' +
|
|
52
|
+
'before starting darwin — draft unchanged';
|
|
53
|
+
/** Variables consulted, in precedence order. */
|
|
54
|
+
export const EDITOR_VARIABLES = ['VISUAL', 'EDITOR'];
|
|
55
|
+
/**
|
|
56
|
+
* `VISUAL` first, then `EDITOR`; an unset or blank variable falls through. A set but
|
|
57
|
+
* unparseable value is refused rather than skipped: silently trying the other
|
|
58
|
+
* variable would run an editor the user did not choose.
|
|
59
|
+
*/
|
|
60
|
+
export function resolveEditorCommand(env) {
|
|
61
|
+
for (const source of EDITOR_VARIABLES) {
|
|
62
|
+
const value = env[source];
|
|
63
|
+
if (value === undefined || value.trim() === '')
|
|
64
|
+
continue;
|
|
65
|
+
const parsed = parseEditorCommand(value);
|
|
66
|
+
return parsed.ok
|
|
67
|
+
? { kind: 'command', source, argv: parsed.argv }
|
|
68
|
+
: { kind: 'refused', source, reason: parsed.reason };
|
|
69
|
+
}
|
|
70
|
+
return { kind: 'unset' };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Unquoted characters that only mean something to a shell: operators, redirection,
|
|
74
|
+
* substitution, globbing, expansion, comments and history. Refusing them is the
|
|
75
|
+
* whole "no shell" contract — nothing is interpreted, so nothing may look like it is.
|
|
76
|
+
*/
|
|
77
|
+
const SHELL_SYNTAX = new Set(['|', '&', ';', '<', '>', '(', ')', '$', '`', '*', '?', '[', ']', '{', '}', '~', '#', '!']);
|
|
78
|
+
/** Inside double quotes a shell would still substitute these. */
|
|
79
|
+
const DOUBLE_QUOTED_SUBSTITUTION = new Set(['$', '`']);
|
|
80
|
+
/** Backslash escapes a shell honours inside double quotes; any other stays literal. */
|
|
81
|
+
const DOUBLE_QUOTED_ESCAPES = new Set(['"', '\\', '$', '`']);
|
|
82
|
+
// eslint-disable-next-line no-control-regex
|
|
83
|
+
const CONTROL = /[\u0000-\u0008\u000a-\u001f\u007f-\u009f]/;
|
|
84
|
+
/**
|
|
85
|
+
* POSIX-style word splitting without a shell: spaces/tabs separate words, single
|
|
86
|
+
* quotes are literal, double quotes allow `\"`/`\\`, an unquoted backslash escapes
|
|
87
|
+
* the next character. Shell syntax, control characters, unterminated quotes and
|
|
88
|
+
* over-cap values are refused with a reason that never echoes the value.
|
|
89
|
+
*/
|
|
90
|
+
export function parseEditorCommand(value) {
|
|
91
|
+
const points = [...value];
|
|
92
|
+
if (points.length > EDITOR_COMMAND_MAX_CODE_POINTS) {
|
|
93
|
+
return { ok: false, reason: `longer than ${EDITOR_COMMAND_MAX_CODE_POINTS} code points` };
|
|
94
|
+
}
|
|
95
|
+
if (CONTROL.test(value))
|
|
96
|
+
return { ok: false, reason: 'contains control characters or newlines' };
|
|
97
|
+
const argv = [];
|
|
98
|
+
let word = '';
|
|
99
|
+
let inWord = false;
|
|
100
|
+
let quote;
|
|
101
|
+
for (let index = 0; index < points.length; index += 1) {
|
|
102
|
+
const ch = points[index];
|
|
103
|
+
if (quote === "'") {
|
|
104
|
+
if (ch === "'")
|
|
105
|
+
quote = undefined;
|
|
106
|
+
else
|
|
107
|
+
word += ch;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (quote === '"') {
|
|
111
|
+
if (ch === '"') {
|
|
112
|
+
quote = undefined;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (DOUBLE_QUOTED_SUBSTITUTION.has(ch))
|
|
116
|
+
return { ok: false, reason: shellReason(ch) };
|
|
117
|
+
if (ch === '\\' && DOUBLE_QUOTED_ESCAPES.has(points[index + 1] ?? '')) {
|
|
118
|
+
word += points[index + 1];
|
|
119
|
+
index += 1;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
word += ch;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (ch === ' ' || ch === '\t') {
|
|
126
|
+
if (inWord) {
|
|
127
|
+
argv.push(word);
|
|
128
|
+
word = '';
|
|
129
|
+
inWord = false;
|
|
130
|
+
}
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
inWord = true;
|
|
134
|
+
if (ch === "'" || ch === '"') {
|
|
135
|
+
quote = ch;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (ch === '\\') {
|
|
139
|
+
const next = points[index + 1];
|
|
140
|
+
if (next === undefined)
|
|
141
|
+
return { ok: false, reason: 'ends with a dangling backslash' };
|
|
142
|
+
word += next;
|
|
143
|
+
index += 1;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (SHELL_SYNTAX.has(ch))
|
|
147
|
+
return { ok: false, reason: shellReason(ch) };
|
|
148
|
+
word += ch;
|
|
149
|
+
}
|
|
150
|
+
if (quote !== undefined)
|
|
151
|
+
return { ok: false, reason: 'has an unterminated quote' };
|
|
152
|
+
if (inWord)
|
|
153
|
+
argv.push(word);
|
|
154
|
+
if (argv.length === 0 || argv[0] === '')
|
|
155
|
+
return { ok: false, reason: 'names no executable' };
|
|
156
|
+
if (argv.length > EDITOR_COMMAND_MAX_ARGS) {
|
|
157
|
+
return { ok: false, reason: `has more than ${EDITOR_COMMAND_MAX_ARGS} words` };
|
|
158
|
+
}
|
|
159
|
+
return { ok: true, argv };
|
|
160
|
+
}
|
|
161
|
+
function shellReason(ch) {
|
|
162
|
+
return `uses shell syntax ${JSON.stringify(ch)}; darwin runs the editor without a shell (quote it, or wrap it in a script)`;
|
|
163
|
+
}
|
|
164
|
+
/** A bounded executable label for notices: basename only, never the arguments. */
|
|
165
|
+
export function editorLabel(argv) {
|
|
166
|
+
const base = path.basename(argv[0] ?? '');
|
|
167
|
+
const points = [...base];
|
|
168
|
+
return points.length <= 48 ? base : `${points.slice(0, 47).join('')}…`;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Why Ctrl+G may not open the editor now: `'ignore'` for the repeated chord, a
|
|
172
|
+
* notice for a state that owns or is about to claim the session, `undefined` when
|
|
173
|
+
* eligible. Permission prompts, compaction and the two search modes never reach this
|
|
174
|
+
* — they own the key earlier in the input chain.
|
|
175
|
+
*/
|
|
176
|
+
export function externalEditorRefusal(context) {
|
|
177
|
+
if (context.editorActive)
|
|
178
|
+
return 'ignore';
|
|
179
|
+
if (!context.idle)
|
|
180
|
+
return 'Ctrl+G opens the external editor only while darwin is idle — draft unchanged';
|
|
181
|
+
if (context.queued > 0 || context.draining || context.clearing || context.goalOwed) {
|
|
182
|
+
return 'Ctrl+G waits until queued or automatic work has run — draft unchanged';
|
|
183
|
+
}
|
|
184
|
+
if (context.peerPending > 0)
|
|
185
|
+
return 'Ctrl+G waits until pending peer messages have run — draft unchanged';
|
|
186
|
+
if (context.liveDelegations > 0) {
|
|
187
|
+
return 'Ctrl+G waits until background delegations settle (see /agents) — draft unchanged';
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
/** True when `text` fits both caps; checked before anything is created. */
|
|
192
|
+
export function withinEditorCaps(text) {
|
|
193
|
+
return Buffer.byteLength(text, 'utf8') <= EXTERNAL_EDITOR_MAX_BYTES &&
|
|
194
|
+
[...text].length <= EXTERNAL_EDITOR_MAX_CODE_POINTS;
|
|
195
|
+
}
|
|
196
|
+
const CAP_REASON = `${EXTERNAL_EDITOR_MAX_CODE_POINTS.toLocaleString('en-US')} code points / 256 KiB UTF-8`;
|
|
197
|
+
/** Opens the editor on `text`; resolves once, after the storage is removed. */
|
|
198
|
+
export function runExternalEditor(text, options) {
|
|
199
|
+
let child;
|
|
200
|
+
let killed = false;
|
|
201
|
+
let killGrace;
|
|
202
|
+
let directory;
|
|
203
|
+
let removed = false;
|
|
204
|
+
const removeNow = () => {
|
|
205
|
+
if (directory === undefined || removed)
|
|
206
|
+
return undefined;
|
|
207
|
+
try {
|
|
208
|
+
rmSync(directory, { recursive: true, force: true });
|
|
209
|
+
removed = true;
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
return problem(error);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const kill = () => {
|
|
217
|
+
if (killed)
|
|
218
|
+
return;
|
|
219
|
+
killed = true;
|
|
220
|
+
const running = child;
|
|
221
|
+
if (running !== undefined && running.exitCode === null && running.signalCode === null) {
|
|
222
|
+
try {
|
|
223
|
+
running.kill('SIGTERM');
|
|
224
|
+
}
|
|
225
|
+
catch { /* already gone */ }
|
|
226
|
+
killGrace = setTimeout(() => {
|
|
227
|
+
try {
|
|
228
|
+
running.kill('SIGKILL');
|
|
229
|
+
}
|
|
230
|
+
catch { /* already gone */ }
|
|
231
|
+
}, EDITOR_KILL_GRACE_MS);
|
|
232
|
+
killGrace.unref?.();
|
|
233
|
+
}
|
|
234
|
+
// Shutdown may not wait for the async settlement below.
|
|
235
|
+
removeNow();
|
|
236
|
+
};
|
|
237
|
+
const prepareAndRun = async () => {
|
|
238
|
+
if (!withinEditorCaps(text)) {
|
|
239
|
+
return { kind: 'refused', reason: `the draft exceeds ${CAP_REASON}; nothing was written` };
|
|
240
|
+
}
|
|
241
|
+
let outcome;
|
|
242
|
+
try {
|
|
243
|
+
directory = await mkdtemp(path.join(options.tempRoot ?? os.tmpdir(), EDITOR_TEMP_PREFIX));
|
|
244
|
+
await chmod(directory, 0o700);
|
|
245
|
+
if (options.projectRoot !== undefined && await inside(directory, options.projectRoot)) {
|
|
246
|
+
outcome = { kind: 'refused', reason: 'the temporary directory resolves inside the project; set TMPDIR outside it' };
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
const file = path.join(directory, EDITOR_TEMP_FILE);
|
|
250
|
+
const handle = await open(file, 'wx', 0o600);
|
|
251
|
+
try {
|
|
252
|
+
await handle.chmod(0o600);
|
|
253
|
+
await handle.writeFile(text, 'utf8');
|
|
254
|
+
}
|
|
255
|
+
finally {
|
|
256
|
+
await handle.close();
|
|
257
|
+
}
|
|
258
|
+
outcome = killed ? stoppedOutcome() : await launch(file);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
outcome = { kind: 'refused', reason: `could not prepare private temporary storage: ${problem(error)}` };
|
|
263
|
+
}
|
|
264
|
+
// The editor has exited (or never started) by now: no SIGKILL is owed.
|
|
265
|
+
if (killGrace !== undefined)
|
|
266
|
+
clearTimeout(killGrace);
|
|
267
|
+
let cleanupProblem;
|
|
268
|
+
if (directory !== undefined && !removed) {
|
|
269
|
+
try {
|
|
270
|
+
await rm(directory, { recursive: true, force: true });
|
|
271
|
+
removed = true;
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
cleanupProblem = `could not remove ${directory}: ${problem(error)}`;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return cleanupProblem === undefined ? outcome : { ...outcome, cleanupProblem };
|
|
278
|
+
};
|
|
279
|
+
const launch = async (file) => {
|
|
280
|
+
const [executable, ...args] = options.argv;
|
|
281
|
+
if (executable === undefined)
|
|
282
|
+
return { kind: 'failed', reason: 'no editor executable' };
|
|
283
|
+
const ignore = options.ignoreTerminalSignals !== false;
|
|
284
|
+
const releaseSignals = ignore ? holdTerminalSignals() : () => { };
|
|
285
|
+
let exit;
|
|
286
|
+
try {
|
|
287
|
+
exit = await new Promise((resolve) => {
|
|
288
|
+
let settled = false;
|
|
289
|
+
const settle = (value) => { if (!settled) {
|
|
290
|
+
settled = true;
|
|
291
|
+
resolve(value);
|
|
292
|
+
} };
|
|
293
|
+
try {
|
|
294
|
+
const fd = options.terminalFd;
|
|
295
|
+
child = spawn(executable, [...args, file], {
|
|
296
|
+
cwd: options.cwd,
|
|
297
|
+
env: { ...options.env },
|
|
298
|
+
// Same process group (never `detached`): the editor must be in the
|
|
299
|
+
// terminal's foreground group to read it without SIGTTIN.
|
|
300
|
+
stdio: fd === undefined ? 'inherit' : [fd, fd, fd],
|
|
301
|
+
shell: false,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
settle({ error: problem(error) });
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
child.once('error', (error) => settle({ error: problem(error) }));
|
|
309
|
+
child.once('exit', (code, signal) => settle({ code, signal }));
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
// The terminal signals the whole foreground group at once: the editor's exit can
|
|
314
|
+
// be processed before darwin's own copy of the same SIGINT is dispatched, so the
|
|
315
|
+
// hold outlives the editor briefly. Once Ink is back in raw mode Ctrl+C is a
|
|
316
|
+
// key, not a signal.
|
|
317
|
+
setTimeout(releaseSignals, TERMINAL_SIGNAL_GRACE_MS).unref();
|
|
318
|
+
}
|
|
319
|
+
const label = editorLabel(options.argv);
|
|
320
|
+
if ('error' in exit)
|
|
321
|
+
return { kind: 'failed', reason: `could not start ${label}: ${exit.error}` };
|
|
322
|
+
if (killed)
|
|
323
|
+
return stoppedOutcome();
|
|
324
|
+
if (exit.signal !== null)
|
|
325
|
+
return { kind: 'failed', reason: `${label} was ended by ${exit.signal}` };
|
|
326
|
+
if (exit.code !== 0)
|
|
327
|
+
return { kind: 'failed', reason: `${label} exited with code ${exit.code}` };
|
|
328
|
+
const read = await readEditorResult(file);
|
|
329
|
+
if (!read.ok)
|
|
330
|
+
return { kind: 'failed', reason: read.reason };
|
|
331
|
+
const next = options.normalize(read.text);
|
|
332
|
+
if (!withinEditorCaps(next))
|
|
333
|
+
return { kind: 'failed', reason: `the result exceeds ${CAP_REASON}` };
|
|
334
|
+
return next === text ? { kind: 'unchanged' } : { kind: 'changed', text: next };
|
|
335
|
+
};
|
|
336
|
+
const done = prepareAndRun();
|
|
337
|
+
return { done, kill };
|
|
338
|
+
}
|
|
339
|
+
function stoppedOutcome() {
|
|
340
|
+
return { kind: 'failed', reason: 'the editor was stopped because darwin is shutting down' };
|
|
341
|
+
}
|
|
342
|
+
/** Signals a cooked-mode terminal sends the foreground group for Ctrl+C / Ctrl+\. */
|
|
343
|
+
const TERMINAL_SIGNALS = ['SIGINT', 'SIGQUIT'];
|
|
344
|
+
/**
|
|
345
|
+
* While the editor shares darwin's process group, a Ctrl+C typed into a cooked-mode
|
|
346
|
+
* editor is a SIGINT to darwin too — and the SDK's vended bash module listens with
|
|
347
|
+
* `process.exit(0)` (the same listener `headless-runner.ts` replaces). Every listener
|
|
348
|
+
* present at the first hold is set aside and one no-op handles the signal instead.
|
|
349
|
+
* Holds are counted process-wide: an edit started inside the previous one's release
|
|
350
|
+
* grace joins the same hold, and only the last release restores exactly the held
|
|
351
|
+
* listeners (keeping any added meanwhile).
|
|
352
|
+
*/
|
|
353
|
+
let terminalSignalHold;
|
|
354
|
+
function holdTerminalSignals() {
|
|
355
|
+
if (terminalSignalHold === undefined) {
|
|
356
|
+
const ignoreSignal = () => { };
|
|
357
|
+
const held = TERMINAL_SIGNALS.map((signal) => {
|
|
358
|
+
const listeners = process.listeners(signal);
|
|
359
|
+
for (const listener of listeners)
|
|
360
|
+
process.off(signal, listener);
|
|
361
|
+
process.on(signal, ignoreSignal);
|
|
362
|
+
return { signal, listeners };
|
|
363
|
+
});
|
|
364
|
+
terminalSignalHold = { count: 0, ignoreSignal, held };
|
|
365
|
+
}
|
|
366
|
+
terminalSignalHold.count += 1;
|
|
367
|
+
let released = false;
|
|
368
|
+
return () => {
|
|
369
|
+
const hold = terminalSignalHold;
|
|
370
|
+
if (released || hold === undefined)
|
|
371
|
+
return;
|
|
372
|
+
released = true;
|
|
373
|
+
hold.count -= 1;
|
|
374
|
+
if (hold.count > 0)
|
|
375
|
+
return;
|
|
376
|
+
terminalSignalHold = undefined;
|
|
377
|
+
for (const { signal, listeners } of hold.held) {
|
|
378
|
+
process.off(signal, hold.ignoreSignal);
|
|
379
|
+
for (const listener of listeners)
|
|
380
|
+
process.on(signal, listener);
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Reads the edited file through one descriptor: no symlink follow, no blocking on a
|
|
386
|
+
* FIFO, regular files only, at most cap+1 bytes however large the file grows, strict
|
|
387
|
+
* UTF-8 (a BOM is kept as text, not silently dropped).
|
|
388
|
+
*/
|
|
389
|
+
export async function readEditorResult(file) {
|
|
390
|
+
let handle;
|
|
391
|
+
try {
|
|
392
|
+
handle = await open(file, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK);
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
const code = error.code;
|
|
396
|
+
if (code === 'ELOOP')
|
|
397
|
+
return { ok: false, reason: 'the result is a symlink, not a regular file' };
|
|
398
|
+
if (code === 'ENOENT')
|
|
399
|
+
return { ok: false, reason: 'the editor removed the file' };
|
|
400
|
+
return { ok: false, reason: `could not read the result: ${problem(error)}` };
|
|
401
|
+
}
|
|
402
|
+
try {
|
|
403
|
+
const stat = await handle.stat();
|
|
404
|
+
if (!stat.isFile())
|
|
405
|
+
return { ok: false, reason: 'the result is not a regular file' };
|
|
406
|
+
const limit = EXTERNAL_EDITOR_MAX_BYTES + 1;
|
|
407
|
+
const buffer = Buffer.alloc(limit);
|
|
408
|
+
let total = 0;
|
|
409
|
+
while (total < limit) {
|
|
410
|
+
const { bytesRead } = await handle.read(buffer, total, limit - total, total);
|
|
411
|
+
if (bytesRead === 0)
|
|
412
|
+
break;
|
|
413
|
+
total += bytesRead;
|
|
414
|
+
}
|
|
415
|
+
if (total > EXTERNAL_EDITOR_MAX_BYTES)
|
|
416
|
+
return { ok: false, reason: `the result exceeds ${CAP_REASON}` };
|
|
417
|
+
let text;
|
|
418
|
+
try {
|
|
419
|
+
text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buffer.subarray(0, total));
|
|
420
|
+
}
|
|
421
|
+
catch {
|
|
422
|
+
return { ok: false, reason: 'the result is not valid UTF-8' };
|
|
423
|
+
}
|
|
424
|
+
if ([...text].length > EXTERNAL_EDITOR_MAX_CODE_POINTS)
|
|
425
|
+
return { ok: false, reason: `the result exceeds ${CAP_REASON}` };
|
|
426
|
+
return { ok: true, text };
|
|
427
|
+
}
|
|
428
|
+
finally {
|
|
429
|
+
await handle.close();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
async function inside(candidate, root) {
|
|
433
|
+
const [real, realRoot] = await Promise.all([realpath(candidate), realpath(root).catch(() => path.resolve(root))]);
|
|
434
|
+
const relative = path.relative(realRoot, real);
|
|
435
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
436
|
+
}
|
|
437
|
+
function problem(error) {
|
|
438
|
+
const code = error?.code;
|
|
439
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
440
|
+
return code !== undefined && !message.includes(code) ? `${code}: ${message}` : message;
|
|
441
|
+
}
|
|
442
|
+
function readHandle(stream) {
|
|
443
|
+
const handle = stream._handle;
|
|
444
|
+
if (handle === undefined || handle === null)
|
|
445
|
+
return undefined;
|
|
446
|
+
if (typeof handle.reading !== 'boolean' || typeof handle.readStop !== 'function' || typeof handle.readStart !== 'function') {
|
|
447
|
+
return undefined;
|
|
448
|
+
}
|
|
449
|
+
return handle;
|
|
450
|
+
}
|
|
451
|
+
/** True when {@link quiesceTerminalInput} can stop darwin's own terminal reads. */
|
|
452
|
+
export function canQuiesceTerminalInput(stream) {
|
|
453
|
+
return readHandle(stream) !== undefined;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Call inside the suspension: lets queued input ticks settle, stops the handle, and
|
|
457
|
+
* returns the restart to call after Ink has resumed. Idempotent restart; a handle Node
|
|
458
|
+
* already restarted itself is left alone.
|
|
459
|
+
*/
|
|
460
|
+
export async function quiesceTerminalInput(stream) {
|
|
461
|
+
const handle = readHandle(stream);
|
|
462
|
+
if (handle === undefined)
|
|
463
|
+
return () => { };
|
|
464
|
+
let stopped = false;
|
|
465
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
466
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
467
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
468
|
+
if (!handle.reading)
|
|
469
|
+
continue;
|
|
470
|
+
handle.reading = false;
|
|
471
|
+
handle.readStop();
|
|
472
|
+
stopped = true;
|
|
473
|
+
}
|
|
474
|
+
return () => {
|
|
475
|
+
if (!stopped || handle.reading)
|
|
476
|
+
return;
|
|
477
|
+
stopped = false;
|
|
478
|
+
handle.reading = true;
|
|
479
|
+
handle.readStart();
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
//# sourceMappingURL=external-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-editor.js","sourceRoot":"","sources":["../../../src/tui/external-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,iFAAiF;AACjF,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC;AACtD,qDAAqD;AACrD,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,CAAC;AACjD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,CAAC;AACpD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAC1C,qFAAqF;AACrF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,MAAM,CAAC,MAAM,gB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,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,SAAS;QAC9B,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO;QACvC,OAAO,GAAG,KAAK,CAAC;QAChB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -8,7 +8,7 @@ export const MAX_HELP_COMMANDS = 28;
|
|
|
8
8
|
* the "prompt and completion" block and the "editing and session" block, plus the
|
|
9
9
|
* one-line overflow notice a filled command cap would add.
|
|
10
10
|
*/
|
|
11
|
-
export const HELP_FIXED_LINES =
|
|
11
|
+
export const HELP_FIXED_LINES = 27 + COLLABORATION_GRAMMAR.length;
|
|
12
12
|
/**
|
|
13
13
|
* The line cap must cover the worst case — a command inventory that fills
|
|
14
14
|
* `MAX_HELP_COMMANDS` *and* every fixed row — so `slice()` can never silently drop a
|
|
@@ -33,7 +33,7 @@ export function formatHelpReport() {
|
|
|
33
33
|
if (commandNames.length < BUILTIN_COMMAND_NAMES.length) {
|
|
34
34
|
lines.push(` … ${BUILTIN_COMMAND_NAMES.length - commandNames.length} more commands not shown`);
|
|
35
35
|
}
|
|
36
|
-
lines.push('prompt and completion:', ...COLLABORATION_GRAMMAR.map(grammar => ` collaboration: ${grammar}`), ' / opens commands and skills · Up/Down select · Tab/Enter completes the selected row', ' @ completes a workspace path · acceptance inserts path text only, never file content', ' !<command> runs your shell command locally (not as a model tool call)', ' Enter sends · Ctrl+J or trailing \\ + Enter inserts a newline · multiline paste never submits', ' Ctrl+O attaches one clipboard image to the next prompt; Ctrl+O again removes it', ' Ctrl+R searches this project’s prompt history · type to filter · Ctrl+R/Up/Down navigate · Tab/Enter accepts', ' Up/Down precedence: completion · Up queued-message take-back · prompt recall · cursor movement', ' Esc closes completion, cancels history search to its exact draft/cursor, or ends prompt recall', ` Esc Esc (within ${ESCAPE_REWIND_CHORD_MS} ms) on an empty idle composer opens the /rewind chooser; one Esc there does nothing`, 'editing and session:', ' Home/End or Ctrl+A/E moves to the visible row edge', ' Ctrl+K/U deletes to the row end/start · Ctrl+W deletes the previous word', ' Alt/Ctrl+Left/Right or Alt+B/F moves by word · Alt+Backspace/Alt+D deletes the word before/after', ' Ctrl+_ (or Ctrl+-) undoes the last Ctrl+K/U, Ctrl+W or Alt word deletion in the draft', ' Ctrl+Y yanks the last cut at the cursor, repeatably in this draft only (65,536 code points max; not the clipboard)', ' Ctrl+S stashes/restores one draft + cursor/image (65,536 code points max); empty composer to restore, never overwrites or sends', ' /rewind branches conversation only; it never rolls back workspace files or side effects', ' /copy puts the last completed answer on the clipboard via OSC 52 (plus wl-copy/xclip/pbcopy when a display is present)', ' Ctrl+B toggles compact/expanded tool details', ' Ctrl+C cancels busy work; press again within 2s to exit (while idle, the first press only arms)', ' Ctrl+D or /exit or /quit exits');
|
|
36
|
+
lines.push('prompt and completion:', ...COLLABORATION_GRAMMAR.map(grammar => ` collaboration: ${grammar}`), ' / opens commands and skills · Up/Down select · Tab/Enter completes the selected row', ' /mcp__<server>__<prompt> [args] fetches an MCP server prompt and sends it (listed last; /mcp shows counts)', ' @ completes a workspace path · acceptance inserts path text only, never file content', ' !<command> runs your shell command locally (not as a model tool call)', ' Enter sends · Ctrl+J or trailing \\ + Enter inserts a newline · multiline paste never submits', ' Ctrl+O attaches one clipboard image to the next prompt; Ctrl+O again removes it', ' Ctrl+R searches this project’s prompt history · type to filter · Ctrl+R/Up/Down navigate · Tab/Enter accepts', ' Up/Down precedence: completion · Up queued-message take-back · prompt recall · cursor movement', ' Esc closes completion, cancels history search to its exact draft/cursor, or ends prompt recall', ` Esc Esc (within ${ESCAPE_REWIND_CHORD_MS} ms) on an empty idle composer opens the /rewind chooser; one Esc there does nothing`, 'editing and session:', ' Home/End or Ctrl+A/E moves to the visible row edge', ' Ctrl+K/U deletes to the row end/start · Ctrl+W deletes the previous word', ' Alt/Ctrl+Left/Right or Alt+B/F moves by word · Alt+Backspace/Alt+D deletes the word before/after', ' Ctrl+_ (or Ctrl+-) undoes the last Ctrl+K/U, Ctrl+W or Alt word deletion in the draft', ' Ctrl+Y yanks the last cut at the cursor, repeatably in this draft only (65,536 code points max; not the clipboard)', ' Ctrl+S stashes/restores one draft + cursor/image (65,536 code points max); empty composer to restore, never overwrites or sends', ' Ctrl+G edits the draft in $VISUAL (else $EDITOR) while idle; the result replaces the draft unsent — Enter sends it', ' /rewind branches conversation only; it never rolls back workspace files or side effects', ' /copy puts the last completed answer on the clipboard via OSC 52 (plus wl-copy/xclip/pbcopy when a display is present)', ' Ctrl+B toggles compact/expanded tool details', ' Ctrl+C cancels busy work; press again within 2s to exit (while idle, the first press only arms)', ' Ctrl+D or /exit or /quit exits');
|
|
37
37
|
return lines.slice(0, MAX_HELP_LINES).map(boundedLine).join('\n');
|
|
38
38
|
}
|
|
39
39
|
//# sourceMappingURL=help-format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help-format.js","sourceRoot":"","sources":["../../../src/tui/help-format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC;AAClE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,GA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E,MAAM,KAAK,GAAG;QACZ,uBAAuB;QACvB,aAAa,YAAY,CAAC,MAAM,IAAI,qBAAqB,CAAC,MAAM,IAAI;QACpE,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,IAAI,MAAM,4BAA4B,CAAC,IAAI,CAAC,EAAE,CAAC;KACpF,CAAC;IAEF,IAAI,YAAY,CAAC,MAAM,GAAG,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,OAAO,qBAAqB,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,0BAA0B,CAAC,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,IAAI,CACR,wBAAwB,EACxB,GAAG,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,oBAAoB,OAAO,EAAE,CAAC,EACtE,uFAAuF,EACvF,8GAA8G,EAC9G,wFAAwF,EACxF,yEAAyE,EACzE,iGAAiG,EACjG,mFAAmF,EACnF,gHAAgH,EAChH,kGAAkG,EAClG,kGAAkG,EAClG,qBAAqB,sBAAsB,sFAAsF,EACjI,sBAAsB,EACtB,sDAAsD,EACtD,4EAA4E,EAC5E,oGAAoG,EACpG,yFAAyF,EACzF,sHAAsH,EACtH,mIAAmI,EACnI,sHAAsH,EACtH,2FAA2F,EAC3F,0HAA0H,EAC1H,gDAAgD,EAChD,mGAAmG,EACnG,kCAAkC,CACnC,CAAC;IAEF,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -5,6 +5,8 @@ import type { McpServerStatus } from '../mcp/registry.js';
|
|
|
5
5
|
* is bounded by construction, never an unbounded dump.
|
|
6
6
|
*/
|
|
7
7
|
export declare const MAX_MCP_TOOL_NAMES = 8;
|
|
8
|
+
/** Prompt command names shown per server before `… N more` — the same bound as tools. */
|
|
9
|
+
export declare const MAX_MCP_PROMPT_NAMES = 8;
|
|
8
10
|
/** The config provenance the report states alongside the servers. */
|
|
9
11
|
export interface McpConfigSources {
|
|
10
12
|
/** Every contributing config path, global first and project second. */
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* is bounded by construction, never an unbounded dump.
|
|
5
5
|
*/
|
|
6
6
|
export const MAX_MCP_TOOL_NAMES = 8;
|
|
7
|
+
/** Prompt command names shown per server before `… N more` — the same bound as tools. */
|
|
8
|
+
export const MAX_MCP_PROMPT_NAMES = MAX_MCP_TOOL_NAMES;
|
|
7
9
|
/**
|
|
8
10
|
* The `/mcp` report: every configured server with its connection state and a
|
|
9
11
|
* bounded list of registered tool names, then the config source(s) in effect.
|
|
@@ -30,7 +32,7 @@ export function formatMcpReport(servers, sources) {
|
|
|
30
32
|
function describeServer(server) {
|
|
31
33
|
switch (server.state) {
|
|
32
34
|
case 'connected':
|
|
33
|
-
return `connected · ${describeTools(server.toolNames)}${server.auth === 'logged-in' ? ' · oauth: logged in' : ''}`;
|
|
35
|
+
return `connected · ${describeTools(server.toolNames)}${server.auth === 'logged-in' ? ' · oauth: logged in' : ''}${describePrompts(server)}`;
|
|
34
36
|
case 'failed':
|
|
35
37
|
// A 401 that needs a login this process cannot perform names the command that fixes it.
|
|
36
38
|
if (server.auth === 'login-required') {
|
|
@@ -45,6 +47,26 @@ function describeServer(server) {
|
|
|
45
47
|
return 'not connected — tools unknown (no connection attempted by this report)';
|
|
46
48
|
}
|
|
47
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The prompt segment (SER-114), only for a server that was asked: the offered
|
|
52
|
+
* `/mcp__…` command names, bounded like the tool names, the skipped count, or the
|
|
53
|
+
* listing failure. Read from the startup discovery summary — nothing is fetched,
|
|
54
|
+
* and a server that does not offer prompts keeps its row byte-identical.
|
|
55
|
+
*/
|
|
56
|
+
function describePrompts(server) {
|
|
57
|
+
const prompts = server.prompts;
|
|
58
|
+
if (prompts === undefined)
|
|
59
|
+
return '';
|
|
60
|
+
if (prompts.failure !== undefined)
|
|
61
|
+
return ` · prompts unavailable — ${prompts.failure}`;
|
|
62
|
+
const skipped = prompts.skipped > 0 ? ` (${prompts.skipped} skipped)` : '';
|
|
63
|
+
if (prompts.commands.length === 0)
|
|
64
|
+
return ` · no prompts${skipped}`;
|
|
65
|
+
const shown = prompts.commands.slice(0, MAX_MCP_PROMPT_NAMES).map((name) => `/${name}`);
|
|
66
|
+
const remainder = prompts.commands.length - shown.length;
|
|
67
|
+
const suffix = remainder > 0 ? ` … ${remainder} more` : '';
|
|
68
|
+
return ` · ${prompts.commands.length} prompt${prompts.commands.length === 1 ? '' : 's'}${skipped}: ${shown.join(', ')}${suffix}`;
|
|
69
|
+
}
|
|
48
70
|
/** Registered tool names, capped with an explicit remainder — or their absence. */
|
|
49
71
|
function describeTools(toolNames) {
|
|
50
72
|
if (toolNames === undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-format.js","sourceRoot":"","sources":["../../../src/tui/mcp-format.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-format.js","sourceRoot":"","sources":["../../../src/tui/mcp-format.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,yFAAyF;AACzF,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAoBvD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAmC,EACnC,OAAyB;IAEzB,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;IACvC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9C,MAAM,MAAM,GACV,OAAO,CAAC,WAAW,CAAC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F,OAAO,aAAa,UAAU,GAAG,KAAK,EAAE,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,MAAM,SAAS,GACb,OAAO,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC;QACtC,CAAC,CAAC,CAAC,0CAA0C,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxF,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,OAAO,GACX,OAAO,CAAC,iBAAiB,KAAK,SAAS;QACrC,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,cAAc,OAAO,CAAC,iBAAiB,sCAAsC,CAAC,CAAC;IACtF,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -36,6 +36,12 @@ export interface EditorValue {
|
|
|
36
36
|
* whether wrapping happens immediately or on the next character.
|
|
37
37
|
*/
|
|
38
38
|
export declare function layoutEditor(text: string, columns: number, cursor: EditorCursor): EditorLayout;
|
|
39
|
+
/**
|
|
40
|
+
* The composer's one text policy (typed keys, paste, search queries and the Ctrl+G
|
|
41
|
+
* external-editor result): canonicalizes terminal line endings and drops controls
|
|
42
|
+
* without losing layout.
|
|
43
|
+
*/
|
|
44
|
+
export declare function normalizeDraftText(value: string): string;
|
|
39
45
|
/** One draft-local cut, not a kill ring. Count code points, not UTF-16 units. */
|
|
40
46
|
export declare const LAST_CUT_CAP = 65536;
|
|
41
47
|
export declare const LAST_CUT_OVERFLOW_NOTICE = "cut exceeds 65,536 code points; yank cleared \u2014 Ctrl+_ can still undo the deletion";
|
|
@@ -36,6 +36,16 @@ export function layoutEditor(text, columns, cursor) {
|
|
|
36
36
|
cursor: { row: rowIndex, column: PROMPT_WIDTH + boundary.column },
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
+
/** C0 controls except LF and tab, plus DEL: never treated as draft text. */
|
|
40
|
+
const NON_TEXT_CONTROLS = /[\u0000-\u0008\u000b-\u001f\u007f]/g;
|
|
41
|
+
/**
|
|
42
|
+
* The composer's one text policy (typed keys, paste, search queries and the Ctrl+G
|
|
43
|
+
* external-editor result): canonicalizes terminal line endings and drops controls
|
|
44
|
+
* without losing layout.
|
|
45
|
+
*/
|
|
46
|
+
export function normalizeDraftText(value) {
|
|
47
|
+
return value.replace(/\r+\n/g, '\n').replace(/\r/g, '\n').replace(NON_TEXT_CONTROLS, '');
|
|
48
|
+
}
|
|
39
49
|
/** One draft-local cut, not a kill ring. Count code points, not UTF-16 units. */
|
|
40
50
|
export const LAST_CUT_CAP = 65_536;
|
|
41
51
|
export const LAST_CUT_OVERFLOW_NOTICE = 'cut exceeds 65,536 code points; yank cleared — Ctrl+_ can still undo the deletion';
|