A configurable status bar for Claude Code — band, status line, pane, and toasts driven by one config; configured with npx @sushant-kum/ccstatus or /ccstatus.

A configurable status bar for Claude Code — the mod-system analog of ccstatusline. One JSON config drives four surfaces — the above-prompt band, the native status line, an openable pane, and threshold toasts — edited with an interactive TUI and rendered live by a Claude Code mod. The TUI preview and the mod paint from the same engine, so what you preview is what you get.
Status: v1, pre-release (
0.1.0). Not yet published to npm or a hosted marketplace — the published commands below work once it ships; until then use the from-source setup.
ccstatus has two halves that share one config file. _(Published install — these work once ccstatus is on npm and the marketplace; to try it before then, see Development.)_
claude plugin marketplace add sushant-kum/ccstatus
claude plugin install ccstatus@ccstatus
Then /ccstatus toggles the band; /ccstatus pane | reload | theme <name> | edit cover the rest.
npx @sushant-kum/ccstatus
An interactive TUI with a live band preview on every screen. Changes are saved to the shared config file and the running mod hot-reloads them.
On launch, npx @sushant-kum/ccstatus checks whether the mod is installed; if it isn't, it shows a banner and offers to install it for you (press i). A successful install takes effect after you restart Claude Code or run /reload-plugins.
All four are driven by the same config and the same 21 widget types (model, context length/%, tokens, git branch/changes/worktree, session clock, cost, rate limits, block timer, cwd, custom text/command, flex separator, …), with 9 built-in themes and a configurable Powerline separator.
One JSON file at $XDG_CONFIG_HOME/ccstatus/config.json (else ~/.config/ccstatus/config.json), shared by the mod and the TUI. It is hand-editable: invalid input never crashes either half — it degrades with a warning. Colors are the named terminal palette (v1; no hex yet).
A demo gif will be added here (docs/demo.gif).
npm-workspaces monorepo: @ccstatus/core (pure engine), @sushant-kum/ccstatus (the TUI bin), and plugin/ (the mod). See CLAUDE.md and the decision/flow records under docs/.
npm install
npm test -w @ccstatus/core
npm test -w @sushant-kum/ccstatus
npm run build:plugin-core && claude plugin test plugin
MIT © Sushant Kumar
hooks/register.tsx 552 lines1import { atom, read, update } from 'claude-code';
2import type { EngineInterface, Register } from 'claude-code';
3
4import { configPath, parseConfig, shouldReload, snapshotPath } from './config-io.js';
5import { render } from './core.js';
6import type { Config, Snapshot } from './core.js';
7import { parseGit } from './git-parse.js';
8import { paintModel } from './paint.js';
9import { buildSnapshot, type RawUsage } from './snapshot-build.js';
10import { dueToasts, evalWhen } from './toasts.js';
11
12const visible = atom({ plugin: 'ccstatus', key: 'visible' } as const, true);
13const snapshot = atom({ plugin: 'ccstatus', key: 'snapshot' } as const, null);
14const config = atom({ plugin: 'ccstatus', key: 'config' } as const, null);
15const paneOpen = atom({ plugin: 'ccstatus', key: 'paneOpen' } as const, false);
16const toastFired = atom(
17 { plugin: 'ccstatus', key: 'toastFired' } as const,
18 {} as Record<string, boolean>
19);
20const configMtime = atom(
21 { plugin: 'ccstatus', key: 'configMtime' } as const,
22 null as number | null
23);
24const effort = atom({ plugin: 'ccstatus', key: 'effort' } as const, null);
25const outputStyle = atom({ plugin: 'ccstatus', key: 'outputStyle' } as const, null);
26const termWidth = atom({ plugin: 'ccstatus', key: 'termWidth' } as const, 0);
27
28const GIT =
29 'r=$(git rev-parse --show-toplevel 2>/dev/null)||{ printf NO;exit 0;};' +
30 'b=$(git rev-parse --abbrev-ref HEAD 2>/dev/null);' +
31 'gd=$(git rev-parse --git-dir 2>/dev/null); case "$gd" in */worktrees/*) w=$(basename "$gd");; *) w="";; esac;' +
32 's=$(git status --porcelain 2>/dev/null);' +
33 'a=$(printf "%s\\n" "$s"|grep -cE "^(A.|.A|\\?\\?)");' +
34 'm=$(printf "%s\\n" "$s"|grep -cE "^(M.|.M)");' +
35 'd=$(printf "%s\\n" "$s"|grep -cE "^(D.|.D)");' +
36 'h=$(git rev-parse --short HEAD 2>/dev/null);' +
37 'ns=$(git diff --numstat 2>/dev/null;git diff --cached --numstat 2>/dev/null);' +
38 'il=$(printf "%s\\n" "$ns"|awk \'{if($1!="-")i+=$1}END{print i+0}\');' +
39 'dl=$(printf "%s\\n" "$ns"|awk \'{if($2!="-")d+=$2}END{print d+0}\');' +
40 'printf "YES\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s" "$(basename "$r")" "$b" "$w" "$a" "$m" "$d" "$h" "$il" "$dl"';
41
42/**
43 * Resolve the config file path using the engine's environment.
44 * @param $ - The engine interface.
45 * @returns The absolute path to the config file.
46 */
47async function resolveConfigPath($: EngineInterface): Promise<string> {
48 const xdg = await $.env.get('XDG_CONFIG_HOME').catch(() => undefined);
49 const home = await $.env.get('HOME').catch(() => undefined);
50 return configPath({ XDG_CONFIG_HOME: xdg, HOME: home });
51}
52
53/**
54 * Read and parse the config from disk, falling back to defaults on any error.
55 * @param $ - The engine interface.
56 * @returns The loaded config and any warnings raised while validating it.
57 */
58async function loadConfigFromDisk(
59 $: EngineInterface
60): Promise<{ config: Config; warnings: string[] }> {
61 try {
62 const text = await $.fs.read(await resolveConfigPath($)).catch(() => null);
63 return parseConfig(typeof text === 'string' ? text : null);
64 } catch {
65 return parseConfig(null);
66 }
67}
68
69/**
70 * Re-read the config when its mtime changed, or always when forced.
71 * @param $ - The engine interface.
72 * @param force - When `true`, reload regardless of the file's mtime.
73 * @returns `true` when the config was reloaded, `false` otherwise.
74 */
75async function reloadConfig($: EngineInterface, force: boolean): Promise<boolean> {
76 try {
77 const path = await resolveConfigPath($);
78 const stat = await $.fs.stat(path).catch(() => null);
79 const prev = await read($, configMtime);
80 if (!force && (!stat || !shouldReload(prev, stat))) {
81 return false;
82 }
83 const { config: cfg, warnings } = await loadConfigFromDisk($);
84 await update($, config, () => cfg);
85 await update($, configMtime, () => (stat ? stat.mtimeMs : null));
86 // Make a rejected/degraded config observable instead of silently showing defaults.
87 if (warnings.length) {
88 try {
89 await $.ui.toast(
90 `ccstatus: config had ${warnings.length} problem(s); using defaults where needed — run \`npx @sushant-kum/ccstatus\` to fix`
91 );
92 } catch {
93 /* guarded: never throw from a reload */
94 }
95 }
96 return true;
97 } catch {
98 return false;
99 }
100}
101
102/**
103 * Switch the active theme and persist it to the config file atomically.
104 * @param $ - The engine interface.
105 * @param name - The theme name to switch to.
106 * @returns A status message describing the outcome.
107 */
108async function setTheme($: EngineInterface, name: string): Promise<string> {
109 const cfg = (await read($, config)) as Config | null;
110 if (!cfg) {
111 return 'ccstatus: config not loaded yet.';
112 }
113 if (!name || !cfg.themes[name]) {
114 return `ccstatus: unknown theme "${name}". Available: ${Object.keys(cfg.themes).join(', ')}`;
115 }
116 const next: Config = { ...cfg, theme: name };
117 await update($, config, () => next);
118 const path = await resolveConfigPath($);
119 const tmp = path + '.tmp';
120 try {
121 // Atomic write, matching the TUI's saveConfigFile discipline. The sandbox fs
122 // has no rename, but $.process.run does (the same shell-out the git snapshot
123 // uses), and rename within one directory is atomic — so a reader never sees a
124 // half-written config.json, and a .bak keeps the prior file recoverable.
125 const existing = await $.fs.read(path).catch(() => null);
126 if (typeof existing === 'string') {
127 await $.fs.write(path + '.bak', existing).catch(() => {
128 /* no-op: a missing backup must not abort the write */
129 });
130 }
131 await $.fs.write(tmp, JSON.stringify(next, null, 2) + '\n');
132 const { exitCode } = await $.process.run(['mv', '-f', tmp, path], { timeoutMs: 5000 });
133 if (exitCode !== 0) {
134 return `ccstatus: theme set to ${name} (could not save the config file).`;
135 }
136 } catch {
137 return `ccstatus: theme set to ${name} (could not save the config file).`;
138 }
139 return `ccstatus: theme set to ${name}.`;
140}
141
142type UsageRaw = Awaited<ReturnType<EngineInterface['session']['usage']>>;
143
144/**
145 * Run the git probe in a directory, returning no-repo fields on any failure.
146 * @param $ - The engine interface.
147 * @param cwd - The directory to probe, or an empty string to skip the probe.
148 * @returns The parsed git fields for the directory.
149 */
150async function probeGit($: EngineInterface, cwd: string): Promise<ReturnType<typeof parseGit>> {
151 if (!cwd) {
152 return parseGit('NO');
153 }
154 try {
155 const { stdout } = await $.process.run(['sh', '-c', GIT], { cwd, timeoutMs: 5000 });
156 return parseGit(stdout || '');
157 } catch {
158 return parseGit('NO');
159 }
160}
161
162type UsageContext = NonNullable<UsageRaw>['context'];
163type UsageRateLimits = NonNullable<UsageRaw>['rateLimits'];
164
165/**
166 * Resolve the maximum context-window size from the raw context report.
167 * @param context - The raw context report, or `null`/`undefined` when absent.
168 * @returns The context-window size in tokens, or 0 when unavailable.
169 */
170function contextWindow(context: UsageContext | null): number {
171 return context?.breakdown?.maxTokens ?? context?.maxTokens ?? 0;
172}
173
174/**
175 * Reduce the context portion of the raw usage report into snapshot fields.
176 * @param context - The raw context report, or `null`/`undefined` when absent.
177 * @returns The normalized context usage figures.
178 */
179function extractContextUsage(
180 context: UsageContext | null
181): Pick<RawUsage & object, 'ctxTokens' | 'ctxPct' | 'cached' | 'input' | 'output' | 'ctxWindow'> {
182 const b = context?.breakdown ?? null;
183 const u = b?.apiUsage ?? null;
184 return {
185 ctxTokens: b?.totalTokens ?? context?.tokens ?? 0,
186 ctxPct: b?.percentage ?? context?.percent ?? 0,
187 cached: u ? u.cache_read_input_tokens + u.cache_creation_input_tokens : 0,
188 input: u?.input_tokens ?? 0,
189 output: u?.output_tokens ?? 0,
190 ctxWindow: contextWindow(context),
191 };
192}
193
194/**
195 * Reduce the rate-limit portion of the raw usage report into snapshot fields.
196 * @param rl - The raw rate-limit entries.
197 * @returns The normalized five-hour and weekly usage figures.
198 */
199function extractRateLimitUsage(
200 rl: UsageRateLimits
201): Pick<RawUsage & object, 'fivePct' | 'fiveReset' | 'weekPct' | 'weekReset'> {
202 const five = rl.find((r) => r.kind === 'five_hour') ?? null;
203 const week = rl.find((r) => r.kind === 'seven_day') ?? null;
204 return {
205 fivePct: five?.percentUsed ?? null,
206 fiveReset: five?.resetsAt ?? null,
207 weekPct: week?.percentUsed ?? null,
208 weekReset: week?.resetsAt ?? null,
209 };
210}
211
212/**
213 * Reduce the engine's raw usage report into the fields the snapshot needs.
214 * @param usageRaw - The raw usage report, or `null` when it could not be read.
215 * @returns The normalized usage figures.
216 */
217function extractUsage(usageRaw: UsageRaw | null): RawUsage {
218 const context = usageRaw?.context ?? null;
219 const rl = usageRaw?.rateLimits ?? [];
220 return {
221 ...extractContextUsage(context),
222 ...extractRateLimitUsage(rl),
223 startedAt: usageRaw?.startedAt ?? 0,
224 cost: usageRaw?.cost ?? null,
225 };
226}
227
228/**
229 * Gather a live snapshot from the session, git, and usage sources.
230 * @param $ - The engine interface.
231 * @param eff - The active reasoning effort, or `null` when unknown.
232 * @returns The assembled snapshot.
233 */
234async function measure($: EngineInterface, eff: string | null): Promise<Snapshot> {
235 const [version, model, cwd, sessionId, usageRaw] = await Promise.all([
236 $.session
237 .version()
238 .then((v) => v.version)
239 .catch(() => ''),
240 $.session.model().catch(() => ''),
241 $.session.cwd().catch(() => ''),
242 $.session.id().catch(() => ''),
243 $.session.usage({ breakdown: 'summary' }).catch(() => null),
244 ]);
245 const git = await probeGit($, cwd);
246 const usage = extractUsage(usageRaw);
247 const style = await read($, outputStyle).catch(() => null);
248 const width = await read($, termWidth).catch(() => 0);
249 return buildSnapshot({
250 version,
251 model,
252 effort: eff,
253 cwd,
254 now: await $.clock.now(),
255 sessionId,
256 outputStyle: style,
257 terminalWidth: width,
258 git,
259 usage,
260 });
261}
262
263/**
264 * Fire any due toasts and update the per-rule fired state, never throwing.
265 * @param $ - The engine interface.
266 * @param cfg - The active config.
267 * @param snap - The current snapshot the toast rules are evaluated against.
268 */
269async function fireToasts($: EngineInterface, cfg: Config, snap: Snapshot): Promise<void> {
270 try {
271 if (!cfg.surfaces.toasts.enabled) {
272 return;
273 }
274 const rules = cfg.surfaces.toasts.rules;
275 const fired = (await read($, toastFired)) ?? {};
276 const next: Record<string, boolean> = { ...fired };
277 for (const t of dueToasts(rules, snap, fired)) {
278 try {
279 await $.ui.toast(t.text);
280 } catch {
281 /* guarded */
282 }
283 next[t.key] = true;
284 }
285 for (const r of rules) {
286 if (!evalWhen(r.when, snap)) {
287 delete next[r.when];
288 }
289 }
290 if (JSON.stringify(next) !== JSON.stringify(fired)) {
291 await update($, toastFired, () => next);
292 }
293 } catch {
294 /* never throw from a refresh */
295 }
296}
297
298/**
299 * Fire any due toasts for a snapshot, never throwing. The native status line is
300 * rendered by the `ccstatus statusline` settings command, not the mod.
301 * @param $ - The engine interface.
302 * @param snap - The current snapshot to evaluate toasts against.
303 */
304async function applySurfaces($: EngineInterface, snap: Snapshot): Promise<void> {
305 try {
306 const cfg = (await read($, config)) as Config | null;
307 if (!cfg) {
308 return;
309 }
310 await fireToasts($, cfg, snap);
311 } catch {
312 /* never throw from a refresh */
313 }
314}
315
316let refreshing = false;
317/**
318 * Measure a fresh snapshot, persist it, and repaint all surfaces.
319 * @param $ - The engine interface.
320 */
321async function refresh($: EngineInterface): Promise<void> {
322 if (refreshing) {
323 return;
324 }
325 refreshing = true;
326 try {
327 const eff = await read($, effort).catch(() => null);
328 const s = await measure($, eff); // compute first, then write (updater is sync)
329 await update($, snapshot, () => s);
330 try {
331 const env = {
332 HOME: await $.env.get('HOME').catch(() => undefined),
333 XDG_CONFIG_HOME: await $.env.get('XDG_CONFIG_HOME').catch(() => undefined),
334 };
335 await $.fs.write(snapshotPath(env), JSON.stringify(s)).catch(() => {
336 /* no-op: snapshot persistence is best-effort */
337 });
338 } catch {
339 /* ignore snapshot persistence errors */
340 }
341 await applySurfaces($, s);
342 } catch {
343 /* keep last snapshot */
344 } finally {
345 refreshing = false;
346 }
347}
348
349/**
350 * Toggle the ccstatus pane open or closed.
351 * @param $ - The engine interface.
352 * @returns A status message describing the new pane state.
353 */
354async function togglePane($: EngineInterface): Promise<string> {
355 if (await read($, paneOpen)) {
356 await $.ui.close({ id: 'ccstatus' });
357 await update($, paneOpen, () => false);
358 return 'ccstatus pane closed.';
359 }
360 await $.ui.open({ id: 'ccstatus', title: 'ccstatus' });
361 await update($, paneOpen, () => true);
362 return 'ccstatus pane opened.';
363}
364
365/**
366 * Read the active reasoning effort out of an engine event.
367 *
368 * The streaming turn.step event exposes it as a bare value
369 * (`low`/`medium`/`high`/`xhigh`/`max`, or a number); the classic-hook input shape
370 * is `{ active }`. Both are read so capture works whichever event carries it.
371 * @param e - The engine event, inspected for an `effort` field.
372 * @returns The effort level as a string, or `''` when the event carries none.
373 */
374export function effortFromEvent(e: unknown): string {
375 const raw = (e as { effort?: unknown })?.effort;
376 if (typeof raw === 'string' || typeof raw === 'number') {
377 return String(raw);
378 }
379 const active = (raw as { active?: unknown })?.active;
380 return typeof active === 'string' ? active : '';
381}
382
383/**
384 * Capture the active reasoning effort from an engine event into plugin state.
385 * @param $ - The engine interface.
386 * @param e - The engine event, inspected for an `effort` field.
387 * @returns A promise that resolves once the effort has been recorded.
388 */
389function captureEffort($: EngineInterface, e: unknown): Promise<void> {
390 const value = effortFromEvent(e);
391 if (value) {
392 return update($, effort, () => value).then(
393 () => undefined,
394 () => undefined
395 );
396 }
397 return Promise.resolve();
398}
399
400/**
401 * Build the help text listing every `/ccstatus` operation.
402 * @returns A multi-line summary of the command's subcommands.
403 */
404function commandHelp(): string {
405 return [
406 'ccstatus commands:',
407 ' /ccstatus show this help',
408 ' /ccstatus toggle toggle the band above the prompt',
409 ' /ccstatus pane toggle the ccstatus pane',
410 ' /ccstatus theme <name> switch the palette theme',
411 ' /ccstatus reload reload config from disk',
412 ' /ccstatus edit how to open the interactive editor',
413 ' /ccstatus help show this help',
414 ].join('\n');
415}
416
417export const register: Register = (on) => {
418 on('session.start', async ($, e, next) => {
419 try {
420 await $.command.register({
421 name: 'ccstatus',
422 description: 'Show the ccstatus command menu',
423 argumentHint: '[toggle | pane | theme <name> | reload | edit | help]',
424 });
425 await reloadConfig($, true);
426 await refresh($);
427 $.clock.every(2000, () => void reloadConfig($, false).then(() => refresh($)));
428 } catch {
429 /* never block session start */
430 }
431 return next(e);
432 });
433
434 on('turn.complete', async ($, e, next) => {
435 await refresh($);
436 return next(e);
437 });
438
439 // The active reasoning effort rides on the streaming turn.step event
440 // (TurnStepInput.effort, a bare level), the function-hook event designed to carry
441 // it; turn.complete/tool.call do not, and the classic Stop hook is not dispatched
442 // to the mod at runtime (observed via a live probe). turn.step is a streaming hook
443 // (async generator): read the effort, then forward the stream with `yield* next(e)`.
444 on('turn.step', async function* ($, e, next) {
445 await captureEffort($, e);
446 return yield* next(e);
447 });
448
449 on('prompt.compose', async ($, e, next) => {
450 const r = await next(e);
451 const ev = e as { outputStyle?: { name?: unknown } | null };
452 if ('outputStyle' in ev) {
453 // Present but nameless (null/empty) means the default style: reset so a stale name does not linger.
454 const name = ev.outputStyle?.name;
455 const value = typeof name === 'string' && name ? name : null;
456 await update($, outputStyle, () => value).catch(() => undefined);
457 }
458 return r;
459 });
460
461 on('command.run', { command: 'ccstatus' }, async ($, e) => {
462 try {
463 const args = String((e as { args?: unknown })?.args ?? '').trim();
464 const [sub = '', ...rest] = args.split(/\s+/);
465 if (sub === 'toggle') {
466 const now = !(await read($, visible));
467 await update($, visible, () => now);
468 return { text: now ? 'ccstatus band shown.' : 'ccstatus band hidden.' };
469 }
470 if (sub === 'pane') {
471 return { text: await togglePane($) };
472 }
473 if (sub === 'reload') {
474 await reloadConfig($, true);
475 await refresh($);
476 return { text: 'ccstatus config reloaded.' };
477 }
478 if (sub === 'theme') {
479 return { text: await setTheme($, rest[0] ?? '') };
480 }
481 if (sub === 'edit') {
482 return {
483 text:
484 'Edit your layout with the ccstatus editor: run `npx @sushant-kum/ccstatus` in a terminal. ' +
485 'Changes are picked up automatically.',
486 };
487 }
488 if (sub === '' || sub === 'help') {
489 return { text: commandHelp() };
490 }
491 return { text: `unknown command: ${sub}\n\n${commandHelp()}` };
492 } catch {
493 return { text: 'ccstatus: command failed.' };
494 }
495 });
496
497 on('ui.close', async ($, e, next) => {
498 try {
499 if ((e as { id?: string }).id === 'ccstatus') {
500 await update($, paneOpen, () => false);
501 }
502 } catch {
503 /* ignore */
504 }
505 return next(e);
506 });
507
508 on('ui.render', { component: 'Pane', requestId: 'ccstatus' }, async ($, e, next) => {
509 try {
510 const cfg = await read($, config);
511 const snap = await read($, snapshot);
512 if (!cfg || !snap) {
513 return next(e);
514 }
515 const model = render(cfg, snap, { surface: 'pane', width: e.props.bodyColumns || 80 });
516 if (model.lines.length === 0) {
517 return next(e);
518 }
519 // eslint-disable-next-line @typescript-eslint/no-explicit-any -- engine boundary: $.ui.resolve + handler element types
520 return paintModel(model, $.ui.resolve(e) as any) as any;
521 } catch {
522 return next(e);
523 }
524 });
525
526 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
527 try {
528 if (e.props.hasSurvey || !(await read($, visible))) {
529 return next(e);
530 }
531 const cfg = await read($, config);
532 const snap = await read($, snapshot);
533 if (!cfg || !snap) {
534 return next(e);
535 }
536 const width = e.props.bodyColumns;
537 if (!width) {
538 return next(e);
539 } // not measured yet: let the engine draw
540 void update($, termWidth, () => width).catch(() => undefined);
541 const model = render(cfg, snap, { surface: 'band', width });
542 if (model.lines.length === 0) {
543 return next(e);
544 }
545 // eslint-disable-next-line @typescript-eslint/no-explicit-any -- engine boundary: $.ui.resolve + handler element types
546 return paintModel(model, $.ui.resolve(e) as any) as any;
547 } catch {
548 return next(e);
549 }
550 });
551};
552hooks/config-io.ts 55 lines1import { loadConfig } from './core.js';
2import type { Config } from './core.js';
3
4/**
5 * Resolve the absolute path to the shared config file from the environment.
6 * @param env - The process environment, read for `XDG_CONFIG_HOME` and `HOME`.
7 * @returns The absolute path to `config.json`.
8 */
9export function configPath(env: Record<string, string | undefined>): string {
10 const xdg = env['XDG_CONFIG_HOME'];
11 const base = xdg && xdg.startsWith('/') ? xdg : `${env['HOME'] ?? ''}/.config`;
12 return `${base}/ccstatus/config.json`;
13}
14
15/**
16 * Resolve the absolute path to the shared snapshot file from the environment.
17 * @param env - The process environment, read for `XDG_CONFIG_HOME` and `HOME`.
18 * @returns The absolute path to `snapshot.json`.
19 */
20export function snapshotPath(env: Record<string, string | undefined>): string {
21 const xdg = env['XDG_CONFIG_HOME'];
22 const base = xdg && xdg.startsWith('/') ? xdg : `${env['HOME'] ?? ''}/.config`;
23 return `${base}/ccstatus/snapshot.json`;
24}
25
26/**
27 * Parse config file text into a validated config, never throwing.
28 * @param text - The raw config file contents, or `null` when the file is absent.
29 * @returns The loaded config and any warnings raised while validating it.
30 */
31export function parseConfig(text: string | null): { config: Config; warnings: string[] } {
32 if (text === null) {
33 return loadConfig(undefined);
34 }
35 let parsed: unknown;
36 try {
37 parsed = JSON.parse(text);
38 } catch {
39 const fallback = loadConfig(undefined);
40 return { config: fallback.config, warnings: ['config file is not valid JSON; using defaults'] };
41 }
42 return loadConfig(parsed);
43}
44
45/**
46 * Decide whether the config should be reloaded given its last-seen mtime.
47 * @param prevMtime - The previously observed modification time, or `null` when never read.
48 * @param stat - The current file stat.
49 * @param stat.mtimeMs - The current modification time in milliseconds.
50 * @returns `true` when the config has not been read before or has changed since.
51 */
52export function shouldReload(prevMtime: number | null, stat: { mtimeMs: number }): boolean {
53 return prevMtime === null || stat.mtimeMs !== prevMtime;
54}
55hooks/core.js 5323 lines1var __defProp = Object.defineProperty;
2var __export = (target, all) => {
3 for (var name in all)
4 __defProp(target, name, { get: all[name], enumerable: true });
5};
6
7// packages/core/src/widgets/registry.ts
8var registry = {};
9function register(def) {
10 registry[def.type] = def;
11}
12
13// packages/core/src/layout/cells.ts
14function itemToCell(item, config, snapshot, commandOutputs) {
15 const def = registry[item.type];
16 if (!def) {
17 return null;
18 }
19 const value = def.format({ snapshot, item, commandOutputs });
20 if (value === null) {
21 return null;
22 }
23 const flex = item.type === "flex-separator";
24 const pad = flex ? "" : " ".repeat(Math.max(0, Math.floor(config.defaults.padding)));
25 const merge = item.type === "flex-separator" ? false : item.merge ?? false;
26 return { text: flex ? "" : `${pad}${value}${pad}`, merge, flex };
27}
28function lineToCells(items, config, snapshot, commandOutputs) {
29 return items.map((it) => itemToCell(it, config, snapshot, commandOutputs)).filter((c) => c !== null);
30}
31function willMerge(cells, index) {
32 var _a;
33 const cell = cells[index];
34 if (!cell || !cell.merge || cell.flex || index === 0) {
35 return false;
36 }
37 return !(((_a = cells[index - 1]) == null ? void 0 : _a.flex) ?? true);
38}
39function groupRuns(cells) {
40 const runs = [];
41 cells.forEach((c, i) => {
42 const run = runs[runs.length - 1];
43 if (run && willMerge(cells, i)) {
44 run.push(c);
45 } else {
46 runs.push([c]);
47 }
48 });
49 return runs;
50}
51function alignColumns(lines, align2) {
52 const runWidth = (run) => run.reduce((n, c) => n + c.text.length, 0);
53 const isFlexRun = (run) => {
54 var _a;
55 return run.length === 1 && (((_a = run[0]) == null ? void 0 : _a.flex) ?? false);
56 };
57 const lineRuns = lines.map(groupRuns);
58 const widths = [];
59 for (const runs of lineRuns) {
60 runs.forEach((run, j) => {
61 if (!isFlexRun(run)) {
62 widths[j] = Math.max(widths[j] ?? 0, runWidth(run));
63 }
64 });
65 }
66 return lineRuns.map(
67 (runs) => runs.flatMap((run, j) => {
68 if (isFlexRun(run)) {
69 return run.map((c) => ({ ...c }));
70 }
71 const deficit = (widths[j] ?? runWidth(run)) - runWidth(run);
72 const leftPad = deficit <= 0 ? 0 : align2 === "right" ? deficit : align2 === "center" ? Math.floor(deficit / 2) : 0;
73 const rightPad = deficit <= 0 ? 0 : deficit - leftPad;
74 return run.map((c, k) => {
75 const lead = k === 0 ? " ".repeat(leftPad) : "";
76 const tail = k === run.length - 1 ? " ".repeat(rightPad) : "";
77 return { ...c, text: `${lead}${c.text}${tail}` };
78 });
79 })
80 );
81}
82
83// packages/core/src/layout/compose.ts
84function mergeCells(cells) {
85 const out = [];
86 cells.forEach((c, i) => {
87 const prev = out[out.length - 1];
88 if (willMerge(cells, i) && prev) {
89 prev.text = `${prev.text}${c.text}`;
90 } else {
91 out.push({ ...c });
92 }
93 });
94 return out;
95}
96function truncate(segs, width) {
97 const total = segs.reduce((n, s) => n + s.text.length, 0);
98 if (total <= width) {
99 return segs;
100 }
101 let budget = width;
102 const out = [];
103 for (const s of segs) {
104 if (s.kind === "cap") {
105 continue;
106 }
107 if (budget <= 0) {
108 break;
109 }
110 if (s.text.length <= budget) {
111 out.push(s);
112 budget -= s.text.length;
113 } else {
114 out.push({ ...s, text: s.text.slice(0, budget) });
115 budget = 0;
116 }
117 }
118 return out;
119}
120function composeLine(cells, mode, width, glyph = "\u2592") {
121 var _a, _b;
122 const merged = mergeCells(cells);
123 const content = merged.filter((c) => !c.flex);
124 const flexCount = merged.filter((c) => c.flex).length;
125 const contentWidth = content.reduce((n, c) => n + c.text.length, 0);
126 let sepWidth = 0;
127 if (mode === "powerline") {
128 sepWidth = Math.max(0, content.length - 1) + (content.length ? 2 : 0);
129 } else if (mode === "space") {
130 sepWidth = Math.max(0, content.length - 1);
131 }
132 const leftover = Math.max(0, width - contentWidth - sepWidth);
133 const per = flexCount ? Math.floor(leftover / flexCount) : 0;
134 let extra = flexCount ? leftover - per * flexCount : 0;
135 const flexWidth = () => {
136 const w = per + (extra > 0 ? 1 : 0);
137 if (extra > 0) {
138 extra -= 1;
139 }
140 return w;
141 };
142 const segs = [];
143 const emitStartCap = mode === "powerline" && content.length > 0;
144 if (emitStartCap) {
145 segs.push({ kind: "cap", text: glyph, fg: (_a = content[0]) == null ? void 0 : _a.bg });
146 }
147 let ci = 0;
148 for (const c of merged) {
149 if (c.flex) {
150 segs.push({ kind: "flex", text: " ".repeat(flexWidth()) });
151 continue;
152 }
153 segs.push({ kind: "cell", text: c.text, fg: c.fg, bg: c.bg });
154 const isLast = ci === content.length - 1;
155 const next = content[ci + 1];
156 if (!isLast && next) {
157 if (mode === "powerline") {
158 segs.push({ kind: "separator", text: glyph, fg: c.bg, bg: next.bg });
159 } else if (mode === "space") {
160 segs.push({ kind: "separator", text: " " });
161 }
162 }
163 ci += 1;
164 }
165 if (emitStartCap) {
166 segs.push({ kind: "cap", text: glyph, fg: (_b = content[content.length - 1]) == null ? void 0 : _b.bg });
167 }
168 return truncate(segs, width);
169}
170
171// packages/core/src/colors.ts
172function isColorIndex(x) {
173 return typeof x === "number" && Number.isInteger(x) && x >= 16 && x <= 255;
174}
175var asIndex = (n) => n;
176
177// packages/core/src/theme/xterm256.ts
178var BLACK = asIndex(16);
179var WHITE = asIndex(231);
180var LEVEL = [0, 95, 135, 175, 215, 255];
181function indexToRgb(idx) {
182 const i = Math.min(255, Math.max(16, Math.round(idx)));
183 if (i >= 232) {
184 const g = 8 + (i - 232) * 10;
185 return [g, g, g];
186 }
187 const n = i - 16;
188 return [LEVEL[Math.floor(n / 36)] ?? 0, LEVEL[Math.floor(n % 36 / 6)] ?? 0, LEVEL[n % 6] ?? 0];
189}
190var hex2 = (v) => v.toString(16).padStart(2, "0");
191function indexToHex(i) {
192 const [r, g, b] = indexToRgb(i);
193 return `#${hex2(r)}${hex2(g)}${hex2(b)}`;
194}
195var NAMED_INDEX = /* @__PURE__ */ new Map([
196 ["black", asIndex(16)],
197 ["brightBlack", asIndex(240)],
198 ["gray", asIndex(240)],
199 ["red", asIndex(160)],
200 ["brightRed", asIndex(196)],
201 ["green", asIndex(40)],
202 ["brightGreen", asIndex(46)],
203 ["yellow", asIndex(184)],
204 ["brightYellow", asIndex(226)],
205 ["blue", asIndex(20)],
206 ["brightBlue", asIndex(21)],
207 ["magenta", asIndex(164)],
208 ["brightMagenta", asIndex(201)],
209 ["cyan", asIndex(44)],
210 ["brightCyan", asIndex(51)],
211 ["white", asIndex(250)],
212 ["brightWhite", asIndex(231)]
213]);
214
215// packages/core/src/theme/contrast.ts
216var LUMA_THRESHOLD = 128;
217function contrastFg(bg) {
218 const [r, g, b] = indexToRgb(bg);
219 const luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
220 return luma >= LUMA_THRESHOLD ? BLACK : WHITE;
221}
222
223// packages/core/src/layout/palette.ts
224function assignPaletteColors(cells, theme) {
225 if (theme.length === 0) {
226 return cells.map((c) => ({ ...c }));
227 }
228 const out = [];
229 let slot = -1;
230 let prev;
231 for (const c of cells) {
232 if (c.flex) {
233 out.push({ ...c });
234 prev = c;
235 continue;
236 }
237 const continuation = c.merge === true && prev !== void 0 && !prev.flex;
238 if (!continuation) {
239 slot += 1;
240 }
241 const pal = theme[slot % theme.length];
242 const bg = pal == null ? void 0 : pal.bg;
243 const fg = (pal == null ? void 0 : pal.fg) ?? (bg !== void 0 ? contrastFg(bg) : void 0);
244 out.push({ ...c, fg, bg });
245 prev = c;
246 }
247 return out;
248}
249
250// packages/core/src/format.ts
251function fmtNum(n) {
252 const trim = (v, suffix) => `${v.toFixed(1).replace(/\.0$/, "")}${suffix}`;
253 if (Math.abs(n) >= 1e6) {
254 return trim(n / 1e6, "M");
255 }
256 if (Math.abs(n) >= 1e3) {
257 return trim(n / 1e3, "k");
258 }
259 return String(Math.round(n));
260}
261function fmtDur(ms) {
262 let s = Math.max(0, Math.floor(ms / 1e3));
263 const h = Math.floor(s / 3600);
264 s -= h * 3600;
265 const m = Math.floor(s / 60);
266 s -= m * 60;
267 if (h > 0) {
268 return `${h}h ${m}m`;
269 }
270 if (m > 0) {
271 return `${m}m ${s}s`;
272 }
273 return `${s}s`;
274}
275function pct(x) {
276 return `${Math.round(x)}%`;
277}
278function bar(x, width = 5) {
279 const filled = Math.floor(Math.min(100, Math.max(0, x)) / 100 * width);
280 return "\u2588".repeat(filled) + "\u2591".repeat(width - filled);
281}
282
283// packages/core/src/widgets/data-widgets.ts
284var labeled = (raw, label, value) => raw ? value : `${label}: ${value}`;
285var rawOf = (item) => "rawValue" in item ? item.rawValue : void 0;
286register({ type: "model", label: "Model", format: ({ snapshot }) => snapshot.model || null });
287register({
288 type: "version",
289 label: "Version",
290 format: ({ snapshot, item }) => snapshot.version ? rawOf(item) ? snapshot.version : `v${snapshot.version}` : null
291});
292register({
293 type: "context-length",
294 label: "Ctx",
295 format: ({ snapshot, item }) => labeled(rawOf(item), "Ctx", fmtNum(snapshot.ctxTokens))
296});
297register({
298 type: "context-percentage",
299 label: "Ctx Used",
300 format: ({ snapshot, item }) => labeled(rawOf(item), "Ctx Used", pct(snapshot.ctxPct))
301});
302register({
303 type: "tokens-input",
304 label: "In",
305 format: ({ snapshot, item }) => labeled(rawOf(item), "In", fmtNum(snapshot.input))
306});
307register({
308 type: "tokens-output",
309 label: "Out",
310 format: ({ snapshot, item }) => labeled(rawOf(item), "Out", fmtNum(snapshot.output))
311});
312register({
313 type: "tokens-cached",
314 label: "Cached",
315 format: ({ snapshot, item }) => labeled(rawOf(item), "Cached", fmtNum(snapshot.cached))
316});
317register({
318 type: "tokens-total",
319 label: "Total",
320 format: ({ snapshot, item }) => labeled(rawOf(item), "Total", fmtNum(snapshot.total))
321});
322register({
323 type: "session-clock",
324 label: "Session",
325 format: ({ snapshot, item }) => labeled(rawOf(item), "Session", fmtDur(snapshot.now - snapshot.startedAt))
326});
327register({
328 type: "cwd",
329 label: "cwd",
330 format: ({ snapshot }) => {
331 if (!snapshot.cwd) {
332 return null;
333 }
334 const parts = snapshot.cwd.split("/").filter(Boolean);
335 return parts[parts.length - 1] ?? snapshot.cwd;
336 }
337});
338register({
339 type: "context-bar",
340 label: "Ctx Bar",
341 format: ({ snapshot }) => bar(snapshot.ctxPct)
342});
343register({
344 type: "context-remaining",
345 label: "Ctx Left",
346 format: ({ snapshot, item }) => labeled(rawOf(item), "Ctx Left", pct(100 - snapshot.ctxPct))
347});
348register({
349 type: "thinking-effort",
350 label: "Effort",
351 // The engine only reports an explicit effort level; when none is set it exposes
352 // nothing, so we can't derive a level here. Match ccstatusline and label that
353 // case "default" rather than inventing a level or hiding the widget. See DEC-0026.
354 format: ({ snapshot, item }) => labeled(rawOf(item), "Effort", snapshot.effort || "default")
355});
356register({
357 type: "session-id",
358 label: "Session ID",
359 format: ({ snapshot, item }) => snapshot.sessionId ? rawOf(item) ? snapshot.sessionId : snapshot.sessionId.slice(0, 8) : null
360});
361register({
362 type: "context-window",
363 label: "Ctx Window",
364 format: ({ snapshot, item }) => snapshot.ctxWindow > 0 ? labeled(rawOf(item), "Window", fmtNum(snapshot.ctxWindow)) : null
365});
366register({
367 type: "output-style",
368 label: "Style",
369 format: ({ snapshot, item }) => snapshot.outputStyle ? labeled(rawOf(item), "Style", snapshot.outputStyle) : null
370});
371register({
372 type: "terminal-width",
373 label: "Width",
374 format: ({ snapshot, item }) => snapshot.terminalWidth > 0 ? labeled(rawOf(item), "Width", String(snapshot.terminalWidth)) : null
375});
376
377// packages/core/src/widgets/git-widgets.ts
378register({
379 type: "git-branch",
380 label: "Branch",
381 format: ({ snapshot }) => snapshot.repo ? `\u270E ${snapshot.gitBranch || "?"}` : null
382});
383register({
384 type: "git-root-dir",
385 label: "Git root",
386 format: ({ snapshot }) => snapshot.repo ? `\u2302 ${snapshot.gitRoot || "?"}` : null
387});
388register({
389 type: "git-changes",
390 label: "Changes",
391 format: ({ snapshot }) => snapshot.repo ? `(+${snapshot.added} ~${snapshot.modified} -${snapshot.deleted})` : null
392});
393register({
394 type: "git-worktree",
395 label: "Worktree",
396 // Inside a repo the widget stays visible: the worktree name, or a placeholder
397 // when the checkout is the main working tree rather than a linked worktree.
398 format: ({ snapshot }) => snapshot.repo ? `\u2387 ${snapshot.gitWorktree || "\u2014"}` : null
399});
400register({
401 type: "git-insertions",
402 label: "Insertions",
403 format: ({ snapshot }) => snapshot.repo ? `+${snapshot.insertions}` : null
404});
405register({
406 type: "git-deletions",
407 label: "Deletions",
408 format: ({ snapshot }) => snapshot.repo ? `-${snapshot.deletions}` : null
409});
410register({
411 type: "git-sha",
412 label: "SHA",
413 format: ({ snapshot }) => snapshot.repo && snapshot.gitSha ? snapshot.gitSha : null
414});
415
416// packages/core/src/widgets/usage-widgets.ts
417function until(iso, now) {
418 if (!iso) {
419 return null;
420 }
421 const t = Date.parse(iso);
422 if (Number.isNaN(t)) {
423 return null;
424 }
425 const d = t - now;
426 return d > 0 ? d : null;
427}
428register({
429 type: "cost",
430 label: "Cost",
431 format: ({ snapshot }) => snapshot.cost === null ? null : `$${snapshot.cost.toFixed(2)}`
432});
433register({
434 type: "rate-limit-5h",
435 label: "Session limit",
436 format: ({ snapshot }) => {
437 const p = snapshot.fivePct ?? 0;
438 const reset = until(snapshot.fiveReset, snapshot.now);
439 return `Session: ${bar(p)} ${pct(p)}${reset !== null ? ` ${fmtDur(reset)}` : ""}`;
440 }
441});
442register({
443 type: "rate-limit-week",
444 label: "Weekly limit",
445 format: ({ snapshot }) => {
446 const p = snapshot.weekPct ?? 0;
447 const reset = until(snapshot.weekReset, snapshot.now);
448 return `Weekly: ${pct(p)}${reset !== null ? ` ${fmtDur(reset)}` : ""}`;
449 }
450});
451register({
452 type: "block-timer",
453 label: "Block",
454 format: ({ snapshot }) => {
455 const reset = until(snapshot.blockReset, snapshot.now);
456 return reset === null ? null : `Block: ${fmtDur(reset)}`;
457 }
458});
459register({
460 type: "session-usage",
461 label: "Session %",
462 format: ({ snapshot }) => `Session: ${pct(snapshot.fivePct ?? 0)}`
463 // unknown shows 0% (DEC-0033)
464});
465register({
466 type: "weekly-usage",
467 label: "Weekly %",
468 format: ({ snapshot }) => `Weekly: ${pct(snapshot.weekPct ?? 0)}`
469 // unknown shows 0% (DEC-0033)
470});
471register({
472 type: "reset-timer",
473 label: "Reset",
474 format: ({ snapshot }) => {
475 const r = until(snapshot.fiveReset, snapshot.now);
476 return r === null ? null : `Reset: ${fmtDur(r)}`;
477 }
478});
479register({
480 type: "weekly-reset-timer",
481 label: "Weekly Reset",
482 format: ({ snapshot }) => {
483 const r = until(snapshot.weekReset, snapshot.now);
484 return r === null ? null : `Weekly Reset: ${fmtDur(r)}`;
485 }
486});
487register({
488 type: "session-cost-rate",
489 label: "Cost/hr",
490 format: ({ snapshot }) => {
491 if (snapshot.cost === null) {
492 return null;
493 }
494 const ms = snapshot.now - snapshot.startedAt;
495 if (ms < 6e4) {
496 return null;
497 }
498 return `$${(snapshot.cost / (ms / 36e5)).toFixed(2)}/hr`;
499 }
500});
501
502// packages/core/src/widgets/custom-widgets.ts
503register({
504 type: "custom-text",
505 label: "Custom text",
506 format: ({ item }) => {
507 const text = item.type === "custom-text" ? item.text : "";
508 return text.length ? text : null;
509 }
510});
511register({
512 type: "custom-command",
513 label: "Custom command",
514 format: ({ item, commandOutputs }) => {
515 const out = (commandOutputs[item.id] ?? "").trim();
516 return out.length ? out : null;
517 }
518});
519register({ type: "flex-separator", label: "Flex separator", format: () => "" });
520
521// packages/core/src/render.ts
522function render(config, snapshot, opts) {
523 const surface = config.surfaces[opts.surface];
524 if (!surface.enabled) {
525 return { lines: [] };
526 }
527 const outputs = opts.commandOutputs ?? {};
528 const theme = Object.hasOwn(config.themes, config.theme) ? config.themes[config.theme] ?? [] : [];
529 let lineCells = surface.lines.map((items) => lineToCells(items, config, snapshot, outputs)).filter((cells) => cells.length > 0);
530 if (config.defaults.alignColumns) {
531 lineCells = alignColumns(lineCells, config.defaults.align);
532 }
533 const lines = lineCells.map((cells) => assignPaletteColors(cells, theme)).map((cells) => ({
534 segments: composeLine(cells, config.defaults.separator, opts.width, config.defaults.glyph)
535 }));
536 return { lines };
537}
538
539// packages/core/src/ansi.ts
540var clampIndex = (i) => Math.min(255, Math.max(16, Math.round(i)));
541function sgr(seg) {
542 const codes = [];
543 if (seg.fg !== void 0) {
544 codes.push(`\x1B[38;5;${clampIndex(seg.fg)}m`);
545 }
546 if (seg.bg !== void 0) {
547 codes.push(`\x1B[48;5;${clampIndex(seg.bg)}m`);
548 }
549 if (!codes.length) {
550 return seg.text;
551 }
552 return `${codes.join("")}${seg.text}\x1B[0m`;
553}
554function toAnsi(model) {
555 return model.lines.map((line) => line.segments.map(sgr).join("")).join("\n");
556}
557
558// packages/core/src/theme/themes.ts
559var mk = (rows) => rows.map(([fg, bg]) => ({ fg: asIndex(fg), bg: asIndex(bg) }));
560var zip = (fg, bg) => fg.map((f, i) => ({ fg: asIndex(f), bg: asIndex(bg[i] ?? f) }));
561var builtinThemes = {
562 default: mk([
563 [16, 44],
564 [231, 20],
565 [16, 226],
566 [231, 240],
567 [16, 40]
568 ]),
569 nord: zip([16, 254, 231, 231, 16], [73, 239, 25, 96, 152]),
570 "nord-aurora": zip([231, 16, 231, 16, 16], [131, 220, 68, 108, 176]),
571 monokai: zip([235, 255, 235, 16, 235], [148, 238, 186, 141, 81]),
572 solarized: zip([231, 234, 254, 16, 234], [33, 136, 240, 37, 254]),
573 minimal: zip([255, 232, 255, 232, 252], [240, 251, 233, 248, 236]),
574 dracula: zip([235, 235, 235, 235, 231], [141, 253, 204, 117, 236]),
575 catppuccin: zip([235, 255, 235, 235, 235], [176, 238, 150, 210, 111]),
576 gruvbox: zip([16, 235, 235, 16, 235], [167, 214, 246, 109, 142]),
577 onedark: zip([235, 251, 235, 16, 235], [75, 237, 114, 204, 180]),
578 tokyonight: zip([16, 234, 16, 234, 234], [111, 248, 176, 221, 80])
579};
580var legacyBuiltinThemes = {
581 default: mk([
582 [16, 44],
583 [231, 20],
584 [16, 226],
585 [231, 240],
586 [16, 40]
587 ]),
588 classic: mk([
589 [16, 184],
590 [16, 250],
591 [16, 40],
592 [231, 20],
593 [16, 164],
594 [16, 44],
595 [16, 226],
596 [231, 160]
597 ]),
598 nord: mk([
599 [16, 51],
600 [16, 44],
601 [16, 20],
602 [231, 240],
603 [16, 21],
604 [16, 40],
605 [16, 184],
606 [231, 16]
607 ]),
608 dracula: mk([
609 [16, 164],
610 [16, 201],
611 [16, 46],
612 [16, 51],
613 [16, 226],
614 [16, 196],
615 [231, 240],
616 [231, 164]
617 ]),
618 gruvbox: mk([
619 [16, 184],
620 [16, 226],
621 [16, 40],
622 [16, 44],
623 [16, 160],
624 [16, 164],
625 [231, 240],
626 [231, 16]
627 ]),
628 monokai: mk([
629 [16, 46],
630 [16, 226],
631 [16, 201],
632 [16, 51],
633 [16, 196],
634 [231, 240],
635 [16, 184],
636 [231, 16]
637 ]),
638 "one-dark": mk([
639 [16, 20],
640 [16, 21],
641 [16, 40],
642 [16, 164],
643 [16, 184],
644 [16, 44],
645 [231, 240],
646 [231, 16]
647 ]),
648 solarized: mk([
649 [231, 20],
650 [16, 44],
651 [16, 184],
652 [231, 40],
653 [231, 164],
654 [231, 160],
655 [231, 240],
656 [231, 16]
657 ]),
658 "tokyo-night": mk([
659 [16, 21],
660 [16, 20],
661 [16, 46],
662 [16, 201],
663 [16, 226],
664 [16, 51],
665 [231, 240],
666 [231, 16]
667 ])
668};
669var legacyThemeAliases = {
670 "one-dark": "onedark",
671 "tokyo-night": "tokyonight",
672 classic: "default"
673};
674function sameTheme(a, b) {
675 return a.length === b.length && a.every((s, i) => {
676 var _a, _b;
677 return s.fg === ((_a = b[i]) == null ? void 0 : _a.fg) && s.bg === ((_b = b[i]) == null ? void 0 : _b.bg);
678 });
679}
680function withBuiltinThemes(saved) {
681 const out = {};
682 for (const [name, theme] of Object.entries(saved)) {
683 const legacy2 = legacyBuiltinThemes[name];
684 if (legacy2 && sameTheme(theme, legacy2)) {
685 continue;
686 }
687 out[name] = theme;
688 }
689 for (const [name, theme] of Object.entries(builtinThemes)) {
690 if (!Object.hasOwn(out, name)) {
691 out[name] = theme.map((s) => ({ ...s }));
692 }
693 }
694 return out;
695}
696
697// packages/core/src/toast.ts
698var TOAST_FIELDS = {
699 ctxPct: (s) => s.ctxPct,
700 fivePct: (s) => s.fivePct,
701 weekPct: (s) => s.weekPct,
702 ctxTokens: (s) => s.ctxTokens,
703 total: (s) => s.total,
704 cost: (s) => s.cost
705};
706var WHEN_RE = /^\s*([a-zA-Z]+)\s*(>=|<=|==|>|<)\s*(-?\d+(?:\.\d+)?)\s*$/;
707function isValidWhen(when) {
708 const m = WHEN_RE.exec(when);
709 if (m === null) {
710 return false;
711 }
712 const field = m[1];
713 return field !== void 0 && field in TOAST_FIELDS;
714}
715function evalWhen(when, snapshot) {
716 const m = WHEN_RE.exec(when);
717 if (!m) {
718 return false;
719 }
720 const field = m[1];
721 const getter = field === void 0 ? void 0 : TOAST_FIELDS[field];
722 if (!getter) {
723 return false;
724 }
725 const value = getter(snapshot);
726 if (value === null || value === void 0 || Number.isNaN(value)) {
727 return false;
728 }
729 const n = Number(m[3]);
730 switch (m[2]) {
731 case ">":
732 return value > n;
733 case ">=":
734 return value >= n;
735 case "<":
736 return value < n;
737 case "<=":
738 return value <= n;
739 case "==":
740 return value === n;
741 default:
742 return false;
743 }
744}
745
746// packages/core/src/config/defaults.ts
747var defaultConfig = {
748 version: 1,
749 theme: "default",
750 themes: structuredClone(builtinThemes),
751 defaults: {
752 separator: "powerline",
753 padding: 1,
754 align: "left",
755 glyph: "\u2592",
756 invert: false,
757 alignColumns: false
758 },
759 surfaces: {
760 band: {
761 enabled: true,
762 lines: [
763 [
764 { id: "d-version", type: "version" },
765 { id: "d-model", type: "model" },
766 { id: "d-ctx", type: "context-length" },
767 { id: "d-ctxp", type: "context-percentage" }
768 ]
769 ]
770 },
771 statusline: { enabled: false, lines: [[]] },
772 pane: { enabled: false, lines: [[]] },
773 toasts: {
774 enabled: true,
775 rules: [{ when: "ctxPct>80", text: "Context over 80%", once: true }]
776 }
777 }
778};
779
780// packages/core/src/config/links.ts
781var LINKABLE = ["band", "statusline", "pane"];
782var clone = (v) => JSON.parse(JSON.stringify(v));
783function linkedSurfaces(surfaces) {
784 return LINKABLE.filter((name) => surfaces[name].linked);
785}
786function writeLinkedLines(surfaces, surface, lines) {
787 const next = { ...surfaces };
788 next[surface] = { ...surfaces[surface], lines: clone(lines) };
789 if (surfaces[surface].linked) {
790 for (const member of LINKABLE) {
791 if (member !== surface && surfaces[member].linked) {
792 next[member] = { ...surfaces[member], lines: clone(lines) };
793 }
794 }
795 }
796 return next;
797}
798function normalizeLinks(surfaces, warn) {
799 const linked = linkedSurfaces(surfaces);
800 if (linked.length < 2) {
801 for (const name of linked) {
802 delete surfaces[name].linked;
803 warn(`dropped lone surface link on "${name}"`);
804 }
805 return;
806 }
807 const canonical = linked[0];
808 if (!canonical) {
809 return;
810 }
811 const source = JSON.stringify(surfaces[canonical].lines);
812 let diverged = false;
813 for (const name of linked) {
814 if (name === canonical) {
815 continue;
816 }
817 if (JSON.stringify(surfaces[name].lines) !== source) {
818 surfaces[name].lines = clone(surfaces[canonical].lines);
819 diverged = true;
820 }
821 }
822 if (diverged) {
823 warn(`linked surfaces diverged; synced to "${canonical}"`);
824 }
825}
826
827// node_modules/zod/v3/external.js
828var external_exports = {};
829__export(external_exports, {
830 BRAND: () => BRAND,
831 DIRTY: () => DIRTY,
832 EMPTY_PATH: () => EMPTY_PATH,
833 INVALID: () => INVALID,
834 NEVER: () => NEVER,
835 OK: () => OK,
836 ParseStatus: () => ParseStatus,
837 Schema: () => ZodType,
838 ZodAny: () => ZodAny,
839 ZodArray: () => ZodArray,
840 ZodBigInt: () => ZodBigInt,
841 ZodBoolean: () => ZodBoolean,
842 ZodBranded: () => ZodBranded,
843 ZodCatch: () => ZodCatch,
844 ZodDate: () => ZodDate,
845 ZodDefault: () => ZodDefault,
846 ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
847 ZodEffects: () => ZodEffects,
848 ZodEnum: () => ZodEnum,
849 ZodError: () => ZodError,
850 ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
851 ZodFunction: () => ZodFunction,
852 ZodIntersection: () => ZodIntersection,
853 ZodIssueCode: () => ZodIssueCode,
854 ZodLazy: () => ZodLazy,
855 ZodLiteral: () => ZodLiteral,
856 ZodMap: () => ZodMap,
857 ZodNaN: () => ZodNaN,
858 ZodNativeEnum: () => ZodNativeEnum,
859 ZodNever: () => ZodNever,
860 ZodNull: () => ZodNull,
861 ZodNullable: () => ZodNullable,
862 ZodNumber: () => ZodNumber,
863 ZodObject: () => ZodObject,
864 ZodOptional: () => ZodOptional,
865 ZodParsedType: () => ZodParsedType,
866 ZodPipeline: () => ZodPipeline,
867 ZodPromise: () => ZodPromise,
868 ZodReadonly: () => ZodReadonly,
869 ZodRecord: () => ZodRecord,
870 ZodSchema: () => ZodType,
871 ZodSet: () => ZodSet,
872 ZodString: () => ZodString,
873 ZodSymbol: () => ZodSymbol,
874 ZodTransformer: () => ZodEffects,
875 ZodTuple: () => ZodTuple,
876 ZodType: () => ZodType,
877 ZodUndefined: () => ZodUndefined,
878 ZodUnion: () => ZodUnion,
879 ZodUnknown: () => ZodUnknown,
880 ZodVoid: () => ZodVoid,
881 addIssueToContext: () => addIssueToContext,
882 any: () => anyType,
883 array: () => arrayType,
884 bigint: () => bigIntType,
885 boolean: () => booleanType,
886 coerce: () => coerce,
887 custom: () => custom,
888 date: () => dateType,
889 datetimeRegex: () => datetimeRegex,
890 defaultErrorMap: () => en_default,
891 discriminatedUnion: () => discriminatedUnionType,
892 effect: () => effectsType,
893 enum: () => enumType,
894 function: () => functionType,
895 getErrorMap: () => getErrorMap,
896 getParsedType: () => getParsedType,
897 instanceof: () => instanceOfType,
898 intersection: () => intersectionType,
899 isAborted: () => isAborted,
900 isAsync: () => isAsync,
901 isDirty: () => isDirty,
902 isValid: () => isValid,
903 late: () => late,
904 lazy: () => lazyType,
905 literal: () => literalType,
906 makeIssue: () => makeIssue,
907 map: () => mapType,
908 nan: () => nanType,
909 nativeEnum: () => nativeEnumType,
910 never: () => neverType,
911 null: () => nullType,
912 nullable: () => nullableType,
913 number: () => numberType,
914 object: () => objectType,
915 objectUtil: () => objectUtil,
916 oboolean: () => oboolean,
917 onumber: () => onumber,
918 optional: () => optionalType,
919 ostring: () => ostring,
920 pipeline: () => pipelineType,
921 preprocess: () => preprocessType,
922 promise: () => promiseType,
923 quotelessJson: () => quotelessJson,
924 record: () => recordType,
925 set: () => setType,
926 setErrorMap: () => setErrorMap,
927 strictObject: () => strictObjectType,
928 string: () => stringType,
929 symbol: () => symbolType,
930 transformer: () => effectsType,
931 tuple: () => tupleType,
932 undefined: () => undefinedType,
933 union: () => unionType,
934 unknown: () => unknownType,
935 util: () => util,
936 void: () => voidType
937});
938
939// node_modules/zod/v3/helpers/util.js
940var util;
941(function(util2) {
942 util2.assertEqual = (_) => {
943 };
944 function assertIs(_arg) {
945 }
946 util2.assertIs = assertIs;
947 function assertNever(_x) {
948 throw new Error();
949 }
950 util2.assertNever = assertNever;
951 util2.arrayToEnum = (items) => {
952 const obj = {};
953 for (const item of items) {
954 obj[item] = item;
955 }
956 return obj;
957 };
958 util2.getValidEnumValues = (obj) => {
959 const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
960 const filtered = {};
961 for (const k of validKeys) {
962 filtered[k] = obj[k];
963 }
964 return util2.objectValues(filtered);
965 };
966 util2.objectValues = (obj) => {
967 return util2.objectKeys(obj).map(function(e) {
968 return obj[e];
969 });
970 };
971 util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
972 const keys = [];
973 for (const key in object) {
974 if (Object.prototype.hasOwnProperty.call(object, key)) {
975 keys.push(key);
976 }
977 }
978 return keys;
979 };
980 util2.find = (arr, checker) => {
981 for (const item of arr) {
982 if (checker(item))
983 return item;
984 }
985 return void 0;
986 };
987 util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
988 function joinValues(array, separator = " | ") {
989 return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
990 }
991 util2.joinValues = joinValues;
992 util2.jsonStringifyReplacer = (_, value) => {
993 if (typeof value === "bigint") {
994 return value.toString();
995 }
996 return value;
997 };
998})(util || (util = {}));
999var objectUtil;
1000(function(objectUtil2) {
1001 objectUtil2.mergeShapes = (first, second) => {
1002 return {
1003 ...first,
1004 ...second
1005 // second overwrites first
1006 };
1007 };
1008})(objectUtil || (objectUtil = {}));
1009var ZodParsedType = util.arrayToEnum([
1010 "string",
1011 "nan",
1012 "number",
1013 "integer",
1014 "float",
1015 "boolean",
1016 "date",
1017 "bigint",
1018 "symbol",
1019 "function",
1020 "undefined",
1021 "null",
1022 "array",
1023 "object",
1024 "unknown",
1025 "promise",
1026 "void",
1027 "never",
1028 "map",
1029 "set"
1030]);
1031var getParsedType = (data) => {
1032 const t = typeof data;
1033 switch (t) {
1034 case "undefined":
1035 return ZodParsedType.undefined;
1036 case "string":
1037 return ZodParsedType.string;
1038 case "number":
1039 return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
1040 case "boolean":
1041 return ZodParsedType.boolean;
1042 case "function":
1043 return ZodParsedType.function;
1044 case "bigint":
1045 return ZodParsedType.bigint;
1046 case "symbol":
1047 return ZodParsedType.symbol;
1048 case "object":
1049 if (Array.isArray(data)) {
1050 return ZodParsedType.array;
1051 }
1052 if (data === null) {
1053 return ZodParsedType.null;
1054 }
1055 if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1056 return ZodParsedType.promise;
1057 }
1058 if (typeof Map !== "undefined" && data instanceof Map) {
1059 return ZodParsedType.map;
1060 }
1061 if (typeof Set !== "undefined" && data instanceof Set) {
1062 return ZodParsedType.set;
1063 }
1064 if (typeof Date !== "undefined" && data instanceof Date) {
1065 return ZodParsedType.date;
1066 }
1067 return ZodParsedType.object;
1068 default:
1069 return ZodParsedType.unknown;
1070 }
1071};
1072
1073// node_modules/zod/v3/ZodError.js
1074var ZodIssueCode = util.arrayToEnum([
1075 "invalid_type",
1076 "invalid_literal",
1077 "custom",
1078 "invalid_union",
1079 "invalid_union_discriminator",
1080 "invalid_enum_value",
1081 "unrecognized_keys",
1082 "invalid_arguments",
1083 "invalid_return_type",
1084 "invalid_date",
1085 "invalid_string",
1086 "too_small",
1087 "too_big",
1088 "invalid_intersection_types",
1089 "not_multiple_of",
1090 "not_finite"
1091]);
1092var quotelessJson = (obj) => {
1093 const json = JSON.stringify(obj, null, 2);
1094 return json.replace(/"([^"]+)":/g, "$1:");
1095};
1096var ZodError = class _ZodError extends Error {
1097 get errors() {
1098 return this.issues;
1099 }
1100 constructor(issues) {
1101 super();
1102 this.issues = [];
1103 this.addIssue = (sub) => {
1104 this.issues = [...this.issues, sub];
1105 };
1106 this.addIssues = (subs = []) => {
1107 this.issues = [...this.issues, ...subs];
1108 };
1109 const actualProto = new.target.prototype;
1110 if (Object.setPrototypeOf) {
1111 Object.setPrototypeOf(this, actualProto);
1112 } else {
1113 this.__proto__ = actualProto;
1114 }
1115 this.name = "ZodError";
1116 this.issues = issues;
1117 }
1118 format(_mapper) {
1119 const mapper = _mapper || function(issue) {
1120 return issue.message;
1121 };
1122 const fieldErrors = { _errors: [] };
1123 const processError = (error) => {
1124 for (const issue of error.issues) {
1125 if (issue.code === "invalid_union") {
1126 issue.unionErrors.map(processError);
1127 } else if (issue.code === "invalid_return_type") {
1128 processError(issue.returnTypeError);
1129 } else if (issue.code === "invalid_arguments") {
1130 processError(issue.argumentsError);
1131 } else if (issue.path.length === 0) {
1132 fieldErrors._errors.push(mapper(issue));
1133 } else {
1134 let curr = fieldErrors;
1135 let i = 0;
1136 while (i < issue.path.length) {
1137 const el = issue.path[i];
1138 const terminal = i === issue.path.length - 1;
1139 if (!terminal) {
1140 curr[el] = curr[el] || { _errors: [] };
1141 } else {
1142 curr[el] = curr[el] || { _errors: [] };
1143 curr[el]._errors.push(mapper(issue));
1144 }
1145 curr = curr[el];
1146 i++;
1147 }
1148 }
1149 }
1150 };
1151 processError(this);
1152 return fieldErrors;
1153 }
1154 static assert(value) {
1155 if (!(value instanceof _ZodError)) {
1156 throw new Error(`Not a ZodError: ${value}`);
1157 }
1158 }
1159 toString() {
1160 return this.message;
1161 }
1162 get message() {
1163 return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
1164 }
1165 get isEmpty() {
1166 return this.issues.length === 0;
1167 }
1168 flatten(mapper = (issue) => issue.message) {
1169 const fieldErrors = {};
1170 const formErrors = [];
1171 for (const sub of this.issues) {
1172 if (sub.path.length > 0) {
1173 const firstEl = sub.path[0];
1174 fieldErrors[firstEl] = fieldErrors[firstEl] || [];
1175 fieldErrors[firstEl].push(mapper(sub));
1176 } else {
1177 formErrors.push(mapper(sub));
1178 }
1179 }
1180 return { formErrors, fieldErrors };
1181 }
1182 get formErrors() {
1183 return this.flatten();
1184 }
1185};
1186ZodError.create = (issues) => {
1187 const error = new ZodError(issues);
1188 return error;
1189};
1190
1191// node_modules/zod/v3/locales/en.js
1192var errorMap = (issue, _ctx) => {
1193 let message;
1194 switch (issue.code) {
1195 case ZodIssueCode.invalid_type:
1196 if (issue.received === ZodParsedType.undefined) {
1197 message = "Required";
1198 } else {
1199 message = `Expected ${issue.expected}, received ${issue.received}`;
1200 }hooks/git-parse.ts 50 lines1export interface GitFields {
2 repo: boolean;
3 root: string;
4 branch: string;
5 worktree: string;
6 added: number;
7 modified: number;
8 deleted: number;
9 insertions: number;
10 deletions: number;
11 sha: string;
12}
13
14const none: GitFields = {
15 repo: false,
16 root: '',
17 branch: '',
18 worktree: '',
19 added: 0,
20 modified: 0,
21 deleted: 0,
22 insertions: 0,
23 deletions: 0,
24 sha: '',
25};
26
27/**
28 * Parse the tab-separated output of the git snapshot shell command.
29 * @param stdout - The raw stdout from the git probe command.
30 * @returns The parsed git fields, or an all-empty set when not in a repository.
31 */
32export function parseGit(stdout: string): GitFields {
33 const t = (stdout || '').trim().split('\t');
34 if (t[0] !== 'YES') {
35 return { ...none };
36 }
37 return {
38 repo: true,
39 root: t[1] ?? '',
40 branch: t[2] ?? '',
41 worktree: t[3] ?? '',
42 added: Number(t[4]) || 0,
43 modified: Number(t[5]) || 0,
44 deleted: Number(t[6]) || 0,
45 sha: t[7] ?? '',
46 insertions: Number(t[8]) || 0,
47 deletions: Number(t[9]) || 0,
48 };
49}
50hooks/paint.tsx 41 lines1import type { RenderModel } from './core.js';
2import { rendererBg, rendererColor } from './core.js';
3
4/**
5 * An element factory taking one props object (with `children` among the props).
6 */
7type ElementFactory = (props: Record<string, unknown>) => unknown;
8
9// No JSX: the element constructors from `$.ui.resolve(e)` take one props object
10// with `children` among the props (what `h(Box, props, ...children)` builds), so
11// they are called directly. This also works with stub factories in tests.
12/**
13 * Paint a render model into engine elements as a column of styled rows.
14 * @param model - The surface-agnostic render model to paint.
15 * @param el - The element factories to build the tree with.
16 * @param el.Box - The `Box` element factory.
17 * @param el.Text - The `Text` element factory.
18 * @returns The root element produced by the `Box` factory.
19 */
20export function paintModel(
21 model: RenderModel,
22 el: { Box: ElementFactory; Text: ElementFactory }
23): unknown {
24 const { Box, Text } = el;
25 const lines = model.lines.map((line, li) =>
26 Box({
27 key: `l${li}`,
28 flexDirection: 'row',
29 children: line.segments.map((seg, si) =>
30 Text({
31 key: `s${li}-${si}`,
32 color: rendererColor(seg.fg),
33 backgroundColor: rendererBg(seg.bg),
34 children: seg.text,
35 })
36 ),
37 })
38 );
39 return Box({ flexDirection: 'column', children: lines });
40}
41hooks/snapshot-build.ts 97 lines1import type { Snapshot } from './core.js';
2import type { GitFields } from './git-parse.js';
3
4export type RawUsage = {
5 ctxTokens: number;
6 ctxPct: number;
7 cached: number;
8 input: number;
9 output: number;
10 startedAt: number;
11 fivePct: number | null;
12 fiveReset: string | null;
13 weekPct: number | null;
14 weekReset: string | null;
15 cost: number | null;
16 ctxWindow: number;
17} | null;
18
19const emptyUsage: NonNullable<RawUsage> = {
20 ctxTokens: 0,
21 ctxPct: 0,
22 cached: 0,
23 input: 0,
24 output: 0,
25 startedAt: 0,
26 fivePct: null,
27 fiveReset: null,
28 weekPct: null,
29 weekReset: null,
30 cost: null,
31 ctxWindow: 0,
32};
33
34/**
35 * Assemble a full `Snapshot` from the raw session, git, and usage fields.
36 * @param raw - The gathered raw inputs.
37 * @param raw.version - The Claude Code version string.
38 * @param raw.model - The active model identifier.
39 * @param raw.effort - The active reasoning effort, or `null` when unknown.
40 * @param raw.cwd - The current working directory.
41 * @param raw.now - The current clock time in milliseconds.
42 * @param raw.sessionId - The Claude Code session id.
43 * @param raw.outputStyle - The active output style name, or `null` when unknown.
44 * @param raw.terminalWidth - The terminal width in columns (0 when unknown).
45 * @param raw.git - The parsed git fields for the working directory.
46 * @param raw.usage - The raw usage figures, or `null` when unavailable.
47 * @returns The complete snapshot with usage defaults filled in.
48 */
49export function buildSnapshot(raw: {
50 version: string;
51 model: string;
52 effort: string | null;
53 cwd: string;
54 now: number;
55 sessionId: string;
56 outputStyle: string | null;
57 terminalWidth: number;
58 git: GitFields;
59 usage: RawUsage;
60}): Snapshot {
61 const u = raw.usage ?? emptyUsage;
62 return {
63 version: raw.version,
64 model: raw.model,
65 effort: raw.effort,
66 cwd: raw.cwd,
67 repo: raw.git.repo,
68 gitRoot: raw.git.root,
69 gitBranch: raw.git.branch,
70 gitWorktree: raw.git.worktree,
71 added: raw.git.added,
72 modified: raw.git.modified,
73 deleted: raw.git.deleted,
74 insertions: raw.git.insertions,
75 deletions: raw.git.deletions,
76 ctxTokens: u.ctxTokens,
77 ctxPct: u.ctxPct,
78 cached: u.cached,
79 input: u.input,
80 output: u.output,
81 total: u.cached + u.input + u.output,
82 startedAt: u.startedAt,
83 cost: u.cost,
84 fivePct: u.fivePct,
85 fiveReset: u.fiveReset,
86 weekPct: u.weekPct,
87 weekReset: u.weekReset,
88 blockReset: null,
89 terminalWidth: raw.terminalWidth,
90 sessionId: raw.sessionId,
91 ctxWindow: u.ctxWindow,
92 gitSha: raw.git.sha,
93 outputStyle: raw.outputStyle,
94 now: raw.now,
95 };
96}
97hooks/toasts.ts 31 lines1import type { Snapshot, ToastRule } from './core.js';
2import { evalWhen } from './core.js';
3
4// Re-exported so existing importers (register.tsx, tests) keep their import path.
5export { evalWhen };
6
7/**
8 * Select the toast rules whose conditions are currently met and not suppressed.
9 * @param rules - The configured toast rules to evaluate.
10 * @param snapshot - The current snapshot the rules are evaluated against.
11 * @param fired - A map of rule keys that have already fired once.
12 * @returns The toasts that are due, each with its display text and dedupe key.
13 */
14export function dueToasts(
15 rules: ToastRule[],
16 snapshot: Snapshot,
17 fired: Record<string, boolean>
18): { text: string; key: string }[] {
19 const out: { text: string; key: string }[] = [];
20 for (const rule of rules) {
21 if (!evalWhen(rule.when, snapshot)) {
22 continue;
23 }
24 if (rule.once && fired[rule.when]) {
25 continue;
26 }
27 out.push({ text: rule.text, key: rule.when });
28 }
29 return out;
30}
31types/index.d.ts 54 lines1// The types contract must be self-contained (no imports), so the shapes the
2// plugin keeps in state are restated here; they mirror hooks/core.d.ts.
3
4export interface CcstatusSnapshot {
5 version: string;
6 model: string;
7 effort: string | null;
8 cwd: string;
9 repo: boolean;
10 gitRoot: string;
11 gitBranch: string;
12 gitWorktree: string;
13 added: number;
14 modified: number;
15 deleted: number;
16 insertions: number;
17 deletions: number;
18 ctxTokens: number;
19 ctxPct: number;
20 cached: number;
21 input: number;
22 output: number;
23 total: number;
24 startedAt: number;
25 cost: number | null;
26 fivePct: number | null;
27 fiveReset: string | null;
28 weekPct: number | null;
29 weekReset: string | null;
30 blockReset: string | null;
31 terminalWidth: number;
32 now: number;
33 sessionId: string;
34 ctxWindow: number;
35 gitSha: string;
36 outputStyle: string | null;
37}
38
39declare module 'claude-code' {
40 interface PluginState {
41 ccstatus: {
42 visible: boolean;
43 snapshot: CcstatusSnapshot | null;
44 config: Record<string, unknown> | null;
45 effort: string | null;
46 paneOpen: boolean;
47 configMtime: number | null;
48 toastFired: Record<string, boolean>;
49 outputStyle: string | null;
50 termWidth: number;
51 };
52 }
53}
54