github erkamyaman/rust-anything v2.0.0

one hour ago

Highlights:

  • Prettier, ported to Rust. Prettier 3.6.2 behind a Rust front door: 15,837 of 17,224
    recorded runs format fully in Rust across JavaScript, TypeScript, JSX, JSON, GraphQL, YAML,
    Markdown, CSS, SCSS and Less, and all 17,224 match Prettier byte for byte. 19x faster on JS/TS
    from the command line (Apple M4). See docs/real-world.md#prettier.
  • json-server, ported to a pure Rust binary: 514/514 HTTP cases, 3.5 MB of memory at idle
    instead of 74 MB.
  • Side effects are compared: outgoing HTTP calls, email and the database's state, per case.
  • map: the whole port at a glance, and every piece whose original changed upstream.
  • Plain JavaScript gets types from JSDoc and .d.ts; OpenCode joins the agents setup
    registers.

Changed: diff exits non-zero when the recording is stale (it printed a warning and exited 0).

  • app record --effects http,smtp, --effect-env VAR=KIND, --db-reset and --db-dump: record
    what leaves the process per case (outgoing HTTP calls, email, the database's state) and compare
    it on replay, for CLIs and servers. A rewrite that sends an email twice or writes different rows
    now fails the case even when its output matches.

  • map (CLI and MCP tool): every unit of the original with the crate that ports it, functions
    in Rust and kept in the original, cases and last diff, the whole app's glue, units not ported
    yet, and every port whose original changed since it was recorded. --write saves
    rust/PORT_MAP.md; --check exits 1 while a recording is stale.

  • Docs: what a real port takes, keeping the original's shape, keeping up with the original, and
    checking a rewrite in any language with app record and app replay --build.

  • bench and record pass --experimental-transform-types only when Node accepts it: Node 26
    removed the option and refused to start (#99).

  • profile keeps a Python workload script given as a relative path (python3 bench.py); its
    functions were dropped and the table came out empty (#101).

  • diff exits non-zero when the recording is stale, as gate already refuses it, and the
    warning says "Stale recording" (#102).

  • analyze says what a wasm-bindgen bridge needs installed, and that --kind napi runs with
    what Node already has (#102).

  • bridge reads types for plain JavaScript: from a sibling .d.ts/.d.mts/.d.cts, then
    JSDoc @param {T} name (with [name], defaults and opts.field shapes) and @returns {T}.
    Before, only parameters with a literal default were typed and the rest became unknown, so
    record generated mostly wrong-typed inputs (#100).

  • TypeScript analysis and recording resolve path aliases against the inherited baseUrl,
    including when the two options come from separate tsconfig files.

  • setup also registers OpenCode: the MCP server in ~/.config/opencode/opencode.json
    (mcp.servers, the whole argv in command) and the workflow skill in
    ~/.config/opencode/skills/, and doctor reads that entry back.

  • A port of Prettier 3.6.2 behind a Rust front door in
    demo/real-world/prettier-rs and docs/real-world.md: 17,224/17,224 recorded CLI cases match,
    15,837 of them (91.9%) formatted fully in Rust and byte-identical to Prettier, the rest handed to
    Prettier per file (8.1% fallback). JavaScript, TypeScript (849 of 929 cases), JSX, JSON in
    all four flavours (995 of the 1,019 JSON cases Prettier formats), GraphQL (all 787 cases
    Prettier formats, with graphql-js's parser ported) YAML (3,309 of 3,310, with yaml's CST
    parser and yaml-unist-parser ported), Markdown (6,305 of 6,350, with remark-parse ported and
    code blocks formatted by the other ports) and CSS, SCSS and Less (all 2,004 cases Prettier
    formats, with postcss, postcss-scss, postcss-less and the value, selector and media query
    parsers ported) run in Rust, as do all 59 real repository
    files. Ported: the doc printer (gate 2,848/2,848), the printer on oxc's ESTree with
    comments, classes, decorators, template literals, ternaries and prettier-ignore (gate
    15,753/15,753 on format()), and the CLI's config resolution (.prettierrc JSON,
    package.json, overrides, .editorconfig, ignore files). On an M4 against Node 24: 19x faster
    per file from the command line, 7x on the median JavaScript/TypeScript file in process (18x on
    the median GraphQL file, 13x on the median YAML file, 25x on the median Markdown file, 9.5x on
    the median CSS/SCSS/Less file); per file from the command line 8.5x for style files and 15.6x
    for Markdown. No file was slower in a first run; one per language was in a second run (a one-off
    stall, 135 µs against 8.5 µs in the first).

  • Glue can decline one case after reading stdin: original::run_with_stdin(args, input) hands the
    case and its bytes to the original; lift refuses while any glue still calls original::.

  • bridge reads export { a, b as c } lists.

  • Fix: with CARGO_TARGET_DIR set, every front door built into the same directory and replays
    ran another app's binary; the front door builds into its own rust/app/target.

  • Fix: case and input lines nested deeper than 128 levels failed to parse; the harness and
    generated from_json read them without a depth limit.

  • Fix: --inputs case names were cut to 24 characters and collided; given names keep 96.

  • A port of json-server to a pure Rust binary in
    demo/real-world/json-server-rs and docs/real-world.md: 514/514 recorded HTTP cases match
    with no fallback, and six units pass gate. Against Node 24 on an M4: first response in 8 to
    10 ms instead of about 80, 3.5 MB of memory idle instead of 74, 2 to 4x the requests per second
    on one connection and 5 to 13x on 50; 1.1 to 1.2x on writes and on the whole list of a 10,000-post
    database.

  • app record --http --fresh <path> copies a file or folder the server writes (its database)
    into a fresh working directory for every start, from a snapshot kept with the cases;
    --arg <arg> passes the original's arguments to every build too; --pace <ms> waits after each
    response for work a server does after answering. json-server needed all three: it rewrites its
    database on every write, and its file watcher can undo a write that follows quickly.

  • bridge --as-json T bridges a generic the app only fills with data (paginate<T>(items: T[]))
    as JSON values instead of keeping it in TS.

  • Fix: the HTTP front door's routes with parameters answered axum's own 400 when an escape was not
    UTF-8 (/posts/%E0); parameters are now read from the URI and the unit gets the request.

  • Fix: app lift left out the crates the wired units depend on by path (shared code, other
    units), so the staged build failed; they are staged, stripped of their bindings and synced back
    with the units.

  • Fix: a lifted unit that keeps generated modules (js.rs) got a lib.rs that failed
    cargo fmt --check: modules are now listed in the order rustfmt keeps.

  • A port of Fuse.js string-list search in
    demo/real-world/fuse-rs and docs/real-world.md: 3,414/3,414 recorded cases match, results
    byte-identical to Fuse, 32x faster on 50,000 strings (5.3x on one core).

  • gate's size check counts the files a TS unit imports from the repository, not only the unit.

  • Batch crates with string items but other results no longer get an unused helper (clippy failed).

  • TypeScript analysis and recording keep inherited path aliases when a later tsconfig base
    omits compilerOptions.paths.

  • Faster single calls on napi: every sync function crosses the binary wire with no napi
    arguments (each argument cost about 55 ns), behind one JS wrapper instead of two;
    serde_json::Value parameters cross as tagged values of any shape, and errors come back in the
    wire buffer. vercel/ms per call: 0.39x to 0.56x of JS over its recorded cases, and parse on a
    normal string at JS speed (79 ns).

  • record --from-tests -- <test command> runs the original's own test suite and records every call
    it makes to the unit's functions: TS/JS with any runner (Jest, Vitest, node --test), Python
    with pytest or unittest. On vercel/ms it captured 340 calls from 167 Jest tests, more than
    twice the 149 inputs copied by hand.

  • record saves a fingerprint of the original unit (recorded-from.json); diff warns and gate
    fails when the original changed since.

  • known-diffs.jsonl lists cases where the port is meant to differ, each with the result it gives
    and a reason. diff and gate count them as passing only with exactly that result, and gate
    fails on an entry that no longer differs.

  • app replay's report no longer carries temporary paths, so CI can commit it and fail on
    git diff --exit-code.

  • A port of vercel/ms, end to end, in demo/real-world/vercel-ms-rs
    and docs/real-world.md: 975/975 recorded cases match; slower per call, 19x faster as a batch
    for parse (3.6x with the handover), 1.3x for format(x, { long: true }).

  • Fix: a napi batch method with a structured parameter did not compile; crates with batch classes
    now enable napi's serde-json feature.

  • napi batches pass strings joined: items cross as one string plus UTF-16 end offsets and string
    results come back the same way, about 2x faster each way. The JS API is unchanged.

  • napi batches of numbers take their items as one Float64Array: new Batch(numbers) costs
    0.1 ms instead of 3.3 ms for 100,000 values.

  • The generated js.rs gains number_to_string (JS String(n), digits from serde_json's fast
    printer) and math_round (JS Math.round), tested against Node.

  • analyze flags Math.round, toFixed, and /i regexes without u where Rust's case folding
    matches more (ſ, the Kelvin sign).

Don't miss a new rust-anything release

NewReleases is sending notifications on new releases.