/** * apply_patch — multi-file diff tool inspired by OpenAI codex-cli. * * One tool call instead of N edit_file/write_file calls. The envelope * format is self-describing so the model can batch related changes * (renames, adds, deletes, edits) into a single auditable diff: * * *** Begin Patch * *** Update File: src/foo.ts * @@ class Foo * - oldLine * + newLine * *** Add File: src/bar.ts * +contents line 1 * +contents line 2 * *** Delete File: src/old.ts * *** Move to: src/other.ts * *** End Patch * * Why this is better than chained edit_file calls: * - One permission prompt covering the whole refactor * - The diff is reviewable as a unit; no half-applied state * - Renames + content edits in the same call (rare-but-real refactor pattern) * - Multi-file refactors cost one tool round-trip * * Parser notes: * - Lines starting with `*** ` are control lines (begin/end/file ops) * - Hunk header lines start with `@@` — symbol anchor or line number * - Body lines start with `-` (remove), `+` (add), or ` ` (context) * - We require minimum 2 chars context (or `@@` anchor) for each hunk * - Match validation: every `-` line must be findable in the current * file content; otherwise the whole patch rejects (no partial apply) */ import type { Tool } from './types.js'; export declare const ApplyPatchTool: Tool;