Skip to content

Add dexter_rename_symbol MCP tool - #85

Open
shanehull wants to merge 1 commit into
feat/mcp-serverfrom
feat/mcp-rename-tool
Open

Add dexter_rename_symbol MCP tool#85
shanehull wants to merge 1 commit into
feat/mcp-serverfrom
feat/mcp-rename-tool

Conversation

@shanehull

@shanehull shanehull commented Aug 20, 2026

Copy link
Copy Markdown

Stacked on #84 (this PR's base is its feat/mcp-server branch and it merges after it).

What

Adds dexter_rename_symbol: workspace-wide rename of a module or function over MCP, returned as a unified diff plus a list of file renames. Nothing is written. The agent applies the diff, performs the listed file moves (module renames follow the file naming convention, including submodule cascades), then calls dexter_reindex.

Why the refactor

The existing rename machinery writes to disk while it collects edits (closed files are written directly; only open buffers come back as TextEdits). A "return a diff, don't write" tool cannot be built on that, so this PR splits rename into plan and apply:

  • Site collection and defdelegate as:-span computation moved verbatim from server.go to renameplan.go (git diff shows the block deletion; the logic is unchanged).
  • FunctionRenamePlan / ModuleRenamePlan compute the full new content of every affected file, plus conventional new paths for moved files, without touching disk.
  • The LSP apply path (renameFunctionEdits, moduleRename) is unchanged in behavior and consumes the same shared pieces.

Correctness

  • TestFunctionRenamePlan_MatchesApply and TestModuleRenamePlan_MatchesApply: after computing a plan, the LSP apply path runs and every planned NewText must byte-match what landed on disk, and every changed file must be in the plan. This pins the two paths together permanently.
  • All pre-existing rename tests pass unmodified.
  • TestRenameTool_DoesNotModifyDisk hashes every file before/after tool calls.
  • internal/diff (new, self-contained) is covered by golden tests, including the missing-trailing-newline cases (expected outputs were validated against git apply when written).

Manually exercised on a large codebase: a 30-file rename plan (62 call sites) computed in 52ms, working tree verified untouched.

Workspace-wide rename of a module or function, returned as a unified
diff plus any file renames. Nothing is written: the agent applies the
diff, performs the listed file moves, and calls dexter_reindex.

The rename machinery writes to disk as it collects edits, so a
plan/apply split was required: site collection and defdelegate span
computation move verbatim from server.go to renameplan.go, where
FunctionRenamePlan and ModuleRenamePlan compute the full new content of
every affected file without touching disk. The LSP apply path is
unchanged; TestFunctionRenamePlan_MatchesApply and
TestModuleRenamePlan_MatchesApply assert a plan predicts the applied
bytes exactly, and all pre-existing rename tests pass unmodified.

internal/diff renders the plans as unified diffs, covered by golden
tests including the missing-trailing-newline cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant