ast_extract_to_file
Extract a symbol (module, function, struct) from a source file into a target file, optionally replacing it and updating imports for safe refactors.
Instructions
Extract a symbol (module, function, struct) to a separate file. For modules with unwrap=true, content is un-indented. Example: {"source": "src/lib.rs", "symbol": "tests", "target": "src/lib_tests.rs", "replacement": "mod tests;", "prepend": "use super::*;"}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lang | No | Language hint. | |
| force | No | Overwrite target if it exists. | |
| source | Yes | Source file containing the symbol. | |
| symbol | Yes | Name of the symbol to extract. | |
| target | Yes | Destination file path. | |
| unwrap | No | If true (default), remove wrapper and un-indent for modules. | |
| prepend | No | Content to prepend to the target file. | |
| replacement | No | Text to leave in place of the extracted block. | |
| update_imports | No | Rewrite consumer `use`/import statements of the extracted symbol. | |
| new_module_path | No | Module path consumers should import from (required with `update_imports`). | |
| old_module_path | No | Module path consumers currently import from (required with `update_imports`). |