extract_function
Extract a code block from a file into a new function. Specify file path, start and end lines, and function name. Preview changes with dry-run before applying.
Instructions
DISABLED pending AST-aware rewrite — returns a structured error explaining the limitation. The previous regex-based implementation produced unparseable code on non-trivial inputs (outer-scope identifiers misclassified as parameters; enclosing function headers spliced into the new helper body). File-existence and line-range validation still run first so obviously malformed inputs keep their familiar errors. Tracking issue: extract_function-ast-rewrite.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | File path (relative to project root) | |
| start_line | Yes | First line to extract (1-indexed, inclusive) | |
| end_line | Yes | Last line to extract (1-indexed, inclusive) | |
| function_name | Yes | Name for the extracted function | |
| dry_run | No | Preview changes without applying (default: true). Set to false to apply. |