ast_replace
Replace text only within a named code symbol's body using AST scoping; changes stay confined to that symbol, leaving other code untouched.
Instructions
Replace text only within a specific symbol's body using AST scoping. Precise: only changes code inside the named symbol, leaving everything else untouched. Example: {"path": "src/lib.rs", "symbol": "parse_config", "old": "unwrap()", "new": "expect("parse failed")"}
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>",
"symbol": "<symbol>",
"old": "<old>",
"new": "<new>"
},
"name": "ast_replace"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| new | Yes | Replacement text. Alias `to` accepted because agents often emit that name (LLM prior). | |
| old | Yes | Text or regex pattern to find. Alias `from` accepted because agents often emit that name (LLM prior). | |
| lang | No | Language hint. | |
| path | Yes | File containing the symbol (relative to working directory). | |
| regex | No | Treat `old` as a regex pattern. | |
| symbol | Yes | Symbol name to scope the replacement to. |