/** * Represents a single line in a diff hunk */ export interface DiffLine { type: 'added' | 'deleted' | 'unchanged'; content: string; oldLineNumber?: number; newLineNumber?: number; } /** * Represents a hunk (section) of a diff */ export interface Hunk { header: string; oldStart: number; oldLines: number; newStart: number; newLines: number; lines: DiffLine[]; } /** * Represents a parsed diff result */ export interface ParsedDiff { oldPath: string; newPath: string; status: 'added' | 'modified' | 'deleted' | 'renamed' | 'unchanged'; language?: string; hunks: Hunk[]; oldContent?: string; newContent?: string; } /** * Configuration for diff generation */ export interface DiffEngineConfig { contextLines: number; ignoreWhitespace: boolean; } /** * DiffEngine - A class for generating and parsing unified diffs * * Uses the Myers diff algorithm (via the 'diff' library) for generating diffs * and parse-git-diff for parsing them. */ export declare class DiffEngine { private config; private static readonly LANGUAGE_MAP; constructor(config?: Partial); /** * Generate a unified diff between two text contents * * @param oldPath - Path to the old file (used in diff header) * @param newPath - Path to the new file (used in diff header) * @param oldContent - Original content (empty string for new files) * @param newContent - New content (empty string for deleted files) * @returns The unified diff string */ generateDiff(oldPath: string, newPath: string, oldContent: string, newContent: string): string; /** * Parse a unified diff string into a structured format * * @param diff - The unified diff string to parse * @returns Array of parsed diff objects */ parseDiff(diff: string): ParsedDiff[]; /** * Convert parse-git-diff output to our ParsedDiff format */ private convertParsedGitDiff; /** * Detect the file status from the parsed diff */ private detectFileStatus; /** * Detect programming language from file extension */ detectLanguage(filePath: string): string | undefined; /** * Convert parse-git-diff chunks to our Hunk format */ private convertHunks; /** * Generate and parse a diff in one step * * @param oldPath - Path to the old file * @param newPath - Path to the new file * @param oldContent - Original content * @param newContent - New content * @returns Parsed diff object */ generateAndParse(oldPath: string, newPath: string, oldContent: string, newContent: string): ParsedDiff; /** * Determine file status based on content */ private determineStatus; /** * Update configuration */ setConfig(config: Partial): void; /** * Get current configuration */ getConfig(): DiffEngineConfig; } export default DiffEngine; //# sourceMappingURL=diff-engine.d.ts.map