ast_extract_to_file
Extract a module, function, or struct into its own file and leave a replacement declaration in the original. Rewrites imports to point to the new module path, keeping dependent code working.
Instructions
Extract a symbol (module, function, struct) to a separate file. For modules with unwrap=true, content is un-indented. IMPORTANT: do NOT issue concurrent extracts/writes against the same files; use execute_plan for multi-op atomicity. 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`). |