/** * structured-diff.ts, parse raw `git diff` output into a complete, structured * form consumers render with their diff-view machinery. * * The old consumer path for `/git diff` sliced the raw text at 4,000 chars and * printed the stub. This module is the SDK-side replacement: the FULL diff is * parsed into per-file entries with per-hunk lines, no size cap anywhere, so * a surface renders it structurally (per-file, per-hunk, colored lines) and the * truncation branch dies. `reconstructUnifiedDiff` proves the structure is * complete: parse → reconstruct round-trips the original text. */ /** One line inside a hunk. */ export interface StructuredDiffLine { /** 'context' (unchanged), 'add' (+), or 'del' (-). */ readonly kind: 'context' | 'add' | 'del'; /** The line content WITHOUT its +/-/space prefix. */ readonly text: string; } /** One @@ hunk: header coordinates plus every line, unabridged. */ export interface StructuredDiffHunk { /** The raw `@@ -a,b +c,d @@ ...` header line. */ readonly header: string; readonly oldStart: number; readonly oldLines: number; readonly newStart: number; readonly newLines: number; readonly lines: readonly StructuredDiffLine[]; } /** One file's diff: paths, status, and every hunk, unabridged. */ export interface StructuredDiffFile { /** Path before the change (null for an added file). */ readonly oldPath: string | null; /** Path after the change (null for a deleted file). */ readonly newPath: string | null; readonly status: 'modified' | 'added' | 'deleted' | 'renamed' | 'binary'; readonly hunks: readonly StructuredDiffHunk[]; /** The file-header lines exactly as emitted (diff --git, index, ---/+++, etc.). */ readonly headerLines: readonly string[]; readonly additions: number; readonly deletions: number; } /** The whole diff, structured, with honest totals. Never truncated. */ export interface StructuredDiff { readonly files: readonly StructuredDiffFile[]; readonly additions: number; readonly deletions: number; } /** * Parse raw unified-diff text (any size, no cap) into structured files/hunks. * Unknown leading material and binary-file notices are handled; an empty diff * yields zero files. */ export declare function parseUnifiedDiff(raw: string): StructuredDiff; /** * Rebuild unified-diff text from the structure, the completeness proof used * by tests (parse → reconstruct round-trips byte-for-byte for text diffs) and * an escape hatch for consumers that still want raw text for one file. */ export declare function reconstructUnifiedDiff(diff: StructuredDiff): string; //# sourceMappingURL=structured-diff.d.ts.map