@narumitw/pi-starship 0.55.1 → 0.56.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 (106) hide show
  1. package/README.md +2 -0
  2. package/dist/chunks/{chunk-UX6PBXVK.js → chunk-SD7TUSSU.js} +113 -113
  3. package/dist/chunks/chunk-SD7TUSSU.js.map +7 -0
  4. package/dist/chunks/{chunk-P4XMFSQW.js → chunk-YWY5RIDQ.js} +3 -7
  5. package/dist/chunks/chunk-YWY5RIDQ.js.map +7 -0
  6. package/dist/chunks/{chunk-EOGXAMTA.js → chunk-ZQZSXXPI.js} +1 -1
  7. package/dist/chunks/chunk-ZQZSXXPI.js.map +7 -0
  8. package/dist/chunks/{cloud-BKHYWCTA.js → cloud-C4VU3TX3.js} +7 -14
  9. package/dist/chunks/cloud-C4VU3TX3.js.map +7 -0
  10. package/dist/chunks/{commands-53ZO2JUK.js → commands-MJCAK6JL.js} +18 -42
  11. package/dist/chunks/commands-MJCAK6JL.js.map +7 -0
  12. package/dist/chunks/{deployment-RKKOEQQ2.js → deployment-FMNTYRBW.js} +6 -21
  13. package/dist/chunks/deployment-FMNTYRBW.js.map +7 -0
  14. package/dist/chunks/{development-BERD42HW.js → development-OUYXDPBS.js} +4 -8
  15. package/dist/chunks/development-OUYXDPBS.js.map +7 -0
  16. package/dist/chunks/{execution-42JTEY3N.js → execution-HJOGLMWD.js} +3 -3
  17. package/dist/chunks/execution-HJOGLMWD.js.map +7 -0
  18. package/dist/chunks/{languages-RMP6DW7H.js → languages-WXMF4GOF.js} +6 -22
  19. package/dist/chunks/languages-WXMF4GOF.js.map +7 -0
  20. package/dist/chunks/{package-LG5H7BBM.js → package-YXRZQAOV.js} +5 -14
  21. package/dist/chunks/package-YXRZQAOV.js.map +7 -0
  22. package/dist/index.ts +20 -55
  23. package/dist/index.ts.map +2 -2
  24. package/package.json +60 -61
  25. package/skills/configuring-pi-starship/SKILL.md +18 -4
  26. package/skills/configuring-pi-starship/references/configuration.md +70 -2
  27. package/skills/configuring-pi-starship/references/module-catalog.md +21 -0
  28. package/skills/configuring-pi-starship/references/modules.md +2 -0
  29. package/skills/configuring-pi-starship/scripts/apply.mjs +48 -47
  30. package/skills/configuring-pi-starship/scripts/backup.mjs +118 -0
  31. package/skills/configuring-pi-starship/scripts/config-path.mjs +3 -3
  32. package/skills/configuring-pi-starship/scripts/script-support.mjs +6 -6
  33. package/skills/configuring-pi-starship/scripts/validate.mjs +18 -18
  34. package/src/command-configuration.ts +267 -286
  35. package/src/command-contract.ts +6 -6
  36. package/src/command-inspector.ts +27 -27
  37. package/src/command-preset-picker.ts +45 -50
  38. package/src/command-preview.ts +153 -166
  39. package/src/commands.ts +590 -618
  40. package/src/config.ts +635 -660
  41. package/src/effective-config.ts +49 -48
  42. package/src/format/formatter.ts +211 -227
  43. package/src/format/style.ts +205 -216
  44. package/src/modules/activity.ts +74 -74
  45. package/src/modules/brand.ts +9 -9
  46. package/src/modules/cache.ts +18 -18
  47. package/src/modules/catalog.ts +79 -83
  48. package/src/modules/cloud.ts +54 -54
  49. package/src/modules/context.ts +27 -27
  50. package/src/modules/cost.ts +23 -23
  51. package/src/modules/deployment.ts +45 -45
  52. package/src/modules/development.ts +80 -81
  53. package/src/modules/directory.ts +89 -113
  54. package/src/modules/display.ts +9 -9
  55. package/src/modules/execution.ts +62 -69
  56. package/src/modules/extension-status.ts +59 -64
  57. package/src/modules/fill.ts +10 -10
  58. package/src/modules/git/branch.ts +26 -26
  59. package/src/modules/git/commit.ts +21 -23
  60. package/src/modules/git/metrics.ts +22 -22
  61. package/src/modules/git/runtime.ts +299 -334
  62. package/src/modules/git/state.ts +17 -17
  63. package/src/modules/git/status.ts +77 -79
  64. package/src/modules/git/worktree.ts +10 -12
  65. package/src/modules/github-pr.ts +20 -20
  66. package/src/modules/helpers.ts +3 -3
  67. package/src/modules/index.ts +21 -21
  68. package/src/modules/inspection.ts +105 -108
  69. package/src/modules/languages.ts +52 -59
  70. package/src/modules/model.ts +61 -67
  71. package/src/modules/package.ts +12 -12
  72. package/src/modules/provider.ts +25 -24
  73. package/src/modules/render.ts +131 -141
  74. package/src/modules/style-rules.ts +21 -0
  75. package/src/modules/thinking.ts +31 -26
  76. package/src/modules/time.ts +10 -13
  77. package/src/modules/tokens.ts +13 -13
  78. package/src/modules/truncation.ts +14 -17
  79. package/src/modules/turn.ts +9 -9
  80. package/src/modules/types.ts +133 -132
  81. package/src/modules/workspace-helpers.ts +4 -7
  82. package/src/pi-starship.ts +567 -603
  83. package/src/presets/catalog.ts +113 -113
  84. package/src/runtime/cloud.ts +122 -150
  85. package/src/runtime/command.ts +106 -108
  86. package/src/runtime/deployment.ts +150 -179
  87. package/src/runtime/development.ts +107 -124
  88. package/src/runtime/execution.ts +110 -124
  89. package/src/runtime/github-pr.ts +223 -252
  90. package/src/runtime/helpers.ts +186 -199
  91. package/src/runtime/languages.ts +149 -180
  92. package/src/runtime/package.ts +74 -87
  93. package/src/runtime/refresh-controller.ts +82 -86
  94. package/src/runtime/types.ts +38 -38
  95. package/src/runtime/workspace.ts +108 -116
  96. package/src/usage.ts +40 -40
  97. package/dist/chunks/chunk-EOGXAMTA.js.map +0 -7
  98. package/dist/chunks/chunk-P4XMFSQW.js.map +0 -7
  99. package/dist/chunks/chunk-UX6PBXVK.js.map +0 -7
  100. package/dist/chunks/cloud-BKHYWCTA.js.map +0 -7
  101. package/dist/chunks/commands-53ZO2JUK.js.map +0 -7
  102. package/dist/chunks/deployment-RKKOEQQ2.js.map +0 -7
  103. package/dist/chunks/development-BERD42HW.js.map +0 -7
  104. package/dist/chunks/execution-42JTEY3N.js.map +0 -7
  105. package/dist/chunks/languages-RMP6DW7H.js.map +0 -7
  106. package/dist/chunks/package-LG5H7BBM.js.map +0 -7
@@ -1,167 +1,157 @@
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 {
5
- isFillChunk,
6
- type LayoutChunk,
7
- renderChunksToAnsi,
8
- type StyledChunk,
9
- } from "../format/style.js";
4
+ import { isFillChunk, type LayoutChunk, renderChunksToAnsi, type StyledChunk } from "../format/style.js";
10
5
  import { MODULE_DEFINITIONS, MODULE_NAMES, type ModuleName } from "./catalog.js";
11
- import type { ModuleValueContext, RenderedStatusline, StarshipRuntimeSnapshot } from "./types.js";
6
+ import { resolveStyleRule } from "./style-rules.js";
7
+ import type { ModuleStyleContext, ModuleValueContext, RenderedStatusline, StarshipRuntimeSnapshot } from "./types.js";
12
8
 
13
9
  export function renderStatusline(
14
- config: StarshipConfig,
15
- runtime: StarshipRuntimeSnapshot,
16
- width = 80,
17
- trueColor = true,
10
+ config: StarshipConfig,
11
+ runtime: StarshipRuntimeSnapshot,
12
+ width = 80,
13
+ trueColor = true,
18
14
  ): RenderedStatusline<ModuleName> {
19
- const palette = activePalette(config);
20
- const modules = {} as Record<ModuleName, StyledChunk[]>;
21
- const layoutModules = {} as Record<ModuleName, LayoutChunk[]>;
22
- for (const name of MODULE_NAMES) {
23
- modules[name] = [];
24
- layoutModules[name] = [];
25
- }
26
- for (const definition of MODULE_DEFINITIONS) {
27
- const name = definition.name;
28
- const module = config.modules[name];
29
- const values = definition.values(valueContext(config, name, runtime));
30
- if (!values) continue;
31
- const styleVariables = definition.resolveStyleVariables
32
- ? definition.resolveStyleVariables({
33
- runtime,
34
- values,
35
- style: module.style,
36
- styles: module.styles,
37
- display: module.display,
38
- })
39
- : { style: module.style };
40
- if (!styleVariables) continue;
41
- const contentValues = Object.fromEntries(
42
- definition.variables.flatMap((variable) =>
43
- variable !== "symbol" && Object.hasOwn(values, variable)
44
- ? [[variable, values[variable]]]
45
- : [],
46
- ),
47
- );
48
- const rendered = renderModule(module, contentValues, styleVariables, palette);
49
- modules[name] = rendered;
50
- layoutModules[name] =
51
- definition.layout === "fill" && !module.disabled
52
- ? [{ type: "fill", pattern: rendered }]
53
- : rendered;
54
- }
15
+ const palette = activePalette(config);
16
+ const modules = {} as Record<ModuleName, StyledChunk[]>;
17
+ const layoutModules = {} as Record<ModuleName, LayoutChunk[]>;
18
+ for (const name of MODULE_NAMES) {
19
+ modules[name] = [];
20
+ layoutModules[name] = [];
21
+ }
22
+ for (const definition of MODULE_DEFINITIONS) {
23
+ const name = definition.name;
24
+ const module = config.modules[name];
25
+ const values = definition.values(valueContext(config, name, runtime));
26
+ if (!values) continue;
27
+ const styleContext: ModuleStyleContext = {
28
+ runtime,
29
+ values,
30
+ style: module.style,
31
+ styles: module.styles,
32
+ display: module.display,
33
+ };
34
+ const baseStyleVariables = definition.resolveStyleVariables
35
+ ? definition.resolveStyleVariables(styleContext)
36
+ : { style: module.style };
37
+ if (!baseStyleVariables) continue;
38
+ const ruleStyle = definition.styleRuleSelectors
39
+ ? resolveStyleRule(module.styleRules, definition.styleRuleSelectors, styleContext)
40
+ : undefined;
41
+ const styleVariables = ruleStyle === undefined ? baseStyleVariables : { ...baseStyleVariables, style: ruleStyle };
42
+ const contentValues = Object.fromEntries(
43
+ definition.variables.flatMap((variable) =>
44
+ variable !== "symbol" && Object.hasOwn(values, variable) ? [[variable, values[variable]]] : [],
45
+ ),
46
+ );
47
+ const rendered = renderModule(module, contentValues, styleVariables, palette);
48
+ modules[name] = rendered;
49
+ layoutModules[name] =
50
+ definition.layout === "fill" && !module.disabled ? [{ type: "fill", pattern: rendered }] : rendered;
51
+ }
55
52
 
56
- const explicitModules = formatVariables(config.formatAst);
57
- const all = MODULE_NAMES.flatMap((name) =>
58
- explicitModules.has(name) || config.modules[name].disabled ? [] : layoutModules[name],
59
- );
60
- const rootVariables: Record<string, FormatValue> = { all };
61
- for (const name of MODULE_NAMES) rootVariables[name] = layoutModules[name];
62
- const layout = renderFormat(config.formatAst, { variables: rootVariables, palette });
63
- const chunks = resolveFillLayout(layout, width);
64
- return {
65
- ansi: renderChunksToAnsi(chunks, trueColor),
66
- chunks,
67
- modules,
68
- };
53
+ const explicitModules = formatVariables(config.formatAst);
54
+ const all = MODULE_NAMES.flatMap((name) =>
55
+ explicitModules.has(name) || config.modules[name].disabled ? [] : layoutModules[name],
56
+ );
57
+ const rootVariables: Record<string, FormatValue> = { all };
58
+ for (const name of MODULE_NAMES) rootVariables[name] = layoutModules[name];
59
+ const layout = renderFormat(config.formatAst, { variables: rootVariables, palette });
60
+ const chunks = resolveFillLayout(layout, width);
61
+ return {
62
+ ansi: renderChunksToAnsi(chunks, trueColor),
63
+ chunks,
64
+ modules,
65
+ };
69
66
  }
70
67
 
71
- function valueContext(
72
- config: StarshipConfig,
73
- name: ModuleName,
74
- runtime: StarshipRuntimeSnapshot,
75
- ): ModuleValueContext {
76
- return {
77
- runtime,
78
- symbol: config.modules[name].symbol,
79
- options: config.modules[name].options,
80
- extensionStatus: config.extensionStatus,
81
- };
68
+ function valueContext(config: StarshipConfig, name: ModuleName, runtime: StarshipRuntimeSnapshot): ModuleValueContext {
69
+ return {
70
+ runtime,
71
+ symbol: config.modules[name].symbol,
72
+ options: config.modules[name].options,
73
+ extensionStatus: config.extensionStatus,
74
+ };
82
75
  }
83
76
 
84
77
  function renderModule(
85
- module: ModuleConfig,
86
- values: Readonly<Record<string, FormatValue>>,
87
- styleVariables: Readonly<Record<string, string>>,
88
- palette: Readonly<Record<string, string>>,
78
+ module: ModuleConfig,
79
+ values: Readonly<Record<string, FormatValue>>,
80
+ styleVariables: Readonly<Record<string, string>>,
81
+ palette: Readonly<Record<string, string>>,
89
82
  ): StyledChunk[] {
90
- if (module.disabled) return [];
91
- return renderFormat(module.formatAst, {
92
- variables: { symbol: module.symbol, ...values },
93
- styleVariables,
94
- palette,
95
- }).filter((chunk): chunk is StyledChunk => !isFillChunk(chunk));
83
+ if (module.disabled) return [];
84
+ return renderFormat(module.formatAst, {
85
+ variables: { symbol: module.symbol, ...values },
86
+ styleVariables,
87
+ palette,
88
+ }).filter((chunk): chunk is StyledChunk => !isFillChunk(chunk));
96
89
  }
97
90
 
98
- export function reachableModuleRequirements(
99
- config: StarshipConfig,
100
- ): ReadonlyMap<ModuleName, ReadonlySet<string>> {
101
- const rootVariables = formatVariables(config.formatAst);
102
- const includeAll = rootVariables.has("all");
103
- const requirements = new Map<ModuleName, ReadonlySet<string>>();
104
- for (const definition of MODULE_DEFINITIONS) {
105
- if (config.modules[definition.name].disabled) continue;
106
- if (!includeAll && !rootVariables.has(definition.name)) continue;
107
- requirements.set(definition.name, formatVariables(config.modules[definition.name].formatAst));
108
- }
109
- return requirements;
91
+ export function reachableModuleRequirements(config: StarshipConfig): ReadonlyMap<ModuleName, ReadonlySet<string>> {
92
+ const rootVariables = formatVariables(config.formatAst);
93
+ const includeAll = rootVariables.has("all");
94
+ const requirements = new Map<ModuleName, ReadonlySet<string>>();
95
+ for (const definition of MODULE_DEFINITIONS) {
96
+ if (config.modules[definition.name].disabled) continue;
97
+ if (!includeAll && !rootVariables.has(definition.name)) continue;
98
+ requirements.set(definition.name, formatVariables(config.modules[definition.name].formatAst));
99
+ }
100
+ return requirements;
110
101
  }
111
102
 
112
103
  function resolveFillLayout(layout: readonly LayoutChunk[], width: number): StyledChunk[] {
113
- const lines = splitLogicalLines(layout);
114
- const resolved: StyledChunk[] = [];
115
- for (const [lineIndex, line] of lines.entries()) {
116
- const fills = line.filter(isFillChunk);
117
- const fixedWidth = line.reduce(
118
- (total, chunk) =>
119
- total + (isFillChunk(chunk) ? 0 : visibleWidth(renderChunksToAnsi([chunk]))),
120
- 0,
121
- );
122
- const remaining = Math.max(0, width - fixedWidth);
123
- const base = fills.length > 0 ? Math.floor(remaining / fills.length) : 0;
124
- let remainder = fills.length > 0 ? remaining % fills.length : 0;
125
- for (const chunk of line) {
126
- if (!isFillChunk(chunk)) {
127
- resolved.push(chunk);
128
- continue;
129
- }
130
- const allocation = base + (remainder > 0 ? 1 : 0);
131
- if (remainder > 0) remainder -= 1;
132
- resolved.push(...expandFill(chunk.pattern, allocation));
133
- }
134
- if (lineIndex < lines.length - 1) resolved.push({ text: "\n" });
135
- }
136
- return resolved;
104
+ const lines = splitLogicalLines(layout);
105
+ const resolved: StyledChunk[] = [];
106
+ for (const [lineIndex, line] of lines.entries()) {
107
+ const fills = line.filter(isFillChunk);
108
+ const fixedWidth = line.reduce(
109
+ (total, chunk) => total + (isFillChunk(chunk) ? 0 : visibleWidth(renderChunksToAnsi([chunk]))),
110
+ 0,
111
+ );
112
+ const remaining = Math.max(0, width - fixedWidth);
113
+ const base = fills.length > 0 ? Math.floor(remaining / fills.length) : 0;
114
+ let remainder = fills.length > 0 ? remaining % fills.length : 0;
115
+ for (const chunk of line) {
116
+ if (!isFillChunk(chunk)) {
117
+ resolved.push(chunk);
118
+ continue;
119
+ }
120
+ const allocation = base + (remainder > 0 ? 1 : 0);
121
+ if (remainder > 0) remainder -= 1;
122
+ resolved.push(...expandFill(chunk.pattern, allocation));
123
+ }
124
+ if (lineIndex < lines.length - 1) resolved.push({ text: "\n" });
125
+ }
126
+ return resolved;
137
127
  }
138
128
 
139
129
  function splitLogicalLines(layout: readonly LayoutChunk[]): LayoutChunk[][] {
140
- const lines: LayoutChunk[][] = [[]];
141
- for (const chunk of layout) {
142
- if (isFillChunk(chunk)) {
143
- lines.at(-1)?.push(chunk);
144
- continue;
145
- }
146
- const parts = chunk.text.split("\n");
147
- for (const [index, text] of parts.entries()) {
148
- if (text) lines.at(-1)?.push({ ...chunk, text });
149
- if (index < parts.length - 1) lines.push([]);
150
- }
151
- }
152
- return lines;
130
+ const lines: LayoutChunk[][] = [[]];
131
+ for (const chunk of layout) {
132
+ if (isFillChunk(chunk)) {
133
+ lines.at(-1)?.push(chunk);
134
+ continue;
135
+ }
136
+ const parts = chunk.text.split("\n");
137
+ for (const [index, text] of parts.entries()) {
138
+ if (text) lines.at(-1)?.push({ ...chunk, text });
139
+ if (index < parts.length - 1) lines.push([]);
140
+ }
141
+ }
142
+ return lines;
153
143
  }
154
144
 
155
145
  function expandFill(pattern: readonly StyledChunk[], width: number): StyledChunk[] {
156
- if (width <= 0) return [];
157
- const patternWidth = visibleWidth(renderChunksToAnsi(pattern));
158
- if (patternWidth <= 0) return [{ text: " ".repeat(width), style: pattern[0]?.style }];
159
- const repetitions = Math.floor(width / patternWidth);
160
- const result: StyledChunk[] = [];
161
- for (let index = 0; index < repetitions; index += 1) {
162
- result.push(...pattern.map((chunk) => ({ ...chunk })));
163
- }
164
- const remainder = width - repetitions * patternWidth;
165
- if (remainder > 0) result.push({ text: " ".repeat(remainder), style: pattern.at(-1)?.style });
166
- return result;
146
+ if (width <= 0) return [];
147
+ const patternWidth = visibleWidth(renderChunksToAnsi(pattern));
148
+ if (patternWidth <= 0) return [{ text: " ".repeat(width), style: pattern[0]?.style }];
149
+ const repetitions = Math.floor(width / patternWidth);
150
+ const result: StyledChunk[] = [];
151
+ for (let index = 0; index < repetitions; index += 1) {
152
+ result.push(...pattern.map((chunk) => ({ ...chunk })));
153
+ }
154
+ const remainder = width - repetitions * patternWidth;
155
+ if (remainder > 0) result.push({ text: " ".repeat(remainder), style: pattern.at(-1)?.style });
156
+ return result;
167
157
  }
@@ -0,0 +1,21 @@
1
+ import type { ModuleStyleContext, ModuleStyleRule, ModuleStyleSelector } from "./types.js";
2
+
3
+ export function resolveStyleRule(
4
+ rules: readonly ModuleStyleRule[],
5
+ selectors: Readonly<Record<string, ModuleStyleSelector>>,
6
+ context: ModuleStyleContext,
7
+ ): string | undefined {
8
+ for (const rule of rules) {
9
+ let matches = true;
10
+ for (const name in rule.selectors) {
11
+ if (!Object.hasOwn(rule.selectors, name)) continue;
12
+ const selector = Object.hasOwn(selectors, name) ? selectors[name] : undefined;
13
+ if (!selector || selector(context) !== rule.selectors[name]) {
14
+ matches = false;
15
+ break;
16
+ }
17
+ }
18
+ if (matches) return rule.style;
19
+ }
20
+ return undefined;
21
+ }
@@ -2,36 +2,41 @@ import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
2
2
  import { defineModule } from "./types.js";
3
3
 
4
4
  const THINKING_LEVELS = [
5
- "off",
6
- "minimal",
7
- "low",
8
- "medium",
9
- "high",
10
- "xhigh",
11
- "max",
5
+ "off",
6
+ "minimal",
7
+ "low",
8
+ "medium",
9
+ "high",
10
+ "xhigh",
11
+ "max",
12
12
  ] as const satisfies readonly ThinkingLevel[];
13
13
 
14
14
  function thinkingLevelOf(value: string): ThinkingLevel | undefined {
15
- return THINKING_LEVELS.find((level) => level === value);
15
+ return THINKING_LEVELS.find((level) => level === value);
16
16
  }
17
17
 
18
18
  export const thinkingModule = defineModule({
19
- name: "thinking",
20
- variables: ["symbol", "level"],
21
- defaults: {
22
- format: "[$symbol $level ]($style)",
23
- symbol: "🧠",
24
- style: "bold purple",
25
- disabled: false,
26
- },
27
- styleDefaults: Object.fromEntries(
28
- THINKING_LEVELS.map((level) => [`style_${level}`, ""]),
29
- ) as Record<`style_${ThinkingLevel}`, string>,
30
- fallbackStyle: true,
31
- styleVariables: ["style"],
32
- resolveStyleVariables: ({ runtime, styles, style }) => {
33
- const level = thinkingLevelOf(runtime.thinkingLevel);
34
- return { style: (level && styles[`style_${level}`]) || style };
35
- },
36
- values: ({ runtime }) => ({ level: runtime.thinkingLevel }),
19
+ name: "thinking",
20
+ variables: ["symbol", "level"],
21
+ defaults: {
22
+ format: "[$symbol $level ]($style)",
23
+ symbol: "🧠",
24
+ style: "bold purple",
25
+ disabled: false,
26
+ },
27
+ styleDefaults: Object.fromEntries(THINKING_LEVELS.map((level) => [`style_${level}`, ""])) as Record<
28
+ `style_${ThinkingLevel}`,
29
+ string
30
+ >,
31
+ fallbackStyle: true,
32
+ styleVariables: ["style"],
33
+ styleRuleSelectors: {
34
+ provider: ({ runtime }) => runtime.model?.provider,
35
+ level: ({ runtime }) => runtime.thinkingLevel,
36
+ },
37
+ resolveStyleVariables: ({ runtime, styles, style }) => {
38
+ const level = thinkingLevelOf(runtime.thinkingLevel);
39
+ return { style: (level && styles[`style_${level}`]) || style };
40
+ },
41
+ values: ({ runtime }) => ({ level: runtime.thinkingLevel }),
37
42
  });
@@ -1,20 +1,17 @@
1
1
  import { defineModule } from "./types.js";
2
2
 
3
3
  export const timeModule = defineModule({
4
- name: "time",
5
- variables: ["symbol", "time"],
6
- defaults: {
7
- format: "[$symbol $time ]($style)",
8
- symbol: "🕒",
9
- style: "bold yellow",
10
- disabled: false,
11
- },
12
- values: ({ runtime }) => ({ time: formatTime(runtime.now) }),
4
+ name: "time",
5
+ variables: ["symbol", "time"],
6
+ defaults: {
7
+ format: "[$symbol $time ]($style)",
8
+ symbol: "🕒",
9
+ style: "bold yellow",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ time: formatTime(runtime.now) }),
13
13
  });
14
14
 
15
15
  function formatTime(now: Date): string {
16
- return `${now.getHours().toString().padStart(2, "0")}:${now
17
- .getMinutes()
18
- .toString()
19
- .padStart(2, "0")}`;
16
+ return `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}`;
20
17
  }
@@ -2,17 +2,17 @@ import { formatCount } from "./helpers.js";
2
2
  import { defineModule } from "./types.js";
3
3
 
4
4
  export const tokensModule = defineModule({
5
- name: "tokens",
6
- variables: ["symbol", "input", "output", "total"],
7
- defaults: {
8
- format: "[$symbol ↑$input ↓$output ]($style)",
9
- symbol: "🔢",
10
- style: "bold cyan",
11
- disabled: false,
12
- },
13
- values: ({ runtime }) => ({
14
- input: formatCount(runtime.tokenTotals.input),
15
- output: formatCount(runtime.tokenTotals.output),
16
- total: formatCount(runtime.tokenTotals.input + runtime.tokenTotals.output),
17
- }),
5
+ name: "tokens",
6
+ variables: ["symbol", "input", "output", "total"],
7
+ defaults: {
8
+ format: "[$symbol ↑$input ↓$output ]($style)",
9
+ symbol: "🔢",
10
+ style: "bold cyan",
11
+ disabled: false,
12
+ },
13
+ values: ({ runtime }) => ({
14
+ input: formatCount(runtime.tokenTotals.input),
15
+ output: formatCount(runtime.tokenTotals.output),
16
+ total: formatCount(runtime.tokenTotals.input + runtime.tokenTotals.output),
17
+ }),
18
18
  });
@@ -3,35 +3,32 @@ import { sep } from "node:path";
3
3
  const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
4
4
 
5
5
  export function graphemes(value: string): string[] {
6
- return [...graphemeSegmenter.segment(value)].map(({ segment }) => segment);
6
+ return [...graphemeSegmenter.segment(value)].map(({ segment }) => segment);
7
7
  }
8
8
 
9
9
  export function firstGrapheme(value: string): string {
10
- return graphemes(value)[0] ?? "";
10
+ return graphemes(value)[0] ?? "";
11
11
  }
12
12
 
13
13
  export function truncateLeadingGraphemes(value: string, length: number, symbol: string): string {
14
- if (length <= 0) return value;
15
- const parts = graphemes(value);
16
- if (parts.length <= length) return value;
17
- return `${parts.slice(0, length).join("")}${firstGrapheme(symbol)}`;
14
+ if (length <= 0) return value;
15
+ const parts = graphemes(value);
16
+ if (parts.length <= length) return value;
17
+ return `${parts.slice(0, length).join("")}${firstGrapheme(symbol)}`;
18
18
  }
19
19
 
20
20
  export function toSlashPath(value: string): string {
21
- return sep === "\\" ? value.replaceAll("\\", "/") : value;
21
+ return sep === "\\" ? value.replaceAll("\\", "/") : value;
22
22
  }
23
23
 
24
- export function truncatePathComponents(
25
- value: string,
26
- length: number,
27
- ): { value: string; truncated: boolean } {
28
- if (length <= 0) return { value, truncated: false };
29
- const normalized = toSlashPath(value);
30
- const components = normalized.split("/").filter((component) => component.length > 0);
31
- if (components.length <= length) return { value: normalized, truncated: false };
32
- return { value: components.slice(-length).join("/"), truncated: true };
24
+ export function truncatePathComponents(value: string, length: number): { value: string; truncated: boolean } {
25
+ if (length <= 0) return { value, truncated: false };
26
+ const normalized = toSlashPath(value);
27
+ const components = normalized.split("/").filter((component) => component.length > 0);
28
+ if (components.length <= length) return { value: normalized, truncated: false };
29
+ return { value: components.slice(-length).join("/"), truncated: true };
33
30
  }
34
31
 
35
32
  export function useNativePathSeparator(value: string): string {
36
- return sep === "/" ? value : value.replaceAll("/", sep);
33
+ return sep === "/" ? value : value.replaceAll("/", sep);
37
34
  }
@@ -1,13 +1,13 @@
1
1
  import { defineModule } from "./types.js";
2
2
 
3
3
  export const turnModule = defineModule({
4
- name: "turn",
5
- variables: ["symbol", "count"],
6
- defaults: {
7
- format: "[$symbol #$count ]($style)",
8
- symbol: "🔁",
9
- style: "bold purple",
10
- disabled: false,
11
- },
12
- values: ({ runtime }) => ({ count: `${runtime.turnCount}` }),
4
+ name: "turn",
5
+ variables: ["symbol", "count"],
6
+ defaults: {
7
+ format: "[$symbol #$count ]($style)",
8
+ symbol: "🔁",
9
+ style: "bold purple",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ count: `${runtime.turnCount}` }),
13
13
  });