@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.
package/README.md CHANGED
@@ -96,7 +96,9 @@ format = "$model$directory$git_branch"
96
96
  style = "bold blue"
97
97
  ```
98
98
 
99
- Provider, model, and thinking modules also accept ordered exact-match `style_rules`; see [Configuration and format](./skills/configuring-pi-starship/references/configuration.md).
99
+ Provider, model, and thinking modules also accept ordered exact-match `style_rules`.
100
+ For per-extension status colors, add `[extension_status.styles]` entries using raw Pi status keys (or `namespace:*`); unmatched statuses keep the module style.
101
+ See [Configuration and format](./skills/configuring-pi-starship/references/configuration.md) for examples and matching rules.
100
102
  Use `/starship` for interactive configuration, preview, diagnostics, presets, and recovery.
101
103
  Manual file edits load at the next `session_start`, including `/reload`.
102
104
 
@@ -1068,13 +1068,19 @@ var extensionStatusModule = defineModule({
1068
1068
  style: "dimmed white",
1069
1069
  disabled: false
1070
1070
  },
1071
- values: ({ runtime, extensionStatus }) => {
1072
- const statuses = [...runtime.extensionStatuses.entries()].filter(([key, value]) => key !== "starship" && value.trim()).map(([key, value]) => formatExtensionStatus(key, value, extensionStatus.icons)).slice(0, extensionStatus.maxStatuses);
1071
+ values: ({ runtime, extensionStatus, palette }) => {
1072
+ const statuses = [...runtime.extensionStatuses.entries()].filter(([key, value]) => key !== "starship" && value.trim()).slice(0, extensionStatus.maxStatuses).map(([key, value]) => ({ key, text: formatExtensionStatus(key, value, extensionStatus.icons) }));
1073
1073
  if (statuses.length === 0) return void 0;
1074
- return {
1075
- statuses: statuses.join(extensionStatus.separator),
1076
- count: `${statuses.length}`
1077
- };
1074
+ const { separator, styles } = extensionStatus;
1075
+ const content = Object.keys(styles).length === 0 ? statuses.map(({ text }) => text).join(separator) : statuses.flatMap(({ key, text }, index) => {
1076
+ const configured = configuredStatusValue(key, styles);
1077
+ const style = configured ?? (Object.hasOwn(styles, "fallback") ? styles.fallback : void 0);
1078
+ return [
1079
+ ...index > 0 ? [{ text: separator }] : [],
1080
+ { text, style: style === void 0 ? void 0 : parseStyle(style, palette) ?? {} }
1081
+ ];
1082
+ });
1083
+ return { statuses: content, count: `${statuses.length}` };
1078
1084
  }
1079
1085
  });
1080
1086
  function formatExtensionStatus(key, value, configuredIcons) {
@@ -1084,21 +1090,21 @@ function formatExtensionStatus(key, value, configuredIcons) {
1084
1090
  return icon ? `${icon} ${text}` : text;
1085
1091
  }
1086
1092
  function extensionStatusIcon(key, leadingIcon, configuredIcons) {
1087
- if (Object.hasOwn(configuredIcons, key)) return configuredIcons[key] ?? "";
1088
- const namespaceIcon = configuredNamespaceIcon(key, configuredIcons);
1089
- if (namespaceIcon !== void 0) return namespaceIcon;
1090
- const fallbackIcon = Object.hasOwn(configuredIcons, "fallback") ? configuredIcons.fallback : void 0;
1091
- return leadingIcon ?? fallbackIcon ?? "\u{1F50C}";
1093
+ const configured = configuredStatusValue(key, configuredIcons);
1094
+ if (configured !== void 0) return configured;
1095
+ const fallback = Object.hasOwn(configuredIcons, "fallback") ? configuredIcons.fallback : void 0;
1096
+ return leadingIcon ?? fallback ?? "\u{1F50C}";
1092
1097
  }
1093
- function configuredNamespaceIcon(key, configuredIcons) {
1098
+ function configuredStatusValue(key, configured) {
1099
+ if (Object.hasOwn(configured, key)) return configured[key];
1094
1100
  let match;
1095
- for (const [selector, icon] of Object.entries(configuredIcons)) {
1101
+ for (const [selector, value] of Object.entries(configured)) {
1096
1102
  if (!selector.endsWith(":*")) continue;
1097
1103
  const base = selector.slice(0, -2);
1098
1104
  if (!base || !key.startsWith(`${base}:`)) continue;
1099
- if (!match || base.length > match.baseLength) match = { baseLength: base.length, icon };
1105
+ if (!match || base.length > match.baseLength) match = { baseLength: base.length, value };
1100
1106
  }
1101
- return match?.icon;
1107
+ return match?.value;
1102
1108
  }
1103
1109
  function splitExtensionStatusIcon(value) {
1104
1110
  const trimmed = value.trim();
@@ -1437,6 +1443,7 @@ var modelModule = defineModule({
1437
1443
  model: ({ runtime }) => runtime.model?.id
1438
1444
  },
1439
1445
  options: {
1446
+ shorten_model: { kind: "boolean", default: false },
1440
1447
  truncation_length: { kind: "integer", default: 0, minimum: 0, maximum: 1e3 },
1441
1448
  truncation_symbol: { kind: "string", default: "\u2026" },
1442
1449
  truncation_direction: {
@@ -1454,8 +1461,9 @@ var modelModule = defineModule({
1454
1461
  const aliases = options.model_aliases;
1455
1462
  const aliasMap = aliases && typeof aliases === "object" && !Array.isArray(aliases) ? aliases : void 0;
1456
1463
  const alias = aliasMap && Object.hasOwn(aliasMap, runtime.model.id) ? aliasMap[runtime.model.id] : void 0;
1464
+ const model = alias ?? (options.shorten_model === true ? shortenModel(runtime.model.id) : runtime.model.id);
1457
1465
  return {
1458
- model: truncateModel(alias ?? shortenModel(runtime.model.id), length, symbol, direction)
1466
+ model: truncateModel(model, length, symbol, direction)
1459
1467
  };
1460
1468
  }
1461
1469
  });
@@ -1482,7 +1490,7 @@ function isTruncationDirection(value) {
1482
1490
  return TRUNCATION_DIRECTIONS.includes(value);
1483
1491
  }
1484
1492
  function shortenModel(model) {
1485
- return model.replace(/^claude-/u, "").replace(/^gpt-/u, "gpt ").replace(/-20\d{6}$/u, "").replace(/-latest$/u, "");
1493
+ return model.replace(/^claude-/u, "").replace(/-20\d{6}$/u, "").replace(/-latest$/u, "");
1486
1494
  }
1487
1495
 
1488
1496
  // src/modules/package.ts
@@ -1731,7 +1739,7 @@ var BUILT_IN_CONFIG = {
1731
1739
  palette: void 0,
1732
1740
  palettes: {},
1733
1741
  modules: BUILT_IN_MODULES,
1734
- extensionStatus: { separator: " \u2022 ", maxStatuses: 5, icons: {} }
1742
+ extensionStatus: { separator: " \u2022 ", maxStatuses: 5, icons: {}, styles: {} }
1735
1743
  };
1736
1744
  var BUILT_IN_EXAMPLE = `# Native Pi modules with Starship-compatible format and style syntax.
1737
1745
  ${BUILT_IN_FORMAT_DOCUMENT}
@@ -1892,6 +1900,7 @@ function normalizeModule(name, value, config, diagnostics) {
1892
1900
  known.add("separator");
1893
1901
  known.add("max_statuses");
1894
1902
  known.add("icons");
1903
+ known.add("styles");
1895
1904
  }
1896
1905
  for (const key of Object.keys(value)) {
1897
1906
  if (!known.has(key)) diagnostics.push(unknownDiagnostic(`${name}.${key}`));
@@ -1986,6 +1995,20 @@ function normalizeModule(name, value, config, diagnostics) {
1986
1995
  );
1987
1996
  }
1988
1997
  }
1998
+ if (value.styles !== void 0) {
1999
+ if (!isRecord(value.styles)) diagnostics.push(typeDiagnostic("extension_status.styles", "table"));
2000
+ else {
2001
+ config.extensionStatus.styles = Object.fromEntries(
2002
+ Object.entries(value.styles).flatMap(([key, style]) => {
2003
+ if (typeof style === "string" && isValidStyle(style, activePalette(config))) return [[key, style]];
2004
+ diagnostics.push(
2005
+ diagnostic("warning", `extension_status.styles.${key}`, "Expected a valid Starship style string; ignored")
2006
+ );
2007
+ return [];
2008
+ })
2009
+ );
2010
+ }
2011
+ }
1989
2012
  }
1990
2013
  function validateConfigDocument(settingsPath, rawDocument) {
1991
2014
  let parsed;
@@ -2078,7 +2101,8 @@ function cloneBuiltInConfig() {
2078
2101
  ),
2079
2102
  extensionStatus: {
2080
2103
  ...BUILT_IN_CONFIG.extensionStatus,
2081
- icons: { ...BUILT_IN_CONFIG.extensionStatus.icons }
2104
+ icons: { ...BUILT_IN_CONFIG.extensionStatus.icons },
2105
+ styles: { ...BUILT_IN_CONFIG.extensionStatus.styles }
2082
2106
  }
2083
2107
  };
2084
2108
  }
@@ -2316,11 +2340,10 @@ function renderStatusline(config, runtime, width = 80, trueColor = true) {
2316
2340
  for (const definition of MODULE_DEFINITIONS) {
2317
2341
  const name = definition.name;
2318
2342
  const module = config.modules[name];
2319
- const values = definition.values(valueContext(config, name, runtime));
2343
+ const values = definition.values(valueContext(config, name, runtime, palette));
2320
2344
  if (!values) continue;
2321
2345
  const styleContext = {
2322
2346
  runtime,
2323
- values,
2324
2347
  style: module.style,
2325
2348
  styles: module.styles,
2326
2349
  display: module.display
@@ -2352,9 +2375,10 @@ function renderStatusline(config, runtime, width = 80, trueColor = true) {
2352
2375
  modules
2353
2376
  };
2354
2377
  }
2355
- function valueContext(config, name, runtime) {
2378
+ function valueContext(config, name, runtime, palette) {
2356
2379
  return {
2357
2380
  runtime,
2381
+ palette,
2358
2382
  symbol: config.modules[name].symbol,
2359
2383
  options: config.modules[name].options,
2360
2384
  extensionStatus: config.extensionStatus
@@ -2536,4 +2560,4 @@ export {
2536
2560
  inspectStatuslineModules,
2537
2561
  inspectUnavailableModules
2538
2562
  };
2539
- //# sourceMappingURL=chunk-R7XUGJTZ.ts.map
2563
+ //# sourceMappingURL=chunk-MTFSZ63Q.ts.map