@narumitw/pi-starship 0.62.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/dist/chunks/{chunk-HPZTMIZS.ts → chunk-63R6R5DH.ts} +41 -8
- package/dist/chunks/chunk-63R6R5DH.ts.map +7 -0
- package/dist/chunks/{chunk-PWTSHSP3.ts → chunk-A65IOGL6.ts} +6 -7
- package/dist/chunks/chunk-A65IOGL6.ts.map +7 -0
- package/dist/chunks/{chunk-43VIENBN.ts → chunk-Y24TJYG6.ts} +7 -7
- package/dist/chunks/{chunk-43VIENBN.ts.map → chunk-Y24TJYG6.ts.map} +2 -2
- package/dist/chunks/{command-configuration-menu-S2LXCOJG.ts → command-configuration-menu-YOLN2SPR.ts} +3 -3
- package/dist/chunks/{command-settings-chat-O34BEU4X.ts → command-settings-chat-5AHP3JGV.ts} +162 -79
- package/dist/chunks/command-settings-chat-5AHP3JGV.ts.map +7 -0
- package/dist/chunks/{commands-ZYIJVIEJ.ts → commands-IOG2PL67.ts} +23 -19
- package/dist/chunks/commands-IOG2PL67.ts.map +7 -0
- package/dist/index.ts +114 -58
- package/dist/index.ts.map +3 -3
- package/package.json +1 -1
- package/skills/configure-pi-starship/SKILL.md +3 -1
- package/skills/configure-pi-starship/references/configuration.md +14 -12
- package/src/command-commit.ts +41 -7
- package/src/command-configuration.ts +6 -10
- package/src/command-settings-chat.ts +2 -44
- package/src/commands.ts +22 -26
- package/src/config.ts +6 -6
- package/src/pi-starship.ts +154 -88
- package/src/settings-chat-transcript.ts +54 -2
- package/src/settings-chat-ui.ts +150 -50
- package/dist/chunks/chunk-HPZTMIZS.ts.map +0 -7
- package/dist/chunks/chunk-PWTSHSP3.ts.map +0 -7
- package/dist/chunks/command-settings-chat-O34BEU4X.ts.map +0 -7
- package/dist/chunks/commands-ZYIJVIEJ.ts.map +0 -7
- /package/dist/chunks/{command-configuration-menu-S2LXCOJG.ts.map → command-configuration-menu-YOLN2SPR.ts.map} +0 -0
|
@@ -5,17 +5,16 @@ import {
|
|
|
5
5
|
commitActiveDocument,
|
|
6
6
|
commitOwnerCurrent,
|
|
7
7
|
saveAsProfile
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-63R6R5DH.ts";
|
|
9
9
|
import {
|
|
10
10
|
assertProfileUnchanged,
|
|
11
|
-
configurationPresentation
|
|
12
|
-
|
|
13
|
-
} from "./chunk-43VIENBN.ts";
|
|
11
|
+
configurationPresentation
|
|
12
|
+
} from "./chunk-Y24TJYG6.ts";
|
|
14
13
|
import {
|
|
15
14
|
BUILT_IN_EXAMPLE,
|
|
16
15
|
MODULE_DEFINITIONS,
|
|
17
16
|
validateConfigDocument
|
|
18
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-A65IOGL6.ts";
|
|
19
18
|
import "./chunk-IYDZ3R2T.ts";
|
|
20
19
|
import "./chunk-KP33I6BR.ts";
|
|
21
20
|
|
|
@@ -99,6 +98,7 @@ import {
|
|
|
99
98
|
} from "@earendil-works/pi-coding-agent";
|
|
100
99
|
import {
|
|
101
100
|
CURSOR_MARKER,
|
|
101
|
+
decodeKittyPrintable,
|
|
102
102
|
Editor,
|
|
103
103
|
getKeybindings,
|
|
104
104
|
isKeyRelease,
|
|
@@ -137,10 +137,29 @@ function createSettingsChatTranscript(agent, tui, cwd) {
|
|
|
137
137
|
write: createWriteToolDefinition(cwd),
|
|
138
138
|
edit: createEditToolDefinition(cwd)
|
|
139
139
|
};
|
|
140
|
+
const identities = /* @__PURE__ */ new WeakMap();
|
|
141
|
+
let streamingIdentity;
|
|
142
|
+
const initial = agent.state.streamingMessage;
|
|
143
|
+
if (initial?.role === "assistant") {
|
|
144
|
+
streamingIdentity = /* @__PURE__ */ Symbol();
|
|
145
|
+
identities.set(initial, streamingIdentity);
|
|
146
|
+
}
|
|
147
|
+
const unsubscribe = agent.subscribe((event) => {
|
|
148
|
+
if (event.type === "agent_end") streamingIdentity = void 0;
|
|
149
|
+
if ((event.type === "message_start" || event.type === "message_update" || event.type === "message_end") && event.message.role === "assistant") {
|
|
150
|
+
if (event.type === "message_start") streamingIdentity = /* @__PURE__ */ Symbol();
|
|
151
|
+
streamingIdentity ??= /* @__PURE__ */ Symbol();
|
|
152
|
+
identities.set(event.message, streamingIdentity);
|
|
153
|
+
if (event.type === "message_end") streamingIdentity = void 0;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
let spans = [];
|
|
140
157
|
let streaming;
|
|
141
158
|
let disposed = false;
|
|
159
|
+
let expanded = true;
|
|
142
160
|
return {
|
|
143
161
|
render(width) {
|
|
162
|
+
spans = [];
|
|
144
163
|
if (disposed || width <= 0) return [];
|
|
145
164
|
const results = new Map(
|
|
146
165
|
agent.state.messages.flatMap(
|
|
@@ -168,7 +187,7 @@ function createSettingsChatTranscript(agent, tui, cwd) {
|
|
|
168
187
|
tui,
|
|
169
188
|
sanitizeTerminalDocument(cwd)
|
|
170
189
|
);
|
|
171
|
-
component2.setExpanded(
|
|
190
|
+
component2.setExpanded(expanded);
|
|
172
191
|
component2.setArgsComplete();
|
|
173
192
|
component2.markExecutionStarted();
|
|
174
193
|
tool = { component: component2 };
|
|
@@ -189,9 +208,11 @@ function createSettingsChatTranscript(agent, tui, cwd) {
|
|
|
189
208
|
};
|
|
190
209
|
for (const message of visible) {
|
|
191
210
|
activeMessages.add(message);
|
|
211
|
+
let start = lines.length;
|
|
192
212
|
let component = messages.get(message);
|
|
193
213
|
if (message.role === "user") {
|
|
194
214
|
if (lines.length) lines.push("");
|
|
215
|
+
start = lines.length;
|
|
195
216
|
if (!component) {
|
|
196
217
|
const text = typeof message.content === "string" ? message.content : message.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
197
218
|
component = new UserMessageComponent(sanitizeTerminalDocument(text));
|
|
@@ -205,17 +226,34 @@ function createSettingsChatTranscript(agent, tui, cwd) {
|
|
|
205
226
|
}
|
|
206
227
|
appendAssistant(message, component);
|
|
207
228
|
}
|
|
229
|
+
spans.push({ message: identities.get(message) ?? message, start, end: lines.length });
|
|
208
230
|
}
|
|
209
231
|
const partial = agent.state.streamingMessage;
|
|
210
232
|
if (partial?.role === "assistant") {
|
|
211
233
|
streaming ??= new AssistantMessageComponent(void 0, true);
|
|
212
234
|
streaming.updateContent(displayValue(partial), true);
|
|
235
|
+
const start = lines.length;
|
|
213
236
|
lines.push(...streaming.render(width));
|
|
237
|
+
spans.push({ message: identities.get(partial) ?? partial, start, end: lines.length });
|
|
214
238
|
} else streaming = void 0;
|
|
215
239
|
for (const message of messages.keys()) if (!activeMessages.has(message)) messages.delete(message);
|
|
216
240
|
for (const id of tools.keys()) if (!activeTools.has(id)) tools.delete(id);
|
|
217
241
|
return lines;
|
|
218
242
|
},
|
|
243
|
+
anchorAt(row) {
|
|
244
|
+
const span = spans.find((item) => row < item.end);
|
|
245
|
+
return span ? { message: span.message, row: row - span.start } : void 0;
|
|
246
|
+
},
|
|
247
|
+
rowAt(anchor) {
|
|
248
|
+
const span = spans.find((item) => item.message === anchor.message);
|
|
249
|
+
return span ? Math.max(0, span.start + Math.min(anchor.row, span.end - span.start - 1)) : 0;
|
|
250
|
+
},
|
|
251
|
+
toggleTools() {
|
|
252
|
+
if (disposed) return;
|
|
253
|
+
expanded = !expanded;
|
|
254
|
+
for (const { component } of tools.values()) component.setExpanded(expanded);
|
|
255
|
+
tui.requestRender();
|
|
256
|
+
},
|
|
219
257
|
invalidate() {
|
|
220
258
|
if (disposed) return;
|
|
221
259
|
messages.clear();
|
|
@@ -223,7 +261,11 @@ function createSettingsChatTranscript(agent, tui, cwd) {
|
|
|
223
261
|
streaming = void 0;
|
|
224
262
|
},
|
|
225
263
|
dispose() {
|
|
264
|
+
if (disposed) return;
|
|
226
265
|
disposed = true;
|
|
266
|
+
unsubscribe();
|
|
267
|
+
streamingIdentity = void 0;
|
|
268
|
+
spans = [];
|
|
227
269
|
messages.clear();
|
|
228
270
|
tools.clear();
|
|
229
271
|
streaming = void 0;
|
|
@@ -240,7 +282,14 @@ function saveKeyReserved(data, keybindings) {
|
|
|
240
282
|
const editorKeys = getKeybindings();
|
|
241
283
|
return Object.keys(TUI_KEYBINDINGS).some(
|
|
242
284
|
(action) => editorKeys.matches(data, action) || keybindings.matches(data, action)
|
|
243
|
-
) || [
|
|
285
|
+
) || [
|
|
286
|
+
"app.clipboard.pasteImage",
|
|
287
|
+
"app.interrupt",
|
|
288
|
+
"app.exit",
|
|
289
|
+
"app.message.followUp",
|
|
290
|
+
"app.message.dequeue",
|
|
291
|
+
"app.tools.expand"
|
|
292
|
+
].some((action) => keybindings.matches(data, action));
|
|
244
293
|
}
|
|
245
294
|
function settingsChatSaveShortcut(keybindings) {
|
|
246
295
|
return SAVE_SHORTCUTS.find(({ key, inputs }) => {
|
|
@@ -248,20 +297,45 @@ function settingsChatSaveShortcut(keybindings) {
|
|
|
248
297
|
return matching.length > 0 && matching.every((data) => !saveKeyReserved(data, keybindings));
|
|
249
298
|
})?.key;
|
|
250
299
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
300
|
+
var BEFORE_PAGE_ACTIONS = [
|
|
301
|
+
"tui.input.copy",
|
|
302
|
+
"tui.editor.undo",
|
|
303
|
+
"tui.input.tab",
|
|
304
|
+
"tui.editor.deleteToLineEnd",
|
|
305
|
+
"tui.editor.deleteToLineStart",
|
|
306
|
+
"tui.editor.deleteWordBackward",
|
|
307
|
+
"tui.editor.deleteWordForward",
|
|
308
|
+
"tui.editor.deleteCharBackward",
|
|
309
|
+
"tui.editor.deleteCharForward",
|
|
310
|
+
"tui.editor.yank",
|
|
311
|
+
"tui.editor.yankPop",
|
|
312
|
+
"tui.editor.historyPrevious",
|
|
313
|
+
"tui.editor.historyNext",
|
|
314
|
+
"tui.editor.cursorLineStart",
|
|
315
|
+
"tui.editor.cursorLineEnd",
|
|
316
|
+
"tui.editor.cursorWordLeft",
|
|
317
|
+
"tui.editor.cursorWordRight",
|
|
318
|
+
"tui.input.newLine",
|
|
319
|
+
"tui.input.submit",
|
|
320
|
+
"tui.editor.cursorUp",
|
|
321
|
+
"tui.editor.cursorDown",
|
|
322
|
+
"tui.editor.cursorRight",
|
|
323
|
+
"tui.editor.cursorLeft"
|
|
324
|
+
];
|
|
325
|
+
function nativeJumpPrintable(data) {
|
|
326
|
+
if (decodeKittyPrintable(data) !== void 0 || data.charCodeAt(0) >= 32) return true;
|
|
327
|
+
if (!data.startsWith("\x1B[27;")) return false;
|
|
328
|
+
const match = /^(\d+);(\d+)~$/u.exec(data.slice(5));
|
|
329
|
+
if (!match) return false;
|
|
330
|
+
const modifier = Number(match[1]) - 1;
|
|
331
|
+
const codepoint = Number(match[2]);
|
|
332
|
+
return (modifier & ~(1 | 64 | 128)) === 0 && codepoint >= 32 && codepoint <= 1114111;
|
|
333
|
+
}
|
|
334
|
+
function nativeBeforePage(data) {
|
|
335
|
+
return BEFORE_PAGE_ACTIONS.some((action) => getKeybindings().matches(data, action)) || matchesKey(data, "shift+backspace") || matchesKey(data, "shift+delete") || data.charCodeAt(0) === 10 || data === "\x1B\r" || data === "\x1B[13;2~" || data.length > 1 && data.includes("\x1B") && data.includes("\r");
|
|
262
336
|
}
|
|
263
337
|
var SettingsChatEditor = class extends CustomEditor {
|
|
264
|
-
constructor(tui, chromeTheme, labels,
|
|
338
|
+
constructor(tui, chromeTheme, labels, chatKeys) {
|
|
265
339
|
super(
|
|
266
340
|
tui,
|
|
267
341
|
{
|
|
@@ -274,15 +348,44 @@ var SettingsChatEditor = class extends CustomEditor {
|
|
|
274
348
|
noMatch: (text) => chromeTheme.fg("warning", text)
|
|
275
349
|
}
|
|
276
350
|
},
|
|
277
|
-
|
|
351
|
+
chatKeys
|
|
278
352
|
);
|
|
279
353
|
this.chromeTheme = chromeTheme;
|
|
280
354
|
this.labels = labels;
|
|
355
|
+
this.chatKeys = chatKeys;
|
|
281
356
|
}
|
|
282
357
|
chromeTheme;
|
|
283
358
|
labels;
|
|
359
|
+
chatKeys;
|
|
360
|
+
onTranscriptPage;
|
|
361
|
+
awaitingJump;
|
|
362
|
+
handleInput(data) {
|
|
363
|
+
const kb = getKeybindings();
|
|
364
|
+
const interrupt = this.chatKeys.matches(data, "app.interrupt");
|
|
365
|
+
const appConsumes = this.chatKeys.matches(data, "app.clipboard.pasteImage") || interrupt && this.onEscape !== void 0 || !interrupt && this.chatKeys.matches(data, "app.exit") && this.getText().length === 0;
|
|
366
|
+
const history = this.chatKeys.matches(data, "tui.editor.historyPrevious") || this.chatKeys.matches(data, "tui.editor.historyNext");
|
|
367
|
+
const registeredAction = !interrupt && !history && (this.chatKeys.matches(data, "app.message.followUp") || this.chatKeys.matches(data, "app.message.dequeue") || this.chatKeys.matches(data, "app.tools.expand"));
|
|
368
|
+
if (appConsumes || registeredAction) {
|
|
369
|
+
super.handleInput(data);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
const jump = kb.matches(data, "tui.editor.jumpForward") || kb.matches(data, "tui.editor.jumpBackward");
|
|
373
|
+
const pendingJump = this.awaitingJump;
|
|
374
|
+
const jumpConsumes = pendingJump !== void 0 && (jump || nativeJumpPrintable(data));
|
|
375
|
+
this.awaitingJump = void 0;
|
|
376
|
+
const earlier = nativeBeforePage(data);
|
|
377
|
+
const direction = kb.matches(data, "tui.editor.pageUp") ? -1 : kb.matches(data, "tui.editor.pageDown") ? 1 : void 0;
|
|
378
|
+
if (!interrupt && !jumpConsumes && !earlier && direction !== void 0 && this.onTranscriptPage) {
|
|
379
|
+
if (pendingJump !== void 0) Editor.prototype.handleInput.call(this, pendingJump);
|
|
380
|
+
this.onTranscriptPage(direction);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (!jumpConsumes && !earlier && direction === void 0 && jump) this.awaitingJump = data;
|
|
384
|
+
super.handleInput(data);
|
|
385
|
+
}
|
|
284
386
|
/** Bypass app shortcuts while the native Editor owns a bracketed paste. */
|
|
285
387
|
handlePasteInput(data) {
|
|
388
|
+
this.awaitingJump = void 0;
|
|
286
389
|
Editor.prototype.handleInput.call(this, data);
|
|
287
390
|
}
|
|
288
391
|
renderTopBorder(width, hiddenLineCount) {
|
|
@@ -300,7 +403,7 @@ var SettingsChatEditor = class extends CustomEditor {
|
|
|
300
403
|
}).render(width)[0] ?? "";
|
|
301
404
|
}
|
|
302
405
|
};
|
|
303
|
-
function
|
|
406
|
+
function settingsChatStopInput(data, keybindings) {
|
|
304
407
|
const editorKeys = getKeybindings();
|
|
305
408
|
const parsed = parseKey(data);
|
|
306
409
|
const textKey = parsed?.startsWith("shift+") ? parsed.slice(6) : parsed;
|
|
@@ -309,26 +412,22 @@ function settingsChatReviewInput(data, keybindings) {
|
|
|
309
412
|
const editing = nativeEditing || Object.keys(TUI_KEYBINDINGS).filter((key) => key.startsWith("tui.editor.") || key.startsWith("tui.input.")).some((key) => editorKeys.matches(data, key));
|
|
310
413
|
return !editing && (keybindings.matches(data, "tui.select.cancel") || matchesKey(data, Key.escape));
|
|
311
414
|
}
|
|
312
|
-
function settingsChatTranscript(agent) {
|
|
313
|
-
return [...agent.state.messages, ...agent.state.streamingMessage ? [agent.state.streamingMessage] : []].filter((message) => message.role !== "system").flatMap((message) => {
|
|
314
|
-
if (!("content" in message) || !Array.isArray(message.content)) return [];
|
|
315
|
-
const label = message.role === "user" ? "You" : message.role === "assistant" ? "Agent" : "Tool";
|
|
316
|
-
const text = message.content.map((part) => {
|
|
317
|
-
if (part.type === "text") return part.text;
|
|
318
|
-
if (part.type === "toolCall") return `Using ${part.name}\u2026`;
|
|
319
|
-
return "";
|
|
320
|
-
}).filter(Boolean).join("\n");
|
|
321
|
-
const error = message.role === "assistant" ? message.errorMessage : void 0;
|
|
322
|
-
const output = [text, error].filter(Boolean).join("\n");
|
|
323
|
-
return output ? [`${label}: ${sanitizeTerminalDocument2(output)}`] : [];
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
415
|
function createSettingsChatComponent(options) {
|
|
327
416
|
const { agent, draft, state, tui, theme, keybindings, signal } = options;
|
|
328
417
|
let disposed = false;
|
|
329
418
|
let inPaste = false;
|
|
330
419
|
let pending;
|
|
331
420
|
let stopping = false;
|
|
421
|
+
let historyTop;
|
|
422
|
+
let historyAnchor;
|
|
423
|
+
let historyRows = 0;
|
|
424
|
+
let historyMaximum = 0;
|
|
425
|
+
const scrollHistory = (delta) => {
|
|
426
|
+
const next = Math.max(0, Math.min(historyMaximum, (historyTop ?? historyMaximum) + delta));
|
|
427
|
+
historyTop = next === historyMaximum ? void 0 : next;
|
|
428
|
+
historyAnchor = historyTop === void 0 ? void 0 : transcript.anchorAt(historyTop);
|
|
429
|
+
render();
|
|
430
|
+
};
|
|
332
431
|
const queued = [];
|
|
333
432
|
const editor = new SettingsChatEditor(
|
|
334
433
|
tui,
|
|
@@ -336,17 +435,20 @@ function createSettingsChatComponent(options) {
|
|
|
336
435
|
() => {
|
|
337
436
|
const status = state.error || agent.state.errorMessage ? "Agent error" : !draft.candidate ? "Invalid" : draft.diagnostics ? "Warnings" : "Valid";
|
|
338
437
|
const saveKey = !pending && !inPaste && draft.candidate ? settingsChatSaveShortcut(keybindings) : void 0;
|
|
438
|
+
const working = !inPaste && settingsChatStopInput("\x1B", keybindings) ? "Working \xB7 esc to interrupt" : "Working";
|
|
339
439
|
return {
|
|
340
440
|
top: queued.length > 0 ? `pi-starship \xB7 ${queued.length} queued` : "pi-starship",
|
|
341
|
-
bottom: `${status} \xB7 unsaved \xB7 ${pending ?
|
|
441
|
+
bottom: `${status} \xB7 unsaved \xB7 ${pending ? working : saveKey ? `${saveKey} to save profile` : "Idle"} \xB7 ctrl+c to discard`
|
|
342
442
|
};
|
|
343
443
|
},
|
|
344
444
|
keybindings
|
|
345
445
|
);
|
|
446
|
+
editor.onTranscriptPage = (direction) => scrollHistory(direction * Math.max(1, historyRows));
|
|
346
447
|
editor.setText(state.input);
|
|
347
448
|
const render = () => {
|
|
348
449
|
if (!disposed && !signal.aborted) tui.requestRender();
|
|
349
450
|
};
|
|
451
|
+
const transcript = createSettingsChatTranscript(agent, tui, draft.directory);
|
|
350
452
|
const unsubscribe = agent.subscribe((event) => {
|
|
351
453
|
if (event.type === "message_start") {
|
|
352
454
|
const index = queued.findIndex((item) => item.message === event.message);
|
|
@@ -373,7 +475,6 @@ function createSettingsChatComponent(options) {
|
|
|
373
475
|
};
|
|
374
476
|
signal.addEventListener("abort", abort, { once: true });
|
|
375
477
|
const rule = new HorizontalRule({ ruleStyle: (text) => theme.fg("border", text) });
|
|
376
|
-
const transcript = createSettingsChatTranscript(agent, tui, draft.directory);
|
|
377
478
|
const failed = () => {
|
|
378
479
|
const last = agent.state.messages.at(-1);
|
|
379
480
|
return last?.role === "assistant" && (last.stopReason === "error" || last.stopReason === "aborted");
|
|
@@ -416,6 +517,7 @@ function createSettingsChatComponent(options) {
|
|
|
416
517
|
editor.onSubmit = (input) => submit(input, "steer");
|
|
417
518
|
editor.onAction("app.message.followUp", () => submit(editor.getExpandedText().trim(), "followUp"));
|
|
418
519
|
editor.onAction("app.message.dequeue", restoreQueue);
|
|
520
|
+
editor.onAction("app.tools.expand", () => transcript.toggleTools());
|
|
419
521
|
return {
|
|
420
522
|
get focused() {
|
|
421
523
|
return editor.focused;
|
|
@@ -424,6 +526,7 @@ function createSettingsChatComponent(options) {
|
|
|
424
526
|
editor.focused = value;
|
|
425
527
|
},
|
|
426
528
|
render(width) {
|
|
529
|
+
historyRows = 0;
|
|
427
530
|
if (disposed || signal.aborted || width <= 0) return [];
|
|
428
531
|
const rows = Math.max(0, Math.floor(Number.isFinite(tui.terminal.rows) ? tui.terminal.rows : 24));
|
|
429
532
|
if (rows === 0) return [];
|
|
@@ -458,7 +561,17 @@ function createSettingsChatComponent(options) {
|
|
|
458
561
|
);
|
|
459
562
|
const content = [...queueLines, ...input, ...detailLines, ...preview];
|
|
460
563
|
const available = rows - content.length;
|
|
461
|
-
|
|
564
|
+
historyRows = available;
|
|
565
|
+
if (available === 0) return content.map((line) => truncateToWidth(line, width, ""));
|
|
566
|
+
const lines = transcript.render(width);
|
|
567
|
+
historyMaximum = Math.max(0, lines.length - available);
|
|
568
|
+
if (historyTop !== void 0) {
|
|
569
|
+
historyTop = Math.min(historyAnchor ? transcript.rowAt(historyAnchor) : historyTop, historyMaximum);
|
|
570
|
+
if (historyTop === historyMaximum) historyTop = void 0;
|
|
571
|
+
}
|
|
572
|
+
const top = historyTop ?? historyMaximum;
|
|
573
|
+
historyAnchor = historyTop === void 0 ? void 0 : transcript.anchorAt(top);
|
|
574
|
+
const history = lines.slice(top, top + available);
|
|
462
575
|
return [...history, ...Array.from({ length: available - history.length }, () => ""), ...content].map(
|
|
463
576
|
(line) => truncateToWidth(line, width, "")
|
|
464
577
|
);
|
|
@@ -479,18 +592,21 @@ function createSettingsChatComponent(options) {
|
|
|
479
592
|
} else if (saveKey && matchesKey(data, saveKey) && !saveKeyReserved(data, keybindings)) {
|
|
480
593
|
state.input = editor.getExpandedText();
|
|
481
594
|
options.complete("save");
|
|
482
|
-
} else if (
|
|
595
|
+
} else if (settingsChatStopInput(data, keybindings)) {
|
|
483
596
|
if (pending) {
|
|
484
597
|
stopping = true;
|
|
485
598
|
restoreQueue();
|
|
486
599
|
agent.abort();
|
|
487
|
-
} else {
|
|
488
|
-
state.input = editor.getExpandedText();
|
|
489
|
-
options.complete("review");
|
|
490
600
|
}
|
|
491
601
|
} else editor.handleInput(data);
|
|
492
602
|
render();
|
|
493
603
|
},
|
|
604
|
+
handleMouse(event) {
|
|
605
|
+
if (disposed || signal.aborted || inPaste || historyRows === 0 || event.type !== "wheel" || !event.wheelDelta)
|
|
606
|
+
return void 0;
|
|
607
|
+
scrollHistory(event.wheelDelta < 0 ? -3 : 3);
|
|
608
|
+
return { handled: true, render: true };
|
|
609
|
+
},
|
|
494
610
|
dispose() {
|
|
495
611
|
if (disposed) return;
|
|
496
612
|
disposed = true;
|
|
@@ -917,40 +1033,7 @@ async function showSettingsAgentChat(ctx, options, base) {
|
|
|
917
1033
|
while (owner.isCurrent()) {
|
|
918
1034
|
const action = await showSettingsChat(ctx, agent, draft, state, owner, preview);
|
|
919
1035
|
if (!owner.isCurrent() || action === "discard") return "close";
|
|
920
|
-
|
|
921
|
-
ctx,
|
|
922
|
-
"Configuration chat \u2014 preview only",
|
|
923
|
-
(width, theme) => [
|
|
924
|
-
"The agent has not changed the active settings file.",
|
|
925
|
-
"Preview uses cached data; enabling modules here does not run commands or network requests.",
|
|
926
|
-
...renderSettingsChatPreview(width, preview(width), theme),
|
|
927
|
-
...sanitizeTerminalDocument3(draft.diagnostics).split("\n")
|
|
928
|
-
],
|
|
929
|
-
[
|
|
930
|
-
{ value: "continue", label: "Continue conversation" },
|
|
931
|
-
{ value: "document", label: "Review exact draft\u2026" },
|
|
932
|
-
{ value: "transcript", label: "Review full conversation\u2026" },
|
|
933
|
-
...draft.candidate ? [{ value: "save", label: "Save draft as profile\u2026" }] : [],
|
|
934
|
-
{ value: "discard", label: "Discard preview and close" }
|
|
935
|
-
],
|
|
936
|
-
owner.signal,
|
|
937
|
-
owner.isCurrent
|
|
938
|
-
);
|
|
939
|
-
if (!owner.isCurrent() || !result || result.kind === "closed") return "close";
|
|
940
|
-
if (result?.kind !== "selected") continue;
|
|
941
|
-
if (result.value === "discard") return "close";
|
|
942
|
-
if (result.value === "document" || result.value === "transcript") {
|
|
943
|
-
const reviewed2 = await reviewText(
|
|
944
|
-
ctx,
|
|
945
|
-
owner,
|
|
946
|
-
result.value === "document" ? "Settings draft" : "Configuration conversation",
|
|
947
|
-
result.value === "document" ? draft.rawDocument : settingsChatTranscript(agent).join("\n\n"),
|
|
948
|
-
result.value === "document"
|
|
949
|
-
);
|
|
950
|
-
if (!owner.isCurrent() || !reviewed2) return "close";
|
|
951
|
-
continue;
|
|
952
|
-
}
|
|
953
|
-
if (result.value !== "save" || !draft.candidate) continue;
|
|
1036
|
+
if (!draft.candidate) continue;
|
|
954
1037
|
const candidate = draft.candidate;
|
|
955
1038
|
const revision = draft.revision;
|
|
956
1039
|
const reviewed = await reviewText(ctx, owner, "Review draft before saving", candidate.rawDocument ?? "", true);
|
|
@@ -981,11 +1064,11 @@ async function showSettingsAgentChat(ctx, options, base) {
|
|
|
981
1064
|
if (!owner.isCurrent()) return "close";
|
|
982
1065
|
if (!confirmed) return "close";
|
|
983
1066
|
try {
|
|
984
|
-
const
|
|
1067
|
+
const result = await commitActiveDocument(ctx, options, candidate, owner, expected, repair, () => {
|
|
985
1068
|
draft.assertRevision(revision);
|
|
986
1069
|
assertProfileUnchanged(options.settingsPath, saved);
|
|
987
1070
|
});
|
|
988
|
-
if (
|
|
1071
|
+
if (result === "applied") return "applied";
|
|
989
1072
|
return "close";
|
|
990
1073
|
} catch (error) {
|
|
991
1074
|
if (!base.signal.aborted && base.isCurrent())
|
|
@@ -1038,4 +1121,4 @@ async function reviewText(ctx, owner, title, content, toml) {
|
|
|
1038
1121
|
export {
|
|
1039
1122
|
showSettingsAgentChat
|
|
1040
1123
|
};
|
|
1041
|
-
//# sourceMappingURL=command-settings-chat-
|
|
1124
|
+
//# sourceMappingURL=command-settings-chat-5AHP3JGV.ts.map
|