Skip to content

build(deps): upgrade Effect to 4.1.7 - #662

Closed
wyattjoh wants to merge 52 commits into
wyattjoh/effect-rewrite-clifrom
wyattjoh/effect-upgrade-4-1-7
Closed

wyattjoh wants to merge 52 commits into
wyattjoh/effect-rewrite-clifrom
wyattjoh/effect-upgrade-4-1-7

Conversation

@wyattjoh

@wyattjoh wyattjoh commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Bumps effect, @effect/platform-bun and @effect/vitest from 4.0.3 to 4.1.7, and removes the two effect/cli workarounds that 4.1.7 makes unnecessary. This unblocks @distilled.cloud/clerk rc.21, which peers ~4.1.7.

 parseAndRun(argv)
   prepareArgv
-    --json        → --json=true          # keep a switch off the next word
-    --no-browser  → --browser=false
+    --json, --no-browser pass through     # Flag.withOptionalValue("true") does it
+    -v --version=<v> --no-version → one   # 4.1 rejects a repeated flag
+    --help=<v> --no-help    → one
+    --=x          → usage error           # 4.1 reads it as a positional
+    --=x + help or version → dropped      # the built-in wins
   Command.runWith
-    Console → silent stub                 # hide effect/cli's own help
-    builtIns: custom help/version actions
+    CliOutput.Presenter → records Help/Version, prints nothing
+    builtIns: GlobalFlag.Help, GlobalFlag.Version

Compile fixes for 4.1's API changes:

  • Terminal now requires a size stream. The TTY terminal follows stdout resizes, and the parser and test terminals share a fixed 80x24 one.
  • HttpClientRequest.method widened to string, so webhook forwarding casts its method to HttpMethod.
  • In the fake platform, File.Info.dev is now a bigint, and the fake spawner reveals Redacted spawn args and env values.

These workarounds stay because 4.1.7 still lacks the feature: multiple aliases, default subcommands, pass-through, last-wins repeats, a parent and child sharing a flag, variadic flags, --prefixed values, and runtime completion.

Evidence

  • Before: with the bump alone, clerk -v -v (and --version --version) exited 2 with Invalid value for flag --version: "2 occurrences". On 4.0.3 it printed the version.
    After: prints the version again. Pinned by command-parser.test.ts (a repeated version flag ["-v","-v"] still prints the version).
  • Before: --version=true --version=true, -v --no-version, --no-help --no-help and other mixes of spellings exited 2 the same way.
    After: every spelling of a built-in counts as the same flag and the first value is read, as on 4.0.3. Pinned by a repeated built-in … still ends in ….
  • Before: clerk api ls --=users searched for --=users and exited 0.
    After: exits 2 with Unrecognized flag: --, as on 4.0.3, and still gives way to help or the version (clerk --=x --help=true prints help).
  • Before: --json true stayed a switch plus an argument only because prepareArgv rewrote it to --json=true.
    After: parseAndRun(["users","--verbose","true"]) gives verbose: true, user: "true" with no rewrite. The test fails if withOptionalValue is dropped.
  • The surface fixture, argv corpus and breaking-changes.json tests pass with no new declared differences. A side-by-side run from source on 4.0.3 and 4.1.7, covering built-in spellings, their repeats and --=x, gives the same exit codes and stdout. Some usage errors differ in stderr only: the --= error has no "Did you mean this?" hint, a repeated --=x is reported once, the Unrecognized flag: -- line is left out when a built-in is already being rejected, and some rejected --help/--version values name the subcommand in the closing Run … --help line where 4.0.3 named clerk.
  • --version and --help startup time on the compiled binary is unchanged, within noise.

Merge Danger

Door: two-way

Revert the branch to go back to 4.0.3; no data or config format changes.

Blast Radius: parsing

Every command line goes through the changed prepareArgv and parser setup, so a missed edge case would show up as a usage error (exit 2) where a command used to run. Separately, Effect 4.1 no longer lets catch/catchTag recover a failure when a finalizer also dies: fail(E).pipe(Effect.ensuring(die), Effect.catchTag("E", …)) recovered on 4.0.3 and does not on 4.1.7, and the same goes for acquireRelease and addFinalizer. A failure next to a defect from concurrent Effect.all or forEach still recovers. A command whose cleanup dies would now report an unexpected error instead of the tagged one. No test exercises this, and the catch sites around resources have not been audited.

Stacked on #661.

Records every command's flags, positionals, aliases and defaults, the shell completion answers, and the exit code of malformed invocations from the Commander tree, and diffs the live surface against it. Differences must be declared in breaking-changes.json.
…/cli

Adds command specs (startup/command-spec.ts) that registration, help and completion can read without loading Effect, the help renderer over them, argv preparation (aliases, default subcommands, pass-through, attached values, last-wins), and lib/command-parser.ts, which builds effect/cli commands from the specs and parses a command line. Ports apps, whoami, link and unlink to specs alongside their Commander registrants; a per-group test diffs each spec against the recorded surface.
…rface

logs list --group-type and --status already accepted repeats through collectChoice; the recorder only recognised collectOptionValues.
…ment names for specs

Record whether an option is variadic in the surface, and count webhooks listen --header as repeatable.
createProgram() now returns the root command spec. runProgram prepares argv,
parses it with effect/cli (loaded lazily, so startup stays Effect-free), renders
help itself, and maps parse errors to usage errors. Shell completion, telemetry,
feedback --command and the integration harness walk the spec tree. The commander
registrants, the setExamples augmentation and both commander dependencies are gone.

BREAKING CHANGE: a parse error (unknown flag or subcommand, missing value, bad
choice) exits 2 with the usage_error envelope in agent mode instead of exit 1
with plain text; --keys, --for and --android-fingerprint take one value per
occurrence (repeat the flag or use commas); groups no longer have an implicit
help subcommand (use clerk help <group> or --help).
Confirm, select, multiselect, text and password run on effect/cli's Prompt
behind the Prompts service; search is a Prompt.Custom with an async source.
A Terminal over stdin, or /dev/tty when stdin is piped, reads the keys.
Spinners, intro/outro and gutter lines are drawn by an Effect-free frame
renderer with the same line shapes. Agent mode and non-TTY runs still never
render a prompt and fail the same way.

BREAKING CHANGE: prompts look and respond differently (effect/cli style,
y/n confirm, inline validation), and Ctrl-C while a spinner runs now exits
130 instead of 0.
@changeset-bot

changeset-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7c8ccda

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
clerk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@wyattjoh
wyattjoh added this pull request to stack #663 December 1, 2026 08:38
`bun --bun vitest` puts a `node` that runs Bun first on PATH, so `npx node …` tried to install the `node` package and the fixture dev servers ran on Bun. The e2e setup drops it from PATH; the worker itself still runs on Bun.
A vitest fork worker's stdin is a pipe that never closes, and `clerk api` without `-d` reads a non-terminal stdin to its end for a body, so every test user delete hung until the hook timed out. A shared `clerk` template in test/e2e/lib/cli.ts runs the CLI with stdin from /dev/null and replaces the per-file CLI_PATH constants.
Vitest sets VITEST, VITEST_*, TEST, MODE, DEV, PROD, SSR and BASE_URL in its workers, and the fixture dev servers inherited them. Astro skips installing its dev request handler when VITEST is set, so the Astro page never loaded Clerk. npm ci, the fixture builds, typechecks and dev servers now run with toolEnv(), which drops them.
Fixture files run in parallel, so their clerk link and clerk init calls reach the Platform API in a burst it can answer with 429. Setup runs in beforeAll, which vitest's retry does not rerun, so setupFixture runs once more in fresh temp dirs after a 429.
@wyattjoh

wyattjoh commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Folded into #661, which now moves the CLI from Commander to native effect/cli in one PR, including the effect 4.1.7 upgrade. Closing this layer.

@wyattjoh wyattjoh closed this Dec 1, 2026
@wyattjoh
wyattjoh removed this pull request from stack #663 December 1, 2026 11:04
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