chore: generate
This commit is contained in:
@@ -127,10 +127,10 @@ Use `Effect.cached` when multiple concurrent callers should share a single in-fl
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
// Inside the layer — yield* to initialize the memo
|
// 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* () {
|
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
|
// To invalidate: swap in a fresh memo
|
||||||
@@ -140,6 +140,7 @@ const invalidate = Effect.fn("Foo.invalidate")(function* () {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Prefer `Effect.cached` over these patterns:
|
Prefer `Effect.cached` over these patterns:
|
||||||
|
|
||||||
- Storing a `Fiber.Fiber | undefined` with manual check-and-fork (e.g. `file/index.ts` `ensure`)
|
- Storing a `Fiber.Fiber | undefined` with manual check-and-fork (e.g. `file/index.ts` `ensure`)
|
||||||
- Storing a `Promise<void>` task for deduplication (e.g. `skill/index.ts` `ensure`)
|
- Storing a `Promise<void>` 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)
|
- `let cached: X | undefined` with check-and-load (races when two callers see `undefined` before either resolves)
|
||||||
|
|||||||
@@ -1231,10 +1231,7 @@ export namespace Config {
|
|||||||
if (provider && model) result.model = `${provider}/${model}`
|
if (provider && model) result.model = `${provider}/${model}`
|
||||||
result["$schema"] = "https://opencode.ai/config.json"
|
result["$schema"] = "https://opencode.ai/config.json"
|
||||||
result = mergeDeep(result, rest)
|
result = mergeDeep(result, rest)
|
||||||
await fsNode.writeFile(
|
await fsNode.writeFile(path.join(Global.Path.config, "config.json"), JSON.stringify(result, null, 2))
|
||||||
path.join(Global.Path.config, "config.json"),
|
|
||||||
JSON.stringify(result, null, 2),
|
|
||||||
)
|
|
||||||
await fsNode.unlink(legacy)
|
await fsNode.unlink(legacy)
|
||||||
})
|
})
|
||||||
.catch(() => {}),
|
.catch(() => {}),
|
||||||
@@ -1244,9 +1241,7 @@ export namespace Config {
|
|||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
let cachedGlobal = yield* Effect.cached(
|
let cachedGlobal = yield* Effect.cached(loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)))
|
||||||
loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)),
|
|
||||||
)
|
|
||||||
|
|
||||||
const getGlobal = Effect.fn("Config.getGlobal")(function* () {
|
const getGlobal = Effect.fn("Config.getGlobal")(function* () {
|
||||||
return yield* cachedGlobal
|
return yield* cachedGlobal
|
||||||
@@ -1440,9 +1435,7 @@ export namespace Config {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const waitForDependencies = Effect.fn("Config.waitForDependencies")(function* () {
|
const waitForDependencies = Effect.fn("Config.waitForDependencies")(function* () {
|
||||||
yield* InstanceState.useEffect(state, (s) =>
|
yield* InstanceState.useEffect(state, (s) => Effect.promise(() => Promise.all(s.deps).then(() => undefined)))
|
||||||
Effect.promise(() => Promise.all(s.deps).then(() => undefined)),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const update = Effect.fn("Config.update")(function* (config: Info) {
|
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) {
|
const invalidate = Effect.fn("Config.invalidate")(function* (wait?: boolean) {
|
||||||
cachedGlobal = yield* Effect.cached(
|
cachedGlobal = yield* Effect.cached(loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)))
|
||||||
loadGlobal().pipe(Effect.orElseSucceed(() => ({}) as Info)),
|
|
||||||
)
|
|
||||||
const task = Instance.disposeAll()
|
const task = Instance.disposeAll()
|
||||||
.catch(() => undefined)
|
.catch(() => undefined)
|
||||||
.finally(() =>
|
.finally(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user