/** * Apply Patch Executor * * Built-in implementation for the documented GPT-5 apply_patch grammar. * It accepts the freeform patch body directly and tolerates the legacy shell * wrapper form used by older prompts. */ import type { ApplyPatchExecutor } from "../types"; import { PatchActionType } from "./apply-patch-parser"; export interface PatchFileChange { type: PatchActionType; oldContent?: string; newContent?: string; movePath?: string; } /** * Options for the apply_patch executor */ export interface ApplyPatchExecutorOptions { /** * File encoding used for read/write operations * @default "utf-8" */ encoding?: BufferEncoding; /** * Restrict relative-path file operations to paths inside cwd. * Absolute paths are always accepted as-is. * @default true */ restrictToCwd?: boolean; } /** * Parse a patch and compute the per-file changes it would apply, without * writing anything to disk. Reads the current contents of the files the patch * references. Exposed so hosts can preview a patch (e.g. in a diff editor) * before the executor applies it. */ export declare function computePatchChanges(patchText: string, cwd: string, options?: ApplyPatchExecutorOptions): Promise<{ changes: Record; fuzz: number; }>; /** * Create an apply_patch executor using Node.js fs module. */ export declare function createApplyPatchExecutor(options?: ApplyPatchExecutorOptions): ApplyPatchExecutor;