@narumitw/pi-starship 0.62.0 → 0.64.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.
Files changed (34) hide show
  1. package/README.md +23 -11
  2. package/dist/chunks/{chunk-PWTSHSP3.ts → chunk-A65IOGL6.ts} +6 -7
  3. package/dist/chunks/chunk-A65IOGL6.ts.map +7 -0
  4. package/dist/chunks/{chunk-HPZTMIZS.ts → chunk-DIHVBO5Z.ts} +41 -8
  5. package/dist/chunks/chunk-DIHVBO5Z.ts.map +7 -0
  6. package/dist/chunks/{chunk-43VIENBN.ts → chunk-UIKPE4UC.ts} +7 -7
  7. package/dist/chunks/{chunk-43VIENBN.ts.map → chunk-UIKPE4UC.ts.map} +2 -2
  8. package/dist/chunks/{command-configuration-menu-S2LXCOJG.ts → command-configuration-menu-ZN2VXU4L.ts} +3 -3
  9. package/dist/chunks/{command-settings-chat-O34BEU4X.ts → command-settings-chat-KLUVZXMO.ts} +632 -196
  10. package/dist/chunks/command-settings-chat-KLUVZXMO.ts.map +7 -0
  11. package/dist/chunks/{commands-ZYIJVIEJ.ts → commands-UAUSSHVS.ts} +25 -20
  12. package/dist/chunks/commands-UAUSSHVS.ts.map +7 -0
  13. package/dist/index.ts +116 -59
  14. package/dist/index.ts.map +3 -3
  15. package/package.json +1 -1
  16. package/skills/configure-pi-starship/SKILL.md +3 -1
  17. package/skills/configure-pi-starship/references/configuration.md +14 -12
  18. package/src/command-commit.ts +41 -7
  19. package/src/command-configuration.ts +8 -10
  20. package/src/command-settings-chat.ts +18 -48
  21. package/src/commands.ts +23 -26
  22. package/src/config.ts +6 -6
  23. package/src/pi-starship.ts +155 -88
  24. package/src/settings-chat-display.ts +11 -0
  25. package/src/settings-chat-fullscreen.ts +264 -0
  26. package/src/settings-chat-scroll.ts +17 -0
  27. package/src/settings-chat-tools.ts +207 -0
  28. package/src/settings-chat-transcript.ts +133 -62
  29. package/src/settings-chat-ui.ts +109 -98
  30. package/dist/chunks/chunk-HPZTMIZS.ts.map +0 -7
  31. package/dist/chunks/chunk-PWTSHSP3.ts.map +0 -7
  32. package/dist/chunks/command-settings-chat-O34BEU4X.ts.map +0 -7
  33. package/dist/chunks/commands-ZYIJVIEJ.ts.map +0 -7
  34. /package/dist/chunks/{command-configuration-menu-S2LXCOJG.ts.map → command-configuration-menu-ZN2VXU4L.ts.map} +0 -0
@@ -7,6 +7,7 @@ import {
7
7
  type Theme,
8
8
  } from "@earendil-works/pi-coding-agent";
9
9
  import {
10
+ type Component,
10
11
  CURSOR_MARKER,
11
12
  Editor,
12
13
  getKeybindings,
@@ -17,14 +18,17 @@ import {
17
18
  type TUI,
18
19
  TUI_KEYBINDINGS,
19
20
  truncateToWidth,
21
+ VStack,
20
22
  } from "@earendil-works/pi-tui";
21
- import { HorizontalRule, renderBoundedFrame, runCustomInteraction } from "@narumitw/pi-tui-kit";
23
+ import { HorizontalRule, renderBoundedFrame } 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";
26
+ import { runSettingsChatFullscreen } from "./settings-chat-fullscreen.js";
27
+ import { SettingsChatScrollView } from "./settings-chat-scroll.js";
24
28
  import { createSettingsChatTranscript } from "./settings-chat-transcript.js";
25
29
  import type { SettingsDraft } from "./settings-draft.js";
26
30
 
27
- export type SettingsChatAction = "review" | "save" | "discard";
31
+ export type SettingsChatAction = "save" | "discard";
28
32
 
29
33
  const SAVE_SHORTCUTS = [
30
34
  { key: "ctrl+s", inputs: ["\x13", "\x1b[115;5u", "\x1b[27;5;115~"] },
@@ -39,7 +43,14 @@ function saveKeyReserved(data: string, keybindings: Pick<KeybindingsManager, "ma
39
43
  (action) => editorKeys.matches(data, action) || keybindings.matches(data, action),
40
44
  ) ||
41
45
  (
42
- ["app.clipboard.pasteImage", "app.interrupt", "app.exit", "app.message.followUp", "app.message.dequeue"] as const
46
+ [
47
+ "app.clipboard.pasteImage",
48
+ "app.interrupt",
49
+ "app.exit",
50
+ "app.message.followUp",
51
+ "app.message.dequeue",
52
+ "app.tools.expand",
53
+ ] as const
43
54
  ).some((action) => keybindings.matches(data, action))
44
55
  );
45
56
  }
@@ -57,24 +68,7 @@ export function settingsChatSaveShortcut(
57
68
  export interface ChatViewState {
58
69
  input: string;
59
70
  error: string;
60
- }
61
-
62
- /** Frame the review menu's footer preview without changing its render width. */
63
- export function renderSettingsChatPreview(
64
- width: number,
65
- preview: readonly string[],
66
- theme: Pick<Theme, "fg">,
67
- ): string[] {
68
- if (width <= 0) return [];
69
- const ruleStyle = (text: string) => theme.fg("border", text);
70
- const top = new HorizontalRule({
71
- label: "Preview",
72
- labelAlignment: "left",
73
- ruleStyle,
74
- labelStyle: (text) => theme.fg("dim", text),
75
- });
76
- const bottom = new HorizontalRule({ ruleStyle });
77
- return [top.render(width)[0] ?? "", ...preview, bottom.render(width)[0] ?? ""];
71
+ toolsExpanded?: boolean;
78
72
  }
79
73
 
80
74
  /** Add labels only to the public Editor border hooks; native scroll indicators keep priority. */
@@ -83,7 +77,7 @@ export class SettingsChatEditor extends CustomEditor {
83
77
  tui: TUI,
84
78
  private readonly chromeTheme: Theme,
85
79
  private readonly labels: () => { top: string; bottom: string },
86
- keybindings: KeybindingsManager,
80
+ chatKeys: KeybindingsManager,
87
81
  ) {
88
82
  super(
89
83
  tui,
@@ -97,7 +91,7 @@ export class SettingsChatEditor extends CustomEditor {
97
91
  noMatch: (text) => chromeTheme.fg("warning", text),
98
92
  },
99
93
  },
100
- keybindings,
94
+ chatKeys,
101
95
  );
102
96
  }
103
97
  /** Bypass app shortcuts while the native Editor owns a bracketed paste. */
@@ -126,8 +120,24 @@ export class SettingsChatEditor extends CustomEditor {
126
120
  }
127
121
  }
128
122
 
129
- /** Editor actions win collisions. Escape remains a review fallback for unusable cancel settings. */
130
- export function settingsChatReviewInput(data: string, keybindings: Pick<KeybindingsManager, "matches">): boolean {
123
+ // Native fullscreen actions evaluated before the focused root component. Search
124
+ // navigation/close are conditional on a focused search overlay, not this editor.
125
+ const ROOT_VIEWPORT_ACTIONS = [
126
+ "tui.altScreen.search",
127
+ "tui.altScreen.pageUp",
128
+ "tui.altScreen.pageDown",
129
+ "tui.altScreen.halfPageUp",
130
+ "tui.altScreen.halfPageDown",
131
+ "tui.altScreen.lineUp",
132
+ "tui.altScreen.lineDown",
133
+ "tui.altScreen.previousPrompt",
134
+ "tui.altScreen.nextPrompt",
135
+ "tui.altScreen.top",
136
+ "tui.altScreen.bottom",
137
+ ] as const;
138
+
139
+ /** Native viewport/editor actions win collisions; Escape is an executable stop fallback. */
140
+ export function settingsChatStopInput(data: string, keybindings: Pick<KeybindingsManager, "matches">): boolean {
131
141
  const editorKeys = getKeybindings();
132
142
  const parsed = parseKey(data);
133
143
  const textKey = parsed?.startsWith("shift+") ? parsed.slice(6) : parsed;
@@ -147,27 +157,8 @@ export function settingsChatReviewInput(data: string, keybindings: Pick<Keybindi
147
157
  (Object.keys(TUI_KEYBINDINGS) as Array<keyof typeof TUI_KEYBINDINGS>)
148
158
  .filter((key) => key.startsWith("tui.editor.") || key.startsWith("tui.input."))
149
159
  .some((key) => editorKeys.matches(data, key));
150
- return !editing && (keybindings.matches(data, "tui.select.cancel") || matchesKey(data, Key.escape));
151
- }
152
-
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
- });
160
+ const viewport = ROOT_VIEWPORT_ACTIONS.some((action) => editorKeys.matches(data, action));
161
+ return !viewport && !editing && (keybindings.matches(data, "tui.select.cancel") || matchesKey(data, Key.escape));
171
162
  }
172
163
 
173
164
  export function createSettingsChatComponent(options: {
@@ -200,9 +191,11 @@ export function createSettingsChatComponent(options: {
200
191
  ? "Warnings"
201
192
  : "Valid";
202
193
  const saveKey = !pending && !inPaste && draft.candidate ? settingsChatSaveShortcut(keybindings) : undefined;
194
+ // Match Pi core: sentence-case states and lowercase key + "to" action hints.
195
+ const working = !inPaste && settingsChatStopInput("\x1b", keybindings) ? "Working · esc to interrupt" : "Working";
203
196
  return {
204
197
  top: queued.length > 0 ? `pi-starship · ${queued.length} queued` : "pi-starship",
205
- bottom: `${status} · unsaved · ${pending ? "Working · Cancel stop" : saveKey ? `${saveKey} save profile` : "Cancel review"} · Ctrl+C discard`,
198
+ bottom: `${status} · unsaved · ${pending ? working : saveKey ? `${saveKey} to save profile` : "Idle"} · ctrl+c to discard`,
206
199
  };
207
200
  },
208
201
  keybindings,
@@ -211,6 +204,14 @@ export function createSettingsChatComponent(options: {
211
204
  const render = () => {
212
205
  if (!disposed && !signal.aborted) tui.requestRender();
213
206
  };
207
+ // Update transcript identities before this listener requests the next frame.
208
+ const transcript = createSettingsChatTranscript(
209
+ agent,
210
+ tui,
211
+ draft.directory,
212
+ state.toolsExpanded ?? false,
213
+ draft.path,
214
+ );
214
215
  const unsubscribe = agent.subscribe((event) => {
215
216
  if (event.type === "message_start") {
216
217
  const index = queued.findIndex((item) => item.message === event.message);
@@ -237,7 +238,6 @@ export function createSettingsChatComponent(options: {
237
238
  };
238
239
  signal.addEventListener("abort", abort, { once: true });
239
240
  const rule = new HorizontalRule({ ruleStyle: (text) => theme.fg("border", text) });
240
- const transcript = createSettingsChatTranscript(agent, tui, draft.directory);
241
241
  const failed = () => {
242
242
  const last = agent.state.messages.at(-1);
243
243
  return last?.role === "assistant" && (last.stopReason === "error" || last.stopReason === "aborted");
@@ -284,18 +284,15 @@ export function createSettingsChatComponent(options: {
284
284
  editor.onSubmit = (input) => submit(input, "steer");
285
285
  editor.onAction("app.message.followUp", () => submit(editor.getExpandedText().trim(), "followUp"));
286
286
  editor.onAction("app.message.dequeue", restoreQueue);
287
- return {
288
- get focused() {
289
- return editor.focused;
290
- },
291
- set focused(value: boolean) {
292
- editor.focused = value;
293
- },
287
+ editor.onAction("app.tools.expand", () => {
288
+ state.toolsExpanded = transcript.toggleTools();
289
+ });
290
+ const dock: Component = {
294
291
  render(width: number): string[] {
295
292
  if (disposed || signal.aborted || width <= 0) return [];
296
293
  const rows = Math.max(0, Math.floor(Number.isFinite(tui.terminal.rows) ? tui.terminal.rows : 24));
297
294
  if (rows === 0) return [];
298
- const input = editor.render(width);
295
+ const input = editor.render(Math.max(3, width)).map((line) => truncateToWidth(line, width, ""));
299
296
  const cursor = Math.max(
300
297
  0,
301
298
  input.findIndex((line) => line.includes(CURSOR_MARKER)),
@@ -305,8 +302,7 @@ export function createSettingsChatComponent(options: {
305
302
  .split("\n")
306
303
  .filter(Boolean)
307
304
  .slice(0, 3);
308
- // Match Pi's transcript -> editor -> footer hierarchy. The fullscreen overlay
309
- // covers the parent footer, so the real draft preview is part of this dock.
305
+ // Keep the draft preview outside the scrollable history.
310
306
  const details = diagnostics.map((line) => theme.fg("muted", line));
311
307
  // Render the footer without extra rules, matching its saved position at the terminal bottom.
312
308
  if (input.length + preview.length > rows) {
@@ -333,11 +329,48 @@ export function createSettingsChatComponent(options: {
333
329
  ),
334
330
  );
335
331
  const content = [...queueLines, ...input, ...detailLines, ...preview];
336
- const available = rows - content.length;
337
- const history = available > 0 ? transcript.render(width).slice(-available) : [];
338
- return [...history, ...Array.from({ length: available - history.length }, () => ""), ...content].map((line) =>
339
- truncateToWidth(line, width, ""),
340
- );
332
+ return content.map((line) => truncateToWidth(line, width, ""));
333
+ },
334
+ invalidate() {
335
+ editor.invalidate();
336
+ },
337
+ };
338
+ const history: Component = {
339
+ render(width) {
340
+ // Capture against the previous frame's spans before rebuilding identities.
341
+ scroll.anchor = scroll.isFollowingEnd ? undefined : transcript.anchorAt(scroll.scrollTop);
342
+ return transcript.render(width);
343
+ },
344
+ invalidate() {
345
+ transcript.invalidate();
346
+ },
347
+ handleMouse: (event) => transcript.handleMouse(event),
348
+ };
349
+ const scroll = new SettingsChatScrollView(history, {
350
+ primary: true,
351
+ follow: "end",
352
+ scrollbar: "auto",
353
+ scrollbarTrackStyle: (text) => theme.fg("scrollbarTrack", text),
354
+ scrollbarThumbStyle: (text) => theme.fg("scrollbarThumb", text),
355
+ });
356
+ scroll.restoreAnchor = (anchor) => transcript.rowAt(anchor);
357
+ const layout = new VStack([
358
+ { component: scroll, basis: 0, grow: 1, minSize: 0 },
359
+ { component: dock, basis: "auto", shrink: 1, minSize: 1 },
360
+ ]);
361
+ return {
362
+ getFullscreenLayout() {
363
+ return layout;
364
+ },
365
+ get focused() {
366
+ return editor.focused;
367
+ },
368
+ set focused(value: boolean) {
369
+ editor.focused = value;
370
+ },
371
+ render(width: number): string[] {
372
+ if (disposed || signal.aborted || width <= 0 || tui.terminal.rows <= 0) return [];
373
+ return layout.render(width);
341
374
  },
342
375
  invalidate() {
343
376
  editor.invalidate();
@@ -356,14 +389,11 @@ export function createSettingsChatComponent(options: {
356
389
  } else if (saveKey && matchesKey(data, saveKey) && !saveKeyReserved(data, keybindings)) {
357
390
  state.input = editor.getExpandedText();
358
391
  options.complete("save");
359
- } else if (settingsChatReviewInput(data, keybindings)) {
392
+ } else if (settingsChatStopInput(data, keybindings)) {
360
393
  if (pending) {
361
394
  stopping = true;
362
395
  restoreQueue();
363
396
  agent.abort();
364
- } else {
365
- state.input = editor.getExpandedText();
366
- options.complete("review");
367
397
  }
368
398
  } else editor.handleInput(data);
369
399
  render();
@@ -375,6 +405,8 @@ export function createSettingsChatComponent(options: {
375
405
  signal.removeEventListener("abort", abort);
376
406
  unsubscribe();
377
407
  transcript.dispose();
408
+ scroll.setScrollbarActive(false);
409
+ scroll.setScrollbar("hidden");
378
410
  abort();
379
411
  },
380
412
  async waitForPending() {
@@ -392,35 +424,14 @@ export async function showSettingsChat(
392
424
  owner: WorkflowOwner,
393
425
  preview: (width: number) => string[],
394
426
  ): Promise<SettingsChatAction> {
395
- // Keep Kit's cancellation/disposal runner, but mount through Pi's public overlay API.
396
- // No second TUI, terminal handoff, or manipulation of unrelated overlay handles is needed.
397
- const fullscreenContext: ExtensionCommandContext = {
398
- ...ctx,
399
- ui: {
400
- ...ctx.ui,
401
- custom: (factory) =>
402
- ctx.ui.custom(factory, {
403
- overlay: true,
404
- overlayOptions: { width: "100%", maxHeight: "100%", anchor: "top-left", margin: 0 },
405
- }),
406
- },
407
- };
408
- const result = await runCustomInteraction<SettingsChatAction>(fullscreenContext, {
409
- signal: owner.signal,
410
- isCurrent: owner.isCurrent,
411
- create: ({ tui, theme, keybindings, signal, complete }) =>
412
- createSettingsChatComponent({
413
- agent,
414
- draft,
415
- state,
416
- tui,
417
- theme,
418
- keybindings,
419
- signal,
420
- preview,
421
- complete,
422
- }),
423
- });
424
- if (result.kind === "error") throw result.error;
425
- return result.kind === "completed" ? result.value : "discard";
427
+ // Seed this side thread once from the public parent display preference. Its
428
+ // later Ctrl+O changes remain local, including across review/name cancellation.
429
+ state.toolsExpanded ??= ctx.ui.getToolsExpanded?.() ?? false;
430
+ return runSettingsChatFullscreen(
431
+ ctx,
432
+ owner,
433
+ ({ tui, theme, keybindings, signal, complete }) =>
434
+ createSettingsChatComponent({ agent, draft, state, tui, theme, keybindings, signal, preview, complete }),
435
+ "discard" as SettingsChatAction,
436
+ );
426
437
  }
@@ -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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