/** * Diff Preview - show changes before applying them */ export interface FileDiff { path: string; type: 'create' | 'modify' | 'delete'; oldContent?: string; newContent?: string; hunks: DiffHunk[]; } export interface DiffHunk { oldStart: number; oldLines: number; newStart: number; newLines: number; lines: DiffLine[]; } export interface DiffLine { type: 'context' | 'add' | 'remove'; content: string; oldLineNum?: number; newLineNum?: number; } export interface DiffPreviewResult { files: FileDiff[]; totalAdditions: number; totalDeletions: number; totalFiles: number; } /** * Generate diff between old and new content */ export declare function generateDiff(oldContent: string, newContent: string, contextLines?: number): DiffHunk[]; /** * Create file diff for a write operation */ export declare function createFileDiff(path: string, newContent: string, projectRoot: string): FileDiff; /** * Create file diff for an edit operation */ export declare function createEditDiff(path: string, oldText: string, newText: string, projectRoot: string): FileDiff | null; /** * Create file diff for a delete operation */ export declare function createDeleteDiff(path: string, projectRoot: string): FileDiff | null; /** * Format diff for terminal display */ export declare function formatDiffForDisplay(diff: FileDiff): string; /** * Format multiple diffs */ export declare function formatDiffPreview(diffs: FileDiff[]): string; /** * Calculate diff statistics */ export declare function getDiffStats(diffs: FileDiff[]): DiffPreviewResult; /** * Apply a subset of a file diff's hunks to the original content. * * Hunk indices in `acceptedHunks` refer to positions in `diff.hunks` * (0-based). Hunks not in the set are skipped — their original lines * stay, their additions are dropped. * * Returns the resulting file content. The caller writes it to disk. * * For `type === 'create'`, the whole file is either accepted (any hunk * accepted) or rejected (empty set) — there's no original to merge * against. For `type === 'delete'`, accepting any hunk deletes the file. */ export declare function applyHunks(diff: FileDiff, acceptedHunks: Set): string; /** * Apply accepted hunks across multiple file diffs and return the * resulting content for each. The caller writes the files to disk. * * `accepted` maps file path → set of accepted hunk indices. Files not * in the map are skipped entirely. */ export declare function applyHunksToFiles(diffs: FileDiff[], accepted: Map>): Array<{ path: string; content: string; type: FileDiff['type']; }>; /** * Count how many hunks in a diff contain actual changes (not just * context). Used to label hunks in the UI ("hunk 2/5"). */ export declare function countChangeHunks(diff: FileDiff): number;