/** * apply-patch — 1:1 port of OpenAI Codex CLI apply_patch tool. * * Parses patch text into hunks, locates context via 4-stage fuzzy matching, * computes replacements, and applies them to the filesystem. */ export interface UpdateFileChunk { changeContext?: string; oldLines: string[]; newLines: string[]; isEndOfFile: boolean; } export type Hunk = { type: "add"; path: string; contents: string; } | { type: "delete"; path: string; } | { type: "update"; path: string; movePath?: string; chunks: UpdateFileChunk[]; }; interface ApplyPatchArgs { patch: string; hunks: Hunk[]; environmentId?: string; } export declare class ParseError extends Error { readonly kind: "invalid-patch" | "invalid-hunk"; readonly lineNumber?: number | undefined; constructor(kind: "invalid-patch" | "invalid-hunk", message: string, lineNumber?: number | undefined); } export declare class ComputeReplacementsError extends Error { constructor(message: string); } export declare function parsePatch(patch: string): ApplyPatchArgs; export declare function seekSequence(lines: string[], pattern: string[], start: number, eof: boolean): number | undefined; export declare function computeReplacements(originalLines: string[], filePath: string, chunks: UpdateFileChunk[]): Array<{ startIdx: number; oldLen: number; newLines: string[]; }>; export declare function applyReplacements(lines: string[], replacements: Array<{ startIdx: number; oldLen: number; newLines: string[]; }>): string[]; export interface AffectedPaths { added: string[]; modified: string[]; deleted: string[]; } export declare function applyPatch(patchText: string, cwd: string): Promise<{ affected: AffectedPaths; exact: boolean; }>; export {}; //# sourceMappingURL=apply-patch.d.ts.map