Skip to content

effect(installation): migrate to AppProcess.run#27188

Merged
kitlangton merged 1 commit into
devfrom
effect/phase2-installation-appprocess
May 13, 2026
Merged

effect(installation): migrate to AppProcess.run#27188
kitlangton merged 1 commit into
devfrom
effect/phase2-installation-appprocess

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Phase 2.1 of the AppProcess migration, stacked on #27178.

Summary

Replaces the spawn-and-collect dance in src/installation/index.ts with AppProcess.run. The service now yields AppProcess.Service instead of ChildProcessSpawner.ChildProcessSpawner, and defaultLayer provides AppProcess.defaultLayer (which provides CrossSpawnSpawner underneath).

Call sites migrated

packages/opencode/src/installation/index.ts:

  • text(cmd, opts) (was lines 96-110): spawn -> collect stdout via Stream.mkString -> await exit code -> catch -> "". Now: single appProcess.run(ChildProcess.make(...), { interpretExitCode: acceptAnyExit }) then .stdout.toString("utf8").
  • run(cmd, opts) (was lines 112-129): spawn -> collect stdout+stderr concurrently -> exit code -> catch -> default failure. Now: single appProcess.run with acceptAnyExit so caller can inspect .exitCode itself (preserves prior behavior where non-zero exits were not failures).
  • upgradeCurl(target) (was lines 139-159): spawn bash with piped stdin, collect, exit. Now: appProcess.run(ChildProcess.make("bash", [], { stdin: Stream.make(bodyBytes), ... }), { interpretExitCode: acceptAnyExit }).

Layer dependency change:

  • Old: Layer.Layer<Service, never, HttpClient.HttpClient | ChildProcessSpawner.ChildProcessSpawner>
  • New: Layer.Layer<Service, never, HttpClient.HttpClient | AppProcess.Service>
  • defaultLayer: dropped direct CrossSpawnSpawner.defaultLayer (now provided via AppProcess.defaultLayer).

Behavior preservation

All three helpers needed interpretExitCode: () => "success" (aliased acceptAnyExit). The pre-existing helpers ignored the exit code on purpose:

  • text is used in method() to probe package managers that may not be installed (e.g., npm list -g on a system without npm). Non-zero exit must not throw.
  • run returns { code, stdout, stderr }, and callers explicitly check code !== 0 (e.g., tap.code !== 0, pull.code !== 0). Letting AppProcess fail on non-zero would lose stdout/stderr from the caller's check.
  • upgradeCurl shares the run-style return shape; the existing Effect.orDie only covers spawn failures, not non-zero exits.

So I used acceptAnyExit rather than custom catch translation. The Effect.catch(() => "") / Effect.catch(() => { code: 1, ... }) wrappers are kept to handle spawn-time failures (AppProcessError), matching prior semantics.

Test updates: test/installation/installation.test.ts composes AppProcess.layer over the existing mockSpawner (which provides ChildProcessSpawner) so the mock spawner still drives the test. All 9 existing tests pass.

LOC delta

packages/opencode/src/installation/index.ts: -1 line (211 insertions, 212 deletions).

Verification

  • bun run typecheck (clean)
  • bun run test test/installation/installation.test.ts -> 9 pass

Test plan

  • Typecheck passes
  • Existing installation tests pass

@kitlangton kitlangton force-pushed the effect/app-process-service branch from ebc8050 to bf596d5 Compare May 13, 2026 01:15
@kitlangton kitlangton force-pushed the effect/phase2-installation-appprocess branch from ce58e16 to 274f96a Compare May 13, 2026 01:16
Base automatically changed from effect/app-process-service to dev May 13, 2026 01:24
@kitlangton kitlangton changed the base branch from dev to effect/phase2-worktree-appprocess May 13, 2026 15:16
@kitlangton kitlangton force-pushed the effect/phase2-installation-appprocess branch from 274f96a to fa1c876 Compare May 13, 2026 15:16
@kitlangton kitlangton marked this pull request as ready for review May 13, 2026 15:17
@kitlangton kitlangton force-pushed the effect/phase2-worktree-appprocess branch from 3ccea03 to acf80a3 Compare May 13, 2026 15:27
Base automatically changed from effect/phase2-worktree-appprocess to dev May 13, 2026 15:39
@kitlangton kitlangton force-pushed the effect/phase2-installation-appprocess branch from fa1c876 to fc91523 Compare May 13, 2026 15:40
@kitlangton kitlangton merged commit 5cdbb75 into dev May 13, 2026
10 checks passed
@kitlangton kitlangton deleted the effect/phase2-installation-appprocess branch May 13, 2026 15:54
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
avion23 pushed a commit to avion23/opencode that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant