@narumitw/pi-starship 0.59.2 → 0.60.1
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 +28 -3
- package/dist/chunks/{chunk-MTFSZ63Q.ts → chunk-KZZKGGFW.ts} +327 -42
- package/dist/chunks/chunk-KZZKGGFW.ts.map +7 -0
- package/dist/chunks/{commands-K6T7PNEM.ts → commands-C2VJ6ZBN.ts} +1279 -111
- package/dist/chunks/commands-C2VJ6ZBN.ts.map +7 -0
- package/dist/index.ts +25 -9
- package/dist/index.ts.map +2 -2
- package/package.json +2 -2
- package/skills/configure-pi-starship/SKILL.md +20 -2
- package/skills/configure-pi-starship/references/configuration.md +122 -11
- package/skills/configure-pi-starship/scripts/apply.mjs +87 -33
- package/skills/configure-pi-starship/scripts/backup.mjs +17 -0
- package/skills/configure-pi-starship/scripts/config-path.mjs +63 -3
- package/src/command-commit.ts +169 -0
- package/src/command-configuration.ts +78 -34
- package/src/command-gist.ts +11 -3
- package/src/command-preset-picker.ts +6 -2
- package/src/command-profiles.ts +664 -0
- package/src/commands.ts +223 -77
- package/src/config.ts +112 -14
- package/src/format/formatter.ts +8 -4
- package/src/format/style.ts +54 -15
- package/src/format/terminal-safety.ts +80 -0
- package/src/format/theme-colors.ts +69 -0
- package/src/modules/model.ts +1 -1
- package/src/modules/render.ts +75 -5
- package/src/pi-starship.ts +22 -6
- package/src/profile-store.ts +526 -0
- package/dist/chunks/chunk-MTFSZ63Q.ts.map +0 -7
- package/dist/chunks/commands-K6T7PNEM.ts.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands.ts", "../../src/command-commit.ts", "../../src/profile-store.ts", "../../src/command-configuration.ts", "../../src/command-preview.ts", "../../src/effective-config.ts", "../../src/presets/bracketed-segments.ts", "../../src/presets/catppuccin-powerline.ts", "../../src/presets/gruvbox-rainbow.ts", "../../src/presets/jetpack.ts", "../../src/presets/minimal.ts", "../../src/presets/nerd-font-symbols.ts", "../../src/presets/no-empty-icons.ts", "../../src/presets/no-nerd-font.ts", "../../src/presets/no-runtime-versions.ts", "../../src/presets/pastel-powerline.ts", "../../src/presets/plain-text-symbols.ts", "../../src/presets/pure-preset.ts", "../../src/presets/tokyo-night.ts", "../../src/presets/catalog.ts", "../../src/command-gist.ts", "../../src/gist.ts", "../../src/command-inspector.ts", "../../src/command-preset-picker.ts", "../../src/command-profiles.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionAPI, ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { isKeyRelease, Key, matchesKey } from \"@earendil-works/pi-tui\";\nimport { defineMenu, runMenu } from \"@narumitw/pi-tui-kit\";\nimport {\n type CommitExpectation,\n type CommitOptions,\n captureCommitExpectation,\n commitActiveDocument,\n commitOwnerCurrent,\n} from \"./command-commit.js\";\nimport {\n type ConfigurationCommandOptions,\n configurationMenuScreen,\n configurationOverviewScreen,\n configurationPresentation,\n effectiveConfigurationScreen,\n reloadConfiguration,\n settingsDocumentScreen,\n type WorkflowOwner,\n} from \"./command-configuration.js\";\nimport { completeStarshipArguments, STARSHIP_SUBCOMMANDS } from \"./command-contract.js\";\nimport { importSettingsGist, shareSettingsGist } from \"./command-gist.js\";\nimport { formatFooterExplanation } from \"./command-inspector.js\";\nimport { showPresetPicker } from \"./command-preset-picker.js\";\nimport { type PreviewMenuResult, showPreviewActionMenu } from \"./command-preview.js\";\nimport { saveAsProfile, showHistory, showProfiles } from \"./command-profiles.js\";\nimport { BUILT_IN_EXAMPLE, type LoadedStarshipConfig, validateConfigDocument } from \"./config.js\";\nimport type { GhApi } from \"./gist.js\";\nimport { inspectUnavailableModules, type StatuslineInspection } from \"./modules/inspection.js\";\nimport { getStarshipPreset, presetForDocument, STARSHIP_PRESETS, type StarshipPreset } from \"./presets/catalog.js\";\n\nconst MAIN_ACTIONS = {\n customize: \"customize\",\n presets: \"presets\",\n explain: \"explain\",\n modules: \"modules\",\n configuration: \"configuration\",\n help: \"help\",\n restore: \"restore\",\n profiles: \"profiles\",\n} as const;\n\nconst PREVIEW_ACTIONS = {\n continue: \"continue\",\n edit: \"edit\",\n cancel: \"cancel\",\n saveProfile: \"save-profile\",\n} as const;\n\nexport interface StarshipCommandOptions extends ConfigurationCommandOptions, CommitOptions {\n getInspection?(): StatuslineInspection | undefined;\n preview?(loaded: LoadedStarshipConfig | undefined, ctx: ExtensionCommandContext): void;\n save?: (settingsPath: string, rawDocument: string) => LoadedStarshipConfig;\n restore?: (settingsPath: string, rawDocument: string) => void;\n validate?: (settingsPath: string, rawDocument: string) => LoadedStarshipConfig;\n getMenuOwner?(): WorkflowOwner;\n gistApi?: GhApi;\n}\n\nexport type ReviewIntent =\n | { kind: \"customize\" }\n | { kind: \"restore\" }\n | { kind: \"import\" }\n | { kind: \"profile\"; name: string }\n | { kind: \"history\"; name?: string }\n | { kind: \"preset\"; preset: StarshipPreset };\n\nexport function registerStarshipCommand(pi: ExtensionAPI, options: StarshipCommandOptions) {\n pi.registerCommand(\"starship\", {\n description: \"Customize or inspect the native Starship-style footer\",\n getArgumentCompletions: completeStarshipArguments,\n handler: (args, ctx) => handleStarshipCommand(args, ctx, options),\n });\n}\n\nexport async function handleStarshipCommand(\n args: string,\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n) {\n if (ctx.mode !== \"tui\") return runStarshipCommand(args, ctx, options);\n const base = workflowOwner(options);\n if (!isCurrentOwner(base)) return;\n const controller = new AbortController();\n const signal = AbortSignal.any([base.signal, controller.signal]);\n const owner: WorkflowOwner = {\n signal,\n isCurrent: () => !signal.aborted && base.isCurrent(),\n isSessionCurrent: () => base.isSessionCurrent?.() ?? base.isCurrent(),\n };\n // Pi delivers bracketed paste as one framed packet. Exact key matching does\n // not treat controls inside pasted text as cancellation or consume native input.\n const unsubscribe = ctx.ui.onTerminalInput((data) => {\n if (!isKeyRelease(data) && matchesKey(data, Key.ctrl(\"c\"))) {\n // Let the current native dialog receive this input before abort restores\n // focus; otherwise the same key can reach the underlying editor.\n queueMicrotask(() => controller.abort());\n }\n return undefined;\n });\n let listening = true;\n const release = () => {\n if (!listening) return;\n listening = false;\n unsubscribe();\n };\n signal.addEventListener(\"abort\", release, { once: true });\n try {\n return await runStarshipCommand(args, ctx, { ...options, getMenuOwner: () => owner });\n } finally {\n signal.removeEventListener(\"abort\", release);\n release();\n controller.abort();\n }\n}\n\nasync function runStarshipCommand(args: string, ctx: ExtensionCommandContext, options: StarshipCommandOptions) {\n const normalized = args.trim();\n if (!normalized) {\n if (ctx.mode === \"tui\") await showMainMenu(ctx, options);\n else showHelp(ctx, options.settingsPath);\n return;\n }\n\n const [subcommand = \"\", ...trailing] = normalized.split(/\\s+/u);\n const route = subcommand.toLowerCase();\n if (trailing.length > 0 || !STARSHIP_SUBCOMMANDS.some((item) => item.value === route)) {\n if (canNotify(ctx)) {\n const reason =\n trailing.length > 0\n ? `Unexpected arguments for /starship ${safeText(route)}.`\n : `Unknown /starship subcommand: ${safeText(route)}.`;\n ctx.ui.notify(`${reason} Usage: /starship [settings|status|help]`, \"warning\");\n }\n return;\n }\n switch (route) {\n case \"settings\":\n await editSettings(ctx, options);\n return;\n case \"status\":\n showStatus(ctx, options);\n return;\n case \"help\":\n showHelp(ctx, options.settingsPath);\n return;\n }\n}\n\nasync function showMainMenu(ctx: ExtensionCommandContext, options: StarshipCommandOptions) {\n const fallbackController = new AbortController();\n const owner = options.getMenuOwner?.() ?? {\n signal: fallbackController.signal,\n isCurrent: () => !fallbackController.signal.aborted,\n };\n type Screen =\n | \"main\"\n | \"explain\"\n | \"modules\"\n | \"configuration\"\n | \"configuration-overview\"\n | \"configuration-effective\"\n | \"configuration-document\"\n | \"help\";\n type Action =\n | \"customize\"\n | \"presets\"\n | \"profiles\"\n | \"history\"\n | \"configuration-reload\"\n | \"restore\"\n | \"gist-share\"\n | \"gist-import\";\n const menu = defineMenu<undefined, Screen, Action, ExtensionCommandContext>({\n start: \"main\",\n screens: {\n main: () => {\n const loaded = options.getLoaded();\n const presentation = configurationPresentation(loaded);\n return {\n kind: \"actions\",\n title: \"pi-starship\",\n lines: [`${presentation.state} \u00B7 ${presentation.health}`],\n items: [\n {\n id: MAIN_ACTIONS.customize,\n label: \"Customize footer\",\n description: `${presentation.state} \u00B7 preview before applying`,\n action: \"customize\",\n },\n {\n id: MAIN_ACTIONS.presets,\n label: \"Presets\",\n description: \"Browse and live-preview bundled footer starting points\",\n action: \"presets\",\n },\n {\n id: MAIN_ACTIONS.explain,\n label: \"Explain footer\",\n description: \"Why each visible module appears\",\n to: \"explain\",\n },\n {\n id: MAIN_ACTIONS.modules,\n label: \"Modules\",\n description: \"Browse supported modules and current states\",\n to: \"modules\",\n },\n {\n id: MAIN_ACTIONS.configuration,\n label: \"Configuration\",\n description: presentation.health,\n to: \"configuration\",\n },\n {\n id: MAIN_ACTIONS.help,\n label: \"Help\",\n description: \"Formats, modules, and commands\",\n to: \"help\",\n },\n {\n id: MAIN_ACTIONS.restore,\n label: \"Restore built-in\u2026\",\n description: presentation.restoreDescription,\n disabled: presentation.restoreDisabled,\n action: \"restore\",\n },\n {\n id: MAIN_ACTIONS.profiles,\n label: \"Profiles\",\n description: \"Save, edit, manage, and live-preview named TOML documents\",\n action: \"profiles\",\n },\n ],\n hint: \"close\",\n };\n },\n explain: () => ({\n kind: \"review\",\n title: \"Explain footer\",\n content: formatFooterExplanation(options.getInspection?.()),\n format: { kind: \"text\" },\n viewportSize: \"adaptive\",\n hint: \"back\",\n }),\n modules: () => {\n const inspection = options.getInspection?.() ?? inspectUnavailableModules(options.getLoaded().config);\n return {\n kind: \"browse\",\n title: \"Modules\",\n items: inspection.modules.map((module) => ({\n id: module.name,\n label: module.name,\n statusText: module.state,\n description: module.description,\n searchText: [...module.variables, ...module.styleFields, ...module.displayRules].join(\" \"),\n details: [\n `Root: ${module.rootReferenced ? \"Referenced\" : \"Not referenced\"}`,\n `Reachable: ${module.reachable ? \"Yes\" : \"No\"}`,\n ...modulePreviewDetails(module.preview),\n `Reason: ${module.reason}`,\n `Variables: ${module.variables.join(\", \") || \"none\"}`,\n `Style fields: ${module.styleFields.join(\", \") || \"none\"}`,\n `Style-rule selectors: ${module.styleRuleSelectors.join(\", \") || \"none\"}`,\n `Style rules: ${module.styleRuleCount} configured`,\n `Display rules: ${module.displayRules.join(\" \u00B7 \") || \"none\"}`,\n ],\n })),\n viewportSize: \"adaptive\",\n hint: \"back\",\n };\n },\n configuration: () => configurationMenuScreen(options.getLoaded()),\n \"configuration-overview\": () => configurationOverviewScreen(options.getLoaded(), options.settingsPath),\n \"configuration-effective\": () => effectiveConfigurationScreen(options.getLoaded()),\n \"configuration-document\": () => settingsDocumentScreen(options.getLoaded(), options.settingsPath),\n help: () => ({\n kind: \"detail\",\n title: \"pi-starship help\",\n lines: [\n \"Customize footer opens the TOML editor, then previews and confirms before saving.\",\n \"Presets live-previews the cursor in the footer; Enter confirms apply, e customizes, and s saves a profile when available.\",\n \"Profiles manages named TOML copies; selecting a document previews it without saving.\",\n \"Configuration History reviews and restores recovery copies; external edits are not fully tracked.\",\n \"Explain footer breaks down the modules currently showing from the existing snapshot.\",\n \"Modules searches every supported module and explains its current read-only state.\",\n \"Configuration includes disk reload plus unlisted Gist sharing and reviewed Gist import through gh.\",\n `Settings: ${safeText(options.settingsPath)}`,\n \"Docs: https://github.com/narumiruna/pi-extensions/tree/main/packages/pi-starship\",\n ],\n hint: \"back\",\n }),\n },\n actions: {\n customize: async () => {\n const result = await editSettings(ctx, options);\n return result === \"applied\" || result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n presets: async () => {\n const result = await choosePreset(ctx, options, owner);\n return result === \"applied\" || result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n profiles: async () => {\n const result = await showProfiles(ctx, options, owner, async (loaded, guardedOwner, checkCandidate, name) => {\n const applied = await reviewAndApply(\n ctx,\n options,\n loaded,\n { kind: \"profile\", name },\n guardedOwner,\n false,\n checkCandidate,\n );\n return applied === \"applied\" ? \"applied\" : applied === \"close\" ? \"close\" : \"stay\";\n });\n return result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n history: async () => {\n const result = await showHistory(ctx, options, owner, async (loaded, guardedOwner, checkCandidate, name) => {\n const applied = await reviewAndApply(\n ctx,\n options,\n loaded,\n { kind: \"history\", name },\n guardedOwner,\n false,\n checkCandidate,\n );\n return applied === \"applied\" ? \"applied\" : applied === \"close\" ? \"close\" : \"stay\";\n });\n return result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n \"gist-share\": async () => {\n const result = await shareSettingsGist(ctx, options, owner, options.gistApi);\n return result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n \"gist-import\": async () => {\n const result = await importSettingsGist(\n ctx,\n options,\n owner,\n async (loaded, guardedOptions, guardedOwner) => {\n const applied = await reviewAndApply(ctx, guardedOptions, loaded, { kind: \"import\" }, guardedOwner);\n return applied === \"edit\" ? \"cancel\" : applied;\n },\n options.gistApi,\n );\n return result === \"applied\" || result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n \"configuration-reload\": async () => {\n const result = await reloadConfiguration(ctx, options, owner);\n return result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n restore: async () => {\n const presentation = configurationPresentation(options.getLoaded());\n if (presentation.restoreDisabled) {\n ctx.ui.notify(presentation.restoreDescription, \"info\");\n return { kind: \"stay\" };\n }\n const result = await restoreBuiltIn(ctx, options);\n return result === \"applied\" || result === \"close\" ? { kind: \"close\" } : { kind: \"stay\" };\n },\n },\n });\n try {\n await runMenu(ctx, menu, {\n getState: () => undefined,\n signal: owner.signal,\n isCurrent: owner.isCurrent,\n });\n } finally {\n fallbackController.abort(new DOMException(\"Starship menu closed\", \"AbortError\"));\n }\n}\n\nasync function editSettings(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n): Promise<\"applied\" | \"cancel\" | \"close\"> {\n const owner = workflowOwner(options);\n if (!isCurrentOwner(owner)) return \"cancel\";\n if (ctx.mode !== \"tui\") {\n if (ctx.hasUI) ctx.ui.notify(`Edit settings manually: ${options.settingsPath}`, \"info\");\n return \"cancel\";\n }\n const expected = captureExpectation(ctx, options);\n if (!expected) return \"cancel\";\n let draft = expected.previous.rawDocument ?? BUILT_IN_EXAMPLE;\n while (true) {\n const edited = await ctx.ui.editor(\"Customize footer \u2014 close to preview\", draft);\n if (!commitOwnerCurrent(options, owner, expected) || edited === undefined) return \"cancel\";\n draft = edited;\n let validated: LoadedStarshipConfig;\n try {\n validated = (options.validate ?? validateConfigDocument)(options.settingsPath, draft);\n } catch (error) {\n ctx.ui.notify(`Footer draft is invalid: ${safeText(formatError(error))}`, \"error\");\n const action = await showPreviewActionMenu(\n ctx,\n \"Configuration needs attention\",\n () => [safeText(formatError(error)), \"The current footer has not changed.\"],\n [\n { value: PREVIEW_ACTIONS.edit, label: \"Continue editing\" },\n { value: PREVIEW_ACTIONS.cancel, label: \"Discard draft\" },\n ],\n owner.signal,\n owner.isCurrent,\n );\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n if (action?.kind === \"closed\") return \"close\";\n if (selectedPreviewAction(action) === PREVIEW_ACTIONS.edit) continue;\n return \"cancel\";\n }\n\n const result = await reviewAndApply(\n ctx,\n options,\n validated,\n { kind: \"customize\" },\n owner,\n false,\n undefined,\n expected,\n );\n if (result === \"edit\") continue;\n return result;\n }\n}\n\nasync function choosePreset(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n): Promise<\"applied\" | \"cancel\" | \"close\"> {\n const expected = captureExpectation(ctx, options);\n if (!expected) return \"cancel\";\n const activePreset = presetForDocument(expected.previous.rawDocument);\n const selection = await showPresetPicker(ctx, {\n presets: STARSHIP_PRESETS,\n activePresetId: activePreset?.id,\n initialPresetId: activePreset?.id ?? STARSHIP_PRESETS[0]?.id,\n signal: owner.signal,\n isCurrent: owner.isCurrent,\n preview(preset) {\n const loaded = (options.validate ?? validateConfigDocument)(options.settingsPath, preset.rawDocument);\n options.preview?.(loaded, ctx);\n },\n });\n if (!commitOwnerCurrent(options, owner, expected)) {\n clearSessionPreview(ctx, options, owner);\n return \"cancel\";\n }\n if (selection.kind === \"back\" || selection.kind === \"close\") {\n clearSessionPreview(ctx, options, owner);\n return selection.kind === \"close\" ? \"close\" : \"cancel\";\n }\n\n const preset = getStarshipPreset(selection.presetId);\n try {\n if (selection.kind === \"save-profile\") {\n const saved = await saveAsProfile(ctx, options, owner, preset.rawDocument);\n return saved === \"close\" ? \"close\" : \"cancel\";\n }\n return await applyPreset(\n ctx,\n options,\n preset,\n selection.kind === \"customize\" ? \"customize\" : \"confirm\",\n expected,\n owner,\n );\n } finally {\n clearSessionPreview(ctx, options, owner);\n }\n}\n\nasync function applyPreset(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n preset: StarshipPreset,\n start: \"review\" | \"confirm\" | \"customize\" = \"review\",\n captured?: CommitExpectation,\n capturedOwner?: WorkflowOwner,\n): Promise<\"applied\" | \"cancel\" | \"close\"> {\n const owner = capturedOwner ?? workflowOwner(options);\n if (!isCurrentOwner(owner)) return \"cancel\";\n const expected = captured ?? captureExpectation(ctx, options);\n if (!expected) return \"cancel\";\n let draft = preset.rawDocument;\n if (start === \"customize\") {\n const edited = await ctx.ui.editor(`Customize ${preset.label} preset`, draft);\n if (!commitOwnerCurrent(options, owner, expected) || edited === undefined) return \"cancel\";\n draft = edited;\n }\n while (true) {\n let validated: LoadedStarshipConfig;\n try {\n validated = (options.validate ?? validateConfigDocument)(options.settingsPath, draft);\n } catch (error) {\n ctx.ui.notify(`Preset draft is invalid: ${safeText(formatError(error))}`, \"error\");\n const action = await showPreviewActionMenu(\n ctx,\n \"Preset needs attention\",\n () => [safeText(formatError(error)), \"The current footer has not changed.\"],\n [\n { value: PREVIEW_ACTIONS.edit, label: \"Continue editing\" },\n { value: PREVIEW_ACTIONS.cancel, label: \"Choose another preset\" },\n ],\n owner.signal,\n owner.isCurrent,\n );\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n if (action?.kind === \"closed\") return \"close\";\n if (selectedPreviewAction(action) !== PREVIEW_ACTIONS.edit) return \"cancel\";\n const edited = await ctx.ui.editor(`Customize ${preset.label} preset`, draft);\n if (!commitOwnerCurrent(options, owner, expected) || edited === undefined) return \"cancel\";\n draft = edited;\n continue;\n }\n\n const result = await reviewAndApply(\n ctx,\n options,\n validated,\n { kind: \"preset\", preset },\n owner,\n start === \"confirm\",\n undefined,\n expected,\n );\n if (result !== \"edit\") return result;\n const edited = await ctx.ui.editor(`Customize ${preset.label} preset`, draft);\n if (!commitOwnerCurrent(options, owner, expected) || edited === undefined) return \"cancel\";\n draft = edited;\n }\n}\n\nasync function restoreBuiltIn(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n): Promise<\"applied\" | \"cancel\" | \"close\"> {\n const owner = workflowOwner(options);\n if (!isCurrentOwner(owner)) return \"cancel\";\n const validated = (options.validate ?? validateConfigDocument)(options.settingsPath, BUILT_IN_EXAMPLE);\n const result = await reviewAndApply(ctx, options, validated, { kind: \"restore\" }, owner);\n return result === \"edit\" ? \"cancel\" : result;\n}\n\nexport async function reviewAndApply(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n validated: LoadedStarshipConfig,\n intent: ReviewIntent,\n owner: WorkflowOwner,\n skipReview = false,\n checkCandidate?: () => void,\n captured?: CommitExpectation,\n): Promise<\"applied\" | \"edit\" | \"cancel\" | \"close\"> {\n if (ctx.mode !== \"tui\" || !isCurrentOwner(owner)) return \"cancel\";\n const expected = captured ?? captureExpectation(ctx, options);\n if (!expected) return \"cancel\";\n let reviewRequired = !skipReview;\n while (true) {\n const directAttempt = !reviewRequired;\n if (reviewRequired) {\n const selection = await showPreviewActionMenu(\n ctx,\n reviewTitle(intent),\n (width) => reviewPreviewBody(ctx, options, validated, width, intent),\n [\n { value: PREVIEW_ACTIONS.continue, label: continueLabel(intent) },\n ...(intent.kind !== \"customize\" && intent.kind !== \"preset\"\n ? []\n : [\n {\n value: PREVIEW_ACTIONS.edit,\n label: intent.kind === \"preset\" ? \"Customize before applying\" : \"Continue editing\",\n },\n ]),\n {\n value: PREVIEW_ACTIONS.cancel,\n label:\n intent.kind === \"restore\"\n ? \"Cancel\"\n : intent.kind === \"preset\"\n ? \"Choose another preset\"\n : \"Discard draft\",\n },\n ...(intent.kind === \"customize\" || intent.kind === \"preset\" || intent.kind === \"import\"\n ? [{ value: PREVIEW_ACTIONS.saveProfile, label: \"Save as profile\u2026\" }]\n : []),\n ],\n owner.signal,\n owner.isCurrent,\n );\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n if (selection?.kind === \"closed\") return \"close\";\n const selected = selectedPreviewAction(selection);\n if (selected === PREVIEW_ACTIONS.edit) return \"edit\";\n if (selected === PREVIEW_ACTIONS.saveProfile) {\n const saved = await saveAsProfile(ctx, options, owner, validated.rawDocument ?? BUILT_IN_EXAMPLE);\n if (saved === \"close\") return \"close\";\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n continue;\n }\n if (selected !== PREVIEW_ACTIONS.continue) return \"cancel\";\n }\n reviewRequired = true;\n\n const confirmed = await ctx.ui.confirm(\n confirmationTitle(intent),\n confirmationMessage(options.settingsPath, intent, expected.previous),\n { signal: owner.signal },\n );\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n if (!confirmed) {\n if (directAttempt) return \"cancel\";\n continue;\n }\n\n try {\n const result = await commitActiveDocument(\n ctx,\n options,\n validated,\n owner,\n expected,\n intent.kind === \"restore\" || intent.kind === \"history\" || intent.kind === \"customize\",\n checkCandidate,\n );\n if (!isSessionOwnerCurrent(owner) || result === \"cancel\") return \"cancel\";\n } catch (error) {\n if (!isSessionOwnerCurrent(owner)) return \"cancel\";\n ctx.ui.notify(safeText(formatError(error)), \"error\");\n if (directAttempt) return \"cancel\";\n continue;\n }\n\n const warningSuffix =\n validated.diagnostics.length > 0\n ? ` (${validated.diagnostics.length} warning${validated.diagnostics.length === 1 ? \"\" : \"s\"})`\n : \"\";\n ctx.ui.notify(`${successMessage(intent)}${warningSuffix}.`, \"info\");\n return \"applied\";\n }\n}\n\nfunction reviewTitle(intent: ReviewIntent): string {\n switch (intent.kind) {\n case \"customize\":\n return \"Footer preview\";\n case \"restore\":\n return \"Restore preview\";\n case \"import\":\n return \"Gist footer preview\";\n case \"profile\":\n return `${safeText(intent.name)} profile preview`;\n case \"history\":\n return \"History recovery preview\";\n case \"preset\":\n return `${intent.preset.label} preset preview`;\n }\n}\n\nfunction continueLabel(intent: ReviewIntent): string {\n switch (intent.kind) {\n case \"customize\":\n return \"Apply changes\u2026\";\n case \"restore\":\n return \"Replace with built-in\u2026\";\n case \"import\":\n return \"Replace with Gist settings\u2026\";\n case \"profile\":\n return `Apply ${safeText(intent.name)} profile\u2026`;\n case \"history\":\n return \"Restore history document\u2026\";\n case \"preset\":\n return `Apply ${intent.preset.label} preset\u2026`;\n }\n}\n\nfunction confirmationTitle(intent: ReviewIntent): string {\n switch (intent.kind) {\n case \"customize\":\n return \"Apply footer changes?\";\n case \"restore\":\n return \"Restore built-in footer?\";\n case \"import\":\n return \"Replace settings with Gist?\";\n case \"profile\":\n return `Apply ${safeText(intent.name)} profile?`;\n case \"history\":\n return \"Restore settings from history?\";\n case \"preset\":\n return `Apply ${intent.preset.label} preset?`;\n }\n}\n\nfunction confirmationMessage(settingsPath: string, intent: ReviewIntent, previous: LoadedStarshipConfig): string {\n if (previous.diagnostics.some((item) => item.severity === \"error\")) {\n 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.`;\n }\n if (intent.kind === \"customize\")\n return \"Replace the entire settings document and apply it immediately? Its previous bytes will be kept in History.\";\n const replacement =\n intent.kind === \"restore\"\n ? \"the built-in configuration\"\n : intent.kind === \"import\"\n ? \"the reviewed Gist settings\"\n : intent.kind === \"profile\"\n ? `the ${safeText(intent.name)} profile`\n : intent.kind === \"history\"\n ? \"the reviewed history document\"\n : `the ${intent.preset.label} preset`;\n 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.`;\n}\n\nfunction successMessage(intent: ReviewIntent): string {\n switch (intent.kind) {\n case \"customize\":\n return \"Footer settings saved and applied\";\n case \"restore\":\n return \"Built-in footer restored and applied\";\n case \"import\":\n return \"Gist settings saved and applied\";\n case \"profile\":\n return `${safeText(intent.name)} profile applied`;\n case \"history\":\n return \"History document restored and applied\";\n case \"preset\":\n return `${intent.preset.label} preset saved and applied`;\n }\n}\n\nfunction modulePreviewDetails(preview: string): string[] {\n const lines = preview ? preview.split(\"\\n\") : [\"(no current preview)\"];\n return lines.map((line, index) => `${index === 0 ? \"Preview: \" : \" \"}${line}`);\n}\n\nfunction workflowOwner(options: StarshipCommandOptions): WorkflowOwner {\n if (options.getMenuOwner) return options.getMenuOwner();\n const controller = new AbortController();\n return { signal: controller.signal, isCurrent: () => true };\n}\n\nfunction isCurrentOwner(owner: WorkflowOwner): boolean {\n return !owner.signal.aborted && owner.isCurrent();\n}\n\nfunction isSessionOwnerCurrent(owner: WorkflowOwner): boolean {\n return !owner.signal.aborted && (owner.isSessionCurrent?.() ?? owner.isCurrent());\n}\n\nfunction clearSessionPreview(ctx: ExtensionCommandContext, options: StarshipCommandOptions, owner: WorkflowOwner) {\n if (owner.isSessionCurrent?.() ?? owner.isCurrent()) options.preview?.(undefined, ctx);\n}\n\nfunction captureExpectation(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n): CommitExpectation | undefined {\n try {\n return captureCommitExpectation(options);\n } catch (error) {\n ctx.ui.notify(`Footer settings were not saved: ${safeText(formatError(error))}`, \"error\");\n return undefined;\n }\n}\n\nfunction reviewPreviewBody(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n loaded: LoadedStarshipConfig,\n width: number,\n intent: ReviewIntent,\n): string[] {\n if (intent.kind === \"restore\") return restorePreviewBody(ctx, options, loaded, width);\n if (intent.kind !== \"preset\") return previewBody(ctx, options, loaded, width);\n const current = configurationPresentation(options.getLoaded());\n return [\n `Preset: ${intent.preset.label}`,\n `Requirement: ${intent.preset.requiresNerdFont ? \"Nerd Font\" : \"No special font\"}`,\n `Current: ${current.state}`,\n `Path: ${safeText(options.settingsPath)}`,\n \"Applying replaces the entire settings document, including custom settings, unknown fields, and comments.\",\n \"The previous document will be kept in History before replacement.\",\n \"\",\n ...previewBody(ctx, options, loaded, width),\n ];\n}\n\nfunction restorePreviewBody(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n loaded: LoadedStarshipConfig,\n width: number,\n): string[] {\n const current = configurationPresentation(options.getLoaded());\n return [\n `Current: ${current.state}`,\n `Path: ${safeText(options.settingsPath)}`,\n \"The entire settings document will be replaced, including custom settings, unknown fields, and comments.\",\n \"The previous document will be kept in History before replacement.\",\n \"\",\n ...previewBody(ctx, options, loaded, width),\n ];\n}\n\nfunction previewBody(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n loaded: LoadedStarshipConfig,\n width: number,\n): string[] {\n let lines: string[];\n try {\n lines = options.renderPreview?.(loaded, width, ctx) ?? [\n \"Live preview is unavailable until the footer is ready.\",\n \"The draft is valid and can still be applied.\",\n ];\n } catch (error) {\n lines = [`Preview unavailable: ${safeText(formatError(error))}`];\n }\n const warning =\n loaded.diagnostics.length === 0\n ? \"Draft validation: Healthy\"\n : `Draft validation: ${loaded.diagnostics.length} warning${loaded.diagnostics.length === 1 ? \"\" : \"s\"}`;\n return [...lines, \"\", warning];\n}\n\nfunction selectedPreviewAction<Value extends string>(result: PreviewMenuResult<Value> | undefined): Value | null {\n return result?.kind === \"selected\" ? result.value : null;\n}\n\nfunction showStatus(ctx: ExtensionCommandContext, options: StarshipCommandOptions) {\n if (!canNotify(ctx)) return;\n const loaded = options.getLoaded();\n const diagnostics = loaded.diagnostics\n .slice(0, 5)\n .map((item) => `${safeText(item.path || \"root\")}: ${safeText(item.message)}`)\n .join(\"; \");\n ctx.ui.notify(\n [\n `pi-starship source: ${loaded.source}`,\n `path: ${options.settingsPath}`,\n diagnostics ? `warnings: ${diagnostics}` : \"warnings: none\",\n ].join(\"\\n\"),\n loaded.diagnostics.length > 0 ? \"warning\" : \"info\",\n );\n}\n\nfunction showHelp(ctx: ExtensionCommandContext, settingsPath: string) {\n if (!canNotify(ctx)) return;\n ctx.ui.notify(\n [\n \"/starship \u2014 manage profiles, live-preview presets, recover history, explain, or inspect the footer in TUI mode\",\n \"/starship settings \u2014 customize, preview, and apply TOML\",\n \"/starship status \u2014 show source, path, and warnings\",\n \"/starship help \u2014 show this help\",\n `Settings: ${settingsPath}`,\n \"Format/module docs: https://github.com/narumiruna/pi-extensions/tree/main/packages/pi-starship\",\n ].join(\"\\n\"),\n \"info\",\n );\n}\n\nfunction canNotify(ctx: ExtensionCommandContext): boolean {\n return ctx.mode === \"tui\" || ctx.hasUI;\n}\n\nfunction safeText(value: string): string {\n return Array.from(value, (character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n const unsafe =\n codePoint <= 0x08 || (codePoint >= 0x0b && codePoint <= 0x1f) || (codePoint >= 0x7f && codePoint <= 0x9f);\n return unsafe ? `\\\\u${codePoint.toString(16).padStart(4, \"0\")}` : character;\n }).join(\"\");\n}\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n", "import { type ExtensionCommandContext, withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport type { ConfigurationCommandOptions, WorkflowOwner } from \"./command-configuration.js\";\nimport {\n assertConfigDocumentUnchanged,\n atomicRestoreConfigDocument,\n atomicSaveConfigDocument,\n type ConfigDocumentSnapshot,\n ConfigPublicationError,\n type LoadedStarshipConfig,\n readConfigDocumentSnapshot,\n removeConfigDocumentIfMatches,\n validateConfigDocument,\n} from \"./config.js\";\nimport { archiveConfigDocument } from \"./profile-store.js\";\n\nexport interface CommitOptions extends ConfigurationCommandOptions {\n save?: (settingsPath: string, rawDocument: string) => LoadedStarshipConfig;\n restore?: (settingsPath: string, rawDocument: string) => void;\n archive?: typeof archiveConfigDocument;\n}\n\nexport interface CommitExpectation {\n previous: LoadedStarshipConfig;\n revision: number | undefined;\n disk: ConfigDocumentSnapshot;\n}\n\nexport function captureCommitExpectation(options: ConfigurationCommandOptions): CommitExpectation {\n return {\n previous: options.getLoaded(),\n revision: options.getLoadedRevision?.(),\n disk: readConfigDocumentSnapshot(options.settingsPath),\n };\n}\n\nexport function commitOwnerCurrent(\n options: ConfigurationCommandOptions,\n owner: WorkflowOwner,\n expected: CommitExpectation,\n): boolean {\n const loaded = options.getLoaded();\n return (\n !owner.signal.aborted &&\n owner.isCurrent() &&\n loaded.rawDocument === expected.previous.rawDocument &&\n loaded.source === expected.previous.source &&\n JSON.stringify(loaded.diagnostics) === JSON.stringify(expected.previous.diagnostics) &&\n options.getLoadedRevision?.() === expected.revision\n );\n}\n\n/** The queue has asynchronous admission; the owned file/runtime transaction has no await boundary. */\nexport async function commitActiveDocument(\n ctx: ExtensionCommandContext,\n options: CommitOptions,\n candidate: LoadedStarshipConfig,\n owner: WorkflowOwner,\n expected: CommitExpectation,\n allowInvalid = false,\n checkCandidate?: () => void,\n): Promise<\"applied\" | \"cancel\"> {\n const raw = candidate.rawDocument;\n if (raw === undefined) throw new Error(\"The candidate settings document is unavailable\");\n return withFileMutationQueue(options.settingsPath, async () => {\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n checkCandidate?.();\n assertConfigDocumentUnchanged(options.settingsPath, expected.disk);\n const previousBytes = expected.disk.rawBytes;\n if (expected.previous.rawDocument !== previousBytes?.toString(\"utf8\")) {\n throw new Error(\n \"The active file differs from the loaded document. Reload and review it before replacing settings.\",\n );\n }\n const invalid = expected.previous.diagnostics.some((item) => item.severity === \"error\");\n if (invalid && !allowInvalid)\n throw new Error(\"The active settings document is invalid. Use explicit repair or recovery before replacing it.\");\n // Always validate again at the publication boundary, not only in the preview layer.\n validateConfigDocument(options.settingsPath, raw);\n if (previousBytes?.equals(Buffer.from(raw))) return \"applied\";\n\n let recoveryPath: string | undefined;\n if (previousBytes !== undefined) {\n recoveryPath = (options.archive ?? archiveConfigDocument)(options.settingsPath, previousBytes).path;\n }\n // A recovery publication can fail or observe an external edit. Never publish over that edit.\n try {\n assertConfigDocumentUnchanged(options.settingsPath, expected.disk);\n if (!commitOwnerCurrent(options, owner, expected)) return \"cancel\";\n checkCandidate?.();\n } catch (error) {\n throw new Error(`${message(error)}.${recoveryNote(recoveryPath)}`);\n }\n let saved: LoadedStarshipConfig;\n try {\n saved = options.save\n ? options.save(options.settingsPath, raw)\n : atomicSaveConfigDocument(options.settingsPath, raw, {}, expected.disk);\n } catch (error) {\n if (error instanceof ConfigPublicationError) {\n const rollback = restorePrevious(ctx, options, owner, expected, raw, error.fileIdentity, false);\n throw new Error(`Footer settings were not saved: ${message(error)}. ${rollback}${recoveryNote(recoveryPath)}`);\n }\n throw new Error(\n `Footer settings were not saved: ${message(error)}. The previous footer remains active.${recoveryNote(recoveryPath)}`,\n );\n }\n try {\n if (\n owner.signal.aborted ||\n !(owner.isSessionCurrent?.() ?? owner.isCurrent()) ||\n options.getLoadedRevision?.() !== expected.revision\n ) {\n throw new Error(\"The configuration owner changed during publication\");\n }\n options.apply(saved, ctx);\n } catch (error) {\n const rollback = restorePrevious(ctx, options, owner, expected, raw, saved.fileIdentity, true);\n throw new Error(\n `Footer settings could not be applied: ${message(error)}. ${rollback}${recoveryNote(recoveryPath)}`,\n );\n }\n return \"applied\";\n });\n}\n\nfunction restorePrevious(\n ctx: ExtensionCommandContext,\n options: CommitOptions,\n owner: WorkflowOwner,\n expected: CommitExpectation,\n raw: string,\n identity: LoadedStarshipConfig[\"fileIdentity\"],\n restoreRuntime: boolean,\n): string {\n try {\n if (owner.signal.aborted || !(owner.isSessionCurrent?.() ?? owner.isCurrent()))\n throw new Error(\"The session owner changed; stale restoration was blocked\");\n const current = options.getLoaded();\n if (current.rawDocument !== expected.previous.rawDocument && current.rawDocument !== raw) {\n throw new Error(\"The active runtime changed; stale restoration was blocked\");\n }\n if (!identity) throw new Error(\"The saved settings document identity is unavailable\");\n assertConfigDocumentUnchanged(options.settingsPath, { rawBytes: Buffer.from(raw), fileIdentity: identity });\n if (expected.disk.rawBytes === undefined) {\n removeConfigDocumentIfMatches(options.settingsPath, raw, identity);\n } else if (options.restore && expected.disk.rawBytes.equals(Buffer.from(expected.previous.rawDocument ?? \"\"))) {\n options.restore(options.settingsPath, expected.previous.rawDocument ?? \"\");\n } else {\n atomicRestoreConfigDocument(\n options.settingsPath,\n expected.disk.rawBytes,\n {},\n { rawBytes: Buffer.from(raw), fileIdentity: identity },\n );\n }\n if (restoreRuntime) options.apply(expected.previous, ctx);\n return \"The previous configuration was restored.\";\n } catch (error) {\n return `Restoring the previous configuration also failed: ${message(error)}. Active path: ${options.settingsPath}.`;\n }\n}\n\nfunction recoveryNote(path: string | undefined): string {\n return path ? ` Recovery copy retained: ${path}.` : \"\";\n}\n\nfunction message(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n", "import { randomUUID } from \"node:crypto\";\nimport {\n type BigIntStats,\n closeSync,\n constants,\n fstatSync,\n fsyncSync,\n lstatSync,\n mkdirSync,\n openSync,\n readdirSync,\n readFileSync,\n realpathSync,\n renameSync,\n rmdirSync,\n unlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { basename, dirname, join, parse, resolve, sep } from \"node:path\";\n\nexport interface DocumentIdentity {\n readonly dev: bigint;\n readonly ino: bigint;\n readonly size: bigint;\n readonly mtimeNs: bigint;\n readonly ctimeNs: bigint;\n}\n\nexport interface ProfileDocument {\n readonly kind: \"profile\";\n readonly name: string;\n readonly path: string;\n readonly rawDocument: string | undefined;\n readonly rawBytes: Buffer;\n readonly readError?: string;\n readonly identity: DocumentIdentity;\n}\n\nexport interface TextProfileDocument extends ProfileDocument {\n readonly rawDocument: string;\n}\n\nexport interface ArchiveReference {\n readonly name: string;\n readonly path: string;\n}\n\nexport interface HistoryDocument {\n readonly kind: \"history\";\n /** Filename, including .toml; not an arbitrary path. */\n readonly name: string;\n readonly path: string;\n /** Undefined when rawBytes are not valid UTF-8; never apply a decoded fallback. */\n readonly rawDocument: string | undefined;\n readonly rawBytes: Buffer;\n readonly readError?: string;\n readonly identity: DocumentIdentity;\n readonly legacy: boolean;\n /** ISO recovery time for new entries; local timestamp for legacy backups. */\n readonly createdAt: string;\n}\n\ntype Document = ProfileDocument | HistoryDocument;\nconst HISTORY_NAME =\n /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}\\.\\d{3}Z)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.toml$/u;\nconst LEGACY_NAME = /^pi-starship-(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})\\.toml$/u;\nconst RESERVED_NAME = /^(?:con|prn|aux|nul|com[1-9\u00B9\u00B2\u00B3]|lpt[1-9\u00B9\u00B2\u00B3]|conin\\$|conout\\$|clock\\$)(?:\\.|$)/iu;\n\n/** Normalize new names, but never trim, truncate, or replace forbidden characters. */\nexport function normalizeProfileName(value: string): string {\n const name = value.normalize(\"NFC\");\n if (\n [...name].length < 1 ||\n [...name].length > 80 ||\n name !== name.trim() ||\n name.startsWith(\".\") ||\n name.endsWith(\".\") ||\n /[\\p{Cc}\\p{Cf}\\p{Cs}<>:\"/\\\\|?*]/u.test(name) ||\n RESERVED_NAME.test(name) ||\n Buffer.byteLength(`${name}.toml`, \"utf8\") > 255\n ) {\n throw new Error(\"Invalid profile name: use 1\u201380 characters without controls, path characters, or reserved names\");\n }\n return name;\n}\n\n/** The caller supplies a trusted settings directory; its home/system symlink ancestors are valid. */\nfunction trustedDirectory(path: string): string {\n try {\n return realpathSync(path);\n } catch (error) {\n if (!isMissing(error)) throw error;\n const parent = dirname(path);\n if (parent === path) throw error;\n return join(trustedDirectory(parent), basename(path));\n }\n}\n\nfunction rootPath(settingsPath: string): string {\n return join(trustedDirectory(dirname(resolve(settingsPath))), \"pi-starship\");\n}\n\nfunction profileDirectory(settingsPath: string): string {\n return join(rootPath(settingsPath), \"profiles\");\n}\n\nfunction historyDirectory(settingsPath: string): string {\n return join(rootPath(settingsPath), \"history\");\n}\n\nfunction isMissing(error: unknown): boolean {\n return (error as NodeJS.ErrnoException).code === \"ENOENT\";\n}\n\nfunction statIfPresent(path: string): BigIntStats | undefined {\n try {\n return lstatSync(path, { bigint: true });\n } catch (error) {\n if (isMissing(error)) return undefined;\n throw error;\n }\n}\n\n/** Paths already have a canonical trusted parent; reject symlinks in every storage-owned component. */\nfunction checkedDirectory(path: string, create = false): boolean {\n const absolute = resolve(path);\n const root = parse(absolute).root;\n let current = root;\n for (const part of absolute.slice(root.length).split(sep).filter(Boolean)) {\n current = join(current, part);\n let stat = statIfPresent(current);\n let created = false;\n if (!stat && create) {\n try {\n mkdirSync(current, { mode: 0o700 });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n }\n stat = statIfPresent(current);\n created = true;\n }\n if (!stat) return false;\n if (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error(`Not a safe directory: ${current}`);\n // Persist each new ancestor's directory entry, including a previously absent agent directory.\n if (created) flushDirectory(dirname(current));\n }\n return true;\n}\n\nfunction identity(stat: BigIntStats): DocumentIdentity {\n return Object.freeze({ dev: stat.dev, ino: stat.ino, size: stat.size, mtimeNs: stat.mtimeNs, ctimeNs: stat.ctimeNs });\n}\n\nfunction sameIdentity(left: DocumentIdentity, right: DocumentIdentity): boolean {\n return (\n left.dev === right.dev &&\n left.ino === right.ino &&\n left.size === right.size &&\n left.mtimeNs === right.mtimeNs &&\n left.ctimeNs === right.ctimeNs\n );\n}\n\nfunction sameFile(left: DocumentIdentity, right: BigIntStats): boolean {\n return left.dev === right.dev && left.ino === right.ino;\n}\n\nfunction encodeDocument(rawDocument: string): Buffer {\n const bytes = Buffer.from(rawDocument, \"utf8\");\n if (bytes.toString(\"utf8\") !== rawDocument) throw new Error(\"Document is not lossless UTF-8 text\");\n return bytes;\n}\n\nfunction readBytes(path: string): { rawBytes: Buffer; identity: DocumentIdentity } {\n if (!checkedDirectory(dirname(path))) throw new Error(`Document directory is missing: ${dirname(path)}`);\n const before = statIfPresent(path);\n if (!before?.isFile() || before.isSymbolicLink()) throw new Error(`Not a regular document: ${path}`);\n const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);\n try {\n const opened = fstatSync(fd, { bigint: true });\n if (!opened.isFile() || !sameIdentity(identity(before), identity(opened))) {\n throw new Error(`Document changed while opening: ${path}`);\n }\n const bytes = readFileSync(fd);\n const after = fstatSync(fd, { bigint: true });\n const published = statIfPresent(path);\n if (\n !sameIdentity(identity(opened), identity(after)) ||\n !published ||\n !sameIdentity(identity(after), identity(published))\n ) {\n throw new Error(`Document changed while reading: ${path}`);\n }\n return { rawBytes: bytes, identity: identity(after) };\n } finally {\n closeSync(fd);\n }\n}\n\nexport function readProfile(settingsPath: string, name: string): ProfileDocument {\n const normalized = normalizeProfileName(name);\n const path = join(profileDirectory(settingsPath), `${normalized}.toml`);\n const document = readBytes(path);\n const decoded = document.rawBytes.toString(\"utf8\");\n const valid = Buffer.from(decoded, \"utf8\").equals(document.rawBytes);\n return Object.freeze({\n kind: \"profile\",\n name: normalized,\n path,\n ...document,\n rawDocument: valid ? decoded : undefined,\n ...(valid ? {} : { readError: \"Profile document is not valid UTF-8; raw bytes are preserved\" }),\n });\n}\n\nexport function listProfiles(settingsPath: string): ProfileDocument[] {\n const directory = profileDirectory(settingsPath);\n if (!checkedDirectory(directory)) return [];\n const profiles: ProfileDocument[] = [];\n for (const filename of readdirSync(directory).sort()) {\n if (!filename.endsWith(\".toml\")) continue;\n const name = filename.slice(0, -5);\n try {\n if (normalizeProfileName(name) !== name) continue;\n } catch {\n continue;\n }\n const stat = statIfPresent(join(directory, filename));\n if (!stat?.isFile() || stat.isSymbolicLink()) continue;\n profiles.push(readProfile(settingsPath, name));\n }\n return profiles;\n}\n\n/**\n * Sync mutations cannot interleave in one JS thread. This directory lock also coordinates\n * cooperating store callers in other processes. Contention fails instead of blocking the event\n * loop. A crashed owner's lock requires explicit manual recovery; never guess that a lock is stale.\n * Node has no portable rename-no-replace operation. Collision checks + rename under this lock\n * prevent cooperative clobbering, NOT races with external editors or directory replacement.\n * There is no portable openat/renameat API here; external directory TOCTOU remains as well.\n */\nfunction mutate<T>(settingsPath: string, operation: () => T): T {\n const root = rootPath(settingsPath);\n checkedDirectory(root, true);\n const lock = join(root, \".mutation-lock\");\n try {\n mkdirSync(lock, { mode: 0o700 });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"EEXIST\") {\n throw new Error(`Profile/history storage is locked; inspect the owner before manually removing ${lock}`);\n }\n throw error;\n }\n const owned = lstatSync(lock, { bigint: true });\n let result!: T;\n let operationError: unknown;\n let failed = false;\n try {\n result = operation();\n } catch (error) {\n failed = true;\n operationError = error;\n }\n try {\n const current = statIfPresent(lock);\n if (current?.isDirectory() && sameFile(identity(owned), current)) rmdirSync(lock);\n } catch (error) {\n if (failed) throw new AggregateError([operationError, error], `Mutation and lock cleanup failed at ${lock}`);\n throw new Error(`Mutation completed but lock cleanup failed at ${lock}`, { cause: error });\n }\n if (failed) throw operationError;\n return result;\n}\n\n/** Conservative Unicode caseless key, including expansions such as \u00DF -> ss and final sigma. */\nfunction collisionKey(name: string): string {\n // A second pass includes uppercase sharp S (\u1E9E -> \u00DF -> ss).\n return name.normalize(\"NFC\").toUpperCase().toLowerCase().toUpperCase().toLowerCase().normalize(\"NFC\");\n}\n\nfunction assertAvailable(directory: string, filename: string): void {\n const key = collisionKey(filename);\n if (readdirSync(directory).some((entry) => collisionKey(entry) === key)) {\n throw new Error(`Document name already exists: ${filename}`);\n }\n}\n\nfunction assertExpected<T extends Document>(current: T, expected: T): void {\n if (\n current.kind !== expected.kind ||\n current.path !== expected.path ||\n current.name !== expected.name ||\n current.rawDocument !== expected.rawDocument ||\n !current.rawBytes.equals(expected.rawBytes) ||\n !sameIdentity(current.identity, expected.identity)\n ) {\n throw new Error(`Document changed since review: ${current.path}`);\n }\n}\n\nfunction flushDirectory(path: string): void {\n // Windows does not support opening/fsyncing directories through this API.\n // File flushing still applies; directory-entry crash durability is POSIX-only.\n if (process.platform === \"win32\") return;\n checkedDirectory(path);\n const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_DIRECTORY);\n try {\n fsyncSync(fd);\n } finally {\n closeSync(fd);\n }\n}\n\nfunction flushMutation(directory: string, path: string): void {\n try {\n flushDirectory(directory);\n } catch (error) {\n throw new Error(`Mutation completed at ${path}, but directory flush failed: ${String(error)}`, { cause: error });\n }\n}\n\n/** Published files are never removed on a subsequent flush/read failure. */\nfunction publish(directory: string, filename: string, bytes: Buffer, beforeRename: () => void): void {\n const temporary = join(directory, `.tmp-${randomUUID()}`);\n const fd = openSync(\n temporary,\n constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW,\n 0o600,\n );\n const owned = fstatSync(fd, { bigint: true });\n let open = true;\n try {\n writeFileSync(fd, bytes);\n fsyncSync(fd);\n closeSync(fd);\n open = false;\n checkedDirectory(directory);\n beforeRename();\n const destination = join(directory, filename);\n renameSync(temporary, destination);\n flushMutation(directory, destination);\n } finally {\n try {\n if (open) closeSync(fd);\n } finally {\n const current = statIfPresent(temporary);\n if (current && sameFile(identity(owned), current)) unlinkSync(temporary);\n }\n }\n}\n\nfunction readTextProfile(settingsPath: string, name: string): TextProfileDocument {\n const document = readProfile(settingsPath, name);\n if (document.rawDocument === undefined) throw new Error(document.readError);\n return { ...document, rawDocument: document.rawDocument };\n}\n\nexport function createProfile(settingsPath: string, name: string, rawDocument: string): TextProfileDocument {\n const normalized = normalizeProfileName(name);\n const bytes = encodeDocument(rawDocument);\n return mutate(settingsPath, () => {\n const directory = profileDirectory(settingsPath);\n checkedDirectory(directory, true);\n const filename = `${normalized}.toml`;\n assertAvailable(directory, filename);\n publish(directory, filename, bytes, () => assertAvailable(directory, filename));\n return readTextProfile(settingsPath, normalized);\n });\n}\n\nexport function duplicateProfile(\n settingsPath: string,\n name: string,\n newName: string,\n expected: ProfileDocument,\n): ProfileDocument {\n const normalized = normalizeProfileName(newName);\n return mutate(settingsPath, () => {\n const current = readProfile(settingsPath, name);\n assertExpected(current, expected);\n const directory = profileDirectory(settingsPath);\n const filename = `${normalized}.toml`;\n assertAvailable(directory, filename);\n publish(directory, filename, current.rawBytes, () => {\n assertExpected(readProfile(settingsPath, name), expected);\n assertAvailable(directory, filename);\n });\n return readProfile(settingsPath, normalized);\n });\n}\n\nexport function saveProfile(\n settingsPath: string,\n name: string,\n rawDocument: string,\n expected: ProfileDocument,\n): TextProfileDocument {\n const normalized = normalizeProfileName(name);\n const bytes = encodeDocument(rawDocument);\n return mutate(settingsPath, () => {\n const current = readProfile(settingsPath, normalized);\n assertExpected(current, expected);\n if (current.rawDocument === rawDocument) return { ...current, rawDocument };\n publish(profileDirectory(settingsPath), `${normalized}.toml`, bytes, () => {\n assertExpected(readProfile(settingsPath, normalized), expected);\n });\n return readTextProfile(settingsPath, normalized);\n });\n}\n\nexport function renameProfile(\n settingsPath: string,\n name: string,\n newName: string,\n expected: ProfileDocument,\n): ProfileDocument {\n const normalized = normalizeProfileName(newName);\n return mutate(settingsPath, () => {\n const current = readProfile(settingsPath, name);\n assertExpected(current, expected);\n if (current.name === normalized) return current;\n // Explicitly reject case-only renames rather than depending on filesystem case behavior.\n if (collisionKey(current.name) === collisionKey(normalized))\n throw new Error(\"Case-only profile rename is not supported\");\n const directory = profileDirectory(settingsPath);\n assertAvailable(directory, `${normalized}.toml`);\n assertExpected(readProfile(settingsPath, name), expected);\n const destination = join(directory, `${normalized}.toml`);\n renameSync(current.path, destination);\n flushMutation(directory, destination);\n return readProfile(settingsPath, normalized);\n });\n}\n\nexport function deleteProfile(settingsPath: string, name: string, expected: ProfileDocument): void {\n mutate(settingsPath, () => {\n const current = readProfile(settingsPath, name);\n assertExpected(current, expected);\n unlinkSync(current.path);\n flushMutation(dirname(current.path), current.path);\n });\n}\n\nfunction assertTimestamp(value: string): void {\n const time = Date.parse(value);\n if (!Number.isFinite(time) || new Date(time).toISOString() !== value) throw new Error(\"Invalid history timestamp\");\n}\n\nfunction historyLocation(settingsPath: string, name: string): { path: string; legacy: boolean; createdAt: string } {\n const modern = HISTORY_NAME.exec(name);\n if (modern) {\n const createdAt = modern[1].replace(/T(\\d{2})-(\\d{2})-(\\d{2})/u, \"T$1:$2:$3\");\n assertTimestamp(createdAt);\n return { path: join(historyDirectory(settingsPath), name), legacy: false, createdAt };\n }\n const legacy = LEGACY_NAME.exec(name);\n if (legacy) {\n const createdAt = `${legacy[1]}-${legacy[2]}-${legacy[3]}T${legacy[4]}:${legacy[5]}`;\n assertTimestamp(`${createdAt}:00.000Z`);\n return { path: join(rootPath(settingsPath), name), legacy: true, createdAt };\n }\n throw new Error(\"Invalid history filename\");\n}\n\nexport function readHistory(settingsPath: string, name: string): HistoryDocument {\n const location = historyLocation(settingsPath, name);\n const document = readBytes(location.path);\n const decoded = document.rawBytes.toString(\"utf8\");\n const valid = Buffer.from(decoded, \"utf8\").equals(document.rawBytes);\n return Object.freeze({\n kind: \"history\",\n name,\n ...location,\n ...document,\n rawDocument: valid ? decoded : undefined,\n ...(valid ? {} : { readError: \"Recovery document is not valid UTF-8; raw bytes are preserved\" }),\n });\n}\n\nexport function listHistory(settingsPath: string): HistoryDocument[] {\n const history: HistoryDocument[] = [];\n for (const [directory, pattern] of [\n [historyDirectory(settingsPath), HISTORY_NAME],\n [rootPath(settingsPath), LEGACY_NAME],\n ] as const) {\n if (!checkedDirectory(directory)) continue;\n for (const name of readdirSync(directory).sort()) {\n if (!pattern.test(name)) continue;\n try {\n historyLocation(settingsPath, name);\n } catch (error) {\n if (error instanceof Error && error.message === \"Invalid history timestamp\") continue;\n throw error;\n }\n const stat = statIfPresent(join(directory, name));\n if (!stat?.isFile() || stat.isSymbolicLink()) continue;\n history.push(readHistory(settingsPath, name));\n }\n }\n return history.sort(\n (left, right) => Date.parse(right.createdAt) - Date.parse(left.createdAt) || left.name.localeCompare(right.name),\n );\n}\n\n/** Return only after file AND directory fsync. Keep recovery bytes even if a later operation fails. */\nexport function archiveConfigDocument(settingsPath: string, rawDocument: string | Buffer): ArchiveReference {\n const bytes = typeof rawDocument === \"string\" ? encodeDocument(rawDocument) : Buffer.from(rawDocument);\n return mutate(settingsPath, () => {\n const directory = historyDirectory(settingsPath);\n checkedDirectory(directory, true);\n const name = `${new Date().toISOString().replace(/:/gu, \"-\")}-${randomUUID()}.toml`;\n publish(directory, name, bytes, () => assertAvailable(directory, name));\n return Object.freeze({ name, path: join(directory, name) });\n });\n}\n\nexport function deleteHistory(settingsPath: string, name: string, expected: HistoryDocument): void {\n if (historyLocation(settingsPath, name).legacy) throw new Error(\"Legacy recovery files are read-only\");\n mutate(settingsPath, () => {\n const current = readHistory(settingsPath, name);\n assertExpected(current, expected);\n unlinkSync(current.path);\n flushMutation(dirname(current.path), current.path);\n });\n}\n", "import { type ExtensionCommandContext, withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport { sanitizeTerminalText } from \"@narumitw/pi-tui-kit/terminal-text\";\nimport { type PreviewMenuResult, showPreviewActionMenu } from \"./command-preview.js\";\nimport {\n assertConfigDocumentUnchanged,\n BUILT_IN_EXAMPLE,\n type ConfigDocumentSnapshot,\n type LoadedStarshipConfig,\n loadStarshipConfig,\n readConfigDocumentSnapshot,\n} from \"./config.js\";\nimport { serializeEffectiveConfig } from \"./effective-config.js\";\nimport { presetForDocument } from \"./presets/catalog.js\";\nimport { archiveConfigDocument } from \"./profile-store.js\";\n\nconst RELOAD_ACTIONS = {\n apply: \"apply\",\n cancel: \"cancel\",\n} as const;\n\nexport interface WorkflowOwner {\n signal: AbortSignal;\n isCurrent(): boolean;\n /** Session ownership independent of command cancellation and candidate/revision guards. */\n isSessionCurrent?(): boolean;\n}\n\nexport interface ConfigurationCommandOptions {\n getLoaded(): LoadedStarshipConfig;\n getLoadedRevision?(): number;\n apply(loaded: LoadedStarshipConfig, ctx: ExtensionCommandContext): void;\n settingsPath: string;\n renderPreview?(loaded: LoadedStarshipConfig, width: number, ctx: ExtensionCommandContext): string[];\n read?: (settingsPath: string) => LoadedStarshipConfig;\n archive?: typeof archiveConfigDocument;\n}\n\nexport interface ConfigurationPresentation {\n state: string;\n source: string;\n health: string;\n restoreDisabled: boolean;\n restoreDescription: string;\n}\n\nexport function configurationPresentation(loaded: LoadedStarshipConfig): ConfigurationPresentation {\n const healthyMissing = isHealthyMissing(loaded);\n const savedBuiltIn = loaded.source === \"user\" && loaded.rawDocument === BUILT_IN_EXAMPLE;\n const activePreset = presetForDocument(loaded.rawDocument);\n const fallback = loaded.source === \"built-in\" && loaded.diagnostics.length > 0;\n return {\n state: healthyMissing\n ? \"Built-in defaults\"\n : savedBuiltIn\n ? \"Saved built-in configuration\"\n : activePreset\n ? `${activePreset.label} preset`\n : fallback\n ? \"Built-in fallback\"\n : \"Custom configuration\",\n source: healthyMissing\n ? \"No settings file\"\n : activePreset\n ? \"Bundled preset\"\n : loaded.source === \"user\"\n ? \"User file\"\n : \"Built-in fallback\",\n health: configurationHealth(loaded),\n restoreDisabled: healthyMissing || savedBuiltIn,\n restoreDescription: healthyMissing\n ? \"Already using defaults \u00B7 no file to replace\"\n : savedBuiltIn\n ? \"Built-in configuration already saved\"\n : fallback\n ? \"Preview before replacing invalid settings\"\n : \"Preview before replacing the document\",\n };\n}\n\nexport function configurationMenuScreen(loaded: LoadedStarshipConfig) {\n const presentation = configurationPresentation(loaded);\n return {\n kind: \"actions\" as const,\n title: \"Configuration\",\n lines: [`${presentation.state} \u00B7 ${presentation.health}`],\n items: [\n {\n id: \"configuration-overview\",\n label: \"Overview\",\n description: \"State, source, path, health, and warnings\",\n to: \"configuration-overview\" as const,\n },\n {\n id: \"configuration-effective\",\n label: \"Effective configuration\",\n description: \"Normalized public TOML currently in use\",\n to: \"configuration-effective\" as const,\n },\n {\n id: \"configuration-document\",\n label: \"Settings document\",\n description: isHealthyMissing(loaded)\n ? \"No settings file \u00B7 built-in defaults are active\"\n : \"Exact loaded UTF-8 text \u00B7 read-only\",\n to: \"configuration-document\" as const,\n },\n {\n id: \"configuration-reload\",\n label: \"Reload from disk\u2026\",\n description: \"Validate and preview external changes\",\n action: \"configuration-reload\" as const,\n },\n {\n id: \"gist-share\",\n label: \"Share settings as Gist\u2026\",\n description: \"Upload reviewed TOML to GitHub \u00B7 unlisted, not private \u00B7 requires gh\",\n action: \"gist-share\" as const,\n },\n {\n id: \"gist-import\",\n label: \"Import settings from Gist\u2026\",\n description: \"Review and preview remote TOML before replacing settings \u00B7 requires gh\",\n action: \"gist-import\" as const,\n },\n {\n id: \"history\",\n label: \"History\",\n description: \"Review and restore recovery copies; legacy skill backups are read-only\",\n action: \"history\" as const,\n },\n ],\n hint: \"back\" as const,\n };\n}\n\nexport function configurationOverviewScreen(loaded: LoadedStarshipConfig, settingsPath: string) {\n const presentation = configurationPresentation(loaded);\n return {\n kind: \"detail\" as const,\n title: \"Configuration overview\",\n lines: [\n `State: ${presentation.state}`,\n `Source: ${presentation.source}`,\n `Path: ${sanitizeTerminalText(settingsPath)}`,\n ...diagnosticLines(loaded, true),\n ],\n hint: \"back\" as const,\n };\n}\n\nexport function effectiveConfigurationScreen(loaded: LoadedStarshipConfig) {\n const presentation = configurationPresentation(loaded);\n return {\n kind: \"review\" as const,\n title: \"Effective configuration\",\n lines: [\n `${presentation.state} \u00B7 ${presentation.health}`,\n \"Normalized public TOML; comments and unknown fields are intentionally excluded.\",\n ],\n content: serializeEffectiveConfig(loaded.config),\n enableSearch: true,\n format: { kind: \"code\" as const, language: \"toml\" },\n viewportSize: \"adaptive\" as const,\n hint: \"back\" as const,\n };\n}\n\nexport function settingsDocumentScreen(loaded: LoadedStarshipConfig, settingsPath: string) {\n const path = sanitizeTerminalText(settingsPath);\n if (loaded.rawDocument !== undefined) {\n return {\n kind: \"review\" as const,\n title: \"Settings document\",\n lines: [\"Exact loaded UTF-8 text \u00B7 display controls sanitized \u00B7 read-only\", `Path: ${path}`],\n content: loaded.rawDocument,\n enableSearch: true,\n format: { kind: \"code\" as const, language: \"toml\" },\n viewportSize: \"adaptive\" as const,\n hint: \"back\" as const,\n };\n }\n return {\n kind: \"detail\" as const,\n title: \"Settings document\",\n lines: [\n ...(isHealthyMissing(loaded)\n ? [\"No settings document exists.\", \"Built-in defaults are active; this read created no file.\"]\n : [\"The settings document could not be loaded.\", ...diagnosticLines(loaded, false)]),\n `Path: ${path}`,\n ],\n hint: \"back\" as const,\n };\n}\n\nexport async function reloadConfiguration(\n ctx: ExtensionCommandContext,\n options: ConfigurationCommandOptions,\n owner: WorkflowOwner,\n): Promise<\"applied\" | \"stay\" | \"close\"> {\n if (!isCurrentOwner(owner)) return \"stay\";\n const previous = options.getLoaded();\n const revision = options.getLoadedRevision?.();\n const candidate = readReloadCandidate(options);\n let disk: ConfigDocumentSnapshot;\n try {\n disk = readConfigDocumentSnapshot(options.settingsPath);\n } catch (error) {\n ctx.ui.notify(`Footer reload was blocked: ${safeError(error)}`, \"error\");\n return \"stay\";\n }\n if (!candidate.ok) {\n ctx.ui.notify(`Footer reload was blocked: ${safeError(candidate.error)}`, \"error\");\n return \"stay\";\n }\n if (sameLoadedDocument(previous, candidate.loaded)) {\n ctx.ui.notify(\"The current disk configuration is already loaded.\", \"info\");\n return \"stay\";\n }\n\n const selection = await showPreviewActionMenu(\n ctx,\n \"Reload preview\",\n (width) => reloadPreviewBody(ctx, options, candidate.loaded, width),\n [\n { value: RELOAD_ACTIONS.apply, label: \"Apply reloaded configuration\u2026\" },\n { value: RELOAD_ACTIONS.cancel, label: \"Cancel\" },\n ],\n owner.signal,\n owner.isCurrent,\n );\n if (!isCurrentOwner(owner) || activeRevisionChanged(options, revision)) return \"stay\";\n if (selection?.kind === \"closed\") return \"close\";\n if (selectedReloadAction(selection) !== RELOAD_ACTIONS.apply) return \"stay\";\n\n const confirmed = await ctx.ui.confirm(\n \"Apply configuration from disk?\",\n candidate.loaded.rawDocument === undefined\n ? \"Use built-in defaults for this session? No settings file will be created.\"\n : \"Apply the validated settings document to this session without changing its bytes? The previous loaded document will be kept in History.\",\n { signal: owner.signal },\n );\n if (!isCurrentOwner(owner) || activeRevisionChanged(options, revision) || !confirmed) {\n return \"stay\";\n }\n\n let warnings = 0;\n try {\n const applied = await withFileMutationQueue(options.settingsPath, async () => {\n if (\n !isCurrentOwner(owner) ||\n activeRevisionChanged(options, revision) ||\n !sameLoadedDocument(previous, options.getLoaded())\n )\n return false;\n assertConfigDocumentUnchanged(options.settingsPath, disk);\n const fresh = readReloadCandidate(options);\n if (!fresh.ok) throw new Error(fresh.error);\n if (!sameLoadedDocument(candidate.loaded, fresh.loaded)) {\n throw new Error(\n \"The settings document changed after preview. The previous footer remains active; reload again to review the latest version.\",\n );\n }\n let recoveryPath: string | undefined;\n const previousBytes = previous.rawBytes ?? previous.rawDocument;\n if (previousBytes !== undefined) {\n recoveryPath = (options.archive ?? archiveConfigDocument)(options.settingsPath, previousBytes).path;\n }\n assertConfigDocumentUnchanged(options.settingsPath, disk);\n if (!isCurrentOwner(owner) || activeRevisionChanged(options, revision)) return false;\n try {\n options.apply(fresh.loaded, ctx);\n } catch (error) {\n let rollbackError: unknown;\n try {\n if (!isCurrentOwner(owner)) throw new Error(\"The session owner changed; stale restoration was blocked\");\n const current = options.getLoaded();\n if (!sameLoadedDocument(current, previous) && !sameLoadedDocument(current, fresh.loaded))\n throw new Error(\"The active runtime changed; stale restoration was blocked\");\n options.apply(previous, ctx);\n } catch (rollback) {\n rollbackError = rollback;\n }\n throw new Error(\n `Footer reload failed: ${formatError(error)}. ${\n rollbackError\n ? `Restoring the previous configuration also failed: ${formatError(rollbackError)}.`\n : \"The previous configuration was restored.\"\n }${recoveryPath ? ` Recovery copy retained: ${recoveryPath}.` : \"\"}`,\n );\n }\n warnings = fresh.loaded.diagnostics.length;\n return true;\n });\n if (!isCurrentOwner(owner) || !applied) return \"stay\";\n } catch (error) {\n if (isCurrentOwner(owner))\n ctx.ui.notify(`Footer reload was blocked after confirmation: ${safeError(error)}`, \"error\");\n return \"stay\";\n }\n ctx.ui.notify(\n warnings === 0\n ? \"Footer configuration reloaded and applied.\"\n : `Footer configuration reloaded and applied with ${warnings} warning${warnings === 1 ? \"\" : \"s\"}.`,\n \"info\",\n );\n return \"applied\";\n}\n\nfunction readReloadCandidate(\n options: ConfigurationCommandOptions,\n): { ok: true; loaded: LoadedStarshipConfig } | { ok: false; error: string } {\n let loaded: LoadedStarshipConfig;\n try {\n loaded = (options.read ?? loadStarshipConfig)(options.settingsPath);\n } catch (error) {\n return { ok: false, error: formatError(error) };\n }\n const errors = loaded.diagnostics.filter((item) => item.severity === \"error\");\n if (errors.length > 0) {\n return { ok: false, error: errors.map((item) => item.message).join(\"; \") };\n }\n return { ok: true, loaded };\n}\n\nfunction reloadPreviewBody(\n ctx: ExtensionCommandContext,\n options: ConfigurationCommandOptions,\n loaded: LoadedStarshipConfig,\n width: number,\n): string[] {\n const presentation = configurationPresentation(loaded);\n let preview: string[];\n try {\n preview = options.renderPreview?.(loaded, width, ctx) ?? [\"Live preview is unavailable until the footer is ready.\"];\n } catch (error) {\n preview = [`Preview unavailable: ${safeError(formatError(error))}`];\n }\n return [\n `Candidate: ${presentation.state}`,\n `Source: ${presentation.source}`,\n `Path: ${sanitizeTerminalText(options.settingsPath)}`,\n loaded.rawDocument === undefined\n ? \"Applying uses built-in defaults and creates no settings file.\"\n : \"Applying changes only the active session; the settings document bytes stay unchanged.\",\n ...diagnosticLines(loaded, true),\n \"\",\n ...preview,\n ];\n}\n\nexport function diagnosticLines(loaded: LoadedStarshipConfig, includeSummary: boolean): string[] {\n const diagnostics = loaded.diagnostics\n .slice(0, 8)\n .map((item) => `${sanitizeTerminalText(item.path || \"root\")}: ${sanitizeTerminalText(item.message)}`);\n const remaining = loaded.diagnostics.length - diagnostics.length;\n return [\n ...(includeSummary ? [`Health: ${configurationHealth(loaded)}`] : []),\n ...(diagnostics.length > 0 ? diagnostics : [\"No configuration warnings.\"]),\n ...(remaining > 0 ? [`${remaining} additional warnings not shown.`] : []),\n ];\n}\n\nfunction configurationHealth(loaded: LoadedStarshipConfig): string {\n const errors = loaded.diagnostics.filter((item) => item.severity === \"error\").length;\n if (errors > 0) return `${errors} error${errors === 1 ? \"\" : \"s\"}`;\n const warnings = loaded.diagnostics.length;\n return warnings === 0 ? \"Healthy\" : `${warnings} warning${warnings === 1 ? \"\" : \"s\"}`;\n}\n\nfunction isHealthyMissing(loaded: LoadedStarshipConfig): boolean {\n return loaded.source === \"built-in\" && loaded.rawDocument === undefined && loaded.diagnostics.length === 0;\n}\n\nfunction sameLoadedDocument(left: LoadedStarshipConfig, right: LoadedStarshipConfig): boolean {\n return (\n left.source === right.source &&\n left.rawDocument === right.rawDocument &&\n JSON.stringify(left.diagnostics) === JSON.stringify(right.diagnostics)\n );\n}\n\nfunction activeRevisionChanged(options: ConfigurationCommandOptions, revision: number | undefined): boolean {\n return revision !== undefined && options.getLoadedRevision?.() !== revision;\n}\n\nfunction isCurrentOwner(owner: WorkflowOwner): boolean {\n return !owner.signal.aborted && owner.isCurrent();\n}\n\nfunction selectedReloadAction(\n result: PreviewMenuResult<(typeof RELOAD_ACTIONS)[keyof typeof RELOAD_ACTIONS]> | undefined,\n) {\n return result?.kind === \"selected\" ? result.value : null;\n}\n\nfunction safeError(value: unknown): string {\n return sanitizeTerminalText(typeof value === \"string\" ? value : formatError(value));\n}\n\nfunction formatError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n", "import { stripVTControlCharacters } from \"node:util\";\nimport type { ExtensionCommandContext, KeybindingsManager } from \"@earendil-works/pi-coding-agent\";\nimport { Key, matchesKey, truncateToWidth, wrapTextWithAnsi } from \"@earendil-works/pi-tui\";\nimport { runCustomInteraction } from \"@narumitw/pi-tui-kit\";\n\nconst RESERVED_HOST_ROWS = 3;\n\nexport interface PreviewMenuItem<Value extends string> {\n value: Value;\n label: string;\n}\n\nexport type PreviewMenuResult<Value extends string> =\n | { kind: \"selected\"; value: Value }\n | { kind: \"cancelled\" }\n | { kind: \"closed\" };\n\nexport async function showPreviewActionMenu<Value extends string>(\n ctx: ExtensionCommandContext,\n title: string,\n body: (width: number) => readonly string[],\n items: readonly PreviewMenuItem<Value>[],\n signal?: AbortSignal,\n isCurrent: () => boolean = () => !signal?.aborted,\n): Promise<PreviewMenuResult<Value> | undefined> {\n if (signal?.aborted || !isCurrent()) return { kind: \"closed\" };\n const result = await runCustomInteraction<PreviewMenuResult<Value>>(ctx, {\n signal,\n isCurrent,\n create: ({ tui, theme, keybindings, complete }) => {\n let selectedIndex = 0;\n let scrollOffset = 0;\n let lastMaximumScroll = 0;\n let lastViewportSize = 1;\n let disposed = false;\n\n const requestRender = () => {\n if (!disposed) tui.requestRender();\n };\n const moveSelection = (delta: number) => {\n if (items.length === 0) return;\n selectedIndex = (selectedIndex + delta + items.length) % items.length;\n requestRender();\n };\n const movePreview = (offset: number) => {\n scrollOffset = Math.max(0, Math.min(offset, lastMaximumScroll));\n requestRender();\n };\n\n return {\n render(width: number): string[] {\n const safeWidth = Math.max(1, width);\n const terminalRows = Number.isFinite(tui.terminal.rows) ? Math.floor(tui.terminal.rows) : 24;\n const availableRows = Math.max(1, terminalRows - RESERVED_HOST_ROWS);\n const bodyLines = body(safeWidth).flatMap((line) => (line ? wrapTextWithAnsi(line, safeWidth) : [\"\"]));\n const layout = allocateLayout(availableRows, items.length, bodyLines.length);\n lastViewportSize = layout.previewRows;\n lastMaximumScroll = Math.max(0, bodyLines.length - layout.previewRows);\n scrollOffset = Math.max(0, Math.min(scrollOffset, lastMaximumScroll));\n const actionStart = actionWindowStart(selectedIndex, items.length, layout.actionRows);\n const actionLines = items.slice(actionStart, actionStart + layout.actionRows).map((item, index) => {\n const absoluteIndex = actionStart + index;\n const prefix = absoluteIndex === selectedIndex ? \"\u2192 \" : \" \";\n return theme.fg(\n absoluteIndex === selectedIndex ? \"accent\" : \"text\",\n `${prefix}${safeDisplayText(item.label)}`,\n );\n });\n const position = layout.positionRows\n ? [theme.fg(\"dim\", previewPosition(scrollOffset, layout.previewRows, bodyLines.length))]\n : [];\n const lines = [\n ...(layout.titleRows ? [theme.fg(\"accent\", theme.bold(safeDisplayText(title)))] : []),\n ...bodyLines.slice(scrollOffset, scrollOffset + layout.previewRows),\n ...position,\n ...actionLines,\n ...(layout.hintRows ? [theme.fg(\"dim\", previewHint(keybindings))] : []),\n ];\n return lines.map((line) => truncateToWidth(line, safeWidth, \"\"));\n },\n invalidate() {},\n handleInput(data: string) {\n if (disposed) return;\n if (matchesKey(data, Key.ctrl(\"c\"))) {\n complete({ kind: \"closed\" });\n } else if (keybindings.matches(data, \"tui.select.cancel\")) {\n complete({ kind: \"cancelled\" });\n } else if (keybindings.matches(data, \"tui.select.up\")) {\n moveSelection(-1);\n } else if (keybindings.matches(data, \"tui.select.down\")) {\n moveSelection(1);\n } else if (keybindings.matches(data, \"tui.select.pageUp\")) {\n movePreview(scrollOffset - lastViewportSize);\n } else if (keybindings.matches(data, \"tui.select.pageDown\")) {\n movePreview(scrollOffset + lastViewportSize);\n } else if (matchesKey(data, Key.home)) {\n movePreview(0);\n } else if (matchesKey(data, Key.end)) {\n movePreview(lastMaximumScroll);\n } else if (keybindings.matches(data, \"tui.select.confirm\")) {\n const item = items[selectedIndex];\n if (item) complete({ kind: \"selected\", value: item.value });\n }\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n },\n };\n },\n });\n if (result.kind === \"completed\") return result.value;\n if (result.kind === \"error\") throw result.error;\n if (result.kind === \"stale\" && (signal?.aborted || !isCurrent())) return { kind: \"closed\" };\n return undefined;\n}\n\ninterface PreviewLayout {\n titleRows: number;\n previewRows: number;\n positionRows: number;\n actionRows: number;\n hintRows: number;\n}\n\nfunction allocateLayout(availableRows: number, actionCount: number, bodyLineCount: number): PreviewLayout {\n if (availableRows === 1) {\n return { titleRows: 0, previewRows: 0, positionRows: 0, actionRows: 1, hintRows: 0 };\n }\n const titleRows = availableRows >= 3 ? 1 : 0;\n const hintRows = availableRows >= 3 ? 1 : 0;\n const minimumPreviewRows = bodyLineCount > 0 && availableRows >= 4 ? 1 : 0;\n const availableActionRows = Math.max(1, availableRows - titleRows - hintRows - minimumPreviewRows);\n const actionRows = Math.min(Math.max(1, actionCount), availableActionRows);\n let previewRows = Math.max(0, availableRows - titleRows - hintRows - actionRows);\n const positionRows = previewRows >= 2 && bodyLineCount > previewRows ? 1 : 0;\n previewRows -= positionRows;\n return { titleRows, previewRows, positionRows, actionRows, hintRows };\n}\n\nfunction actionWindowStart(selectedIndex: number, itemCount: number, viewportSize: number): number {\n if (itemCount <= viewportSize) return 0;\n return Math.max(0, Math.min(selectedIndex, itemCount - viewportSize));\n}\n\nfunction previewPosition(offset: number, viewportSize: number, lineCount: number): string {\n if (lineCount === 0) return \"0/0\";\n return `${offset + 1}-${Math.min(lineCount, offset + viewportSize)}/${lineCount}`;\n}\n\nfunction previewHint(keybindings: Pick<KeybindingsManager, \"getKeys\">): string {\n const up = bindingText(keybindings, \"tui.select.up\");\n const down = bindingText(keybindings, \"tui.select.down\");\n const confirm = bindingText(keybindings, \"tui.select.confirm\");\n const cancel = bindingText(keybindings, \"tui.select.cancel\", \"ctrl+c\");\n const pageUp = bindingText(keybindings, \"tui.select.pageUp\");\n const pageDown = bindingText(keybindings, \"tui.select.pageDown\");\n return [\n ...(up || down ? [`${[up, down].filter(Boolean).join(\"/\")} navigate`] : []),\n ...(confirm ? [`${confirm} select`] : []),\n ...(cancel ? [`${cancel} discard`] : []),\n \"ctrl+c close\",\n ...(pageUp || pageDown ? [`${[pageUp, pageDown].filter(Boolean).join(\"/\")} preview`] : []),\n ].join(\" \u2022 \");\n}\n\nfunction bindingText(\n keybindings: Pick<KeybindingsManager, \"getKeys\">,\n binding: Parameters<KeybindingsManager[\"getKeys\"]>[0],\n excluded?: string,\n): string {\n return keybindings\n .getKeys(binding)\n .filter((key) => key !== excluded)\n .map((key) => {\n if (key === \"up\") return \"\u2191\";\n if (key === \"down\") return \"\u2193\";\n if (key === \"escape\") return \"esc\";\n if (key === \"return\") return \"enter\";\n return safeDisplayText(key);\n })\n .join(\"/\");\n}\n\nfunction safeDisplayText(value: string): string {\n return Array.from(stripVTControlCharacters(value), (character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n const control = codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f);\n return control ? \"\" : character;\n }).join(\"\");\n}\n", "import { stringify, type TomlTable, type TomlValue } from \"smol-toml\";\nimport type { StarshipConfig } from \"./config.js\";\nimport { MODULE_DEFINITIONS } from \"./modules/catalog.js\";\nimport type { ModuleOptionValue } from \"./modules/types.js\";\n\nexport function projectEffectiveConfig(config: StarshipConfig): TomlTable {\n const projected: TomlTable = {\n format: config.format,\n };\n if (config.palette !== undefined) projected.palette = config.palette;\n projected.palettes = Object.fromEntries(\n sortedEntries(config.palettes).map(([name, colors]) => [name, sortedRecord(colors)]),\n );\n for (const definition of MODULE_DEFINITIONS) {\n const module = config.modules[definition.name];\n const table: TomlTable = {\n format: module.format,\n symbol: module.symbol,\n };\n if (definition.styleDefaults) {\n if (definition.fallbackStyle) table.style = module.style;\n for (const field of Object.keys(definition.styleDefaults)) {\n table[field] = module.styles[field] ?? \"\";\n }\n } else if (!definition.displayDefaults) {\n table.style = module.style;\n }\n if (definition.displayDefaults) {\n table.display = module.display.map((entry) => ({ ...entry }));\n }\n if (definition.styleRuleSelectors && module.styleRules.length > 0) {\n table.style_rules = module.styleRules.map((rule) => ({ ...rule.selectors, style: rule.style }));\n }\n table.disabled = module.disabled;\n for (const key of Object.keys(definition.options ?? {})) {\n table[key] = cloneOptionValue(module.options[key]);\n }\n if (definition.name === \"extension_status\") {\n table.separator = config.extensionStatus.separator;\n table.max_statuses = config.extensionStatus.maxStatuses;\n table.icons = sortedRecord(config.extensionStatus.icons);\n table.styles = sortedRecord(config.extensionStatus.styles);\n }\n projected[definition.name] = table;\n }\n return projected;\n}\n\nexport function serializeEffectiveConfig(config: StarshipConfig): string {\n return stringify(projectEffectiveConfig(config));\n}\n\nfunction cloneOptionValue(value: ModuleOptionValue | undefined): TomlValue {\n if (value === undefined) throw new Error(\"Missing normalized module option\");\n if (Array.isArray(value)) return [...(value as readonly string[])];\n if (typeof value === \"object\") {\n return sortedRecord(value as Readonly<Record<string, string>>);\n }\n return value;\n}\n\nfunction sortedRecord(values: Readonly<Record<string, string>>): Record<string, string> {\n return Object.fromEntries(sortedEntries(values));\n}\n\nfunction sortedEntries<Value>(values: Readonly<Record<string, Value>>): [string, Value][] {\n return Object.entries(values).sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));\n}\n", "export const BRACKETED_SEGMENTS_PRESET = String.raw`# Font-safe bracketed segments inspired by Starship.\nformat = \"$brand$model$thinking$directory$git_branch$git_status$activity$context$time\"\n\n[brand]\nformat = '[\\[$symbol\\]]($style) '\nstyle = \"bold white\"\n\n[model]\nformat = '[\\[$symbol $model\\]]($style) '\nsymbol = \"AI\"\nstyle = \"bold blue\"\n\n[thinking]\nformat = '[\\[$symbol $level\\]]($style) '\nsymbol = \"think\"\nstyle = \"bold purple\"\n\n[directory]\nformat = '[\\[$symbol $path\\]]($style) '\nsymbol = \"dir\"\nstyle = \"cyan bold\"\n\n[git_branch]\nformat = '[\\[$symbol $branch\\]]($style) '\nsymbol = \"git\"\nstyle = \"bold purple\"\n\n[git_status]\nformat = '[\\[$all_status( $ahead_behind)\\]]($style) '\nstyle = \"red bold\"\n\n[activity]\nformat = '[\\[$text\\]]($style) '\nsymbol = \"run\"\nstyle = \"bold yellow\"\n\n[context]\nformat = '[\\[$symbol $percentage\\]]($style) '\nsymbol = \"ctx\"\n\n[time]\nformat = '[\\[$time\\]]($style)'\nsymbol = \"\"\nstyle = \"bold yellow\"\n`;\n", "export const CATPPUCCIN_POWERLINE_PRESET = `# Pi-native adaptation of Starship's Catppuccin Powerline preset.\nformat = \"[\uE0B6](red)$brand$model[\uE0B0](bg:peach fg:red)$directory[\uE0B0](bg:yellow fg:peach)$git_branch$git_status[\uE0B0](fg:yellow bg:green)$thinking$activity[\uE0B0](fg:green bg:sapphire)$context[\uE0B0](fg:sapphire bg:lavender)$time[\uE0B4](fg:lavender)\"\npalette = \"catppuccin_mocha\"\n\n[brand]\nformat = \"[ $symbol ]($style)\"\nsymbol = \"\uE285\"\nstyle = \"fg:crust bg:red bold\"\n\n[model]\nformat = \"[$model ]($style)\"\nsymbol = \"\"\nstyle = \"fg:crust bg:red bold\"\n\n[directory]\nformat = \"[ $path ]($style)\"\nsymbol = \"\"\nstyle = \"fg:crust bg:peach bold\"\ntruncation_length = 3\ntruncation_symbol = \"\u2026/\"\n\n[git_branch]\nformat = \"[ $symbol $branch ]($style)\"\nsymbol = \"\uF418\"\nstyle = \"fg:crust bg:yellow bold\"\n\n[git_status]\nformat = \"[$all_status$ahead_behind ]($style)\"\nstyle = \"fg:crust bg:yellow bold\"\n\n[thinking]\nformat = \"[ $symbol $level ]($style)\"\nsymbol = \"\uDB81\uDD1F\"\nstyle = \"fg:crust bg:green bold\"\n\n[activity]\nformat = \"[ $text ]($style)\"\nsymbol = \"\uDB81\uDC6E\"\nstyle = \"fg:crust bg:green bold\"\n\n[context]\nformat = \"[ $symbol $percentage ](fg:crust bg:sapphire bold)\"\nsymbol = \"\uDB80\uDF5B\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"sapphire\"\nhidden = false\n\n[time]\nformat = \"[ \uF43A $time ]($style)\"\nsymbol = \"\"\nstyle = \"fg:crust bg:lavender bold\"\n\n[palettes.catppuccin_mocha]\nred = \"#f38ba8\"\npeach = \"#fab387\"\nyellow = \"#f9e2af\"\ngreen = \"#a6e3a1\"\nsapphire = \"#74c7ec\"\nlavender = \"#b4befe\"\ncrust = \"#11111b\"\n\n[palettes.catppuccin_frappe]\nred = \"#e78284\"\npeach = \"#ef9f76\"\nyellow = \"#e5c890\"\ngreen = \"#a6d189\"\nsapphire = \"#85c1dc\"\nlavender = \"#babbf1\"\ncrust = \"#232634\"\n\n[palettes.catppuccin_latte]\nred = \"#d20f39\"\npeach = \"#fe640b\"\nyellow = \"#df8e1d\"\ngreen = \"#40a02b\"\nsapphire = \"#209fb5\"\nlavender = \"#7287fd\"\ncrust = \"#dce0e8\"\n\n[palettes.catppuccin_macchiato]\nred = \"#ed8796\"\npeach = \"#f5a97f\"\nyellow = \"#eed49f\"\ngreen = \"#a6da95\"\nsapphire = \"#7dc4e4\"\nlavender = \"#b7bdf8\"\ncrust = \"#181926\"\n`;\n", "export const GRUVBOX_RAINBOW_PRESET = `# Pi-native adaptation of Starship's Gruvbox Rainbow preset.\nformat = \"[\uE0B6](color_orange)$brand$model[\uE0B0](bg:color_yellow fg:color_orange)$directory[\uE0B0](fg:color_yellow bg:color_aqua)$git_branch$git_status[\uE0B0](fg:color_aqua bg:color_blue)$thinking$activity[\uE0B0](fg:color_blue bg:color_bg3)$context[\uE0B0](fg:color_bg3 bg:color_bg1)$time[\uE0B4](fg:color_bg1)\"\npalette = \"gruvbox_dark\"\n\n[palettes.gruvbox_dark]\ncolor_fg0 = \"#fbf1c7\"\ncolor_bg1 = \"#3c3836\"\ncolor_bg3 = \"#665c54\"\ncolor_blue = \"#458588\"\ncolor_aqua = \"#689d6a\"\ncolor_green = \"#98971a\"\ncolor_orange = \"#d65d0e\"\ncolor_purple = \"#b16286\"\ncolor_red = \"#cc241d\"\ncolor_yellow = \"#d79921\"\n\n[brand]\nformat = \"[ $symbol ]($style)\"\nsymbol = \"\uE285\"\nstyle = \"fg:color_fg0 bg:color_orange bold\"\n\n[model]\nformat = \"[$model ]($style)\"\nsymbol = \"\"\nstyle = \"fg:color_fg0 bg:color_orange bold\"\n\n[directory]\nformat = \"[ $path ]($style)\"\nsymbol = \"\"\nstyle = \"fg:color_fg0 bg:color_yellow bold\"\ntruncation_length = 3\ntruncation_symbol = \"\u2026/\"\n\n[git_branch]\nformat = \"[ $symbol $branch ]($style)\"\nsymbol = \"\uF418\"\nstyle = \"fg:color_fg0 bg:color_aqua bold\"\n\n[git_status]\nformat = \"[$all_status$ahead_behind ]($style)\"\nstyle = \"fg:color_fg0 bg:color_aqua bold\"\n\n[thinking]\nformat = \"[ $symbol $level ]($style)\"\nsymbol = \"\uDB81\uDD1F\"\nstyle = \"fg:color_fg0 bg:color_blue bold\"\n\n[activity]\nformat = \"[ $text ]($style)\"\nsymbol = \"\uDB81\uDC6E\"\nstyle = \"fg:color_fg0 bg:color_blue bold\"\n\n[context]\nformat = \"[ $symbol $percentage ](fg:color_fg0 bg:color_bg3 bold)\"\nsymbol = \"\uDB80\uDF5B\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"color_bg3\"\nhidden = false\n\n[time]\nformat = \"[ \uF43A $time ]($style)\"\nsymbol = \"\"\nstyle = \"fg:color_fg0 bg:color_bg1 bold\"\n`;\n", "export const JETPACK_PRESET = `# Pi-native adaptation of Starship's Jetpack preset.\n# Left-side session activity and right-side workspace context meet at $fill.\nformat = \"$activity$context$fill$directory$git_branch$git_state$git_status$time\"\n\n[activity]\nformat = \"[\u25C4 $text ]($style)\"\nsymbol = \"\"\nstyle = \"italic white\"\n\n[context]\nformat = \"[\u25EF $percentage]($style) \"\nsymbol = \"\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"bold purple\"\nhidden = false\n\n[fill]\nsymbol = \" \"\nstyle = \"none\"\n\n[directory]\nformat = \"[$path]($style) \"\nsymbol = \"\"\nstyle = \"italic blue\"\ntruncation_length = 2\ntruncation_symbol = \"\u25A1 \"\nhome_symbol = \"\u2302\"\n\n[git_branch]\nformat = \"[$symbol$branch]($style)\"\nsymbol = \"\u25B3 \"\nstyle = \"italic bright-blue\"\ntruncation_length = 11\ntruncation_symbol = \"\u22EF\"\n\n[git_state]\nformat = \"([\u23AA$state $progress_current/$progress_total\u23A5]($style))\"\nsymbol = \"\"\nstyle = \"italic bright-purple\"\n\n[git_status]\nformat = \"([\u23AA$all_status$ahead_behind\u23A5]($style))\"\nstyle = \"bold italic bright-blue\"\n\n[time]\nformat = \"[ $time]($style)\"\nsymbol = \"\"\nstyle = \"italic dimmed white\"\n`;\n", "export const MINIMAL_PRESET = `# A compact, font-safe Pi footer.\nformat = \"$model$directory$git_branch$activity\"\n\n[model]\nformat = \"[$model]($style) \"\nsymbol = \"\"\nstyle = \"bold blue\"\n\n[directory]\nformat = \"[$path]($style) \"\nsymbol = \"\"\nstyle = \"cyan bold\"\n\n[git_branch]\nformat = \"[git:$branch]($style) \"\nsymbol = \"\"\nstyle = \"bold purple\"\n\n[activity]\nformat = \"[$text]($style)\"\nsymbol = \"*\"\nstyle = \"bold yellow\"\n`;\n", "export const NERD_FONT_SYMBOLS_PRESET = `# Balanced Pi footer with Nerd Font symbols.\nformat = \"$brand$model$thinking$directory$git_branch$git_status$activity$context$time\"\n\n[brand]\nsymbol = \"\uE285\"\n\n[model]\nsymbol = \"\uDB81\uDEA9\"\n\n[thinking]\nsymbol = \"\uDB81\uDD1F\"\n\n[directory]\nsymbol = \"\uDB80\uDE4B\"\n\n[git_branch]\nsymbol = \"\uF418\"\n\n[activity]\nsymbol = \"\uDB81\uDC6E\"\n\n[context]\nsymbol = \"\uDB80\uDF5B\"\n\n[time]\nsymbol = \"\uF43A\"\n`;\n", "export const NO_EMPTY_ICONS_PRESET = `# Pi-native adaptation of Starship's No Empty Icons preset.\n# Each label lives inside the same conditional group as its value.\nformat = \"$model$thinking$directory$git_branch$git_status$activity$context$time\"\n\n[model]\nformat = \"([model $model]($style) )\"\nsymbol = \"\"\nstyle = \"bold blue\"\n\n[thinking]\nformat = \"([thinking $level]($style) )\"\nsymbol = \"\"\nstyle = \"bold purple\"\n\n[directory]\nformat = \"([in $path]($style) )\"\nsymbol = \"\"\nstyle = \"cyan bold\"\n\n[git_branch]\nformat = \"([on $branch]($style) )\"\nsymbol = \"\"\nstyle = \"bold purple\"\n\n[git_status]\nformat = \"([$all_status$ahead_behind]($style) )\"\nstyle = \"red bold\"\n\n[activity]\nformat = \"([while $text]($style) )\"\nsymbol = \"\"\nstyle = \"bold yellow\"\n\n[context]\nformat = \"([using $percentage context]($style) )\"\nsymbol = \"\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"bold green\"\nhidden = false\n\n[time]\nformat = \"([at $time]($style))\"\nsymbol = \"\"\nstyle = \"bold yellow\"\n`;\n", "export const NO_NERD_FONT_PRESET = `# Pi-native adaptation of Starship's No Nerd Font preset.\nformat = \"$brand$model$thinking$directory$git_branch$git_status$activity$context$time\"\n\n[brand]\nformat = \"[$symbol]($style) \"\nsymbol = \"\u2726\"\nstyle = \"bold white\"\n\n[model]\nformat = \"[$symbol $model]($style) \"\nsymbol = \"\u25C6\"\nstyle = \"bold blue\"\n\n[thinking]\nformat = \"[$symbol $level]($style) \"\nsymbol = \"\u25C7\"\nstyle = \"bold purple\"\n\n[directory]\nformat = \"[$symbol $path]($style) \"\nsymbol = \"\u2302\"\nstyle = \"cyan bold\"\n\n[git_branch]\nformat = \"[$symbol $branch]($style) \"\nsymbol = \"\u2387\"\nstyle = \"bold purple\"\n\n[git_status]\nformat = \"[$all_status( $ahead_behind)]($style) \"\nstyle = \"red bold\"\n\n[activity]\nformat = \"[$text]($style) \"\nsymbol = \"\u25CF\"\nstyle = \"bold yellow\"\n\n[context]\nformat = \"[$symbol $percentage]($style) \"\nsymbol = \"\u25CC\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"bold green\"\nhidden = false\n\n[time]\nformat = \"[$symbol $time]($style)\"\nsymbol = \"\u25F4\"\nstyle = \"bold yellow\"\n`;\n", "export const NO_RUNTIME_VERSIONS_PRESET = `# Pi-native adaptation of Starship's No Runtime Versions preset.\n# Model and thinking modules retain presence symbols while hiding version-like details.\nformat = \"$brand$model$thinking$directory$git_branch$git_status$activity$context$time\"\n\n[brand]\nformat = \"[$symbol]($style) \"\nsymbol = \"\u03C0\"\nstyle = \"bold white\"\n\n[model]\nformat = \"[$symbol]($style) \"\nsymbol = \"AI\"\nstyle = \"bold blue\"\n\n[thinking]\nformat = \"[$symbol]($style) \"\nsymbol = \"think\"\nstyle = \"bold purple\"\n\n[directory]\nformat = \"[$path]($style) \"\nsymbol = \"\"\nstyle = \"cyan bold\"\n\n[git_branch]\nformat = \"[$symbol$branch]($style) \"\nsymbol = \"git:\"\nstyle = \"bold purple\"\n\n[git_status]\nformat = \"[$all_status( $ahead_behind)]($style) \"\nstyle = \"red bold\"\n\n[activity]\nformat = \"[$symbol]($style) \"\nsymbol = \"run\"\nstyle = \"bold yellow\"\n\n[context]\nformat = \"[$percentage]($style) \"\nsymbol = \"\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"bold green\"\nhidden = false\n\n[time]\nformat = \"[$time]($style)\"\nsymbol = \"\"\nstyle = \"bold yellow\"\n`;\n", "export const PASTEL_POWERLINE_PRESET = `# Pi-native adaptation of Starship's Pastel Powerline preset.\nformat = \"[\uE0B6](#9A348E)$brand$model[\uE0B0](bg:#DA627D fg:#9A348E)$directory[\uE0B0](fg:#DA627D bg:#FCA17D)$git_branch$git_status[\uE0B0](fg:#FCA17D bg:#86BBD8)$thinking$activity[\uE0B0](fg:#86BBD8 bg:#06969A)$context[\uE0B0](fg:#06969A bg:#33658A)$time[\uE0B4](fg:#33658A)\"\n\n[brand]\nformat = \"[ $symbol ]($style)\"\nsymbol = \"\uE285\"\nstyle = \"fg:#ffffff bg:#9A348E bold\"\n\n[model]\nformat = \"[$model ]($style)\"\nsymbol = \"\"\nstyle = \"fg:#ffffff bg:#9A348E bold\"\n\n[directory]\nformat = \"[ $path ]($style)\"\nsymbol = \"\"\nstyle = \"fg:#ffffff bg:#DA627D bold\"\ntruncation_length = 3\ntruncation_symbol = \"\u2026/\"\n\n[git_branch]\nformat = \"[ $symbol $branch ]($style)\"\nsymbol = \"\uF418\"\nstyle = \"fg:#1f1f1f bg:#FCA17D bold\"\n\n[git_status]\nformat = \"[$all_status$ahead_behind ]($style)\"\nstyle = \"fg:#1f1f1f bg:#FCA17D bold\"\n\n[thinking]\nformat = \"[ $symbol $level ]($style)\"\nsymbol = \"\uDB81\uDD1F\"\nstyle = \"fg:#1f1f1f bg:#86BBD8 bold\"\n\n[activity]\nformat = \"[ $text ]($style)\"\nsymbol = \"\uDB81\uDC6E\"\nstyle = \"fg:#1f1f1f bg:#86BBD8 bold\"\n\n[context]\nformat = \"[ $symbol $percentage ](fg:#ffffff bg:#06969A bold)\"\nsymbol = \"\uDB80\uDF5B\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"#06969A\"\nhidden = false\n\n[time]\nformat = \"[ \u2665 $time ]($style)\"\nsymbol = \"\"\nstyle = \"fg:#ffffff bg:#33658A bold\"\n`;\n", "export const PLAIN_TEXT_SYMBOLS_PRESET = `# Pi-native adaptation of Starship's Plain Text Symbols preset.\nformat = \"$brand$model$thinking$directory$git_branch$git_status$activity$context$time\"\n\n[brand]\nformat = \"[$symbol]($style) \"\nsymbol = \"pi\"\nstyle = \"bold white\"\n\n[model]\nformat = \"[$symbol $model]($style) \"\nsymbol = \"model\"\nstyle = \"bold blue\"\n\n[thinking]\nformat = \"[$symbol $level]($style) \"\nsymbol = \"thinking\"\nstyle = \"bold purple\"\n\n[directory]\nformat = \"[$symbol $path]($style) \"\nsymbol = \"dir\"\nstyle = \"cyan bold\"\n\n[git_branch]\nformat = \"[$symbol $branch]($style) \"\nsymbol = \"git\"\nstyle = \"bold purple\"\ntruncation_symbol = \"...\"\n\n[git_status]\nformat = \"[$all_status( $ahead_behind)]($style) \"\nstyle = \"red bold\"\n\n[activity]\nformat = \"[$text]($style) \"\nsymbol = \"active\"\nstyle = \"bold yellow\"\n\n[context]\nformat = \"[$symbol $percentage]($style) \"\nsymbol = \"context\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"bold green\"\nhidden = false\n\n[time]\nformat = \"[$symbol $time]($style)\"\nsymbol = \"time\"\nstyle = \"bold yellow\"\n`;\n", "export const PURE_PRESET = `# Pi-native adaptation of Starship's Pure preset.\nformat = \"$directory$git_branch$git_state$git_status$activity\\\\n$model$thinking$context$fill$time\"\n\n[directory]\nformat = \"[$path]($style) \"\nsymbol = \"\"\nstyle = \"blue\"\n\n[git_branch]\nformat = \"[$branch]($style) \"\nsymbol = \"\"\nstyle = \"bright-black\"\n\n[git_state]\nformat = '([($state( $progress_current/$progress_total))]($style) )'\nsymbol = \"\"\nstyle = \"bright-black\"\n\n[git_status]\nformat = \"[(*$all_status)](218) [$ahead_behind]($style) \"\nstyle = \"cyan\"\n\n[activity]\nformat = \"[$text]($style) \"\nsymbol = \"\"\nstyle = \"yellow\"\n\n[model]\nformat = \"[$model]($style) \"\nsymbol = \"\"\nstyle = \"bright-black\"\n\n[thinking]\nformat = \"[$level]($style) \"\nsymbol = \"\"\nstyle = \"bright-black\"\n\n[context]\nformat = \"[$percentage]($style)\"\nsymbol = \"\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"bright-black\"\nhidden = false\n\n[fill]\nsymbol = \" \"\nstyle = \"none\"\n\n[time]\nformat = \"[$time]($style)\"\nsymbol = \"\"\nstyle = \"bright-black\"\n`;\n", "export const TOKYO_NIGHT_PRESET = `# Pi-native adaptation of Starship's Tokyo Night preset.\nformat = \"[\u2591\u2592\u2593](#a3aed2)$brand$model[\uE0B4](bg:#769ff0 fg:#a3aed2)$directory[\uE0B4](fg:#769ff0 bg:#394260)$git_branch$git_status[\uE0B4](fg:#394260 bg:#212736)$thinking$activity[\uE0B4](fg:#212736 bg:#1d2230)$context$time[\uE0B4](fg:#1d2230)\"\n\n[brand]\nformat = \"[ $symbol ]($style)\"\nsymbol = \"\uE285\"\nstyle = \"fg:#090c0c bg:#a3aed2 bold\"\n\n[model]\nformat = \"[$model ]($style)\"\nsymbol = \"\"\nstyle = \"fg:#090c0c bg:#a3aed2 bold\"\n\n[directory]\nformat = \"[ $path ]($style)\"\nsymbol = \"\"\nstyle = \"fg:#e3e5e5 bg:#769ff0 bold\"\ntruncation_length = 3\ntruncation_symbol = \"\u2026/\"\n\n[git_branch]\nformat = \"[ $symbol $branch ]($style)\"\nsymbol = \"\uF418\"\nstyle = \"fg:#769ff0 bg:#394260 bold\"\n\n[git_status]\nformat = \"[$all_status$ahead_behind ]($style)\"\nstyle = \"fg:#769ff0 bg:#394260 bold\"\n\n[thinking]\nformat = \"[ $symbol $level ]($style)\"\nsymbol = \"\uDB81\uDD1F\"\nstyle = \"fg:#769ff0 bg:#212736 bold\"\n\n[activity]\nformat = \"[ $text ]($style)\"\nsymbol = \"\uDB81\uDC6E\"\nstyle = \"fg:#769ff0 bg:#212736 bold\"\n\n[context]\nformat = \"[ $symbol $percentage ](fg:#a0a9cb bg:#1d2230 bold)\"\nsymbol = \"\uDB80\uDF5B\"\n\n[[context.display]]\nthreshold = 0\nstyle = \"#1d2230\"\nhidden = false\n\n[time]\nformat = \"[\uF43A $time ]($style)\"\nsymbol = \"\"\nstyle = \"fg:#a0a9cb bg:#1d2230 bold\"\n`;\n", "import { BRACKETED_SEGMENTS_PRESET } from \"./bracketed-segments.js\";\nimport { CATPPUCCIN_POWERLINE_PRESET } from \"./catppuccin-powerline.js\";\nimport { GRUVBOX_RAINBOW_PRESET } from \"./gruvbox-rainbow.js\";\nimport { JETPACK_PRESET } from \"./jetpack.js\";\nimport { MINIMAL_PRESET } from \"./minimal.js\";\nimport { NERD_FONT_SYMBOLS_PRESET } from \"./nerd-font-symbols.js\";\nimport { NO_EMPTY_ICONS_PRESET } from \"./no-empty-icons.js\";\nimport { NO_NERD_FONT_PRESET } from \"./no-nerd-font.js\";\nimport { NO_RUNTIME_VERSIONS_PRESET } from \"./no-runtime-versions.js\";\nimport { PASTEL_POWERLINE_PRESET } from \"./pastel-powerline.js\";\nimport { PLAIN_TEXT_SYMBOLS_PRESET } from \"./plain-text-symbols.js\";\nimport { PURE_PRESET } from \"./pure-preset.js\";\nimport { TOKYO_NIGHT_PRESET } from \"./tokyo-night.js\";\n\nexport interface StarshipPreset {\n id:\n | \"minimal\"\n | \"bracketed-segments\"\n | \"catppuccin-powerline\"\n | \"gruvbox-rainbow\"\n | \"jetpack\"\n | \"nerd-font-symbols\"\n | \"no-empty-icons\"\n | \"no-nerd-font\"\n | \"no-runtime-versions\"\n | \"pastel-powerline\"\n | \"plain-text-symbols\"\n | \"pure-preset\"\n | \"tokyo-night\";\n label: string;\n description: string;\n requiresNerdFont: boolean;\n rawDocument: string;\n}\n\nexport const STARSHIP_PRESETS = [\n {\n id: \"minimal\",\n label: \"Minimal\",\n description: \"Compact Pi essentials \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: MINIMAL_PRESET,\n },\n {\n id: \"bracketed-segments\",\n label: \"Bracketed Segments\",\n description: \"Balanced Pi and Git details in brackets \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: BRACKETED_SEGMENTS_PRESET,\n },\n {\n id: \"catppuccin-powerline\",\n label: \"Catppuccin Powerline\",\n description: \"Mocha connected color blocks \u00B7 requires Nerd Font\",\n requiresNerdFont: true,\n rawDocument: CATPPUCCIN_POWERLINE_PRESET,\n },\n {\n id: \"gruvbox-rainbow\",\n label: \"Gruvbox Rainbow\",\n description: \"Warm Gruvbox connected segments \u00B7 requires Nerd Font\",\n requiresNerdFont: true,\n rawDocument: GRUVBOX_RAINBOW_PRESET,\n },\n {\n id: \"jetpack\",\n label: \"Jetpack\",\n description: \"Airy geometric left/right layout \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: JETPACK_PRESET,\n },\n {\n id: \"nerd-font-symbols\",\n label: \"Nerd Font Symbols\",\n description: \"Balanced default layout with icon-rich symbols \u00B7 requires Nerd Font\",\n requiresNerdFont: true,\n rawDocument: NERD_FONT_SYMBOLS_PRESET,\n },\n {\n id: \"no-empty-icons\",\n label: \"No Empty Icons\",\n description: \"Conditional labels never appear without values \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: NO_EMPTY_ICONS_PRESET,\n },\n {\n id: \"no-nerd-font\",\n label: \"No Nerd Font\",\n description: \"Portable Unicode symbols without private-use glyphs \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: NO_NERD_FONT_PRESET,\n },\n {\n id: \"no-runtime-versions\",\n label: \"No Runtime Versions\",\n description: \"Presence indicators without model or thinking details \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: NO_RUNTIME_VERSIONS_PRESET,\n },\n {\n id: \"pastel-powerline\",\n label: \"Pastel Powerline\",\n description: \"Pastel connected color blocks \u00B7 requires Nerd Font\",\n requiresNerdFont: true,\n rawDocument: PASTEL_POWERLINE_PRESET,\n },\n {\n id: \"plain-text-symbols\",\n label: \"Plain Text Symbols\",\n description: \"Plain words replace pictograms \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: PLAIN_TEXT_SYMBOLS_PRESET,\n },\n {\n id: \"pure-preset\",\n label: \"Pure Preset\",\n description: \"Clean two-line workspace and session context \u00B7 font-safe\",\n requiresNerdFont: false,\n rawDocument: PURE_PRESET,\n },\n {\n id: \"tokyo-night\",\n label: \"Tokyo Night\",\n description: \"Cool connected color blocks \u00B7 requires Nerd Font\",\n requiresNerdFont: true,\n rawDocument: TOKYO_NIGHT_PRESET,\n },\n] as const satisfies readonly StarshipPreset[];\n\nexport function getStarshipPreset(id: StarshipPreset[\"id\"]): StarshipPreset {\n const preset = STARSHIP_PRESETS.find((candidate) => candidate.id === id);\n if (!preset) throw new Error(`Unknown pi-starship preset: ${id}`);\n return preset;\n}\n\nexport function presetForDocument(rawDocument: string | undefined): StarshipPreset | undefined {\n return STARSHIP_PRESETS.find((preset) => preset.rawDocument === rawDocument);\n}\n", "import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { defineMenu, runMenu, runTask } from \"@narumitw/pi-tui-kit\";\nimport { sanitizeTerminalText } from \"@narumitw/pi-tui-kit/terminal-text\";\nimport type { WorkflowOwner } from \"./command-configuration.js\";\nimport type { StarshipCommandOptions } from \"./commands.js\";\nimport {\n atomicSaveConfigDocument,\n BUILT_IN_EXAMPLE,\n type LoadedStarshipConfig,\n loadStarshipConfig,\n readConfigDocumentSnapshot,\n validateConfigDocument,\n} from \"./config.js\";\nimport { checkGistDocument, createSettingsGist, fetchSettingsGist, type GhApi, gistId } from \"./gist.js\";\n\nexport type GistWorkflowResult = \"applied\" | \"cancel\" | \"close\";\nexport type ReviewImport = (\n loaded: LoadedStarshipConfig,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n) => Promise<GistWorkflowResult>;\n\nexport async function shareSettingsGist(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n api?: GhApi,\n): Promise<GistWorkflowResult> {\n if (ctx.mode !== \"tui\" || !current(owner)) return \"cancel\";\n const loaded = options.getLoaded();\n if (loaded.diagnostics.some((item) => item.severity === \"error\")) {\n ctx.ui.notify(\"Fix configuration errors before sharing settings.\", \"warning\");\n return \"cancel\";\n }\n const raw = loaded.rawDocument ?? BUILT_IN_EXAMPLE;\n try {\n checkGistDocument(raw);\n } catch (error) {\n ctx.ui.notify(safeError(error), \"error\");\n return \"cancel\";\n }\n const review = await reviewDocument(\n ctx,\n owner,\n \"Share settings as Gist\",\n raw,\n [\n \"Review the entire loaded document, including comments and unknown fields, for secrets and local paths.\",\n \"No settings file is created when sharing built-in defaults.\",\n ],\n \"Share unlisted Gist\u2026\",\n );\n if (!current(owner)) return \"cancel\";\n if (!review) return \"close\";\n const confirmed = await ctx.ui.confirm(\n \"Upload settings to GitHub?\",\n [\n \"Send the reviewed pi-starship.toml to github.com as a new unlisted Gist?\",\n \"Unlisted is not private: anyone with the link can read it. Comments and unknown fields are included.\",\n \"Cancellation or a network error cannot undo an upload already accepted by GitHub; check your Gists before retrying.\",\n ].join(\"\\n\"),\n { signal: owner.signal },\n );\n if (!current(owner) || !confirmed) return \"cancel\";\n const result = await runTask(ctx, {\n label: \"Sharing settings with GitHub\u2026\",\n signal: owner.signal,\n isCurrent: owner.isCurrent,\n task: ({ signal }) => createSettingsGist(raw, signal, api),\n onError: () =>\n ctx.ui.notify(\n \"Gist upload failed. Check gh auth status, Gist access, connectivity, and your Gists before retrying. The upload may already exist.\",\n \"error\",\n ),\n });\n if (!current(owner)) return \"cancel\";\n if (result.kind === \"completed\") {\n ctx.ui.notify(`Settings Gist: ${result.value}`, \"info\");\n return \"cancel\";\n }\n return result.kind === \"error\" ? \"cancel\" : \"close\";\n}\n\nexport async function importSettingsGist(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n reviewImport: ReviewImport,\n api?: GhApi,\n): Promise<GistWorkflowResult> {\n if (ctx.mode !== \"tui\" || !current(owner)) return \"cancel\";\n const previous = options.getLoaded();\n const revision = options.getLoadedRevision?.();\n const disk = diskSnapshot(options);\n const initialDisk = readConfigDocumentSnapshot(options.settingsPath);\n const guardedOwner: WorkflowOwner = {\n signal: owner.signal,\n isSessionCurrent: () => owner.isSessionCurrent?.() ?? owner.isCurrent(),\n isCurrent: () =>\n current(owner) &&\n options.getLoadedRevision?.() === revision &&\n options.getLoaded().rawDocument === previous.rawDocument &&\n options.getLoaded().source === previous.source,\n };\n const value = await ctx.ui.input(\"Import pi-starship settings from Gist\", \"https://gist.github.com/<owner>/<id>\", {\n signal: owner.signal,\n });\n if (!current(guardedOwner) || value === undefined) return \"cancel\";\n let id: string;\n try {\n id = gistId(value);\n } catch (error) {\n ctx.ui.notify(safeError(error), \"error\");\n return \"cancel\";\n }\n const result = await runTask(ctx, {\n label: \"Reading settings from GitHub\u2026\",\n signal: owner.signal,\n isCurrent: guardedOwner.isCurrent,\n task: ({ signal }) => fetchSettingsGist(id, signal, api),\n onError: () =>\n ctx.ui.notify(\n \"Gist import failed. Check the Gist ID, gh auth status, connectivity, and a complete pi-starship.toml file (up to 64 KiB).\",\n \"error\",\n ),\n });\n if (!current(guardedOwner)) return \"cancel\";\n if (result.kind !== \"completed\") return result.kind === \"error\" ? \"cancel\" : \"close\";\n let validated: LoadedStarshipConfig;\n try {\n validated = (options.validate ?? validateConfigDocument)(options.settingsPath, result.value);\n } catch (error) {\n ctx.ui.notify(`Gist settings are invalid: ${safeError(error)}`, \"error\");\n return \"cancel\";\n }\n const reviewed = await reviewDocument(\n ctx,\n guardedOwner,\n \"Review Gist settings\",\n result.value,\n [\n `Source: https://gist.github.com/${id}`,\n \"Untrusted settings can enable local commands and network requests. Review the complete TOML before applying.\",\n \"Import replaces the entire local document, including comments and unknown fields; its previous bytes will be kept in History.\",\n ],\n \"Preview imported footer\u2026\",\n );\n if (!current(guardedOwner)) return \"cancel\";\n if (!reviewed) return \"close\";\n return reviewImport(\n validated,\n {\n ...options,\n save(path, raw) {\n if (!current(guardedOwner) || diskSnapshot(options) !== disk) {\n throw new Error(\"Settings changed during import. Start a new import to review the latest state.\");\n }\n return options.save ? options.save(path, raw) : atomicSaveConfigDocument(path, raw, {}, initialDisk);\n },\n },\n guardedOwner,\n );\n}\n\nasync function reviewDocument(\n ctx: ExtensionCommandContext,\n owner: WorkflowOwner,\n title: string,\n content: string,\n lines: string[],\n label: string,\n): Promise<boolean> {\n let approved = false;\n const menu = defineMenu<undefined, \"document\", \"continue\", ExtensionCommandContext>({\n start: \"document\",\n screens: {\n document: () => ({\n kind: \"review\",\n title,\n lines,\n content,\n format: { kind: \"code\", language: \"toml\" },\n viewportSize: \"adaptive\",\n enableSearch: true,\n confirm: { id: \"continue\", label, action: \"continue\" },\n hint: \"close\",\n }),\n },\n actions: {\n continue: () => {\n approved = true;\n return { kind: \"close\" };\n },\n },\n });\n await runMenu(ctx, menu, { getState: () => undefined, signal: owner.signal, isCurrent: owner.isCurrent });\n return current(owner) && approved;\n}\n\nfunction diskSnapshot(options: StarshipCommandOptions): string {\n const loaded = (options.read ?? loadStarshipConfig)(options.settingsPath);\n return JSON.stringify([\n loaded.rawDocument,\n loaded.source,\n loaded.diagnostics,\n readConfigDocumentSnapshot(options.settingsPath),\n ]);\n}\n\nfunction current(owner: WorkflowOwner): boolean {\n return !owner.signal.aborted && owner.isCurrent();\n}\n\nfunction safeError(error: unknown): string {\n return sanitizeTerminalText(error instanceof Error ? error.message : String(error));\n}\n", "import { spawn } from \"node:child_process\";\n\nexport const GIST_FILENAME = \"pi-starship.toml\";\nexport const MAX_GIST_DOCUMENT_BYTES = 64 * 1024;\nconst MAX_RESPONSE_BYTES = 512 * 1024;\nconst REQUEST_TIMEOUT_MS = 30_000;\n\nexport type GhApi = (args: string[], input: string | undefined, signal: AbortSignal) => Promise<string>;\n\n/** Gists are intentionally limited to github.com; never forward auth to a pasted host. */\nexport function gistId(value: string): string {\n const text = value.trim();\n if (/^[a-f\\d]{5,64}$/iu.test(text)) return text;\n try {\n const url = new URL(text);\n const match = /^\\/(?:[\\w-]+\\/)?([a-f\\d]{5,64})\\/?$/iu.exec(url.pathname);\n if (\n url.protocol === \"https:\" &&\n url.hostname === \"gist.github.com\" &&\n !url.port &&\n !url.username &&\n !url.password &&\n !url.search &&\n match?.[1]\n )\n return match[1];\n } catch {\n // Report one fixed error without echoing untrusted input.\n }\n throw new Error(\"Enter a github.com Gist ID or https://gist.github.com/<owner>/<id> URL.\");\n}\n\nexport function checkGistDocument(rawDocument: string): void {\n if (!rawDocument.trim()) throw new Error(\"The Gist settings document is empty.\");\n if (Buffer.byteLength(rawDocument, \"utf8\") > MAX_GIST_DOCUMENT_BYTES) {\n throw new Error(\"The Gist settings document exceeds 64 KiB.\");\n }\n}\n\nexport async function createSettingsGist(\n rawDocument: string,\n signal: AbortSignal,\n api: GhApi = executeGhApi,\n): Promise<string> {\n checkGistDocument(rawDocument);\n const response = JSON.parse(\n await api(\n [\"/gists\", \"--method\", \"POST\", \"--input\", \"-\"],\n JSON.stringify({\n description: \"pi-starship footer settings\",\n public: false,\n files: { [GIST_FILENAME]: { content: rawDocument } },\n }),\n signal,\n ),\n ) as unknown;\n signal.throwIfAborted();\n if (!isRecord(response) || response.public !== false || typeof response.html_url !== \"string\") {\n throw new Error(\"GitHub returned an invalid Gist response. Check your Gists before retrying.\");\n }\n return `https://gist.github.com/${gistId(response.html_url)}`;\n}\n\nexport async function fetchSettingsGist(\n value: string,\n signal: AbortSignal,\n api: GhApi = executeGhApi,\n): Promise<string> {\n const id = gistId(value);\n const response = JSON.parse(await api([`/gists/${id}`, \"--method\", \"GET\"], undefined, signal)) as unknown;\n signal.throwIfAborted();\n const file = isRecord(response) && isRecord(response.files) ? response.files[GIST_FILENAME] : undefined;\n if (!isRecord(file) || typeof file.content !== \"string\" || file.truncated !== false) {\n throw new Error(`The Gist must contain a complete ${GIST_FILENAME} file. Truncated files are not supported.`);\n }\n checkGistDocument(file.content);\n return file.content;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value);\n}\n\n/** Bound output and lifetime, keep request bodies on stdin, and never expose gh stderr. */\nexport const executeGhApi: GhApi = (args, input, signal) => {\n signal.throwIfAborted();\n return new Promise((resolve, reject) => {\n const child = spawn(process.platform === \"win32\" ? \"gh.exe\" : \"gh\", [\"api\", \"--hostname\", \"github.com\", ...args], {\n env: { ...process.env, GH_PROMPT_DISABLED: \"1\", GH_PAGER: \"\", GH_DEBUG: \"\" },\n stdio: [\"pipe\", \"pipe\", \"ignore\"],\n windowsHide: true,\n });\n const chunks: Buffer[] = [];\n let bytes = 0;\n let failure: Error | undefined;\n const stop = (error: Error) => {\n failure ??= error;\n child.kill(\"SIGKILL\");\n };\n const onAbort = () => stop(new Error(\"Gist request cancelled.\"));\n const timer = setTimeout(\n () => stop(new Error(\"Gist request timed out. Check GitHub before retrying an upload.\")),\n REQUEST_TIMEOUT_MS,\n );\n timer.unref();\n signal.addEventListener(\"abort\", onAbort, { once: true });\n child.stdout.on(\"data\", (chunk: Buffer) => {\n bytes += chunk.length;\n if (bytes > MAX_RESPONSE_BYTES) stop(new Error(\"GitHub Gist response exceeds 512 KiB.\"));\n else chunks.push(chunk);\n });\n child.stdin.on(\"error\", () => {\n stop(new Error(\"Unable to send settings to gh.\"));\n });\n child.on(\"error\", () => {\n failure ??= new Error(\"Unable to start gh. Install GitHub CLI and run gh auth login with Gist access.\");\n });\n child.on(\"close\", (code) => {\n clearTimeout(timer);\n signal.removeEventListener(\"abort\", onAbort);\n if (failure) reject(failure);\n else if (code !== 0)\n reject(\n new Error(\n \"Gist request failed. Check gh auth status, Gist access, and connectivity. An upload may already exist.\",\n ),\n );\n else resolve(Buffer.concat(chunks).toString(\"utf8\"));\n });\n if (signal.aborted) onAbort();\n child.stdin.end(input);\n });\n};\n", "import { stripVTControlCharacters } from \"node:util\";\nimport type { StatuslineInspection } from \"./modules/inspection.js\";\n\nexport function formatFooterExplanation(inspection: StatuslineInspection | undefined): string {\n if (!inspection) {\n return safeLines([\n \"Footer inspection is unavailable until the TUI footer is ready.\",\n \"No collection work was started.\",\n ]);\n }\n if (inspection.showing.length === 0) {\n return safeLines([\n \"No modules are currently showing.\",\n \"Open Modules to inspect empty, disabled, or unreachable modules.\",\n ]);\n }\n return safeLines(\n inspection.showing.flatMap((module, index) => [\n ...(index > 0 ? [\"\"] : []),\n module.name,\n ...previewLines(module.preview),\n module.description,\n ]),\n );\n}\n\nfunction previewLines(preview: string): string[] {\n const lines = preview ? preview.split(\"\\n\") : [\"(no text)\"];\n return lines.map((line, index) => `${index === 0 ? \"Value: \" : \" \"}${line}`);\n}\n\nfunction safeLines(lines: readonly string[]): string {\n return lines.map(safeDisplayText).join(\"\\n\");\n}\n\nfunction safeDisplayText(value: string): string {\n return Array.from(stripVTControlCharacters(value), (character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f) ? \"\" : character;\n }).join(\"\");\n}\n", "import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { runLiveChoice } from \"@narumitw/pi-tui-kit\";\nimport type { StarshipPreset } from \"./presets/catalog.js\";\n\nexport type PresetPickerResult =\n | { kind: \"apply\"; presetId: StarshipPreset[\"id\"] }\n | { kind: \"customize\"; presetId: StarshipPreset[\"id\"] }\n | { kind: \"save-profile\"; presetId: StarshipPreset[\"id\"] }\n | { kind: \"back\" }\n | { kind: \"close\" };\n\nexport interface PresetPickerOptions {\n presets: readonly StarshipPreset[];\n activePresetId?: StarshipPreset[\"id\"];\n initialPresetId?: StarshipPreset[\"id\"];\n signal: AbortSignal;\n isCurrent(): boolean;\n preview(preset: StarshipPreset): void;\n}\n\nexport async function showPresetPicker(\n ctx: ExtensionCommandContext,\n options: PresetPickerOptions,\n): Promise<PresetPickerResult> {\n const current =\n options.presets.find((preset) => preset.id === options.activePresetId)?.label ?? \"Custom configuration\";\n const result = await runLiveChoice(ctx, {\n title: `Presets \u00B7 current: ${current}`,\n items: options.presets.map((preset) => ({\n id: preset.id,\n label: preset.label,\n description:\n preset.id === options.activePresetId ? `Currently applied \u00B7 ${preset.description}` : preset.description,\n details: [`Selected: ${preset.label} \u00B7 ${preset.requiresNerdFont ? \"requires Nerd Font\" : \"font-safe\"}`],\n confirmationDisabled: preset.id === options.activePresetId,\n confirmationDisabledReason: \"Already applied; press e to customize\",\n })),\n currentItemId: options.activePresetId,\n initialItemId: options.initialPresetId ?? options.activePresetId,\n viewportSize: Math.min(options.presets.length, 10),\n hint: \"back\",\n navigationLabel: \"live preview\",\n confirmLabel: \"apply\",\n shortcuts: [\n { id: \"customize\", keys: [\"e\", \"shift+e\"], label: \"customize\" },\n { id: \"save-profile\", keys: [\"s\", \"shift+s\"], label: \"save as profile\" },\n ],\n onSelectionChange: ({ item }) => {\n const preset = options.presets.find((candidate) => candidate.id === item.id);\n if (preset) options.preview(preset);\n },\n signal: options.signal,\n isCurrent: options.isCurrent,\n });\n if (result.kind === \"selected\") return { kind: \"apply\", presetId: result.itemId };\n if (result.kind === \"shortcut\") {\n return { kind: result.shortcutId === \"save-profile\" ? \"save-profile\" : \"customize\", presetId: result.itemId };\n }\n if (result.kind === \"closed\" && result.reason === \"back\") return { kind: \"back\" };\n return { kind: \"close\" };\n}\n", "import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { isKeyRelease, Key, matchesKey } from \"@earendil-works/pi-tui\";\nimport { defineMenu, runLiveChoice, runMenu } from \"@narumitw/pi-tui-kit\";\nimport { sanitizeTerminalText } from \"@narumitw/pi-tui-kit/terminal-text\";\nimport type { WorkflowOwner } from \"./command-configuration.js\";\nimport type { StarshipCommandOptions } from \"./commands.js\";\nimport { BUILT_IN_EXAMPLE, type LoadedStarshipConfig, validateConfigDocument } from \"./config.js\";\nimport {\n createProfile,\n deleteHistory,\n deleteProfile,\n duplicateProfile,\n type HistoryDocument,\n listHistory,\n listProfiles,\n type ProfileDocument,\n readHistory,\n readProfile,\n renameProfile,\n saveProfile,\n} from \"./profile-store.js\";\n\nexport type ProfileApplyCandidate = (\n loaded: LoadedStarshipConfig,\n owner: WorkflowOwner,\n checkCandidate: () => void,\n name: string,\n) => Promise<\"applied\" | \"stay\" | \"close\">;\n\ntype Document = ProfileDocument | HistoryDocument;\ntype Exit = \"back\" | \"close\";\ninterface Action {\n id: string;\n label: string;\n description?: string;\n disabled?: boolean;\n disabledReason?: string;\n}\ninterface Candidate {\n loaded?: LoadedStarshipConfig;\n lines: string[];\n}\n\nconst PREVIEW_NOTICE = \"Preview uses the current runtime snapshot only; unavailable module data can be empty.\";\nconst SAVE_CURRENT = \"save-current\";\nclass FlowEnded extends Error {}\n\n/** Profiles are independent copies. Only applyCandidate may replace active settings. */\nexport async function showProfiles(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n applyCandidate: ProfileApplyCandidate,\n): Promise<Exit> {\n return browseDocuments(ctx, options, owner, applyCandidate, \"profile\");\n}\n\nexport async function showHistory(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n applyCandidate: ProfileApplyCandidate,\n): Promise<Exit> {\n return browseDocuments(ctx, options, owner, applyCandidate, \"history\");\n}\n\n/** Reusable by reviewed preset/Gist candidates; never writes the active file. */\nexport async function saveAsProfile(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n raw: string,\n): Promise<ProfileDocument | \"close\" | undefined> {\n if (!interactive(ctx) || !current(owner)) return undefined;\n const flow = createFlow(ctx, options, owner);\n try {\n candidateFor(options, raw, true);\n const saved = await saveNamedCopy(ctx, options, flow, raw);\n flow.ensure();\n return saved;\n } catch (error) {\n if (flow.signal.aborted || !flow.sessionCurrent()) return \"close\";\n report(ctx, flow, error);\n return undefined;\n } finally {\n flow.dispose();\n }\n}\n\nasync function browseDocuments(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n owner: WorkflowOwner,\n applyCandidate: ProfileApplyCandidate,\n kind: Document[\"kind\"],\n): Promise<Exit> {\n if (!interactive(ctx) || !current(owner)) return \"close\";\n const flow = createFlow(ctx, options, owner);\n let selectedId: string | undefined;\n try {\n while (flow.current()) {\n let interacted = false;\n try {\n const documents: Document[] =\n kind === \"profile\" ? listProfiles(options.settingsPath) : listHistory(options.settingsPath);\n const active = options.getLoaded();\n const matches = documents.filter(\n (document) => document.rawDocument !== undefined && document.rawDocument === active.rawDocument,\n );\n const candidates = new Map(\n documents.map((document) => [documentId(document), candidateFor(options, document.rawDocument)]),\n );\n const selection = await runLiveChoice(ctx, {\n title: kind === \"profile\" ? \"Profiles\" : \"History\",\n lines: [\n active.rawDocument === undefined && active.diagnostics.length === 0\n ? \"Active: Built-in defaults\"\n : active.diagnostics.some((item) => item.severity === \"error\")\n ? \"Active: Invalid settings document \u00B7 replacement requires explicit recovery\"\n : \"Active: Independent settings document\",\n ...(kind === \"profile\" && matches.length === 0 ? [\"Current settings are not saved as a profile\"] : []),\n PREVIEW_NOTICE,\n ],\n items: [\n ...(kind === \"profile\"\n ? [\n {\n id: SAVE_CURRENT,\n label: \"Save current as\u2026\",\n description: \"Copy exact loaded TOML; keep active settings unchanged\",\n },\n ]\n : []),\n ...documents.map((document) => ({\n id: documentId(document),\n label: safe(document.name),\n description: [\n ...(document.kind === \"history\"\n ? [safe(document.createdAt), ...(document.legacy ? [\"Legacy \u00B7 read-only\"] : [])]\n : []),\n ...(document.rawDocument !== undefined && document.rawDocument === active.rawDocument\n ? [\"Matches active settings\"]\n : []),\n ...(!candidates.get(documentId(document))?.loaded ? [\"Invalid document \u00B7 review or repair\"] : []),\n ].join(\" \u00B7 \"),\n details: [\n `Selected: ${safe(document.name)}`,\n `Path: ${safe(document.path)}`,\n ...(candidates.get(documentId(document))?.lines ?? []),\n ],\n })),\n ],\n initialItemId: selectedId,\n enableSearch: true,\n viewportSize: 10,\n hint: \"back\",\n confirmLabel: \"actions\",\n navigationLabel: \"live preview\",\n signal: flow.signal,\n isCurrent: flow.current,\n onSelectionChange: ({ item, signal }) => {\n if (signal.aborted || !flow.current()) return;\n selectedId = item.id;\n flow.preview(candidates.get(item.id)?.loaded);\n },\n });\n flow.ensure();\n interacted = true;\n if (selection.kind !== \"selected\") {\n return selection.kind === \"closed\" && selection.reason === \"back\" ? \"back\" : \"close\";\n }\n selectedId = selection.itemId;\n if (selectedId === SAVE_CURRENT) {\n flow.preview(undefined);\n const loaded = options.getLoaded();\n if (loaded.diagnostics.some((item) => item.severity === \"error\")) {\n throw new Error(\n \"Cannot save unreadable or malformed active settings as a profile. Repair the settings document first.\",\n );\n }\n const raw = loaded.rawDocument ?? BUILT_IN_EXAMPLE;\n candidateFor(options, raw, true);\n const saved = await saveNamedCopy(ctx, options, flow, raw);\n flow.ensure();\n if (saved) selectedId = documentId(saved);\n continue;\n }\n const document = documents.find((item) => documentId(item) === selectedId);\n if (!document) continue;\n flow.ensure(document);\n const outcome = await documentActions(ctx, options, flow, document, applyCandidate);\n flow.ensure();\n if (outcome === \"close\") return \"close\";\n if (outcome) selectedId = documentId(outcome);\n } catch (error) {\n if (error instanceof FlowEnded || !flow.current()) return \"close\";\n flow.preview(undefined);\n report(ctx, flow, error);\n if (!interacted) return \"close\";\n }\n }\n return \"close\";\n } finally {\n flow.dispose();\n }\n}\n\nasync function documentActions(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n flow: ReturnType<typeof createFlow>,\n document: Document,\n applyCandidate: ProfileApplyCandidate,\n): Promise<Document | \"close\" | undefined> {\n const candidate = candidateFor(options, document.rawDocument);\n const profile = document.kind === \"profile\";\n const activeInvalid = profile && options.getLoaded().diagnostics.some((item) => item.severity === \"error\");\n const action = await actionScreen(ctx, flow, {\n title: `${profile ? \"Profile\" : \"Recovery copy\"}: ${safe(document.name)}`,\n lines: [\n `Path: ${safe(document.path)}`,\n ...(document.kind === \"history\"\n ? [`Recovery time: ${safe(document.createdAt)}`, \"A recovery copy is not proof that an application succeeded.\"]\n : []),\n ...(document.kind === \"history\" && document.legacy\n ? [\"Legacy backup \u00B7 read-only; restore copies bytes without changing this backup.\"]\n : []),\n ...(document.readError ? [safe(document.readError)] : []),\n ...candidate.lines,\n PREVIEW_NOTICE,\n ],\n raw: document.rawDocument,\n actions: [\n {\n id: \"apply\",\n label: profile ? \"Apply\u2026\" : \"Restore\u2026\",\n disabled: !candidate.loaded || activeInvalid,\n disabledReason: activeInvalid\n ? \"Repair active settings or use explicit recovery first\"\n : \"Invalid TOML cannot be applied\",\n },\n ...(profile\n ? [\n { id: \"edit\", label: \"Edit TOML\u2026\" },\n { id: \"rename\", label: \"Rename\u2026\" },\n { id: \"duplicate\", label: \"Duplicate\u2026\" },\n ]\n : [\n {\n id: \"save-as\",\n label: \"Save as a profile\u2026\",\n disabled: !candidate.loaded,\n disabledReason: \"Invalid TOML cannot be saved as a validated profile\",\n },\n ]),\n {\n id: \"delete\",\n label: \"Delete\u2026\",\n disabled: document.kind === \"history\" && document.legacy,\n disabledReason: \"Legacy backups are read-only\",\n },\n ],\n });\n flow.ensure(document);\n if (action === \"close\") return \"close\";\n if (action === \"back\") return undefined;\n if (action === \"apply\" && candidate.loaded) {\n const result = await applyReviewedCandidate(flow, candidate.loaded, applyCandidate, document);\n flow.ensure(document);\n return result === \"close\" ? \"close\" : document;\n }\n if (action === \"edit\" && profile) {\n const result = await editProfile(ctx, options, flow, document, applyCandidate);\n flow.ensure();\n return result;\n }\n if (action === \"rename\" && profile) {\n const name = await flow.dialog(() =>\n ctx.ui.input(`Rename profile: ${safe(document.name)}`, \"New profile name\", { signal: flow.signal }),\n );\n flow.ensure(document);\n if (name === undefined) return document;\n return renameProfile(options.settingsPath, document.name, name, document);\n }\n if (action === \"duplicate\" || (action === \"save-as\" && document.rawDocument !== undefined)) {\n const saved = await saveNamedCopy(ctx, options, flow, document.rawDocument, document);\n flow.ensure(document);\n return action === \"duplicate\" || document.kind === \"history\" ? document : (saved ?? document);\n }\n if (action === \"delete\" && !(document.kind === \"history\" && document.legacy)) {\n const confirmed = await flow.dialog(() =>\n ctx.ui.confirm(\n `Delete ${profile ? \"profile\" : \"recovery copy\"}: ${safe(document.name)}?`,\n `Path: ${safe(document.path)}\\n${profile ? \"This deletes only the saved profile. The active settings copy remains unchanged.\" : \"This permanently deletes only this recovery copy. Active settings remain unchanged.\"}`,\n { signal: flow.signal },\n ),\n );\n flow.ensure(document);\n if (confirmed) {\n if (document.kind === \"profile\") deleteProfile(options.settingsPath, document.name, document);\n else deleteHistory(options.settingsPath, document.name, document);\n }\n }\n return undefined;\n}\n\nasync function editProfile(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n flow: ReturnType<typeof createFlow>,\n original: ProfileDocument,\n applyCandidate: ProfileApplyCandidate,\n): Promise<ProfileDocument | \"close\"> {\n let draft = original.rawDocument ?? \"\";\n if (original.rawDocument === undefined) {\n const repair = await flow.dialog(() =>\n ctx.ui.confirm(\n `Repair invalid UTF-8 profile: ${safe(original.name)}?`,\n `Path: ${safe(original.path)}\\nThe original bytes cannot be edited as TOML text. Open an empty repair draft? Saving replaces these invalid bytes; the saved copy stays unchanged until you select Save profile. Duplicate it first to keep the original bytes.`,\n { signal: flow.signal },\n ),\n );\n flow.ensure(original);\n if (!repair) return original;\n }\n while (flow.current()) {\n // Pi's editor has no signal or public dismissal API. Drain it, then reject\n // stale completion. The owner abort listener clears the footer immediately.\n const edited = await flow.dialog(() => ctx.ui.editor(`Edit profile: ${safe(original.name)}`, draft));\n flow.ensure(original);\n if (edited === undefined) return original;\n draft = edited;\n const candidate = candidateFor(options, draft);\n flow.preview(candidate.loaded);\n const action = await actionScreen(ctx, flow, {\n title: candidate.loaded ? \"Profile draft preview\" : \"Profile draft needs attention\",\n lines: [\n \"Save profile changes only the saved copy, even when it matches active settings.\",\n ...candidate.lines,\n PREVIEW_NOTICE,\n ],\n raw: draft,\n actions: [\n {\n id: \"save\",\n label: \"Save profile\",\n disabled: !candidate.loaded,\n disabledReason: \"Repair the draft before saving\",\n },\n {\n id: \"save-apply\",\n label: \"Save profile and apply\u2026\",\n description: \"Two operations: a failed apply retains the saved profile\",\n disabled: !candidate.loaded,\n disabledReason: \"Repair the draft before saving\",\n },\n { id: \"continue\", label: \"Continue editing\" },\n { id: \"discard\", label: \"Discard draft\" },\n ],\n });\n flow.ensure(original);\n if (action === \"close\") return \"close\";\n if (action === \"discard\") return original;\n if (action === \"continue\" || action === \"back\") continue;\n if (!candidate.loaded || (action !== \"save\" && action !== \"save-apply\")) continue;\n const saved = saveProfile(options.settingsPath, original.name, draft, original);\n ctx.ui.notify(`Profile saved: ${safe(saved.name)}. Active settings are unchanged.`, \"info\");\n if (action === \"save-apply\") {\n try {\n const result = await applyReviewedCandidate(flow, candidate.loaded, applyCandidate, saved);\n flow.ensure(saved);\n if (result === \"close\") return \"close\";\n if (result !== \"applied\")\n ctx.ui.notify(\n \"The profile was saved. Application did not complete; review the configuration result before retrying.\",\n \"warning\",\n );\n } catch (error) {\n if (!flow.current()) throw error;\n ctx.ui.notify(\n `The saved profile was retained, but application did not complete: ${safeError(error)}. Review active settings before retrying.`,\n \"error\",\n );\n }\n }\n return saved;\n }\n throw new FlowEnded();\n}\n\nasync function applyReviewedCandidate(\n flow: ReturnType<typeof createFlow>,\n loaded: LoadedStarshipConfig,\n applyCandidate: ProfileApplyCandidate,\n document: Document,\n) {\n flow.ensure(document);\n const result = await applyCandidate(\n loaded,\n {\n signal: flow.signal,\n // The shared commit policy captures the active revision before applying.\n // A successful apply changes it; session ownership must remain valid after it.\n isCurrent: () => !flow.signal.aborted && flow.sessionCurrent(),\n isSessionCurrent: flow.sessionCurrent,\n },\n () => flow.ensure(document),\n document.name,\n );\n // Only this operation may advance the loaded revision. Other awaits must keep\n // the reviewed active revision; failed or cancelled applies cannot adopt it.\n if (result === \"applied\") flow.adoptAppliedRevision();\n flow.ensure(document);\n flow.preview(undefined);\n return result;\n}\n\nasync function saveNamedCopy(\n ctx: ExtensionCommandContext,\n options: StarshipCommandOptions,\n flow: ReturnType<typeof createFlow>,\n raw: string | undefined,\n source?: Document,\n): Promise<ProfileDocument | undefined> {\n while (flow.current()) {\n const name = await flow.dialog(() =>\n ctx.ui.input(\"Save as a profile\", \"Profile name (without .toml)\", { signal: flow.signal }),\n );\n flow.ensure(source);\n if (name === undefined) return undefined;\n try {\n const saved =\n source?.kind === \"profile\"\n ? duplicateProfile(options.settingsPath, source.name, name, source)\n : createProfile(options.settingsPath, name, requireText(raw));\n ctx.ui.notify(`Profile saved: ${safe(saved.name)}. Active settings are unchanged.`, \"info\");\n return saved;\n } catch (error) {\n report(ctx, flow, error);\n }\n }\n throw new FlowEnded();\n}\n\nasync function actionScreen(\n ctx: ExtensionCommandContext,\n flow: ReturnType<typeof createFlow>,\n screen: { title: string; lines: string[]; actions: Action[]; raw: string | undefined },\n): Promise<string> {\n let selected: string | undefined;\n const menu = defineMenu<undefined, \"actions\" | \"document\", \"select\">({\n start: \"actions\",\n screens: {\n actions: () => ({\n kind: \"actions\",\n title: screen.title,\n lines: screen.lines,\n items: [\n {\n id: \"review\",\n label: \"Review TOML\",\n to: \"document\",\n disabled: screen.raw === undefined,\n disabledReason: \"The document is not valid UTF-8\",\n },\n ...screen.actions.map((action) => ({ ...action, action: \"select\" as const })),\n ],\n hint: \"back\",\n }),\n document: () => ({\n kind: \"review\",\n title: screen.title,\n lines: [\"Exact UTF-8 text \u00B7 display controls sanitized \u00B7 read-only\"],\n content: screen.raw ?? \"The document is not valid UTF-8; no decoded fallback is shown.\",\n format: { kind: \"code\", language: \"toml\" },\n enableSearch: true,\n viewportSize: \"adaptive\",\n hint: \"back\",\n }),\n },\n actions: {\n select: ({ itemId }) => {\n flow.ensure();\n selected = itemId;\n return { kind: \"close\" };\n },\n },\n });\n const result = await runMenu(ctx, menu, { getState: () => undefined, signal: flow.signal, isCurrent: flow.current });\n flow.ensure();\n return selected ?? (result.kind === \"closed\" && result.reason === \"back\" ? \"back\" : \"close\");\n}\n\nfunction createFlow(ctx: ExtensionCommandContext, options: StarshipCommandOptions, owner: WorkflowOwner) {\n const controller = new AbortController();\n const signal = AbortSignal.any([controller.signal, owner.signal]);\n let revision = options.getLoadedRevision?.();\n let activeDocument = activeFingerprint(options.getLoaded());\n let previewOwned = false;\n const isCurrent = () =>\n !signal.aborted &&\n owner.isCurrent() &&\n (revision === undefined\n ? activeFingerprint(options.getLoaded()) === activeDocument\n : options.getLoadedRevision?.() === revision);\n const clearPreview = () => {\n if (!previewOwned) return;\n previewOwned = false;\n // The session owner, not a captured footer snapshot, decides whether cleanup\n // can touch the UI, even after command cancellation. Runtime lifecycle\n // cleanup owns a replaced session.\n if (owner.isSessionCurrent?.() ?? owner.isCurrent()) {\n try {\n options.preview?.(undefined, ctx);\n } catch (error) {\n ctx.ui.notify(`Could not clear the footer preview: ${safeError(error)}`, \"error\");\n }\n }\n };\n const matches = (expected?: Document) => {\n if (!isCurrent()) return false;\n if (!expected) return true;\n try {\n const fresh =\n expected.kind === \"profile\"\n ? readProfile(options.settingsPath, expected.name)\n : readHistory(options.settingsPath, expected.name);\n return (\n fresh.rawDocument === expected.rawDocument &&\n fresh.identity.dev === expected.identity.dev &&\n fresh.identity.ino === expected.identity.ino &&\n fresh.identity.size === expected.identity.size &&\n fresh.identity.mtimeNs === expected.identity.mtimeNs &&\n fresh.identity.ctimeNs === expected.identity.ctimeNs &&\n fresh.rawBytes.equals(expected.rawBytes)\n );\n } catch {\n return false;\n }\n };\n const ensure = (expected?: Document) => {\n if (!isCurrent()) throw new FlowEnded();\n if (!matches(expected))\n throw new Error(\"The selected document changed or was removed. Review the latest copy before trying again.\");\n };\n signal.addEventListener(\"abort\", clearPreview, { once: true });\n return {\n signal,\n current: isCurrent,\n sessionCurrent: () => owner.isSessionCurrent?.() ?? owner.isCurrent(),\n ensure,\n preview(loaded: LoadedStarshipConfig | undefined) {\n ensure();\n if (!loaded) {\n clearPreview();\n return;\n }\n previewOwned = true;\n try {\n options.preview?.(loaded, ctx);\n } catch (error) {\n clearPreview();\n throw error;\n }\n },\n async dialog<Value>(run: () => Promise<Value>): Promise<Value> {\n ensure();\n // Native dialogs collapse Escape and Ctrl+C into one result. Observe only\n // hard cancellation; never consume, rewrite, or forward editor content.\n const unsubscribe = ctx.ui.onTerminalInput((data) => {\n if (!isKeyRelease(data) && matchesKey(data, Key.ctrl(\"c\"))) {\n // Abort after native input dispatch, before its promise continuation.\n // Synchronous abort could restore focus and leak this key to Pi's editor.\n queueMicrotask(() => controller.abort());\n }\n return undefined;\n });\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n unsubscribe();\n };\n signal.addEventListener(\"abort\", release, { once: true });\n try {\n if (signal.aborted) release();\n ensure();\n const result = await run();\n ensure();\n return result;\n } finally {\n signal.removeEventListener(\"abort\", release);\n release();\n }\n },\n adoptAppliedRevision() {\n if (signal.aborted || !(owner.isSessionCurrent?.() ?? owner.isCurrent())) throw new FlowEnded();\n revision = options.getLoadedRevision?.();\n activeDocument = activeFingerprint(options.getLoaded());\n },\n dispose() {\n try {\n clearPreview();\n } finally {\n signal.removeEventListener(\"abort\", clearPreview);\n controller.abort();\n }\n },\n };\n}\n\nfunction candidateFor(options: StarshipCommandOptions, raw: string | undefined, required = false): Candidate {\n try {\n if (raw === undefined) throw new Error(\"The document is not valid UTF-8; no decoded fallback is shown.\");\n const loaded = (options.validate ?? validateConfigDocument)(options.settingsPath, raw);\n if (loaded.diagnostics.some((item) => item.severity === \"error\"))\n throw new Error(loaded.diagnostics.map((item) => item.message).join(\"; \"));\n return {\n loaded,\n lines:\n loaded.diagnostics.length === 0\n ? [\"No configuration warnings.\"]\n : loaded.diagnostics.map((item) => `${safe(item.path || \"root\")}: ${safe(item.message)}`),\n };\n } catch (error) {\n if (required) throw error;\n return { lines: [`Invalid TOML: ${safeError(error)}`, \"No candidate footer preview is shown.\"] };\n }\n}\n\nfunction requireText(raw: string | undefined): string {\n if (raw === undefined) throw new Error(\"The document is not valid UTF-8; no decoded fallback can be saved.\");\n return raw;\n}\n\nfunction activeFingerprint(loaded: LoadedStarshipConfig) {\n return JSON.stringify([loaded.source, loaded.rawDocument, loaded.diagnostics]);\n}\n\nfunction current(owner: WorkflowOwner) {\n return !owner.signal.aborted && owner.isCurrent();\n}\n\nfunction interactive(ctx: ExtensionCommandContext) {\n if (ctx.mode === \"tui\" && ctx.hasUI) return true;\n if (ctx.hasUI) ctx.ui.notify(\"Profiles and History require TUI mode.\", \"info\");\n return false;\n}\n\nfunction documentId(document: Document) {\n return `${document.kind}:${document.name}`;\n}\n\nfunction report(ctx: ExtensionCommandContext, flow: ReturnType<typeof createFlow>, error: unknown) {\n if (!(error instanceof FlowEnded) && flow.current()) ctx.ui.notify(safeError(error), \"error\");\n}\n\nfunction safeError(error: unknown) {\n return safe(error instanceof Error ? error.message : String(error));\n}\n\nfunction safe(value: string) {\n return sanitizeTerminalText(value);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AACA,SAAS,gBAAAA,eAAc,OAAAC,MAAK,cAAAC,mBAAkB;AAC9C,SAAS,cAAAC,aAAY,WAAAC,gBAAe;;;ACFpC,SAAuC,6BAA6B;;;ACApE,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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ACE,uBAAuB,OAAO,MAAM;AAAA,MACpC,SAAS,QAAQ,YAAY;AAAA,MAC7B,cAAc,aAAa,WAAW,KAAK;AAAA,IAC7C,EAAE,KAAK,IAAI;AAAA,IACX,OAAO,YAAY,SAAS,IAAI,YAAY;AAAA,EAC9C;AACF;AAEA,SAAS,SAAS,KAA8B,cAAsB;AACpE,MAAI,CAAC,UAAU,GAAG,EAAG;AACrB,MAAI,GAAG;AAAA,IACL;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa,YAAY;AAAA,MACzB;AAAA,IACF,EAAE,KAAK,IAAI;AAAA,IACX;AAAA,EACF;AACF;AAEA,SAAS,UAAU,KAAuC;AACxD,SAAO,IAAI,SAAS,SAAS,IAAI;AACnC;AAEA,SAAS,SAAS,OAAuB;AACvC,SAAO,MAAM,KAAK,OAAO,CAAC,cAAc;AACtC,UAAM,YAAY,UAAU,YAAY,CAAC,KAAK;AAC9C,UAAM,SACJ,aAAa,KAAS,aAAa,MAAQ,aAAa,MAAU,aAAa,OAAQ,aAAa;AACtG,WAAO,SAAS,MAAM,UAAU,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,KAAK;AAAA,EACpE,CAAC,EAAE,KAAK,EAAE;AACZ;AAEA,SAASA,aAAY,OAAwB;AAC3C,SAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;",
|
|
6
|
+
"names": ["isKeyRelease", "Key", "matchesKey", "defineMenu", "runMenu", "current", "identity", "current", "withFileMutationQueue", "withFileMutationQueue", "current", "sanitizeTerminalText", "resolve", "safeError", "sanitizeTerminalText", "stripVTControlCharacters", "safeDisplayText", "current", "Key", "matchesKey", "defineMenu", "runLiveChoice", "runMenu", "sanitizeTerminalText", "current", "document", "runLiveChoice", "safeError", "defineMenu", "runMenu", "matchesKey", "Key", "sanitizeTerminalText", "isCurrentOwner", "isKeyRelease", "matchesKey", "Key", "defineMenu", "runMenu", "formatError", "preset", "edited", "current"]
|
|
7
|
+
}
|