/** A single rendered diff line. */ export type DiffRowKind = 'add' | 'del' | 'ctx' | 'meta'; export interface DiffRow { kind: DiffRowKind; text: string; } /** Extraction result: enough for a caller to render without re-inspecting input. */ export type ToolDiff = { mode: 'lcs'; oldText: string; newText: string; caption: string; } | { mode: 'unified'; patchText: string; caption: string; }; /** Max lines per side before we bail out of the O(n*m) LCS table. */ export declare const DIFF_MAX_LINES = 5000; /** * Recognise the edit-family tools and pull a renderable diff descriptor out of * their input. Returns null when the tool doesn't carry diffable input. * * @param toolName canonical or aliased tool name. * @param input tool input — a parsed object OR a JSON string. */ export declare function diffFromToolInput(toolName: string | undefined, input: unknown): ToolDiff | null; /** * LCS-based line diff. Returns null when either side exceeds DIFF_MAX_LINES * (an O(n*m) memory guard — fine for a normal edit, prohibitive for a huge * generated-file rewrite). */ export declare function computeLineDiff(oldText: string, newText: string): DiffRow[] | null; /** * Parse a unified-diff string into renderable rows. Hunk headers (`@@ ... @@`) * and file headers (`--- `, `+++ `, `diff `, `index `) become `meta` rows; body * lines map to add/del/ctx by their leading char. `\ No newline at end of file` * is kept as a meta row. */ export declare function parseUnifiedDiff(patchText: string): DiffRow[]; /** * Convenience: extract + render to rows in one call. Returns null when the tool * carries no diffable input, or `{ caption, rows: null }` when the diff is too * large to render (LCS guard). */ export declare function diffRowsFromToolInput(toolName: string | undefined, input: unknown): { caption: string; rows: DiffRow[] | null; } | null; /** Rich diff row: like DiffRow but with a dedicated `hunk` kind and gutters. */ export type DiffLineKind = 'add' | 'del' | 'hunk' | 'ctx' | 'meta'; export interface DiffLineRow { kind: DiffLineKind; text: string; oldLine?: number | undefined; newLine?: number | undefined; } /** A parsed unified-diff preview: rows plus visible/hidden tallies. */ export interface DiffPreview { rows: DiffLineRow[]; hidden: number; added: number; removed: number; hiddenAdded: number; hiddenRemoved: number; } /** * Safety cap on a single diff row's stored text — guards against pathological * one-line files (minified bundles, huge JSON) flooding a consumer. Real code * lines are never truncated at this length. */ export declare const DIFF_LINE_SAFETY_CAP = 4000; /** Truncate the middle-out: keep the head, append an ellipsis, past `max`. */ export declare function truncMid(s: string, max: number): string; /** * Parse a unified-diff string into a {@link DiffPreview} with per-row line * numbers and add/remove tallies. `maxLines` caps the visible rows; the rest * fold into `hidden`/`hiddenAdded`/`hiddenRemoved`. Pass * `Number.POSITIVE_INFINITY` to render everything. * * This is the richer sibling of {@link parseUnifiedDiff}: it keeps a dedicated * `hunk` kind (rather than folding hunk headers into `meta`) and tracks old/new * line gutters, which a terminal/gutter renderer needs. */ export declare function parseUnifiedDiffPreview(diff: string, maxLines: number, lineCap?: number): DiffPreview; export declare const TOOL_DIFF_BROWSER_SRC: string; //# sourceMappingURL=tool-diff.d.ts.map