Weavatrix Refactor

io.github.Weavatrix由 GitHub 账号 Weavatrix 发布v1.0.11更新于 Oct 24, 2026

Transactional refactoring extension with 11 evidence-backed tools, previews, and rollback.

已验证STDIO仅桌面文件与存储开发者工具

概览

AI 生成的概览

让编码助手规划、预览并执行跨文件重构(如重命名),并支持回滚。

可以做什么
Weavatrix Refactor 是一个面向编码助手的本地 MCP 服务器,用于在代码仓库中执行有证据支撑的重构。它通过仓库图查找符号,生成带内容哈希的逐字节精确编辑计划,报告无法证明的同名出现位置,并且只在显式且与哈希绑定的确认后才写入。它的十一个工具涵盖重命名流程、签名变更、符号编辑、批量替换、导入整理、文件移动、删除就绪评估、计划应用以及上次应用的回滚。
适用场景
当助手需要进行跨文件代码修改(例如重命名符号、更改签名或移动文件),并且你希望先预览、再以可恢复的事务方式执行,而不是直接编辑时,适合使用它。当你希望名称有歧义时返回候选标识符而不是被猜测时,它也有用。
运行要求
作为本地进程在用户机器上运行,通过 npm 的 npx 启动或用 Cargo 安装,并需要传入仓库的绝对路径。仅支持桌面端,没有远程端点。写入源文件需要将环境变量 WEAVATRIX_ALLOW_SOURCE_EDITS 设为 1;未设置时重构工具保持仅预览。未声明任何身份验证。
安装前请注意
将 WEAVATRIX_ALLOW_SOURCE_EDITS 设为 1 会授权已确认的应用和回滚操作写入源文件,因此仅预览的会话应保持未设置。写入仍需一个短期有效、一次性使用、绑定到该仓库和精确重算计划的令牌。多文件写入有日志记录且可崩溃恢复,但对无关进程而言并非观察上原子,回滚会拒绝覆盖事务后发生漂移的文件。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Weavatrix Refactor,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Weavatrix Refactor

[CI] [npm] [crates.io] [docs.rs] [MIT]

The explicit source-write layer of the Weavatrix ecosystem; Core remains read-only.

Refactor across files without letting the agent guess.

Weavatrix Refactor is a native MCP server for coding agents. It finds a symbol through the repository graph, previews byte-exact edits, reports every same-named occurrence it could not prove, and writes only after an explicit, hash-bound confirmation.

The useful difference is not “AI can rename a word.” It is that the agent gets evidence before the write and a recoverable transaction after it.

Install

Run the native binary through npm:

bash
npx -y weavatrix-refactor mcp /absolute/path/to/repository

Or install it with Cargo:

bash
cargo install weavatrix-refactor --lockedweavatrix-refactor mcp /absolute/path/to/repository

An MCP client can start it directly. Prefer an absolute path, or Cursor's ${workspaceFolder} so the write server never follows the host process cwd:

json
{  "mcpServers": {    "weavatrix-refactor": {      "command": "npx",      "args": ["-y", "[email protected]", "mcp", "${workspaceFolder}", "--profile=refactor"],      "env": {"WEAVATRIX_ALLOW_SOURCE_EDITS": "1"}    }  }}

Leave WEAVATRIX_ALLOW_SOURCE_EDITS unset for preview-only sessions. Preview is a read; only a confirmed apply or rollback requires the gate. Refactor does not expose Core's open_repo, so it cannot silently retarget mid-session; the launch root is the only repository it will edit.

Install as a plugin

The repository also ships one plugin bundle for Cursor, Codex, Claude Code, and Grok Build. The plugin starts the extension-only profile, so it contributes the 11 Refactor methods without repeating Weavatrix Core's 43 read-only method definitions. Install the separate Weavatrix plugin when both surfaces are needed.

The bundled skill is optional and activates only for explicitly requested refactoring work. Its entry point stays short; each method has an individual reference card that is loaded only when needed.

  • Cursor: search for Weavatrix Refactor after marketplace approval.
  • Codex: add the Weavatrix/weavatrix-refactor marketplace from .agents/plugins, then add weavatrix-refactor@weavatrix-refactor.
  • Claude Code: add the same repository marketplace from .claude-plugin, then install weavatrix-refactor@weavatrix-refactor.
  • Grok Build: run grok plugin marketplace add Weavatrix/weavatrix-refactor, open /marketplace, and install it.

The plugin opens WEAVATRIX_ALLOW_SOURCE_EDITS=1, but every write still needs the exact preview's short-lived, plan-bound single-use token.

For a rename task, expose only the two tools the agent needs:

bash
weavatrix-refactor mcp /absolute/path/to/repository --profile=rename

The rename profile keeps rename_symbol and rollback_last_apply; every unrelated graph and refactor tool is absent and cannot be called. Omit the option (or use --profile=refactor) for all 11 Refactor methods. The narrower catalog reduces repeated agent context; it does not weaken preview hashes, the write gate, the confirmation token, or rollback checks.

When Weavatrix Core is already installed as a separate MCP, expose only the 11 methods that Refactor adds:

bash
weavatrix-refactor mcp /absolute/path/to/repository --profile=refactor

The refactor profile is the default for MCP and list-tools, including the marketplace plugin. The former full compatibility profile has been removed and is rejected by both commands: Refactor no longer republishes Core methods. Install Weavatrix Core as its own MCP when read-only repository intelligence is also needed.

A safe cross-file rename in three calls

Suppose two files declare resolveTarget. A bare name is ambiguous, so the server refuses to pick one and returns exact ids:

json
// rename_symbol{"symbol":"resolveTarget","new_name":"locateTarget","output_format":"json"}
{  "status": "NOT_FOUND",  "reason": "the name matches more than one symbol; pass one of the candidate ids",  "candidates": [    "symbol:src/core.ts#function:resolveTarget@2:1",    "symbol:src/shadow.ts#function:resolveTarget@3:1"  ]}

Retry with the intended id. The result is still read-only: it contains the edit plan, content hashes, the proven edit count, and the references the backend refused to guess at.

json
// rename_symbol{  "symbol": "symbol:src/core.ts#function:resolveTarget@2:1",  "new_name": "locateTarget",  "output_format": "json"}
{  "status": "PLANNED",  "completeness": "PARTIAL",  "renamedEdits": 7,  "uncertainReferences": ["... three named locations ..."],  "confirmToken": "single-use-token",  "plan": {"schemaVersion":"weavatrix.edit-plan.v1","files":["..."]}}

After reviewing the plan, repeat the same operation with the same inputs and its token:

json
// rename_symbol{  "symbol": "symbol:src/core.ts#function:resolveTarget@2:1",  "new_name": "locateTarget",  "mode": "apply",  "confirm_token": "single-use-token",  "output_format": "json"}
{"status":"APPLIED"}

This exact flow is exercised against the real stdio MCP server. The repository fixture requires seven edits across three files, preserves four traps (a longer identifier, string, comment, and unrelated shadow), and must still compile; it scores 12/12.

What is automatic today

The eleven tools do not all claim the same level of automation:

LevelToolsWhat the agent receives
Complete preview/apply workflowrename_symbol, rename_related_symbolsA generated plan and token, then a confirmed write by repeating the same operation
Plan-producingchange_signature, edit_symbol, bulk_replace, organize_imports, move_fileByte-exact edits or a review plan; use apply_edit_plan where an edit-plan envelope is returned
Advisorymove_symbol, delete_readinessBlast radius, cycle/architecture risks, or a deletion verdict; no automatic source write
Safety infrastructureapply_edit_plan, rollback_last_applyVerification/application of an edit-plan envelope and drift-safe restoration

Refactor uses the Rust Weavatrix graph internally for evidence but never exports Core methods. Install the separate Weavatrix plugin for read-only repository intelligence. The Refactor MCP owns exactly its 11 extension methods; --profile=rename is an optional narrower two-method workflow.

Safety model and exact limits

  • Ambiguous names fail with candidate ids instead of selecting the first match.
  • PARTIAL means the graph proved the edits in the plan but did not prove that no other semantic references exist. uncertainReferences names the places requiring review.
  • Every file in a plan carries a content hash. A changed working tree makes the preview stale instead of applying the old coordinates.
  • Apply requires WEAVATRIX_ALLOW_SOURCE_EDITS=1 plus a short-lived, single-use token bound to that repository and exact recomputed plan.
  • rollback_last_apply refuses to overwrite files that drifted after the transaction.
  • Multi-file writes are journaled and crash-recoverable. They are not observationally atomic to unrelated processes: another process may briefly observe an intermediate filesystem state.

Only edits with proven provenance are applied. A lexical or graph backend is deliberately more conservative than a language server and must not be read as a claim of full compiler semantics.

Measured benchmark, with unlike layers kept separate

The checked-in August 2026 benchmark uses equivalent adversarial TypeScript, Rust, and Python fixtures. Each has seven required edits, four traps, and a build/test gate. Protocol runs count exact o200k_base initialization, catalog, request, and response tokens. Agent runs use the actual cumulative usage reported by Codex CLI with pinned gpt-5.6-sol / medium reasoning. No byte proxy or estimated tokens-per-second conversion is used.

The new rename-only profile kept all nine protocol runs at 12/12 while reducing fixed MCP context from 9,331 to 485 tokens. Its guided TypeScript agent A/B is:

ArmCorrectnessMedian end-to-endMedian input tokens
Naked Codex12/12 x342,602 ms72,169
Weavatrix 1.0.6 --profile=rename12/12 x348,389 ms108,155
Weavatrix 1.0.5 full surface12/12 x358,719 ms275,784
Serena12/12 x368,728 ms388,271

The full agent matrix is 12/12 in all 27 TypeScript/Rust/Python runs; every run also completed operationally and passed the sanitized edit-channel audit. The deterministic protocol matrix also exposed a language-specific Serena defect: its suggested find_symbol → rename_symbol flow scored 7/12 on TypeScript in all three runs, while Rust and Python passed. It also found and drove fixes for Rust macro calls and Python f-string/module-level call evidence.

On this toy TypeScript repository naked Codex is still faster and cheaper than the narrowed profile. Weavatrix's demonstrated value is preview-before-write, named uncertainty, stale-plan refusal, explicit authorization, and rollback—not a universal small-repository token win.

See the full methodology, all language medians, raw-result links, and limitations.

Contract

The 11 Refactor tool names, schemas, and result states are frozen in contract/refactor-tools.v1.json. All refactor operations are native Rust; the host uses the read-only weavatrix-rust engine internally for graph evidence without exporting its methods on the default surface.

Versions 0.1.x used the JavaScript engine. That line continues as weavatrix-refactor-js and keeps a separate state directory, token store, and rollback journal.

License

MIT.

来源:README.md,提交 236668e

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.11最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分