/** * Status line — Claude Code v2.1.119 compatible. * * Schema (from `settings.json`): * * { * "statusLine": { * "type": "command" | "default" | "detailed", * "command": "/path/to/script.sh", // when type === "command" * "padding": 0 * } * } * * When `type === "command"`, cave invokes the binary with a JSON context * payload on stdin and renders stdout (single-line, ANSI-stripped to * terminal width). The schema is identical to Claude Code so a user pasting * `~/.claude/settings.json#statusLine` into `~/.cave/settings.json` Just * Works. */ import type { Component } from "../tui.js"; /** * Claude-Code-shaped statusLine setting. The `type` field is the union * authority; unknown types fall back to "default". */ export interface StatusLineSettings { type?: "command" | "default" | "detailed"; /** Shell command to run (only when `type === "command"`). */ command?: string; /** Left padding in cells. */ padding?: number; } /** * JSON context that cave pipes to a `command`-type status line on stdin. * Matches Claude Code's documented shape closely enough that scripts written * for Claude Code work with cave (and vice versa). */ export interface StatusLineContext { hook_event_name: "Status"; session_id: string; transcript_path?: string; cwd: string; model: { id: string; display_name?: string; }; workspace: { current_dir: string; project_dir: string; }; version?: string; output_style?: { name: string; }; cost?: { total_cost_usd: number; total_duration_ms: number; }; exceeds_200k_tokens?: boolean; /** Cave-specific extras. Claude Code ignores keys it doesn't know. */ cave?: { branch?: string; gitDirty?: boolean; queuedMessages?: number; tokensIn?: number; tokensOut?: number; /** Savings Meter (DD §10.8): caveman bytes eliminated this session. */ savedBytes?: number; }; } /** Result of rendering — separated from Component so callers can compose. */ export interface StatusLineResult { text: string; /** Where the text came from. Useful for surfacing errors in /doctor. */ source: "default" | "detailed" | "command" | "command-failed"; stderr?: string; } /** * Build the default (terse) status line. Format: * · */ export declare function renderDefault(ctx: StatusLineContext): string; /** * Build the detailed status line. Format: * · () · · q: · $ */ export declare function renderDetailed(ctx: StatusLineContext): string; /** * Truncate a filesystem path to the trailing N components. * * tailPath("/a/b/c/d", 2) → "c/d" * tailPath("/usr", 2) → "/usr" */ export declare function tailPath(path: string, components: number): string; /** * Resolve a status line settings block to text. Synchronous helpers only — * the `command` type is async and lives on the StatusLine component below. */ export declare function renderStatusLineSync(settings: StatusLineSettings, ctx: StatusLineContext): StatusLineResult; /** * Validate and coerce an unknown settings.json `statusLine` value into a * concrete StatusLineSettings. Returns `undefined` only when the value is * malformed in a way that cannot be safely rendered. */ export declare function parseStatusLineSettings(raw: unknown): StatusLineSettings | undefined; export interface StatusLineRenderer { /** * Async render — runs the configured command if any. Implementations are * provided by the coding-agent (which has access to bash-executor); the * TUI component takes a renderer and only does layout. */ render(ctx: StatusLineContext): Promise; } export interface StatusLineComponentTheme { bg: (text: string) => string; muted: (text: string) => string; error: (text: string) => string; } /** * Single-line status component. Renders the current cached text. Callers * call `setText()` when the renderer produces a new result. */ export declare class StatusLine implements Component { private text; private source; private theme; private padding; constructor(options?: { theme?: StatusLineComponentTheme; padding?: number; }); setText(result: StatusLineResult): void; invalidate(): void; render(width: number): string[]; } /** Strip newlines/carriage returns; status line is single-row by contract. */ export declare function sanitizeOneLine(s: string): string; //# sourceMappingURL=StatusLine.d.ts.map