Skip to content

Commit 9f94bdb

Browse files
chore: generate
1 parent 28f5176 commit 9f94bdb

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

packages/opencode/specs/effect-migration.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ Use `Effect.cached` when multiple concurrent callers should share a single in-fl
127127

128128
```ts
129129
// Inside the layer — yield* to initialize the memo
130-
let cached = yield* Effect.cached(loadExpensive())
130+
let cached = yield * Effect.cached(loadExpensive())
131131

132132
const get = Effect.fn("Foo.get")(function* () {
133-
return yield* cached // concurrent callers share the same fiber
133+
return yield* cached // concurrent callers share the same fiber
134134
})
135135

136136
// To invalidate: swap in a fresh memo
@@ -140,6 +140,7 @@ const invalidate = Effect.fn("Foo.invalidate")(function* () {
140140
```
141141

142142
Prefer `Effect.cached` over these patterns:
143+
143144
- Storing a `Fiber.Fiber | undefined` with manual check-and-fork (e.g. `file/index.ts` `ensure`)
144145
- Storing a `Promise<void>` task for deduplication (e.g. `skill/index.ts` `ensure`)
145146
- `let cached: X | undefined` with check-and-load (races when two callers see `undefined` before either resolves)

packages/opencode/src/config/config.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,10 +1231,7 @@ export namespace Config {
12311231
if (provider && model) result.model = `${provider}/${model}`
12321232
result["$schema"] = "https://opencode.ai/config.json"
12331233
result = mergeDeep(result, rest)
1234-
await fsNode.writeFile(
1235-
path.join(Global.Path.config, "config.json"),
1236-
JSON.stringify(result, null, 2),
1237-
)
1234+
await fsNode.writeFile(path.join(Global.Path.config, "config.json"), JSON.stringify(result, null, 2))
12381235
await fsNode.unlink(legacy)
12391236
})
12401237
.catch(() => {}),
@@ -1244,9 +1241,7 @@ export namespace Config {
12441241
return result
12451242
})
12461243

1247-
let cachedGlobal = yield* Effect.cached(
1248-
loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)),
1249-
)
1244+
let cachedGlobal = yield* Effect.cached(loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)))
12501245

12511246
const getGlobal = Effect.fn("Config.getGlobal")(function* () {
12521247
return yield* cachedGlobal
@@ -1440,9 +1435,7 @@ export namespace Config {
14401435
})
14411436

14421437
const waitForDependencies = Effect.fn("Config.waitForDependencies")(function* () {
1443-
yield* InstanceState.useEffect(state, (s) =>
1444-
Effect.promise(() => Promise.all(s.deps).then(() => undefined)),
1445-
)
1438+
yield* InstanceState.useEffect(state, (s) => Effect.promise(() => Promise.all(s.deps).then(() => undefined)))
14461439
})
14471440

14481441
const update = Effect.fn("Config.update")(function* (config: Info) {
@@ -1453,9 +1446,7 @@ export namespace Config {
14531446
})
14541447

14551448
const invalidate = Effect.fn("Config.invalidate")(function* (wait?: boolean) {
1456-
cachedGlobal = yield* Effect.cached(
1457-
loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)),
1458-
)
1449+
cachedGlobal = yield* Effect.cached(loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)))
14591450
const task = Instance.disposeAll()
14601451
.catch(() => undefined)
14611452
.finally(() =>

0 commit comments

Comments
 (0)