最后更新:11/23/2026最后核验:2026-11-23

rust-anything

rust-anything 功能介绍:一块一块把应用迁到 Rust

0
0

rust-anything 是一个把现有应用一块块迁到 Rust 并逐块验证的命令行工具:它先录下原程序的行为,由你的 coding agent 写 Rust,只有所有录制用例都对得上,这一块才会被启用。仓库自带 MCP 服务与工作流技能,可注册进 Claude Code、Codex、Cursor、Gemini CLI 和 OpenCode。

免费

rust-anything 是什么

rust-anything 是一款 MIT 协议、免费开源的命令行工具,用来把现有应用一块一块迁到 Rust。它会先跑真实负载做 profile,生成 Rust crate 与桥接,<code>record</code> 录下原程序在自动生成的边界用例以及你自己提供的输入上的行为,<code>diff</code> 按原调用方的方式重放每个用例,只有全部对得上,这一块才会被启用。它不替你翻译代码:Rust 由你的 coding agent(Claude Code、Codex、Cursor、Gemini CLI 或 OpenCode)或你自己写。仓库没有独立产品官网,文档与分发都在 GitHub、npm 与 crates.io 上(两个 registry 均 3.3.0,release v3.3.0 发布于 2026-11-22),仓库的 homepage 字段指向 npm 包页面。

核心功能

  • 录制与重放:<code>record</code> 保存原程序在自动生成的边界用例和你的输入上返回的值或抛出的错误,<code>diff</code> 按原调用方看到的结果逐个重放,只有每个录制用例都一致,这一块才会被启用。
  • 只迁热点:<code>rust-anything go --agent claude -- python3 app.py</code> 会做 profile、挑出最外层值得迁的函数、录用例,把 <code>src/port.rs</code> 交给 agent(claude、codex 或任何从 stdin 读提示的命令);不给 <code>--agent</code> 就写 TASK.md 停下。
  • 一条 CLI 串起全流程:profile、analyze、bridge、record、diff、fuzz、bench、shadow、gate,之后 enable / disable;<code>disable</code> 会删掉 <code>enable</code> 加的那些行,文件逐字节还原。
  • 整应用模式(面向服务器与 CLI):analyze --whole-app、app record、app front-door、app wire、app lift,不局限于单个函数。
  • 语言支持(README 语言表):TypeScript/JavaScript、Python、C、Go、Ruby、Java、Kotlin 做单元迁移,PHP 与 C# 则分别通过 FFI 和 P/Invoke 做单元迁移。
  • agent 集成:<code>rust-anything setup</code> 把 MCP 服务(<code>rust-anything mcp</code>)与工作流技能注册进 Claude Code、Codex、Cursor、Gemini CLI、OpenCode,改文件前会留 <code>.rust-anything.bak</code> 备份。
  • 运行前提(docs/install.md 原始表述):TypeScript/JavaScript 需 Node 22.6+,profile 需 Node 24+,Python 3.9+,Go 1.21+,Ruby 3+,JDK 17+;wasm 桥接还要 wasm32-unknown-unknown target 与 wasm-bindgen-cli。

最适合

想把一两个性能敏感的函数据迁到 Rust、而不想一次性重写整个应用的开发者。希望 Rust 移植版本对照原程序真实行为的录制结果来验收,而不只靠代码评审的团队。维护已有 TypeScript/JavaScript、Python、Go、Ruby 或 Java 代码、并且能在 Rust 工具链之外再装一套源语言运行时的维护者。已经在用 Claude Code、Codex、Cursor、Gemini CLI 或 OpenCode,希望用结构化的 record-diff-gate 流程代替随手提问的开发者。除单函数迁移外,还需要整应用路径(analyze --whole-app、app front-door、app lift)的服务器与 CLI 维护者。

定价

MIT 协议、免费开源(LICENSE,Copyright 2026 Erkam Yaman)。仓库与站点都没有定价页,也没有付费档:README 只提供 GitHub Sponsors 赞助入口,仓库的 pricingUrl 指向 MIT LICENSE。分发在 npm 与 crates.io,版本 3.3.0。可能产生的额外费用来自你指定的 coding agent——它按自己的模型服务商计费,仓库本身不为此定价。

优缺点

优点

  • 用录制行为来证明移植,而不是只相信生成的代码:重放会比较 stdout、stderr、退出码、写出的文件与 HTTP 响应,<code>app record</code> 需要时还能录出站 HTTP、SMTP 与数据库状态。
  • 可以先只迁一个热点函数,再决定是否扩大范围。
  • 自动生成的边界用例和你自己提供的输入都会被录进用例集。
  • <code>enable</code> 与 <code>disable</code> 可逆:<code>disable</code> 逐字节还原文件。
  • 一条 <code>setup</code> 命令就能把 MCP 服务和工作流技能注册进五个 coding agent。
  • MIT 协议、无付费档;README 给出了作者在 Apple M4 上测的基准(Prettier 3.6.2 由 128.6 s 降到 6.9 s、json-server 常驻内存 74 MB 降到 3.5 MB、Fuse.js 5 万条搜索 91.2 ms 降到 2.8 ms,各测两次)。这些是作者自测数字,本次未复现。

缺点

  • 它不替你改写代码:负责 profile、录制与生成桥接,Rust 由你的 coding agent 或你自己写。
  • 通过只证明录制过的东西:没人录的输入、之后又改动的原程序、regex 的 lookaround 与反向引用、浮点数转字符串的格式,以及 stdout、stderr、退出码、写出的文件与 HTTP 之外的行为,都不在默认比对范围内。
  • 需要 Rust 工具链,以及被迁语言的运行时(TS 需 Node 22.6+,profile 需 Node 24+,Python 3.9+,Go 1.21+,Ruby 3+,JDK 17+);wasm 桥接还要 wasm32 target 与 wasm-bindgen-cli。
  • Rust 不一定更快:FAQ 直说每次只调一次的小函数在 Rust 里往往更慢,因为每次调用都要跨桥,而 V8、JVM 与 Go 跑这种函数是纳秒级;碰硬件寄存器、依赖编译器类型宽度或内存布局、或用内联汇编的成熟 C 会被标成 keep in C,因为在你机器上录的结果证明不了目标环境,稳定的驱动或固件代码从重写里收益也很小。
  • 没有独立产品官网,也没有托管服务;Windows 只在 CI 里跑 MSVC target。本文只依据 README、docs 与 LICENSE 核验,未安装或运行。

替代工具

Claude Code

官方文档列为受支持的集成:<code>rust-anything setup</code> 会把 MCP 服务与工作流技能注册进 Claude Code,由它来写这个 CLI 负责录制、diff 与门禁的 Rust。它配合迁移流程,而不是替代其中的录制与门禁环节。

OpenAI Codex

同样列为受支持的集成,MCP 服务与技能还以 Codex 插件形式发布(codex plugin marketplace add erkamyaman/rust-anything)。它是流程里写代码的那一环,不等于录制与门禁本身。

Cursor

属于 <code>rust-anything setup</code> 会配置的 agent 之一,可以负责写 port.rs 的实现;录制、重放与 enable/disable 的判断仍由 rust-anything 完成。

Gemini CLI

同样在 <code>rust-anything setup</code> 注册 MCP 服务与工作流技能的 agent 列表里,可以作为为录制用例写 Rust 的那个 agent。

OpenCode

官方文档列为受支持的集成,在 opencode.json 的 mcp.servers 下配置。和其他几个一样,它写 Rust,而不做 record-diff-gate 那几步。

常见问题

详情

平台

macOSWindowsLinux

功能特性

  • Records what the original CLI, server or library does on generated edge cases and your own inputs, then replays every case against the Rust port before it is enabled
  • Profiles a slow run and ports only the hot function (rust-anything go --agent claude -- python3 app.py), handing port.rs to the agent or writing TASK.md when no agent is given
  • Pipeline of profile, analyze, bridge, record, diff, fuzz, bench, shadow and gate, with enable/disable that turns a gated TS/JS or Python port on for every caller and off again byte for byte
  • Source languages it records and ports: TypeScript/JavaScript, Python, C, Go, Ruby, Java and Kotlin, with PHP and C# handled for unit ports through FFI and P/Invoke
  • Whole-app mode (analyze --whole-app, app record, app front-door, app wire, app lift) for servers and CLIs, not just single functions
  • Ships an MCP server (rust-anything mcp) and a workflow skill that rust-anything setup registers with Claude Code, Codex, Cursor, Gemini CLI and OpenCode

支持语言

en

已知限制

  • It does not rewrite the code itself: it profiles, records and generates the bridge, and your coding agent (or you) writes the Rust; the README states this plainly
  • A pass only proves the Rust matches what was recorded: inputs nobody recorded, an original that changed afterwards, regex lookaround and backreferences, float-to-text formatting, and behaviour outside stdout, stderr, exit codes, written files and HTTP are outside the check
  • Needs a Rust toolchain plus the runtime of the language being ported (Node 22.6+ for TS, Node 24+ for profile, Python 3.9+, Go 1.21+, Ruby 3+, JDK 17+); wasm bridges also need the wasm32 target and wasm-bindgen-cli
  • There is no standalone product website: distribution and docs live on GitHub, crates.io and npm, and the Windows path is only exercised against the MSVC target in CI
  • Rust is not always faster: the FAQ says a small function called once per item is often slower in Rust because each call crosses a bridge, while V8, the JVM and Go run such functions in nanoseconds; battle-tested C that touches hardware registers, relies on its compiler type sizes or memory layout, or uses inline assembly is marked keep in C, since stable driver or firmware code gains little from a rewrite
  • The repo went from creation on 2026-11-16 to 8.5k stars in a week; the listing was verified from the README, docs and LICENSE only, and nothing was installed or run

为此工具评分

相关工具