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")"}
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. |