From 6c7f35b49e66e684bd53b4c834dc3932db2cf63b Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Wed, 13 May 2026 11:26:42 -0400 Subject: [PATCH] effect(format): migrate to AppProcess (#27185) --- packages/opencode/src/format/index.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/opencode/src/format/index.ts b/packages/opencode/src/format/index.ts index b6eb9dfd0e..d8365e0fa7 100644 --- a/packages/opencode/src/format/index.ts +++ b/packages/opencode/src/format/index.ts @@ -1,6 +1,6 @@ import { Effect, Layer, Context, Schema } from "effect" -import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process" -import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner" +import { ChildProcess } from "effect/unstable/process" +import { AppProcess } from "@opencode-ai/core/process" import { InstanceState } from "@/effect/instance-state" import path from "path" import { mergeDeep } from "remeda" @@ -29,7 +29,7 @@ export const layer = Layer.effect( Service, Effect.gen(function* () { const config = yield* Config.Service - const spawner = yield* ChildProcessSpawner.ChildProcessSpawner + const appProcess = yield* AppProcess.Service const state = yield* InstanceState.make( Effect.fn("Format.state")(function* (ctx) { @@ -81,8 +81,8 @@ export const layer = Layer.effect( log.info("running", { command: cmd }) const replaced = cmd.map((x) => x.replace("$FILE", filepath)) const dir = yield* InstanceState.directory - const code = yield* spawner - .spawn( + const result = yield* appProcess + .run( ChildProcess.make(replaced[0]!, replaced.slice(1), { cwd: dir, env: item.environment, @@ -93,21 +93,20 @@ export const layer = Layer.effect( }), ) .pipe( - Effect.flatMap((handle) => handle.exitCode), - Effect.scoped, - Effect.catch(() => + Effect.catch((error) => Effect.sync(() => { log.error("failed to format file", { error: "spawn failed", command: cmd, ...item.environment, file: filepath, + cause: error.message, }) - return ChildProcessSpawner.ExitCode(1) + return undefined }), ), ) - if (code !== 0) { + if (result && result.exitCode !== 0) { log.error("failed", { command: cmd, ...item.environment, @@ -198,9 +197,6 @@ export const layer = Layer.effect( }), ) -export const defaultLayer = layer.pipe( - Layer.provide(Config.defaultLayer), - Layer.provide(CrossSpawnSpawner.defaultLayer), -) +export const defaultLayer = layer.pipe(Layer.provide(Config.defaultLayer), Layer.provide(AppProcess.defaultLayer)) export * as Format from "."