script_patch
Surgically edit an existing res:// file without rewriting it whole; apply ordered find/replace, append, or prepend edits, writing only when anchors match and GDScript compiles.
Instructions
Surgically edit an existing res:// file without rewriting it whole. edits = an ordered array; each item is {find, replace[, all]} (find must match EXACTLY once unless all:true), {append: text}, or {prepend: text}. Atomic + safe: nothing is written if any anchor is missing/ambiguous or (for .gd) the result fails to compile. Reads the file back (disk_verified). Prefer this over write_script for small changes.
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": {
"path": "<path>",
"edits": "<edits>"
},
"name": "script_patch"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | res:// path to an existing file | |
| edits | Yes | [{find, replace, all?} | {append} | {prepend}] applied in order | |
| validate | No | compile-check the result before writing (default true, .gd only) |