@narumitw/pi-starship 0.56.3 → 0.58.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.
@@ -171,6 +171,7 @@ style_root = "red bold"
171
171
  [extension_status]
172
172
  format = "([$statuses ]($style))"
173
173
  icons = { "foo:*" = "🧪", "third_party/key" = "◎", fallback = "•" }
174
+ styles = { "foo:*" = "bold green", "foo:error" = "bold red", fallback = "dimmed white" }
174
175
  ```
175
176
 
176
177
  Every module table supports `format`, `symbol`, and `disabled`.
@@ -185,6 +186,8 @@ A leading `!` is supported by language detection arrays and rejects a matching p
185
186
  Icon matching uses the exact key, the longest `:*` wildcard, a leading status emoji, then `fallback`/`🔌`.
186
187
  An empty configured icon suppresses only the icon.
187
188
  `foo:*` matches `foo:server` but not `foo`, `foobar`, or `foo/server`.
189
+ `[extension_status].styles` applies a Starship style to each complete status (icon and text) by exact raw key, then longest `:*` wildcard, then optional `fallback`; unmatched statuses inherit the module's `style`.
190
+ Separators retain the module style. An explicit `none` style removes the inherited module style for that status.
188
191
 
189
192
  Pi does not expose status ownership, so exact raw keys are the reliable third-party contract.
190
193
  pi-starship does not inspect installed packages, infer aliases, assign known-extension icons, or bridge compatibility keys.
@@ -235,8 +238,9 @@ Unknown display fields warn.
235
238
  Invalid display entries are discarded independently.
236
239
  When no valid entries remain, the complete module display default is restored.
237
240
 
238
- `extension_status` additionally accepts `separator`, `max_statuses`, and `icons`.
239
- `separator` is a string, `max_statuses` is an integer from 0 through 100, and `icons` is a string-to-string table.
241
+ `extension_status` additionally accepts `separator`, `max_statuses`, `icons`, and `styles`.
242
+ `separator` is a string, `max_statuses` is an integer from 0 through 100, `icons` is a string-to-string table, and `styles` maps raw status keys to valid Starship style strings.
243
+ Invalid `styles` entries warn and are ignored independently; a non-table value warns and uses an empty table.
240
244
 
241
245
  ### Module option types
242
246
 
@@ -366,7 +370,7 @@ The exact selectors are:
366
370
  | `thinking` | `provider` | Raw Pi provider ID. |
367
371
  | `thinking` | `level` | Current Pi thinking-level string. |
368
372
 
369
- Provider and model aliases, built-in model shortening, configured truncation, and terminal display sanitization do not change these raw selector values.
373
+ Provider and model aliases, optional model shortening, configured truncation, and terminal display sanitization do not change these raw selector values.
370
374
  Style-rule styles use the selected palette and the same style grammar as other style fields.
371
375
  An unknown field, unsupported selector, non-string selector, missing style, or invalid style warns and discards only that rule; valid sibling rules remain ordered and active.
372
376
  An invalid non-array `style_rules` value warns and restores the empty default.
@@ -102,10 +102,11 @@ Additional options:
102
102
 
103
103
  | Option | Type | Default | Constraints and meaning |
104
104
  | --- | --- | --- | --- |
105
+ | `shorten_model` | boolean | `false` | Opt in to removing a leading `claude-`, a trailing `-20` plus six digits, or a trailing `-latest` from model IDs that do not match an alias; `gpt-` is unchanged. |
105
106
  | `truncation_length` | integer | `0` | Inclusive range 0 through 1000. Maximum retained model-label grapheme clusters; zero disables truncation. |
106
107
  | `truncation_symbol` | string | `"…"` | May be empty. Marker placed at the removed start, middle, or end; an empty string removes text without a marker. |
107
108
  | `truncation_direction` | string enum | `"end"` | One of `start`, `middle`, `end`. Which part of the model label is removed when truncating. |
108
- | `model_aliases` | string-to-string table | `{}` | Keys and values are strings. Exact model-ID replacements that bypass built-in Claude/GPT shortening and are then subject to configured truncation. |
109
+ | `model_aliases` | string-to-string table | `{}` | Keys and values are strings. Exact model-ID replacements that bypass optional shortening and are then subject to configured truncation. |
109
110
 
110
111
  ### `thinking`
111
112
 
@@ -997,3 +998,4 @@ Additional options:
997
998
  | `separator` | string | `" • "` | May be empty. Text inserted between rendered extension statuses. |
998
999
  | `max_statuses` | integer | `5` | Inclusive range 0 through 100. Maximum number of extension statuses rendered; zero hides all status values. |
999
1000
  | `icons` | string-to-string table | `{}` | Keys and values are strings. Exact status-key and explicit `namespace:*` icon mappings, plus optional `fallback`. |
1001
+ | `styles` | string-to-style table | `{}` | Valid Starship style strings for exact raw status keys or explicit `namespace:*` mappings, plus optional `fallback`. Unmatched statuses inherit the module style. |
@@ -190,21 +190,23 @@ Collectors retain bounded, control-sanitized source metadata.
190
190
 
191
191
  ### Model and provider aliases and model truncation
192
192
 
193
- The model module accepts exact `model_aliases`, Starship-style `truncation_length` and `truncation_symbol` options, plus the Pi-specific `truncation_direction` option:
193
+ The model module displays the raw Pi model ID by default. Set `shorten_model = true` to remove the leading `claude-`, a trailing `-20` followed by six digits, or a trailing `-latest`. Shortening does not replace `gpt-` with `gpt `; model IDs such as `gpt-6-sol` retain their hyphens. These rules match the ID text regardless of provider and apply only when no exact alias matches.
194
+ The model module also accepts exact `model_aliases`, Starship-style `truncation_length` and `truncation_symbol` options, plus the Pi-specific `truncation_direction` option:
194
195
 
195
196
  ```toml
196
197
  [model]
198
+ shorten_model = true # optional; false by default
197
199
  model_aliases = { "/models/Qwen3.6-35B-Q4.gguf" = "Qwen 35B Q4" }
198
200
  truncation_length = 36
199
201
  truncation_symbol = "…"
200
202
  truncation_direction = "middle"
201
203
  ```
202
204
 
203
- An exact alias replaces the label that the built-in Claude/GPT shortening rules would otherwise produce, bypasses those rules, and is then subject to the configured truncation.
205
+ An exact alias replaces the raw model ID, bypasses optional shortening, and is then subject to the configured truncation.
204
206
  `truncation_length` counts model grapheme clusters retained before the symbol; `0` disables truncation and is the default.
205
207
  The direction names the removed portion: `start` retains the suffix, `end` retains the prefix and is the default, and `middle` retains both ends.
206
- When no alias matches, truncation runs after the built-in Claude/GPT shortening rules.
207
- Truncation changes display only; the provider model ID is untouched.
208
+ When no alias matches, truncation runs on the raw ID or the optionally shortened label.
209
+ Shortening and truncation change display only; the provider model ID is untouched.
208
210
  Terminal control sequences in model IDs and truncation symbols are removed at render time.
209
211
  An empty symbol truncates without a marker.
210
212
 
@@ -217,7 +219,7 @@ provider_aliases = { "openai-codex" = "codex", "amazon-bedrock" = "bedrock" }
217
219
 
218
220
  An empty alias hides only the provider text.
219
221
  Provider names and aliases are stripped of terminal controls at render time.
220
- The `provider`, `model`, and `thinking` modules match `style_rules` against raw provider/model IDs and thinking levels before aliases, built-in model shortening, configured truncation, or display sanitization.
222
+ The `provider`, `model`, and `thinking` modules match `style_rules` against raw provider/model IDs and thinking levels before aliases, optional model shortening, configured truncation, or display sanitization.
221
223
  A selector whose runtime value is unavailable does not match; exact selector fields and precedence are documented in [Configuration and Format](configuration.md#content-selected-styles).
222
224
  For example, `middle` can retain both a Hugging Face model family and its variant, while `start` is useful when a llama.cpp server reports an absolute model path.
223
225
  pi-starship treats model IDs as opaque strings and does not parse paths, repositories, GGUF suffixes, or quantization names.
package/src/config.ts CHANGED
@@ -30,6 +30,7 @@ export interface ExtensionStatusConfig {
30
30
  separator: string;
31
31
  maxStatuses: number;
32
32
  icons: Record<string, string>;
33
+ styles: Record<string, string>;
33
34
  }
34
35
 
35
36
  export interface StarshipConfig {
@@ -91,7 +92,7 @@ export const BUILT_IN_CONFIG: StarshipConfig = {
91
92
  palette: undefined,
92
93
  palettes: {},
93
94
  modules: BUILT_IN_MODULES,
94
- extensionStatus: { separator: " • ", maxStatuses: 5, icons: {} },
95
+ extensionStatus: { separator: " • ", maxStatuses: 5, icons: {}, styles: {} },
95
96
  };
96
97
 
97
98
  export const BUILT_IN_EXAMPLE = `# Native Pi modules with Starship-compatible format and style syntax.\n${BUILT_IN_FORMAT_DOCUMENT}\n`;
@@ -271,6 +272,7 @@ function normalizeModule(
271
272
  known.add("separator");
272
273
  known.add("max_statuses");
273
274
  known.add("icons");
275
+ known.add("styles");
274
276
  }
275
277
  for (const key of Object.keys(value)) {
276
278
  if (!known.has(key)) diagnostics.push(unknownDiagnostic(`${name}.${key}`));
@@ -370,6 +372,20 @@ function normalizeModule(
370
372
  );
371
373
  }
372
374
  }
375
+ if (value.styles !== undefined) {
376
+ if (!isRecord(value.styles)) diagnostics.push(typeDiagnostic("extension_status.styles", "table"));
377
+ else {
378
+ config.extensionStatus.styles = Object.fromEntries(
379
+ Object.entries(value.styles).flatMap(([key, style]) => {
380
+ if (typeof style === "string" && isValidStyle(style, activePalette(config))) return [[key, style]];
381
+ diagnostics.push(
382
+ diagnostic("warning", `extension_status.styles.${key}`, "Expected a valid Starship style string; ignored"),
383
+ );
384
+ return [];
385
+ }),
386
+ );
387
+ }
388
+ }
373
389
  }
374
390
 
375
391
  interface AtomicFileSystem {
@@ -499,6 +515,7 @@ function cloneBuiltInConfig(): StarshipConfig {
499
515
  extensionStatus: {
500
516
  ...BUILT_IN_CONFIG.extensionStatus,
501
517
  icons: { ...BUILT_IN_CONFIG.extensionStatus.icons },
518
+ styles: { ...BUILT_IN_CONFIG.extensionStatus.styles },
502
519
  },
503
520
  };
504
521
  }
@@ -39,6 +39,7 @@ export function projectEffectiveConfig(config: StarshipConfig): TomlTable {
39
39
  table.separator = config.extensionStatus.separator;
40
40
  table.max_statuses = config.extensionStatus.maxStatuses;
41
41
  table.icons = sortedRecord(config.extensionStatus.icons);
42
+ table.styles = sortedRecord(config.extensionStatus.styles);
42
43
  }
43
44
  projected[definition.name] = table;
44
45
  }
@@ -1,3 +1,4 @@
1
+ import { parseStyle } from "../format/style.js";
1
2
  import { defineModule } from "./types.js";
2
3
 
3
4
  export const extensionStatusModule = defineModule({
@@ -9,16 +10,25 @@ export const extensionStatusModule = defineModule({
9
10
  style: "dimmed white",
10
11
  disabled: false,
11
12
  },
12
- values: ({ runtime, extensionStatus }) => {
13
+ values: ({ runtime, extensionStatus, palette }) => {
13
14
  const statuses = [...runtime.extensionStatuses.entries()]
14
15
  .filter(([key, value]) => key !== "starship" && value.trim())
15
- .map(([key, value]) => formatExtensionStatus(key, value, extensionStatus.icons))
16
- .slice(0, extensionStatus.maxStatuses);
16
+ .slice(0, extensionStatus.maxStatuses)
17
+ .map(([key, value]) => ({ key, text: formatExtensionStatus(key, value, extensionStatus.icons) }));
17
18
  if (statuses.length === 0) return undefined;
18
- return {
19
- statuses: statuses.join(extensionStatus.separator),
20
- count: `${statuses.length}`,
21
- };
19
+ const { separator, styles } = extensionStatus;
20
+ const content =
21
+ Object.keys(styles).length === 0
22
+ ? statuses.map(({ text }) => text).join(separator)
23
+ : statuses.flatMap(({ key, text }, index) => {
24
+ const configured = configuredStatusValue(key, styles);
25
+ const style = configured ?? (Object.hasOwn(styles, "fallback") ? styles.fallback : undefined);
26
+ return [
27
+ ...(index > 0 ? [{ text: separator }] : []),
28
+ { text, style: style === undefined ? undefined : (parseStyle(style, palette) ?? {}) },
29
+ ];
30
+ });
31
+ return { statuses: content, count: `${statuses.length}` };
22
32
  },
23
33
  });
24
34
 
@@ -38,22 +48,22 @@ function extensionStatusIcon(
38
48
  leadingIcon: string | undefined,
39
49
  configuredIcons: Readonly<Record<string, string>>,
40
50
  ): string {
41
- if (Object.hasOwn(configuredIcons, key)) return configuredIcons[key] ?? "";
42
- const namespaceIcon = configuredNamespaceIcon(key, configuredIcons);
43
- if (namespaceIcon !== undefined) return namespaceIcon;
44
- const fallbackIcon = Object.hasOwn(configuredIcons, "fallback") ? configuredIcons.fallback : undefined;
45
- return leadingIcon ?? fallbackIcon ?? "🔌";
51
+ const configured = configuredStatusValue(key, configuredIcons);
52
+ if (configured !== undefined) return configured;
53
+ const fallback = Object.hasOwn(configuredIcons, "fallback") ? configuredIcons.fallback : undefined;
54
+ return leadingIcon ?? fallback ?? "🔌";
46
55
  }
47
56
 
48
- function configuredNamespaceIcon(key: string, configuredIcons: Readonly<Record<string, string>>): string | undefined {
49
- let match: { baseLength: number; icon: string } | undefined;
50
- for (const [selector, icon] of Object.entries(configuredIcons)) {
57
+ function configuredStatusValue(key: string, configured: Readonly<Record<string, string>>): string | undefined {
58
+ if (Object.hasOwn(configured, key)) return configured[key];
59
+ let match: { baseLength: number; value: string } | undefined;
60
+ for (const [selector, value] of Object.entries(configured)) {
51
61
  if (!selector.endsWith(":*")) continue;
52
62
  const base = selector.slice(0, -2);
53
63
  if (!base || !key.startsWith(`${base}:`)) continue;
54
- if (!match || base.length > match.baseLength) match = { baseLength: base.length, icon };
64
+ if (!match || base.length > match.baseLength) match = { baseLength: base.length, value };
55
65
  }
56
- return match?.icon;
66
+ return match?.value;
57
67
  }
58
68
 
59
69
  function splitExtensionStatusIcon(value: string): { icon?: string; text: string } {
@@ -19,6 +19,7 @@ export const modelModule = defineModule({
19
19
  model: ({ runtime }) => runtime.model?.id,
20
20
  },
21
21
  options: {
22
+ shorten_model: { kind: "boolean", default: false },
22
23
  truncation_length: { kind: "integer", default: 0, minimum: 0, maximum: 1000 },
23
24
  truncation_symbol: { kind: "string", default: "…" },
24
25
  truncation_direction: {
@@ -39,8 +40,9 @@ export const modelModule = defineModule({
39
40
  ? (aliases as Readonly<Record<string, string>>)
40
41
  : undefined;
41
42
  const alias = aliasMap && Object.hasOwn(aliasMap, runtime.model.id) ? aliasMap[runtime.model.id] : undefined;
43
+ const model = alias ?? (options.shorten_model === true ? shortenModel(runtime.model.id) : runtime.model.id);
42
44
  return {
43
- model: truncateModel(alias ?? shortenModel(runtime.model.id), length, symbol, direction),
45
+ model: truncateModel(model, length, symbol, direction),
44
46
  };
45
47
  },
46
48
  });
@@ -73,7 +75,6 @@ function isTruncationDirection(value: unknown): value is TruncationDirection {
73
75
  export function shortenModel(model: string): string {
74
76
  return model
75
77
  .replace(/^claude-/u, "")
76
- .replace(/^gpt-/u, "gpt ")
77
78
  .replace(/-20\d{6}$/u, "")
78
79
  .replace(/-latest$/u, "");
79
80
  }
@@ -1,7 +1,13 @@
1
1
  import { visibleWidth } from "@earendil-works/pi-tui";
2
2
  import { activePalette, type ModuleConfig, type StarshipConfig } from "../config.js";
3
3
  import { type FormatValue, formatVariables, renderFormat } from "../format/formatter.js";
4
- import { isFillChunk, type LayoutChunk, renderChunksToAnsi, type StyledChunk } from "../format/style.js";
4
+ import {
5
+ type ColorPalette,
6
+ isFillChunk,
7
+ type LayoutChunk,
8
+ renderChunksToAnsi,
9
+ type StyledChunk,
10
+ } from "../format/style.js";
5
11
  import { MODULE_DEFINITIONS, MODULE_NAMES, type ModuleName } from "./catalog.js";
6
12
  import { resolveStyleRule } from "./style-rules.js";
7
13
  import type { ModuleStyleContext, ModuleValueContext, RenderedStatusline, StarshipRuntimeSnapshot } from "./types.js";
@@ -22,11 +28,10 @@ export function renderStatusline(
22
28
  for (const definition of MODULE_DEFINITIONS) {
23
29
  const name = definition.name;
24
30
  const module = config.modules[name];
25
- const values = definition.values(valueContext(config, name, runtime));
31
+ const values = definition.values(valueContext(config, name, runtime, palette));
26
32
  if (!values) continue;
27
33
  const styleContext: ModuleStyleContext = {
28
34
  runtime,
29
- values,
30
35
  style: module.style,
31
36
  styles: module.styles,
32
37
  display: module.display,
@@ -39,7 +44,7 @@ export function renderStatusline(
39
44
  ? resolveStyleRule(module.styleRules, definition.styleRuleSelectors, styleContext)
40
45
  : undefined;
41
46
  const styleVariables = ruleStyle === undefined ? baseStyleVariables : { ...baseStyleVariables, style: ruleStyle };
42
- const contentValues = Object.fromEntries(
47
+ const contentValues: Record<string, FormatValue> = Object.fromEntries(
43
48
  definition.variables.flatMap((variable) =>
44
49
  variable !== "symbol" && Object.hasOwn(values, variable) ? [[variable, values[variable]]] : [],
45
50
  ),
@@ -65,9 +70,15 @@ export function renderStatusline(
65
70
  };
66
71
  }
67
72
 
68
- function valueContext(config: StarshipConfig, name: ModuleName, runtime: StarshipRuntimeSnapshot): ModuleValueContext {
73
+ function valueContext(
74
+ config: StarshipConfig,
75
+ name: ModuleName,
76
+ runtime: StarshipRuntimeSnapshot,
77
+ palette: ColorPalette,
78
+ ): ModuleValueContext {
69
79
  return {
70
80
  runtime,
81
+ palette,
71
82
  symbol: config.modules[name].symbol,
72
83
  options: config.modules[name].options,
73
84
  extensionStatus: config.extensionStatus,
@@ -1,5 +1,6 @@
1
1
  import type { UIPromptKind } from "@earendil-works/pi-coding-agent";
2
- import type { StyledChunk } from "../format/style.js";
2
+ import type { FormatValue } from "../format/formatter.js";
3
+ import type { ColorPalette, StyledChunk } from "../format/style.js";
3
4
 
4
5
  export interface GitBranchSnapshot {
5
6
  name: string;
@@ -120,12 +121,14 @@ export interface ExtensionStatusPresentation {
120
121
  separator: string;
121
122
  maxStatuses: number;
122
123
  icons: Readonly<Record<string, string>>;
124
+ styles: Readonly<Record<string, string>>;
123
125
  }
124
126
 
125
127
  export type ModuleOptionValue = string | boolean | number | readonly string[] | Readonly<Record<string, string>>;
126
128
 
127
129
  export interface ModuleValueContext {
128
130
  runtime: StarshipRuntimeSnapshot;
131
+ palette: ColorPalette;
129
132
  symbol: string;
130
133
  options: Readonly<Record<string, ModuleOptionValue>>;
131
134
  extensionStatus: ExtensionStatusPresentation;
@@ -159,7 +162,6 @@ export interface ModuleDefaults {
159
162
 
160
163
  export interface ModuleStyleContext {
161
164
  runtime: StarshipRuntimeSnapshot;
162
- values: Readonly<Record<string, string>>;
163
165
  style: string;
164
166
  styles: Readonly<Record<string, string>>;
165
167
  display: readonly ModuleDisplayConfig[];
@@ -179,7 +181,7 @@ export interface ModuleDefinition<Name extends string> {
179
181
  resolveStyleVariables?(context: ModuleStyleContext): Readonly<Record<string, string>> | undefined;
180
182
  options?: Readonly<Record<string, ModuleOptionSchema>>;
181
183
  layout?: "fill";
182
- values(context: ModuleValueContext): Record<string, string> | undefined;
184
+ values(context: ModuleValueContext): Record<string, FormatValue> | undefined;
183
185
  }
184
186
 
185
187
  export function defineModule<const Name extends string>(definition: ModuleDefinition<Name>): ModuleDefinition<Name> {