@narumitw/pi-starship 0.43.0 → 0.45.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 (46) hide show
  1. package/README.md +274 -89
  2. package/package.json +2 -2
  3. package/src/command-inspector.ts +470 -0
  4. package/src/command-preview.ts +206 -0
  5. package/src/commands.ts +187 -152
  6. package/src/config.ts +177 -67
  7. package/src/format/style.ts +64 -45
  8. package/src/modules/activity.ts +1 -1
  9. package/src/modules/brand.ts +1 -1
  10. package/src/modules/cache.ts +1 -1
  11. package/src/modules/catalog.ts +65 -4
  12. package/src/modules/context.ts +13 -1
  13. package/src/modules/cost.ts +12 -1
  14. package/src/modules/development.ts +1 -1
  15. package/src/modules/directory.ts +1 -1
  16. package/src/modules/display.ts +14 -0
  17. package/src/modules/execution.ts +12 -1
  18. package/src/modules/extension-status.ts +7 -98
  19. package/src/modules/fill.ts +1 -1
  20. package/src/modules/git/branch.ts +3 -37
  21. package/src/modules/git/commit.ts +1 -1
  22. package/src/modules/git/metrics.ts +8 -2
  23. package/src/modules/git/runtime.ts +5 -2
  24. package/src/modules/git/state.ts +1 -1
  25. package/src/modules/git/status.ts +1 -1
  26. package/src/modules/git/worktree.ts +1 -1
  27. package/src/modules/github-pr.ts +24 -0
  28. package/src/modules/index.ts +15 -6
  29. package/src/modules/inspection.ts +138 -0
  30. package/src/modules/model.ts +1 -1
  31. package/src/modules/provider.ts +1 -1
  32. package/src/modules/render.ts +23 -19
  33. package/src/modules/thinking.ts +1 -1
  34. package/src/modules/time.ts +1 -1
  35. package/src/modules/tokens.ts +1 -1
  36. package/src/modules/turn.ts +1 -1
  37. package/src/modules/types.ts +32 -5
  38. package/src/pi-starship.ts +149 -27
  39. package/src/runtime/command.ts +46 -8
  40. package/src/runtime/execution.ts +15 -3
  41. package/src/runtime/github-pr.ts +332 -0
  42. package/src/runtime/helpers.ts +1 -0
  43. package/src/runtime/refresh-controller.ts +30 -8
  44. package/src/runtime/types.ts +4 -0
  45. package/src/runtime/workspace.ts +27 -10
  46. package/src/installed-packages.ts +0 -84
package/src/commands.ts CHANGED
@@ -1,12 +1,8 @@
1
1
  import type { ExtensionAPI, ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
- import {
3
- type AutocompleteItem,
4
- type SelectItem,
5
- SelectList,
6
- truncateToWidth,
7
- wrapTextWithAnsi,
8
- } from "@earendil-works/pi-tui";
2
+ import type { AutocompleteItem } from "@earendil-works/pi-tui";
9
3
  import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
4
+ import { showFooterExplanation, showModuleBrowser } from "./command-inspector.js";
5
+ import { type PreviewMenuResult, showPreviewActionMenu } from "./command-preview.js";
10
6
  import {
11
7
  atomicRestoreConfigDocument,
12
8
  atomicSaveConfigDocument,
@@ -15,6 +11,7 @@ import {
15
11
  removeConfigDocumentIfMatches,
16
12
  validateConfigDocument,
17
13
  } from "./config.js";
14
+ import { inspectUnavailableModules, type StatuslineInspection } from "./modules/inspection.js";
18
15
 
19
16
  const SUBCOMMANDS: AutocompleteItem[] = [
20
17
  { value: "settings", label: "settings", description: "Customize the footer TOML" },
@@ -24,15 +21,11 @@ const SUBCOMMANDS: AutocompleteItem[] = [
24
21
 
25
22
  const MAIN_ACTIONS = {
26
23
  customize: "customize",
27
- diagnostics: "diagnostics",
24
+ explain: "explain",
25
+ modules: "modules",
26
+ configuration: "configuration",
28
27
  help: "help",
29
- advanced: "advanced",
30
- } as const;
31
-
32
- const ADVANCED_ACTIONS = {
33
- details: "details",
34
28
  restore: "restore",
35
- back: "back",
36
29
  } as const;
37
30
 
38
31
  const PREVIEW_ACTIONS = {
@@ -43,6 +36,7 @@ const PREVIEW_ACTIONS = {
43
36
 
44
37
  export interface StarshipCommandOptions {
45
38
  getLoaded(): LoadedStarshipConfig;
39
+ getInspection?(): StatuslineInspection | undefined;
46
40
  apply(loaded: LoadedStarshipConfig, ctx: ExtensionCommandContext): void;
47
41
  settingsPath: string;
48
42
  renderPreview?(
@@ -56,8 +50,9 @@ export interface StarshipCommandOptions {
56
50
  getMenuOwner?(): { signal: AbortSignal; isCurrent(): boolean };
57
51
  }
58
52
 
59
- interface MenuItem extends SelectItem {
60
- value: string;
53
+ interface WorkflowOwner {
54
+ signal: AbortSignal;
55
+ isCurrent(): boolean;
61
56
  }
62
57
 
63
58
  export function registerStarshipCommand(pi: ExtensionAPI, options: StarshipCommandOptions) {
@@ -76,8 +71,19 @@ export function registerStarshipCommand(pi: ExtensionAPI, options: StarshipComma
76
71
  return;
77
72
  }
78
73
 
79
- const subcommand = normalized.split(/\s+/u)[0]?.toLowerCase() ?? "";
80
- switch (subcommand) {
74
+ const [subcommand = "", ...trailing] = normalized.split(/\s+/u);
75
+ const route = subcommand.toLowerCase();
76
+ if (trailing.length > 0 || !SUBCOMMANDS.some((item) => item.value === route)) {
77
+ if (canNotify(ctx)) {
78
+ const reason =
79
+ trailing.length > 0
80
+ ? `Unexpected arguments for /starship ${safeText(route)}.`
81
+ : `Unknown /starship subcommand: ${safeText(route)}.`;
82
+ ctx.ui.notify(`${reason} Usage: /starship [settings|status|help]`, "warning");
83
+ }
84
+ return;
85
+ }
86
+ switch (route) {
81
87
  case "settings":
82
88
  await editSettings(ctx, options);
83
89
  return;
@@ -87,10 +93,6 @@ export function registerStarshipCommand(pi: ExtensionAPI, options: StarshipComma
87
93
  case "help":
88
94
  showHelp(ctx, options.settingsPath);
89
95
  return;
90
- default:
91
- if (canNotify(ctx)) {
92
- ctx.ui.notify(`Unknown /starship subcommand: ${subcommand}`, "warning");
93
- }
94
96
  }
95
97
  },
96
98
  });
@@ -102,31 +104,42 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
102
104
  signal: fallbackController.signal,
103
105
  isCurrent: () => !fallbackController.signal.aborted,
104
106
  };
105
- type Screen = "main" | "advanced" | "diagnostics" | "details" | "help";
106
- type Action = "customize" | "restore" | "back";
107
+ type Screen = "main" | "configuration" | "help";
108
+ type Action = "customize" | "explain" | "modules" | "restore";
107
109
  const menu = defineMenu<undefined, Screen, Action, ExtensionCommandContext>({
108
110
  start: "main",
109
111
  screens: {
110
112
  main: () => {
111
113
  const loaded = options.getLoaded();
112
- const state = configurationState(loaded);
113
- const health = configurationHealth(loaded);
114
+ const presentation = configurationPresentation(loaded);
114
115
  return {
115
116
  kind: "actions",
116
117
  title: "pi-starship",
117
- lines: [`${state} · ${health}`],
118
+ lines: [`${presentation.state} · ${presentation.health}`],
118
119
  items: [
119
120
  {
120
121
  id: MAIN_ACTIONS.customize,
121
122
  label: "Customize footer",
122
- description: `${state} · preview before applying`,
123
+ description: `${presentation.state} · preview before applying`,
123
124
  action: "customize",
124
125
  },
125
126
  {
126
- id: MAIN_ACTIONS.diagnostics,
127
- label: "Check configuration",
128
- description: health,
129
- to: "diagnostics",
127
+ id: MAIN_ACTIONS.explain,
128
+ label: "Explain footer",
129
+ description: "Why each visible module appears",
130
+ action: "explain",
131
+ },
132
+ {
133
+ id: MAIN_ACTIONS.modules,
134
+ label: "Modules",
135
+ description: "Browse supported modules and current states",
136
+ action: "modules",
137
+ },
138
+ {
139
+ id: MAIN_ACTIONS.configuration,
140
+ label: "Configuration",
141
+ description: presentation.health,
142
+ to: "configuration",
130
143
  },
131
144
  {
132
145
  id: MAIN_ACTIONS.help,
@@ -135,61 +148,25 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
135
148
  to: "help",
136
149
  },
137
150
  {
138
- id: MAIN_ACTIONS.advanced,
139
- label: "Advanced",
140
- description: "Details and restore controls",
141
- to: "advanced",
151
+ id: MAIN_ACTIONS.restore,
152
+ label: "Restore built-in…",
153
+ description: presentation.restoreDescription,
154
+ disabled: presentation.restoreDisabled,
155
+ action: "restore",
142
156
  },
143
157
  ],
144
158
  hint: "close",
145
159
  };
146
160
  },
147
- advanced: () => {
148
- const loaded = options.getLoaded();
149
- const alreadyBuiltIn = loaded.rawDocument === BUILT_IN_EXAMPLE;
150
- return {
151
- kind: "actions",
152
- title: "Advanced",
153
- lines: [configurationState(loaded)],
154
- items: [
155
- {
156
- id: ADVANCED_ACTIONS.details,
157
- label: "Configuration details",
158
- description: `${configurationSource(loaded)} · ${fileName(options.settingsPath)}`,
159
- to: "details",
160
- },
161
- {
162
- id: ADVANCED_ACTIONS.restore,
163
- label: "Restore built-in",
164
- description: alreadyBuiltIn
165
- ? "Already active"
166
- : "Preview before replacing the document",
167
- action: "restore",
168
- },
169
- {
170
- id: ADVANCED_ACTIONS.back,
171
- label: "Back",
172
- description: "Return to pi-starship",
173
- action: "back",
174
- },
175
- ],
176
- hint: "back",
177
- };
178
- },
179
- diagnostics: () => ({
180
- kind: "detail",
181
- title: "Configuration health",
182
- lines: diagnosticLines(options.getLoaded(), false),
183
- hint: "back",
184
- }),
185
- details: () => {
161
+ configuration: () => {
186
162
  const loaded = options.getLoaded();
163
+ const presentation = configurationPresentation(loaded);
187
164
  return {
188
165
  kind: "detail",
189
- title: "Configuration details",
166
+ title: "Configuration",
190
167
  lines: [
191
- `State: ${configurationState(loaded)}`,
192
- `Source: ${configurationSource(loaded)}`,
168
+ `State: ${presentation.state}`,
169
+ `Source: ${presentation.source}`,
193
170
  `Path: ${safeText(options.settingsPath)}`,
194
171
  ...diagnosticLines(loaded, true),
195
172
  ],
@@ -201,7 +178,9 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
201
178
  title: "pi-starship help",
202
179
  lines: [
203
180
  "Customize footer opens the TOML editor, then previews and confirms before saving.",
204
- "Check configuration explains warnings without changing the footer.",
181
+ "Explain footer breaks down the modules currently showing from the existing snapshot.",
182
+ "Modules searches every supported module and explains its current read-only state.",
183
+ "Configuration explains state, source, path, and warnings without changing the footer.",
205
184
  `Settings: ${safeText(options.settingsPath)}`,
206
185
  "Docs: https://github.com/narumiruna/pi-extensions/tree/main/extensions/pi-starship",
207
186
  ],
@@ -209,16 +188,31 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
209
188
  }),
210
189
  },
211
190
  actions: {
212
- customize: async () =>
213
- (await editSettings(ctx, options)) ? { kind: "close" } : { kind: "stay" },
191
+ customize: async () => {
192
+ const result = await editSettings(ctx, options);
193
+ return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
194
+ },
195
+ explain: async () => {
196
+ const result = await showFooterExplanation(ctx, options.getInspection?.(), owner.signal);
197
+ if (!isCurrentOwner(owner)) return { kind: "stay" };
198
+ return result?.kind === "back" ? { kind: "stay" } : { kind: "close" };
199
+ },
200
+ modules: async () => {
201
+ const inspection =
202
+ options.getInspection?.() ?? inspectUnavailableModules(options.getLoaded().config);
203
+ const result = await showModuleBrowser(ctx, inspection, owner.signal);
204
+ if (!isCurrentOwner(owner)) return { kind: "stay" };
205
+ return result?.kind === "back" ? { kind: "stay" } : { kind: "close" };
206
+ },
214
207
  restore: async () => {
215
- if (options.getLoaded().rawDocument === BUILT_IN_EXAMPLE) {
216
- ctx.ui.notify("The built-in footer configuration is already active.", "info");
208
+ const presentation = configurationPresentation(options.getLoaded());
209
+ if (presentation.restoreDisabled) {
210
+ ctx.ui.notify(presentation.restoreDescription, "info");
217
211
  return { kind: "stay" };
218
212
  }
219
- return (await restoreBuiltIn(ctx, options)) ? { kind: "close" } : { kind: "stay" };
213
+ const result = await restoreBuiltIn(ctx, options);
214
+ return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
220
215
  },
221
- back: async () => ({ kind: "back" }),
222
216
  },
223
217
  });
224
218
  try {
@@ -235,15 +229,17 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
235
229
  async function editSettings(
236
230
  ctx: ExtensionCommandContext,
237
231
  options: StarshipCommandOptions,
238
- ): Promise<boolean> {
232
+ ): Promise<"applied" | "cancel" | "close"> {
233
+ const owner = workflowOwner(options);
234
+ if (!isCurrentOwner(owner)) return "cancel";
239
235
  if (ctx.mode !== "tui") {
240
236
  if (ctx.hasUI) ctx.ui.notify(`Edit settings manually: ${options.settingsPath}`, "info");
241
- return false;
237
+ return "cancel";
242
238
  }
243
239
  let draft = options.getLoaded().rawDocument ?? BUILT_IN_EXAMPLE;
244
240
  while (true) {
245
241
  const edited = await ctx.ui.editor("Customize footer — close to preview", draft);
246
- if (edited === undefined) return false;
242
+ if (!isCurrentOwner(owner) || edited === undefined) return "cancel";
247
243
  draft = edited;
248
244
  let validated: LoadedStarshipConfig;
249
245
  try {
@@ -256,28 +252,34 @@ async function editSettings(
256
252
  () => [safeText(formatError(error)), "The current footer has not changed."],
257
253
  [
258
254
  { value: PREVIEW_ACTIONS.edit, label: "Continue editing" },
259
- { value: PREVIEW_ACTIONS.cancel, label: "Back" },
255
+ { value: PREVIEW_ACTIONS.cancel, label: "Discard draft" },
260
256
  ],
257
+ owner.signal,
261
258
  );
262
- if (action === PREVIEW_ACTIONS.edit) continue;
263
- return false;
259
+ if (!isCurrentOwner(owner)) return "cancel";
260
+ if (action?.kind === "closed") return "close";
261
+ if (selectedPreviewAction(action) === PREVIEW_ACTIONS.edit) continue;
262
+ return "cancel";
264
263
  }
265
264
 
266
- const result = await reviewAndApply(ctx, options, validated, "Footer preview", false);
265
+ const result = await reviewAndApply(ctx, options, validated, "Footer preview", false, owner);
267
266
  if (result === "edit") continue;
268
- return result === "applied";
267
+ return result;
269
268
  }
270
269
  }
271
270
 
272
271
  async function restoreBuiltIn(
273
272
  ctx: ExtensionCommandContext,
274
273
  options: StarshipCommandOptions,
275
- ): Promise<boolean> {
274
+ ): Promise<"applied" | "cancel" | "close"> {
275
+ const owner = workflowOwner(options);
276
+ if (!isCurrentOwner(owner)) return "cancel";
276
277
  const validated = (options.validate ?? validateConfigDocument)(
277
278
  options.settingsPath,
278
279
  BUILT_IN_EXAMPLE,
279
280
  );
280
- return (await reviewAndApply(ctx, options, validated, "Restore preview", true)) === "applied";
281
+ const result = await reviewAndApply(ctx, options, validated, "Restore preview", true, owner);
282
+ return result === "edit" ? "cancel" : result;
281
283
  }
282
284
 
283
285
  async function reviewAndApply(
@@ -286,27 +288,42 @@ async function reviewAndApply(
286
288
  validated: LoadedStarshipConfig,
287
289
  title: string,
288
290
  restore: boolean,
289
- ): Promise<"applied" | "edit" | "cancel"> {
291
+ owner: WorkflowOwner,
292
+ ): Promise<"applied" | "edit" | "cancel" | "close"> {
290
293
  while (true) {
291
294
  const selection = await showPreviewActionMenu(
292
295
  ctx,
293
296
  title,
294
- (width) => previewBody(ctx, options, validated, width),
297
+ (width) =>
298
+ restore
299
+ ? restorePreviewBody(ctx, options, validated, width)
300
+ : previewBody(ctx, options, validated, width),
295
301
  [
296
- { value: PREVIEW_ACTIONS.continue, label: "Continue to apply" },
302
+ {
303
+ value: PREVIEW_ACTIONS.continue,
304
+ label: restore ? "Replace with built-in…" : "Apply changes…",
305
+ },
297
306
  ...(restore ? [] : [{ value: PREVIEW_ACTIONS.edit, label: "Continue editing" }]),
298
- { value: PREVIEW_ACTIONS.cancel, label: "Cancel" },
307
+ {
308
+ value: PREVIEW_ACTIONS.cancel,
309
+ label: restore ? "Cancel" : "Discard draft",
310
+ },
299
311
  ],
312
+ owner.signal,
300
313
  );
301
- if (selection === PREVIEW_ACTIONS.edit) return "edit";
302
- if (selection !== PREVIEW_ACTIONS.continue) return "cancel";
314
+ if (!isCurrentOwner(owner)) return "cancel";
315
+ if (selection?.kind === "closed") return "close";
316
+ const selected = selectedPreviewAction(selection);
317
+ if (selected === PREVIEW_ACTIONS.edit) return "edit";
318
+ if (selected !== PREVIEW_ACTIONS.continue) return "cancel";
303
319
 
304
320
  const confirmed = await ctx.ui.confirm(
305
321
  restore ? "Restore built-in footer?" : "Apply footer changes?",
306
322
  restore
307
- ? `Replace ${options.settingsPath} with the built-in configuration?`
323
+ ? `Replace ${safeText(options.settingsPath)} entirely with the built-in configuration? All custom settings, unknown fields, and comments will be removed. No backup is kept after success.`
308
324
  : "Save this configuration and apply it immediately?",
309
325
  );
326
+ if (!isCurrentOwner(owner)) return "cancel";
310
327
  if (!confirmed) continue;
311
328
 
312
329
  const save = options.save ?? atomicSaveConfigDocument;
@@ -349,6 +366,16 @@ async function reviewAndApply(
349
366
  }
350
367
  }
351
368
 
369
+ function workflowOwner(options: StarshipCommandOptions): WorkflowOwner {
370
+ if (options.getMenuOwner) return options.getMenuOwner();
371
+ const controller = new AbortController();
372
+ return { signal: controller.signal, isCurrent: () => true };
373
+ }
374
+
375
+ function isCurrentOwner(owner: WorkflowOwner): boolean {
376
+ return !owner.signal.aborted && owner.isCurrent();
377
+ }
378
+
352
379
  function restorePreviousConfiguration(
353
380
  ctx: ExtensionCommandContext,
354
381
  options: StarshipCommandOptions,
@@ -370,6 +397,23 @@ function restorePreviousConfiguration(
370
397
  }
371
398
  }
372
399
 
400
+ function restorePreviewBody(
401
+ ctx: ExtensionCommandContext,
402
+ options: StarshipCommandOptions,
403
+ loaded: LoadedStarshipConfig,
404
+ width: number,
405
+ ): string[] {
406
+ const current = configurationPresentation(options.getLoaded());
407
+ return [
408
+ `Current: ${current.state}`,
409
+ `Path: ${safeText(options.settingsPath)}`,
410
+ "The entire settings document will be replaced, including custom settings, unknown fields, and comments.",
411
+ "No backup is kept after a successful restore.",
412
+ "",
413
+ ...previewBody(ctx, options, loaded, width),
414
+ ];
415
+ }
416
+
373
417
  function previewBody(
374
418
  ctx: ExtensionCommandContext,
375
419
  options: StarshipCommandOptions,
@@ -392,46 +436,10 @@ function previewBody(
392
436
  return [...lines, "", warning];
393
437
  }
394
438
 
395
- async function showPreviewActionMenu(
396
- ctx: ExtensionCommandContext,
397
- title: string,
398
- body: (width: number) => readonly string[],
399
- items: readonly MenuItem[],
400
- ): Promise<string | null> {
401
- return ctx.ui.custom<string | null>((tui, theme, _keybindings, done) => {
402
- const list = new SelectList([...items], Math.min(items.length, 8), {
403
- selectedPrefix: (text) => theme.fg("accent", text),
404
- selectedText: (text) => theme.fg("accent", text),
405
- description: (text) => theme.fg("muted", text),
406
- scrollInfo: (text) => theme.fg("dim", text),
407
- noMatch: (text) => theme.fg("warning", text),
408
- });
409
- list.onSelect = (item) => done(String(item.value));
410
- list.onCancel = () => done(null);
411
- return {
412
- render(width: number): string[] {
413
- const safeWidth = Math.max(1, width);
414
- const content = [
415
- ...wrapTextWithAnsi(theme.fg("accent", theme.bold(title)), safeWidth),
416
- ...body(safeWidth).flatMap((line) => (line ? wrapTextWithAnsi(line, safeWidth) : [""])),
417
- "",
418
- ...list.render(safeWidth),
419
- ...wrapTextWithAnsi(
420
- theme.fg("dim", "↑↓ navigate • enter select • esc cancel"),
421
- safeWidth,
422
- ),
423
- ];
424
- return content.map((line) => truncateToWidth(line, safeWidth));
425
- },
426
- invalidate() {
427
- list.invalidate();
428
- },
429
- handleInput(data: string) {
430
- list.handleInput(data);
431
- tui.requestRender();
432
- },
433
- };
434
- });
439
+ function selectedPreviewAction<Value extends string>(
440
+ result: PreviewMenuResult<Value> | undefined,
441
+ ): Value | null {
442
+ return result?.kind === "selected" ? result.value : null;
435
443
  }
436
444
 
437
445
  function diagnosticLines(loaded: LoadedStarshipConfig, includeSummary: boolean): string[] {
@@ -446,13 +454,44 @@ function diagnosticLines(loaded: LoadedStarshipConfig, includeSummary: boolean):
446
454
  ];
447
455
  }
448
456
 
449
- function configurationState(loaded: LoadedStarshipConfig): string {
450
- if (loaded.source === "built-in") return "Built-in fallback";
451
- return loaded.rawDocument === BUILT_IN_EXAMPLE ? "Built-in footer" : "Custom footer";
457
+ interface ConfigurationPresentation {
458
+ state: string;
459
+ source: string;
460
+ health: string;
461
+ restoreDisabled: boolean;
462
+ restoreDescription: string;
452
463
  }
453
464
 
454
- function configurationSource(loaded: LoadedStarshipConfig): string {
455
- return loaded.source === "user" ? "User file" : "Built-in fallback";
465
+ function configurationPresentation(loaded: LoadedStarshipConfig): ConfigurationPresentation {
466
+ const healthyMissing =
467
+ loaded.source === "built-in" &&
468
+ loaded.rawDocument === undefined &&
469
+ loaded.diagnostics.length === 0;
470
+ const savedBuiltIn = loaded.source === "user" && loaded.rawDocument === BUILT_IN_EXAMPLE;
471
+ const fallback = loaded.source === "built-in" && loaded.diagnostics.length > 0;
472
+ return {
473
+ state: healthyMissing
474
+ ? "Built-in defaults"
475
+ : savedBuiltIn
476
+ ? "Saved built-in configuration"
477
+ : fallback
478
+ ? "Built-in fallback"
479
+ : "Custom configuration",
480
+ source: healthyMissing
481
+ ? "No settings file"
482
+ : loaded.source === "user"
483
+ ? "User file"
484
+ : "Built-in fallback",
485
+ health: configurationHealth(loaded),
486
+ restoreDisabled: healthyMissing || savedBuiltIn,
487
+ restoreDescription: healthyMissing
488
+ ? "Already using defaults · no file to replace"
489
+ : savedBuiltIn
490
+ ? "Built-in configuration already saved"
491
+ : fallback
492
+ ? "Preview before replacing invalid settings"
493
+ : "Preview before replacing the document",
494
+ };
456
495
  }
457
496
 
458
497
  function configurationHealth(loaded: LoadedStarshipConfig): string {
@@ -462,10 +501,6 @@ function configurationHealth(loaded: LoadedStarshipConfig): string {
462
501
  return warnings === 0 ? "Healthy" : `${warnings} warning${warnings === 1 ? "" : "s"}`;
463
502
  }
464
503
 
465
- function fileName(path: string): string {
466
- return path.replaceAll("\\", "/").split("/").at(-1) || path;
467
- }
468
-
469
504
  function showStatus(ctx: ExtensionCommandContext, options: StarshipCommandOptions) {
470
505
  if (!canNotify(ctx)) return;
471
506
  const loaded = options.getLoaded();
@@ -487,7 +522,7 @@ function showHelp(ctx: ExtensionCommandContext, settingsPath: string) {
487
522
  if (!canNotify(ctx)) return;
488
523
  ctx.ui.notify(
489
524
  [
490
- "/starship — open the interactive footer menu",
525
+ "/starship — customize, explain, or inspect the footer in TUI mode",
491
526
  "/starship settings — customize, preview, and apply TOML",
492
527
  "/starship status — show source, path, and warnings",
493
528
  "/starship help — show this help",