Skip to content

refactor(cli): port runtime to Node-compatible APIs - #29

Merged
gustavohariel merged 1 commit into
mainfrom
refactor/port-to-node
Jun 6, 2026
Merged

gustavohariel merged 1 commit into
mainfrom
refactor/port-to-node

Conversation

@gustavohariel

Copy link
Copy Markdown
Owner

What & why

funfa's only Bun-specific code was a handful of spots in its own source — pi itself uses zero Bun globals. This swaps those for Node-compatible APIs so funfa runs on Node as well as Bun, unblocking a much smaller distribution later (a bun build --target node bundle is ~6.9 MB / 1.8 MB gzip, vs the 74 MB compiled binary — most of which is the embedded Bun runtime).

No distribution change in this PR — it still builds via bun build --compile. This is purely the API port; how we ship (single node bundle vs npm package vs keep the compiled binary) is a separate decision.

Changes

  • Bun.spawn → node:child_process execFile (argv-only — same no-shell contract — preserving the ENOENT→127 "command absent" signal and the child's real exit code). apply-command.ts
  • Bun.argv → process.argv. index.ts
  • @effect/platform-bun BunContext/BunRuntime → @effect/platform-node NodeContext/NodeRuntime; BunPath → NodePath in the CLI test.
  • StderrBun → StderrNode (it only used process.stderr.write — runtime-neutral, just misnamed).
  • Dropped the now-unused @effect/platform-bun dep; added @effect/platform-node@0.106.0 (matches @effect/platform 0.96 / effect 3.21 / @effect/platform-node-shared 0.59 already resolved).

Skills still inline at build time via the .md text loader, so nothing reads them from disk at runtime.

Verification

  • tsc --noEmit + Ultracite clean.
  • Full suite 105 pass / 1 skip / 0 fail, including the real makeNodeApplyRunner tests (echo round-trip + missing-binary → exit 127) and the existing bun --compile smoke test (the ported code still runs under Bun).
  • Built a --target node bundle and ran it under node v25: --help renders (exit 0, clean stderr) and auth bogus hits the real provider registry.

Follow-up (not in this PR)

Pick a small-distribution model — single self-contained funfa.mjs (requires node) vs npm package vs keep the 74 MB zero-dep binary — then wire the launcher/install/CI/smoke-test accordingly.

Replace the Bun-only APIs so funfa runs on Node as well as Bun: Bun.spawn -> node:child_process execFile (argv-only, preserves the ENOENT->127 contract), Bun.argv -> process.argv, @effect/platform-bun BunContext/BunRuntime -> @effect/platform-node NodeContext/NodeRuntime, BunPath -> NodePath in the CLI test, and StderrBun -> StderrNode (it was already runtime-neutral).

Drop the now-unused @effect/platform-bun dependency; add @effect/platform-node@0.106.0 (matches @effect/platform 0.96 / effect 3.21 / platform-node-shared 0.59 already in the tree). pi itself uses no Bun globals, and skills inline at build time via the .md text loader.

No distribution change: still builds via 'bun build --compile'. This unblocks shipping a small node bundle later. Verified: tsc + Ultracite clean, full suite 105 pass / 1 skip / 0 fail (incl. real makeNodeApplyRunner echo + ENOENT->127 tests), and a node-target bundle runs under node v25 (--help + auth).

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@gustavohariel
gustavohariel merged commit 6896022 into main Jun 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant