@narumitw/pi-starship 0.62.0 → 0.63.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 +10 -9
- package/dist/chunks/{chunk-HPZTMIZS.ts → chunk-63R6R5DH.ts} +41 -8
- package/dist/chunks/chunk-63R6R5DH.ts.map +7 -0
- package/dist/chunks/{chunk-PWTSHSP3.ts → chunk-A65IOGL6.ts} +6 -7
- package/dist/chunks/chunk-A65IOGL6.ts.map +7 -0
- package/dist/chunks/{chunk-43VIENBN.ts → chunk-Y24TJYG6.ts} +7 -7
- package/dist/chunks/{chunk-43VIENBN.ts.map → chunk-Y24TJYG6.ts.map} +2 -2
- package/dist/chunks/{command-configuration-menu-S2LXCOJG.ts → command-configuration-menu-YOLN2SPR.ts} +3 -3
- package/dist/chunks/{command-settings-chat-O34BEU4X.ts → command-settings-chat-5AHP3JGV.ts} +162 -79
- package/dist/chunks/command-settings-chat-5AHP3JGV.ts.map +7 -0
- package/dist/chunks/{commands-ZYIJVIEJ.ts → commands-IOG2PL67.ts} +23 -19
- package/dist/chunks/commands-IOG2PL67.ts.map +7 -0
- package/dist/index.ts +114 -58
- package/dist/index.ts.map +3 -3
- package/package.json +1 -1
- package/skills/configure-pi-starship/SKILL.md +3 -1
- package/skills/configure-pi-starship/references/configuration.md +14 -12
- package/src/command-commit.ts +41 -7
- package/src/command-configuration.ts +6 -10
- package/src/command-settings-chat.ts +2 -44
- package/src/commands.ts +22 -26
- package/src/config.ts +6 -6
- package/src/pi-starship.ts +154 -88
- package/src/settings-chat-transcript.ts +54 -2
- package/src/settings-chat-ui.ts +150 -50
- package/dist/chunks/chunk-HPZTMIZS.ts.map +0 -7
- package/dist/chunks/chunk-PWTSHSP3.ts.map +0 -7
- package/dist/chunks/command-settings-chat-O34BEU4X.ts.map +0 -7
- package/dist/chunks/commands-ZYIJVIEJ.ts.map +0 -7
- /package/dist/chunks/{command-configuration-menu-S2LXCOJG.ts.map → command-configuration-menu-YOLN2SPR.ts.map} +0 -0
package/package.json
CHANGED
|
@@ -81,7 +81,9 @@ Do not install another Pi copy, modify `node_modules`, hard-code a Bun global di
|
|
|
81
81
|
|
|
82
82
|
Read the existing document before editing it.
|
|
83
83
|
|
|
84
|
-
Treat a missing document as
|
|
84
|
+
Treat a missing document as Pi's native footer, and create it only when the requested change requires a persisted Starship configuration.
|
|
85
|
+
Use the built-in Starship example as an editing seed, not as a document equivalent to Pi's native footer.
|
|
86
|
+
The menu action **Restore built-in…** archives the exact active bytes in History and removes the settings document; a saved built-in Starship example remains eligible for Restore.
|
|
85
87
|
|
|
86
88
|
Do not redirect this workflow to `starship.toml`, `pi-statusline.json`, project-local overrides, or extension source files.
|
|
87
89
|
|
|
@@ -10,8 +10,9 @@ The only configuration source is:
|
|
|
10
10
|
<getAgentDir()>/pi-starship.toml
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
When this file is absent, the extension uses
|
|
14
|
-
The built-in
|
|
13
|
+
When this file is absent, the extension uses Pi's native footer without creating the file or its parent directory.
|
|
14
|
+
The built-in Starship example remains an editing seed; saving it enables a Starship footer, not Pi's native footer.
|
|
15
|
+
Its root is the explicit sequence `$brand$model$thinking$directory` `$git_branch$git_status$activity$context$time`; it does not start the opt-in GitHub PR query.
|
|
15
16
|
The first successful settings save creates the file atomically.
|
|
16
17
|
Existing malformed documents are never overwritten.
|
|
17
18
|
|
|
@@ -41,19 +42,18 @@ The ordinary main-session skill has no live runtime access; direct active-state
|
|
|
41
42
|
The preview uses cached data without starting module commands or network requests.
|
|
42
43
|
During a response, normal submission queues steering for the next assistant turn; the configured app.message.followUp action queues work after natural completion and submits normally when idle.
|
|
43
44
|
The app.message.dequeue action restores pending messages to the editor; these message actions use Pi's native precedence, including explicit history bindings.
|
|
44
|
-
The configured cancel action stops a response and restores undelivered messages,
|
|
45
|
+
The configured cancel action stops a response and restores undelivered messages; when idle, it leaves the conversation open without opening a menu. Editor actions win cancel-key collisions, with Escape as a stop fallback unless assigned to an editor action.
|
|
45
46
|
Failed or aborted responses restore undelivered input without automatic restart.
|
|
46
47
|
Ctrl+C discards the flow, clears both queues, and restores the active footer unless its session was replaced.
|
|
47
48
|
When idle with a valid draft, Ctrl+S opens the Save draft as profile flow directly; its gray editor-border hint switches to F2 if Ctrl+S is reserved, or is omitted when both keys conflict.
|
|
48
|
-
The review menu retains the same save action.
|
|
49
49
|
Saving requires exact-draft review and a profile name; invalid or existing names are rejected without overwriting a profile.
|
|
50
50
|
After saving, the host asks whether to apply that profile through managed History and atomic replacement; declining keeps the profile without changing active settings.
|
|
51
51
|
Cancelling naming returns to the chat without saving; closing or session replacement removes the temporary draft, not any saved profile.
|
|
52
52
|
Application checks the initial disk snapshot, loaded revision, and saved profile identity, blocks detected concurrent changes, and warns before explicitly repairing an invalid original.
|
|
53
53
|
Chat content and settings read by the agent go to the selected model provider; the child uses the opening model/thinking selection with Pi authentication, has no shell tool, and does not persist its transcript or change the main conversation.
|
|
54
54
|
The fullscreen view uses Pi's native user/assistant/tool message components. Short gray status and control labels sit on the editor borders; the live preview ends at the terminal bottom, in the saved footer's position.
|
|
55
|
-
It shows recent output with expanded, read-only tool results;
|
|
56
|
-
Choose **Continue** to leave
|
|
55
|
+
It shows recent output with expanded, read-only tool results; saving opens an exact-draft review.
|
|
56
|
+
Choose **Continue** to leave the save review; cancelling the review discards the flow without publishing.
|
|
57
57
|
|
|
58
58
|
Outside this hosted chat, the bundled `configure-pi-starship` skill uses a separate external-edit workflow.
|
|
59
59
|
Before its apply script replaces an existing document, it preserves the inspected document under `<getAgentDir()>/pi-starship/pi-starship-YYYYMMDDHHmm.toml`; these backups use local time and remain after a successful apply.
|
|
@@ -69,13 +69,15 @@ The focused action remains visible at small terminal heights; enlarge an extreme
|
|
|
69
69
|
Gist actions use `gh` authentication for github.com and transfer only `pi-starship.toml`, limited to 64 KiB; sharing includes comments and unknown fields and requires review and confirmation before creating an unlisted Gist.
|
|
70
70
|
Unlisted Gists are readable by anyone with the link; remove sensitive data before sharing, and check GitHub before retrying a cancelled or failed upload because a remote Gist may already exist.
|
|
71
71
|
Import accepts a Gist ID or URL, validates the complete document, requires raw TOML review, footer preview, and full-replacement confirmation, and preserves the previous document before applying; review untrusted settings for command execution and network access before accepting.
|
|
72
|
-
A missing file
|
|
72
|
+
A missing file uses Pi's native footer, an exact bundled document uses its preset name, and read or parse errors are **Built-in fallback**.
|
|
73
73
|
Reload from disk reads only after the explicit action, validates and previews the current external state from the existing runtime snapshot, and asks for separate confirmation before changing the active session.
|
|
74
|
-
A deleted document is a valid previewable transition to
|
|
74
|
+
A deleted document is a valid previewable transition to Pi's native footer and creates no file.
|
|
75
75
|
An unchanged document is a no-op, while read or parse failure, cancellation, disposal, external changes after preview, session replacement, shutdown, or runtime apply failure preserves the prior effective footer and every file byte.
|
|
76
76
|
Reload re-reads immediately after confirmation and rejects a different external snapshot; it does not claim cross-process locking or continuing synchronization with later edits.
|
|
77
|
-
Restore
|
|
78
|
-
|
|
77
|
+
**Restore built-in…** remains in the main menu and is disabled only when no settings document exists.
|
|
78
|
+
A saved built-in Starship example is not Pi's native footer and can be restored.
|
|
79
|
+
Restore previews Pi's native footer and asks for confirmation before archiving the exact document bytes in History and removing the active settings document, including custom settings, unknown fields, and comments.
|
|
80
|
+
Invalid content is preserved through the explicit recovery path.
|
|
79
81
|
|
|
80
82
|
### Named profiles
|
|
81
83
|
|
|
@@ -405,7 +407,7 @@ See [Git status behavior](modules.md#git-display-controls-and-status-templates)
|
|
|
405
407
|
|
|
406
408
|
| Failure | Result |
|
|
407
409
|
| --- | --- |
|
|
408
|
-
| Missing file | Use
|
|
410
|
+
| Missing file | Use Pi's native footer without creating a file or directory. |
|
|
409
411
|
| Read failure | Use built-in defaults and report an error diagnostic. |
|
|
410
412
|
| TOML syntax failure | Preserve the raw document, use built-in defaults, and report an error diagnostic. |
|
|
411
413
|
| Unknown root, module, option, or display field | Warn, ignore that field, and keep processing the document. |
|
|
@@ -631,6 +633,6 @@ Choose one migration:
|
|
|
631
633
|
|
|
632
634
|
1. Replace old aliases with direct styles such as `cyan bold`, `bold bright-yellow`, or `fg:#e3e5e5 bg:#769ff0`.
|
|
633
635
|
2. Define every needed alias under your own `[palettes.<name>]` table and explicitly select it with `palette = "<name>"`.
|
|
634
|
-
3. Use **Restore built-in…** from `/starship` to
|
|
636
|
+
3. Use **Restore built-in…** from `/starship` to archive the complete document in History, remove the active settings file, and return to Pi's native footer.
|
|
635
637
|
|
|
636
638
|
There is no hidden compatibility overlay or automatic migration.
|
package/src/command-commit.ts
CHANGED
|
@@ -58,9 +58,13 @@ export async function commitActiveDocument(
|
|
|
58
58
|
expected: CommitExpectation,
|
|
59
59
|
allowInvalid = false,
|
|
60
60
|
checkCandidate?: () => void,
|
|
61
|
+
restoreNative = false,
|
|
61
62
|
): Promise<"applied" | "cancel"> {
|
|
62
63
|
const raw = candidate.rawDocument;
|
|
63
|
-
if (
|
|
64
|
+
if (restoreNative) {
|
|
65
|
+
if (raw !== undefined || candidate.source !== "built-in" || candidate.diagnostics.length > 0)
|
|
66
|
+
throw new Error("The native footer candidate is invalid");
|
|
67
|
+
} else if (raw === undefined) throw new Error("The candidate settings document is unavailable");
|
|
64
68
|
return withFileMutationQueue(options.settingsPath, async () => {
|
|
65
69
|
if (!commitOwnerCurrent(options, owner, expected)) return "cancel";
|
|
66
70
|
checkCandidate?.();
|
|
@@ -75,8 +79,10 @@ export async function commitActiveDocument(
|
|
|
75
79
|
if (invalid && !allowInvalid)
|
|
76
80
|
throw new Error("The active settings document is invalid. Use explicit repair or recovery before replacing it.");
|
|
77
81
|
// Always validate again at the publication boundary, not only in the preview layer.
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
if (raw !== undefined) {
|
|
83
|
+
validateConfigDocument(options.settingsPath, raw);
|
|
84
|
+
if (previousBytes?.equals(Buffer.from(raw))) return "applied";
|
|
85
|
+
}
|
|
80
86
|
|
|
81
87
|
let recoveryPath: string | undefined;
|
|
82
88
|
if (previousBytes !== undefined) {
|
|
@@ -92,10 +98,28 @@ export async function commitActiveDocument(
|
|
|
92
98
|
}
|
|
93
99
|
let saved: LoadedStarshipConfig;
|
|
94
100
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
if (raw === undefined) {
|
|
102
|
+
if (previousBytes !== undefined) {
|
|
103
|
+
if (!expected.disk.fileIdentity) throw new Error("The settings document identity is unavailable");
|
|
104
|
+
removeConfigDocumentIfMatches(
|
|
105
|
+
options.settingsPath,
|
|
106
|
+
previousBytes.toString("utf8"),
|
|
107
|
+
expected.disk.fileIdentity,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
saved = candidate;
|
|
111
|
+
} else {
|
|
112
|
+
saved = options.save
|
|
113
|
+
? options.save(options.settingsPath, raw)
|
|
114
|
+
: atomicSaveConfigDocument(options.settingsPath, raw, {}, expected.disk);
|
|
115
|
+
}
|
|
98
116
|
} catch (error) {
|
|
117
|
+
if (restoreNative) {
|
|
118
|
+
const rollback = restorePrevious(ctx, options, owner, expected, undefined, undefined, false);
|
|
119
|
+
throw new Error(
|
|
120
|
+
`Pi native footer was not restored: ${message(error)}. ${rollback}${recoveryNote(recoveryPath)}`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
99
123
|
if (error instanceof ConfigPublicationError) {
|
|
100
124
|
const rollback = restorePrevious(ctx, options, owner, expected, raw, error.fileIdentity, false);
|
|
101
125
|
throw new Error(`Footer settings were not saved: ${message(error)}. ${rollback}${recoveryNote(recoveryPath)}`);
|
|
@@ -128,7 +152,7 @@ function restorePrevious(
|
|
|
128
152
|
options: CommitOptions,
|
|
129
153
|
owner: WorkflowOwner,
|
|
130
154
|
expected: CommitExpectation,
|
|
131
|
-
raw: string,
|
|
155
|
+
raw: string | undefined,
|
|
132
156
|
identity: LoadedStarshipConfig["fileIdentity"],
|
|
133
157
|
restoreRuntime: boolean,
|
|
134
158
|
): string {
|
|
@@ -139,6 +163,16 @@ function restorePrevious(
|
|
|
139
163
|
if (current.rawDocument !== expected.previous.rawDocument && current.rawDocument !== raw) {
|
|
140
164
|
throw new Error("The active runtime changed; stale restoration was blocked");
|
|
141
165
|
}
|
|
166
|
+
if (raw === undefined) {
|
|
167
|
+
const disk = readConfigDocumentSnapshot(options.settingsPath);
|
|
168
|
+
if (disk.rawBytes !== undefined) {
|
|
169
|
+
assertConfigDocumentUnchanged(options.settingsPath, expected.disk);
|
|
170
|
+
} else if (expected.disk.rawBytes !== undefined) {
|
|
171
|
+
atomicRestoreConfigDocument(options.settingsPath, expected.disk.rawBytes, {}, disk);
|
|
172
|
+
}
|
|
173
|
+
if (restoreRuntime) options.apply(expected.previous, ctx);
|
|
174
|
+
return "The previous configuration was restored.";
|
|
175
|
+
}
|
|
142
176
|
if (!identity) throw new Error("The saved settings document identity is unavailable");
|
|
143
177
|
assertConfigDocumentUnchanged(options.settingsPath, { rawBytes: Buffer.from(raw), fileIdentity: identity });
|
|
144
178
|
if (expected.disk.rawBytes === undefined) {
|
|
@@ -49,7 +49,7 @@ export function configurationPresentation(loaded: LoadedStarshipConfig): Configu
|
|
|
49
49
|
const fallback = loaded.source === "built-in" && loaded.diagnostics.length > 0;
|
|
50
50
|
return {
|
|
51
51
|
state: healthyMissing
|
|
52
|
-
? "
|
|
52
|
+
? "Pi native footer"
|
|
53
53
|
: savedBuiltIn
|
|
54
54
|
? "Saved built-in configuration"
|
|
55
55
|
: activePreset
|
|
@@ -65,14 +65,10 @@ export function configurationPresentation(loaded: LoadedStarshipConfig): Configu
|
|
|
65
65
|
? "User file"
|
|
66
66
|
: "Built-in fallback",
|
|
67
67
|
health: configurationHealth(loaded),
|
|
68
|
-
restoreDisabled: healthyMissing
|
|
68
|
+
restoreDisabled: healthyMissing,
|
|
69
69
|
restoreDescription: healthyMissing
|
|
70
|
-
? "Already using
|
|
71
|
-
:
|
|
72
|
-
? "Built-in configuration already saved"
|
|
73
|
-
: fallback
|
|
74
|
-
? "Preview before replacing invalid settings"
|
|
75
|
-
: "Preview before replacing the document",
|
|
70
|
+
? "Already using Pi native footer · no file to remove"
|
|
71
|
+
: "Preview before restoring Pi native footer",
|
|
76
72
|
};
|
|
77
73
|
}
|
|
78
74
|
|
|
@@ -160,7 +156,7 @@ export async function reloadConfiguration(
|
|
|
160
156
|
const confirmed = await ctx.ui.confirm(
|
|
161
157
|
"Apply configuration from disk?",
|
|
162
158
|
candidate.loaded.rawDocument === undefined
|
|
163
|
-
? "
|
|
159
|
+
? "Show Pi's native footer for this session? No settings file will be created."
|
|
164
160
|
: "Apply the validated settings document to this session without changing its bytes? The previous loaded document will be kept in History.",
|
|
165
161
|
{ signal: owner.signal },
|
|
166
162
|
);
|
|
@@ -265,7 +261,7 @@ function reloadPreviewBody(
|
|
|
265
261
|
`Source: ${presentation.source}`,
|
|
266
262
|
`Path: ${sanitizeTerminalText(options.settingsPath)}`,
|
|
267
263
|
loaded.rawDocument === undefined
|
|
268
|
-
? "Applying
|
|
264
|
+
? "Applying shows Pi's native footer and creates no settings file."
|
|
269
265
|
: "Applying changes only the active session; the settings document bytes stay unchanged.",
|
|
270
266
|
...diagnosticLines(loaded, true),
|
|
271
267
|
"",
|
|
@@ -4,17 +4,11 @@ import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
|
4
4
|
import { sanitizeTerminalDocument } from "@narumitw/pi-tui-kit/terminal-document";
|
|
5
5
|
import { captureCommitExpectation, commitActiveDocument, commitOwnerCurrent } from "./command-commit.js";
|
|
6
6
|
import type { WorkflowOwner } from "./command-configuration.js";
|
|
7
|
-
import { showPreviewActionMenu } from "./command-preview.js";
|
|
8
7
|
import { saveAsProfile } from "./command-profiles.js";
|
|
9
8
|
import type { StarshipCommandOptions } from "./commands.js";
|
|
10
9
|
import { assertProfileUnchanged } from "./profile-store.js";
|
|
11
10
|
import { createSettingsAgent, starshipPackageRoot } from "./settings-agent.js";
|
|
12
|
-
import {
|
|
13
|
-
type ChatViewState,
|
|
14
|
-
renderSettingsChatPreview,
|
|
15
|
-
settingsChatTranscript,
|
|
16
|
-
showSettingsChat,
|
|
17
|
-
} from "./settings-chat-ui.js";
|
|
11
|
+
import { type ChatViewState, showSettingsChat } from "./settings-chat-ui.js";
|
|
18
12
|
import { createSettingsDraft } from "./settings-draft.js";
|
|
19
13
|
import { settingsSnapshots } from "./settings-snapshots.js";
|
|
20
14
|
|
|
@@ -78,43 +72,7 @@ export async function showSettingsAgentChat(
|
|
|
78
72
|
while (owner.isCurrent()) {
|
|
79
73
|
const action = await showSettingsChat(ctx, agent, draft, state, owner, preview);
|
|
80
74
|
if (!owner.isCurrent() || action === "discard") return "close";
|
|
81
|
-
|
|
82
|
-
action === "save"
|
|
83
|
-
? { kind: "selected" as const, value: "save" as const }
|
|
84
|
-
: await showPreviewActionMenu(
|
|
85
|
-
ctx,
|
|
86
|
-
"Configuration chat — preview only",
|
|
87
|
-
(width, theme) => [
|
|
88
|
-
"The agent has not changed the active settings file.",
|
|
89
|
-
"Preview uses cached data; enabling modules here does not run commands or network requests.",
|
|
90
|
-
...renderSettingsChatPreview(width, preview(width), theme),
|
|
91
|
-
...sanitizeTerminalDocument(draft.diagnostics).split("\n"),
|
|
92
|
-
],
|
|
93
|
-
[
|
|
94
|
-
{ value: "continue", label: "Continue conversation" },
|
|
95
|
-
{ value: "document", label: "Review exact draft…" },
|
|
96
|
-
{ value: "transcript", label: "Review full conversation…" },
|
|
97
|
-
...(draft.candidate ? [{ value: "save" as const, label: "Save draft as profile…" }] : []),
|
|
98
|
-
{ value: "discard", label: "Discard preview and close" },
|
|
99
|
-
],
|
|
100
|
-
owner.signal,
|
|
101
|
-
owner.isCurrent,
|
|
102
|
-
);
|
|
103
|
-
if (!owner.isCurrent() || !result || result.kind === "closed") return "close";
|
|
104
|
-
if (result?.kind !== "selected") continue;
|
|
105
|
-
if (result.value === "discard") return "close";
|
|
106
|
-
if (result.value === "document" || result.value === "transcript") {
|
|
107
|
-
const reviewed = await reviewText(
|
|
108
|
-
ctx,
|
|
109
|
-
owner,
|
|
110
|
-
result.value === "document" ? "Settings draft" : "Configuration conversation",
|
|
111
|
-
result.value === "document" ? draft.rawDocument : settingsChatTranscript(agent).join("\n\n"),
|
|
112
|
-
result.value === "document",
|
|
113
|
-
);
|
|
114
|
-
if (!owner.isCurrent() || !reviewed) return "close";
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
if (result.value !== "save" || !draft.candidate) continue;
|
|
75
|
+
if (!draft.candidate) continue;
|
|
118
76
|
const candidate = draft.candidate;
|
|
119
77
|
const revision = draft.revision;
|
|
120
78
|
const reviewed = await reviewText(ctx, owner, "Review draft before saving", candidate.rawDocument ?? "", true);
|
package/src/commands.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { importSettingsGist, shareSettingsGist } from "./command-gist.js";
|
|
|
19
19
|
import { showPresetPicker } from "./command-preset-picker.js";
|
|
20
20
|
import { type PreviewMenuResult, showPreviewActionMenu } from "./command-preview.js";
|
|
21
21
|
import { saveAsProfile, showHistory, showProfiles } from "./command-profiles.js";
|
|
22
|
-
import { BUILT_IN_EXAMPLE, type LoadedStarshipConfig, validateConfigDocument } from "./config.js";
|
|
22
|
+
import { BUILT_IN_EXAMPLE, type LoadedStarshipConfig, nativeFooterConfig, validateConfigDocument } from "./config.js";
|
|
23
23
|
import type { GhApi } from "./gist.js";
|
|
24
24
|
import type { StatuslineInspection } from "./modules/inspection.js";
|
|
25
25
|
import { getStarshipPreset, presetForDocument, STARSHIP_PRESETS, type StarshipPreset } from "./presets/catalog.js";
|
|
@@ -502,8 +502,8 @@ async function restoreBuiltIn(
|
|
|
502
502
|
): Promise<"applied" | "cancel" | "close"> {
|
|
503
503
|
const owner = workflowOwner(options);
|
|
504
504
|
if (!isCurrentOwner(owner)) return "cancel";
|
|
505
|
-
const
|
|
506
|
-
const result = await reviewAndApply(ctx, options,
|
|
505
|
+
const candidate = nativeFooterConfig(options.settingsPath);
|
|
506
|
+
const result = await reviewAndApply(ctx, options, candidate, { kind: "restore" }, owner);
|
|
507
507
|
return result === "edit" ? "cancel" : result;
|
|
508
508
|
}
|
|
509
509
|
|
|
@@ -588,6 +588,7 @@ export async function reviewAndApply(
|
|
|
588
588
|
expected,
|
|
589
589
|
intent.kind === "restore" || intent.kind === "history" || intent.kind === "customize",
|
|
590
590
|
checkCandidate,
|
|
591
|
+
intent.kind === "restore",
|
|
591
592
|
);
|
|
592
593
|
if (!isSessionOwnerCurrent(owner) || result === "cancel") return "cancel";
|
|
593
594
|
} catch (error) {
|
|
@@ -628,7 +629,7 @@ function continueLabel(intent: ReviewIntent): string {
|
|
|
628
629
|
case "customize":
|
|
629
630
|
return "Apply changes…";
|
|
630
631
|
case "restore":
|
|
631
|
-
return "
|
|
632
|
+
return "Restore Pi native footer…";
|
|
632
633
|
case "import":
|
|
633
634
|
return "Replace with Gist settings…";
|
|
634
635
|
case "profile":
|
|
@@ -645,7 +646,7 @@ function confirmationTitle(intent: ReviewIntent): string {
|
|
|
645
646
|
case "customize":
|
|
646
647
|
return "Apply footer changes?";
|
|
647
648
|
case "restore":
|
|
648
|
-
return "Restore
|
|
649
|
+
return "Restore Pi native footer?";
|
|
649
650
|
case "import":
|
|
650
651
|
return "Replace settings with Gist?";
|
|
651
652
|
case "profile":
|
|
@@ -658,21 +659,21 @@ function confirmationTitle(intent: ReviewIntent): string {
|
|
|
658
659
|
}
|
|
659
660
|
|
|
660
661
|
function confirmationMessage(settingsPath: string, intent: ReviewIntent, previous: LoadedStarshipConfig): string {
|
|
662
|
+
if (intent.kind === "restore")
|
|
663
|
+
return `Remove ${safeText(settingsPath)} and show Pi's native footer? The exact previous document, including invalid settings, unknown fields, and comments, will be kept in History.`;
|
|
661
664
|
if (previous.diagnostics.some((item) => item.severity === "error")) {
|
|
662
665
|
return `Explicit recovery: replace the invalid settings file ${safeText(settingsPath)} entirely with the reviewed document? Its exact original bytes will be kept in History before replacement.`;
|
|
663
666
|
}
|
|
664
667
|
if (intent.kind === "customize")
|
|
665
668
|
return "Replace the entire settings document and apply it immediately? Its previous bytes will be kept in History.";
|
|
666
669
|
const replacement =
|
|
667
|
-
intent.kind === "
|
|
668
|
-
? "the
|
|
669
|
-
: intent.kind === "
|
|
670
|
-
?
|
|
671
|
-
: intent.kind === "
|
|
672
|
-
?
|
|
673
|
-
: intent.
|
|
674
|
-
? "the reviewed history document"
|
|
675
|
-
: `the ${intent.preset.label} preset`;
|
|
670
|
+
intent.kind === "import"
|
|
671
|
+
? "the reviewed Gist settings"
|
|
672
|
+
: intent.kind === "profile"
|
|
673
|
+
? `the ${safeText(intent.name)} profile`
|
|
674
|
+
: intent.kind === "history"
|
|
675
|
+
? "the reviewed history document"
|
|
676
|
+
: `the ${intent.preset.label} preset`;
|
|
676
677
|
return `Replace ${safeText(settingsPath)} entirely with ${replacement}? All custom settings, unknown fields, and comments will be replaced. The previous document will be kept in History.`;
|
|
677
678
|
}
|
|
678
679
|
|
|
@@ -681,7 +682,7 @@ function successMessage(intent: ReviewIntent): string {
|
|
|
681
682
|
case "customize":
|
|
682
683
|
return "Footer settings saved and applied";
|
|
683
684
|
case "restore":
|
|
684
|
-
return "
|
|
685
|
+
return "Pi native footer restored and applied";
|
|
685
686
|
case "import":
|
|
686
687
|
return "Gist settings saved and applied";
|
|
687
688
|
case "profile":
|
|
@@ -730,7 +731,7 @@ function reviewPreviewBody(
|
|
|
730
731
|
width: number,
|
|
731
732
|
intent: ReviewIntent,
|
|
732
733
|
): string[] {
|
|
733
|
-
if (intent.kind === "restore") return restorePreviewBody(
|
|
734
|
+
if (intent.kind === "restore") return restorePreviewBody(options);
|
|
734
735
|
if (intent.kind !== "preset") return previewBody(ctx, options, loaded, width);
|
|
735
736
|
const current = configurationPresentation(options.getLoaded());
|
|
736
737
|
return [
|
|
@@ -745,20 +746,15 @@ function reviewPreviewBody(
|
|
|
745
746
|
];
|
|
746
747
|
}
|
|
747
748
|
|
|
748
|
-
function restorePreviewBody(
|
|
749
|
-
ctx: ExtensionCommandContext,
|
|
750
|
-
options: StarshipCommandOptions,
|
|
751
|
-
loaded: LoadedStarshipConfig,
|
|
752
|
-
width: number,
|
|
753
|
-
): string[] {
|
|
749
|
+
function restorePreviewBody(options: StarshipCommandOptions): string[] {
|
|
754
750
|
const current = configurationPresentation(options.getLoaded());
|
|
755
751
|
return [
|
|
756
752
|
`Current: ${current.state}`,
|
|
757
753
|
`Path: ${safeText(options.settingsPath)}`,
|
|
758
|
-
"The entire settings document will be
|
|
759
|
-
"The previous document will be kept in History before
|
|
760
|
-
"",
|
|
761
|
-
|
|
754
|
+
"The entire settings document will be removed, including custom settings, unknown fields, and comments.",
|
|
755
|
+
"The previous document will be kept in History before removal.",
|
|
756
|
+
"Pi's native footer will be shown instead of the pi-starship footer.",
|
|
757
|
+
"No replacement settings file will be created.",
|
|
762
758
|
];
|
|
763
759
|
}
|
|
764
760
|
|
package/src/config.ts
CHANGED
|
@@ -115,6 +115,11 @@ export function settingsFilePath(agentDir: string): string {
|
|
|
115
115
|
return join(agentDir, CONFIG_FILE_NAME);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
/** No active Starship document: Pi owns the footer. Module defaults remain available for new drafts. */
|
|
119
|
+
export function nativeFooterConfig(settingsPath: string): LoadedStarshipConfig {
|
|
120
|
+
return { config: cloneBuiltInConfig(), source: "built-in", settingsPath, diagnostics: [] };
|
|
121
|
+
}
|
|
122
|
+
|
|
118
123
|
export function loadStarshipConfig(settingsPath: string): LoadedStarshipConfig {
|
|
119
124
|
let rawDocument: string;
|
|
120
125
|
let snapshot: ConfigDocumentSnapshot;
|
|
@@ -125,12 +130,7 @@ export function loadStarshipConfig(settingsPath: string): LoadedStarshipConfig {
|
|
|
125
130
|
rawDocument = rawBytes.toString("utf8");
|
|
126
131
|
} catch (error) {
|
|
127
132
|
if ((error as NodeJS.ErrnoException).code === "ENOENT" && !existsSync(settingsPath)) {
|
|
128
|
-
return
|
|
129
|
-
config: cloneBuiltInConfig(),
|
|
130
|
-
source: "built-in",
|
|
131
|
-
settingsPath,
|
|
132
|
-
diagnostics: [],
|
|
133
|
-
};
|
|
133
|
+
return nativeFooterConfig(settingsPath);
|
|
134
134
|
}
|
|
135
135
|
return {
|
|
136
136
|
config: cloneBuiltInConfig(),
|