rust-anything 4.0.0

Rewrite your app in Rust, one piece at a time, checked against the original's recorded behavior at every step. TypeScript/JavaScript, Python, C, Go, Ruby, Java, Kotlin, PHP, C# and PowerShell
Documentation
{
  "version": "1.5.1",
  "commands": [
    {
      "command": "",
      "help": "Rewrite TypeScript/JavaScript, Python, C, Go, Ruby or Java apps in Rust, one verified piece at a time\n\nUsage: rust-anything <COMMAND>\n\nCommands:\n  analyze  1. Map a repository and write a ranked, ordered migration plan\n  bridge   2. Scaffold a Rust crate with JS bindings for one unit\n  refresh  2b. Regenerate the bindings (`lib.rs`, `index.cjs`, `js.rs`) from the signatures in `port.rs`\n  record   3a. Record what the TS functions return on generated and given inputs\n  build    3b. Build the crate's JS module (napi-rs `.node` or wasm-bindgen output)\n  diff     3c. Replay recorded cases against the Rust module\n  bench    3d. Time the recorded cases on the TS original and on Rust, bridge included\n  profile  Run a real workload under the language's profiler and say what to port: hot functions, their callers, and loops to batch. `rust-anything profile <repo> -- node bench.mjs` (also `python3 x.py`, `go test -bench . ./pkg`, `java ...`, `ruby x.rb`)\n  shadow   4. Generate a drop-in module that runs TS and Rust side by side\n  gate     5. Check the definition of done for a port\n  app      Record the whole app's behavior and replay any build against it (CLIs)\n  mcp      Serve every step as MCP tools over stdio\n  setup    Register rust-anything with your coding agents (Claude Code, Codex, Cursor, Gemini CLI): the MCP server and, where the agent reads skills, the workflow skill. Keeps your other settings; run it again any time\n  doctor   Check the language runtimes, the agent setup and the MCP server, with the command that fixes each problem. Exits 1 when something required is missing\n  help     Print this message or the help of the given subcommand(s)\n\nOptions:\n  -h, --help     Print help\n  -V, --version  Print version\n\nLoop per unit: analyze -> bridge -> record -> port src/port.rs -> build -> diff -> shadow -> gate\n"
    },
    {
      "command": "analyze",
      "help": "1. Map a repository and write a ranked, ordered migration plan\n\nUsage: rust-anything analyze [OPTIONS] [ROOT]\n\nArguments:\n  [ROOT]  Repository root [default: .]\n\nOptions:\n      --json         Print the machine-readable report (schema `rust-anything/analyze@1`) instead of Markdown\n  -o, --out <OUT>    Write to this file instead of stdout\n      --lang <LANG>  Source language; detected from the repository when omitted [possible values: ts, python, c, go, ruby, java, php, csharp]\n      --whole-app    Plan a whole-app port: entry points and shape, every dependency (imported or declared) with its crate, pieces in port order, and decisions for the user\n  -h, --help         Print help\n"
    },
    {
      "command": "bridge",
      "help": "2. Scaffold a Rust crate with JS bindings for one unit\n\nUsage: rust-anything bridge [OPTIONS] <ROOT> <UNIT>\n\nArguments:\n  <ROOT>  Repository root\n  <UNIT>  Unit id, as `analyze` lists it\n\nOptions:\n      --kind <KIND>           Bridge to generate; defaults to the plan's choice [possible values: napi, wasm]\n  -o, --out <OUT>             Crate folder; defaults to `<root>/rust/<name>`\n      --name <NAME>           Crate name; defaults to `<unit>-rs`\n      --force                 Bridge a unit the plan marks blocked or keep\n      --keep <KEEP>           Keep an export in TS: `name` or `\"name: reason\"`. Repeatable\n      --batch <BATCH>         Add a batch class: `function:param` runs `function` over many `param` values kept in Rust, on all cores (what `profile` recommends for leaves called in loops)\n      --as-json <TYPE_PARAM>  Bridge a type parameter as JSON values (`--as-json T`) when the app only fills it with data, instead of keeping the generic export in TS. Repeatable\n  -h, --help                  Print help\n"
    },
    {
      "command": "refresh",
      "help": "2b. Regenerate the bindings (`lib.rs`, `index.cjs`, `js.rs`) from the signatures in `port.rs`\n\nUsage: rust-anything refresh [OPTIONS] [CRATE_DIR]\n\nArguments:\n  [CRATE_DIR]  [default: .]\n\nOptions:\n      --batch <BATCH>  Add a batch class: `function:param` runs `function` over many `param` values kept in Rust, on all cores. Repeat for more\n  -h, --help           Print help\n"
    },
    {
      "command": "record",
      "help": "3a. Record what the TS functions return on generated and given inputs\n\nUsage: rust-anything record [OPTIONS] [CRATE_DIR] [-- <TEST_COMMAND>...]\n\nArguments:\n  [CRATE_DIR]        Crate folder made by `bridge` [default: .]\n  [TEST_COMMAND]...  The test command for `--from-tests`, after `--`; it runs in the original's folder\n\nOptions:\n      --count <COUNT>\n          Generated cases per function [default: 200]\n      --inputs <INPUTS>\n          Extra cases: JSONL of `{\"fn\": name, \"args\": [...]}`\n      --module <MODULE>\n          Import the original from this JS module (e.g. built output) instead of the TS source\n      --resolve-from <RESOLVE_FROM>\n          Resolve npm packages from this folder's `node_modules` (when the repo has none installed)\n      --node-arg <NODE_ARGS>\n          Extra arguments for node, e.g. `--node-arg=--import=tsx`\n      --float-tolerance <FLOAT_TOLERANCE>\n          Floats match when they differ by at most this times the larger magnitude (absolute below 1), e.g. 1e-9 for numeric code. Saved with the crate for diff and gate; 0 removes it\n      --from-tests\n          Also record every call the original's own test suite makes to the unit's functions: `--from-tests -- npx jest` (TS/JS, any runner) or `-- pytest` (Python)\n  -h, --help\n          Print help\n"
    },
    {
      "command": "build",
      "help": "3b. Build the crate's JS module (napi-rs `.node` or wasm-bindgen output)\n\nUsage: rust-anything build [CRATE_DIR]\n\nArguments:\n  [CRATE_DIR]  [default: .]\n\nOptions:\n  -h, --help  Print help\n"
    },
    {
      "command": "diff",
      "help": "3c. Replay recorded cases against the Rust module\n\nUsage: rust-anything diff [OPTIONS] [CRATE_DIR]\n\nArguments:\n  [CRATE_DIR]  [default: .]\n\nOptions:\n      --module <MODULE>\n          Test this JS module instead of the crate's `index.cjs`\n      --ignore-key-order\n          Compare objects regardless of key order\n      --float-tolerance <FLOAT_TOLERANCE>\n          Floats match within this tolerance for this run (the one saved by `record` otherwise)\n      --json\n          \n      --node-arg <NODE_ARGS>\n          \n  -h, --help\n          Print help\n"
    },
    {
      "command": "bench",
      "help": "3d. Time the recorded cases on the TS original and on Rust, bridge included\n\nUsage: rust-anything bench [OPTIONS] [CRATE_DIR]\n\nArguments:\n  [CRATE_DIR]  [default: .]\n\nOptions:\n      --min-ms <MIN_MS>              Minimum measured time per function and side, in milliseconds [default: 200]\n      --resolve-from <RESOLVE_FROM>  Resolve npm packages the original imports from this folder's `node_modules`\n      --json                         \n      --node-arg <NODE_ARGS>         \n  -h, --help                         Print help\n"
    },
    {
      "command": "profile",
      "help": "Run a real workload under the language's profiler and say what to port: hot functions, their callers, and loops to batch. `rust-anything profile <repo> -- node bench.mjs` (also `python3 x.py`, `go test -bench . ./pkg`, `java ...`, `ruby x.rb`)\n\nUsage: rust-anything profile [OPTIONS] <ROOT> -- <COMMAND>...\n\nArguments:\n  <ROOT>        Repository root\n  <COMMAND>...  The workload, after `--`\n\nOptions:\n      --json         \n      --lang <LANG>  Source language; detected from the repository when omitted [possible values: ts, python, c, go, ruby, java, php, csharp]\n  -h, --help         Print help\n"
    },
    {
      "command": "shadow",
      "help": "4. Generate a drop-in module that runs TS and Rust side by side\n\nUsage: rust-anything shadow [OPTIONS] [CRATE_DIR]\n\nArguments:\n  [CRATE_DIR]  [default: .]\n\nOptions:\n  -o, --out <OUT>  Where to write the module; defaults to `<crate>/shadow/<name>.shadow.ts`\n  -h, --help       Print help\n"
    },
    {
      "command": "gate",
      "help": "5. Check the definition of done for a port\n\nUsage: rust-anything gate [OPTIONS] [CRATE_DIR]\n\nArguments:\n  [CRATE_DIR]  [default: .]\n\nOptions:\n      --json                  \n      --node-arg <NODE_ARGS>  \n  -h, --help                  Print help\n"
    },
    {
      "command": "app",
      "help": "Record the whole app's behavior and replay any build against it (CLIs)\n\nUsage: rust-anything app <COMMAND>\n\nCommands:\n  record      Run the original CLI on cases (its own examples, `--inputs`, semantic traps), twice each, and store them as trycmd files in `<repo>/rust/app-cases/`. `rust-anything app record . -- python3 cli.py`\n  replay      Run a build against `<repo>/rust/app-cases/`, print passed/total, write a report with a diff per failing case; exits non-zero on any mismatch\n  front-door  Scaffold `<repo>/rust/app`, the Rust binary that owns the CLI's entry point: a clap parser for the recorded commands and flags, every command running the original until a unit is wired. Builds it and replays the cases (100% passed, 100% fallback)\n  wire        Hand commands to a unit's `port.rs` (after it passes gate): adds the crate to `rust/app`, a glue file to write once, the routing and a kill switch (`RUST_ANYTHING_UNIT_<NAME>=original`), then builds and replays\n  lift        Make `rust/app` a pure Rust app, once replay passes with fallback rate 0 and every unit passes gate: removes the fallback and the kill switches, turns the units into plain libraries, runs the lift checklist and replays the pure binary. Checked on a copy first; the original stays in place\n  help        Print this message or the help of the given subcommand(s)\n\nOptions:\n  -h, --help  Print help\n"
    },
    {
      "command": "app record",
      "help": "Run the original CLI on cases (its own examples, `--inputs`, semantic traps), twice each, and store them as trycmd files in `<repo>/rust/app-cases/`. `rust-anything app record . -- python3 cli.py`\n\nUsage: rust-anything app record [OPTIONS] [REPO] [-- <RUN>...]\n\nArguments:\n  [REPO]    Repository root [default: .]\n  [RUN]...  The command that runs the original, after `--`; paths are relative to the repository. Taken from the saved cases when omitted\n\nOptions:\n      --inputs <INPUTS>\n          Extra cases: JSONL of `{\"name\", \"args\": [...], \"stdin\", \"env\": {...}, \"files\": {path: text}}`\n      --normalize <NORMALIZE>\n          Normalizer: `timestamps`, `uuids`, `key-order`, or `name=regex` for your own. Repeatable; saved with the cases\n      --name <NAME>\n          The name the app is invoked by in its docs (found from the command and manifests when omitted)\n      --no-traps\n          Leave out the semantic-trap inputs\n      --timeout <TIMEOUT>\n          Seconds before a run is killed (default 30)\n      --http\n          The app is a server: the command starts it, taking its port from PORT or `{port}`; cases are requests (curl lines in its docs, `--inputs`, traps), kept in `http/`\n      --port <PORT>\n          A port the server always listens on (implies --http)\n      --arg <ARG>\n          An argument every server start gets after its command, the original's and every build's, so the Rust binary is started as the original is (`--arg db.json`). Repeatable; implies --http; saved with the cases\n      --fresh <FRESH>\n          A file or folder of the repository the server reads or writes (a database file, a public folder): snapshotted into `http/files/` and copied into a fresh working directory before every start. Repeatable; implies --http; saved with the cases\n      --pace <MS>\n          Milliseconds to wait after each response before the next request, for work a server does after answering (a file watcher reloading what it just wrote). Implies --http; saved with the cases and used by replay; 0 removes it\n      --float-tolerance <FLOAT_TOLERANCE>\n          Numbers in the output match when they differ by at most this times the larger magnitude (absolute below 1), e.g. 1e-9 for numeric code. Saved with the cases; 0 removes it\n      --json\n          \n  -h, --help\n          Print help\n"
    },
    {
      "command": "app replay",
      "help": "Run a build against `<repo>/rust/app-cases/`, print passed/total, write a report with a diff per failing case; exits non-zero on any mismatch\n\nUsage: rust-anything app replay [OPTIONS] [REPO]\n\nArguments:\n  [REPO]  Repository root [default: .]\n\nOptions:\n      --build <BUILD>      Command line of the build to test (the original, the front door, the final binary); the original when omitted\n      --timeout <TIMEOUT>  Seconds before a run is killed\n      --port <PORT>        Servers: the port the build always listens on; otherwise it gets a free one through PORT and `{port}`\n      --case <CASE>        Replay only this case, by the name the report gives it (a library: only this unit). The fast, repeatable loop for fixing one mismatch\n      --json               \n  -h, --help               Print help\n"
    },
    {
      "command": "app front-door",
      "help": "Scaffold `<repo>/rust/app`, the Rust binary that owns the CLI's entry point: a clap parser for the recorded commands and flags, every command running the original until a unit is wired. Builds it and replays the cases (100% passed, 100% fallback)\n\nUsage: rust-anything app front-door [OPTIONS] [REPO]\n\nArguments:\n  [REPO]  Repository root [default: .]\n\nOptions:\n      --no-check  Only write the files; skip the build and replay\n      --library   Treat the repository as a library even if it has a `main`: the front door is a Rust crate with the public API (found by default when there is no main and no server)\n      --json      \n  -h, --help      Print help\n"
    },
    {
      "command": "app wire",
      "help": "Hand commands to a unit's `port.rs` (after it passes gate): adds the crate to `rust/app`, a glue file to write once, the routing and a kill switch (`RUST_ANYTHING_UNIT_<NAME>=original`), then builds and replays\n\nUsage: rust-anything app wire [OPTIONS] <REPO> <UNIT>\n\nArguments:\n  <REPO>  Repository root\n  <UNIT>  Unit crate: its folder, its name under `rust/`, or the unit id it was bridged from\n\nOptions:\n      --command <COMMANDS>  A command the unit answers. Repeatable; kept from the last wire when omitted\n      --route <ROUTES>      Servers: a route the unit answers, axum syntax (`GET /users/{id}`, `/path` for any method, `*` for everything else). Repeatable; kept from the last wire when omitted\n      --skip-gate           Do not run gate on the unit first (it just passed)\n      --no-check            Only write the files; skip the build and replay\n      --json                \n  -h, --help                Print help\n"
    },
    {
      "command": "app lift",
      "help": "Make `rust/app` a pure Rust app, once replay passes with fallback rate 0 and every unit passes gate: removes the fallback and the kill switches, turns the units into plain libraries, runs the lift checklist and replays the pure binary. Checked on a copy first; the original stays in place\n\nUsage: rust-anything app lift [OPTIONS] [REPO]\n\nArguments:\n  [REPO]  Repository root [default: .]\n\nOptions:\n      --json  \n  -h, --help  Print help\n"
    },
    {
      "command": "mcp",
      "help": "Serve every step as MCP tools over stdio\n\nUsage: rust-anything mcp\n\nOptions:\n  -h, --help  Print help\n"
    },
    {
      "command": "setup",
      "help": "Register rust-anything with your coding agents (Claude Code, Codex, Cursor, Gemini CLI): the MCP server and, where the agent reads skills, the workflow skill. Keeps your other settings; run it again any time\n\nUsage: rust-anything setup [OPTIONS]\n\nOptions:\n      --agent <AGENTS>\n          Agents to set up (repeatable); every agent found by default\n\n          Possible values:\n          - claude: Claude Code: `~/.claude.json`, skill in `~/.claude/skills`\n          - codex:  OpenAI Codex CLI: `~/.codex/config.toml`, skill in `~/.codex/skills`\n          - cursor: Cursor: `~/.cursor/mcp.json`\n          - gemini: Gemini CLI: `~/.gemini/settings.json`\n\n      --remove\n          Take the rust-anything entries out again\n\n      --dry-run\n          Show what would change, write nothing\n\n      --json\n          \n\n  -h, --help\n          Print help (see a summary with '-h')\n"
    },
    {
      "command": "doctor",
      "help": "Check the language runtimes, the agent setup and the MCP server, with the command that fixes each problem. Exits 1 when something required is missing\n\nUsage: rust-anything doctor [OPTIONS]\n\nOptions:\n      --json  \n  -h, --help  Print help\n"
    }
  ]
}