@narumitw/pi-starship 0.22.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.
@@ -0,0 +1,17 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const costModule = defineModule({
4
+ name: "cost",
5
+ variables: ["symbol", "cost"],
6
+ defaults: {
7
+ format: "[ $symbol \\$$cost ]($style)",
8
+ symbol: "💸",
9
+ style: "fg:meter_fg bg:meter",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ cost: formatCost(runtime.tokenTotals.cost) }),
13
+ });
14
+
15
+ function formatCost(value: number): string {
16
+ return value.toFixed(value >= 1 ? 2 : 3);
17
+ }
@@ -0,0 +1,17 @@
1
+ import { basename } from "node:path";
2
+ import { defineModule } from "./types.js";
3
+
4
+ export const directoryModule = defineModule({
5
+ name: "directory",
6
+ variables: ["symbol", "path", "full_path"],
7
+ defaults: {
8
+ format: "[ $symbol $path ]($style)",
9
+ symbol: "📁",
10
+ style: "fg:directory_fg bg:directory",
11
+ disabled: false,
12
+ },
13
+ values: ({ runtime }) => ({
14
+ path: basename(runtime.cwd) || runtime.cwd,
15
+ full_path: runtime.cwd,
16
+ }),
17
+ });
@@ -0,0 +1,152 @@
1
+ import { defineModule, type ExtensionStatusIconAliasMap } from "./types.js";
2
+
3
+ const DEFAULT_EXTENSION_STATUS_ICONS: Record<string, string> = {
4
+ "chrome-devtools": "🌐",
5
+ "codex-usage": "📊",
6
+ caffeinate: "💊",
7
+ firecrawl: "🔥",
8
+ "github-pr": "🔎",
9
+ goal: "🎯",
10
+ lsp: "🧰",
11
+ "plan-mode": "📝",
12
+ pisync: "🔄",
13
+ subagents: "🧑‍🤝‍🧑",
14
+ "unknown-error-retry": "🔁",
15
+ };
16
+
17
+ export const extensionStatusModule = defineModule({
18
+ name: "extension_status",
19
+ variables: ["symbol", "statuses", "count"],
20
+ defaults: {
21
+ format: "[$statuses]($style)",
22
+ symbol: "",
23
+ style: "fg:extension",
24
+ disabled: false,
25
+ },
26
+ values: ({ runtime, extensionStatus, hiddenExtensionStatusKeys }) => {
27
+ const statuses = [...runtime.extensionStatuses.entries()]
28
+ .filter(
29
+ ([key, value]) => key !== "starship" && !hiddenExtensionStatusKeys.has(key) && value.trim(),
30
+ )
31
+ .map(([key, value]) =>
32
+ formatExtensionStatus(
33
+ key,
34
+ value,
35
+ extensionStatus.icons,
36
+ runtime.extensionStatusIconAliases,
37
+ ),
38
+ )
39
+ .slice(0, extensionStatus.maxStatuses);
40
+ if (statuses.length === 0) return undefined;
41
+ return {
42
+ statuses: statuses.join(extensionStatus.separator),
43
+ count: `${statuses.length}`,
44
+ };
45
+ },
46
+ });
47
+
48
+ export function formatExtensionStatus(
49
+ key: string,
50
+ value: string,
51
+ configuredIcons: Readonly<Record<string, string>>,
52
+ aliases: ExtensionStatusIconAliasMap,
53
+ ): string {
54
+ const status = splitExtensionStatusIcon(stripExtensionStatusPrefix(key, value));
55
+ const icon = extensionStatusIcon(key, status.icon, configuredIcons, aliases);
56
+ const text = simplifyExtensionStatusText(status.text);
57
+ return icon ? `${icon} ${text}` : text;
58
+ }
59
+
60
+ function extensionStatusIcon(
61
+ key: string,
62
+ leadingIcon: string | undefined,
63
+ configuredIcons: Readonly<Record<string, string>>,
64
+ aliases: ExtensionStatusIconAliasMap,
65
+ ): string {
66
+ if (Object.hasOwn(configuredIcons, key)) return configuredIcons[key] ?? "";
67
+ for (const alias of extensionStatusAliasesForKey(key, aliases)) {
68
+ if (Object.hasOwn(configuredIcons, alias)) return configuredIcons[alias] ?? "";
69
+ }
70
+ const defaultIcon = Object.hasOwn(DEFAULT_EXTENSION_STATUS_ICONS, key)
71
+ ? DEFAULT_EXTENSION_STATUS_ICONS[key]
72
+ : undefined;
73
+ const fallbackIcon = Object.hasOwn(configuredIcons, "fallback")
74
+ ? configuredIcons.fallback
75
+ : undefined;
76
+ return leadingIcon ?? defaultIcon ?? fallbackIcon ?? "🔌";
77
+ }
78
+
79
+ function extensionStatusAliasesForKey(
80
+ key: string,
81
+ aliases: ExtensionStatusIconAliasMap,
82
+ ): readonly string[] {
83
+ for (const [base, values] of aliases) {
84
+ if (key === base || key.startsWith(`${base}:`) || key.startsWith(`${base}/`)) return values;
85
+ }
86
+ return [];
87
+ }
88
+
89
+ function splitExtensionStatusIcon(value: string): { icon?: string; text: string } {
90
+ const trimmed = value.trim();
91
+ const [first, ...rest] = trimmed.split(/\s+/u);
92
+ if (first && isEmojiOnlyToken(first)) return { icon: first, text: rest.join(" ") };
93
+ return { text: trimmed };
94
+ }
95
+
96
+ function isEmojiOnlyToken(value: string): boolean {
97
+ return /^(?=.*(?:\p{Extended_Pictographic}|\p{Regional_Indicator}|[0-9#*]\ufe0f?\u20e3))(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|\p{Regional_Indicator}|\u200d|\ufe0f|[0-9#*]\ufe0f?\u20e3)+$/u.test(
98
+ value,
99
+ );
100
+ }
101
+
102
+ function stripExtensionStatusPrefix(key: string, value: string): string {
103
+ return value.trim().replace(new RegExp(`^${escapeRegExp(key)}\\s*:\\s*`, "iu"), "");
104
+ }
105
+
106
+ function simplifyExtensionStatusText(value: string): string {
107
+ return value
108
+ .trim()
109
+ .replace(/\bready\b/giu, "✓")
110
+ .replace(/\bmissing\b/giu, "✗")
111
+ .replace(/,\s*/g, " ")
112
+ .replace(/\s+\([^)]*\)\s*$/u, "")
113
+ .replace(/\s+/gu, " ");
114
+ }
115
+
116
+ function escapeRegExp(value: string): string {
117
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
118
+ }
119
+
120
+ interface InstalledPackage {
121
+ packageName: string;
122
+ source?: string;
123
+ }
124
+
125
+ export function buildExtensionStatusIconAliases(
126
+ packages: readonly InstalledPackage[],
127
+ ): Map<string, string[]> {
128
+ const candidates = new Map<string, Map<string, string[]>>();
129
+ for (const installed of packages) {
130
+ const base = installed.packageName.slice(installed.packageName.lastIndexOf("/") + 1);
131
+ const statusBase = base.startsWith("pi-") ? base.slice(3) : base;
132
+ if (!statusBase) continue;
133
+ const sourceAliases = installed.source?.startsWith("npm:")
134
+ ? [installed.source, `npm:${npmPackageName(installed.source)}`]
135
+ : [];
136
+ const aliases = [...new Set([...sourceAliases, installed.packageName, base, statusBase])];
137
+ const byPackage = candidates.get(statusBase) ?? new Map<string, string[]>();
138
+ byPackage.set(installed.packageName, aliases);
139
+ candidates.set(statusBase, byPackage);
140
+ }
141
+ const result = new Map<string, string[]>();
142
+ for (const [base, byPackage] of candidates) {
143
+ if (byPackage.size === 1) result.set(base, [...byPackage.values()][0] ?? []);
144
+ }
145
+ return result;
146
+ }
147
+
148
+ function npmPackageName(source: string): string {
149
+ const spec = source.slice("npm:".length);
150
+ if (spec.startsWith("@")) return spec.split("@").slice(0, 2).join("@").replace(/^@/u, "@");
151
+ return spec.split("@")[0] ?? spec;
152
+ }
@@ -0,0 +1,52 @@
1
+ import { defineModule } from "../types.js";
2
+
3
+ export const gitBranchModule = defineModule({
4
+ name: "git_branch",
5
+ variables: ["symbol", "branch", "pr"],
6
+ defaults: {
7
+ format: "[ $symbol $branch( $pr) ]($style)",
8
+ symbol: "🌿",
9
+ style: "fg:git_fg bg:git",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => {
13
+ if (!runtime.gitBranch) return undefined;
14
+ return {
15
+ branch: runtime.gitBranch,
16
+ pr: prContextFromStatuses(runtime.extensionStatuses) ?? "",
17
+ };
18
+ },
19
+ });
20
+
21
+ export function prContextFromStatuses(statuses: ReadonlyMap<string, string>): string | undefined {
22
+ const value = statuses.get("github-pr");
23
+ if (!value) return undefined;
24
+ const link = prLink(value);
25
+ if (!link) return undefined;
26
+ const state = compactPrState(value.replace(link, ""));
27
+ return state ? `${link} · ${state}` : undefined;
28
+ }
29
+
30
+ function prLink(value: string): string | undefined {
31
+ const open = value.indexOf("\x1b]8;;");
32
+ if (open === -1) return undefined;
33
+ const closeMarker = "\x1b]8;;\x07";
34
+ const close = value.indexOf(closeMarker, open + 1);
35
+ return close === -1 ? undefined : value.slice(open, close + closeMarker.length);
36
+ }
37
+
38
+ function compactPrState(value: string): string | undefined {
39
+ if (/:\s*merged\s*$/u.test(value)) return "merged";
40
+ if (/:\s*closed\s*$/u.test(value)) return "closed";
41
+ if (/\bdraft\b/u.test(value)) return "draft";
42
+ const failing = /\bchecks failing \((\d+)\)/u.exec(value);
43
+ if (failing?.[1]) return `${failing[1]} failing`;
44
+ if (/\bchanges requested\b/u.test(value)) return "changes requested";
45
+ const pending = /\bchecks pending \((\d+)\)/u.exec(value);
46
+ if (pending?.[1]) return `${pending[1]} pending`;
47
+ if (/\bapproved\b/u.test(value)) return "approved";
48
+ if (/\breview required\b/u.test(value)) return "review required";
49
+ if (/\bchecks passing\b/u.test(value)) return "checks passing";
50
+ if (/\bno checks\b/u.test(value)) return "no checks";
51
+ return undefined;
52
+ }
@@ -0,0 +1,111 @@
1
+ import { basename, isAbsolute, resolve } from "node:path";
2
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
3
+ import type { GitStatusSnapshot, GitWorktreeSnapshot } from "../types.js";
4
+
5
+ const GIT_TIMEOUT_MS = 3_000;
6
+
7
+ export async function readGitStatus(
8
+ pi: ExtensionAPI,
9
+ cwd: string,
10
+ ): Promise<GitStatusSnapshot | undefined> {
11
+ const result = await pi.exec(
12
+ "git",
13
+ ["--no-optional-locks", "status", "--porcelain=v1", "--branch", "--untracked-files=normal"],
14
+ { cwd, timeout: GIT_TIMEOUT_MS },
15
+ );
16
+ if (result.code !== 0 || result.killed) return undefined;
17
+ return parseGitStatusPorcelain(result.stdout);
18
+ }
19
+
20
+ export async function readGitWorktree(
21
+ pi: ExtensionAPI,
22
+ cwd: string,
23
+ ): Promise<GitWorktreeSnapshot | undefined> {
24
+ const result = await pi.exec(
25
+ "git",
26
+ ["rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir", "--git-dir"],
27
+ { cwd, timeout: GIT_TIMEOUT_MS },
28
+ );
29
+ if (result.code !== 0 || result.killed) return undefined;
30
+ return parseGitWorktree(result.stdout);
31
+ }
32
+
33
+ export function parseGitWorktree(output: string): GitWorktreeSnapshot | undefined {
34
+ const lines = output.trimEnd().split(/\r?\n/u);
35
+ if (lines.length !== 3) return undefined;
36
+ const [path, commonDir, gitDir] = lines;
37
+ if (!path || !commonDir || !gitDir) return undefined;
38
+ if (![path, commonDir, gitDir].every(isAbsolute)) return undefined;
39
+ if (samePath(commonDir, gitDir)) return undefined;
40
+ return { name: basename(path) || path, path };
41
+ }
42
+
43
+ export function parseGitStatusPorcelain(output: string): GitStatusSnapshot {
44
+ const summary: GitStatusSnapshot = {
45
+ ahead: 0,
46
+ behind: 0,
47
+ staged: 0,
48
+ modified: 0,
49
+ untracked: 0,
50
+ conflicted: 0,
51
+ };
52
+ for (const line of output.split(/\r?\n/u)) {
53
+ if (!line) continue;
54
+ if (line.startsWith("## ")) {
55
+ const ahead = /\bahead (\d+)/u.exec(line);
56
+ const behind = /\bbehind (\d+)/u.exec(line);
57
+ summary.ahead = ahead?.[1] ? Number(ahead[1]) : 0;
58
+ summary.behind = behind?.[1] ? Number(behind[1]) : 0;
59
+ continue;
60
+ }
61
+ const indexStatus = line[0] ?? " ";
62
+ const worktreeStatus = line[1] ?? " ";
63
+ if (indexStatus === "?" && worktreeStatus === "?") {
64
+ summary.untracked += 1;
65
+ continue;
66
+ }
67
+ if (isConflict(indexStatus, worktreeStatus)) {
68
+ summary.conflicted += 1;
69
+ continue;
70
+ }
71
+ if (isChanged(indexStatus)) summary.staged += 1;
72
+ if (isChanged(worktreeStatus)) summary.modified += 1;
73
+ }
74
+ return summary;
75
+ }
76
+
77
+ function samePath(left: string, right: string): boolean {
78
+ const normalizedLeft = resolve(left);
79
+ const normalizedRight = resolve(right);
80
+ return process.platform === "win32"
81
+ ? normalizedLeft.toLowerCase() === normalizedRight.toLowerCase()
82
+ : normalizedLeft === normalizedRight;
83
+ }
84
+
85
+ function isConflict(indexStatus: string, worktreeStatus: string): boolean {
86
+ return (
87
+ (indexStatus === "D" && worktreeStatus === "D") ||
88
+ (indexStatus === "A" && worktreeStatus === "A") ||
89
+ indexStatus === "U" ||
90
+ worktreeStatus === "U"
91
+ );
92
+ }
93
+
94
+ function isChanged(status: string): boolean {
95
+ return status !== " " && status !== "?" && status !== "!";
96
+ }
97
+
98
+ export function gitStatusEqual(
99
+ left: GitStatusSnapshot | undefined,
100
+ right: GitStatusSnapshot | undefined,
101
+ ): boolean {
102
+ if (!left || !right) return left === right;
103
+ return (
104
+ left.ahead === right.ahead &&
105
+ left.behind === right.behind &&
106
+ left.staged === right.staged &&
107
+ left.modified === right.modified &&
108
+ left.untracked === right.untracked &&
109
+ left.conflicted === right.conflicted
110
+ );
111
+ }
@@ -0,0 +1,36 @@
1
+ import { formatCount } from "../helpers.js";
2
+ import { defineModule } from "../types.js";
3
+
4
+ export const gitStatusModule = defineModule({
5
+ name: "git_status",
6
+ variables: [
7
+ "symbol",
8
+ "all_status",
9
+ "ahead",
10
+ "behind",
11
+ "staged",
12
+ "modified",
13
+ "untracked",
14
+ "conflicted",
15
+ ],
16
+ defaults: {
17
+ format: "[$all_status ]($style)",
18
+ symbol: "",
19
+ style: "fg:git_fg bg:git",
20
+ disabled: false,
21
+ },
22
+ values: ({ runtime }) => {
23
+ if (!runtime.gitBranch || !runtime.gitStatus) return undefined;
24
+ const status = runtime.gitStatus;
25
+ const values = {
26
+ ahead: status.ahead > 0 ? `⇡${formatCount(status.ahead)}` : "",
27
+ behind: status.behind > 0 ? `⇣${formatCount(status.behind)}` : "",
28
+ staged: status.staged > 0 ? `+${formatCount(status.staged)}` : "",
29
+ modified: status.modified > 0 ? `~${formatCount(status.modified)}` : "",
30
+ untracked: status.untracked > 0 ? `?${formatCount(status.untracked)}` : "",
31
+ conflicted: status.conflicted > 0 ? `!${formatCount(status.conflicted)}` : "",
32
+ };
33
+ const allStatus = Object.values(values).filter(Boolean).join(" ");
34
+ return allStatus ? { ...values, all_status: allStatus } : undefined;
35
+ },
36
+ });
@@ -0,0 +1,16 @@
1
+ import { defineModule } from "../types.js";
2
+
3
+ export const gitWorktreeModule = defineModule({
4
+ name: "git_worktree",
5
+ variables: ["symbol", "name", "path"],
6
+ defaults: {
7
+ format: "[ $symbol $name ]($style)",
8
+ symbol: "🌳",
9
+ style: "fg:git_fg bg:git",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) =>
13
+ runtime.gitWorktree
14
+ ? { name: runtime.gitWorktree.name, path: runtime.gitWorktree.path }
15
+ : undefined,
16
+ });
@@ -0,0 +1,5 @@
1
+ export function formatCount(value: number): string {
2
+ if (value < 1000) return `${value}`;
3
+ if (value < 1_000_000) return `${(value / 1000).toFixed(value < 10_000 ? 1 : 0)}k`;
4
+ return `${(value / 1_000_000).toFixed(1)}m`;
5
+ }
@@ -0,0 +1,16 @@
1
+ export { MODULE_DEFINITIONS, MODULE_NAMES, type ModuleName } from "./catalog.js";
2
+ export {
3
+ buildExtensionStatusIconAliases,
4
+ formatExtensionStatus,
5
+ } from "./extension-status.js";
6
+ export { prContextFromStatuses } from "./git/branch.js";
7
+ export { formatCount } from "./helpers.js";
8
+ export { shortenModel } from "./model.js";
9
+ export { renderStatusline } from "./render.js";
10
+ export type {
11
+ ExtensionStatusIconAliasMap,
12
+ GitStatusSnapshot,
13
+ GitWorktreeSnapshot,
14
+ RenderedStatusline,
15
+ StarshipRuntimeSnapshot,
16
+ } from "./types.js";
@@ -0,0 +1,21 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const modelModule = defineModule({
4
+ name: "model",
5
+ variables: ["symbol", "model"],
6
+ defaults: {
7
+ format: "[$symbol $model ]($style)",
8
+ symbol: "🤖",
9
+ style: "fg:header_fg bg:header",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => (runtime.model ? { model: shortenModel(runtime.model.id) } : undefined),
13
+ });
14
+
15
+ export function shortenModel(model: string): string {
16
+ return model
17
+ .replace(/^claude-/u, "")
18
+ .replace(/^gpt-/u, "gpt ")
19
+ .replace(/-20\d{6}$/u, "")
20
+ .replace(/-latest$/u, "");
21
+ }
@@ -0,0 +1,13 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const providerModule = defineModule({
4
+ name: "provider",
5
+ variables: ["symbol", "provider"],
6
+ defaults: {
7
+ format: "[$symbol $provider ]($style)",
8
+ symbol: "🔌",
9
+ style: "fg:header_fg bg:header",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => (runtime.model ? { provider: runtime.model.provider } : undefined),
13
+ });
@@ -0,0 +1,73 @@
1
+ import { activePalette, type ModuleConfig, type StarshipConfig } from "../config.js";
2
+ import { type FormatValue, formatVariables, renderFormat } from "../format/formatter.js";
3
+ import { renderChunksToAnsi, type StyledChunk } from "../format/style.js";
4
+ import { MODULE_DEFINITIONS, MODULE_NAMES, type ModuleName } from "./catalog.js";
5
+ import type { ModuleValueContext, RenderedStatusline, StarshipRuntimeSnapshot } from "./types.js";
6
+
7
+ export function renderStatusline(
8
+ config: StarshipConfig,
9
+ runtime: StarshipRuntimeSnapshot,
10
+ ): RenderedStatusline<ModuleName> {
11
+ const palette = activePalette(config);
12
+ const modules = {} as Record<ModuleName, StyledChunk[]>;
13
+ for (const name of MODULE_NAMES) modules[name] = [];
14
+ const consumedExtensionStatusKeys = new Set<string>();
15
+
16
+ for (const definition of MODULE_DEFINITIONS) {
17
+ const name = definition.name;
18
+ const values = definition.values(
19
+ valueContext(config, name, runtime, consumedExtensionStatusKeys),
20
+ );
21
+ if (!values) continue;
22
+ modules[name] = renderModule(config.modules[name], values, palette);
23
+ if (
24
+ name === "git_branch" &&
25
+ values.pr &&
26
+ formatVariables(config.modules.git_branch.formatAst).has("pr") &&
27
+ modules.git_branch.some((chunk) => chunk.text.includes(values.pr ?? ""))
28
+ ) {
29
+ consumedExtensionStatusKeys.add("github-pr");
30
+ }
31
+ }
32
+
33
+ const explicitModules = formatVariables(config.formatAst);
34
+ const all = MODULE_NAMES.flatMap((name) =>
35
+ explicitModules.has(name) || config.modules[name].disabled ? [] : modules[name],
36
+ );
37
+ const rootVariables: Record<string, FormatValue> = { all };
38
+ for (const name of MODULE_NAMES) rootVariables[name] = modules[name];
39
+ const chunks = renderFormat(config.formatAst, { variables: rootVariables, palette });
40
+ return {
41
+ ansi: renderChunksToAnsi(chunks),
42
+ chunks,
43
+ modules,
44
+ consumedExtensionStatusKeys,
45
+ };
46
+ }
47
+
48
+ function valueContext(
49
+ config: StarshipConfig,
50
+ name: ModuleName,
51
+ runtime: StarshipRuntimeSnapshot,
52
+ hiddenExtensionStatusKeys: ReadonlySet<string>,
53
+ ): ModuleValueContext {
54
+ return {
55
+ runtime,
56
+ symbol: config.modules[name].symbol,
57
+ extensionStatus: config.extensionStatus,
58
+ hiddenExtensionStatusKeys,
59
+ };
60
+ }
61
+
62
+ function renderModule(
63
+ module: ModuleConfig,
64
+ values: Readonly<Record<string, FormatValue>>,
65
+ palette: Readonly<Record<string, string>>,
66
+ ): StyledChunk[] {
67
+ if (module.disabled) return [];
68
+ return renderFormat(module.formatAst, {
69
+ variables: { ...values, symbol: module.symbol },
70
+ styleVariables: { style: module.style },
71
+ palette,
72
+ });
73
+ }
@@ -0,0 +1,13 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const thinkingModule = defineModule({
4
+ name: "thinking",
5
+ variables: ["symbol", "level"],
6
+ defaults: {
7
+ format: "[$symbol $level ]($style)",
8
+ symbol: "🧠",
9
+ style: "fg:header_fg bg:header",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ level: runtime.thinkingLevel }),
13
+ });
@@ -0,0 +1,20 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const timeModule = defineModule({
4
+ name: "time",
5
+ variables: ["symbol", "time"],
6
+ defaults: {
7
+ format: "[$symbol $time ]($style)",
8
+ symbol: "🕒",
9
+ style: "fg:meter_fg bg:meter",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ time: formatTime(runtime.now) }),
13
+ });
14
+
15
+ function formatTime(now: Date): string {
16
+ return `${now.getHours().toString().padStart(2, "0")}:${now
17
+ .getMinutes()
18
+ .toString()
19
+ .padStart(2, "0")}`;
20
+ }
@@ -0,0 +1,18 @@
1
+ import { formatCount } from "./helpers.js";
2
+ import { defineModule } from "./types.js";
3
+
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: "fg:runtime_fg bg:runtime",
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
+ });
@@ -0,0 +1,13 @@
1
+ import { defineModule } from "./types.js";
2
+
3
+ export const turnModule = defineModule({
4
+ name: "turn",
5
+ variables: ["symbol", "count"],
6
+ defaults: {
7
+ format: "[$symbol #$count ]($style)",
8
+ symbol: "🔁",
9
+ style: "fg:meter_fg bg:meter",
10
+ disabled: false,
11
+ },
12
+ values: ({ runtime }) => ({ count: `${runtime.turnCount}` }),
13
+ });