/** * Diff Generator - Line-level diff generation for content comparison * * Provides: * - Line-by-line diff using Myers algorithm (LCS-based) * - Unified diff format output (like git diff) * - Context-aware diff with configurable context lines * - Inline diff for showing character-level changes * - Summary statistics and change counts * * Part of F-010: Diff Generation for Content Changes */ /** * A single diff operation */ export interface DiffOp { /** Type of operation */ type: 'equal' | 'insert' | 'delete'; /** The line content */ line: string; /** Line number in old content (1-indexed, undefined for inserts) */ oldLineNumber?: number; /** Line number in new content (1-indexed, undefined for deletes) */ newLineNumber?: number; } /** * A hunk in a unified diff (group of changes with context) */ export interface DiffHunk { /** Starting line in old content */ oldStart: number; /** Number of lines from old content */ oldCount: number; /** Starting line in new content */ newStart: number; /** Number of lines from new content */ newCount: number; /** The operations in this hunk */ operations: DiffOp[]; } /** * Full diff result with statistics and formatting */ export interface DiffResult { /** Whether there are any changes */ hasChanges: boolean; /** All diff operations */ operations: DiffOp[]; /** Hunks (groups of changes with context) */ hunks: DiffHunk[]; /** Statistics about the diff */ stats: DiffStats; /** Unified diff format string */ unifiedDiff: string; /** Side-by-side diff format */ sideBySideDiff: SideBySideLine[]; /** Summary string */ summary: string; } /** * Statistics about a diff */ export interface DiffStats { /** Total lines in old content */ oldLineCount: number; /** Total lines in new content */ newLineCount: number; /** Number of lines added */ linesAdded: number; /** Number of lines deleted */ linesDeleted: number; /** Number of lines unchanged */ linesUnchanged: number; /** Number of hunks (change groups) */ hunkCount: number; } /** * A line in side-by-side diff format */ export interface SideBySideLine { /** Line number in old content */ oldLineNumber?: number; /** Content from old version */ oldContent?: string; /** Line number in new content */ newLineNumber?: number; /** Content from new version */ newContent?: string; /** Type of change */ type: 'equal' | 'insert' | 'delete' | 'modify'; } /** * Options for diff generation */ export interface DiffOptions { /** Number of context lines around changes (default: 3) */ contextLines?: number; /** Ignore whitespace changes (default: false) */ ignoreWhitespace?: boolean; /** Ignore case (default: false) */ ignoreCase?: boolean; /** Label for old content in unified diff (default: 'old') */ oldLabel?: string; /** Label for new content in unified diff (default: 'new') */ newLabel?: string; /** Maximum line length before truncation (default: no limit) */ maxLineLength?: number; } /** * Generate a diff between two strings * * @param oldContent - Original content * @param newContent - Modified content * @param options - Diff options * @returns Full diff result with multiple formats */ export declare function generateDiff(oldContent: string, newContent: string, options?: DiffOptions): DiffResult; /** * Generate inline diff showing character-level changes between two lines * * @param oldLine - Original line * @param newLine - Modified line * @returns Object with highlighted segments */ export declare function generateInlineDiff(oldLine: string, newLine: string): { oldSegments: Array<{ text: string; changed: boolean; }>; newSegments: Array<{ text: string; changed: boolean; }>; }; /** * Format a diff for terminal output with ANSI colors * * @param diff - The diff result * @returns Formatted string with ANSI color codes */ export declare function formatDiffAnsi(diff: DiffResult): string; /** * Format a diff for HTML output * * @param diff - The diff result * @returns HTML string with styled diff */ export declare function formatDiffHtml(diff: DiffResult): string; /** * Quick check if content has changed (without full diff) * * @param oldContent - Original content * @param newContent - Modified content * @returns Whether content has changed */ export declare function hasContentChanged(oldContent: string, newContent: string): boolean; /** * Get quick stats without full diff computation * * @param oldContent - Original content * @param newContent - Modified content * @returns Basic statistics */ export declare function getQuickStats(oldContent: string, newContent: string): { changed: boolean; oldLineCount: number; newLineCount: number; sizeDelta: number; }; //# sourceMappingURL=diff-generator.d.ts.map