Expand description
Pure apply_patch engine — parser, graduated fuzzy matcher, and applier —
adapted from OpenAI Codex’s apply-patch crate.
It lives in the runtime crate (rather than beside the tool) so BOTH the main
crate’s apply_patch tool AND the approval-replay path can apply patches
without duplicating the engine. It is PURE: parsing and applying operate on
&str; all file I/O stays with the callers (via the confined pathguard).
Trimmed from Codex: no Lark grammar, no local_shell/heredoc extraction, no
lenient GPT-4.1 mode, no streaming — the patch arrives as one string.
Structs§
- Applied
File - The result of applying chunks: the new file text and whether any chunk had to be located fuzzily (whitespace/Unicode-normalized rather than byte-exact).
- Update
File Chunk - One contiguous edit region within an
UpdateFilehunk.old_linesis the span to locate (context + removed lines, in file order);new_linesis its replacement (context + added lines).
Enums§
- Apply
Error - Why applying an update hunk failed. Rendered back to the model.
- Hunk
- One file operation in a patch.
- Parse
Error - A patch parse failure, rendered back to the model so it can fix the envelope.
Functions§
- derive_
new_ contents - Apply
chunkstooriginal, returning the new file contents. - parse_
patch - Parse a complete patch into its hunks. Strict: requires the Begin/End markers (tolerating surrounding blank lines) and rejects stray lines.