Repository navigation
fix(sea): accept commands regardless of the executable's filename - #98
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fix is small, correct per Node SEA argv behavior, fully plumbed through all CliRuntimeService implementations, and covered by a new test plus the documented SEA build/smoke verification.
Review effort: Balanced
Findings: None
What changed in this PR
This PR fixes a bug in the SEA (Single Executable Application) build where the binary rejected every command when invoked under its platform-suffixed filename (e.g. putio-darwin-arm64 version failed with Unknown subcommand). The root cause was that argv stripping relied on matching a hardcoded putio/putio.exe/bin.mjs basename, which did not match the build output name. The fix detects single-executable mode via node:sea's isSea(), exposes it on CliRuntimeService as isSingleExecutable, and uses it to skip Node SEA's two leading argv entries ([execPath, name, ...args]) regardless of filename. This fits cleanly into the existing Effect service/runtime layering, keeping the npm bin.mjs path unchanged.
Changes:
- Add
isSingleExecutabletoCliRuntimeService, defaulting toisSea()inmakeCliRuntime. - In
commandArgsFromArgv, strip the first two argv entries when running as a single executable instead of relying on basename matching. - Thread the flag through test helpers and add a SEA-argv test; update the hand-written runtime mock.
| File | Description |
|---|---|
src/internal/runtime.ts |
Imports isSea, adds isSingleExecutable to the service type and makeCliRuntime (default isSea()). |
src/cli.ts |
commandArgsFromArgv now takes isSingleExecutable and strips argv[0]/argv[1] for SEA; passes runtime.isSingleExecutable. |
src/cli.test.ts |
Adds isSingleExecutable to the test-run options and a new SEA argv parsing test. |
src/internal/auth-flow.test.ts |
Adds isSingleExecutable: false to the hand-written CliRuntimeService mock to satisfy the updated type. |
I verified that auth-flow.test.ts is the only hand-written implementation of CliRuntimeService (all other call sites use makeCliRuntime, which now supplies a default), that the SEA argv behavior ([execPath, name, ...args]) matches the slice(2) approach, that the npm/node/bin.mjs paths are unaffected, and that the SEA entry point (sea.ts) uses CliRuntimeLive, which resolves isSingleExecutable from isSea() at runtime. The engines field (node >= 24.19.0) guarantees node:sea is available.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
🎉 This PR is included in version 1.8.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
The SEA binary now runs commands under any filename. Before,
.artifacts/sea/putio-darwin-arm64 versionfailed withUnknown subcommand ".../putio-darwin-arm64"because argv stripping only recognizedputio,putio.exe, orbin.mjs.argv[0]and the invoked name inargv[1], so the CLI now skips both whennode:seareportsisSea(), instead of matching on the basename.CliRuntimeexposes this asisSingleExecutable; the npmbin.mjspath is unchanged.Closes #97
Verification
pnpm exec vp run verify: pass, 369 testscli.test.tscase for SEA argv with a platform-suffixed name; fails with thesrc/cli.tschange revertedpnpm exec vp run build:seaandverify:sea(darwin-arm64): passputio-darwin-arm64 version,putio version, a symlink to the binary,./dist/bin.mjs version, andnode dist/bin.mjs --version: all exit 0Notes
Only darwin-arm64 was smoked locally; other platforms rely on the release SEA matrix.
Written by an agent (Claude Code, Opus 5.5)