@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.
- package/README.md +2 -0
- package/dist/chunks/{chunk-UX6PBXVK.js → chunk-SD7TUSSU.js} +113 -113
- package/dist/chunks/chunk-SD7TUSSU.js.map +7 -0
- package/dist/chunks/{chunk-P4XMFSQW.js → chunk-YWY5RIDQ.js} +3 -7
- package/dist/chunks/chunk-YWY5RIDQ.js.map +7 -0
- package/dist/chunks/{chunk-EOGXAMTA.js → chunk-ZQZSXXPI.js} +1 -1
- package/dist/chunks/chunk-ZQZSXXPI.js.map +7 -0
- package/dist/chunks/{cloud-BKHYWCTA.js → cloud-C4VU3TX3.js} +7 -14
- package/dist/chunks/cloud-C4VU3TX3.js.map +7 -0
- package/dist/chunks/{commands-53ZO2JUK.js → commands-MJCAK6JL.js} +18 -42
- package/dist/chunks/commands-MJCAK6JL.js.map +7 -0
- package/dist/chunks/{deployment-RKKOEQQ2.js → deployment-FMNTYRBW.js} +6 -21
- package/dist/chunks/deployment-FMNTYRBW.js.map +7 -0
- package/dist/chunks/{development-BERD42HW.js → development-OUYXDPBS.js} +4 -8
- package/dist/chunks/development-OUYXDPBS.js.map +7 -0
- package/dist/chunks/{execution-42JTEY3N.js → execution-HJOGLMWD.js} +3 -3
- package/dist/chunks/execution-HJOGLMWD.js.map +7 -0
- package/dist/chunks/{languages-RMP6DW7H.js → languages-WXMF4GOF.js} +6 -22
- package/dist/chunks/languages-WXMF4GOF.js.map +7 -0
- package/dist/chunks/{package-LG5H7BBM.js → package-YXRZQAOV.js} +5 -14
- package/dist/chunks/package-YXRZQAOV.js.map +7 -0
- package/dist/index.ts +20 -55
- package/dist/index.ts.map +2 -2
- package/package.json +60 -61
- package/skills/configuring-pi-starship/SKILL.md +18 -4
- package/skills/configuring-pi-starship/references/configuration.md +70 -2
- package/skills/configuring-pi-starship/references/module-catalog.md +21 -0
- package/skills/configuring-pi-starship/references/modules.md +2 -0
- package/skills/configuring-pi-starship/scripts/apply.mjs +48 -47
- package/skills/configuring-pi-starship/scripts/backup.mjs +118 -0
- package/skills/configuring-pi-starship/scripts/config-path.mjs +3 -3
- package/skills/configuring-pi-starship/scripts/script-support.mjs +6 -6
- package/skills/configuring-pi-starship/scripts/validate.mjs +18 -18
- package/src/command-configuration.ts +267 -286
- package/src/command-contract.ts +6 -6
- package/src/command-inspector.ts +27 -27
- package/src/command-preset-picker.ts +45 -50
- package/src/command-preview.ts +153 -166
- package/src/commands.ts +590 -618
- package/src/config.ts +635 -660
- package/src/effective-config.ts +49 -48
- package/src/format/formatter.ts +211 -227
- package/src/format/style.ts +205 -216
- package/src/modules/activity.ts +74 -74
- package/src/modules/brand.ts +9 -9
- package/src/modules/cache.ts +18 -18
- package/src/modules/catalog.ts +79 -83
- package/src/modules/cloud.ts +54 -54
- package/src/modules/context.ts +27 -27
- package/src/modules/cost.ts +23 -23
- package/src/modules/deployment.ts +45 -45
- package/src/modules/development.ts +80 -81
- package/src/modules/directory.ts +89 -113
- package/src/modules/display.ts +9 -9
- package/src/modules/execution.ts +62 -69
- package/src/modules/extension-status.ts +59 -64
- package/src/modules/fill.ts +10 -10
- package/src/modules/git/branch.ts +26 -26
- package/src/modules/git/commit.ts +21 -23
- package/src/modules/git/metrics.ts +22 -22
- package/src/modules/git/runtime.ts +299 -334
- package/src/modules/git/state.ts +17 -17
- package/src/modules/git/status.ts +77 -79
- package/src/modules/git/worktree.ts +10 -12
- package/src/modules/github-pr.ts +20 -20
- package/src/modules/helpers.ts +3 -3
- package/src/modules/index.ts +21 -21
- package/src/modules/inspection.ts +105 -108
- package/src/modules/languages.ts +52 -59
- package/src/modules/model.ts +61 -67
- package/src/modules/package.ts +12 -12
- package/src/modules/provider.ts +25 -24
- package/src/modules/render.ts +131 -141
- package/src/modules/style-rules.ts +21 -0
- package/src/modules/thinking.ts +31 -26
- package/src/modules/time.ts +10 -13
- package/src/modules/tokens.ts +13 -13
- package/src/modules/truncation.ts +14 -17
- package/src/modules/turn.ts +9 -9
- package/src/modules/types.ts +133 -132
- package/src/modules/workspace-helpers.ts +4 -7
- package/src/pi-starship.ts +567 -603
- package/src/presets/catalog.ts +113 -113
- package/src/runtime/cloud.ts +122 -150
- package/src/runtime/command.ts +106 -108
- package/src/runtime/deployment.ts +150 -179
- package/src/runtime/development.ts +107 -124
- package/src/runtime/execution.ts +110 -124
- package/src/runtime/github-pr.ts +223 -252
- package/src/runtime/helpers.ts +186 -199
- package/src/runtime/languages.ts +149 -180
- package/src/runtime/package.ts +74 -87
- package/src/runtime/refresh-controller.ts +82 -86
- package/src/runtime/types.ts +38 -38
- package/src/runtime/workspace.ts +108 -116
- package/src/usage.ts +40 -40
- package/dist/chunks/chunk-EOGXAMTA.js.map +0 -7
- package/dist/chunks/chunk-P4XMFSQW.js.map +0 -7
- package/dist/chunks/chunk-UX6PBXVK.js.map +0 -7
- package/dist/chunks/cloud-BKHYWCTA.js.map +0 -7
- package/dist/chunks/commands-53ZO2JUK.js.map +0 -7
- package/dist/chunks/deployment-RKKOEQQ2.js.map +0 -7
- package/dist/chunks/development-BERD42HW.js.map +0 -7
- package/dist/chunks/execution-42JTEY3N.js.map +0 -7
- package/dist/chunks/languages-RMP6DW7H.js.map +0 -7
- 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
|
-
|
|
10
|
-
|
|
9
|
+
apply: "apply",
|
|
10
|
+
cancel: "cancel",
|
|
11
11
|
} as const;
|
|
12
12
|
|
|
13
13
|
export interface WorkflowOwner {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
isCurrent(): boolean;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface ConfigurationCommandOptions {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
165
|
+
ctx: ExtensionCommandContext,
|
|
166
|
+
options: ConfigurationCommandOptions,
|
|
167
|
+
owner: WorkflowOwner,
|
|
175
168
|
): Promise<"applied" | "stay" | "close"> {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
252
|
+
options: ConfigurationCommandOptions,
|
|
260
253
|
): { ok: true; loaded: LoadedStarshipConfig } | { ok: false; error: string } {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
268
|
+
ctx: ExtensionCommandContext,
|
|
269
|
+
options: ConfigurationCommandOptions,
|
|
270
|
+
loaded: LoadedStarshipConfig,
|
|
271
|
+
width: number,
|
|
279
272
|
): string[] {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
-
|
|
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
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
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
|
-
|
|
329
|
+
return !owner.signal.aborted && owner.isCurrent();
|
|
349
330
|
}
|
|
350
331
|
|
|
351
332
|
function selectedReloadAction(
|
|
352
|
-
|
|
333
|
+
result: PreviewMenuResult<(typeof RELOAD_ACTIONS)[keyof typeof RELOAD_ACTIONS]> | undefined,
|
|
353
334
|
) {
|
|
354
|
-
|
|
335
|
+
return result?.kind === "selected" ? result.value : null;
|
|
355
336
|
}
|
|
356
337
|
|
|
357
338
|
function safeError(value: unknown): string {
|
|
358
|
-
|
|
339
|
+
return sanitizeTerminalText(typeof value === "string" ? value : formatError(value));
|
|
359
340
|
}
|
|
360
341
|
|
|
361
342
|
function formatError(error: unknown): string {
|
|
362
|
-
|
|
343
|
+
return error instanceof Error ? error.message : String(error);
|
|
363
344
|
}
|
package/src/command-contract.ts
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
}
|