ast_transform
Apply declarative code transformations — add parameters, wrap with try-catch, add decorators, change return types, or extract variables — with a two-phase write that previews changes before applying.
Instructions
Apply a declarative AST transformation to a symbol. Supports: add_parameter, wrap_with_try_catch, add_decorator, change_return_type, extract_variable. Uses two-phase write (Phase 1: preview diff, Phase 2: confirm with token).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to file | |
| projectRoot | Yes | Project root (REQUIRED) | |
| symbolName | Yes | Target symbol to transform | |
| className | No | Class name (optional, for scoping) | |
| transform | Yes | Transform specification | |
| confirm | No | Set true to apply a pending operation (Phase 2) | |
| confirmationToken | No | Token from Phase 1 dry-run (Phase 2 only) | |
| diffFormat | No | Diff verbosity (default: unified) |