Skip to content

Bundle cua-cli with tsdown; smoke-test the bin in CI#30

Merged
rgarcia merged 2 commits into
mainfrom
hypeship/fix-cli-esm-imports
Jun 12, 2026
Merged

Bundle cua-cli with tsdown; smoke-test the bin in CI#30
rgarcia merged 2 commits into
mainfrom
hypeship/fix-cli-esm-imports

Conversation

@rgarcia

@rgarcia rgarcia commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

The packed-tarball smoke test (runbook step 4) fails with ERR_MODULE_NOT_FOUND: ...dist/cli-harness. packages/cli used extensionless relative imports and shipped raw tsc output — legal under the repo's moduleResolution: "Bundler" and resolvable by vitest, but Node ESM requires fully-specified relative specifiers, so the published bin could never run. Nothing caught it because the only bin smoke test lives in the release workflow, which only runs on cua-cli/v* tags.

Fix: bundle the cli with tsdown, the same build the other published packages (cua-ai, cua-agent) already use. Bundling rewrites specifiers, so source imports stay extensionless.

  • packages/cli builds with tsdown (dist/cli.js + split chunk for the dynamically imported TUI; deps externalized; shebang preserved). tsc -b becomes declaration-only emit to dist-tsc/ for typechecking, mirroring packages/agent.
  • Root build bundles the cli after tsc -b, so npm ci && npm run build produces a runnable bin.
  • Dropped the types field — it's a binary, and tsdown no longer emits cli.d.ts.
  • Mirror the release workflow's packed-tarball cua --help smoke test into the cli-unit CI job so the real binary executes on every PR.

Test plan

  • Reproduced the failure from the packed tarball before the fix
  • After fix: npm pack → install into a temp project → ./node_modules/.bin/cua --help prints usage, exit 0; tarball ships dist/cli.js + chunks
  • Fresh root npm run build passes (incl. ptywright native via zig)
  • npx tsc -b clean
  • PTYWRIGHT_REQUIRED=1 npm test --workspace @onkernel/cua-cli — 33/33
  • CI green, including the new bin smoke step

🤖 Generated with Claude Code


Note

Medium Risk
Changes the published CLI artifact and build pipeline; low runtime risk for library consumers but high impact if the bundled bin or pack layout is wrong—mitigated by the new CI smoke test.

Overview
Fixes published @onkernel/cua-cli failing at runtime under Node ESM by bundling the CLI with tsdown instead of shipping raw tsc output with extensionless relative imports.

packages/cli now builds dist/cli.js via tsdown (aligned with cua-ai / cua-agent), uses declaration-only tsc into dist-tsc/ for typechecking, drops the types field, and adds tsdown as a dev dependency. The root build script runs the cli workspace build after tsc -b.

CI (cli-unit) adds steps to build the cli, npm pack, install the tarball in a temp project, and smoke-test cua --help so the real binary is exercised on every PR—not only on release tags.

Reviewed by Cursor Bugbot for commit 1e0664b. Bugbot is set up for automated code reviews on this repo. Configure here.

rgarcia added 2 commits June 12, 2026 19:15
packages/cli used extensionless relative imports, which compile cleanly
under moduleResolution Bundler and work in vitest, but fail at runtime
with ERR_MODULE_NOT_FOUND when Node executes the published dist. Add .js
extensions to all relative imports and switch the package to
module/moduleResolution NodeNext so tsc enforces them from now on.

Run the packed-tarball bin smoke test in the cli-unit CI job (mirrors
release-cua-cli.yml) so the real binary is executed on every PR instead
of only at release time.
Revert the .js-extension sweep and NodeNext switch; bundle the cli with
tsdown (matching cua-ai and cua-agent) so extensionless relative imports
keep working and the published dist runs under Node ESM. tsc -b now does
declaration-only emit to dist-tsc for typechecking, tsdown owns dist/,
and the root build bundles the cli after typechecking.
@rgarcia rgarcia changed the title Fix ESM imports in cua-cli dist; smoke-test the bin in CI Bundle cua-cli with tsdown; smoke-test the bin in CI Jun 12, 2026
@rgarcia rgarcia marked this pull request as ready for review June 12, 2026 19:33
@rgarcia rgarcia merged commit 0da96b2 into main Jun 12, 2026
5 checks passed
@rgarcia rgarcia deleted the hypeship/fix-cli-esm-imports branch June 12, 2026 19:33
@firetiger-agent

Copy link
Copy Markdown

Created a monitoring plan for this PR.

What this PR does: Fixes the cua CLI binary so it actually runs after npm install — the previous build emitted raw TypeScript output that Node ESM couldn't execute. Adds a bin smoke test to CI so this class of breakage is caught on every PR going forward, not just at release time.

Intended effect:

  • cli-unit CI smoke test: baseline — step did not exist; confirmed if the new "CLI bin smoke test" step passes (packs tarball, installs, runs cua --help, exits 0).
  • Root build command: baseline — npm run build silently skipped CLI bundling; confirmed if packages/cli/dist/cli.js is produced and executable after a fresh root build.

No production telemetry signal exists for this change — @onkernel/cua-cli is a locally-installed CLI with no server-side component.

Risks:

  • Dynamic TUI import missing from bundle — tsdown emits a split chunk for the dynamically imported TUI; if the chunk is missing or misnamed, cua crashes on first interactive use. Signal: runtime error on TUI invocation; alert if any ERR_MODULE_NOT_FOUND after npm install of the published package.
  • CI timeout regressioncli-unit has a 15-min limit; new build/pack/smoke steps add overhead alongside the existing Zig native build. Alert if the job times out (conclusion = timed_out in CI events).
  • Release workflow failure on next tag — the Release CUA CLI workflow mirrors the new smoke test; a CI pass is strong evidence the release will succeed, but alert if the Release CUA CLI workflow's conclusion is failure on the next cua-cli/v* tag.

Status updates will be posted automatically on this PR as monitoring progresses.

View monitor

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