@narumitw/pi-starship 0.52.3 → 0.55.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.
Files changed (43) hide show
  1. package/README.md +53 -622
  2. package/dist/chunks/{chunk-6D6VEVE5.js → chunk-UX6PBXVK.js} +125 -26
  3. package/dist/chunks/chunk-UX6PBXVK.js.map +7 -0
  4. package/dist/chunks/{cloud-GEBXIN43.js → cloud-BKHYWCTA.js} +3 -3
  5. package/dist/chunks/cloud-BKHYWCTA.js.map +7 -0
  6. package/dist/chunks/{commands-T73QN435.js → commands-53ZO2JUK.js} +3 -2
  7. package/dist/chunks/{commands-T73QN435.js.map → commands-53ZO2JUK.js.map} +2 -2
  8. package/dist/chunks/{development-TOXV7LWE.js → development-BERD42HW.js} +2 -2
  9. package/dist/chunks/{development-TOXV7LWE.js.map → development-BERD42HW.js.map} +2 -2
  10. package/dist/chunks/{execution-QDYHQKST.js → execution-42JTEY3N.js} +2 -2
  11. package/dist/chunks/{execution-QDYHQKST.js.map → execution-42JTEY3N.js.map} +2 -2
  12. package/dist/chunks/{languages-QR3XPRVQ.js → languages-RMP6DW7H.js} +2 -2
  13. package/dist/chunks/languages-RMP6DW7H.js.map +7 -0
  14. package/dist/index.ts +31 -10
  15. package/dist/index.ts.map +3 -3
  16. package/package.json +14 -12
  17. package/skills/configuring-pi-starship/SKILL.md +113 -0
  18. package/skills/configuring-pi-starship/references/configuration.md +365 -0
  19. package/skills/configuring-pi-starship/references/module-catalog.md +978 -0
  20. package/skills/configuring-pi-starship/references/modules.md +230 -0
  21. package/skills/configuring-pi-starship/references/runtime-and-security.md +213 -0
  22. package/skills/configuring-pi-starship/scripts/apply.mjs +64 -0
  23. package/skills/configuring-pi-starship/scripts/config-path.mjs +11 -0
  24. package/skills/configuring-pi-starship/scripts/script-support.mjs +20 -0
  25. package/skills/configuring-pi-starship/scripts/validate.mjs +30 -0
  26. package/src/config.ts +9 -0
  27. package/src/effective-config.ts +1 -0
  28. package/src/format/style.ts +14 -6
  29. package/src/modules/activity.ts +57 -4
  30. package/src/modules/catalog.ts +2 -2
  31. package/src/modules/provider.ts +19 -1
  32. package/src/modules/render.ts +2 -1
  33. package/src/modules/thinking.ts +24 -0
  34. package/src/modules/types.ts +3 -0
  35. package/src/pi-starship.ts +24 -3
  36. package/src/runtime/cloud.ts +3 -2
  37. package/src/runtime/development.ts +1 -1
  38. package/src/runtime/execution.ts +1 -1
  39. package/src/runtime/github-pr.ts +2 -1
  40. package/src/runtime/languages.ts +1 -1
  41. package/dist/chunks/chunk-6D6VEVE5.js.map +0 -7
  42. package/dist/chunks/cloud-GEBXIN43.js.map +0 -7
  43. package/dist/chunks/languages-QR3XPRVQ.js.map +0 -7
@@ -158,7 +158,7 @@ function parseColor(token, palette = {}) {
158
158
  blue: Number.parseInt(rgb[1].slice(4, 6), 16)
159
159
  };
160
160
  }
161
- function renderChunksToAnsi(chunks) {
161
+ function renderChunksToAnsi(chunks, trueColor = true) {
162
162
  const runs = [];
163
163
  let previous;
164
164
  for (const chunk of chunks) {
@@ -170,7 +170,7 @@ function renderChunksToAnsi(chunks) {
170
170
  previous = style;
171
171
  }
172
172
  return runs.map(({ text, style }) => {
173
- const codes = ansiCodes(style);
173
+ const codes = ansiCodes(style, trueColor);
174
174
  return codes.length > 0 ? `\x1B[${codes.join(";")}m${text}\x1B[0m` : text;
175
175
  }).join("");
176
176
  }
@@ -190,10 +190,10 @@ function resolveColor(fallback, source, previous) {
190
190
  if (!source || !previous) return fallback;
191
191
  return source === "foreground" ? previous.foreground : previous.background;
192
192
  }
193
- function ansiCodes(style) {
193
+ function ansiCodes(style, trueColor) {
194
194
  const codes = [];
195
- if (style.foreground) codes.push(...colorCodes(style.foreground, false));
196
- if (style.background) codes.push(...colorCodes(style.background, true));
195
+ if (style.foreground) codes.push(...colorCodes(style.foreground, false, trueColor));
196
+ if (style.background) codes.push(...colorCodes(style.background, true, trueColor));
197
197
  if (style.bold) codes.push("1");
198
198
  if (style.dimmed) codes.push("2");
199
199
  if (style.italic) codes.push("3");
@@ -204,14 +204,21 @@ function ansiCodes(style) {
204
204
  if (style.strikethrough) codes.push("9");
205
205
  return codes;
206
206
  }
207
- function colorCodes(color, background) {
207
+ function colorCodes(color, background, trueColor) {
208
208
  if (color.kind === "named") {
209
209
  const foreground = FOREGROUND_CODES[color.name];
210
210
  return [`${background ? foreground + 10 : foreground}`];
211
211
  }
212
212
  if (color.kind === "fixed") return [background ? "48" : "38", "5", `${color.value}`];
213
+ if (!trueColor) {
214
+ return [background ? "48" : "38", "5", `${rgbToAnsi256(color.red, color.green, color.blue)}`];
215
+ }
213
216
  return [background ? "48" : "38", "2", `${color.red}`, `${color.green}`, `${color.blue}`];
214
217
  }
218
+ function rgbToAnsi256(red, green, blue) {
219
+ const channels = [red, green, blue].map((value) => Math.round(value / 255 * 5));
220
+ return 16 + 36 * (channels[0] ?? 0) + 6 * (channels[1] ?? 0) + (channels[2] ?? 0);
221
+ }
215
222
 
216
223
  // src/format/formatter.ts
217
224
  var FormatSyntaxError = class extends Error {
@@ -433,22 +440,59 @@ function conditionalVisible(nodes, variables) {
433
440
  return false;
434
441
  }
435
442
 
443
+ // src/modules/activity.ts
444
+ import { sliceByColumn, visibleWidth } from "@earendil-works/pi-tui";
445
+ import { sanitizeTerminalText } from "@narumitw/pi-tui-kit/terminal-text";
446
+
436
447
  // src/modules/types.ts
437
448
  function defineModule(definition) {
438
449
  return definition;
439
450
  }
440
451
 
441
452
  // src/modules/activity.ts
453
+ var MAX_UI_PROMPT_TITLE_CODE_POINTS = 256;
454
+ var MAX_UI_PROMPT_TITLE_WIDTH = 40;
455
+ var EMPTY_PROMPT_VALUES = { kind: "", title: "" };
456
+ function boundUIPromptTitleLength(title) {
457
+ let end = 0;
458
+ let ellipsisEnd = 0;
459
+ let codePoints = 0;
460
+ while (end < title.length && codePoints < MAX_UI_PROMPT_TITLE_CODE_POINTS) {
461
+ const codePoint = title.codePointAt(end) ?? 0;
462
+ end += codePoint > 65535 ? 2 : 1;
463
+ codePoints += 1;
464
+ if (codePoints < MAX_UI_PROMPT_TITLE_CODE_POINTS) ellipsisEnd = end;
465
+ }
466
+ return end < title.length ? `${title.slice(0, ellipsisEnd)}\u2026` : title;
467
+ }
468
+ function formatUIPromptTitle(title) {
469
+ const safeTitle = title ? sanitizeTerminalText(title).trim() : "";
470
+ const boundedTitle = boundUIPromptTitleLength(safeTitle);
471
+ if (visibleWidth(boundedTitle) <= MAX_UI_PROMPT_TITLE_WIDTH) return boundedTitle;
472
+ return `${sliceByColumn(boundedTitle, 0, MAX_UI_PROMPT_TITLE_WIDTH - 1, true)}\u2026`;
473
+ }
442
474
  var activityModule = defineModule({
443
475
  name: "activity",
444
- variables: ["symbol", "state", "tool", "count", "text"],
476
+ variables: ["symbol", "state", "tool", "count", "kind", "title", "text"],
445
477
  defaults: {
446
478
  format: "[ $text ]($style)",
447
- symbol: "\u2699",
479
+ symbol: "\u2699\uFE0F",
448
480
  style: "bold yellow",
449
481
  disabled: false
450
482
  },
451
483
  values: ({ runtime, symbol }) => {
484
+ if (runtime.uiPrompt) {
485
+ const title = formatUIPromptTitle(runtime.uiPrompt.title);
486
+ const waiting = `waiting for ${runtime.uiPrompt.kind}${title ? ` \xB7 ${title}` : ""}`;
487
+ return {
488
+ state: "waiting",
489
+ tool: "",
490
+ count: "0",
491
+ kind: runtime.uiPrompt.kind,
492
+ title,
493
+ text: `${symbol} ${waiting}`
494
+ };
495
+ }
452
496
  const active = [...runtime.activeTools.entries()];
453
497
  if (active.length > 0) {
454
498
  const [tool = "tool", count2 = 1] = active[0] ?? [];
@@ -458,21 +502,35 @@ var activityModule = defineModule({
458
502
  state: "active",
459
503
  tool,
460
504
  count: `${count2}`,
505
+ ...EMPTY_PROMPT_VALUES,
461
506
  text: `${symbol} ${tool}${suffix}${more}`
462
507
  };
463
508
  }
464
509
  if (runtime.isStreaming) {
465
- return { state: "thinking", tool: "", count: "0", text: `${symbol} thinking` };
510
+ return {
511
+ state: "thinking",
512
+ tool: "",
513
+ count: "0",
514
+ ...EMPTY_PROMPT_VALUES,
515
+ text: `${symbol} thinking`
516
+ };
466
517
  }
467
518
  if (runtime.lastCompletedTool) {
468
519
  return {
469
520
  state: "completed",
470
521
  tool: runtime.lastCompletedTool,
471
522
  count: "0",
523
+ ...EMPTY_PROMPT_VALUES,
472
524
  text: `${symbol} completed ${runtime.lastCompletedTool}`
473
525
  };
474
526
  }
475
- return { state: "idle", tool: "", count: "0", text: `${symbol} idle` };
527
+ return {
528
+ state: "idle",
529
+ tool: "",
530
+ count: "0",
531
+ ...EMPTY_PROMPT_VALUES,
532
+ text: `${symbol} idle`
533
+ };
476
534
  }
477
535
  });
478
536
 
@@ -838,7 +896,7 @@ var developmentModules = [
838
896
 
839
897
  // src/modules/directory.ts
840
898
  import { basename, isAbsolute, relative, sep as sep2 } from "node:path";
841
- import { sanitizeTerminalText } from "@narumitw/pi-tui-kit/terminal-text";
899
+ import { sanitizeTerminalText as sanitizeTerminalText2 } from "@narumitw/pi-tui-kit/terminal-text";
842
900
  var directoryModule = defineModule({
843
901
  name: "directory",
844
902
  variables: ["symbol", "path", "full_path"],
@@ -866,7 +924,7 @@ var directoryModule = defineModule({
866
924
  const substitutions = mapOption(options, "substitutions");
867
925
  const homeContracted = contractPath(fullPath, home, homeSymbol);
868
926
  const repoContracted = truncateToRepo && repoRoot && (!home || !samePath(repoRoot, home)) ? contractRepositoryPath(fullPath, repoRoot) : void 0;
869
- let path = sanitizeTerminalText(repoContracted ?? homeContracted);
927
+ let path = sanitizeTerminalText2(repoContracted ?? homeContracted);
870
928
  let truncated = repoContracted !== void 0;
871
929
  for (const [from, to] of Object.entries(substitutions)) {
872
930
  if (from) path = path.replaceAll(from, to);
@@ -888,8 +946,8 @@ var directoryModule = defineModule({
888
946
  if (booleanOption(options, "use_os_path_sep", true)) path = useNativePathSeparator(path);
889
947
  const fallback = basename(fullPath) || fullPath;
890
948
  return {
891
- path: sanitizeTerminalText(path || fallback),
892
- full_path: sanitizeTerminalText(fullPath)
949
+ path: sanitizeTerminalText2(path || fallback),
950
+ full_path: sanitizeTerminalText2(fullPath)
893
951
  };
894
952
  }
895
953
  });
@@ -1387,7 +1445,7 @@ var languageModules = [
1387
1445
  ];
1388
1446
 
1389
1447
  // src/modules/model.ts
1390
- import { sanitizeTerminalText as sanitizeTerminalText2 } from "@narumitw/pi-tui-kit/terminal-text";
1448
+ import { sanitizeTerminalText as sanitizeTerminalText3 } from "@narumitw/pi-tui-kit/terminal-text";
1391
1449
  var TRUNCATION_DIRECTIONS = ["start", "middle", "end"];
1392
1450
  var graphemeSegmenter2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
1393
1451
  var modelModule = defineModule({
@@ -1423,11 +1481,11 @@ var modelModule = defineModule({
1423
1481
  }
1424
1482
  });
1425
1483
  function truncateModel(model, length, symbol, direction) {
1426
- const safeModel = sanitizeTerminalText2(model);
1484
+ const safeModel = sanitizeTerminalText3(model);
1427
1485
  if (length === 0) return safeModel;
1428
1486
  const graphemes2 = [...graphemeSegmenter2.segment(safeModel)].map(({ segment }) => segment);
1429
1487
  if (graphemes2.length <= length) return safeModel;
1430
- const safeSymbol = sanitizeTerminalText2(symbol);
1488
+ const safeSymbol = sanitizeTerminalText3(symbol);
1431
1489
  switch (direction) {
1432
1490
  case "start":
1433
1491
  return `${safeSymbol}${graphemes2.slice(-length).join("")}`;
@@ -1465,6 +1523,8 @@ var packageModule = defineModule({
1465
1523
  });
1466
1524
 
1467
1525
  // src/modules/provider.ts
1526
+ import { sanitizeTerminalText as sanitizeTerminalText4 } from "@narumitw/pi-tui-kit/terminal-text";
1527
+ var PROVIDER_ALIASES_KEY = "provider_aliases";
1468
1528
  var providerModule = defineModule({
1469
1529
  name: "provider",
1470
1530
  variables: ["symbol", "provider"],
@@ -1474,10 +1534,31 @@ var providerModule = defineModule({
1474
1534
  style: "bold blue",
1475
1535
  disabled: false
1476
1536
  },
1477
- values: ({ runtime }) => runtime.model ? { provider: runtime.model.provider } : void 0
1537
+ options: {
1538
+ [PROVIDER_ALIASES_KEY]: { kind: "string-map", default: {} }
1539
+ },
1540
+ values: ({ runtime, options }) => {
1541
+ if (!runtime.model) return void 0;
1542
+ const aliases = options[PROVIDER_ALIASES_KEY];
1543
+ const aliasMap = aliases && typeof aliases === "object" && !Array.isArray(aliases) ? aliases : void 0;
1544
+ const alias = aliasMap && Object.hasOwn(aliasMap, runtime.model.provider) ? aliasMap[runtime.model.provider] : void 0;
1545
+ return { provider: sanitizeTerminalText4(alias ?? runtime.model.provider) };
1546
+ }
1478
1547
  });
1479
1548
 
1480
1549
  // src/modules/thinking.ts
1550
+ var THINKING_LEVELS = [
1551
+ "off",
1552
+ "minimal",
1553
+ "low",
1554
+ "medium",
1555
+ "high",
1556
+ "xhigh",
1557
+ "max"
1558
+ ];
1559
+ function thinkingLevelOf(value) {
1560
+ return THINKING_LEVELS.find((level) => level === value);
1561
+ }
1481
1562
  var thinkingModule = defineModule({
1482
1563
  name: "thinking",
1483
1564
  variables: ["symbol", "level"],
@@ -1487,6 +1568,15 @@ var thinkingModule = defineModule({
1487
1568
  style: "bold purple",
1488
1569
  disabled: false
1489
1570
  },
1571
+ styleDefaults: Object.fromEntries(
1572
+ THINKING_LEVELS.map((level) => [`style_${level}`, ""])
1573
+ ),
1574
+ fallbackStyle: true,
1575
+ styleVariables: ["style"],
1576
+ resolveStyleVariables: ({ runtime, styles, style }) => {
1577
+ const level = thinkingLevelOf(runtime.thinkingLevel);
1578
+ return { style: level && styles[`style_${level}`] || style };
1579
+ },
1490
1580
  values: ({ runtime }) => ({ level: runtime.thinkingLevel })
1491
1581
  });
1492
1582
 
@@ -1568,7 +1658,7 @@ var MODULE_IMPLEMENTATIONS = [
1568
1658
  extensionStatusModule
1569
1659
  ];
1570
1660
  var MODULE_DESCRIPTIONS = {
1571
- activity: "Current Pi activity or most recently completed tool.",
1661
+ activity: "Current Pi activity, extension UI wait, or most recently completed tool.",
1572
1662
  aws: "Active AWS profile and region.",
1573
1663
  azure: "Active Azure subscription and optional username.",
1574
1664
  brand: "pi-starship brand mark.",
@@ -1602,7 +1692,7 @@ var MODULE_DESCRIPTIONS = {
1602
1692
  nodejs: "Node.js version detected in the current workspace.",
1603
1693
  openstack: "Active OpenStack cloud and project.",
1604
1694
  os: "Current operating system identity.",
1605
- package: "Current workspace package name and version.",
1695
+ package: "Current workspace package version and manifest source.",
1606
1696
  pixi: "Active Pixi environment and project.",
1607
1697
  provider: "Current Pi model provider.",
1608
1698
  python: "Python version, virtual environment, and pyenv state.",
@@ -1817,6 +1907,9 @@ function normalizeConfig(value) {
1817
1907
  );
1818
1908
  validateLiteralStyles(module.formatAst, palette, `${name}.format`, diagnostics);
1819
1909
  if (definition.styleDefaults) {
1910
+ if (definition.fallbackStyle) {
1911
+ validateModuleStyleField(name, "style", module, palette, diagnostics);
1912
+ }
1820
1913
  for (const field of Object.keys(definition.styleDefaults)) {
1821
1914
  validateModuleStyleField(name, field, module, palette, diagnostics);
1822
1915
  }
@@ -1832,6 +1925,7 @@ function normalizeModule(name, value, config, diagnostics) {
1832
1925
  const optionSchemas = definition.options ?? {};
1833
1926
  const known = /* @__PURE__ */ new Set(["format", "symbol", "disabled", ...Object.keys(optionSchemas)]);
1834
1927
  if (definition.styleDefaults) {
1928
+ if (definition.fallbackStyle) known.add("style");
1835
1929
  for (const field of Object.keys(definition.styleDefaults)) known.add(field);
1836
1930
  } else if (!definition.displayDefaults) known.add("style");
1837
1931
  if (definition.displayDefaults) known.add("display");
@@ -1867,6 +1961,11 @@ function normalizeModule(name, value, config, diagnostics) {
1867
1961
  diagnostics.push(typeDiagnostic(`${name}.symbol`, "string"));
1868
1962
  } else module.symbol = value.symbol;
1869
1963
  }
1964
+ if (definition.styleDefaults && definition.fallbackStyle && value.style !== void 0) {
1965
+ if (typeof value.style !== "string") {
1966
+ diagnostics.push(typeDiagnostic(`${name}.style`, "string"));
1967
+ } else module.style = value.style;
1968
+ }
1870
1969
  if (definition.styleDefaults) {
1871
1970
  for (const field of Object.keys(definition.styleDefaults)) {
1872
1971
  if (value[field] === void 0) continue;
@@ -2214,8 +2313,8 @@ function ownPalette(palettes, name) {
2214
2313
  import { stripVTControlCharacters } from "node:util";
2215
2314
 
2216
2315
  // src/modules/render.ts
2217
- import { visibleWidth } from "@earendil-works/pi-tui";
2218
- function renderStatusline(config, runtime, width = 80) {
2316
+ import { visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
2317
+ function renderStatusline(config, runtime, width = 80, trueColor = true) {
2219
2318
  const palette = activePalette(config);
2220
2319
  const modules = {};
2221
2320
  const layoutModules = {};
@@ -2254,7 +2353,7 @@ function renderStatusline(config, runtime, width = 80) {
2254
2353
  const layout = renderFormat(config.formatAst, { variables: rootVariables, palette });
2255
2354
  const chunks = resolveFillLayout(layout, width);
2256
2355
  return {
2257
- ansi: renderChunksToAnsi(chunks),
2356
+ ansi: renderChunksToAnsi(chunks, trueColor),
2258
2357
  chunks,
2259
2358
  modules
2260
2359
  };
@@ -2292,7 +2391,7 @@ function resolveFillLayout(layout, width) {
2292
2391
  for (const [lineIndex, line] of lines.entries()) {
2293
2392
  const fills = line.filter(isFillChunk);
2294
2393
  const fixedWidth = line.reduce(
2295
- (total, chunk) => total + (isFillChunk(chunk) ? 0 : visibleWidth(renderChunksToAnsi([chunk]))),
2394
+ (total, chunk) => total + (isFillChunk(chunk) ? 0 : visibleWidth2(renderChunksToAnsi([chunk]))),
2296
2395
  0
2297
2396
  );
2298
2397
  const remaining = Math.max(0, width - fixedWidth);
@@ -2328,7 +2427,7 @@ function splitLogicalLines(layout) {
2328
2427
  }
2329
2428
  function expandFill(pattern, width) {
2330
2429
  if (width <= 0) return [];
2331
- const patternWidth = visibleWidth(renderChunksToAnsi(pattern));
2430
+ const patternWidth = visibleWidth2(renderChunksToAnsi(pattern));
2332
2431
  if (patternWidth <= 0) return [{ text: " ".repeat(width), style: pattern[0]?.style }];
2333
2432
  const repetitions = Math.floor(width / patternWidth);
2334
2433
  const result = [];
@@ -2443,4 +2542,4 @@ export {
2443
2542
  inspectStatuslineModules,
2444
2543
  inspectUnavailableModules
2445
2544
  };
2446
- //# sourceMappingURL=chunk-6D6VEVE5.js.map
2545
+ //# sourceMappingURL=chunk-UX6PBXVK.js.map