patch
Apply unified diff patches to files with encoding awareness. Preview changes using dry_run to verify without modifying.
Instructions
Applies a unified diff patch to a file. Parses @@ hunk headers, verifies context lines, and applies changes. Encoding-aware: preserves original file encoding. Use dry_run=true to preview without modifying the file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | Absolute path to the file to patch | |
| path | No | Alias for file_path | |
| patch | Yes | Unified diff text (output of the diff tool) | |
| dry_run | No | Preview patch result without modifying the file: true or false. Default: false |