ashlr

ashlr__edit_structural

AST-aware rename across files. Handles Unicode identifiers, cross-file rename with shadowing guard, extract-function with return-value detection. TypeScript/TSX/JS/JSX only.

ashlr__edit_structural performs AST-aware symbol renames and function extractions. Unlike ashlr__edit (text search/replace), it understands scope and shadowing — a rename of foo only touches occurrences that resolve to the same binding.

Use cases

  • Rename a function, variable, or type across all files in a project
  • Rename Unicode identifiers (café, π, CJK characters) correctly
  • Extract a code block into a new function, auto-detecting return values
  • Dry-run a rename to preview all affected sites before applying

Parameters

ParameterTypeRequiredDescription
operation"rename" | "rename-cross-file" | "extract-function"noOperation to perform (default: 'rename' for back-compat)
pathstringnoAbsolute or cwd-relative file path (rename, extract-function)
rootDirstringnoRoot directory to search (rename-cross-file)
namestringnoCurrent identifier name to rename (rename, rename-cross-file)
newNamestringyesNew symbol name.
kind"value" | "type"no'value' (default) | 'type'; for rename operations
dryRunbooleannoIf true, return the planned edits without writing (default false)
forcebooleannoBypass shadowing + collision guards for rename (default false)
includestring[]noGlob patterns to include (rename-cross-file, default: **/*.{ts,tsx,js,jsx})
excludestring[]noGlob patterns to exclude (rename-cross-file)
anchorFilestringnoDisambiguate when name appears in multiple files (rename-cross-file).
maxFilesnumbernoHard cap on candidate files for cross-file rename (default 200). Beyond this the rename is truncated and a warning is emitted.
startnumbernoByte offset start of range to extract (extract-function)
endnumbernoByte offset end of range to extract (extract-function)

For function extraction, use extract mode (see tool schema for full args).

Supported languages

.ts, .tsx, .js, .jsx. Other languages fall back to ashlr__search_replace_regex.

Example

{
  "tool": "ashlr__edit_structural",
  "arguments": {
    "path": "src/auth/handler.ts",
    "name": "handleRequest",
    "newName": "handleAuthRequest",
    "dryRun": true
  }
}

Returns a preview of all affected sites. Remove dryRun to apply.

On this page