chore: generate

This commit is contained in:
opencode-agent[bot]
2026-03-22 00:51:19 +00:00
parent 3236f228fb
commit e82c5a9a28
2 changed files with 20 additions and 13 deletions
+13 -4
View File
@@ -82,24 +82,33 @@ The `InstanceState.make` init callback receives a `Scope`, so you can use `Effec
- **Subscriptions**: Use `Effect.acquireRelease` to subscribe and auto-unsubscribe: - **Subscriptions**: Use `Effect.acquireRelease` to subscribe and auto-unsubscribe:
```ts ```ts
const cache = yield* InstanceState.make<State>( const cache =
yield *
InstanceState.make<State>(
Effect.fn("Foo.state")(function* (ctx) { Effect.fn("Foo.state")(function* (ctx) {
// ... load state ... // ... load state ...
yield* Effect.acquireRelease( yield* Effect.acquireRelease(
Effect.sync(() => Bus.subscribeAll((event) => { /* handle */ })), Effect.sync(() =>
Bus.subscribeAll((event) => {
/* handle */
}),
),
(unsub) => Effect.sync(unsub), (unsub) => Effect.sync(unsub),
) )
return { /* state */ } return {
/* state */
}
}), }),
) )
``` ```
- **Background fibers**: Use `Effect.forkScoped` — the fiber is interrupted on disposal. - **Background fibers**: Use `Effect.forkScoped` — the fiber is interrupted on disposal.
- **Side effects at init**: Config notification, event wiring, etc. all belong in the init closure. Callers just do `InstanceState.get(cache)` to trigger everything, and `ScopedCache` deduplicates automatically. - **Side effects at init**: Config notification, event wiring, etc. all belong in the init closure. Callers just do `InstanceState.get(cache)` to trigger everything, and `ScopedCache` deduplicates automatically.
The key insight: don't split init into a separate method with a `started` flag. Put everything in the `InstanceState.make` closure and let `ScopedCache` handle the run-once semantics. The key insight: don't split init into a separate method with a `started` flag. Put everything in the `InstanceState.make` closure and let `ScopedCache` handle the run-once semantics.
## Scheduled Tasks ## Scheduled Tasks
For loops or periodic work, use `Effect.repeat` or `Effect.schedule` with `Effect.forkScoped` in the layer definition. For loops or periodic work, use `Effect.repeat` or `Effect.schedule` with `Effect.forkScoped` in the layer definition.
+1 -3
View File
@@ -24,9 +24,7 @@ export namespace Plugin {
// Hook names that follow the (input, output) => Promise<void> trigger pattern // Hook names that follow the (input, output) => Promise<void> trigger pattern
type TriggerName = { type TriggerName = {
[K in keyof Hooks]-?: NonNullable<Hooks[K]> extends (input: any, output: any) => Promise<void> [K in keyof Hooks]-?: NonNullable<Hooks[K]> extends (input: any, output: any) => Promise<void> ? K : never
? K
: never
}[keyof Hooks] }[keyof Hooks]
export interface Interface { export interface Interface {