@narumitw/pi-starship 0.65.2 → 0.67.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 (32) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +9 -2
  3. package/dist/chunks/{chunk-PZWT7OTP.ts → chunk-URY35OTN.ts} +3 -3
  4. package/dist/chunks/{chunk-5YA3XF7S.ts → chunk-VK26JO5L.ts} +31 -3
  5. package/dist/chunks/chunk-VK26JO5L.ts.map +7 -0
  6. package/dist/chunks/{chunk-RQY2AYI2.ts → chunk-WZ2FWJHK.ts} +2 -2
  7. package/dist/chunks/{command-configuration-menu-JHKQ5SDW.ts → command-configuration-menu-3MMJJX4D.ts} +3 -3
  8. package/dist/chunks/{command-settings-chat-RN2GDMF5.ts → command-settings-chat-NB6YCNUD.ts} +4 -4
  9. package/dist/chunks/{commands-XIRYGV7S.ts → commands-HT6MGWJV.ts} +6 -6
  10. package/dist/index.ts +86 -34
  11. package/dist/index.ts.map +2 -2
  12. package/package.json +1 -1
  13. package/skills/configure-pi-starship/SKILL.md +3 -1
  14. package/skills/configure-pi-starship/references/configuration.md +81 -14
  15. package/skills/configure-pi-starship/references/module-catalog.md +22 -4
  16. package/skills/configure-pi-starship/references/modules.md +31 -1
  17. package/src/config.ts +2 -1
  18. package/src/modules/catalog.ts +4 -0
  19. package/src/modules/extension-status.ts +3 -2
  20. package/src/modules/inspection.ts +3 -2
  21. package/src/modules/render.ts +78 -31
  22. package/src/modules/tokens-per-second.ts +14 -0
  23. package/src/modules/types.ts +1 -0
  24. package/src/pi-starship.ts +4 -7
  25. package/src/root-references.ts +15 -0
  26. package/src/usage.ts +25 -0
  27. package/dist/chunks/chunk-5YA3XF7S.ts.map +0 -7
  28. /package/dist/chunks/{chunk-PZWT7OTP.ts.map → chunk-URY35OTN.ts.map} +0 -0
  29. /package/dist/chunks/{chunk-RQY2AYI2.ts.map → chunk-WZ2FWJHK.ts.map} +0 -0
  30. /package/dist/chunks/{command-configuration-menu-JHKQ5SDW.ts.map → command-configuration-menu-3MMJJX4D.ts.map} +0 -0
  31. /package/dist/chunks/{command-settings-chat-RN2GDMF5.ts.map → command-settings-chat-NB6YCNUD.ts.map} +0 -0
  32. /package/dist/chunks/{commands-XIRYGV7S.ts.map → commands-HT6MGWJV.ts.map} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  saveAsProfile,
8
8
  showHistory,
9
9
  showProfiles
10
- } from "./chunk-PZWT7OTP.ts";
10
+ } from "./chunk-URY35OTN.ts";
11
11
  import {
12
12
  STARSHIP_PRESETS,
13
13
  configurationPresentation,
@@ -15,7 +15,7 @@ import {
15
15
  presetForDocument,
16
16
  reloadConfiguration,
17
17
  showPreviewActionMenu
18
- } from "./chunk-RQY2AYI2.ts";
18
+ } from "./chunk-WZ2FWJHK.ts";
19
19
  import {
20
20
  STARSHIP_SUBCOMMANDS,
21
21
  completeStarshipArguments
@@ -27,7 +27,7 @@ import {
27
27
  nativeFooterConfig,
28
28
  readConfigDocumentSnapshot,
29
29
  validateConfigDocument
30
- } from "./chunk-5YA3XF7S.ts";
30
+ } from "./chunk-VK26JO5L.ts";
31
31
  import "./chunk-IYDZ3R2T.ts";
32
32
  import "./chunk-KP33I6BR.ts";
33
33
 
@@ -515,13 +515,13 @@ async function showMainMenu(ctx, options) {
515
515
  },
516
516
  actions: {
517
517
  "settings-chat": async () => {
518
- const { showSettingsAgentChat } = await import("./command-settings-chat-RN2GDMF5.ts");
518
+ const { showSettingsAgentChat } = await import("./command-settings-chat-NB6YCNUD.ts");
519
519
  if (!isCurrentOwner(owner)) return { kind: "close" };
520
520
  await showSettingsAgentChat(ctx, options, owner);
521
521
  return { kind: "close" };
522
522
  },
523
523
  configuration: async () => {
524
- const { showConfigurationMenu } = await import("./command-configuration-menu-JHKQ5SDW.ts");
524
+ const { showConfigurationMenu } = await import("./command-configuration-menu-3MMJJX4D.ts");
525
525
  if (!isCurrentOwner(owner)) return { kind: "close" };
526
526
  let selected;
527
527
  while (isCurrentOwner(owner)) {
@@ -1024,4 +1024,4 @@ export {
1024
1024
  registerStarshipCommand,
1025
1025
  reviewAndApply
1026
1026
  };
1027
- //# sourceMappingURL=commands-XIRYGV7S.ts.map
1027
+ //# sourceMappingURL=commands-HT6MGWJV.ts.map
package/dist/index.ts CHANGED
@@ -8,9 +8,11 @@ import {
8
8
  MODULE_NAMES,
9
9
  activePalette,
10
10
  directoryAlternateFormat,
11
+ extensionStatusKey,
11
12
  loadStarshipConfig,
13
+ referencesModule,
12
14
  settingsFilePath
13
- } from "./chunks/chunk-5YA3XF7S.ts";
15
+ } from "./chunks/chunk-VK26JO5L.ts";
14
16
  import "./chunks/chunk-IYDZ3R2T.ts";
15
17
  import {
16
18
  PRIVATE_STYLE_SELECTOR
@@ -473,6 +475,15 @@ function resolveStyleRule(rules, selectors, context) {
473
475
  // src/modules/render.ts
474
476
  function renderStatusline(config, runtime, width = 80, trueColor = true, themeColors) {
475
477
  const palette = activePalette(config);
478
+ const explicitModules = formatVariables(config.formatAst);
479
+ const statusReferences = new Map(
480
+ [...explicitModules].flatMap((reference) => {
481
+ const key = extensionStatusKey(reference);
482
+ return key === void 0 ? [] : [[reference, key]];
483
+ })
484
+ );
485
+ const selectedKeys = new Set(statusReferences.values());
486
+ const statusChunks = /* @__PURE__ */ new Map();
476
487
  const modules = {};
477
488
  const layoutModules = {};
478
489
  for (const name of MODULE_NAMES) {
@@ -483,40 +494,42 @@ function renderStatusline(config, runtime, width = 80, trueColor = true, themeCo
483
494
  const name = definition.name;
484
495
  const module = config.modules[name];
485
496
  const context = valueContext(config, name, runtime, palette);
486
- const values = definition.values(context);
487
- if (!values) continue;
488
- const styleContext = {
489
- runtime,
490
- style: module.style,
491
- styles: module.styles,
492
- display: module.display,
493
- options: context.options
494
- };
495
- const baseStyleVariables = definition.resolveStyleVariables ? definition.resolveStyleVariables(styleContext) : { style: module.style };
496
- if (!baseStyleVariables) continue;
497
- const ruleStyle = definition.styleRuleSelectors ? resolveStyleRule(module.styleRules, definition.styleRuleSelectors, styleContext) : void 0;
498
- const styleVariables = ruleStyle === void 0 ? baseStyleVariables : { ...baseStyleVariables, style: ruleStyle };
499
- const contentValues = Object.fromEntries(
500
- definition.variables.flatMap(
501
- (variable) => Object.hasOwn(values, variable) ? [[variable, values[variable]]] : []
502
- )
503
- );
504
- const alternate = definition.resolveFormat?.(context, values);
505
- const rendered = renderModule(
506
- alternate === void 0 ? module : { ...module, formatAst: parseFormat(alternate) },
507
- contentValues,
508
- styleVariables,
509
- palette
510
- );
497
+ if (name === "extension_status" && statusReferences.size > 0) {
498
+ const statuses = context.runtime.extensionStatuses;
499
+ for (const [reference, key] of statusReferences) {
500
+ const value = statuses.get(key);
501
+ const selected = new Map(value === void 0 ? [] : [[key, value]]);
502
+ statusChunks.set(
503
+ reference,
504
+ renderDefinition(
505
+ definition,
506
+ module,
507
+ { ...context, runtime: { ...context.runtime, extensionStatuses: selected } },
508
+ runtime
509
+ ) ?? []
510
+ );
511
+ }
512
+ context.runtime = {
513
+ ...context.runtime,
514
+ extensionStatuses: new Map([...statuses].filter(([key]) => !selectedKeys.has(key)))
515
+ };
516
+ }
517
+ const rendered = renderDefinition(definition, module, context, runtime);
518
+ if (!rendered) continue;
511
519
  modules[name] = rendered;
512
520
  layoutModules[name] = definition.layout === "fill" && !module.disabled ? [{ type: "fill", pattern: rendered }] : rendered;
513
521
  }
514
- const explicitModules = formatVariables(config.formatAst);
515
522
  const all = MODULE_NAMES.flatMap(
516
523
  (name) => explicitModules.has(name) || config.modules[name].disabled ? [] : layoutModules[name]
517
524
  );
518
525
  const rootVariables = { all };
519
526
  for (const name of MODULE_NAMES) rootVariables[name] = layoutModules[name];
527
+ for (const [reference, rendered] of statusChunks) rootVariables[reference] = rendered;
528
+ if (statusReferences.size > 0) {
529
+ modules.extension_status = [...explicitModules].flatMap(
530
+ (reference) => reference === "extension_status" || reference === "all" && !explicitModules.has("extension_status") ? modules.extension_status : statusChunks.get(reference) ?? []
531
+ );
532
+ }
520
533
  const layout = renderFormat(config.formatAst, { variables: rootVariables, palette });
521
534
  const chunks = resolveFillLayout(layout, width);
522
535
  return {
@@ -525,6 +538,31 @@ function renderStatusline(config, runtime, width = 80, trueColor = true, themeCo
525
538
  modules
526
539
  };
527
540
  }
541
+ function renderDefinition(definition, module, context, runtime) {
542
+ const values = definition.values(context);
543
+ if (!values) return void 0;
544
+ const styleContext = {
545
+ runtime,
546
+ style: module.style,
547
+ styles: module.styles,
548
+ display: module.display,
549
+ options: context.options
550
+ };
551
+ const baseStyleVariables = definition.resolveStyleVariables ? definition.resolveStyleVariables(styleContext) : { style: module.style };
552
+ if (!baseStyleVariables) return void 0;
553
+ const ruleStyle = definition.styleRuleSelectors ? resolveStyleRule(module.styleRules, definition.styleRuleSelectors, styleContext) : void 0;
554
+ const styleVariables = ruleStyle === void 0 ? baseStyleVariables : { ...baseStyleVariables, style: ruleStyle };
555
+ const contentValues = Object.fromEntries(
556
+ definition.variables.flatMap((variable) => Object.hasOwn(values, variable) ? [[variable, values[variable]]] : [])
557
+ );
558
+ const alternate = definition.resolveFormat?.(context, values);
559
+ return renderModule(
560
+ alternate === void 0 ? module : { ...module, formatAst: parseFormat(alternate) },
561
+ contentValues,
562
+ styleVariables,
563
+ context.palette
564
+ );
565
+ }
528
566
  function valueContext(config, name, runtime, palette) {
529
567
  return {
530
568
  runtime: runtimeForDisplay(name, runtime),
@@ -609,7 +647,7 @@ function reachableModuleRequirements(config) {
609
647
  const requirements = /* @__PURE__ */ new Map();
610
648
  for (const definition of MODULE_DEFINITIONS) {
611
649
  if (config.modules[definition.name].disabled) continue;
612
- if (!includeAll && !rootVariables.has(definition.name)) continue;
650
+ if (!includeAll && !referencesModule(rootVariables, definition.name)) continue;
613
651
  const variables = formatVariables(config.modules[definition.name].formatAst);
614
652
  if (definition.name === "directory") {
615
653
  const alternate = directoryAlternateFormat(config.modules.directory.options, config.modules.directory.styles);
@@ -691,7 +729,7 @@ function inspectStatuslineModules(config, runtime, width = 80) {
691
729
  definition,
692
730
  state,
693
731
  preview,
694
- includeAll || rootVariables.has(definition.name),
732
+ includeAll || referencesModule(rootVariables, definition.name),
695
733
  reachable
696
734
  );
697
735
  });
@@ -1181,6 +1219,21 @@ function freezeSnapshot(modules) {
1181
1219
  }
1182
1220
 
1183
1221
  // src/usage.ts
1222
+ function latestTokensPerSecond(branch) {
1223
+ for (let index = branch.length - 1; index >= 0; index -= 1) {
1224
+ const entry = branch[index];
1225
+ if (entry?.type !== "message" || entry.message.role !== "assistant") continue;
1226
+ const { stopReason, durationMs, usage } = entry.message;
1227
+ if (stopReason !== "stop" && stopReason !== "length" && stopReason !== "toolUse") return void 0;
1228
+ const output = usage?.output;
1229
+ if (typeof durationMs !== "number" || !Number.isFinite(durationMs) || durationMs <= 0 || typeof output !== "number" || !Number.isFinite(output) || output < 0) {
1230
+ return void 0;
1231
+ }
1232
+ const rate = output / (durationMs / 1e3);
1233
+ return Number.isFinite(rate) ? rate : void 0;
1234
+ }
1235
+ return void 0;
1236
+ }
1184
1237
  function summarizeFooterUsage(entries) {
1185
1238
  const totals = {
1186
1239
  input: 0,
@@ -1228,7 +1281,7 @@ var MAX_TIMER_DELAY_MS = 2147483647;
1228
1281
  var starshipCommandsPromise;
1229
1282
  function loadStarshipCommands() {
1230
1283
  if (!starshipCommandsPromise) {
1231
- starshipCommandsPromise = import("./chunks/commands-XIRYGV7S.ts").catch((error) => {
1284
+ starshipCommandsPromise = import("./chunks/commands-HT6MGWJV.ts").catch((error) => {
1232
1285
  starshipCommandsPromise = void 0;
1233
1286
  throw error;
1234
1287
  });
@@ -1793,19 +1846,21 @@ function safeUsername() {
1793
1846
  }
1794
1847
  }
1795
1848
  function runtimeSnapshot(ctx, footerData, runtime) {
1849
+ const branch = ctx.sessionManager.getBranch();
1796
1850
  return {
1797
1851
  cwd: ctx.cwd,
1798
1852
  homeDir: homedir(),
1799
1853
  gitRoot: runtime.git?.root,
1800
1854
  model: ctx.model ? { provider: ctx.model.provider, id: ctx.model.id } : void 0,
1801
1855
  thinkingLevel: runtime.thinkingLevel,
1802
- turnCount: userTurnCount(ctx),
1856
+ turnCount: branch.filter((entry) => entry.type === "message" && entry.message.role === "user").length,
1803
1857
  activeTools: runtime.activeTools,
1804
1858
  isStreaming: runtime.isStreaming,
1805
1859
  uiPrompt: runtime.uiPrompt,
1806
1860
  lastCompletedTool: runtime.lastCompletedTool,
1807
1861
  contextUsage: ctx.getContextUsage() ?? void 0,
1808
1862
  tokenTotals: summarizeFooterUsage(ctx.sessionManager.getEntries()),
1863
+ tokensPerSecond: latestTokensPerSecond(branch),
1809
1864
  usingSubscription: isSubscriptionBacked(ctx),
1810
1865
  gitBranch: runtime.git?.branch?.name ?? footerData.getGitBranch(),
1811
1866
  gitBranchDetails: runtime.git?.branch,
@@ -1820,9 +1875,6 @@ function runtimeSnapshot(ctx, footerData, runtime) {
1820
1875
  now: /* @__PURE__ */ new Date()
1821
1876
  };
1822
1877
  }
1823
- function userTurnCount(ctx) {
1824
- return ctx.sessionManager.getBranch().filter((entry) => entry.type === "message" && entry.message.role === "user").length;
1825
- }
1826
1878
  function isSubscriptionBacked(ctx) {
1827
1879
  const model = ctx.model;
1828
1880
  return model !== void 0 && (model.provider === "kimi-coding" || ctx.modelRegistry.isUsingOAuth(model));