generate_refactoring_code
Turns one structured refactoring plan from get_health(include=["refactoring"]) into generated code and a unified diff, grounded on the plan plus the real source it references.
get_health(include=["refactoring"]) returns ranked, structured
refactoring plans, not template strings. generate_refactoring_code
takes one plan's id and turns it into actual generated code: for
Extract Class, the result includes an LCOM4 before/after self-check.
Disabled by default
Registered and on by default in the tool surface, but the tool itself
returns {"error": "disabled", ...} unless the repo has opted in:
# .repowise/config.yaml
refactoring:
llm:
enabled: trueWhen enabled, it uses the repo's configured LLM provider/model (bring your own key) and caches results by a content hash, so an unchanged plan never regenerates.
When to call
- After
get_health(include=["refactoring"])surfaces a plan you want turned into an applyable diff. - Only when your repo has opted into LLM-backed generation — check
for the
disablederror first, or just read the config.
Parameters
Prop
Type
Example
get_health(targets=["module:src.api"], include=["refactoring"])
# -> pick a plan's `id`
generate_refactoring_code(suggestion_id="a1b2c3d4")Things worth knowing
- Content-hash cached. Re-running with the same plan against unchanged source returns the cached result instead of a fresh LLM call.
- Grounded, not templated. The generation is anchored on the plan's evidence plus the real source spans it references, not a generic rewrite prompt.
- Extract Class gets a self-check. The result includes an LCOM4 cohesion score before and after, so you can see whether the split actually improved cohesion.
- BYO key. Uses whichever LLM provider/model the repo already has configured for doc generation — no separate credential.
See get_health for how refactoring plans are
ranked and what evidence each one carries, and
Refactoring intelligence for the full
plan shapes (Extract Class, Extract Helper, Move Method, Break Cycle).
get_health
Code-health scores and marker findings per file across three signals (defect risk, maintainability, performance), exposed to your agent so it can self-check a change before opening a PR.
Dependency graph
How repowise builds the two-tier dependency graph — file nodes and symbol nodes — with import resolution, call resolution, heritage extraction, and community detection.