@narumitw/pi-starship 0.44.0 → 0.46.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 (44) hide show
  1. package/README.md +246 -71
  2. package/package.json +2 -2
  3. package/src/command-inspector.ts +198 -0
  4. package/src/command-preview.ts +206 -0
  5. package/src/commands.ts +190 -154
  6. package/src/config.ts +177 -68
  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 +62 -3
  12. package/src/modules/context.ts +13 -1
  13. package/src/modules/cost.ts +12 -1
  14. package/src/modules/development.ts +24 -7
  15. package/src/modules/directory.ts +141 -7
  16. package/src/modules/display.ts +14 -0
  17. package/src/modules/execution.ts +13 -2
  18. package/src/modules/extension-status.ts +1 -1
  19. package/src/modules/fill.ts +1 -1
  20. package/src/modules/git/branch.ts +14 -5
  21. package/src/modules/git/commit.ts +10 -3
  22. package/src/modules/git/metrics.ts +8 -2
  23. package/src/modules/git/runtime.ts +3 -0
  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 +1 -1
  28. package/src/modules/index.ts +13 -1
  29. package/src/modules/inspection.ts +138 -0
  30. package/src/modules/model.ts +15 -65
  31. package/src/modules/provider.ts +1 -1
  32. package/src/modules/render.ts +22 -3
  33. package/src/modules/terminal.ts +60 -0
  34. package/src/modules/thinking.ts +1 -1
  35. package/src/modules/time.ts +1 -1
  36. package/src/modules/tokens.ts +1 -1
  37. package/src/modules/truncation.ts +37 -0
  38. package/src/modules/turn.ts +1 -1
  39. package/src/modules/types.ts +22 -0
  40. package/src/pi-starship.ts +27 -1
  41. package/src/runtime/development.ts +1 -2
  42. package/src/runtime/execution.ts +19 -9
  43. package/src/runtime/types.ts +2 -0
  44. package/src/runtime/workspace.ts +21 -7
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 } 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,10 +50,6 @@ export interface StarshipCommandOptions {
56
50
  getMenuOwner?(): { signal: AbortSignal; isCurrent(): boolean };
57
51
  }
58
52
 
59
- interface MenuItem extends SelectItem {
60
- value: string;
61
- }
62
-
63
53
  interface WorkflowOwner {
64
54
  signal: AbortSignal;
65
55
  isCurrent(): boolean;
@@ -81,8 +71,19 @@ export function registerStarshipCommand(pi: ExtensionAPI, options: StarshipComma
81
71
  return;
82
72
  }
83
73
 
84
- const subcommand = normalized.split(/\s+/u)[0]?.toLowerCase() ?? "";
85
- 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) {
86
87
  case "settings":
87
88
  await editSettings(ctx, options);
88
89
  return;
@@ -92,10 +93,6 @@ export function registerStarshipCommand(pi: ExtensionAPI, options: StarshipComma
92
93
  case "help":
93
94
  showHelp(ctx, options.settingsPath);
94
95
  return;
95
- default:
96
- if (canNotify(ctx)) {
97
- ctx.ui.notify(`Unknown /starship subcommand: ${subcommand}`, "warning");
98
- }
99
96
  }
100
97
  },
101
98
  });
@@ -107,31 +104,42 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
107
104
  signal: fallbackController.signal,
108
105
  isCurrent: () => !fallbackController.signal.aborted,
109
106
  };
110
- type Screen = "main" | "advanced" | "diagnostics" | "details" | "help";
111
- type Action = "customize" | "restore" | "back";
107
+ type Screen = "main" | "modules" | "configuration" | "help";
108
+ type Action = "customize" | "explain" | "restore";
112
109
  const menu = defineMenu<undefined, Screen, Action, ExtensionCommandContext>({
113
110
  start: "main",
114
111
  screens: {
115
112
  main: () => {
116
113
  const loaded = options.getLoaded();
117
- const state = configurationState(loaded);
118
- const health = configurationHealth(loaded);
114
+ const presentation = configurationPresentation(loaded);
119
115
  return {
120
116
  kind: "actions",
121
117
  title: "pi-starship",
122
- lines: [`${state} · ${health}`],
118
+ lines: [`${presentation.state} · ${presentation.health}`],
123
119
  items: [
124
120
  {
125
121
  id: MAIN_ACTIONS.customize,
126
122
  label: "Customize footer",
127
- description: `${state} · preview before applying`,
123
+ description: `${presentation.state} · preview before applying`,
128
124
  action: "customize",
129
125
  },
130
126
  {
131
- id: MAIN_ACTIONS.diagnostics,
132
- label: "Check configuration",
133
- description: health,
134
- 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
+ to: "modules",
137
+ },
138
+ {
139
+ id: MAIN_ACTIONS.configuration,
140
+ label: "Configuration",
141
+ description: presentation.health,
142
+ to: "configuration",
135
143
  },
136
144
  {
137
145
  id: MAIN_ACTIONS.help,
@@ -140,61 +148,53 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
140
148
  to: "help",
141
149
  },
142
150
  {
143
- id: MAIN_ACTIONS.advanced,
144
- label: "Advanced",
145
- description: "Details and restore controls",
146
- to: "advanced",
151
+ id: MAIN_ACTIONS.restore,
152
+ label: "Restore built-in…",
153
+ description: presentation.restoreDescription,
154
+ disabled: presentation.restoreDisabled,
155
+ action: "restore",
147
156
  },
148
157
  ],
149
158
  hint: "close",
150
159
  };
151
160
  },
152
- advanced: () => {
153
- const loaded = options.getLoaded();
154
- const alreadyBuiltIn = loaded.rawDocument === BUILT_IN_EXAMPLE;
161
+ modules: () => {
162
+ const inspection =
163
+ options.getInspection?.() ?? inspectUnavailableModules(options.getLoaded().config);
155
164
  return {
156
- kind: "actions",
157
- title: "Advanced",
158
- lines: [configurationState(loaded)],
159
- items: [
160
- {
161
- id: ADVANCED_ACTIONS.details,
162
- label: "Configuration details",
163
- description: `${configurationSource(loaded)} · ${fileName(options.settingsPath)}`,
164
- to: "details",
165
- },
166
- {
167
- id: ADVANCED_ACTIONS.restore,
168
- label: "Restore built-in",
169
- description: alreadyBuiltIn
170
- ? "Already active"
171
- : "Preview before replacing the document",
172
- action: "restore",
173
- },
174
- {
175
- id: ADVANCED_ACTIONS.back,
176
- label: "Back",
177
- description: "Return to pi-starship",
178
- action: "back",
179
- },
180
- ],
165
+ kind: "browse",
166
+ title: "Modules",
167
+ items: inspection.modules.map((module) => ({
168
+ id: module.name,
169
+ label: module.name,
170
+ statusText: module.state,
171
+ description: module.description,
172
+ searchText: [...module.variables, ...module.styleFields, ...module.displayRules].join(
173
+ " ",
174
+ ),
175
+ details: [
176
+ `Root: ${module.rootReferenced ? "Referenced" : "Not referenced"}`,
177
+ `Reachable: ${module.reachable ? "Yes" : "No"}`,
178
+ ...modulePreviewDetails(module.preview),
179
+ `Reason: ${module.reason}`,
180
+ `Variables: ${module.variables.join(", ") || "none"}`,
181
+ `Style fields: ${module.styleFields.join(", ") || "none"}`,
182
+ `Display rules: ${module.displayRules.join(" · ") || "none"}`,
183
+ ],
184
+ })),
185
+ viewportSize: "adaptive",
181
186
  hint: "back",
182
187
  };
183
188
  },
184
- diagnostics: () => ({
185
- kind: "detail",
186
- title: "Configuration health",
187
- lines: diagnosticLines(options.getLoaded(), false),
188
- hint: "back",
189
- }),
190
- details: () => {
189
+ configuration: () => {
191
190
  const loaded = options.getLoaded();
191
+ const presentation = configurationPresentation(loaded);
192
192
  return {
193
193
  kind: "detail",
194
- title: "Configuration details",
194
+ title: "Configuration",
195
195
  lines: [
196
- `State: ${configurationState(loaded)}`,
197
- `Source: ${configurationSource(loaded)}`,
196
+ `State: ${presentation.state}`,
197
+ `Source: ${presentation.source}`,
198
198
  `Path: ${safeText(options.settingsPath)}`,
199
199
  ...diagnosticLines(loaded, true),
200
200
  ],
@@ -206,7 +206,9 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
206
206
  title: "pi-starship help",
207
207
  lines: [
208
208
  "Customize footer opens the TOML editor, then previews and confirms before saving.",
209
- "Check configuration explains warnings without changing the footer.",
209
+ "Explain footer breaks down the modules currently showing from the existing snapshot.",
210
+ "Modules searches every supported module and explains its current read-only state.",
211
+ "Configuration explains state, source, path, and warnings without changing the footer.",
210
212
  `Settings: ${safeText(options.settingsPath)}`,
211
213
  "Docs: https://github.com/narumiruna/pi-extensions/tree/main/extensions/pi-starship",
212
214
  ],
@@ -214,16 +216,24 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
214
216
  }),
215
217
  },
216
218
  actions: {
217
- customize: async () =>
218
- (await editSettings(ctx, options)) ? { kind: "close" } : { kind: "stay" },
219
+ customize: async () => {
220
+ const result = await editSettings(ctx, options);
221
+ return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
222
+ },
223
+ explain: async () => {
224
+ const result = await showFooterExplanation(ctx, options.getInspection?.(), owner.signal);
225
+ if (!isCurrentOwner(owner)) return { kind: "stay" };
226
+ return result?.kind === "back" ? { kind: "stay" } : { kind: "close" };
227
+ },
219
228
  restore: async () => {
220
- if (options.getLoaded().rawDocument === BUILT_IN_EXAMPLE) {
221
- ctx.ui.notify("The built-in footer configuration is already active.", "info");
229
+ const presentation = configurationPresentation(options.getLoaded());
230
+ if (presentation.restoreDisabled) {
231
+ ctx.ui.notify(presentation.restoreDescription, "info");
222
232
  return { kind: "stay" };
223
233
  }
224
- return (await restoreBuiltIn(ctx, options)) ? { kind: "close" } : { kind: "stay" };
234
+ const result = await restoreBuiltIn(ctx, options);
235
+ return result === "applied" || result === "close" ? { kind: "close" } : { kind: "stay" };
225
236
  },
226
- back: async () => ({ kind: "back" }),
227
237
  },
228
238
  });
229
239
  try {
@@ -240,17 +250,17 @@ async function showMainMenu(ctx: ExtensionCommandContext, options: StarshipComma
240
250
  async function editSettings(
241
251
  ctx: ExtensionCommandContext,
242
252
  options: StarshipCommandOptions,
243
- ): Promise<boolean> {
253
+ ): Promise<"applied" | "cancel" | "close"> {
244
254
  const owner = workflowOwner(options);
245
- if (!isCurrentOwner(owner)) return false;
255
+ if (!isCurrentOwner(owner)) return "cancel";
246
256
  if (ctx.mode !== "tui") {
247
257
  if (ctx.hasUI) ctx.ui.notify(`Edit settings manually: ${options.settingsPath}`, "info");
248
- return false;
258
+ return "cancel";
249
259
  }
250
260
  let draft = options.getLoaded().rawDocument ?? BUILT_IN_EXAMPLE;
251
261
  while (true) {
252
262
  const edited = await ctx.ui.editor("Customize footer — close to preview", draft);
253
- if (!isCurrentOwner(owner) || edited === undefined) return false;
263
+ if (!isCurrentOwner(owner) || edited === undefined) return "cancel";
254
264
  draft = edited;
255
265
  let validated: LoadedStarshipConfig;
256
266
  try {
@@ -263,33 +273,34 @@ async function editSettings(
263
273
  () => [safeText(formatError(error)), "The current footer has not changed."],
264
274
  [
265
275
  { value: PREVIEW_ACTIONS.edit, label: "Continue editing" },
266
- { value: PREVIEW_ACTIONS.cancel, label: "Back" },
276
+ { value: PREVIEW_ACTIONS.cancel, label: "Discard draft" },
267
277
  ],
278
+ owner.signal,
268
279
  );
269
- if (!isCurrentOwner(owner)) return false;
270
- if (action === PREVIEW_ACTIONS.edit) continue;
271
- return false;
280
+ if (!isCurrentOwner(owner)) return "cancel";
281
+ if (action?.kind === "closed") return "close";
282
+ if (selectedPreviewAction(action) === PREVIEW_ACTIONS.edit) continue;
283
+ return "cancel";
272
284
  }
273
285
 
274
286
  const result = await reviewAndApply(ctx, options, validated, "Footer preview", false, owner);
275
287
  if (result === "edit") continue;
276
- return result === "applied";
288
+ return result;
277
289
  }
278
290
  }
279
291
 
280
292
  async function restoreBuiltIn(
281
293
  ctx: ExtensionCommandContext,
282
294
  options: StarshipCommandOptions,
283
- ): Promise<boolean> {
295
+ ): Promise<"applied" | "cancel" | "close"> {
284
296
  const owner = workflowOwner(options);
285
- if (!isCurrentOwner(owner)) return false;
297
+ if (!isCurrentOwner(owner)) return "cancel";
286
298
  const validated = (options.validate ?? validateConfigDocument)(
287
299
  options.settingsPath,
288
300
  BUILT_IN_EXAMPLE,
289
301
  );
290
- return (
291
- (await reviewAndApply(ctx, options, validated, "Restore preview", true, owner)) === "applied"
292
- );
302
+ const result = await reviewAndApply(ctx, options, validated, "Restore preview", true, owner);
303
+ return result === "edit" ? "cancel" : result;
293
304
  }
294
305
 
295
306
  async function reviewAndApply(
@@ -299,26 +310,38 @@ async function reviewAndApply(
299
310
  title: string,
300
311
  restore: boolean,
301
312
  owner: WorkflowOwner,
302
- ): Promise<"applied" | "edit" | "cancel"> {
313
+ ): Promise<"applied" | "edit" | "cancel" | "close"> {
303
314
  while (true) {
304
315
  const selection = await showPreviewActionMenu(
305
316
  ctx,
306
317
  title,
307
- (width) => previewBody(ctx, options, validated, width),
318
+ (width) =>
319
+ restore
320
+ ? restorePreviewBody(ctx, options, validated, width)
321
+ : previewBody(ctx, options, validated, width),
308
322
  [
309
- { value: PREVIEW_ACTIONS.continue, label: "Continue to apply" },
323
+ {
324
+ value: PREVIEW_ACTIONS.continue,
325
+ label: restore ? "Replace with built-in…" : "Apply changes…",
326
+ },
310
327
  ...(restore ? [] : [{ value: PREVIEW_ACTIONS.edit, label: "Continue editing" }]),
311
- { value: PREVIEW_ACTIONS.cancel, label: "Cancel" },
328
+ {
329
+ value: PREVIEW_ACTIONS.cancel,
330
+ label: restore ? "Cancel" : "Discard draft",
331
+ },
312
332
  ],
333
+ owner.signal,
313
334
  );
314
335
  if (!isCurrentOwner(owner)) return "cancel";
315
- if (selection === PREVIEW_ACTIONS.edit) return "edit";
316
- if (selection !== PREVIEW_ACTIONS.continue) return "cancel";
336
+ if (selection?.kind === "closed") return "close";
337
+ const selected = selectedPreviewAction(selection);
338
+ if (selected === PREVIEW_ACTIONS.edit) return "edit";
339
+ if (selected !== PREVIEW_ACTIONS.continue) return "cancel";
317
340
 
318
341
  const confirmed = await ctx.ui.confirm(
319
342
  restore ? "Restore built-in footer?" : "Apply footer changes?",
320
343
  restore
321
- ? `Replace ${options.settingsPath} with the built-in configuration?`
344
+ ? `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.`
322
345
  : "Save this configuration and apply it immediately?",
323
346
  );
324
347
  if (!isCurrentOwner(owner)) return "cancel";
@@ -364,6 +387,11 @@ async function reviewAndApply(
364
387
  }
365
388
  }
366
389
 
390
+ function modulePreviewDetails(preview: string): string[] {
391
+ const lines = preview ? preview.split("\n") : ["(no current preview)"];
392
+ return lines.map((line, index) => `${index === 0 ? "Preview: " : " "}${line}`);
393
+ }
394
+
367
395
  function workflowOwner(options: StarshipCommandOptions): WorkflowOwner {
368
396
  if (options.getMenuOwner) return options.getMenuOwner();
369
397
  const controller = new AbortController();
@@ -395,6 +423,23 @@ function restorePreviousConfiguration(
395
423
  }
396
424
  }
397
425
 
426
+ function restorePreviewBody(
427
+ ctx: ExtensionCommandContext,
428
+ options: StarshipCommandOptions,
429
+ loaded: LoadedStarshipConfig,
430
+ width: number,
431
+ ): string[] {
432
+ const current = configurationPresentation(options.getLoaded());
433
+ return [
434
+ `Current: ${current.state}`,
435
+ `Path: ${safeText(options.settingsPath)}`,
436
+ "The entire settings document will be replaced, including custom settings, unknown fields, and comments.",
437
+ "No backup is kept after a successful restore.",
438
+ "",
439
+ ...previewBody(ctx, options, loaded, width),
440
+ ];
441
+ }
442
+
398
443
  function previewBody(
399
444
  ctx: ExtensionCommandContext,
400
445
  options: StarshipCommandOptions,
@@ -417,46 +462,10 @@ function previewBody(
417
462
  return [...lines, "", warning];
418
463
  }
419
464
 
420
- async function showPreviewActionMenu(
421
- ctx: ExtensionCommandContext,
422
- title: string,
423
- body: (width: number) => readonly string[],
424
- items: readonly MenuItem[],
425
- ): Promise<string | null> {
426
- return ctx.ui.custom<string | null>((tui, theme, _keybindings, done) => {
427
- const list = new SelectList([...items], Math.min(items.length, 8), {
428
- selectedPrefix: (text) => theme.fg("accent", text),
429
- selectedText: (text) => theme.fg("accent", text),
430
- description: (text) => theme.fg("muted", text),
431
- scrollInfo: (text) => theme.fg("dim", text),
432
- noMatch: (text) => theme.fg("warning", text),
433
- });
434
- list.onSelect = (item) => done(String(item.value));
435
- list.onCancel = () => done(null);
436
- return {
437
- render(width: number): string[] {
438
- const safeWidth = Math.max(1, width);
439
- const content = [
440
- ...wrapTextWithAnsi(theme.fg("accent", theme.bold(title)), safeWidth),
441
- ...body(safeWidth).flatMap((line) => (line ? wrapTextWithAnsi(line, safeWidth) : [""])),
442
- "",
443
- ...list.render(safeWidth),
444
- ...wrapTextWithAnsi(
445
- theme.fg("dim", "↑↓ navigate • enter select • esc cancel"),
446
- safeWidth,
447
- ),
448
- ];
449
- return content.map((line) => truncateToWidth(line, safeWidth));
450
- },
451
- invalidate() {
452
- list.invalidate();
453
- },
454
- handleInput(data: string) {
455
- list.handleInput(data);
456
- tui.requestRender();
457
- },
458
- };
459
- });
465
+ function selectedPreviewAction<Value extends string>(
466
+ result: PreviewMenuResult<Value> | undefined,
467
+ ): Value | null {
468
+ return result?.kind === "selected" ? result.value : null;
460
469
  }
461
470
 
462
471
  function diagnosticLines(loaded: LoadedStarshipConfig, includeSummary: boolean): string[] {
@@ -471,13 +480,44 @@ function diagnosticLines(loaded: LoadedStarshipConfig, includeSummary: boolean):
471
480
  ];
472
481
  }
473
482
 
474
- function configurationState(loaded: LoadedStarshipConfig): string {
475
- if (loaded.source === "built-in") return "Built-in fallback";
476
- return loaded.rawDocument === BUILT_IN_EXAMPLE ? "Built-in footer" : "Custom footer";
483
+ interface ConfigurationPresentation {
484
+ state: string;
485
+ source: string;
486
+ health: string;
487
+ restoreDisabled: boolean;
488
+ restoreDescription: string;
477
489
  }
478
490
 
479
- function configurationSource(loaded: LoadedStarshipConfig): string {
480
- return loaded.source === "user" ? "User file" : "Built-in fallback";
491
+ function configurationPresentation(loaded: LoadedStarshipConfig): ConfigurationPresentation {
492
+ const healthyMissing =
493
+ loaded.source === "built-in" &&
494
+ loaded.rawDocument === undefined &&
495
+ loaded.diagnostics.length === 0;
496
+ const savedBuiltIn = loaded.source === "user" && loaded.rawDocument === BUILT_IN_EXAMPLE;
497
+ const fallback = loaded.source === "built-in" && loaded.diagnostics.length > 0;
498
+ return {
499
+ state: healthyMissing
500
+ ? "Built-in defaults"
501
+ : savedBuiltIn
502
+ ? "Saved built-in configuration"
503
+ : fallback
504
+ ? "Built-in fallback"
505
+ : "Custom configuration",
506
+ source: healthyMissing
507
+ ? "No settings file"
508
+ : loaded.source === "user"
509
+ ? "User file"
510
+ : "Built-in fallback",
511
+ health: configurationHealth(loaded),
512
+ restoreDisabled: healthyMissing || savedBuiltIn,
513
+ restoreDescription: healthyMissing
514
+ ? "Already using defaults · no file to replace"
515
+ : savedBuiltIn
516
+ ? "Built-in configuration already saved"
517
+ : fallback
518
+ ? "Preview before replacing invalid settings"
519
+ : "Preview before replacing the document",
520
+ };
481
521
  }
482
522
 
483
523
  function configurationHealth(loaded: LoadedStarshipConfig): string {
@@ -487,10 +527,6 @@ function configurationHealth(loaded: LoadedStarshipConfig): string {
487
527
  return warnings === 0 ? "Healthy" : `${warnings} warning${warnings === 1 ? "" : "s"}`;
488
528
  }
489
529
 
490
- function fileName(path: string): string {
491
- return path.replaceAll("\\", "/").split("/").at(-1) || path;
492
- }
493
-
494
530
  function showStatus(ctx: ExtensionCommandContext, options: StarshipCommandOptions) {
495
531
  if (!canNotify(ctx)) return;
496
532
  const loaded = options.getLoaded();
@@ -512,7 +548,7 @@ function showHelp(ctx: ExtensionCommandContext, settingsPath: string) {
512
548
  if (!canNotify(ctx)) return;
513
549
  ctx.ui.notify(
514
550
  [
515
- "/starship — open the interactive footer menu",
551
+ "/starship — customize, explain, or inspect the footer in TUI mode",
516
552
  "/starship settings — customize, preview, and apply TOML",
517
553
  "/starship status — show source, path, and warnings",
518
554
  "/starship help — show this help",