@narumitw/pi-starship 0.49.4 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICES.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Notices
2
2
 
3
- pi-starship's format and style behavior is based in part on Starship. It uses the `yaml`
4
- package to parse kubeconfig and OpenStack metadata as inert local data.
3
+ pi-starship's format, style behavior, and bundled preset color and layout treatments are based in
4
+ part on the preset documents emitted by Starship 1.26.0. The preset modules and TOML are adapted to
5
+ Pi's native runtime snapshots. pi-starship uses the `yaml` package to parse kubeconfig and OpenStack
6
+ metadata as inert local data.
5
7
 
6
8
  ## yaml
7
9
 
package/README.md CHANGED
@@ -17,8 +17,9 @@ A native Pi footer configured with Starship-style TOML. It parses and renders fo
17
17
  - Width-aware `$fill` alignment for native multiline left/right layouts.
18
18
  - Footer rendering is pure: no subprocess, network, filesystem, timer, or environment work runs from `render()`.
19
19
  - Multiline output wraps to the terminal width instead of truncating.
20
- - Goal-oriented `/starship` menu with footer explanation, searchable module inspection,
21
- configuration health, transactional preview, and recovery.
20
+ - Goal-oriented `/starship` menu with every Starship 1.26 preset style plus a Pi-native Minimal
21
+ preset, footer explanation, searchable module inspection, configuration health, transactional
22
+ preview, and recovery.
22
23
 
23
24
  ## 📦 Install
24
25
 
@@ -64,9 +65,9 @@ on the next `session_start`, including `/reload` and session replacement. Editor
64
65
  cancellation, component disposal, invalid drafts, write failures, and runtime application failures
65
66
  preserve the previous file and effective footer.
66
67
 
67
- The shallow main menu also exposes **Explain footer**, **Modules**, **Configuration**, **Help**, and
68
- **Restore built-in…**. Explain footer uses the current immutable runtime snapshot to list each
69
- currently showing non-empty module once with its rendered value and description; it starts no new
68
+ The shallow main menu also exposes **Presets**, **Explain footer**, **Modules**, **Configuration**,
69
+ **Help**, and **Restore built-in…**. Explain footer uses the current immutable runtime snapshot to list
70
+ each currently showing non-empty module once with its rendered value and description; it starts no new
70
71
  collection work. Modules opens a bounded searchable inspector for every registered module. Its
71
72
  textual states distinguish **Showing**, **Empty**, **Disabled**, **Not in format**, and
72
73
  **Unavailable** only when the current footer cannot provide an inspection snapshot. Module detail
@@ -75,12 +76,56 @@ variables, style fields, display rules, and the known reason for absent output.
75
76
  read-only and never create or update the settings document.
76
77
 
77
78
  Configuration combines state, source, path, health, and diagnostics. A healthy missing file is shown
78
- as **Built-in defaults**, while **Built-in fallback** is reserved for read or parse errors. Restore is
79
- disabled when no settings document exists or the exact built-in document is already saved. For a
80
- custom or invalid document, Restore previews the result and warns that the complete document,
79
+ as **Built-in defaults**, an exact bundled document is shown as its named preset, and **Built-in
80
+ fallback** is reserved for read or parse errors. Restore is disabled when no settings document exists
81
+ or the exact built-in document is already saved. For a custom or invalid document, Restore previews
82
+ the result and warns that the complete document,
81
83
  including custom settings, unknown fields, and comments, will be replaced without a post-success
82
84
  backup before asking for confirmation.
83
85
 
86
+ ### 🎛️ Presets
87
+
88
+ Choose **Presets** from `/starship` to browse complete Pi-native starting points. The catalog adapts
89
+ all styles listed by `starship preset --list` in Starship 1.26.0, plus a Pi-specific Minimal option.
90
+ Colors, separators, typography, and layout follow the named Starship preset; modules are deliberately
91
+ selected for Pi's model, thinking, workspace, Git, activity, context, and time snapshots.
92
+
93
+ | Preset | Adapted visual treatment | Font requirement |
94
+ | --- | --- | --- |
95
+ | **Minimal** | Compact Pi essentials | Standard Unicode |
96
+ | **Bracketed Segments** | Balanced Pi and Git information in brackets | Standard Unicode |
97
+ | **Catppuccin Powerline** | Connected Catppuccin Mocha blocks; other Catppuccin palettes remain in the document for customization | Nerd Font |
98
+ | **Gruvbox Rainbow** | Warm Gruvbox connected segments | Nerd Font |
99
+ | **Jetpack** | Airy geometric activity/context and workspace columns joined by fill | Standard Unicode |
100
+ | **Nerd Font Symbols** | Balanced default layout with icon-rich symbols | Nerd Font |
101
+ | **No Empty Icons** | Conditional text labels that cannot appear without their values | Standard Unicode |
102
+ | **No Nerd Font** | Portable Unicode symbols without private-use glyphs | Standard Unicode |
103
+ | **No Runtime Versions** | Presence indicators without model or thinking details | Standard Unicode |
104
+ | **Pastel Powerline** | Connected magenta, coral, orange, blue, teal, and navy blocks | Nerd Font |
105
+ | **Plain Text Symbols** | Plain words replace pictograms | Standard Unicode |
106
+ | **Pure Preset** | Clean two-line workspace and session context | Standard Unicode |
107
+ | **Tokyo Night** | Connected cool blue Tokyo Night blocks | Nerd Font |
108
+
109
+ The preset cursor is a live footer preview. Opening the picker and moving with Up/Down, Page Up/Down,
110
+ Home, or End temporarily renders the selected preset in the actual footer without writing settings or
111
+ starting new collectors. Press Enter to start the named preset's replacement confirmation, or press
112
+ `e` to customize the selected complete TOML document before its normal editor preview and
113
+ confirmation. Escape returns to the main menu, while Ctrl+C closes the complete workflow; both restore
114
+ the previously effective footer.
115
+
116
+ Presets are complete documents, not overlays. Applying one replaces `pi-starship.toml`, including
117
+ custom settings, unknown fields, and comments, only after a separate confirmation; no post-success
118
+ backup is kept. Cursor movement, confirmation cancellation, disposal, validation failure, write
119
+ failure, and runtime-apply failure retain the previous valid document and effective footer. Exact
120
+ unedited matches are shown as **Currently applied** and cannot be redundantly selected; editing any
121
+ byte makes the document custom again. **Restore built-in…** remains the deterministic recovery path.
122
+
123
+ The bundled presets use only pi-starship's local Pi and Git snapshot modules. They do not enable the
124
+ GitHub PR query, cloud/deployment readers, or optional command-backed workspace collectors. They are
125
+ Pi-native adaptations of the color and format treatments emitted by Starship 1.26.0; they do not copy
126
+ Starship's module selections because Pi exposes different runtime information. There is no
127
+ `/starship preset` textual route and no remote preset download.
128
+
84
129
  ### 📝 Example
85
130
 
86
131
  ```toml
@@ -593,10 +638,11 @@ Package's explicitly documented Cargo lookup is the only ancestor walk and is ca
593
638
  | `/starship status` | Show config source/path and diagnostics |
594
639
  | `/starship help` | Show command and configuration help |
595
640
 
596
- The standard main menu keeps six goals on one level: **Customize footer**, **Explain footer**,
597
- **Modules**, **Configuration**, **Help**, and **Restore built-in…**. It shows whether the footer uses
598
- built-in defaults, a saved built-in document, a custom document, or an error-driven fallback,
599
- together with the current health. Explain and Modules are menu-only read paths; they do not add
641
+ The standard main menu keeps seven goals on one level: **Customize footer**, **Presets**,
642
+ **Explain footer**, **Modules**, **Configuration**, **Help**, and **Restore built-in…**. It shows whether
643
+ the footer uses built-in defaults, a saved built-in document, a named preset, a custom document, or an
644
+ error-driven fallback,
645
+ together with the current health. Presets, Explain, and Modules are menu-only paths; they do not add
600
646
  textual subcommands or change RPC, print, or JSON protocols. Restore remains last and unavailable
601
647
  when there is no document to replace.
602
648
 
@@ -635,6 +681,8 @@ Keep `extension_status` last in the catalog so arbitrary third-party statuses fo
635
681
  - `src/usage.ts` — native-aligned session usage and cache aggregation.
636
682
  - `src/command-contract.ts` — lightweight command routes and completions loaded at startup.
637
683
  - `src/commands.ts` — lazily loaded menu, preview/confirmation flow, diagnostics, and compatibility routes.
684
+ - `src/command-preset-picker.ts` — lifecycle-owned preset cursor and temporary footer-preview UI.
685
+ - `src/presets/` — bundled complete TOML documents and stable preset metadata.
638
686
  - `src/command-inspector.ts` — adaptive Explain and searchable read-only module inspection surfaces.
639
687
  - `src/command-preview.ts` — adaptive, scrollable, keybinding-aware preview action surface.
640
688
  - `src/config.ts` — TOML loading, draft validation, defaults, atomic persistence, and rollback.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-starship",
3
- "version": "0.49.4",
3
+ "version": "0.50.0",
4
4
  "description": "Native Starship-style TOML statusline for the Pi coding agent.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,6 +25,9 @@
25
25
  "./src/index.ts"
26
26
  ]
27
27
  },
28
+ "piExtension": {
29
+ "lifecycle": "stable"
30
+ },
28
31
  "scripts": {
29
32
  "check": "biome check --vcs-use-ignore-file=false src test package.json tsconfig.json README.md NOTICES.md && npm run typecheck",
30
33
  "format": "biome check --write --vcs-use-ignore-file=false src test package.json tsconfig.json README.md NOTICES.md",
@@ -41,14 +44,14 @@
41
44
  },
42
45
  "devDependencies": {
43
46
  "@biomejs/biome": "2.5.7",
44
- "@earendil-works/pi-coding-agent": "0.83.0",
45
- "@earendil-works/pi-tui": "0.83.0",
47
+ "@earendil-works/pi-coding-agent": "0.84.1",
48
+ "@earendil-works/pi-tui": "0.84.1",
46
49
  "@types/node": "26.1.2",
47
50
  "typescript": "7.0.2"
48
51
  },
49
52
  "repository": {
50
53
  "type": "git",
51
54
  "url": "https://github.com/narumiruna/pi-extensions",
52
- "directory": "extensions/pi-starship"
55
+ "directory": "packages/pi-starship"
53
56
  }
54
57
  }
@@ -0,0 +1,203 @@
1
+ import { stripVTControlCharacters } from "node:util";
2
+ import {
3
+ DynamicBorder,
4
+ type ExtensionCommandContext,
5
+ type KeybindingsManager,
6
+ } from "@earendil-works/pi-coding-agent";
7
+ import {
8
+ Container,
9
+ Key,
10
+ matchesKey,
11
+ type SelectItem,
12
+ SelectList,
13
+ Text,
14
+ } from "@earendil-works/pi-tui";
15
+ import { runCustomInteraction } from "@narumitw/pi-tui-kit";
16
+ import type { StarshipPreset } from "./presets/catalog.js";
17
+
18
+ export type PresetPickerResult =
19
+ | { kind: "apply"; presetId: StarshipPreset["id"] }
20
+ | { kind: "customize"; presetId: StarshipPreset["id"] }
21
+ | { kind: "back" }
22
+ | { kind: "close" };
23
+
24
+ export interface PresetPickerOptions {
25
+ presets: readonly StarshipPreset[];
26
+ activePresetId?: StarshipPreset["id"];
27
+ initialPresetId?: StarshipPreset["id"];
28
+ signal: AbortSignal;
29
+ isCurrent(): boolean;
30
+ preview(preset: StarshipPreset): void;
31
+ }
32
+
33
+ export async function showPresetPicker(
34
+ ctx: ExtensionCommandContext,
35
+ options: PresetPickerOptions,
36
+ ): Promise<PresetPickerResult> {
37
+ const items: SelectItem[] = options.presets.map((preset) => ({
38
+ value: preset.id,
39
+ label: `${preset.id === options.activePresetId ? "[-] " : ""}${preset.label}`,
40
+ description:
41
+ preset.id === options.activePresetId
42
+ ? `Currently applied · ${preset.description}`
43
+ : preset.description,
44
+ }));
45
+ const initialIndex = Math.max(
46
+ 0,
47
+ options.presets.findIndex(
48
+ (preset) => preset.id === (options.initialPresetId ?? options.activePresetId),
49
+ ),
50
+ );
51
+ const result = await runCustomInteraction<PresetPickerResult>(ctx, {
52
+ signal: options.signal,
53
+ isCurrent: options.isCurrent,
54
+ create({ tui, theme, keybindings, complete }) {
55
+ const container = new Container();
56
+ const topBorder = new DynamicBorder((text: string) => theme.fg("accent", text));
57
+ const bottomBorder = new DynamicBorder((text: string) => theme.fg("accent", text));
58
+ const title = new Text("", 1, 0);
59
+ const detail = new Text("", 1, 0);
60
+ const hint = new Text("", 1, 0);
61
+ const viewportSize = Math.min(items.length, 10);
62
+ const list = new SelectList(items, viewportSize, {
63
+ selectedPrefix: (text) => theme.fg("accent", text),
64
+ selectedText: (text) => theme.fg("accent", text),
65
+ description: (text) => theme.fg("muted", text),
66
+ scrollInfo: (text) => theme.fg("dim", text),
67
+ noMatch: (text) => theme.fg("warning", text),
68
+ });
69
+ const selectedPreset = () => {
70
+ const id = list.getSelectedItem()?.value;
71
+ return options.presets.find((preset) => preset.id === id);
72
+ };
73
+ const updateSelectedText = () => {
74
+ const preset = selectedPreset();
75
+ if (!preset) return;
76
+ detail.setText(
77
+ theme.fg(
78
+ "muted",
79
+ `Selected: ${preset.label} · ${preset.requiresNerdFont ? "requires Nerd Font" : "font-safe"}`,
80
+ ),
81
+ );
82
+ };
83
+ const previewSelected = () => {
84
+ const preset = selectedPreset();
85
+ if (!preset) return;
86
+ updateSelectedText();
87
+ options.preview(preset);
88
+ };
89
+ const updateThemedText = () => {
90
+ const current =
91
+ options.presets.find((preset) => preset.id === options.activePresetId)?.label ??
92
+ "Custom configuration";
93
+ title.setText(theme.fg("accent", theme.bold(`Presets · current: ${current}`)));
94
+ hint.setText(theme.fg("dim", pickerHint(keybindings)));
95
+ };
96
+
97
+ let selectedIndex = initialIndex;
98
+ const select = (index: number) => {
99
+ if (items.length === 0) return;
100
+ selectedIndex = Math.max(0, Math.min(index, items.length - 1));
101
+ list.setSelectedIndex(selectedIndex);
102
+ previewSelected();
103
+ };
104
+ const move = (delta: number) => {
105
+ if (items.length === 0) return;
106
+ select((selectedIndex + delta + items.length) % items.length);
107
+ };
108
+ const applySelected = () => {
109
+ const preset = selectedPreset();
110
+ if (preset && preset.id !== options.activePresetId) {
111
+ complete({ kind: "apply", presetId: preset.id });
112
+ }
113
+ };
114
+ list.setSelectedIndex(initialIndex);
115
+ container.addChild(topBorder);
116
+ container.addChild(title);
117
+ container.addChild(list);
118
+ container.addChild(detail);
119
+ container.addChild(hint);
120
+ container.addChild(bottomBorder);
121
+ updateThemedText();
122
+ previewSelected();
123
+
124
+ return {
125
+ render: (width: number) => container.render(width),
126
+ invalidate() {
127
+ container.invalidate();
128
+ updateThemedText();
129
+ updateSelectedText();
130
+ },
131
+ handleInput(data: string) {
132
+ if (matchesKey(data, Key.ctrl("c"))) {
133
+ complete({ kind: "close" });
134
+ } else if (keybindings.matches(data, "tui.select.cancel")) {
135
+ complete({ kind: "back" });
136
+ } else if (keybindings.matches(data, "tui.select.up")) {
137
+ move(-1);
138
+ } else if (keybindings.matches(data, "tui.select.down")) {
139
+ move(1);
140
+ } else if (keybindings.matches(data, "tui.select.pageUp")) {
141
+ select(selectedIndex - Math.max(1, viewportSize));
142
+ } else if (keybindings.matches(data, "tui.select.pageDown")) {
143
+ select(selectedIndex + Math.max(1, viewportSize));
144
+ } else if (matchesKey(data, Key.home)) {
145
+ select(0);
146
+ } else if (matchesKey(data, Key.end)) {
147
+ select(items.length - 1);
148
+ } else if (data === "e" || data === "E") {
149
+ const preset = selectedPreset();
150
+ if (preset) complete({ kind: "customize", presetId: preset.id });
151
+ } else if (keybindings.matches(data, "tui.select.confirm")) {
152
+ applySelected();
153
+ }
154
+ tui.requestRender();
155
+ },
156
+ };
157
+ },
158
+ });
159
+ return result.kind === "completed" ? result.value : { kind: "close" };
160
+ }
161
+
162
+ function pickerHint(keybindings: Pick<KeybindingsManager, "getKeys">): string {
163
+ const up = bindingText(keybindings, "tui.select.up");
164
+ const down = bindingText(keybindings, "tui.select.down");
165
+ const confirm = bindingText(keybindings, "tui.select.confirm");
166
+ const cancel = bindingText(keybindings, "tui.select.cancel", "ctrl+c");
167
+ const pageUp = bindingText(keybindings, "tui.select.pageUp");
168
+ const pageDown = bindingText(keybindings, "tui.select.pageDown");
169
+ return [
170
+ ...(up || down ? [`${[up, down].filter(Boolean).join("/")} live preview`] : []),
171
+ ...(confirm ? [`${confirm} apply`] : []),
172
+ "e customize",
173
+ ...(cancel ? [`${cancel} back`] : []),
174
+ "ctrl+c close",
175
+ ...(pageUp || pageDown ? [`${[pageUp, pageDown].filter(Boolean).join("/")} page preview`] : []),
176
+ ].join(" • ");
177
+ }
178
+
179
+ function bindingText(
180
+ keybindings: Pick<KeybindingsManager, "getKeys">,
181
+ binding: Parameters<KeybindingsManager["getKeys"]>[0],
182
+ excluded?: string,
183
+ ): string {
184
+ return keybindings
185
+ .getKeys(binding)
186
+ .filter((key) => key !== excluded)
187
+ .map((key) => {
188
+ if (key === "up") return "↑";
189
+ if (key === "down") return "↓";
190
+ if (key === "escape") return "esc";
191
+ if (key === "return") return "enter";
192
+ return safeDisplayText(key);
193
+ })
194
+ .join("/");
195
+ }
196
+
197
+ function safeDisplayText(value: string): string {
198
+ return Array.from(stripVTControlCharacters(value), (character) => {
199
+ const codePoint = character.codePointAt(0) ?? 0;
200
+ const control = codePoint <= 0x1f || (codePoint >= 0x7f && codePoint <= 0x9f);
201
+ return control ? "" : character;
202
+ }).join("");
203
+ }