rust-anything 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -4,32 +4,42 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">rust-anything</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center"><
|
|
7
|
+
<p align="center"><sub>English · <a href="docs/README_TR.md">Türkçe</a> · <a href="docs/README_UK.md">Українська</a> · <a href="docs/README_ZH.md">简体中文</a> · <a href="docs/README_ZH-TW.md">繁體中文</a> · <a href="docs/README_DE.md">Deutsch</a> · <a href="docs/README_FR.md">Français</a> · <a href="docs/README_RU.md">Русский</a> · <a href="docs/README_JA.md">日本語</a> · <a href="docs/README_KO.md">한국어</a> · <a href="docs/README_AZ.md">Azərbaycanca</a> · <a href="docs/README_UZ.md">Oʻzbekcha</a> · <a href="docs/README_KK.md">Қазақша</a> · <a href="docs/README_KY.md">Кыргызча</a> · <a href="docs/README_TK.md">Türkmençe</a> · <a href="docs/README_TT.md">Татарча</a> · <a href="docs/README_UG.md">ئۇيغۇرچە</a> · <a href="docs/README_PT.md">Português</a> · <a href="docs/README_VI.md">Tiếng Việt</a></sub></p>
|
|
8
8
|
|
|
9
|
-
<p align="center">
|
|
9
|
+
<p align="center"><b>Rewrite your app in Rust, and prove it still behaves the same.</b><br>
|
|
10
|
+
Point it at your app: it records what the original does, your coding agent writes the Rust one piece at a time,<br>
|
|
11
|
+
and every piece is checked against that recording before it moves on. It doesn't translate code; it proves the rewrite.</p>
|
|
10
12
|
|
|
11
13
|
<p align="center">
|
|
14
|
+
<img src="https://img.shields.io/github/languages/top/erkamyaman/rust-anything?logo=rust&label=Rust&color=CE422B" alt="Rust share of the code">
|
|
15
|
+
<img src="https://img.shields.io/badge/macOS%20·%20Linux%20·%20Windows-native-2563EB" alt="Native binaries for macOS, Linux and Windows">
|
|
16
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-555" alt="MIT license"></a>
|
|
12
17
|
<a href="https://crates.io/crates/rust-anything"><img src="https://img.shields.io/crates/v/rust-anything?color=E2862A&label=crates.io" alt="crates.io version"></a>
|
|
13
18
|
<a href="https://www.npmjs.com/package/rust-anything"><img src="https://img.shields.io/npm/v/rust-anything?color=E2862A&label=npm" alt="npm version"></a>
|
|
14
|
-
<
|
|
15
|
-
<a href="https://
|
|
19
|
+
<br>
|
|
20
|
+
<a href="https://coderabbit.link/erkamyaman"><img src="https://img.shields.io/coderabbit/prs/github/erkamyaman/rust-anything?labelColor=171717&color=FF570A&label=Reviewed+by+CodeRabbit" alt="Pull requests reviewed by CodeRabbit"></a>
|
|
21
|
+
<a href="https://github.com/rust-unofficial/awesome-rust#development-tools"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Rust"></a>
|
|
16
22
|
<a href="https://github.com/AIshihzong/awesome-reverse-engineer-anything"><img src="https://img.shields.io/badge/Featured%20in-Awesome%20REA-f0b429" alt="Featured in Awesome REA"></a>
|
|
23
|
+
<a href="https://github.com/erkamyaman/rust-anything"><img src="https://img.shields.io/github/stars/erkamyaman/rust-anything?style=social" alt="GitHub stars"></a>
|
|
17
24
|
</p>
|
|
18
25
|
|
|
19
|
-
<p align="center">
|
|
20
|
-
<a href="#quick-start">Quick start</a> ·
|
|
21
|
-
<a href="#languages">Languages</a> ·
|
|
22
|
-
<a href="docs/real-world.md">Real-world ports</a> ·
|
|
23
|
-
<a href="docs/how-it-works.md#how-it-works">How it works</a> ·
|
|
24
|
-
<a href="docs/whole-apps.md#port-a-whole-app">Whole apps</a> ·
|
|
25
|
-
<a href="docs/faq.md#faq">FAQ</a>
|
|
26
|
-
</p>
|
|
26
|
+
<p align="center"><a href="https://github.com/erkamyaman/rust-anything/discussions/127"><img src="https://img.shields.io/badge/Join%20the%20discussion-6E40C9?style=for-the-badge&logo=github&logoColor=white" alt="Join the discussion"></a></p>
|
|
27
27
|
|
|
28
|
-
<p align="center"
|
|
28
|
+
<p align="center"><a href="https://trendshift.io/repositories/363468" target="_blank" rel="noopener noreferrer"><img src="https://trendshift.io/api/badge/trendshift/repositories/363468/daily?language=Rust" alt="erkamyaman/rust-anything: #1 Rust repository of the day on Trendshift" width="250" height="55"/></a></p>
|
|
29
29
|
|
|
30
|
-
<p align="center">
|
|
30
|
+
<p align="center"><b><a href="#quick-start">Install</a></b> · <a href="https://github.com/erkamyaman/rust-anything/releases">Releases</a> · <a href="#quick-start">Claude Code plugin</a> · <a href="https://registry.modelcontextprotocol.io/v0.1/servers?search=rust-anything">MCP Registry</a> · <a href="docs/real-world.md">Real-world ports</a> · <a href="docs/faq.md#faq">FAQ</a><br>
|
|
31
|
+
<sub><a href="#languages">Languages</a> · <a href="docs/how-it-works.md#how-it-works">How it works</a> · <a href="docs/whole-apps.md#port-a-whole-app">Whole apps</a> · <a href="#sponsors">Sponsors</a> · <a href="LICENSE">MIT</a></sub><br>
|
|
32
|
+
Made in Türkiye 🇹🇷 by <a href="https://github.com/erkamyaman">erKam Yaman</a> · <a href="https://github.com/sponsors/erkamyaman">❤️ Sponsor me</a> · Sponsored by <a href="https://coderabbit.link/erkamyaman"><img src="docs/assets/brands/coderabbit.png" width="22" height="22" align="absmiddle" alt=""> <b>CodeRabbit</b></a></p>
|
|
31
33
|
|
|
32
|
-
<p align="center"
|
|
34
|
+
<p align="center">New in 2.0: <a href="docs/real-world.md#prettier">Prettier, ported to Rust</a>. 19x faster · 15,861 of 17,224 recorded runs fully in Rust · every run byte-identical</p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="docs/assets/prettier.gif" alt="Prettier and its Rust port format the same 59 real files, one process per file: Prettier takes 3.63 s, the Rust port 0.20 s, with the same output byte for byte." width="820">
|
|
38
|
+
<br>
|
|
39
|
+
<sub>Prettier against its Rust port on 59 real files from ms, Fuse.js and json-server (Apple M4). Same output, byte for byte. <a href="docs/real-world.md#prettier">How it was measured</a>.</sub>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<p align="center"><sub>PHP and C#: record, replay and the front door today; unit ports come next.</sub></p>
|
|
33
43
|
|
|
34
44
|
<table>
|
|
35
45
|
<tr>
|
|
@@ -53,9 +63,12 @@
|
|
|
53
63
|
</table>
|
|
54
64
|
|
|
55
65
|
**Rewrite your whole app in Rust, one piece at a time.** rust-anything records what your
|
|
56
|
-
Node.js (TypeScript/JavaScript), Python, C, Go, Ruby or
|
|
66
|
+
Node.js (TypeScript/JavaScript), Python, C, Go, Ruby, Java or Kotlin app does today, then checks every piece of the
|
|
57
67
|
Rust rewrite against that recording before it moves on, until the app is pure Rust. CLIs, HTTP
|
|
58
|
-
servers and libraries; your coding agent (or you) writes the Rust. It
|
|
68
|
+
servers and libraries; your coding agent (or you) writes the Rust. It is built on
|
|
69
|
+
[napi-rs](https://github.com/napi-rs/napi-rs), [PyO3](https://github.com/PyO3/pyo3) and
|
|
70
|
+
[wasm-bindgen](https://github.com/wasm-bindgen/wasm-bindgen), which carry the calls between your
|
|
71
|
+
language and Rust; rust-anything decides what to move and proves it matches. It can only catch what the
|
|
59
72
|
recording covers: see [What it can't catch](docs/how-it-works.md#what-it-cant-catch). Whole tools
|
|
60
73
|
and servers, or only the slow part, one hot path at a time:
|
|
61
74
|
|
|
@@ -67,18 +80,15 @@ and servers, or only the slow part, one hot path at a time:
|
|
|
67
80
|
| json-server, from start to first response | 79 to 85 ms | **8 to 10 ms** |
|
|
68
81
|
| [Fuse.js](docs/real-world.md#fusejs) search over 50,000 strings, per query | 91.2 ms | **2.8 ms: 32x faster** |
|
|
69
82
|
|
|
70
|
-
Prettier: 15,
|
|
83
|
+
Prettier: 15,861 of 17,224 recorded runs format fully in Rust across 10 languages (JavaScript,
|
|
71
84
|
TypeScript, JSX, JSON, GraphQL, YAML, Markdown, CSS, SCSS, Less), and all 17,224 match Prettier
|
|
72
85
|
byte for byte, since anything not ported yet falls back to Prettier. json-server: 514/514
|
|
73
86
|
recorded HTTP cases match on a pure Rust binary. Measured on an Apple M4, two runs each, every
|
|
74
87
|
output compared before timing ([details](docs/real-world.md)). Calling Rust once per small
|
|
75
|
-
function is usually *slower* than a JIT; rust-anything finds the loop worth moving, and moves it.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<br>
|
|
80
|
-
<sub>Prettier against its Rust port on 59 real files from ms, Fuse.js and json-server (Apple M4). Same output, byte for byte. <a href="docs/real-world.md#prettier">How it was measured</a>.</sub>
|
|
81
|
-
</p>
|
|
88
|
+
function is usually *slower* than a JIT; rust-anything finds the loop worth moving, and moves it. Against
|
|
89
|
+
C the win is safety, not speed: [ffmpeg's libavutil](docs/real-world.md#ffmpeg) ported to Rust
|
|
90
|
+
matches all 226,447 recorded calls and runs at about C's speed (18 of 42 benchmarks even, 8
|
|
91
|
+
faster, 16 slower by 3 to 40%).
|
|
82
92
|
|
|
83
93
|
<p align="center">
|
|
84
94
|
<img src="docs/assets/json-server.gif" alt="json-server as a Node server and as one Rust binary: memory at idle 74 MB and 3.5 MB, start to first response 79 to 85 ms and 8 to 10 ms, and 514 of 514 recorded HTTP cases match." width="820">
|
|
@@ -96,6 +106,28 @@ function is usually *slower* than a JIT; rust-anything finds the loop worth movi
|
|
|
96
106
|
> database or calls the network does that once per case. Run them on a copy of the project, with a
|
|
97
107
|
> test database and no production credentials in the environment.
|
|
98
108
|
|
|
109
|
+
## Install the ports
|
|
110
|
+
|
|
111
|
+
The ESLint port is an npm command. It runs the Rust port for what it covers and ESLint 10.15.0,
|
|
112
|
+
pinned as a dependency, for everything else, so the output is ESLint's either way:
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
npm install -g eslint-rs # ESLint 10.15.0
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Command | Answered in Rust | Handed to ESLint 10.15.0 |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| `eslint-rs` | `--no-config-lookup --rule ... --stdin` with the 90 ported rules (`stylish` and `json` output, fixes, suggestions) | `eslint.config.*` lookups (`eslint .`), files and folders, the other 202 core rules, plugins, parsers, the other formatters, parse errors |
|
|
121
|
+
|
|
122
|
+
The binary comes for macOS (arm64, x64) and Linux (x64, arm64, glibc). On Windows and elsewhere,
|
|
123
|
+
or with `RUST_ANYTHING_MODE=old`, `eslint-rs` runs ESLint itself: same output, no speedup.
|
|
124
|
+
Installed from its tarballs on macOS arm64, `eslint-rs` matches ESLint 10.15.0 installed beside it
|
|
125
|
+
on all 10,585 recorded runs ([how](docs/packaging.md#a-whole-cli-front-door)).
|
|
126
|
+
|
|
127
|
+
The Prettier port is packaged the same way (`prettier-rs`, Prettier 3.6.2) and replays
|
|
128
|
+
17,224/17,224 recorded runs from its tarballs, 7.9% handed to Prettier, but it is not on npm.
|
|
129
|
+
`rust-anything package` makes this kind of package from any CLI front door.
|
|
130
|
+
|
|
99
131
|
## Quick start
|
|
100
132
|
|
|
101
133
|
Paste this into Claude Code, Codex, Cursor, Gemini CLI or OpenCode and let your agent install it:
|
|
@@ -123,6 +155,14 @@ must be on your `PATH`):
|
|
|
123
155
|
/plugin install rust-anything --marketplace erkamyaman/rust-anything
|
|
124
156
|
```
|
|
125
157
|
|
|
158
|
+
In Codex, from the agents marketplace in this repo (`.agents/plugins/marketplace.json`, the same
|
|
159
|
+
plugin under `plugin/`, with the skill and MCP server):
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
codex plugin marketplace add erkamyaman/rust-anything
|
|
163
|
+
codex plugin add rust-anything@rust-anything
|
|
164
|
+
```
|
|
165
|
+
|
|
126
166
|
`setup` adds the MCP server to each agent it finds and installs the workflow skill where the agent
|
|
127
167
|
reads skills. It keeps your other settings, is safe to run again, and `--remove` undoes it.
|
|
128
168
|
Then ask your agent, for example:
|
|
@@ -143,7 +183,7 @@ Then ask your agent, for example:
|
|
|
143
183
|
| OpenCode | MCP server in `~/.config/opencode/opencode.json` (`mcp.servers`), skill in `~/.config/opencode/skills/` |
|
|
144
184
|
| Any other MCP client | add `rust-anything mcp` as a stdio server by hand (see [Install](docs/install.md#install)) |
|
|
145
185
|
|
|
146
|
-
Before changing a file that exists, `setup` saves a copy beside it (`<file>.rust-anything.bak`).
|
|
186
|
+
Before changing a file that exists, `setup` saves a copy beside it (`<file>.rust-anything.bak`); `--no-backup` skips the copy.
|
|
147
187
|
|
|
148
188
|
To wire OpenCode up by hand, put the server in `~/.config/opencode/opencode.json` (`command` is
|
|
149
189
|
the whole argv) and copy [`skills/rust-anything/`](./skills/rust-anything) to
|
|
@@ -167,6 +207,7 @@ rust-anything bridge . src/fuzzy.ts --batch fuzzyScore:text
|
|
|
167
207
|
# write src/port.rs (or let your agent), then:
|
|
168
208
|
rust-anything record rust/fuzzy-rs && rust-anything build rust/fuzzy-rs
|
|
169
209
|
rust-anything diff rust/fuzzy-rs # every recorded case must match
|
|
210
|
+
rust-anything fuzz rust/fuzzy-rs --time 60 --keep # fresh inputs: what the recording missed
|
|
170
211
|
rust-anything bench rust/fuzzy-rs # faster? the verdict says
|
|
171
212
|
rust-anything gate rust/fuzzy-rs # done means this passes
|
|
172
213
|
```
|
|
@@ -195,17 +236,36 @@ Same output is not enough. Record what the app sends too, and a rewrite that mai
|
|
|
195
236
|
| Go | package | typed cgo calls and a generated binary wire, in a package with the original API | a generated Go driver, built as its own module |
|
|
196
237
|
| Ruby | file or folder of module functions | a magnus extension under the original modules | a generated Ruby driver |
|
|
197
238
|
| Java | package of `public static` methods | typed JNI and a generated binary wire, in wrapper classes with the original methods | a generated reflection driver |
|
|
239
|
+
| Kotlin | Gradle module of top-level functions and `@JvmStatic` methods | the Java bridge: typed JNI in Java wrapper classes calling the compiled Kotlin statics | a generated reflection driver, with the Kotlin sources compiled by `kotlinc` |
|
|
198
240
|
| PHP | folder of functions and `public static` methods | coming next: PHP FFI over a C ABI | whole apps today: `app record`, `app replay` and the front door, for CLIs and servers (`php -S`) |
|
|
199
241
|
| C# | folder of `public static` methods | coming next: P/Invoke over a C ABI | whole apps today: `app record`, `app replay` and the front door, for CLIs and ASP.NET servers (`dotnet <app>.dll`) |
|
|
200
242
|
|
|
201
243
|
Every language except C also gets batch classes (`--batch`): the items cross once and stay in
|
|
202
244
|
Rust, and each call runs over all of them on all cores.
|
|
203
245
|
|
|
204
|
-
The language is detected from the repository (`go.mod`, `pom.xml`,
|
|
205
|
-
`pyproject.toml`, `Gemfile`, `composer.json`, `package.json`, else the most
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
as
|
|
246
|
+
The language is detected from the repository (`go.mod`, `pom.xml`, `build.gradle`/`build.gradle.kts`,
|
|
247
|
+
a `.csproj` or `.sln`, `pyproject.toml`, `Gemfile`, `composer.json`, `package.json`, else the most
|
|
248
|
+
common source files); a Gradle module with `.kt` sources and no `.java` sources is Kotlin, mixed
|
|
249
|
+
modules stay Java. `--lang` overrides it. Types come from the source: TS types, Python hints, C, Go,
|
|
250
|
+
Java, Kotlin and C# signatures, Ruby YARD tags, PHP types and phpdoc; untyped parameters used as
|
|
251
|
+
numbers are inferred as numbers.
|
|
252
|
+
|
|
253
|
+
For Android, `rust-anything build <crate> --profile android` builds the same JNI library with the
|
|
254
|
+
NDK for `arm64-v8a`, `armeabi-v7a` and `x86_64` (or the `--abi` values you pass) and installs it
|
|
255
|
+
into `<crate>/jniLibs/<abi>/`; `--api` sets the API level (minimum 26, which the generated Java
|
|
256
|
+
runtime needs). It finds the NDK from `ANDROID_NDK_HOME`/`ANDROID_NDK_ROOT` or the SDK, needs the
|
|
257
|
+
Rust targets (`rustup target add aarch64-linux-android armv7-linux-androideabi
|
|
258
|
+
x86_64-linux-android`), links 64-bit libraries with 16 KB page alignment, and checks that every
|
|
259
|
+
JNI entry point is exported. Gradle looks in `src/main/jniLibs` by default, so pass
|
|
260
|
+
`--jni-libs app/src/main/jniLibs` or add `<crate>/jniLibs` to `sourceSets.main.jniLibs.srcDirs`.
|
|
261
|
+
`rust-anything record <crate> --profile android` runs the original Kotlin unit under ART on a
|
|
262
|
+
connected device (adb), dexes the generated driver with `d8` from the SDK's build-tools, and pulls
|
|
263
|
+
the results back as the same `cases.jsonl`; `diff <crate> --profile android` replays them against
|
|
264
|
+
the `.so` built for the device's ABI. Both need `adb`, a device, `kotlinc`, an SDK with build-tools
|
|
265
|
+
and a platform, and `--device <serial>` when more than one device is connected. The profile covers
|
|
266
|
+
logic units: Activity/Compose/XML UI, lifecycle and SDK-only classes stay in Kotlin, and each call
|
|
267
|
+
crosses JNI, so prefer the generated batch wrappers for hot loops. On a host, `record` and `diff`
|
|
268
|
+
keep using the desktop JVM.
|
|
209
269
|
|
|
210
270
|
For PHP, `analyze` plans a PHP app (Composer packages and PSR-4 autoloading, risks
|
|
211
271
|
such as loose comparison and integer overflow into floats, Composer packages mapped to crates),
|
|
@@ -221,6 +281,7 @@ comes next.
|
|
|
221
281
|
## Learn more
|
|
222
282
|
|
|
223
283
|
- [How it works](docs/how-it-works.md): the loop, what `bridge` and `analyze` decide, hot paths, what it can't catch, what a real port takes, and keeping up with the original (`map`)
|
|
284
|
+
- [Ship a port as a package](docs/packaging.md): maturin wheels and napi-rs per-platform npm packages, with the CI that builds them
|
|
224
285
|
- [Port a whole app](docs/whole-apps.md): servers, CLIs and libraries, from the front door to `app lift`
|
|
225
286
|
- [Examples and case studies](docs/examples.md): x18n, and real code in six languages
|
|
226
287
|
- [Real-world ports](docs/real-world.md): json-server, Fuse.js, vercel/ms, with benchmarks
|
|
@@ -235,7 +296,7 @@ comes next.
|
|
|
235
296
|
</p>
|
|
236
297
|
|
|
237
298
|
<p align="center">
|
|
238
|
-
<a href="https://coderabbit.
|
|
299
|
+
<a href="https://coderabbit.link/erkamyaman">
|
|
239
300
|
<picture>
|
|
240
301
|
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/company-dark.svg">
|
|
241
302
|
<img src="docs/assets/sponsors/company-light.svg" width="800" alt="Company sponsor: CodeRabbit">
|
|
@@ -247,13 +308,14 @@ comes next.
|
|
|
247
308
|
<a href="https://github.com/sponsors/erkamyaman">
|
|
248
309
|
<picture>
|
|
249
310
|
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/sponsors/sponsors-dark.svg">
|
|
250
|
-
<img src="docs/assets/sponsors/sponsors-light.svg" width="800" alt="Sponsors: Ali Yilmaz, Ashley Hunter, Fatih Uzuntaş">
|
|
311
|
+
<img src="docs/assets/sponsors/sponsors-light.svg" width="800" alt="Sponsors: Santosh Yadav, Hakan Soytürk, Ali Yilmaz, Ashley Hunter, Fatih Uzuntaş">
|
|
251
312
|
</picture>
|
|
252
313
|
</a>
|
|
253
314
|
</p>
|
|
254
315
|
|
|
255
316
|
<p align="center">
|
|
256
317
|
<a href="https://github.com/sponsors/erkamyaman"><img src="https://img.shields.io/badge/Become_a_sponsor-%E2%9D%A4-db61a2?style=for-the-badge&logo=githubsponsors&logoColor=white" alt="Become a sponsor"></a>
|
|
318
|
+
<a href="https://buymeacoffee.com/erkamyaman"><img src="https://img.shields.io/badge/Buy_me_a_coffee-%E2%98%95-FFDD00?style=for-the-badge&logo=buymeacoffee&logoColor=black" alt="Buy me a coffee"></a>
|
|
257
319
|
</p>
|
|
258
320
|
|
|
259
321
|
## Contributing
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-anything",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Rewrite your app in Rust, one piece at a time, checked against the original's recorded behavior at every step. TypeScript, Python, C, Go, Ruby, Java.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rust",
|