refactor(cli): convert run command to effectCmd#25519
Merged
Merged
Conversation
Stage 3 of the run.ts conversion: wrap-in-Effect.promise approach.
- cmd() → effectCmd({ instance: (args) => !args.attach, directory: ... })
- --attach path: no instance load (matches legacy — legacy didn't load
either; SDK talks to the remote server)
- default path: instance loaded by effectCmd via InstanceStore.provide,
auto-disposed on exit (matches legacy bootstrap() finally)
- Drop the bootstrap(process.cwd(), async () => {...}) wrapper since
effectCmd handles it
- Drop AppRuntime import (the inner AppRuntime.runPromise(Agent.Service.use)
for agent validation still imports it via the Effect... wait no, that
call is on the !args.attach path where instance is loaded)
- The whole legacy handler body is wrapped in Effect.promise() inside
Effect.fn for byte-equivalent behavior. Process.exit(1) paths and
internal AppRuntime.runPromise calls all preserved as-is.
Also extends effectCmd to accept WithDoubleDash<Args> on the handler so
args["--"] works without casts (matches the legacy cmd() wrapper shape).
- Export WithDoubleDash from cmd.ts and import in effect-cmd.ts (was redefined). Single source of truth. - Drop the "Default path: effectCmd already loaded the instance..." comment in run.ts — effectCmd's docstring already explains this.
5891431 to
809cc4e
Compare
4 tasks
oleksii-honchar
pushed a commit
to oleksii-honchar/better-opencode
that referenced
this pull request
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 3 of the run.ts conversion (Stage 1 is #25517 — function-form `instance`).
Also extends `effectCmd` to type `handler` args as `WithDoubleDash` so `args["--"]` (yargs's "everything after `--` separator") works without casts. Matches the legacy `cmd()` wrapper's shape.
Why this conversion is safe
The `Effect.promise(async () => { ... })` wrap means the handler body executes as a Promise inside the Effect runtime — same async semantics as legacy `async (args) => { ... }`. No behavior change to:
Stacked on #25517
Depends on the function-form `instance` opt-out landing first.
Test plan