diff --git a/packages/opencode/specs/effect-migration.md b/packages/opencode/specs/effect-migration.md index a73f8ea39b..176190437c 100644 --- a/packages/opencode/specs/effect-migration.md +++ b/packages/opencode/specs/effect-migration.md @@ -127,10 +127,10 @@ Use `Effect.cached` when multiple concurrent callers should share a single in-fl ```ts // Inside the layer — yield* to initialize the memo -let cached = yield* Effect.cached(loadExpensive()) +let cached = yield * Effect.cached(loadExpensive()) const get = Effect.fn("Foo.get")(function* () { - return yield* cached // concurrent callers share the same fiber + return yield* cached // concurrent callers share the same fiber }) // To invalidate: swap in a fresh memo @@ -140,6 +140,7 @@ const invalidate = Effect.fn("Foo.invalidate")(function* () { ``` Prefer `Effect.cached` over these patterns: + - Storing a `Fiber.Fiber | undefined` with manual check-and-fork (e.g. `file/index.ts` `ensure`) - Storing a `Promise` task for deduplication (e.g. `skill/index.ts` `ensure`) - `let cached: X | undefined` with check-and-load (races when two callers see `undefined` before either resolves) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index c398d42193..645ae8814a 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -1231,10 +1231,7 @@ export namespace Config { if (provider && model) result.model = `${provider}/${model}` result["$schema"] = "https://opencode.ai/config.json" result = mergeDeep(result, rest) - await fsNode.writeFile( - path.join(Global.Path.config, "config.json"), - JSON.stringify(result, null, 2), - ) + await fsNode.writeFile(path.join(Global.Path.config, "config.json"), JSON.stringify(result, null, 2)) await fsNode.unlink(legacy) }) .catch(() => {}), @@ -1244,9 +1241,7 @@ export namespace Config { return result }) - let cachedGlobal = yield* Effect.cached( - loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)), - ) + let cachedGlobal = yield* Effect.cached(loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info))) const getGlobal = Effect.fn("Config.getGlobal")(function* () { return yield* cachedGlobal @@ -1440,9 +1435,7 @@ export namespace Config { }) const waitForDependencies = Effect.fn("Config.waitForDependencies")(function* () { - yield* InstanceState.useEffect(state, (s) => - Effect.promise(() => Promise.all(s.deps).then(() => undefined)), - ) + yield* InstanceState.useEffect(state, (s) => Effect.promise(() => Promise.all(s.deps).then(() => undefined))) }) const update = Effect.fn("Config.update")(function* (config: Info) { @@ -1453,9 +1446,7 @@ export namespace Config { }) const invalidate = Effect.fn("Config.invalidate")(function* (wait?: boolean) { - cachedGlobal = yield* Effect.cached( - loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)), - ) + cachedGlobal = yield* Effect.cached(loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info))) const task = Instance.disposeAll() .catch(() => undefined) .finally(() =>