@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
package/src/settings-chat-ui.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "@earendil-works/pi-coding-agent";
|
|
9
9
|
import {
|
|
10
10
|
CURSOR_MARKER,
|
|
11
|
+
decodeKittyPrintable,
|
|
11
12
|
Editor,
|
|
12
13
|
getKeybindings,
|
|
13
14
|
isKeyRelease,
|
|
@@ -16,15 +17,16 @@ import {
|
|
|
16
17
|
parseKey,
|
|
17
18
|
type TUI,
|
|
18
19
|
TUI_KEYBINDINGS,
|
|
20
|
+
type TuiMouseEvent,
|
|
19
21
|
truncateToWidth,
|
|
20
22
|
} from "@earendil-works/pi-tui";
|
|
21
23
|
import { HorizontalRule, renderBoundedFrame, runCustomInteraction } from "@narumitw/pi-tui-kit";
|
|
22
24
|
import { sanitizeTerminalDocument } from "@narumitw/pi-tui-kit/terminal-document";
|
|
23
25
|
import type { WorkflowOwner } from "./command-configuration.js";
|
|
24
|
-
import { createSettingsChatTranscript } from "./settings-chat-transcript.js";
|
|
26
|
+
import { createSettingsChatTranscript, type SettingsChatAnchor } from "./settings-chat-transcript.js";
|
|
25
27
|
import type { SettingsDraft } from "./settings-draft.js";
|
|
26
28
|
|
|
27
|
-
export type SettingsChatAction = "
|
|
29
|
+
export type SettingsChatAction = "save" | "discard";
|
|
28
30
|
|
|
29
31
|
const SAVE_SHORTCUTS = [
|
|
30
32
|
{ key: "ctrl+s", inputs: ["\x13", "\x1b[115;5u", "\x1b[27;5;115~"] },
|
|
@@ -39,7 +41,14 @@ function saveKeyReserved(data: string, keybindings: Pick<KeybindingsManager, "ma
|
|
|
39
41
|
(action) => editorKeys.matches(data, action) || keybindings.matches(data, action),
|
|
40
42
|
) ||
|
|
41
43
|
(
|
|
42
|
-
[
|
|
44
|
+
[
|
|
45
|
+
"app.clipboard.pasteImage",
|
|
46
|
+
"app.interrupt",
|
|
47
|
+
"app.exit",
|
|
48
|
+
"app.message.followUp",
|
|
49
|
+
"app.message.dequeue",
|
|
50
|
+
"app.tools.expand",
|
|
51
|
+
] as const
|
|
43
52
|
).some((action) => keybindings.matches(data, action))
|
|
44
53
|
);
|
|
45
54
|
}
|
|
@@ -59,31 +68,67 @@ export interface ChatViewState {
|
|
|
59
68
|
error: string;
|
|
60
69
|
}
|
|
61
70
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
// Installed Editor.handleInput actions before pageUp/pageDown, in native order.
|
|
72
|
+
// No autocomplete provider is installed in this chat. Jump triggers come AFTER paging.
|
|
73
|
+
const BEFORE_PAGE_ACTIONS = [
|
|
74
|
+
"tui.input.copy",
|
|
75
|
+
"tui.editor.undo",
|
|
76
|
+
"tui.input.tab",
|
|
77
|
+
"tui.editor.deleteToLineEnd",
|
|
78
|
+
"tui.editor.deleteToLineStart",
|
|
79
|
+
"tui.editor.deleteWordBackward",
|
|
80
|
+
"tui.editor.deleteWordForward",
|
|
81
|
+
"tui.editor.deleteCharBackward",
|
|
82
|
+
"tui.editor.deleteCharForward",
|
|
83
|
+
"tui.editor.yank",
|
|
84
|
+
"tui.editor.yankPop",
|
|
85
|
+
"tui.editor.historyPrevious",
|
|
86
|
+
"tui.editor.historyNext",
|
|
87
|
+
"tui.editor.cursorLineStart",
|
|
88
|
+
"tui.editor.cursorLineEnd",
|
|
89
|
+
"tui.editor.cursorWordLeft",
|
|
90
|
+
"tui.editor.cursorWordRight",
|
|
91
|
+
"tui.input.newLine",
|
|
92
|
+
"tui.input.submit",
|
|
93
|
+
"tui.editor.cursorUp",
|
|
94
|
+
"tui.editor.cursorDown",
|
|
95
|
+
"tui.editor.cursorRight",
|
|
96
|
+
"tui.editor.cursorLeft",
|
|
97
|
+
] as const;
|
|
98
|
+
|
|
99
|
+
/** Match Editor's printable jump targets without a Jiti-incompatible package subpath. */
|
|
100
|
+
function nativeJumpPrintable(data: string): boolean {
|
|
101
|
+
if (decodeKittyPrintable(data) !== undefined || data.charCodeAt(0) >= 32) return true;
|
|
102
|
+
// Editor also accepts plain/Shift modifyOtherKeys text, ignoring Caps/Num Lock bits.
|
|
103
|
+
if (!data.startsWith("\x1b[27;")) return false;
|
|
104
|
+
const match = /^(\d+);(\d+)~$/u.exec(data.slice(5));
|
|
105
|
+
if (!match) return false;
|
|
106
|
+
const modifier = Number(match[1]) - 1;
|
|
107
|
+
const codepoint = Number(match[2]);
|
|
108
|
+
return (modifier & ~(1 | 64 | 128)) === 0 && codepoint >= 32 && codepoint <= 0x10ffff;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function nativeBeforePage(data: string): boolean {
|
|
112
|
+
return (
|
|
113
|
+
BEFORE_PAGE_ACTIONS.some((action) => getKeybindings().matches(data, action)) ||
|
|
114
|
+
matchesKey(data, "shift+backspace") ||
|
|
115
|
+
matchesKey(data, "shift+delete") ||
|
|
116
|
+
data.charCodeAt(0) === 10 ||
|
|
117
|
+
data === "\x1b\r" ||
|
|
118
|
+
data === "\x1b[13;2~" ||
|
|
119
|
+
(data.length > 1 && data.includes("\x1b") && data.includes("\r"))
|
|
120
|
+
);
|
|
78
121
|
}
|
|
79
122
|
|
|
80
123
|
/** Add labels only to the public Editor border hooks; native scroll indicators keep priority. */
|
|
81
124
|
export class SettingsChatEditor extends CustomEditor {
|
|
125
|
+
onTranscriptPage?: (direction: -1 | 1) => void;
|
|
126
|
+
private awaitingJump: string | undefined;
|
|
82
127
|
constructor(
|
|
83
128
|
tui: TUI,
|
|
84
129
|
private readonly chromeTheme: Theme,
|
|
85
130
|
private readonly labels: () => { top: string; bottom: string },
|
|
86
|
-
|
|
131
|
+
private readonly chatKeys: KeybindingsManager,
|
|
87
132
|
) {
|
|
88
133
|
super(
|
|
89
134
|
tui,
|
|
@@ -97,11 +142,55 @@ export class SettingsChatEditor extends CustomEditor {
|
|
|
97
142
|
noMatch: (text) => chromeTheme.fg("warning", text),
|
|
98
143
|
},
|
|
99
144
|
},
|
|
100
|
-
|
|
145
|
+
chatKeys,
|
|
101
146
|
);
|
|
102
147
|
}
|
|
148
|
+
handleInput(data: string): void {
|
|
149
|
+
const kb = getKeybindings();
|
|
150
|
+
// These CustomEditor branches consume input before reaching Editor, even
|
|
151
|
+
// without a handler. Explicit history bypasses registered message actions.
|
|
152
|
+
const interrupt = this.chatKeys.matches(data, "app.interrupt");
|
|
153
|
+
const appConsumes =
|
|
154
|
+
this.chatKeys.matches(data, "app.clipboard.pasteImage") ||
|
|
155
|
+
(interrupt && this.onEscape !== undefined) ||
|
|
156
|
+
(!interrupt && this.chatKeys.matches(data, "app.exit") && this.getText().length === 0);
|
|
157
|
+
const history =
|
|
158
|
+
this.chatKeys.matches(data, "tui.editor.historyPrevious") ||
|
|
159
|
+
this.chatKeys.matches(data, "tui.editor.historyNext");
|
|
160
|
+
const registeredAction =
|
|
161
|
+
!interrupt &&
|
|
162
|
+
!history &&
|
|
163
|
+
(this.chatKeys.matches(data, "app.message.followUp") ||
|
|
164
|
+
this.chatKeys.matches(data, "app.message.dequeue") ||
|
|
165
|
+
this.chatKeys.matches(data, "app.tools.expand"));
|
|
166
|
+
if (appConsumes || registeredAction) {
|
|
167
|
+
super.handleInput(data);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const jump = kb.matches(data, "tui.editor.jumpForward") || kb.matches(data, "tui.editor.jumpBackward");
|
|
171
|
+
const pendingJump = this.awaitingJump;
|
|
172
|
+
const jumpConsumes = pendingJump !== undefined && (jump || nativeJumpPrintable(data));
|
|
173
|
+
this.awaitingJump = undefined;
|
|
174
|
+
const earlier = nativeBeforePage(data);
|
|
175
|
+
const direction = kb.matches(data, "tui.editor.pageUp")
|
|
176
|
+
? -1
|
|
177
|
+
: kb.matches(data, "tui.editor.pageDown")
|
|
178
|
+
? 1
|
|
179
|
+
: undefined;
|
|
180
|
+
// The chat registers no interrupt handler. CustomEditor forwards it to
|
|
181
|
+
// Editor, then returns; retain that branch and its jump-state transition.
|
|
182
|
+
if (!interrupt && !jumpConsumes && !earlier && direction !== undefined && this.onTranscriptPage) {
|
|
183
|
+
// Repeating the trigger cancels native jump mode without moving the editor.
|
|
184
|
+
if (pendingJump !== undefined) Editor.prototype.handleInput.call(this, pendingJump);
|
|
185
|
+
this.onTranscriptPage(direction);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (!jumpConsumes && !earlier && direction === undefined && jump) this.awaitingJump = data;
|
|
189
|
+
super.handleInput(data);
|
|
190
|
+
}
|
|
103
191
|
/** Bypass app shortcuts while the native Editor owns a bracketed paste. */
|
|
104
192
|
handlePasteInput(data: string): void {
|
|
193
|
+
this.awaitingJump = undefined;
|
|
105
194
|
Editor.prototype.handleInput.call(this, data);
|
|
106
195
|
}
|
|
107
196
|
protected renderTopBorder(width: number, hiddenLineCount: number): string {
|
|
@@ -126,8 +215,8 @@ export class SettingsChatEditor extends CustomEditor {
|
|
|
126
215
|
}
|
|
127
216
|
}
|
|
128
217
|
|
|
129
|
-
/** Editor actions win collisions. Escape remains a
|
|
130
|
-
export function
|
|
218
|
+
/** Editor actions win collisions. Escape remains a stop fallback for unusable cancel settings. */
|
|
219
|
+
export function settingsChatStopInput(data: string, keybindings: Pick<KeybindingsManager, "matches">): boolean {
|
|
131
220
|
const editorKeys = getKeybindings();
|
|
132
221
|
const parsed = parseKey(data);
|
|
133
222
|
const textKey = parsed?.startsWith("shift+") ? parsed.slice(6) : parsed;
|
|
@@ -150,26 +239,6 @@ export function settingsChatReviewInput(data: string, keybindings: Pick<Keybindi
|
|
|
150
239
|
return !editing && (keybindings.matches(data, "tui.select.cancel") || matchesKey(data, Key.escape));
|
|
151
240
|
}
|
|
152
241
|
|
|
153
|
-
export function settingsChatTranscript(agent: Agent): string[] {
|
|
154
|
-
return [...agent.state.messages, ...(agent.state.streamingMessage ? [agent.state.streamingMessage] : [])]
|
|
155
|
-
.filter((message) => message.role !== "system")
|
|
156
|
-
.flatMap((message) => {
|
|
157
|
-
if (!("content" in message) || !Array.isArray(message.content)) return [];
|
|
158
|
-
const label = message.role === "user" ? "You" : message.role === "assistant" ? "Agent" : "Tool";
|
|
159
|
-
const text = message.content
|
|
160
|
-
.map((part) => {
|
|
161
|
-
if (part.type === "text") return part.text;
|
|
162
|
-
if (part.type === "toolCall") return `Using ${part.name}…`;
|
|
163
|
-
return "";
|
|
164
|
-
})
|
|
165
|
-
.filter(Boolean)
|
|
166
|
-
.join("\n");
|
|
167
|
-
const error = message.role === "assistant" ? message.errorMessage : undefined;
|
|
168
|
-
const output = [text, error].filter(Boolean).join("\n");
|
|
169
|
-
return output ? [`${label}: ${sanitizeTerminalDocument(output)}`] : [];
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
242
|
export function createSettingsChatComponent(options: {
|
|
174
243
|
agent: Agent;
|
|
175
244
|
draft: SettingsDraft;
|
|
@@ -186,6 +255,17 @@ export function createSettingsChatComponent(options: {
|
|
|
186
255
|
let inPaste = false;
|
|
187
256
|
let pending: Promise<void> | undefined;
|
|
188
257
|
let stopping = false;
|
|
258
|
+
// Undefined follows output; message identity keeps retained history stable after eviction.
|
|
259
|
+
let historyTop: number | undefined;
|
|
260
|
+
let historyAnchor: SettingsChatAnchor | undefined;
|
|
261
|
+
let historyRows = 0;
|
|
262
|
+
let historyMaximum = 0;
|
|
263
|
+
const scrollHistory = (delta: number) => {
|
|
264
|
+
const next = Math.max(0, Math.min(historyMaximum, (historyTop ?? historyMaximum) + delta));
|
|
265
|
+
historyTop = next === historyMaximum ? undefined : next;
|
|
266
|
+
historyAnchor = historyTop === undefined ? undefined : transcript.anchorAt(historyTop);
|
|
267
|
+
render();
|
|
268
|
+
};
|
|
189
269
|
const queued: Array<{ kind: "steer" | "followUp"; message: UserMessage; text: string }> = [];
|
|
190
270
|
const editor = new SettingsChatEditor(
|
|
191
271
|
tui,
|
|
@@ -200,17 +280,22 @@ export function createSettingsChatComponent(options: {
|
|
|
200
280
|
? "Warnings"
|
|
201
281
|
: "Valid";
|
|
202
282
|
const saveKey = !pending && !inPaste && draft.candidate ? settingsChatSaveShortcut(keybindings) : undefined;
|
|
283
|
+
// Match Pi core: sentence-case states and lowercase key + "to" action hints.
|
|
284
|
+
const working = !inPaste && settingsChatStopInput("\x1b", keybindings) ? "Working · esc to interrupt" : "Working";
|
|
203
285
|
return {
|
|
204
286
|
top: queued.length > 0 ? `pi-starship · ${queued.length} queued` : "pi-starship",
|
|
205
|
-
bottom: `${status} · unsaved · ${pending ?
|
|
287
|
+
bottom: `${status} · unsaved · ${pending ? working : saveKey ? `${saveKey} to save profile` : "Idle"} · ctrl+c to discard`,
|
|
206
288
|
};
|
|
207
289
|
},
|
|
208
290
|
keybindings,
|
|
209
291
|
);
|
|
292
|
+
editor.onTranscriptPage = (direction) => scrollHistory(direction * Math.max(1, historyRows));
|
|
210
293
|
editor.setText(state.input);
|
|
211
294
|
const render = () => {
|
|
212
295
|
if (!disposed && !signal.aborted) tui.requestRender();
|
|
213
296
|
};
|
|
297
|
+
// Update transcript identities before this listener requests the next frame.
|
|
298
|
+
const transcript = createSettingsChatTranscript(agent, tui, draft.directory);
|
|
214
299
|
const unsubscribe = agent.subscribe((event) => {
|
|
215
300
|
if (event.type === "message_start") {
|
|
216
301
|
const index = queued.findIndex((item) => item.message === event.message);
|
|
@@ -237,7 +322,6 @@ export function createSettingsChatComponent(options: {
|
|
|
237
322
|
};
|
|
238
323
|
signal.addEventListener("abort", abort, { once: true });
|
|
239
324
|
const rule = new HorizontalRule({ ruleStyle: (text) => theme.fg("border", text) });
|
|
240
|
-
const transcript = createSettingsChatTranscript(agent, tui, draft.directory);
|
|
241
325
|
const failed = () => {
|
|
242
326
|
const last = agent.state.messages.at(-1);
|
|
243
327
|
return last?.role === "assistant" && (last.stopReason === "error" || last.stopReason === "aborted");
|
|
@@ -284,6 +368,7 @@ export function createSettingsChatComponent(options: {
|
|
|
284
368
|
editor.onSubmit = (input) => submit(input, "steer");
|
|
285
369
|
editor.onAction("app.message.followUp", () => submit(editor.getExpandedText().trim(), "followUp"));
|
|
286
370
|
editor.onAction("app.message.dequeue", restoreQueue);
|
|
371
|
+
editor.onAction("app.tools.expand", () => transcript.toggleTools());
|
|
287
372
|
return {
|
|
288
373
|
get focused() {
|
|
289
374
|
return editor.focused;
|
|
@@ -292,6 +377,7 @@ export function createSettingsChatComponent(options: {
|
|
|
292
377
|
editor.focused = value;
|
|
293
378
|
},
|
|
294
379
|
render(width: number): string[] {
|
|
380
|
+
historyRows = 0;
|
|
295
381
|
if (disposed || signal.aborted || width <= 0) return [];
|
|
296
382
|
const rows = Math.max(0, Math.floor(Number.isFinite(tui.terminal.rows) ? tui.terminal.rows : 24));
|
|
297
383
|
if (rows === 0) return [];
|
|
@@ -334,7 +420,18 @@ export function createSettingsChatComponent(options: {
|
|
|
334
420
|
);
|
|
335
421
|
const content = [...queueLines, ...input, ...detailLines, ...preview];
|
|
336
422
|
const available = rows - content.length;
|
|
337
|
-
|
|
423
|
+
historyRows = available;
|
|
424
|
+
// Keep the anchor while the dock temporarily leaves no room for history.
|
|
425
|
+
if (available === 0) return content.map((line) => truncateToWidth(line, width, ""));
|
|
426
|
+
const lines = transcript.render(width);
|
|
427
|
+
historyMaximum = Math.max(0, lines.length - available);
|
|
428
|
+
if (historyTop !== undefined) {
|
|
429
|
+
historyTop = Math.min(historyAnchor ? transcript.rowAt(historyAnchor) : historyTop, historyMaximum);
|
|
430
|
+
if (historyTop === historyMaximum) historyTop = undefined;
|
|
431
|
+
}
|
|
432
|
+
const top = historyTop ?? historyMaximum;
|
|
433
|
+
historyAnchor = historyTop === undefined ? undefined : transcript.anchorAt(top);
|
|
434
|
+
const history = lines.slice(top, top + available);
|
|
338
435
|
return [...history, ...Array.from({ length: available - history.length }, () => ""), ...content].map((line) =>
|
|
339
436
|
truncateToWidth(line, width, ""),
|
|
340
437
|
);
|
|
@@ -356,18 +453,21 @@ export function createSettingsChatComponent(options: {
|
|
|
356
453
|
} else if (saveKey && matchesKey(data, saveKey) && !saveKeyReserved(data, keybindings)) {
|
|
357
454
|
state.input = editor.getExpandedText();
|
|
358
455
|
options.complete("save");
|
|
359
|
-
} else if (
|
|
456
|
+
} else if (settingsChatStopInput(data, keybindings)) {
|
|
360
457
|
if (pending) {
|
|
361
458
|
stopping = true;
|
|
362
459
|
restoreQueue();
|
|
363
460
|
agent.abort();
|
|
364
|
-
} else {
|
|
365
|
-
state.input = editor.getExpandedText();
|
|
366
|
-
options.complete("review");
|
|
367
461
|
}
|
|
368
462
|
} else editor.handleInput(data);
|
|
369
463
|
render();
|
|
370
464
|
},
|
|
465
|
+
handleMouse(event: TuiMouseEvent) {
|
|
466
|
+
if (disposed || signal.aborted || inPaste || historyRows === 0 || event.type !== "wheel" || !event.wheelDelta)
|
|
467
|
+
return undefined;
|
|
468
|
+
scrollHistory(event.wheelDelta < 0 ? -3 : 3);
|
|
469
|
+
return { handled: true, render: true };
|
|
470
|
+
},
|
|
371
471
|
dispose() {
|
|
372
472
|
if (disposed) return;
|
|
373
473
|
disposed = true;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/command-commit.ts", "../../src/command-profiles.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ExtensionCommandContext, withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport type { ConfigurationCommandOptions, WorkflowOwner } from \"./command-configuration.js\";\nimport {\n assertConfigDocumentUnchanged,\n atomicRestoreConfigDocument,\n atomicSaveConfigDocument,\n type ConfigDocumentSnapshot,\n ConfigPublicationError,\n type LoadedStarshipConfig,\n readConfigDocumentSnapshot,\n removeConfigDocumentIfMatches,\n validateConfigDocument,\n} from \"./config.js\";\nimport { archiveConfigDocument } from \"./profile-store.js\";\n\nexport interface CommitOptions extends ConfigurationCommandOptions {\n save?: (settingsPath: string, rawDocument: string) => LoadedStarshipConfig;\n restore?: (settingsPath: string, rawDocument: string) => void;\n archive?: typeof archiveConfigDocument;\n}\n\nexport interface CommitExpectation {\n previous: LoadedStarshipConfig;\n revision: number | undefined;\n disk: ConfigDocumentSnapshot;\n}\n\nexport function captureCommitExpectation(options: ConfigurationCommandOptions): CommitExpectation {\n return {\n previous: options.getLoaded(),\n revision: options.getLoadedRevision?.(),\n disk: readConfigDocumentSnapshot(options.settingsPath),\n };\n}\n\nexport function commitOwnerCurrent(\n options: ConfigurationCommandOptions,\n owner: WorkflowOwner,\n expected: CommitExpectation,\n): boolean {\n const loaded = options.getLoaded();\n return (\n !owner.signal.aborted &&\n owner.isCurrent() &&\n loaded.rawDocument === expected.previous.rawDocument &&\n loaded.source === expected.previous.source &&\n JSON.stringify(loaded.diagnostics) === JSON.stringify(expected.previous.diagnostics) &&\n options.getLoadedRevision?.() === expected.revision\n );\n}\n\n/** The queue has asynchronous admission; the owned file/runtime transaction has no await boundary. */\nexport async function commitActiveDocument(\n ctx: ExtensionCommandContext,\n options: CommitOptions,\n candidate: LoadedStarshipConfig,\n owner: WorkflowOwner,\n expected: CommitExpectation,\n allowInvalid = false,\n checkCandidate?: () => void,\n): Promise<\"applied\" | \"cancel\"> {\n const raw = candidate.rawDocument;\n if (raw === undefined) throw new Error(\"The candidate settings document is unavailable\");\n return withFileMutationQueue(options.settingsPath, async () => {\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n checkCandidate?.();\n assertConfigDocumentUnchanged(options.settingsPath, expected.disk);\n const previousBytes = expected.disk.rawBytes;\n if (expected.previous.rawDocument !== previousBytes?.toString(\"utf8\")) {\n throw new Error(\n \"The active file differs from the loaded document. Reload and review it before replacing settings.\",\n );\n }\n const invalid = expected.previous.diagnostics.some((item) => item.severity === \"error\");\n if (invalid && !allowInvalid)\n throw new Error(\"The active settings document is invalid. Use explicit repair or recovery before replacing it.\");\n // Always validate again at the publication boundary, not only in the preview layer.\n validateConfigDocument(options.settingsPath, raw);\n if (previousBytes?.equals(Buffer.from(raw))) return \"applied\";\n\n let recoveryPath: string | undefined;\n if (previousBytes !== undefined) {\n recoveryPath = (options.archive ?? archiveConfigDocument)(options.settingsPath, previousBytes).path;\n }\n // A recovery publication can fail or observe an external edit. Never publish over that edit.\n try {\n assertConfigDocumentUnchanged(options.settingsPath, expected.disk);\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n checkCandidate?.();\n } catch (error) {\n throw new Error(`${message(error)}.${recoveryNote(recoveryPath)}`);\n }\n let saved: LoadedStarshipConfig;\n try {\n saved = options.save\n ? options.save(options.settingsPath, raw)\n : atomicSaveConfigDocument(options.settingsPath, raw, {}, expected.disk);\n } catch (error) {\n if (error instanceof ConfigPublicationError) {\n const rollback = restorePrevious(ctx, options, owner, expected, raw, error.fileIdentity, false);\n throw new Error(`Footer settings were not saved: ${message(error)}. ${rollback}${recoveryNote(recoveryPath)}`);\n }\n throw new Error(\n `Footer settings were not saved: ${message(error)}. The previous footer remains active.${recoveryNote(recoveryPath)}`,\n );\n }\n try {\n if (\n owner.signal.aborted ||\n !(owner.isSessionCurrent?.() ?? owner.isCurrent()) ||\n options.getLoadedRevision?.() !== expected.revision\n ) {\n throw new Error(\"The configuration owner changed during publication\");\n }\n options.apply(saved, ctx);\n } catch (error) {\n const rollback = restorePrevious(ctx, options, owner, expected, raw, saved.fileIdentity, true);\n throw new Error(\n `Footer settings could not be applied: ${message(error)}. ${rollback}${recoveryNote(recoveryPath)}`,\n );\n }\n return \"applied\";\n });\n}\n\nfunction restorePrevious(\n ctx: ExtensionCommandContext,\n options: CommitOptions,\n owner: WorkflowOwner,\n expected: CommitExpectation,\n raw: string,\n identity: LoadedStarshipConfig[\"fileIdentity\"],\n restoreRuntime: boolean,\n): string {\n try {\n if (owner.signal.aborted || !(owner.isSessionCurrent?.() ?? owner.isCurrent()))\n throw new Error(\"The session owner changed; stale restoration was blocked\");\n const current = options.getLoaded();\n if (current.rawDocument !== expected.previous.rawDocument && current.rawDocument !== raw) {\n throw new Error(\"The active runtime changed; stale restoration was blocked\");\n }\n if (!identity) throw new Error(\"The saved settings document identity is unavailable\");\n assertConfigDocumentUnchanged(options.settingsPath, { rawBytes: Buffer.from(raw), fileIdentity: identity });\n if (expected.disk.rawBytes === undefined) {\n removeConfigDocumentIfMatches(options.settingsPath, raw, identity);\n } else if (options.restore && expected.disk.rawBytes.equals(Buffer.from(expected.previous.rawDocument ?? \"\"))) {\n options.restore(options.settingsPath, expected.previous.rawDocument ?? \"\");\n } else {\n atomicRestoreConfigDocument(\n options.settingsPath,\n expected.disk.rawBytes,\n {},\n { rawBytes: Buffer.from(raw), fileIdentity: identity },\n );\n }\n if (restoreRuntime) options.apply(expected.previous, ctx);\n return \"The previous configuration was restored.\";\n } catch (error) {\n return `Restoring the previous configuration also failed: ${message(error)}. Active path: ${options.settingsPath}.`;\n }\n}\n\nfunction recoveryNote(path: string | undefined): string {\n return path ? ` Recovery copy retained: ${path}.` : \"\";\n}\n\nfunction message(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n", "import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { isKeyRelease, Key, matchesKey } from \"@earendil-works/pi-tui\";\nimport { defineMenu, runLiveChoice, runMenu } from \"@narumitw/pi-tui-kit\";\nimport { sanitizeTerminalText } from \"@narumitw/pi-tui-kit/terminal-text\";\nimport type { WorkflowOwner } from \"./command-configuration.js\";\nimport type { StarshipCommandOptions } from \"./commands.js\";\nimport { BUILT_IN_EXAMPLE, type LoadedStarshipConfig, validateConfigDocument } from \"./config.js\";\nimport {\n createProfile,\n deleteHistory,\n deleteProfile,\n duplicateProfile,\n type HistoryDocument,\n listHistory,\n listProfiles,\n type ProfileDocument,\n readHistory,\n readProfile,\n renameProfile,\n saveProfile,\n} from \"./profile-store.js\";\n\nexport type ProfileApplyCandidate = (\n loaded: LoadedStarshipConfig,\n owner: WorkflowOwner,\n checkCandidate: () => void,\n name: string,\n) => Promise<\"applied\" | \"stay\" | \"close\">;\n\ntype Document = ProfileDocument | HistoryDocument;\ntype Exit = \"back\" | \"close\";\ninterface Action {\n id: string;\n label: string;\n description?: string;\n disabled?: boolean;\n disabledReason?: string;\n}\ninterface Candidate {\n loaded?: LoadedStarshipConfig;\n lines: string[];\n}\n\nconst PREVIEW_NOTICE = \"Preview uses the current runtime snapshot only; unavailable module data can be empty.\";\nconst SAVE_CURRENT = \"save-current\";\nclass FlowEnded extends Error {}\n\n/** Profiles are independent copies. Only applyCandidate may replace active settings. */\nexport async function showProfiles(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n applyCandidate: ProfileApplyCandidate,\n): Promise<Exit> {\n return browseDocuments(ctx, options, owner, applyCandidate, \"profile\");\n}\n\nexport async function showHistory(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n applyCandidate: ProfileApplyCandidate,\n): Promise<Exit> {\n return browseDocuments(ctx, options, owner, applyCandidate, \"history\");\n}\n\n/** Reusable by reviewed preset/Gist candidates; never writes the active file. */\nexport async function saveAsProfile(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n raw: string,\n): Promise<ProfileDocument | \"close\" | undefined> {\n if (!interactive(ctx) || !current(owner)) return undefined;\n const flow = createFlow(ctx, options, owner);\n try {\n candidateFor(options, raw, true);\n const saved = await saveNamedCopy(ctx, options, flow, raw);\n flow.ensure();\n return saved;\n } catch (error) {\n if (flow.signal.aborted || !flow.sessionCurrent()) return \"close\";\n report(ctx, flow, error);\n return undefined;\n } finally {\n flow.dispose();\n }\n}\n\nasync function browseDocuments(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n applyCandidate: ProfileApplyCandidate,\n kind: Document[\"kind\"],\n): Promise<Exit> {\n if (!interactive(ctx) || !current(owner)) return \"close\";\n const flow = createFlow(ctx, options, owner);\n let selectedId: string | undefined;\n try {\n while (flow.current()) {\n let interacted = false;\n try {\n const documents: Document[] =\n kind === \"profile\" ? listProfiles(options.settingsPath) : listHistory(options.settingsPath);\n const active = options.getLoaded();\n const matches = documents.filter(\n (document) => document.rawDocument !== undefined && document.rawDocument === active.rawDocument,\n );\n const candidates = new Map(\n documents.map((document) => [documentId(document), candidateFor(options, document.rawDocument)]),\n );\n const selection = await runLiveChoice(ctx, {\n title: kind === \"profile\" ? \"Profiles\" : \"History\",\n lines: [\n active.rawDocument === undefined && active.diagnostics.length === 0\n ? \"Active: Built-in defaults\"\n : active.diagnostics.some((item) => item.severity === \"error\")\n ? \"Active: Invalid settings document \u00B7 replacement requires explicit recovery\"\n : \"Active: Independent settings document\",\n ...(kind === \"profile\" && matches.length === 0 ? [\"Current settings are not saved as a profile\"] : []),\n PREVIEW_NOTICE,\n ],\n items: [\n ...(kind === \"profile\"\n ? [\n {\n id: SAVE_CURRENT,\n label: \"Save current as\u2026\",\n description: \"Copy exact loaded TOML; keep active settings unchanged\",\n },\n ]\n : []),\n ...documents.map((document) => ({\n id: documentId(document),\n label: safe(document.name),\n description: [\n ...(document.kind === \"history\"\n ? [safe(document.createdAt), ...(document.legacy ? [\"Legacy \u00B7 read-only\"] : [])]\n : []),\n ...(document.rawDocument !== undefined && document.rawDocument === active.rawDocument\n ? [\"Matches active settings\"]\n : []),\n ...(!candidates.get(documentId(document))?.loaded ? [\"Invalid document \u00B7 review or repair\"] : []),\n ].join(\" \u00B7 \"),\n details: [\n `Selected: ${safe(document.name)}`,\n `Path: ${safe(document.path)}`,\n ...(candidates.get(documentId(document))?.lines ?? []),\n ],\n })),\n ],\n initialItemId: selectedId,\n enableSearch: true,\n viewportSize: 10,\n hint: \"back\",\n confirmLabel: \"actions\",\n navigationLabel: \"live preview\",\n signal: flow.signal,\n isCurrent: flow.current,\n onSelectionChange: ({ item, signal }) => {\n if (signal.aborted || !flow.current()) return;\n selectedId = item.id;\n flow.preview(candidates.get(item.id)?.loaded);\n },\n });\n flow.ensure();\n interacted = true;\n if (selection.kind !== \"selected\") {\n return selection.kind === \"closed\" && selection.reason === \"back\" ? \"back\" : \"close\";\n }\n selectedId = selection.itemId;\n if (selectedId === SAVE_CURRENT) {\n flow.preview(undefined);\n const loaded = options.getLoaded();\n if (loaded.diagnostics.some((item) => item.severity === \"error\")) {\n throw new Error(\n \"Cannot save unreadable or malformed active settings as a profile. Repair the settings document first.\",\n );\n }\n const raw = loaded.rawDocument ?? BUILT_IN_EXAMPLE;\n candidateFor(options, raw, true);\n const saved = await saveNamedCopy(ctx, options, flow, raw);\n flow.ensure();\n if (saved) selectedId = documentId(saved);\n continue;\n }\n const document = documents.find((item) => documentId(item) === selectedId);\n if (!document) continue;\n flow.ensure(document);\n const outcome = await documentActions(ctx, options, flow, document, applyCandidate);\n flow.ensure();\n if (outcome === \"close\") return \"close\";\n if (outcome) selectedId = documentId(outcome);\n } catch (error) {\n if (error instanceof FlowEnded || !flow.current()) return \"close\";\n flow.preview(undefined);\n report(ctx, flow, error);\n if (!interacted) return \"close\";\n }\n }\n return \"close\";\n } finally {\n flow.dispose();\n }\n}\n\nasync function documentActions(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n flow: ReturnType<typeof createFlow>,\n document: Document,\n applyCandidate: ProfileApplyCandidate,\n): Promise<Document | \"close\" | undefined> {\n const candidate = candidateFor(options, document.rawDocument);\n const profile = document.kind === \"profile\";\n const activeInvalid = profile && options.getLoaded().diagnostics.some((item) => item.severity === \"error\");\n const action = await actionScreen(ctx, flow, {\n title: `${profile ? \"Profile\" : \"Recovery copy\"}: ${safe(document.name)}`,\n lines: [\n `Path: ${safe(document.path)}`,\n ...(document.kind === \"history\"\n ? [`Recovery time: ${safe(document.createdAt)}`, \"A recovery copy is not proof that an application succeeded.\"]\n : []),\n ...(document.kind === \"history\" && document.legacy\n ? [\"Legacy backup \u00B7 read-only; restore copies bytes without changing this backup.\"]\n : []),\n ...(document.readError ? [safe(document.readError)] : []),\n ...candidate.lines,\n PREVIEW_NOTICE,\n ],\n raw: document.rawDocument,\n actions: [\n {\n id: \"apply\",\n label: profile ? \"Apply\u2026\" : \"Restore\u2026\",\n disabled: !candidate.loaded || activeInvalid,\n disabledReason: activeInvalid\n ? \"Repair active settings or use explicit recovery first\"\n : \"Invalid TOML cannot be applied\",\n },\n ...(profile\n ? [\n { id: \"edit\", label: \"Edit TOML\u2026\" },\n { id: \"rename\", label: \"Rename\u2026\" },\n { id: \"duplicate\", label: \"Duplicate\u2026\" },\n ]\n : [\n {\n id: \"save-as\",\n label: \"Save as a profile\u2026\",\n disabled: !candidate.loaded,\n disabledReason: \"Invalid TOML cannot be saved as a validated profile\",\n },\n ]),\n {\n id: \"delete\",\n label: \"Delete\u2026\",\n disabled: document.kind === \"history\" && document.legacy,\n disabledReason: \"Legacy backups are read-only\",\n },\n ],\n });\n flow.ensure(document);\n if (action === \"close\") return \"close\";\n if (action === \"back\") return undefined;\n if (action === \"apply\" && candidate.loaded) {\n const result = await applyReviewedCandidate(flow, candidate.loaded, applyCandidate, document);\n flow.ensure(document);\n return result === \"close\" ? \"close\" : document;\n }\n if (action === \"edit\" && profile) {\n const result = await editProfile(ctx, options, flow, document, applyCandidate);\n flow.ensure();\n return result;\n }\n if (action === \"rename\" && profile) {\n const name = await flow.dialog(() =>\n ctx.ui.input(`Rename profile: ${safe(document.name)}`, \"New profile name\", { signal: flow.signal }),\n );\n flow.ensure(document);\n if (name === undefined) return document;\n return renameProfile(options.settingsPath, document.name, name, document);\n }\n if (action === \"duplicate\" || (action === \"save-as\" && document.rawDocument !== undefined)) {\n const saved = await saveNamedCopy(ctx, options, flow, document.rawDocument, document);\n flow.ensure(document);\n return action === \"duplicate\" || document.kind === \"history\" ? document : (saved ?? document);\n }\n if (action === \"delete\" && !(document.kind === \"history\" && document.legacy)) {\n const confirmed = await flow.dialog(() =>\n ctx.ui.confirm(\n `Delete ${profile ? \"profile\" : \"recovery copy\"}: ${safe(document.name)}?`,\n `Path: ${safe(document.path)}\\n${profile ? \"This deletes only the saved profile. The active settings copy remains unchanged.\" : \"This permanently deletes only this recovery copy. Active settings remain unchanged.\"}`,\n { signal: flow.signal },\n ),\n );\n flow.ensure(document);\n if (confirmed) {\n if (document.kind === \"profile\") deleteProfile(options.settingsPath, document.name, document);\n else deleteHistory(options.settingsPath, document.name, document);\n }\n }\n return undefined;\n}\n\nasync function editProfile(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n flow: ReturnType<typeof createFlow>,\n original: ProfileDocument,\n applyCandidate: ProfileApplyCandidate,\n): Promise<ProfileDocument | \"close\"> {\n let draft = original.rawDocument ?? \"\";\n if (original.rawDocument === undefined) {\n const repair = await flow.dialog(() =>\n ctx.ui.confirm(\n `Repair invalid UTF-8 profile: ${safe(original.name)}?`,\n `Path: ${safe(original.path)}\\nThe original bytes cannot be edited as TOML text. Open an empty repair draft? Saving replaces these invalid bytes; the saved copy stays unchanged until you select Save profile. Duplicate it first to keep the original bytes.`,\n { signal: flow.signal },\n ),\n );\n flow.ensure(original);\n if (!repair) return original;\n }\n while (flow.current()) {\n // Pi's editor has no signal or public dismissal API. Drain it, then reject\n // stale completion. The owner abort listener clears the footer immediately.\n const edited = await flow.dialog(() => ctx.ui.editor(`Edit profile: ${safe(original.name)}`, draft));\n flow.ensure(original);\n if (edited === undefined) return original;\n draft = edited;\n const candidate = candidateFor(options, draft);\n flow.preview(candidate.loaded);\n const action = await actionScreen(ctx, flow, {\n title: candidate.loaded ? \"Profile draft preview\" : \"Profile draft needs attention\",\n lines: [\n \"Save profile changes only the saved copy, even when it matches active settings.\",\n ...candidate.lines,\n PREVIEW_NOTICE,\n ],\n raw: draft,\n actions: [\n {\n id: \"save\",\n label: \"Save profile\",\n disabled: !candidate.loaded,\n disabledReason: \"Repair the draft before saving\",\n },\n {\n id: \"save-apply\",\n label: \"Save profile and apply\u2026\",\n description: \"Two operations: a failed apply retains the saved profile\",\n disabled: !candidate.loaded,\n disabledReason: \"Repair the draft before saving\",\n },\n { id: \"continue\", label: \"Continue editing\" },\n { id: \"discard\", label: \"Discard draft\" },\n ],\n });\n flow.ensure(original);\n if (action === \"close\") return \"close\";\n if (action === \"discard\") return original;\n if (action === \"continue\" || action === \"back\") continue;\n if (!candidate.loaded || (action !== \"save\" && action !== \"save-apply\")) continue;\n const saved = saveProfile(options.settingsPath, original.name, draft, original);\n ctx.ui.notify(`Profile saved: ${safe(saved.name)}. Active settings are unchanged.`, \"info\");\n if (action === \"save-apply\") {\n try {\n const result = await applyReviewedCandidate(flow, candidate.loaded, applyCandidate, saved);\n flow.ensure(saved);\n if (result === \"close\") return \"close\";\n if (result !== \"applied\")\n ctx.ui.notify(\n \"The profile was saved. Application did not complete; review the configuration result before retrying.\",\n \"warning\",\n );\n } catch (error) {\n if (!flow.current()) throw error;\n ctx.ui.notify(\n `The saved profile was retained, but application did not complete: ${safeError(error)}. Review active settings before retrying.`,\n \"error\",\n );\n }\n }\n return saved;\n }\n throw new FlowEnded();\n}\n\nasync function applyReviewedCandidate(\n flow: ReturnType<typeof createFlow>,\n loaded: LoadedStarshipConfig,\n applyCandidate: ProfileApplyCandidate,\n document: Document,\n) {\n flow.ensure(document);\n const result = await applyCandidate(\n loaded,\n {\n signal: flow.signal,\n // The shared commit policy captures the active revision before applying.\n // A successful apply changes it; session ownership must remain valid after it.\n isCurrent: () => !flow.signal.aborted && flow.sessionCurrent(),\n isSessionCurrent: flow.sessionCurrent,\n },\n () => flow.ensure(document),\n document.name,\n );\n // Only this operation may advance the loaded revision. Other awaits must keep\n // the reviewed active revision; failed or cancelled applies cannot adopt it.\n if (result === \"applied\") flow.adoptAppliedRevision();\n flow.ensure(document);\n flow.preview(undefined);\n return result;\n}\n\nasync function saveNamedCopy(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n flow: ReturnType<typeof createFlow>,\n raw: string | undefined,\n source?: Document,\n): Promise<ProfileDocument | undefined> {\n while (flow.current()) {\n const name = await flow.dialog(() =>\n ctx.ui.input(\"Save as a profile\", \"Profile name (without .toml)\", { signal: flow.signal }),\n );\n flow.ensure(source);\n if (name === undefined) return undefined;\n try {\n const saved =\n source?.kind === \"profile\"\n ? duplicateProfile(options.settingsPath, source.name, name, source)\n : createProfile(options.settingsPath, name, requireText(raw));\n ctx.ui.notify(`Profile saved: ${safe(saved.name)}. Active settings are unchanged.`, \"info\");\n return saved;\n } catch (error) {\n report(ctx, flow, error);\n }\n }\n throw new FlowEnded();\n}\n\nasync function actionScreen(\n ctx: ExtensionCommandContext,\n flow: ReturnType<typeof createFlow>,\n screen: { title: string; lines: string[]; actions: Action[]; raw: string | undefined },\n): Promise<string> {\n let selected: string | undefined;\n const menu = defineMenu<undefined, \"actions\" | \"document\", \"select\">({\n start: \"actions\",\n screens: {\n actions: () => ({\n kind: \"actions\",\n title: screen.title,\n lines: screen.lines,\n items: [\n {\n id: \"review\",\n label: \"Review TOML\",\n to: \"document\",\n disabled: screen.raw === undefined,\n disabledReason: \"The document is not valid UTF-8\",\n },\n ...screen.actions.map((action) => ({ ...action, action: \"select\" as const })),\n ],\n hint: \"back\",\n }),\n document: () => ({\n kind: \"review\",\n title: screen.title,\n lines: [\"Exact UTF-8 text \u00B7 display controls sanitized \u00B7 read-only\"],\n content: screen.raw ?? \"The document is not valid UTF-8; no decoded fallback is shown.\",\n format: { kind: \"code\", language: \"toml\" },\n enableSearch: true,\n viewportSize: \"adaptive\",\n hint: \"back\",\n }),\n },\n actions: {\n select: ({ itemId }) => {\n flow.ensure();\n selected = itemId;\n return { kind: \"close\" };\n },\n },\n });\n const result = await runMenu(ctx, menu, { getState: () => undefined, signal: flow.signal, isCurrent: flow.current });\n flow.ensure();\n return selected ?? (result.kind === \"closed\" && result.reason === \"back\" ? \"back\" : \"close\");\n}\n\nfunction createFlow(ctx: ExtensionCommandContext, options: StarshipCommandOptions, owner: WorkflowOwner) {\n const controller = new AbortController();\n const signal = AbortSignal.any([controller.signal, owner.signal]);\n let revision = options.getLoadedRevision?.();\n let activeDocument = activeFingerprint(options.getLoaded());\n let previewOwned = false;\n const isCurrent = () =>\n !signal.aborted &&\n owner.isCurrent() &&\n (revision === undefined\n ? activeFingerprint(options.getLoaded()) === activeDocument\n : options.getLoadedRevision?.() === revision);\n const clearPreview = () => {\n if (!previewOwned) return;\n previewOwned = false;\n // The session owner, not a captured footer snapshot, decides whether cleanup\n // can touch the UI, even after command cancellation. Runtime lifecycle\n // cleanup owns a replaced session.\n if (owner.isSessionCurrent?.() ?? owner.isCurrent()) {\n try {\n options.preview?.(undefined, ctx);\n } catch (error) {\n ctx.ui.notify(`Could not clear the footer preview: ${safeError(error)}`, \"error\");\n }\n }\n };\n const matches = (expected?: Document) => {\n if (!isCurrent()) return false;\n if (!expected) return true;\n try {\n const fresh =\n expected.kind === \"profile\"\n ? readProfile(options.settingsPath, expected.name)\n : readHistory(options.settingsPath, expected.name);\n return (\n fresh.rawDocument === expected.rawDocument &&\n fresh.identity.dev === expected.identity.dev &&\n fresh.identity.ino === expected.identity.ino &&\n fresh.identity.size === expected.identity.size &&\n fresh.identity.mtimeNs === expected.identity.mtimeNs &&\n fresh.identity.ctimeNs === expected.identity.ctimeNs &&\n fresh.rawBytes.equals(expected.rawBytes)\n );\n } catch {\n return false;\n }\n };\n const ensure = (expected?: Document) => {\n if (!isCurrent()) throw new FlowEnded();\n if (!matches(expected))\n throw new Error(\"The selected document changed or was removed. Review the latest copy before trying again.\");\n };\n signal.addEventListener(\"abort\", clearPreview, { once: true });\n return {\n signal,\n current: isCurrent,\n sessionCurrent: () => owner.isSessionCurrent?.() ?? owner.isCurrent(),\n ensure,\n preview(loaded: LoadedStarshipConfig | undefined) {\n ensure();\n if (!loaded) {\n clearPreview();\n return;\n }\n previewOwned = true;\n try {\n options.preview?.(loaded, ctx);\n } catch (error) {\n clearPreview();\n throw error;\n }\n },\n async dialog<Value>(run: () => Promise<Value>): Promise<Value> {\n ensure();\n // Native dialogs collapse Escape and Ctrl+C into one result. Observe only\n // hard cancellation; never consume, rewrite, or forward editor content.\n const unsubscribe = ctx.ui.onTerminalInput((data) => {\n if (!isKeyRelease(data) && matchesKey(data, Key.ctrl(\"c\"))) {\n // Abort after native input dispatch, before its promise continuation.\n // Synchronous abort could restore focus and leak this key to Pi's editor.\n queueMicrotask(() => controller.abort());\n }\n return undefined;\n });\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n unsubscribe();\n };\n signal.addEventListener(\"abort\", release, { once: true });\n try {\n if (signal.aborted) release();\n ensure();\n const result = await run();\n ensure();\n return result;\n } finally {\n signal.removeEventListener(\"abort\", release);\n release();\n }\n },\n adoptAppliedRevision() {\n if (signal.aborted || !(owner.isSessionCurrent?.() ?? owner.isCurrent())) throw new FlowEnded();\n revision = options.getLoadedRevision?.();\n activeDocument = activeFingerprint(options.getLoaded());\n },\n dispose() {\n try {\n clearPreview();\n } finally {\n signal.removeEventListener(\"abort\", clearPreview);\n controller.abort();\n }\n },\n };\n}\n\nfunction candidateFor(options: StarshipCommandOptions, raw: string | undefined, required = false): Candidate {\n try {\n if (raw === undefined) throw new Error(\"The document is not valid UTF-8; no decoded fallback is shown.\");\n const loaded = (options.validate ?? validateConfigDocument)(options.settingsPath, raw);\n if (loaded.diagnostics.some((item) => item.severity === \"error\"))\n throw new Error(loaded.diagnostics.map((item) => item.message).join(\"; \"));\n return {\n loaded,\n lines:\n loaded.diagnostics.length === 0\n ? [\"No configuration warnings.\"]\n : loaded.diagnostics.map((item) => `${safe(item.path || \"root\")}: ${safe(item.message)}`),\n };\n } catch (error) {\n if (required) throw error;\n return { lines: [`Invalid TOML: ${safeError(error)}`, \"No candidate footer preview is shown.\"] };\n }\n}\n\nfunction requireText(raw: string | undefined): string {\n if (raw === undefined) throw new Error(\"The document is not valid UTF-8; no decoded fallback can be saved.\");\n return raw;\n}\n\nfunction activeFingerprint(loaded: LoadedStarshipConfig) {\n return JSON.stringify([loaded.source, loaded.rawDocument, loaded.diagnostics]);\n}\n\nfunction current(owner: WorkflowOwner) {\n return !owner.signal.aborted && owner.isCurrent();\n}\n\nfunction interactive(ctx: ExtensionCommandContext) {\n if (ctx.mode === \"tui\" && ctx.hasUI) return true;\n if (ctx.hasUI) ctx.ui.notify(\"Profiles and History require TUI mode.\", \"info\");\n return false;\n}\n\nfunction documentId(document: Document) {\n return `${document.kind}:${document.name}`;\n}\n\nfunction report(ctx: ExtensionCommandContext, flow: ReturnType<typeof createFlow>, error: unknown) {\n if (!(error instanceof FlowEnded) && flow.current()) ctx.ui.notify(safeError(error), \"error\");\n}\n\nfunction safeError(error: unknown) {\n return safe(error instanceof Error ? error.message : String(error));\n}\n\nfunction safe(value: string) {\n return sanitizeTerminalText(value);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAuC,6BAA6B;AA2B7D,SAAS,yBAAyB,SAAyD;AAChG,SAAO;AAAA,IACL,UAAU,QAAQ,UAAU;AAAA,IAC5B,UAAU,QAAQ,oBAAoB;AAAA,IACtC,MAAM,2BAA2B,QAAQ,YAAY;AAAA,EACvD;AACF;AAEO,SAAS,mBACd,SACA,OACA,UACS;AACT,QAAM,SAAS,QAAQ,UAAU;AACjC,SACE,CAAC,MAAM,OAAO,WACd,MAAM,UAAU,KAChB,OAAO,gBAAgB,SAAS,SAAS,eACzC,OAAO,WAAW,SAAS,SAAS,UACpC,KAAK,UAAU,OAAO,WAAW,MAAM,KAAK,UAAU,SAAS,SAAS,WAAW,KACnF,QAAQ,oBAAoB,MAAM,SAAS;AAE/C;AAGA,eAAsB,qBACpB,KACA,SACA,WACA,OACA,UACA,eAAe,OACf,gBAC+B;AAC/B,QAAM,MAAM,UAAU;AACtB,MAAI,QAAQ,OAAW,OAAM,IAAI,MAAM,gDAAgD;AACvF,SAAO,sBAAsB,QAAQ,cAAc,YAAY;AAC7D,QAAI,CAAC,mBAAmB,SAAS,OAAO,QAAQ,EAAG,QAAO;AAC1D,qBAAiB;AACjB,kCAA8B,QAAQ,cAAc,SAAS,IAAI;AACjE,UAAM,gBAAgB,SAAS,KAAK;AACp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