Skip to main content

Module patch

Module patch 

Source
Expand description

Patch application engine — combo patches and move corrections.

Provides a unified diff parser, applicator, validator, and generator so agents can land precise code changes without rewriting entire files. Think of it as a carefully choreographed combo: each hunk is a move in the sequence, and the engine ensures every hit connects cleanly.

Structs§

FilePatch
A patch for a single file — the full combo sequence for one target.
PatchConflict
A detected conflict when validating a patch against file content.
PatchHunk
A contiguous region of changes within a file patch — one move in the combo.
PatchSet
A collection of file patches — a full combo chain across the codebase.

Enums§

ConflictType
Classification of a patch conflict — how badly the move missed.
PatchLine
A single line in a patch hunk — context, removal, or addition.

Functions§

apply_patch
Apply a single file patch to the original content — execute the combo.
apply_patch_fuzzy
Apply a file patch with fuzzy matching — allow hunks to land at a nearby offset.
generate_unified_diff
Generate a unified diff from two strings — choreograph the combo notation.
parse_unified_diff
Parse a unified diff string into a PatchSet — decode the combo notation.
reverse_patch
Create a reverse patch — swap additions and removals, old and new paths.
validate_patch
Validate a patch against the original content without applying it.