file_apply_patch
Apply unified diffs safely: validate every hunk and file before writing, preview changes with dry_run, and return an undoable operation ID.
Instructions
Apply a unified diff and return operation_id and undo_available. Destructive.
The whole patch is parsed and every hunk is checked against its file
before a byte is written; a failed or ambiguous hunk rejects the patch
with PATCH_FAILED and leaves the pre-patch state intact. A patch is
limited to 1048576 bytes here. A multi-file patch is recorded as one
logical operation and is undoable, but its application is recoverable,
not atomic across files. dry_run validates and reports every file and
hunk without touching the tree. Renaming patches are refused.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"patch": "<patch>"
},
"name": "file_apply_patch"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| patch | Yes | ||
| dry_run | No | ||
| i_accept_secret_write_risk | No |