rust-anything 1.0.1 → 1.2.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/LICENSE +1 -1
- package/README.md +237 -21
- package/bin/rust-anything.js +1 -1
- package/binaries/darwin-arm64/rust-anything +0 -0
- package/binaries/darwin-x64/rust-anything +0 -0
- package/binaries/linux-arm64/rust-anything +0 -0
- package/binaries/linux-x64/rust-anything +0 -0
- package/binaries/win32-x64/rust-anything.exe +0 -0
- package/package.json +2 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="docs/assets/
|
|
2
|
+
<img src="docs/assets/logo.svg" width="160" height="160" alt="The rust-anything crab, its mouth a code tag">
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
<h1 align="center">rust-anything</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><em>Rewrite your whole app in Rust. Keep it working the whole way.</em></p>
|
|
8
|
+
|
|
9
|
+
<p align="center"><em>CLIs, servers and libraries, piece by piece, checked against the original at every step.</em></p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<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
|
+
<img src="https://img.shields.io/badge/languages-6-E2862A" alt="6 languages">
|
|
14
|
+
<a href="#works-with"><img src="https://img.shields.io/badge/works%20with-4%20agents-E2862A" alt="Works with 4 agents"></a>
|
|
15
|
+
<a href="https://github.com/erkamyaman/rust-anything/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/erkamyaman/rust-anything/ci.yml?branch=main&label=tests" alt="Tests"></a>
|
|
16
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-E2862A" alt="MIT license"></a>
|
|
17
|
+
<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>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">up to 20x faster · 38,251 recorded cases replayed · 0 mismatches · one command</p>
|
|
21
|
+
|
|
22
|
+
**Rewrite your whole app in Rust, one piece at a time.** rust-anything records what your
|
|
23
|
+
TypeScript/JavaScript, Python, C, Go, Ruby or Java app does today, then checks every piece of the
|
|
24
|
+
Rust rewrite against that recording before it moves on, until the app is pure Rust. CLIs, HTTP
|
|
25
|
+
servers and libraries; your coding agent (or you) writes the Rust. It can only catch what the
|
|
26
|
+
recording covers: see [What it can't catch](#what-it-cant-catch). Only need the slow part fast?
|
|
27
|
+
Port just that, one hot path at a time:
|
|
8
28
|
|
|
9
29
|
| Real workload, same results as the original | Original | With rust-anything |
|
|
10
30
|
| --- | ---: | ---: |
|
|
@@ -31,19 +51,20 @@ rust-anything finds the loop worth moving, and moves it.
|
|
|
31
51
|
Paste this into Claude Code, Codex, Cursor or Gemini CLI and let your agent install it:
|
|
32
52
|
|
|
33
53
|
```text
|
|
34
|
-
Install rust-anything: run `cargo install
|
|
35
|
-
|
|
54
|
+
Install rust-anything: run `cargo install rust-anything`, then `rust-anything setup`.
|
|
55
|
+
Tell me when to restart you.
|
|
36
56
|
```
|
|
37
57
|
|
|
38
58
|
Or yourself:
|
|
39
59
|
|
|
40
60
|
```sh
|
|
41
|
-
|
|
42
|
-
# or: cargo install --git https://github.com/erkamyaman/rust-anything
|
|
61
|
+
cargo install rust-anything # from crates.io
|
|
43
62
|
rust-anything setup # registers it with Claude Code, Codex, Cursor and Gemini CLI
|
|
44
63
|
```
|
|
45
64
|
|
|
46
|
-
Prebuilt binaries are
|
|
65
|
+
No Rust toolchain yet? Prebuilt binaries for macOS, Linux and Windows are attached to each
|
|
66
|
+
[GitHub release](https://github.com/erkamyaman/rust-anything/releases), and for JavaScript
|
|
67
|
+
projects `npm install -g rust-anything` installs the same binary.
|
|
47
68
|
|
|
48
69
|
In Claude Code you can also install it as a plugin (the MCP server and the skill; the CLI above
|
|
49
70
|
must be on your `PATH`):
|
|
@@ -56,6 +77,7 @@ must be on your `PATH`):
|
|
|
56
77
|
reads skills. It keeps your other settings, is safe to run again, and `--remove` undoes it.
|
|
57
78
|
Then ask your agent, for example:
|
|
58
79
|
|
|
80
|
+
- *"Rewrite this CLI in Rust with rust-anything, end to end, and prove it behaves the same."*
|
|
59
81
|
- *"This search feels slow. Profile it with rust-anything and move the hot loop to Rust."*
|
|
60
82
|
- *"Plan a migration of `src/parser/` to Rust with rust-anything; port the first unit and prove it."*
|
|
61
83
|
- *"Bench the Rust port in `rust/text-rs` against the original and tell me whether to ship it."*
|
|
@@ -127,21 +149,182 @@ The original stays the source of truth: `record` runs it on edge cases (and your
|
|
|
127
149
|
saves what it returns or throws; `diff` replays every case against the Rust; nothing ships until
|
|
128
150
|
they all match and `gate` passes. Callers keep the original API throughout.
|
|
129
151
|
|
|
152
|
+
A whole app goes through the same loop unit by unit, inside a frame that proves the whole
|
|
153
|
+
program ([Port a whole app](#port-a-whole-app)):
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
analyze --whole-app ──> app record ──> app front-door ──> per unit: the loop above, then app wire ──> app lift
|
|
157
|
+
shape, every what the app Rust owns the gate passes, so the unit answers in pure Rust,
|
|
158
|
+
dependency, the does from the entry point; the Rust: replay 100%, fallback rate down proved by
|
|
159
|
+
decisions to make outside original answers replay
|
|
160
|
+
```
|
|
161
|
+
|
|
130
162
|
## The loop
|
|
131
163
|
|
|
132
164
|
| Step | Command | What it does |
|
|
133
165
|
| --- | --- | --- |
|
|
134
|
-
| 0. Profile | `rust-anything profile <repo> -- node bench.mjs` | Runs a real workload under the language's profiler (node, cProfile, `go test` pprof, JFR, a Ruby tracer): hot functions by inclusive time, their callers, and which loops to batch |
|
|
135
|
-
| 1. Plan | `rust-anything analyze <repo>` | Units, port order, risks with `file:line`, bridge per unit, dependency-to-crate fit, best first ports |
|
|
166
|
+
| 0. Profile | `rust-anything profile <repo> -- node bench.mjs` | Runs a real workload under the language's profiler (node, cProfile, `go test` pprof, JFR, a Ruby tracer): hot functions by inclusive time, their callers, and which loops to batch; flags code that is already compiled (numba, Cython, JAX), where Rust gains little |
|
|
167
|
+
| 1. Plan | `rust-anything analyze <repo>` | Units, port order, risks with `file:line`, bridge per unit, dependency-to-crate fit, best first ports; `--whole-app` adds entry points and shape, every dependency (imported or declared) with its crate, pieces (units that import each other move together) and numbered decisions with a recommended answer |
|
|
136
168
|
| 2. Bridge | `rust-anything bridge <repo> <unit>` | Crate with the bindings (`lib.rs`, plus the wrapper the source language loads) and stubs to port (`port.rs`); `--batch fn:param` adds a class that keeps many `param` values in Rust |
|
|
137
|
-
| 3. Record | `rust-anything record <crate>` | Runs the original on generated edge cases (non-ASCII, emoji, `-0`, `NaN`, ints where floats are expected, ...) and saves `cases.jsonl` |
|
|
169
|
+
| 3. Record | `rust-anything record <crate>` | Runs the original on generated edge cases (non-ASCII, emoji, `-0`, `NaN`, ints where floats are expected, ...) and on every semantic trap in every parameter (string length and case, signed division, overflow edges, float printing, map and sort order), and saves `cases.jsonl`; `--float-tolerance 1e-9` lets floats match within that share for numeric code |
|
|
138
170
|
| 3. Build | `rust-anything build <crate>` | Builds the Rust side: `.node`, wasm package, Python extension or shared library |
|
|
139
171
|
| 3. Diff | `rust-anything diff <crate>` | Replays the recorded cases against Rust, called the way the original's callers call it; lists mismatches |
|
|
140
172
|
| 3. Bench | `rust-anything bench <crate>` | Times the recorded cases on the original and on Rust, bridge included |
|
|
141
173
|
| 4. Shadow | `rust-anything shadow <crate>` | Drop-in that runs both, returns the original's result, reports mismatches; `RUST_ANYTHING_MODE=old\|shadow\|new` |
|
|
142
|
-
| 5. Gate | `rust-anything gate <crate>` | fmt, clippy `-D warnings`, tests, `unsafe` audit, nothing unported, build, API, behavior |
|
|
174
|
+
| 5. Gate | `rust-anything gate <crate>` | fmt, clippy `-D warnings`, tests, `unsafe` audit, nothing unported, a recorded failing case for every error path of the original, no `unwrap`/`expect`/`panic!` where the original returns an error (unless marked `// INFALLIBLE: <why>`), build, API, behavior |
|
|
143
175
|
| Agents | `rust-anything setup` | Registers the MCP server (`rust-anything mcp`, every step as a tool) and the workflow skill ([`skills/rust-anything/SKILL.md`](./skills/rust-anything/SKILL.md)) with your coding agents |
|
|
144
176
|
|
|
177
|
+
## Port a whole app
|
|
178
|
+
|
|
179
|
+
The goal is a pure Rust app that behaves like the original, with the original kept as reference.
|
|
180
|
+
Your agent writes the Rust; rust-anything orders the work, scaffolds it, and proves every step.
|
|
181
|
+
The [whole-app skill](./skills/rust-anything/whole-app.md) walks the agent through it, starting
|
|
182
|
+
with the decisions only you can make:
|
|
183
|
+
|
|
184
|
+
- **Grilling**: the agent asks in rounds, each question with its recommended answer, until every
|
|
185
|
+
decision the port depends on is settled, and writes each one as an ADR in `rust/DECISIONS.md`,
|
|
186
|
+
with `rust/GLOSSARY.md` mapping the original's terms to Rust names.
|
|
187
|
+
- **Research**: background agents read each dependency's primary sources and write
|
|
188
|
+
`rust/research/<topic>.md`, with every semantic trap they found.
|
|
189
|
+
- **Across sessions**: `rust/MAP.md` lists every unit with its state; a session claims one unit
|
|
190
|
+
before it starts, and each checkpoint leaves a `rust/HANDOFF.md` for the next session. Units in
|
|
191
|
+
one wave can be ported in parallel by subagents.
|
|
192
|
+
- **Cutover**: the agent does what it can and writes `rust/cutover.sh`, an interactive script for
|
|
193
|
+
the steps only you can do (deploys, DNS, secrets), with a way back at each step.
|
|
194
|
+
|
|
195
|
+
Grilling, research and these practices are adapted from
|
|
196
|
+
[Matt Pocock's skills](https://github.com/mattpocock/skills).
|
|
197
|
+
|
|
198
|
+
Plan first: `rust-anything analyze . --whole-app` adds the app's shape (CLI, server or library)
|
|
199
|
+
and entry points, every external dependency (imported or declared) with its Rust crate and fit,
|
|
200
|
+
the port order as pieces (units that import each other move together), and numbered decisions
|
|
201
|
+
with a recommended answer: keep units, blocked units, dependencies with no or a partial crate.
|
|
202
|
+
|
|
203
|
+
Then prove the whole program from the outside. `record` and `diff` prove one unit; `app record`
|
|
204
|
+
and `app replay` prove the app, for CLIs and servers in any of the six languages (the app is a
|
|
205
|
+
black box):
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
rust-anything app record . -- python3 cli.py # the command that runs the original
|
|
209
|
+
rust-anything app replay . # the original must pass 100%
|
|
210
|
+
rust-anything app replay . --build "target/release/mytool"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
- `app record` runs the original on the app's own documented examples (`$ mytool ...` lines in
|
|
214
|
+
its Markdown and shell files, with the files they name), an `--inputs` JSONL file
|
|
215
|
+
(`{"name", "args", "stdin", "env", "files"}`), and semantic traps derived from those cases
|
|
216
|
+
(non-ASCII and emoji strings, negative division and modulo, overflow, large and tiny floats,
|
|
217
|
+
map order, missing files). Each case runs twice; what differs between the two runs becomes a
|
|
218
|
+
`[..]` wildcard. `--normalize timestamps|uuids|key-order` or `--normalize name=regex` adds
|
|
219
|
+
normalizers, saved with the cases.
|
|
220
|
+
- Cases are [trycmd](https://docs.rs/trycmd) files in `rust/app-cases/`: `<case>.toml` (argv, env,
|
|
221
|
+
exit code), `.stdin`, `.stdout`, `.stderr`, `.in/` (files in) and `.out/` (files written). Read
|
|
222
|
+
and edit them by hand; a Rust test can run them with `trycmd` once the port has a binary.
|
|
223
|
+
- `app replay` runs any build against the cases, prints `passed/total`, writes
|
|
224
|
+
`rust/app-cases/replay-report.md` with a diff per failing case, and exits non-zero on any
|
|
225
|
+
mismatch. A build that appends to the file named by `RUST_ANYTHING_FALLBACK_LOG` (one line per
|
|
226
|
+
fallback to the original), as the front door below does, also gets its fallback rate reported.
|
|
227
|
+
- `app replay --case <name>` reruns one case by the name the report gives it: the fast,
|
|
228
|
+
repeatable loop for fixing a mismatch before running everything again.
|
|
229
|
+
|
|
230
|
+
Then move the entry point to Rust and hand it commands one unit at a time:
|
|
231
|
+
|
|
232
|
+
```sh
|
|
233
|
+
rust-anything app front-door . # rust/app: every command runs the original
|
|
234
|
+
rust-anything app wire . textkit --command upper # after textkit-rs passes gate
|
|
235
|
+
# write the glue in rust/app/src/units/textkit.rs, then:
|
|
236
|
+
rust-anything app wire . textkit # 100% again, lower fallback rate
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
- `app front-door` scaffolds `rust/app`, a Rust binary named after the app: a clap parser for the
|
|
240
|
+
commands and flags in the recorded cases, where every command runs the original with the same
|
|
241
|
+
argv, stdin and environment and passes its output and exit code through. Each fallback is
|
|
242
|
+
counted, so replaying the fresh front door gives 100% passed at 100% fallback (it builds and
|
|
243
|
+
replays to show it). It never overwrites `rust/app`: the code is yours from then on.
|
|
244
|
+
- `app wire <repo> <unit> --command <name>` runs `gate` on the unit crate (`--skip-gate` if it just
|
|
245
|
+
passed), adds it to `rust/app` as a library, writes `src/units/<unit>.rs` once for you or your
|
|
246
|
+
agent to fill in (parse the arguments, call `<crate>::port`, print what the original prints),
|
|
247
|
+
routes the commands to it, then builds and replays. `RUST_ANYTHING_UNIT_<NAME>=original` sends a
|
|
248
|
+
wired unit back to the original until the lift.
|
|
249
|
+
|
|
250
|
+
Wire the app's own name as a command (`--command mytool`) for argv that names no command: no
|
|
251
|
+
arguments, unknown commands, usage errors.
|
|
252
|
+
|
|
253
|
+
When replay passes with fallback rate 0 and every unit passes gate, make it a pure Rust app:
|
|
254
|
+
|
|
255
|
+
```sh
|
|
256
|
+
rust-anything app lift .
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
- `app lift` refuses until both hold, and says what blocks it: the cases still falling back,
|
|
260
|
+
glue still a stub, units failing gate.
|
|
261
|
+
- On a copy first, it removes the fallback path and the kill switches, turns each unit crate into
|
|
262
|
+
a plain library of `rust/app` (no `cdylib`, bindings or generated wrappers), and adds
|
|
263
|
+
`rust/app/tests/app_cases.rs`, which runs `rust/app-cases` with trycmd on `cargo test`, so CI
|
|
264
|
+
needs nothing but cargo.
|
|
265
|
+
- Then it runs the lift checklist: fmt, clippy `-D warnings` and tests on every unit and on
|
|
266
|
+
`rust/app`, every target named in `rust/DECISIONS.md` built or checked where it is installed,
|
|
267
|
+
files read at run time and asset folders not embedded, and replay on the pure binary. Only when
|
|
268
|
+
all of it passes are the changes written back. The original is never touched.
|
|
269
|
+
|
|
270
|
+
### Servers
|
|
271
|
+
|
|
272
|
+
The same commands prove HTTP servers. `--http` says the command starts a server; it takes its
|
|
273
|
+
port from `PORT` or `{port}` in the command (`--port` for one that always listens on the same
|
|
274
|
+
port):
|
|
275
|
+
|
|
276
|
+
```sh
|
|
277
|
+
rust-anything app record . --http -- node server.js
|
|
278
|
+
rust-anything app replay .
|
|
279
|
+
rust-anything app front-door . # axum: every route proxied
|
|
280
|
+
rust-anything app wire . api --route 'GET /users/{id}' --route '*'
|
|
281
|
+
rust-anything app lift .
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
- Requests come from `curl` lines in the app's docs (`curl -X POST -d ... http://localhost:8080/x`),
|
|
285
|
+
`--inputs` (`{"name", "method", "path", "headers", "body"}`) and traps: path segments and query
|
|
286
|
+
values swapped for the same traps as CLI arguments, bodies for text and JSON traps, and an
|
|
287
|
+
unknown route. Each run starts the server fresh and sends the requests in name order, so state
|
|
288
|
+
between requests is kept.
|
|
289
|
+
- Cases are `rust/app-cases/http/<case>.toml` (the request, the status and the headers that matter)
|
|
290
|
+
and `<case>.body` (the response body, with `[..]` where two runs differed). Date, server and
|
|
291
|
+
other per-response headers are left out; delete any header line you do not care about.
|
|
292
|
+
- The front door is an axum server that starts the original on a port of its own and proxies
|
|
293
|
+
every route no unit answers. `wire --route` takes axum routes: `METHOD /path/{param}`, `/path`
|
|
294
|
+
for any method, `*` for everything else; the glue gets the route, its parameters and the
|
|
295
|
+
request. `lift` removes the proxy; HTTP cases then run in CI with `app replay`.
|
|
296
|
+
|
|
297
|
+
### Libraries
|
|
298
|
+
|
|
299
|
+
A library has no process to replay: its public API is the front door, and each unit's recorded
|
|
300
|
+
cases are the proof.
|
|
301
|
+
|
|
302
|
+
```sh
|
|
303
|
+
rust-anything app front-door . # rust/app: a Rust crate with the public API
|
|
304
|
+
# each unit through the loop: bridge, record, port.rs, build, diff, gate; then:
|
|
305
|
+
rust-anything app wire . textkit-rs # re-exported from rust/app; the original imports its shadow
|
|
306
|
+
rust-anything app replay . # every wired unit's cases; fallback = exports still in the original
|
|
307
|
+
rust-anything app lift .
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
- `app front-door` finds the public API (every unit's exports) when the repository has no `main`
|
|
311
|
+
and no server (`--library` otherwise), and scaffolds `rust/app` as a library crate. Each wired
|
|
312
|
+
unit becomes a module of it: `pub use textkit_rs::port as textkit;`.
|
|
313
|
+
- `app wire` takes a crate made by `bridge`, runs `gate`, and writes the unit's shadow drop-in:
|
|
314
|
+
the original package imports it in place of the unit, so its callers keep the original API and
|
|
315
|
+
reach the Rust. `RUST_ANYTHING_UNIT_<NAME>=original` sends the unit back (C: build without the
|
|
316
|
+
shadow's flags).
|
|
317
|
+
- `app replay` runs every wired unit's recorded cases through its bindings. The fallback rate is
|
|
318
|
+
the share of public exports Rust does not answer yet: unwired units, and exports `bridge` keeps
|
|
319
|
+
in the original language.
|
|
320
|
+
- `app lift` needs fallback 0 and every unit through `gate`; it strips the bindings, wrappers and
|
|
321
|
+
shadows from the units and leaves `rust/app` as one pure Rust library. It does not touch any
|
|
322
|
+
`port.rs`, so the cases that matched through the bindings still describe it; the checklist
|
|
323
|
+
warns about files of the original that still import the shadows.
|
|
324
|
+
|
|
325
|
+
All five are MCP tools too: `app_record`, `app_replay`, `app_front_door`, `app_wire` and
|
|
326
|
+
`app_lift`.
|
|
327
|
+
|
|
145
328
|
## Case study: x18n's core
|
|
146
329
|
|
|
147
330
|
All 29 functions of x18n's core that can move without an API change were ported with rust-anything:
|
|
@@ -301,7 +484,7 @@ installed, and TS that needs transforming (enums, parameter properties) is retri
|
|
|
301
484
|
## Development
|
|
302
485
|
|
|
303
486
|
```sh
|
|
304
|
-
cargo test # unit tests, fixture repo, record/diff/shadow loop (needs node)
|
|
487
|
+
cargo test # unit tests, fixture repo, record/diff/shadow loop (needs node), app record/replay per language
|
|
305
488
|
cargo clippy --all-targets -- -D warnings
|
|
306
489
|
cargo fmt
|
|
307
490
|
```
|
|
@@ -312,16 +495,43 @@ Design choices and their reasons: [DECISIONS.md](./DECISIONS.md).
|
|
|
312
495
|
## Update or remove
|
|
313
496
|
|
|
314
497
|
```sh
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
rust-anything setup
|
|
318
|
-
rust-anything setup --remove &&
|
|
319
|
-
rust-anything setup --remove &&
|
|
498
|
+
cargo install rust-anything # update (Cargo)
|
|
499
|
+
npm install -g rust-anything@latest # update (npm)
|
|
500
|
+
rust-anything setup # refresh agent settings
|
|
501
|
+
rust-anything setup --remove && cargo uninstall rust-anything # remove (Cargo)
|
|
502
|
+
rust-anything setup --remove && npm uninstall -g rust-anything # remove (npm)
|
|
320
503
|
```
|
|
321
504
|
|
|
322
505
|
`setup --remove` takes out only rust-anything's entries; the copies it saved
|
|
323
506
|
(`<file>.rust-anything.bak`) stay until you delete them.
|
|
324
507
|
|
|
508
|
+
## What it can't catch
|
|
509
|
+
|
|
510
|
+
Passing means the Rust matches every case that was recorded, nothing more. What bites rewrites
|
|
511
|
+
usually lives outside the recording, so know where the edges are:
|
|
512
|
+
|
|
513
|
+
- **Inputs nobody recorded.** The generated cases, the traps and your own `--inputs` are the
|
|
514
|
+
ceiling. Add real inputs (production samples, bug reports, the original's test fixtures); the
|
|
515
|
+
user input that breaks prod is rarely one a generator thinks of.
|
|
516
|
+
- **Regexes.** The `regex` crate has no lookaround or backreferences, and even a pattern that
|
|
517
|
+
compiles can treat `\w`, `\b`, `\d` and case-insensitive matching on non-ASCII text differently
|
|
518
|
+
from JS, Python or Java. Swapping in `fancy-regex` or rewriting the pattern can pass every
|
|
519
|
+
recorded case and still differ on a Turkish dotless `ı` or a zero-width joiner. `record` adds
|
|
520
|
+
regex traps (those, the Kelvin sign, long s, Arabic-Indic digits, line separators, final sigma)
|
|
521
|
+
to every function in a file that uses regexes, but fuzz your real patterns against real text too.
|
|
522
|
+
- **What changes between runs.** `record` runs the original twice and sorts out what differed:
|
|
523
|
+
changed values (times, ids) become wildcards; the same lines in another order (hash maps,
|
|
524
|
+
concurrency) are compared in any order, so a port still has to produce exactly those lines; a
|
|
525
|
+
different number of lines becomes `...`, which matches anything. `record` lists each kind:
|
|
526
|
+
look at every one, since a hash-order or concurrency difference is exactly what can change for
|
|
527
|
+
real in a port.
|
|
528
|
+
- **Floats.** Number-to-text formatting differs between languages (`1e21`, `-0`, digit counts).
|
|
529
|
+
The traps include those values, and they must match exactly; `--float-tolerance` forgives
|
|
530
|
+
rounding only, never formatting.
|
|
531
|
+
- **Anything not in the output.** Timing, memory, concurrency under load, and side effects other
|
|
532
|
+
than stdout, stderr, exit codes, written files and HTTP responses (network calls, databases,
|
|
533
|
+
signals) are not compared.
|
|
534
|
+
|
|
325
535
|
## FAQ
|
|
326
536
|
|
|
327
537
|
**Does it rewrite my code automatically?** No. It finds what to move, generates the bridge,
|
|
@@ -334,7 +544,13 @@ runs both and returns the original's result while you build confidence).
|
|
|
334
544
|
**Is Rust always faster?** No, and rust-anything says so. A small function called once per item
|
|
335
545
|
is often slower in Rust, because each call crosses a bridge; V8, the JVM and Go run such functions
|
|
336
546
|
in nanoseconds. `profile` finds the loop around it, `--batch` moves the whole loop, and `bench`
|
|
337
|
-
gives a verdict before you ship.
|
|
547
|
+
gives a verdict before you ship. Code already compiled by numba, Cython or JAX runs as machine
|
|
548
|
+
code too: `profile` and `analyze` flag it, since porting it buys little speed.
|
|
549
|
+
|
|
550
|
+
**My code is numeric; will the floats match exactly?** Often not: operation order, fused
|
|
551
|
+
multiply-add and the math library differ between compilers. Record with `--float-tolerance 1e-9`
|
|
552
|
+
(`record` or `app record`), and floats match within that share of the larger value (absolute below
|
|
553
|
+
1). Integers, text and structure still have to match exactly.
|
|
338
554
|
|
|
339
555
|
**Does my code leave my machine?** No: rust-anything runs locally and sends none of your code
|
|
340
556
|
anywhere. Cargo downloads crates as usual, and your agent's model provider sees what your agent
|
|
@@ -354,4 +570,4 @@ especially welcome.
|
|
|
354
570
|
|
|
355
571
|
## License
|
|
356
572
|
|
|
357
|
-
[MIT](./LICENSE). Ports and generated code in your repository are yours.
|
|
573
|
+
[MIT](./LICENSE) © [Erkam Yaman](https://github.com/erkamyaman). Ports and generated code in your repository are yours.
|
package/bin/rust-anything.js
CHANGED
|
@@ -10,7 +10,7 @@ const bin = path.join(__dirname, '..', 'binaries', key, exe)
|
|
|
10
10
|
if (!fs.existsSync(bin)) {
|
|
11
11
|
console.error(
|
|
12
12
|
`rust-anything: no prebuilt binary for ${key}.\n` +
|
|
13
|
-
'Install it with Cargo instead: cargo install
|
|
13
|
+
'Install it with Cargo instead: cargo install rust-anything',
|
|
14
14
|
)
|
|
15
15
|
process.exit(1)
|
|
16
16
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-anything",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
7
7
|
"performance",
|