ast_replace
Replace text only inside a named symbol's body using AST scoping, leaving all other code unchanged. For atomic multi-file edits, use execute_plan instead.
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. IMPORTANT: do NOT issue concurrent writes against the same file or directory tree; use execute_plan for multi-op atomicity. 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. |