export interface Diff { readonly filePath: string; readonly oldContent: string; readonly newContent: string; readonly hunks: DiffHunk[]; readonly language: string; readonly isNewFile: boolean; readonly isDeletedFile: boolean; readonly isBinary: boolean; } export interface DiffHunk { readonly oldStart: number; readonly oldLines: number; readonly newStart: number; readonly newLines: number; readonly content: string; readonly lines: DiffLine[]; } export interface DiffLine { readonly type: 'added' | 'removed' | 'context'; readonly content: string; readonly lineNumber: number; readonly oldLineNumber?: number; readonly newLineNumber?: number; } export class DiffBuilder { private filePath: string = ''; private oldContent: string = ''; private newContent: string = ''; private hunks: DiffHunk[] = []; private language: string = ''; private isNewFile: boolean = false; private isDeletedFile: boolean = false; private isBinary: boolean = false; withFilePath(filePath: string): DiffBuilder { this.filePath = filePath; return this; } withOldContent(oldContent: string): DiffBuilder { this.oldContent = oldContent; return this; } withNewContent(newContent: string): DiffBuilder { this.newContent = newContent; return this; } withHunks(hunks: DiffHunk[]): DiffBuilder { this.hunks = hunks; return this; } withLanguage(language: string): DiffBuilder { this.language = language; return this; } asNewFile(): DiffBuilder { this.isNewFile = true; return this; } asDeletedFile(): DiffBuilder { this.isDeletedFile = true; return this; } asBinary(): DiffBuilder { this.isBinary = true; return this; } build(): Diff { return { filePath: this.filePath, oldContent: this.oldContent, newContent: this.newContent, hunks: this.hunks, language: this.language, isNewFile: this.isNewFile, isDeletedFile: this.isDeletedFile, isBinary: this.isBinary, }; } }