@narumitw/pi-starship 0.49.2 → 0.49.3

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 (84) hide show
  1. package/README.md +6 -4
  2. package/dist/chunks/chunk-CKNSOLSW.ts +10 -0
  3. package/dist/chunks/chunk-CKNSOLSW.ts.map +7 -0
  4. package/dist/chunks/chunk-G2GG2V6Q.ts +218 -0
  5. package/dist/chunks/chunk-G2GG2V6Q.ts.map +7 -0
  6. package/dist/chunks/chunk-Q6DLIM7H.ts +2492 -0
  7. package/dist/chunks/chunk-Q6DLIM7H.ts.map +7 -0
  8. package/dist/chunks/cloud-JBSZWTB6.ts +142 -0
  9. package/dist/chunks/cloud-JBSZWTB6.ts.map +7 -0
  10. package/dist/chunks/commands-BSQZ2R4M.ts +757 -0
  11. package/dist/chunks/commands-BSQZ2R4M.ts.map +7 -0
  12. package/dist/chunks/deployment-ZNYM4B6W.ts +172 -0
  13. package/dist/chunks/deployment-ZNYM4B6W.ts.map +7 -0
  14. package/dist/chunks/development-TNWZ5SRC.ts +132 -0
  15. package/dist/chunks/development-TNWZ5SRC.ts.map +7 -0
  16. package/dist/chunks/execution-QHAP4U33.ts +132 -0
  17. package/dist/chunks/execution-QHAP4U33.ts.map +7 -0
  18. package/dist/chunks/languages-DPWDCH6Q.ts +184 -0
  19. package/dist/chunks/languages-DPWDCH6Q.ts.map +7 -0
  20. package/dist/chunks/package-MXN2YFLX.ts +104 -0
  21. package/dist/chunks/package-MXN2YFLX.ts.map +7 -0
  22. package/dist/pi-starship.ts +1350 -0
  23. package/dist/pi-starship.ts.map +7 -0
  24. package/package.json +9 -5
  25. package/src/index.ts +1 -1
  26. package/src/command-contract.ts +0 -13
  27. package/src/command-inspector.ts +0 -198
  28. package/src/command-preview.ts +0 -206
  29. package/src/commands.ts +0 -575
  30. package/src/config.ts +0 -794
  31. package/src/format/formatter.ts +0 -275
  32. package/src/format/style.ts +0 -278
  33. package/src/modules/activity.ts +0 -38
  34. package/src/modules/brand.ts +0 -13
  35. package/src/modules/cache.ts +0 -23
  36. package/src/modules/catalog.ts +0 -124
  37. package/src/modules/cloud.ts +0 -74
  38. package/src/modules/context.ts +0 -33
  39. package/src/modules/cost.ts +0 -31
  40. package/src/modules/deployment.ts +0 -61
  41. package/src/modules/development.ts +0 -112
  42. package/src/modules/directory.ts +0 -151
  43. package/src/modules/display.ts +0 -14
  44. package/src/modules/execution.ts +0 -84
  45. package/src/modules/extension-status.ts +0 -93
  46. package/src/modules/fill.ts +0 -14
  47. package/src/modules/git/branch.ts +0 -31
  48. package/src/modules/git/commit.ts +0 -29
  49. package/src/modules/git/metrics.ts +0 -26
  50. package/src/modules/git/runtime.ts +0 -415
  51. package/src/modules/git/state.ts +0 -21
  52. package/src/modules/git/status.ts +0 -87
  53. package/src/modules/git/worktree.ts +0 -16
  54. package/src/modules/github-pr.ts +0 -24
  55. package/src/modules/helpers.ts +0 -5
  56. package/src/modules/index.ts +0 -31
  57. package/src/modules/inspection.ts +0 -138
  58. package/src/modules/languages.ts +0 -87
  59. package/src/modules/model.ts +0 -85
  60. package/src/modules/package.ts +0 -17
  61. package/src/modules/provider.ts +0 -13
  62. package/src/modules/render.ts +0 -166
  63. package/src/modules/terminal.ts +0 -60
  64. package/src/modules/thinking.ts +0 -13
  65. package/src/modules/time.ts +0 -20
  66. package/src/modules/tokens.ts +0 -18
  67. package/src/modules/truncation.ts +0 -37
  68. package/src/modules/turn.ts +0 -13
  69. package/src/modules/types.ts +0 -189
  70. package/src/modules/workspace-helpers.ts +0 -10
  71. package/src/pi-starship.ts +0 -609
  72. package/src/runtime/cloud.ts +0 -166
  73. package/src/runtime/command.ts +0 -123
  74. package/src/runtime/deployment.ts +0 -201
  75. package/src/runtime/development.ts +0 -153
  76. package/src/runtime/execution.ts +0 -151
  77. package/src/runtime/github-pr.ts +0 -332
  78. package/src/runtime/helpers.ts +0 -274
  79. package/src/runtime/languages.ts +0 -205
  80. package/src/runtime/package.ts +0 -112
  81. package/src/runtime/refresh-controller.ts +0 -107
  82. package/src/runtime/types.ts +0 -63
  83. package/src/runtime/workspace.ts +0 -147
  84. package/src/usage.ts +0 -53
@@ -1,275 +0,0 @@
1
- import {
2
- type ColorPalette,
3
- isFillChunk,
4
- type LayoutChunk,
5
- parseStyle,
6
- type TextStyle,
7
- } from "./style.js";
8
-
9
- export type FormatNode =
10
- | { type: "text"; value: string }
11
- | { type: "variable"; name: string }
12
- | { type: "group"; children: FormatNode[]; style: StyleNode[] }
13
- | { type: "conditional"; children: FormatNode[] };
14
-
15
- export type StyleNode = { type: "text"; value: string } | { type: "variable"; name: string };
16
- export type FormatValue = string | readonly LayoutChunk[] | undefined;
17
-
18
- export interface RenderFormatOptions {
19
- variables: Readonly<Record<string, FormatValue>>;
20
- styleVariables?: Readonly<Record<string, string | undefined>>;
21
- palette?: ColorPalette;
22
- }
23
-
24
- export class FormatSyntaxError extends Error {
25
- readonly offset: number;
26
-
27
- constructor(message: string, offset: number) {
28
- super(`${message} at offset ${offset}`);
29
- this.name = "FormatSyntaxError";
30
- this.offset = offset;
31
- }
32
- }
33
-
34
- const FUNCTIONAL = new Set(["[", "]", "(", ")", "\\", "$"]);
35
-
36
- export function parseFormat(format: string): FormatNode[] {
37
- const parser = new FormatParser(format);
38
- const nodes = parser.parseNodes();
39
- if (!parser.done()) throw new FormatSyntaxError("Unexpected character", parser.offset());
40
- return nodes;
41
- }
42
-
43
- class FormatParser {
44
- private index = 0;
45
-
46
- constructor(private readonly input: string) {}
47
-
48
- offset() {
49
- return this.index;
50
- }
51
-
52
- done() {
53
- return this.index === this.input.length;
54
- }
55
-
56
- parseNodes(end?: "]" | ")"): FormatNode[] {
57
- const nodes: FormatNode[] = [];
58
- let text = "";
59
- const flushText = () => {
60
- if (!text) return;
61
- nodes.push({ type: "text", value: text });
62
- text = "";
63
- };
64
-
65
- while (!this.done()) {
66
- const current = this.input[this.index];
67
- if (current === end) {
68
- flushText();
69
- this.index += 1;
70
- return nodes;
71
- }
72
- if (current === "\\") {
73
- const escaped = this.input[this.index + 1];
74
- if (!escaped || !FUNCTIONAL.has(escaped)) {
75
- throw new FormatSyntaxError("Invalid escape", this.index);
76
- }
77
- text += escaped;
78
- this.index += 2;
79
- continue;
80
- }
81
- if (current === "$") {
82
- flushText();
83
- nodes.push({ type: "variable", name: this.parseVariable() });
84
- continue;
85
- }
86
- if (current === "[") {
87
- flushText();
88
- this.index += 1;
89
- const children = this.parseNodes("]");
90
- if (this.input[this.index] !== "(") {
91
- throw new FormatSyntaxError("Text group requires a style", this.index);
92
- }
93
- this.index += 1;
94
- nodes.push({ type: "group", children, style: this.parseStyleNodes() });
95
- continue;
96
- }
97
- if (current === "(") {
98
- flushText();
99
- this.index += 1;
100
- nodes.push({ type: "conditional", children: this.parseNodes(")") });
101
- continue;
102
- }
103
- if (current === "]" || current === ")") {
104
- throw new FormatSyntaxError(`Unexpected ${current}`, this.index);
105
- }
106
- text += current;
107
- this.index += 1;
108
- }
109
-
110
- if (end) throw new FormatSyntaxError(`Missing ${end}`, this.index);
111
- flushText();
112
- return nodes;
113
- }
114
-
115
- private parseVariable(): string {
116
- const start = this.index;
117
- this.index += 1;
118
- if (this.input[this.index] === "{") {
119
- this.index += 1;
120
- const nameStart = this.index;
121
- while (!this.done() && this.input[this.index] !== "}") {
122
- const current = this.input[this.index];
123
- if (!current || FUNCTIONAL.has(current) || current === "{") {
124
- throw new FormatSyntaxError("Invalid scoped variable", this.index);
125
- }
126
- this.index += 1;
127
- }
128
- if (this.done() || this.index === nameStart) {
129
- throw new FormatSyntaxError("Unclosed scoped variable", start);
130
- }
131
- const name = this.input.slice(nameStart, this.index);
132
- this.index += 1;
133
- return name;
134
- }
135
- const match = /^[A-Za-z_][A-Za-z0-9_]*/u.exec(this.input.slice(this.index));
136
- if (!match) throw new FormatSyntaxError("Invalid variable", start);
137
- this.index += match[0].length;
138
- return match[0];
139
- }
140
-
141
- private parseStyleNodes(): StyleNode[] {
142
- const nodes: StyleNode[] = [];
143
- let text = "";
144
- const flushText = () => {
145
- if (!text) return;
146
- nodes.push({ type: "text", value: text });
147
- text = "";
148
- };
149
- while (!this.done()) {
150
- const current = this.input[this.index];
151
- if (current === ")") {
152
- flushText();
153
- this.index += 1;
154
- return nodes;
155
- }
156
- if (current === "$") {
157
- flushText();
158
- nodes.push({ type: "variable", name: this.parseVariable() });
159
- continue;
160
- }
161
- if (current === "(" || current === "[" || current === "]" || current === "\\") {
162
- throw new FormatSyntaxError("Invalid style character", this.index);
163
- }
164
- text += current;
165
- this.index += 1;
166
- }
167
- throw new FormatSyntaxError("Missing )", this.index);
168
- }
169
- }
170
-
171
- export function formatVariables(nodes: readonly FormatNode[]): Set<string> {
172
- const variables = new Set<string>();
173
- for (const node of nodes) {
174
- if (node.type === "variable") variables.add(node.name);
175
- else if (node.type === "group" || node.type === "conditional") {
176
- for (const variable of formatVariables(node.children)) variables.add(variable);
177
- }
178
- }
179
- return variables;
180
- }
181
-
182
- export function styleVariables(nodes: readonly FormatNode[]): Set<string> {
183
- const variables = new Set<string>();
184
- for (const node of nodes) {
185
- if (node.type === "group") {
186
- for (const part of node.style) {
187
- if (part.type === "variable") variables.add(part.name);
188
- }
189
- }
190
- if (node.type === "group" || node.type === "conditional") {
191
- for (const variable of styleVariables(node.children)) variables.add(variable);
192
- }
193
- }
194
- return variables;
195
- }
196
-
197
- export function renderFormat(
198
- nodes: readonly FormatNode[],
199
- options: RenderFormatOptions,
200
- ): LayoutChunk[] {
201
- return renderNodes(nodes, options, undefined);
202
- }
203
-
204
- function renderNodes(
205
- nodes: readonly FormatNode[],
206
- options: RenderFormatOptions,
207
- inheritedStyle: TextStyle | undefined,
208
- ): LayoutChunk[] {
209
- const chunks: LayoutChunk[] = [];
210
- for (const node of nodes) {
211
- switch (node.type) {
212
- case "text":
213
- chunks.push({ text: node.value, style: inheritedStyle });
214
- break;
215
- case "variable":
216
- chunks.push(...chunksForValue(ownValue(options.variables, node.name), inheritedStyle));
217
- break;
218
- case "conditional":
219
- if (conditionalVisible(node.children, options.variables)) {
220
- chunks.push(...renderNodes(node.children, options, inheritedStyle));
221
- }
222
- break;
223
- case "group": {
224
- const styleString = node.style
225
- .map((part) =>
226
- part.type === "text" ? part.value : (ownValue(options.styleVariables, part.name) ?? ""),
227
- )
228
- .join("");
229
- const style = parseStyle(styleString, options.palette);
230
- const rendered = renderNodes(node.children, options, style);
231
- if (node.children.length === 0) chunks.push({ text: "", style });
232
- else chunks.push(...rendered);
233
- break;
234
- }
235
- }
236
- }
237
- return chunks;
238
- }
239
-
240
- function ownValue<T>(record: Readonly<Record<string, T>> | undefined, key: string): T | undefined {
241
- return record && Object.hasOwn(record, key) ? record[key] : undefined;
242
- }
243
-
244
- function chunksForValue(value: FormatValue, inheritedStyle: TextStyle | undefined): LayoutChunk[] {
245
- if (value === undefined) return [];
246
- if (typeof value === "string") return [{ text: value, style: inheritedStyle }];
247
- return value.map((chunk) =>
248
- isFillChunk(chunk)
249
- ? {
250
- type: "fill" as const,
251
- pattern: chunk.pattern.map((part) => ({
252
- ...part,
253
- style: part.style ?? inheritedStyle,
254
- })),
255
- }
256
- : { ...chunk, style: chunk.style ?? inheritedStyle },
257
- );
258
- }
259
-
260
- function conditionalVisible(
261
- nodes: readonly FormatNode[],
262
- variables: Readonly<Record<string, FormatValue>>,
263
- ): boolean {
264
- for (const variable of formatVariables(nodes)) {
265
- const value = ownValue(variables, variable);
266
- if (
267
- typeof value === "string"
268
- ? value.length > 0
269
- : value?.some((chunk) => isFillChunk(chunk) || chunk.text.length > 0)
270
- ) {
271
- return true;
272
- }
273
- }
274
- return false;
275
- }
@@ -1,278 +0,0 @@
1
- export type NamedColor =
2
- | "black"
3
- | "red"
4
- | "green"
5
- | "yellow"
6
- | "blue"
7
- | "purple"
8
- | "cyan"
9
- | "white"
10
- | "bright-black"
11
- | "bright-red"
12
- | "bright-green"
13
- | "bright-yellow"
14
- | "bright-blue"
15
- | "bright-purple"
16
- | "bright-cyan"
17
- | "bright-white";
18
-
19
- export type ColorSpec =
20
- | { kind: "named"; name: NamedColor }
21
- | { kind: "fixed"; value: number }
22
- | { kind: "rgb"; red: number; green: number; blue: number };
23
-
24
- export type PreviousColorSource = "foreground" | "background";
25
-
26
- export interface TextStyle {
27
- foreground?: ColorSpec;
28
- background?: ColorSpec;
29
- foregroundPrevious?: PreviousColorSource;
30
- backgroundPrevious?: PreviousColorSource;
31
- bold?: boolean;
32
- italic?: boolean;
33
- underline?: boolean;
34
- dimmed?: boolean;
35
- inverted?: boolean;
36
- blink?: boolean;
37
- hidden?: boolean;
38
- strikethrough?: boolean;
39
- }
40
-
41
- export type StyleParseResult =
42
- | { valid: true; style: TextStyle | undefined }
43
- | { valid: false; style: undefined };
44
-
45
- export interface StyledChunk {
46
- text: string;
47
- style?: TextStyle;
48
- }
49
-
50
- export interface FillChunk {
51
- type: "fill";
52
- pattern: readonly StyledChunk[];
53
- }
54
-
55
- export type LayoutChunk = StyledChunk | FillChunk;
56
-
57
- export function isFillChunk(chunk: LayoutChunk): chunk is FillChunk {
58
- return "type" in chunk && chunk.type === "fill";
59
- }
60
-
61
- export type ColorPalette = Readonly<Record<string, string>>;
62
-
63
- const NAMED_COLORS = new Set<NamedColor>([
64
- "black",
65
- "red",
66
- "green",
67
- "yellow",
68
- "blue",
69
- "purple",
70
- "cyan",
71
- "white",
72
- "bright-black",
73
- "bright-red",
74
- "bright-green",
75
- "bright-yellow",
76
- "bright-blue",
77
- "bright-purple",
78
- "bright-cyan",
79
- "bright-white",
80
- ]);
81
-
82
- const FOREGROUND_CODES: Record<NamedColor, number> = {
83
- black: 30,
84
- red: 31,
85
- green: 32,
86
- yellow: 33,
87
- blue: 34,
88
- purple: 35,
89
- cyan: 36,
90
- white: 37,
91
- "bright-black": 90,
92
- "bright-red": 91,
93
- "bright-green": 92,
94
- "bright-yellow": 93,
95
- "bright-blue": 94,
96
- "bright-purple": 95,
97
- "bright-cyan": 96,
98
- "bright-white": 97,
99
- };
100
-
101
- export function isValidStyle(styleString: string, palette: ColorPalette = {}): boolean {
102
- return parseStyleResult(styleString, palette).valid;
103
- }
104
-
105
- export function parseStyleResult(
106
- styleString: string,
107
- palette: ColorPalette = {},
108
- ): StyleParseResult {
109
- const tokens = styleString.split(/\s+/u).filter(Boolean).map(normalizeStyleToken);
110
- if (tokens.some(({ token, foreground }) => foreground && token === "none")) {
111
- return { valid: true, style: undefined };
112
- }
113
-
114
- const style: TextStyle = {};
115
- for (const { token, foreground } of tokens) {
116
- if (applyModifier(style, token)) continue;
117
- if (token === "prev_fg" || token === "prev_bg") {
118
- const source = token === "prev_fg" ? "foreground" : "background";
119
- if (foreground) style.foregroundPrevious = source;
120
- else style.backgroundPrevious = source;
121
- continue;
122
- }
123
- const color = parseColor(token, palette);
124
- if (!foreground && !color) {
125
- delete style.background;
126
- continue;
127
- }
128
- if (!color) return { valid: false, style: undefined };
129
- if (foreground) style.foreground = color;
130
- else style.background = color;
131
- }
132
- return { valid: true, style };
133
- }
134
-
135
- export function parseStyle(styleString: string, palette: ColorPalette = {}): TextStyle | undefined {
136
- return parseStyleResult(styleString, palette).style;
137
- }
138
-
139
- function normalizeStyleToken(rawToken: string): { token: string; foreground: boolean } {
140
- let token = rawToken.toLowerCase();
141
- if (token.startsWith("fg:")) {
142
- return { token: token.replace(/^(?:fg:)+/u, ""), foreground: true };
143
- }
144
- if (token.startsWith("bg:")) {
145
- token = token.replace(/^(?:bg:)+/u, "");
146
- return { token, foreground: false };
147
- }
148
- return { token, foreground: true };
149
- }
150
-
151
- function applyModifier(style: TextStyle, token: string): boolean {
152
- switch (token) {
153
- case "bold":
154
- style.bold = true;
155
- return true;
156
- case "italic":
157
- style.italic = true;
158
- return true;
159
- case "underline":
160
- style.underline = true;
161
- return true;
162
- case "dimmed":
163
- style.dimmed = true;
164
- return true;
165
- case "inverted":
166
- style.inverted = true;
167
- return true;
168
- case "blink":
169
- style.blink = true;
170
- return true;
171
- case "hidden":
172
- style.hidden = true;
173
- return true;
174
- case "strikethrough":
175
- style.strikethrough = true;
176
- return true;
177
- default:
178
- return false;
179
- }
180
- }
181
-
182
- export function parseColor(token: string, palette: ColorPalette = {}): ColorSpec | undefined {
183
- const paletteValue = Object.hasOwn(palette, token) ? palette[token] : undefined;
184
- if (paletteValue !== undefined) return parseColor(paletteValue.toLowerCase(), {});
185
- if (NAMED_COLORS.has(token as NamedColor)) {
186
- return { kind: "named", name: token as NamedColor };
187
- }
188
- if (/^\d{1,3}$/u.test(token)) {
189
- const value = Number(token);
190
- return value <= 255 ? { kind: "fixed", value } : undefined;
191
- }
192
- const rgb = /^#([0-9a-f]{6})$/iu.exec(token);
193
- if (!rgb?.[1]) return undefined;
194
- return {
195
- kind: "rgb",
196
- red: Number.parseInt(rgb[1].slice(0, 2), 16),
197
- green: Number.parseInt(rgb[1].slice(2, 4), 16),
198
- blue: Number.parseInt(rgb[1].slice(4, 6), 16),
199
- };
200
- }
201
-
202
- interface ResolvedStyle
203
- extends Omit<
204
- TextStyle,
205
- "foreground" | "background" | "foregroundPrevious" | "backgroundPrevious"
206
- > {
207
- foreground?: ColorSpec;
208
- background?: ColorSpec;
209
- }
210
-
211
- export function renderChunksToAnsi(chunks: readonly LayoutChunk[]): string {
212
- const runs: Array<{ text: string; style: ResolvedStyle }> = [];
213
- let previous: ResolvedStyle | undefined;
214
- for (const chunk of chunks) {
215
- if (isFillChunk(chunk)) continue;
216
- const style = resolveStyle(chunk.style, previous);
217
- const last = runs.at(-1);
218
- if (chunk.text && last && stylesEqual(last.style, style)) last.text += chunk.text;
219
- else if (chunk.text) runs.push({ text: chunk.text, style });
220
- previous = style;
221
- }
222
- return runs
223
- .map(({ text, style }) => {
224
- const codes = ansiCodes(style);
225
- return codes.length > 0 ? `\u001b[${codes.join(";")}m${text}\u001b[0m` : text;
226
- })
227
- .join("");
228
- }
229
-
230
- function stylesEqual(left: ResolvedStyle, right: ResolvedStyle): boolean {
231
- return JSON.stringify(left) === JSON.stringify(right);
232
- }
233
-
234
- function resolveStyle(
235
- style: TextStyle | undefined,
236
- previous: ResolvedStyle | undefined,
237
- ): ResolvedStyle {
238
- if (!style) return {};
239
- const { foregroundPrevious, backgroundPrevious, ...resolved } = style;
240
- return {
241
- ...resolved,
242
- foreground: resolveColor(style.foreground, foregroundPrevious, previous),
243
- background: resolveColor(style.background, backgroundPrevious, previous),
244
- };
245
- }
246
-
247
- function resolveColor(
248
- fallback: ColorSpec | undefined,
249
- source: PreviousColorSource | undefined,
250
- previous: ResolvedStyle | undefined,
251
- ): ColorSpec | undefined {
252
- if (!source || !previous) return fallback;
253
- return source === "foreground" ? previous.foreground : previous.background;
254
- }
255
-
256
- function ansiCodes(style: ResolvedStyle): string[] {
257
- const codes: string[] = [];
258
- if (style.foreground) codes.push(...colorCodes(style.foreground, false));
259
- if (style.background) codes.push(...colorCodes(style.background, true));
260
- if (style.bold) codes.push("1");
261
- if (style.dimmed) codes.push("2");
262
- if (style.italic) codes.push("3");
263
- if (style.underline) codes.push("4");
264
- if (style.blink) codes.push("5");
265
- if (style.inverted) codes.push("7");
266
- if (style.hidden) codes.push("8");
267
- if (style.strikethrough) codes.push("9");
268
- return codes;
269
- }
270
-
271
- function colorCodes(color: ColorSpec, background: boolean): string[] {
272
- if (color.kind === "named") {
273
- const foreground = FOREGROUND_CODES[color.name];
274
- return [`${background ? foreground + 10 : foreground}`];
275
- }
276
- if (color.kind === "fixed") return [background ? "48" : "38", "5", `${color.value}`];
277
- return [background ? "48" : "38", "2", `${color.red}`, `${color.green}`, `${color.blue}`];
278
- }
@@ -1,38 +0,0 @@
1
- import { defineModule } from "./types.js";
2
-
3
- export const activityModule = defineModule({
4
- name: "activity",
5
- variables: ["symbol", "state", "tool", "count", "text"],
6
- defaults: {
7
- format: "[ $text ]($style)",
8
- symbol: "⚙",
9
- style: "bold yellow",
10
- disabled: false,
11
- },
12
- values: ({ runtime, symbol }) => {
13
- const active = [...runtime.activeTools.entries()];
14
- if (active.length > 0) {
15
- const [tool = "tool", count = 1] = active[0] ?? [];
16
- const suffix = count > 1 ? `×${count}` : "";
17
- const more = active.length > 1 ? `+${active.length - 1}` : "";
18
- return {
19
- state: "active",
20
- tool,
21
- count: `${count}`,
22
- text: `${symbol} ${tool}${suffix}${more}`,
23
- };
24
- }
25
- if (runtime.isStreaming) {
26
- return { state: "thinking", tool: "", count: "0", text: `${symbol} thinking` };
27
- }
28
- if (runtime.lastCompletedTool) {
29
- return {
30
- state: "completed",
31
- tool: runtime.lastCompletedTool,
32
- count: "0",
33
- text: `${symbol} completed ${runtime.lastCompletedTool}`,
34
- };
35
- }
36
- return { state: "idle", tool: "", count: "0", text: `${symbol} idle` };
37
- },
38
- });
@@ -1,13 +0,0 @@
1
- import { defineModule } from "./types.js";
2
-
3
- export const brandModule = defineModule({
4
- name: "brand",
5
- variables: ["symbol"],
6
- defaults: {
7
- format: "[ $symbol ]($style)",
8
- symbol: "π",
9
- style: "bold white",
10
- disabled: false,
11
- },
12
- values: () => ({}),
13
- });
@@ -1,23 +0,0 @@
1
- import { formatCount } from "./helpers.js";
2
- import { defineModule } from "./types.js";
3
-
4
- export const cacheModule = defineModule({
5
- name: "cache",
6
- variables: ["symbol", "rate", "read", "write"],
7
- defaults: {
8
- format: "[$symbol (CH$rate )]($style)",
9
- symbol: "📦",
10
- style: "bold green",
11
- disabled: true,
12
- },
13
- values: ({ runtime }) => {
14
- const { cacheRead, cacheWrite, latestCacheHitRate } = runtime.tokenTotals;
15
- if (cacheRead === 0 && cacheWrite === 0) return undefined;
16
- const rate = latestCacheHitRate === undefined ? "" : `${latestCacheHitRate.toFixed(1)}%`;
17
- return {
18
- rate,
19
- read: cacheRead > 0 ? formatCount(cacheRead) : "",
20
- write: cacheWrite > 0 ? formatCount(cacheWrite) : "",
21
- };
22
- },
23
- });