# src/

Refactoring engine source.

- `lib.rs` — Core types (PlannedEdit, RefactoringPlan, RefactoringContext, References) and RefactoringExecutor
- `actions.rs` — Query and mutation primitives (locate symbol, find references, check conflicts, plan renames/deletes/inserts). `decoration_extended_start` walks tree-sitter siblings to include leading doc comments / attributes / decorators when moving a symbol, classified by `node.kind()` rather than text. Climbs through known wrapper kinds (`decorated_definition`, `export_statement`, etc.) so leading comments above a Python `@decorator` block or a TypeScript `export class` are picked up
- `rename.rs` — Rename recipe: composes actions into a complete cross-file rename plan
- `move_item.rs` — Move recipe: relocates a symbol to a destination file (including leading doc comments / attributes / decorators identified via tree-sitter), deletes it from the source, and rewrites import statements in every file that imported it. Per-language module-path derivation is best-effort (Python, Go, JS/TS); unsupported languages emit warnings instead of generating wrong imports. Optional `--reexport` leaves a re-export stub at the source location (Python only)
- `introduce_variable.rs` — Introduce-variable recipe: extracts an expression at a given byte range (derived from a `line:col-line:col` range string) into a named variable binding inserted before the containing statement. Language-specific binding keyword: `name = expr` for Python, `const name = expr;` for JS/TS, `let name = expr;` for all others. Uses tree-sitter CST node navigation to find the expression and its parent statement.
- `inline_variable.rs` — Inline-variable recipe: inverse of introduce-variable. Given a `line:col` position pointing at the variable name in its declaration, finds all uses in the same scope, replaces them with the initializer expression (wrapped in parens when needed for precedence), and removes the declaration line. Errors if the variable has no initializer or is reassigned. Warns if the initializer has side effects and is used more than once. Supports Rust (`let`/`let mut`), TypeScript/JavaScript (`const`/`let`/`var`), and Python (bare assignment).
- `add_parameter.rs` — Add-parameter recipe: inserts a new parameter into a function signature at a given position (default: last) and updates all call sites by inserting the default value at the same argument position. Uses tree-sitter to locate the function and argument lists. Finds callers via the facts index (`find_references`); falls back with a warning if the index is unavailable. Supports Rust, TypeScript/JavaScript, Python.
- `inline_function.rs` — Inline-function recipe: locates a function definition and its (single) call site within the same file, substitutes arguments for parameters, replaces the call with the function body, and removes the definition. Supports JS/TS function declarations, arrow-function `const` bindings (`const f = (...) => ...`), Python `def`, and Rust `fn`. Conservative: aborts on multiple `return` statements or mismatched argument count. `--force` overrides the single-use check.
