@narumitw/pi-starship 0.55.1 → 0.56.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 (106) hide show
  1. package/README.md +2 -0
  2. package/dist/chunks/{chunk-UX6PBXVK.js → chunk-SD7TUSSU.js} +113 -113
  3. package/dist/chunks/chunk-SD7TUSSU.js.map +7 -0
  4. package/dist/chunks/{chunk-P4XMFSQW.js → chunk-YWY5RIDQ.js} +3 -7
  5. package/dist/chunks/chunk-YWY5RIDQ.js.map +7 -0
  6. package/dist/chunks/{chunk-EOGXAMTA.js → chunk-ZQZSXXPI.js} +1 -1
  7. package/dist/chunks/chunk-ZQZSXXPI.js.map +7 -0
  8. package/dist/chunks/{cloud-BKHYWCTA.js → cloud-C4VU3TX3.js} +7 -14
  9. package/dist/chunks/cloud-C4VU3TX3.js.map +7 -0
  10. package/dist/chunks/{commands-53ZO2JUK.js → commands-MJCAK6JL.js} +18 -42
  11. package/dist/chunks/commands-MJCAK6JL.js.map +7 -0
  12. package/dist/chunks/{deployment-RKKOEQQ2.js → deployment-FMNTYRBW.js} +6 -21
  13. package/dist/chunks/deployment-FMNTYRBW.js.map +7 -0
  14. package/dist/chunks/{development-BERD42HW.js → development-OUYXDPBS.js} +4 -8
  15. package/dist/chunks/development-OUYXDPBS.js.map +7 -0
  16. package/dist/chunks/{execution-42JTEY3N.js → execution-HJOGLMWD.js} +3 -3
  17. package/dist/chunks/execution-HJOGLMWD.js.map +7 -0
  18. package/dist/chunks/{languages-RMP6DW7H.js → languages-WXMF4GOF.js} +6 -22
  19. package/dist/chunks/languages-WXMF4GOF.js.map +7 -0
  20. package/dist/chunks/{package-LG5H7BBM.js → package-YXRZQAOV.js} +5 -14
  21. package/dist/chunks/package-YXRZQAOV.js.map +7 -0
  22. package/dist/index.ts +20 -55
  23. package/dist/index.ts.map +2 -2
  24. package/package.json +60 -61
  25. package/skills/configuring-pi-starship/SKILL.md +18 -4
  26. package/skills/configuring-pi-starship/references/configuration.md +70 -2
  27. package/skills/configuring-pi-starship/references/module-catalog.md +21 -0
  28. package/skills/configuring-pi-starship/references/modules.md +2 -0
  29. package/skills/configuring-pi-starship/scripts/apply.mjs +48 -47
  30. package/skills/configuring-pi-starship/scripts/backup.mjs +118 -0
  31. package/skills/configuring-pi-starship/scripts/config-path.mjs +3 -3
  32. package/skills/configuring-pi-starship/scripts/script-support.mjs +6 -6
  33. package/skills/configuring-pi-starship/scripts/validate.mjs +18 -18
  34. package/src/command-configuration.ts +267 -286
  35. package/src/command-contract.ts +6 -6
  36. package/src/command-inspector.ts +27 -27
  37. package/src/command-preset-picker.ts +45 -50
  38. package/src/command-preview.ts +153 -166
  39. package/src/commands.ts +590 -618
  40. package/src/config.ts +635 -660
  41. package/src/effective-config.ts +49 -48
  42. package/src/format/formatter.ts +211 -227
  43. package/src/format/style.ts +205 -216
  44. package/src/modules/activity.ts +74 -74
  45. package/src/modules/brand.ts +9 -9
  46. package/src/modules/cache.ts +18 -18
  47. package/src/modules/catalog.ts +79 -83
  48. package/src/modules/cloud.ts +54 -54
  49. package/src/modules/context.ts +27 -27
  50. package/src/modules/cost.ts +23 -23
  51. package/src/modules/deployment.ts +45 -45
  52. package/src/modules/development.ts +80 -81
  53. package/src/modules/directory.ts +89 -113
  54. package/src/modules/display.ts +9 -9
  55. package/src/modules/execution.ts +62 -69
  56. package/src/modules/extension-status.ts +59 -64
  57. package/src/modules/fill.ts +10 -10
  58. package/src/modules/git/branch.ts +26 -26
  59. package/src/modules/git/commit.ts +21 -23
  60. package/src/modules/git/metrics.ts +22 -22
  61. package/src/modules/git/runtime.ts +299 -334
  62. package/src/modules/git/state.ts +17 -17
  63. package/src/modules/git/status.ts +77 -79
  64. package/src/modules/git/worktree.ts +10 -12
  65. package/src/modules/github-pr.ts +20 -20
  66. package/src/modules/helpers.ts +3 -3
  67. package/src/modules/index.ts +21 -21
  68. package/src/modules/inspection.ts +105 -108
  69. package/src/modules/languages.ts +52 -59
  70. package/src/modules/model.ts +61 -67
  71. package/src/modules/package.ts +12 -12
  72. package/src/modules/provider.ts +25 -24
  73. package/src/modules/render.ts +131 -141
  74. package/src/modules/style-rules.ts +21 -0
  75. package/src/modules/thinking.ts +31 -26
  76. package/src/modules/time.ts +10 -13
  77. package/src/modules/tokens.ts +13 -13
  78. package/src/modules/truncation.ts +14 -17
  79. package/src/modules/turn.ts +9 -9
  80. package/src/modules/types.ts +133 -132
  81. package/src/modules/workspace-helpers.ts +4 -7
  82. package/src/pi-starship.ts +567 -603
  83. package/src/presets/catalog.ts +113 -113
  84. package/src/runtime/cloud.ts +122 -150
  85. package/src/runtime/command.ts +106 -108
  86. package/src/runtime/deployment.ts +150 -179
  87. package/src/runtime/development.ts +107 -124
  88. package/src/runtime/execution.ts +110 -124
  89. package/src/runtime/github-pr.ts +223 -252
  90. package/src/runtime/helpers.ts +186 -199
  91. package/src/runtime/languages.ts +149 -180
  92. package/src/runtime/package.ts +74 -87
  93. package/src/runtime/refresh-controller.ts +82 -86
  94. package/src/runtime/types.ts +38 -38
  95. package/src/runtime/workspace.ts +108 -116
  96. package/src/usage.ts +40 -40
  97. package/dist/chunks/chunk-EOGXAMTA.js.map +0 -7
  98. package/dist/chunks/chunk-P4XMFSQW.js.map +0 -7
  99. package/dist/chunks/chunk-UX6PBXVK.js.map +0 -7
  100. package/dist/chunks/cloud-BKHYWCTA.js.map +0 -7
  101. package/dist/chunks/commands-53ZO2JUK.js.map +0 -7
  102. package/dist/chunks/deployment-RKKOEQQ2.js.map +0 -7
  103. package/dist/chunks/development-BERD42HW.js.map +0 -7
  104. package/dist/chunks/execution-42JTEY3N.js.map +0 -7
  105. package/dist/chunks/languages-RMP6DW7H.js.map +0 -7
  106. package/dist/chunks/package-LG5H7BBM.js.map +0 -7
@@ -6,358 +6,339 @@ import { serializeEffectiveConfig } from "./effective-config.js";
6
6
  import { presetForDocument } from "./presets/catalog.js";
7
7
 
8
8
  const RELOAD_ACTIONS = {
9
- apply: "apply",
10
- cancel: "cancel",
9
+ apply: "apply",
10
+ cancel: "cancel",
11
11
  } as const;
12
12
 
13
13
  export interface WorkflowOwner {
14
- signal: AbortSignal;
15
- isCurrent(): boolean;
14
+ signal: AbortSignal;
15
+ isCurrent(): boolean;
16
16
  }
17
17
 
18
18
  export interface ConfigurationCommandOptions {
19
- getLoaded(): LoadedStarshipConfig;
20
- getLoadedRevision?(): number;
21
- apply(loaded: LoadedStarshipConfig, ctx: ExtensionCommandContext): void;
22
- settingsPath: string;
23
- renderPreview?(
24
- loaded: LoadedStarshipConfig,
25
- width: number,
26
- ctx: ExtensionCommandContext,
27
- ): string[];
28
- read?: (settingsPath: string) => LoadedStarshipConfig;
19
+ getLoaded(): LoadedStarshipConfig;
20
+ getLoadedRevision?(): number;
21
+ apply(loaded: LoadedStarshipConfig, ctx: ExtensionCommandContext): void;
22
+ settingsPath: string;
23
+ renderPreview?(loaded: LoadedStarshipConfig, width: number, ctx: ExtensionCommandContext): string[];
24
+ read?: (settingsPath: string) => LoadedStarshipConfig;
29
25
  }
30
26
 
31
27
  export interface ConfigurationPresentation {
32
- state: string;
33
- source: string;
34
- health: string;
35
- restoreDisabled: boolean;
36
- restoreDescription: string;
28
+ state: string;
29
+ source: string;
30
+ health: string;
31
+ restoreDisabled: boolean;
32
+ restoreDescription: string;
37
33
  }
38
34
 
39
35
  export function configurationPresentation(loaded: LoadedStarshipConfig): ConfigurationPresentation {
40
- const healthyMissing = isHealthyMissing(loaded);
41
- const savedBuiltIn = loaded.source === "user" && loaded.rawDocument === BUILT_IN_EXAMPLE;
42
- const activePreset = presetForDocument(loaded.rawDocument);
43
- const fallback = loaded.source === "built-in" && loaded.diagnostics.length > 0;
44
- return {
45
- state: healthyMissing
46
- ? "Built-in defaults"
47
- : savedBuiltIn
48
- ? "Saved built-in configuration"
49
- : activePreset
50
- ? `${activePreset.label} preset`
51
- : fallback
52
- ? "Built-in fallback"
53
- : "Custom configuration",
54
- source: healthyMissing
55
- ? "No settings file"
56
- : activePreset
57
- ? "Bundled preset"
58
- : loaded.source === "user"
59
- ? "User file"
60
- : "Built-in fallback",
61
- health: configurationHealth(loaded),
62
- restoreDisabled: healthyMissing || savedBuiltIn,
63
- restoreDescription: healthyMissing
64
- ? "Already using defaults · no file to replace"
65
- : savedBuiltIn
66
- ? "Built-in configuration already saved"
67
- : fallback
68
- ? "Preview before replacing invalid settings"
69
- : "Preview before replacing the document",
70
- };
36
+ const healthyMissing = isHealthyMissing(loaded);
37
+ const savedBuiltIn = loaded.source === "user" && loaded.rawDocument === BUILT_IN_EXAMPLE;
38
+ const activePreset = presetForDocument(loaded.rawDocument);
39
+ const fallback = loaded.source === "built-in" && loaded.diagnostics.length > 0;
40
+ return {
41
+ state: healthyMissing
42
+ ? "Built-in defaults"
43
+ : savedBuiltIn
44
+ ? "Saved built-in configuration"
45
+ : activePreset
46
+ ? `${activePreset.label} preset`
47
+ : fallback
48
+ ? "Built-in fallback"
49
+ : "Custom configuration",
50
+ source: healthyMissing
51
+ ? "No settings file"
52
+ : activePreset
53
+ ? "Bundled preset"
54
+ : loaded.source === "user"
55
+ ? "User file"
56
+ : "Built-in fallback",
57
+ health: configurationHealth(loaded),
58
+ restoreDisabled: healthyMissing || savedBuiltIn,
59
+ restoreDescription: healthyMissing
60
+ ? "Already using defaults · no file to replace"
61
+ : savedBuiltIn
62
+ ? "Built-in configuration already saved"
63
+ : fallback
64
+ ? "Preview before replacing invalid settings"
65
+ : "Preview before replacing the document",
66
+ };
71
67
  }
72
68
 
73
69
  export function configurationMenuScreen(loaded: LoadedStarshipConfig) {
74
- const presentation = configurationPresentation(loaded);
75
- return {
76
- kind: "actions" as const,
77
- title: "Configuration",
78
- lines: [`${presentation.state} · ${presentation.health}`],
79
- items: [
80
- {
81
- id: "configuration-overview",
82
- label: "Overview",
83
- description: "State, source, path, health, and warnings",
84
- to: "configuration-overview" as const,
85
- },
86
- {
87
- id: "configuration-effective",
88
- label: "Effective configuration",
89
- description: "Normalized public TOML currently in use",
90
- to: "configuration-effective" as const,
91
- },
92
- {
93
- id: "configuration-document",
94
- label: "Settings document",
95
- description: isHealthyMissing(loaded)
96
- ? "No settings file · built-in defaults are active"
97
- : "Exact loaded UTF-8 text · read-only",
98
- to: "configuration-document" as const,
99
- },
100
- {
101
- id: "configuration-reload",
102
- label: "Reload from disk…",
103
- description: "Validate and preview external changes",
104
- action: "configuration-reload" as const,
105
- },
106
- ],
107
- hint: "back" as const,
108
- };
70
+ const presentation = configurationPresentation(loaded);
71
+ return {
72
+ kind: "actions" as const,
73
+ title: "Configuration",
74
+ lines: [`${presentation.state} · ${presentation.health}`],
75
+ items: [
76
+ {
77
+ id: "configuration-overview",
78
+ label: "Overview",
79
+ description: "State, source, path, health, and warnings",
80
+ to: "configuration-overview" as const,
81
+ },
82
+ {
83
+ id: "configuration-effective",
84
+ label: "Effective configuration",
85
+ description: "Normalized public TOML currently in use",
86
+ to: "configuration-effective" as const,
87
+ },
88
+ {
89
+ id: "configuration-document",
90
+ label: "Settings document",
91
+ description: isHealthyMissing(loaded)
92
+ ? "No settings file · built-in defaults are active"
93
+ : "Exact loaded UTF-8 text · read-only",
94
+ to: "configuration-document" as const,
95
+ },
96
+ {
97
+ id: "configuration-reload",
98
+ label: "Reload from disk…",
99
+ description: "Validate and preview external changes",
100
+ action: "configuration-reload" as const,
101
+ },
102
+ ],
103
+ hint: "back" as const,
104
+ };
109
105
  }
110
106
 
111
107
  export function configurationOverviewScreen(loaded: LoadedStarshipConfig, settingsPath: string) {
112
- const presentation = configurationPresentation(loaded);
113
- return {
114
- kind: "detail" as const,
115
- title: "Configuration overview",
116
- lines: [
117
- `State: ${presentation.state}`,
118
- `Source: ${presentation.source}`,
119
- `Path: ${sanitizeTerminalText(settingsPath)}`,
120
- ...diagnosticLines(loaded, true),
121
- ],
122
- hint: "back" as const,
123
- };
108
+ const presentation = configurationPresentation(loaded);
109
+ return {
110
+ kind: "detail" as const,
111
+ title: "Configuration overview",
112
+ lines: [
113
+ `State: ${presentation.state}`,
114
+ `Source: ${presentation.source}`,
115
+ `Path: ${sanitizeTerminalText(settingsPath)}`,
116
+ ...diagnosticLines(loaded, true),
117
+ ],
118
+ hint: "back" as const,
119
+ };
124
120
  }
125
121
 
126
122
  export function effectiveConfigurationScreen(loaded: LoadedStarshipConfig) {
127
- const presentation = configurationPresentation(loaded);
128
- return {
129
- kind: "review" as const,
130
- title: "Effective configuration",
131
- lines: [
132
- `${presentation.state} · ${presentation.health}`,
133
- "Normalized public TOML; comments and unknown fields are intentionally excluded.",
134
- ],
135
- content: serializeEffectiveConfig(loaded.config),
136
- format: { kind: "code" as const, language: "toml" },
137
- viewportSize: "adaptive" as const,
138
- hint: "back" as const,
139
- };
123
+ const presentation = configurationPresentation(loaded);
124
+ return {
125
+ kind: "review" as const,
126
+ title: "Effective configuration",
127
+ lines: [
128
+ `${presentation.state} · ${presentation.health}`,
129
+ "Normalized public TOML; comments and unknown fields are intentionally excluded.",
130
+ ],
131
+ content: serializeEffectiveConfig(loaded.config),
132
+ format: { kind: "code" as const, language: "toml" },
133
+ viewportSize: "adaptive" as const,
134
+ hint: "back" as const,
135
+ };
140
136
  }
141
137
 
142
138
  export function settingsDocumentScreen(loaded: LoadedStarshipConfig, settingsPath: string) {
143
- const path = sanitizeTerminalText(settingsPath);
144
- if (loaded.rawDocument !== undefined) {
145
- return {
146
- kind: "review" as const,
147
- title: "Settings document",
148
- lines: ["Exact loaded UTF-8 text · display controls sanitized · read-only", `Path: ${path}`],
149
- content: loaded.rawDocument,
150
- format: { kind: "code" as const, language: "toml" },
151
- viewportSize: "adaptive" as const,
152
- hint: "back" as const,
153
- };
154
- }
155
- return {
156
- kind: "detail" as const,
157
- title: "Settings document",
158
- lines: [
159
- ...(isHealthyMissing(loaded)
160
- ? [
161
- "No settings document exists.",
162
- "Built-in defaults are active; this read created no file.",
163
- ]
164
- : ["The settings document could not be loaded.", ...diagnosticLines(loaded, false)]),
165
- `Path: ${path}`,
166
- ],
167
- hint: "back" as const,
168
- };
139
+ const path = sanitizeTerminalText(settingsPath);
140
+ if (loaded.rawDocument !== undefined) {
141
+ return {
142
+ kind: "review" as const,
143
+ title: "Settings document",
144
+ lines: ["Exact loaded UTF-8 text · display controls sanitized · read-only", `Path: ${path}`],
145
+ content: loaded.rawDocument,
146
+ format: { kind: "code" as const, language: "toml" },
147
+ viewportSize: "adaptive" as const,
148
+ hint: "back" as const,
149
+ };
150
+ }
151
+ return {
152
+ kind: "detail" as const,
153
+ title: "Settings document",
154
+ lines: [
155
+ ...(isHealthyMissing(loaded)
156
+ ? ["No settings document exists.", "Built-in defaults are active; this read created no file."]
157
+ : ["The settings document could not be loaded.", ...diagnosticLines(loaded, false)]),
158
+ `Path: ${path}`,
159
+ ],
160
+ hint: "back" as const,
161
+ };
169
162
  }
170
163
 
171
164
  export async function reloadConfiguration(
172
- ctx: ExtensionCommandContext,
173
- options: ConfigurationCommandOptions,
174
- owner: WorkflowOwner,
165
+ ctx: ExtensionCommandContext,
166
+ options: ConfigurationCommandOptions,
167
+ owner: WorkflowOwner,
175
168
  ): Promise<"applied" | "stay" | "close"> {
176
- if (!isCurrentOwner(owner)) return "stay";
177
- const previous = options.getLoaded();
178
- const revision = options.getLoadedRevision?.();
179
- const candidate = readReloadCandidate(options);
180
- if (!candidate.ok) {
181
- ctx.ui.notify(`Footer reload was blocked: ${safeError(candidate.error)}`, "error");
182
- return "stay";
183
- }
184
- if (sameLoadedDocument(previous, candidate.loaded)) {
185
- ctx.ui.notify("The current disk configuration is already loaded.", "info");
186
- return "stay";
187
- }
169
+ if (!isCurrentOwner(owner)) return "stay";
170
+ const previous = options.getLoaded();
171
+ const revision = options.getLoadedRevision?.();
172
+ const candidate = readReloadCandidate(options);
173
+ if (!candidate.ok) {
174
+ ctx.ui.notify(`Footer reload was blocked: ${safeError(candidate.error)}`, "error");
175
+ return "stay";
176
+ }
177
+ if (sameLoadedDocument(previous, candidate.loaded)) {
178
+ ctx.ui.notify("The current disk configuration is already loaded.", "info");
179
+ return "stay";
180
+ }
188
181
 
189
- const selection = await showPreviewActionMenu(
190
- ctx,
191
- "Reload preview",
192
- (width) => reloadPreviewBody(ctx, options, candidate.loaded, width),
193
- [
194
- { value: RELOAD_ACTIONS.apply, label: "Apply reloaded configuration…" },
195
- { value: RELOAD_ACTIONS.cancel, label: "Cancel" },
196
- ],
197
- owner.signal,
198
- owner.isCurrent,
199
- );
200
- if (!isCurrentOwner(owner) || activeRevisionChanged(options, revision)) return "stay";
201
- if (selection?.kind === "closed") return "close";
202
- if (selectedReloadAction(selection) !== RELOAD_ACTIONS.apply) return "stay";
182
+ const selection = await showPreviewActionMenu(
183
+ ctx,
184
+ "Reload preview",
185
+ (width) => reloadPreviewBody(ctx, options, candidate.loaded, width),
186
+ [
187
+ { value: RELOAD_ACTIONS.apply, label: "Apply reloaded configuration…" },
188
+ { value: RELOAD_ACTIONS.cancel, label: "Cancel" },
189
+ ],
190
+ owner.signal,
191
+ owner.isCurrent,
192
+ );
193
+ if (!isCurrentOwner(owner) || activeRevisionChanged(options, revision)) return "stay";
194
+ if (selection?.kind === "closed") return "close";
195
+ if (selectedReloadAction(selection) !== RELOAD_ACTIONS.apply) return "stay";
203
196
 
204
- const confirmed = await ctx.ui.confirm(
205
- "Apply configuration from disk?",
206
- candidate.loaded.rawDocument === undefined
207
- ? "Use built-in defaults for this session? No settings file will be created."
208
- : "Apply the validated settings document to this session without changing its bytes?",
209
- );
210
- if (!isCurrentOwner(owner) || activeRevisionChanged(options, revision) || !confirmed) {
211
- return "stay";
212
- }
197
+ const confirmed = await ctx.ui.confirm(
198
+ "Apply configuration from disk?",
199
+ candidate.loaded.rawDocument === undefined
200
+ ? "Use built-in defaults for this session? No settings file will be created."
201
+ : "Apply the validated settings document to this session without changing its bytes?",
202
+ );
203
+ if (!isCurrentOwner(owner) || activeRevisionChanged(options, revision) || !confirmed) {
204
+ return "stay";
205
+ }
213
206
 
214
- const fresh = readReloadCandidate(options);
215
- if (!fresh.ok) {
216
- ctx.ui.notify(
217
- `Footer reload was blocked after confirmation: ${safeError(fresh.error)}. The previous footer remains active.`,
218
- "error",
219
- );
220
- return "stay";
221
- }
222
- if (!sameLoadedDocument(candidate.loaded, fresh.loaded)) {
223
- ctx.ui.notify(
224
- "The settings document changed after preview. The previous footer remains active; reload again to review the latest version.",
225
- "warning",
226
- );
227
- return "stay";
228
- }
207
+ const fresh = readReloadCandidate(options);
208
+ if (!fresh.ok) {
209
+ ctx.ui.notify(
210
+ `Footer reload was blocked after confirmation: ${safeError(fresh.error)}. The previous footer remains active.`,
211
+ "error",
212
+ );
213
+ return "stay";
214
+ }
215
+ if (!sameLoadedDocument(candidate.loaded, fresh.loaded)) {
216
+ ctx.ui.notify(
217
+ "The settings document changed after preview. The previous footer remains active; reload again to review the latest version.",
218
+ "warning",
219
+ );
220
+ return "stay";
221
+ }
229
222
 
230
- try {
231
- options.apply(fresh.loaded, ctx);
232
- } catch (error) {
233
- let rollbackError: unknown;
234
- try {
235
- options.apply(previous, ctx);
236
- } catch (rollback) {
237
- rollbackError = rollback;
238
- }
239
- ctx.ui.notify(
240
- rollbackError
241
- ? `Footer reload failed: ${safeError(error)}. Restoring the previous configuration also failed: ${safeError(rollbackError)}.`
242
- : `Footer reload failed: ${safeError(error)}. The previous configuration was restored.`,
243
- "error",
244
- );
245
- return "stay";
246
- }
223
+ try {
224
+ options.apply(fresh.loaded, ctx);
225
+ } catch (error) {
226
+ let rollbackError: unknown;
227
+ try {
228
+ options.apply(previous, ctx);
229
+ } catch (rollback) {
230
+ rollbackError = rollback;
231
+ }
232
+ ctx.ui.notify(
233
+ rollbackError
234
+ ? `Footer reload failed: ${safeError(error)}. Restoring the previous configuration also failed: ${safeError(rollbackError)}.`
235
+ : `Footer reload failed: ${safeError(error)}. The previous configuration was restored.`,
236
+ "error",
237
+ );
238
+ return "stay";
239
+ }
247
240
 
248
- const warnings = fresh.loaded.diagnostics.length;
249
- ctx.ui.notify(
250
- warnings === 0
251
- ? "Footer configuration reloaded and applied."
252
- : `Footer configuration reloaded and applied with ${warnings} warning${warnings === 1 ? "" : "s"}.`,
253
- "info",
254
- );
255
- return "applied";
241
+ const warnings = fresh.loaded.diagnostics.length;
242
+ ctx.ui.notify(
243
+ warnings === 0
244
+ ? "Footer configuration reloaded and applied."
245
+ : `Footer configuration reloaded and applied with ${warnings} warning${warnings === 1 ? "" : "s"}.`,
246
+ "info",
247
+ );
248
+ return "applied";
256
249
  }
257
250
 
258
251
  function readReloadCandidate(
259
- options: ConfigurationCommandOptions,
252
+ options: ConfigurationCommandOptions,
260
253
  ): { ok: true; loaded: LoadedStarshipConfig } | { ok: false; error: string } {
261
- let loaded: LoadedStarshipConfig;
262
- try {
263
- loaded = (options.read ?? loadStarshipConfig)(options.settingsPath);
264
- } catch (error) {
265
- return { ok: false, error: formatError(error) };
266
- }
267
- const errors = loaded.diagnostics.filter((item) => item.severity === "error");
268
- if (errors.length > 0) {
269
- return { ok: false, error: errors.map((item) => item.message).join("; ") };
270
- }
271
- return { ok: true, loaded };
254
+ let loaded: LoadedStarshipConfig;
255
+ try {
256
+ loaded = (options.read ?? loadStarshipConfig)(options.settingsPath);
257
+ } catch (error) {
258
+ return { ok: false, error: formatError(error) };
259
+ }
260
+ const errors = loaded.diagnostics.filter((item) => item.severity === "error");
261
+ if (errors.length > 0) {
262
+ return { ok: false, error: errors.map((item) => item.message).join("; ") };
263
+ }
264
+ return { ok: true, loaded };
272
265
  }
273
266
 
274
267
  function reloadPreviewBody(
275
- ctx: ExtensionCommandContext,
276
- options: ConfigurationCommandOptions,
277
- loaded: LoadedStarshipConfig,
278
- width: number,
268
+ ctx: ExtensionCommandContext,
269
+ options: ConfigurationCommandOptions,
270
+ loaded: LoadedStarshipConfig,
271
+ width: number,
279
272
  ): string[] {
280
- const presentation = configurationPresentation(loaded);
281
- let preview: string[];
282
- try {
283
- preview = options.renderPreview?.(loaded, width, ctx) ?? [
284
- "Live preview is unavailable until the footer is ready.",
285
- ];
286
- } catch (error) {
287
- preview = [`Preview unavailable: ${safeError(formatError(error))}`];
288
- }
289
- return [
290
- `Candidate: ${presentation.state}`,
291
- `Source: ${presentation.source}`,
292
- `Path: ${sanitizeTerminalText(options.settingsPath)}`,
293
- loaded.rawDocument === undefined
294
- ? "Applying uses built-in defaults and creates no settings file."
295
- : "Applying changes only the active session; the settings document bytes stay unchanged.",
296
- ...diagnosticLines(loaded, true),
297
- "",
298
- ...preview,
299
- ];
273
+ const presentation = configurationPresentation(loaded);
274
+ let preview: string[];
275
+ try {
276
+ preview = options.renderPreview?.(loaded, width, ctx) ?? ["Live preview is unavailable until the footer is ready."];
277
+ } catch (error) {
278
+ preview = [`Preview unavailable: ${safeError(formatError(error))}`];
279
+ }
280
+ return [
281
+ `Candidate: ${presentation.state}`,
282
+ `Source: ${presentation.source}`,
283
+ `Path: ${sanitizeTerminalText(options.settingsPath)}`,
284
+ loaded.rawDocument === undefined
285
+ ? "Applying uses built-in defaults and creates no settings file."
286
+ : "Applying changes only the active session; the settings document bytes stay unchanged.",
287
+ ...diagnosticLines(loaded, true),
288
+ "",
289
+ ...preview,
290
+ ];
300
291
  }
301
292
 
302
293
  export function diagnosticLines(loaded: LoadedStarshipConfig, includeSummary: boolean): string[] {
303
- const diagnostics = loaded.diagnostics
304
- .slice(0, 8)
305
- .map(
306
- (item) =>
307
- `${sanitizeTerminalText(item.path || "root")}: ${sanitizeTerminalText(item.message)}`,
308
- );
309
- const remaining = loaded.diagnostics.length - diagnostics.length;
310
- return [
311
- ...(includeSummary ? [`Health: ${configurationHealth(loaded)}`] : []),
312
- ...(diagnostics.length > 0 ? diagnostics : ["No configuration warnings."]),
313
- ...(remaining > 0 ? [`${remaining} additional warnings not shown.`] : []),
314
- ];
294
+ const diagnostics = loaded.diagnostics
295
+ .slice(0, 8)
296
+ .map((item) => `${sanitizeTerminalText(item.path || "root")}: ${sanitizeTerminalText(item.message)}`);
297
+ const remaining = loaded.diagnostics.length - diagnostics.length;
298
+ return [
299
+ ...(includeSummary ? [`Health: ${configurationHealth(loaded)}`] : []),
300
+ ...(diagnostics.length > 0 ? diagnostics : ["No configuration warnings."]),
301
+ ...(remaining > 0 ? [`${remaining} additional warnings not shown.`] : []),
302
+ ];
315
303
  }
316
304
 
317
305
  function configurationHealth(loaded: LoadedStarshipConfig): string {
318
- const errors = loaded.diagnostics.filter((item) => item.severity === "error").length;
319
- if (errors > 0) return `${errors} error${errors === 1 ? "" : "s"}`;
320
- const warnings = loaded.diagnostics.length;
321
- return warnings === 0 ? "Healthy" : `${warnings} warning${warnings === 1 ? "" : "s"}`;
306
+ const errors = loaded.diagnostics.filter((item) => item.severity === "error").length;
307
+ if (errors > 0) return `${errors} error${errors === 1 ? "" : "s"}`;
308
+ const warnings = loaded.diagnostics.length;
309
+ return warnings === 0 ? "Healthy" : `${warnings} warning${warnings === 1 ? "" : "s"}`;
322
310
  }
323
311
 
324
312
  function isHealthyMissing(loaded: LoadedStarshipConfig): boolean {
325
- return (
326
- loaded.source === "built-in" &&
327
- loaded.rawDocument === undefined &&
328
- loaded.diagnostics.length === 0
329
- );
313
+ return loaded.source === "built-in" && loaded.rawDocument === undefined && loaded.diagnostics.length === 0;
330
314
  }
331
315
 
332
316
  function sameLoadedDocument(left: LoadedStarshipConfig, right: LoadedStarshipConfig): boolean {
333
- return (
334
- left.source === right.source &&
335
- left.rawDocument === right.rawDocument &&
336
- JSON.stringify(left.diagnostics) === JSON.stringify(right.diagnostics)
337
- );
317
+ return (
318
+ left.source === right.source &&
319
+ left.rawDocument === right.rawDocument &&
320
+ JSON.stringify(left.diagnostics) === JSON.stringify(right.diagnostics)
321
+ );
338
322
  }
339
323
 
340
- function activeRevisionChanged(
341
- options: ConfigurationCommandOptions,
342
- revision: number | undefined,
343
- ): boolean {
344
- return revision !== undefined && options.getLoadedRevision?.() !== revision;
324
+ function activeRevisionChanged(options: ConfigurationCommandOptions, revision: number | undefined): boolean {
325
+ return revision !== undefined && options.getLoadedRevision?.() !== revision;
345
326
  }
346
327
 
347
328
  function isCurrentOwner(owner: WorkflowOwner): boolean {
348
- return !owner.signal.aborted && owner.isCurrent();
329
+ return !owner.signal.aborted && owner.isCurrent();
349
330
  }
350
331
 
351
332
  function selectedReloadAction(
352
- result: PreviewMenuResult<(typeof RELOAD_ACTIONS)[keyof typeof RELOAD_ACTIONS]> | undefined,
333
+ result: PreviewMenuResult<(typeof RELOAD_ACTIONS)[keyof typeof RELOAD_ACTIONS]> | undefined,
353
334
  ) {
354
- return result?.kind === "selected" ? result.value : null;
335
+ return result?.kind === "selected" ? result.value : null;
355
336
  }
356
337
 
357
338
  function safeError(value: unknown): string {
358
- return sanitizeTerminalText(typeof value === "string" ? value : formatError(value));
339
+ return sanitizeTerminalText(typeof value === "string" ? value : formatError(value));
359
340
  }
360
341
 
361
342
  function formatError(error: unknown): string {
362
- return error instanceof Error ? error.message : String(error);
343
+ return error instanceof Error ? error.message : String(error);
363
344
  }
@@ -1,13 +1,13 @@
1
1
  import type { AutocompleteItem } from "@earendil-works/pi-tui";
2
2
 
3
3
  export const STARSHIP_SUBCOMMANDS: readonly AutocompleteItem[] = [
4
- { value: "settings", label: "settings", description: "Customize the footer TOML" },
5
- { value: "status", label: "status", description: "Show configuration health and source" },
6
- { value: "help", label: "help", description: "Show configuration help" },
4
+ { value: "settings", label: "settings", description: "Customize the footer TOML" },
5
+ { value: "status", label: "status", description: "Show configuration health and source" },
6
+ { value: "help", label: "help", description: "Show configuration help" },
7
7
  ];
8
8
 
9
9
  export function completeStarshipArguments(prefix: string): AutocompleteItem[] | null {
10
- const normalized = prefix.trim().toLowerCase();
11
- const matches = STARSHIP_SUBCOMMANDS.filter((item) => item.value.startsWith(normalized));
12
- return matches.length > 0 ? [...matches] : null;
10
+ const normalized = prefix.trim().toLowerCase();
11
+ const matches = STARSHIP_SUBCOMMANDS.filter((item) => item.value.startsWith(normalized));
12
+ return matches.length > 0 ? [...matches] : null;
13
13
  }