/** * Pure presentation helpers for Cursor-style file-change previews in the * tool card and export/copy paths. */ import type { DiffOp, FileChange, ModalDiffLine } from "../../tools/file-diff.js"; import type { Theme } from "./theme.js"; import { type LangId, type SyntaxKind, type SyntaxSpan } from "./syntax-highlight.js"; export type DiffLineTone = "context" | "add" | "del" | "gap" | "header"; export interface PresentedDiffRow { readonly tone: DiffLineTone; /** Right-aligned gutter (line number or blank). */ readonly gutter: string; /** Prefix character: space / + / − / · */ readonly prefix: string; readonly text: string; /** Soft-clipped body for chat cards. */ readonly displayText: string; /** Syntax spans for the display body (clipped). */ readonly spans: readonly SyntaxSpan[]; } /** Hard-wrap by character columns — no ellipsis, no dropped characters. */ export declare function wrapCodeLine(text: string, max: number): string[]; export declare function syntaxColor(kind: SyntaxKind, theme: Theme): string; export declare function rowBackground(tone: DiffLineTone, theme: Theme): string | undefined; /** Flatten preview hunks into styled rows for the tool card. */ export declare function presentFileChangePreview(change: FileChange, options?: { maxLineChars?: number; maxRows?: number; }): PresentedDiffRow[]; export declare function presentAllFileChangePreviews(changes: readonly FileChange[], options?: { maxLineChars?: number; }): Array<{ change: FileChange; rows: PresentedDiffRow[]; }>; /** Plain-text export of a file change (no ANSI). */ export declare function fileChangeExportText(change: FileChange): string; /** Structured modal row for pager (gutter split from body). */ export interface ModalPagerRow { readonly gutter: string; /** Prefix + body without line number, e.g. `+ const x = 1` */ readonly body: string; readonly tone: DiffOp | "header"; readonly spans: readonly SyntaxSpan[]; /** Raw code only (no prefix) for copy. */ readonly code: string; } export declare function buildModalPagerRows(change: FileChange, options?: { maxHighlightLines?: number; }): ModalPagerRow[]; /** * Build numbered modal body for the pager (plain string fallback). * Format: ` │ <+/−/ > ` so the pager can split gutter/body. */ export declare function formatModalPlainText(change: FileChange): string; export type { ModalDiffLine, SyntaxSpan, LangId }; /** * Prefer project-relative path for chat titles (Cursor-style). * Falls back to absolute when outside the project root / cwd. */ export declare function relativeDisplayPath(absPath: string): string; /** * Compact path line under the card title. * Title already carries the verb ("Edited App.tsx") — do not repeat it here. */ export declare function collapsedFileChangeLabel(change: FileChange): string; /** Multi-file collapsed label. */ export declare function collapsedFileChangesLabel(changes: readonly FileChange[]): string;