Skip to content

Add dexter_rename_symbol MCP tool - #2

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

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

Conversation

@shanehull

@shanehull shanehull commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Stacked on the MCP server PR (base branch feat/mcp-server). Draft to share the idea.

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.

@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch from 83ab2cb to 6ebee02 Compare July 14, 2026 02:05
@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch 3 times, most recently from 6ae9d82 to 5535f95 Compare July 14, 2026 02:31
@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch 2 times, most recently from d2f7921 to f8ce74d Compare July 14, 2026 02:52
@shanehull
shanehull force-pushed the feat/mcp-server branch 2 times, most recently from 59a08f6 to 98c310f Compare July 14, 2026 03:53
@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch from f8ce74d to 4d755c9 Compare July 14, 2026 03:54
@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch from 4d755c9 to e284f19 Compare July 14, 2026 03:56
@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch 2 times, most recently from d39ec5f to 585f53b Compare July 14, 2026 04:11
@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch from 585f53b to 5f4567d Compare July 14, 2026 07:42
@shanehull
shanehull force-pushed the feat/mcp-rename-tool branch from 5f4567d to bb121b0 Compare July 26, 2026 23:25
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.
@shanehull

Copy link
Copy Markdown
Owner Author

Superseded by remoteoss#85 (stacked on remoteoss#84)

@shanehull shanehull closed this Aug 20, 2026
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