fun-refactor

Refactoring · targeted changes · Lean proof writing

Help agents change code.
Check their edits and proofs.

Use fr to find a function and its known callers, review a targeted change, run the project's checks and undo a saved edit. For a proof task, inspect a supported Lean model and property, write proof steps and ask Lean to check them. The agent chooses the change or proof; the tool exposes the checks and remaining limits.

See why a use matches a declaration

A declaration defines a name; a reference uses it. For example, greet() can refer to a function in this file or an imported one. The report labels the source rule used to connect that call to its declaration.

It rewrites exact and import-qualified. It hands you field-based and name-only to check yourself. Review unresolved uses and test the requested behavior before keeping the change.

helm/helm @ a8ab76e
fr refs pkg/action/action.go:725:6
5 reference(s) to determineReleaseSSApplyMethod
  pkg/action/action_test.go:2280:54  [exact]
  pkg/action/action_test.go:2281:54  [exact]
  pkg/action/install.go:676:23       [exact]
  pkg/action/rollback.go:192:23      [exact]
  pkg/action/upgrade.go:334:23       [exact]

It reads the configuration too

A Helm chart pairs a values file with the templates that read it, a dataflow no compiler sees. Rename a values key and the templates that use it move with it. {{ .Release.Name }} stays as written, because it spells the same word and means a different thing.

alpine chart
fr rename testcharts/alpine/values.yaml:1:1 appName
-  name: "{{.Release.Name}}-{{.Values.Name}}"
+  name: "{{.Release.Name}}-{{.Values.appName}}"
-    values: {{.Values.Name}}
+    values: {{.Values.appName}}

Name → appName: 3 site(s) across 2 file(s)

Not changed — review these yourself:
  textual-occurrence (1):
    alpine-pod.yaml:3:17  'Name' appears in a string or comment; left unchanged

Earlier observations on real code

These figures describe earlier runs over helm/helm and grafana/grafana. They are not comparisons with another tool or evidence of lower agent cost. The measurement guide explains baselines and overhead. The roadmap names the next changes and completion checks.

16,525 files of Grafana parsed in 10.9 seconds, across 13 languages
337 duplicated blocks in helm, holding 64,530 redundant tokens, found in 3.6s
47 internal Go symbols reported unused in that run; the earlier incorrect result was 238

Languages

  • Rust
  • Go
  • Java
  • TypeScript
  • TSX
  • Python
  • Zig
  • Bash
  • HTML
  • CSS
  • SCSS
  • Sass
  • Terraform
  • JSON
  • YAML
  • Helm
  • XML
  • Markdown
  • Lean

Fr reads 19 source formats through one index. Run fr capabilities to see which commands support your format and why a combination is unavailable.

Get it

git clone https://github.com/e6qu/fun-refactor
cargo install --locked --path fun-refactor

cd ~/code/your-project
fr parse --stats
fr unused --internal
fr duplicates

Replace ~/code/your-project with your project's folder. These commands check readable syntax, report candidates for unused code and find repeated code. Inspect missing files, unresolved callers and external use before deleting a reported unused function.