chore: generate

This commit is contained in:
opencode-agent[bot]
2026-03-26 00:56:34 +00:00
parent ea04b23745
commit 31ad6e85ba
5 changed files with 49 additions and 53 deletions
+17 -10
View File
@@ -82,31 +82,38 @@ The `InstanceState.make` init callback receives a `Scope`, so you can use `Effec
- **Subscriptions**: Yield `Bus.Service` at the layer level, then use `Stream` + `forkScoped` inside the init closure. The fiber is automatically interrupted when the instance scope closes: - **Subscriptions**: Yield `Bus.Service` at the layer level, then use `Stream` + `forkScoped` inside the init closure. The fiber is automatically interrupted when the instance scope closes:
```ts ```ts
const bus = yield* Bus.Service const bus = yield * Bus.Service
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* bus yield* bus.subscribeAll().pipe(
.subscribeAll() Stream.runForEach((event) =>
.pipe( Effect.sync(() => {
Stream.runForEach((event) => Effect.sync(() => { /* handle */ })), /* handle */
}),
),
Effect.forkScoped, Effect.forkScoped,
) )
return { /* state */ } return {
/* state */
}
}), }),
) )
``` ```
- **Resource cleanup**: Use `Effect.acquireRelease` or `Effect.addFinalizer` for resources that need teardown (native watchers, process handles, etc.): - **Resource cleanup**: Use `Effect.acquireRelease` or `Effect.addFinalizer` for resources that need teardown (native watchers, process handles, etc.):
```ts ```ts
yield* Effect.acquireRelease( yield *
Effect.acquireRelease(
Effect.sync(() => nativeAddon.watch(dir)), Effect.sync(() => nativeAddon.watch(dir)),
(watcher) => Effect.sync(() => watcher.close()), (watcher) => Effect.sync(() => watcher.close()),
) )
``` ```
- **Background fibers**: Use `Effect.forkScoped` — the fiber is interrupted on disposal. - **Background fibers**: Use `Effect.forkScoped` — the fiber is interrupted on disposal.
+2 -6
View File
@@ -404,15 +404,11 @@ export namespace File {
s.cache = next s.cache = next
}) })
let cachedScan = yield* Effect.cached( let cachedScan = yield* Effect.cached(scan().pipe(Effect.catchCause(() => Effect.void)))
scan().pipe(Effect.catchCause(() => Effect.void)),
)
const ensure = Effect.fn("File.ensure")(function* () { const ensure = Effect.fn("File.ensure")(function* () {
yield* cachedScan yield* cachedScan
cachedScan = yield* Effect.cached( cachedScan = yield* Effect.cached(scan().pipe(Effect.catchCause(() => Effect.void)))
scan().pipe(Effect.catchCause(() => Effect.void)),
)
}) })
const init = Effect.fn("File.init")(function* () { const init = Effect.fn("File.init")(function* () {
+1 -3
View File
@@ -149,9 +149,7 @@ export namespace Plugin {
}) })
// Subscribe to bus events, fiber interrupted when scope closes // Subscribe to bus events, fiber interrupted when scope closes
yield* bus yield* bus.subscribeAll().pipe(
.subscribeAll()
.pipe(
Stream.runForEach((input) => Stream.runForEach((input) =>
Effect.sync(() => { Effect.sync(() => {
for (const hook of hooks) { for (const hook of hooks) {
+1 -3
View File
@@ -159,9 +159,7 @@ export namespace Vcs {
const value = { current, root } const value = { current, root }
log.info("initialized", { branch: value.current, default_branch: value.root?.name }) log.info("initialized", { branch: value.current, default_branch: value.root?.name })
yield* bus yield* bus.subscribe(FileWatcher.Event.Updated).pipe(
.subscribe(FileWatcher.Event.Updated)
.pipe(
Stream.filter((evt) => evt.properties.file.endsWith("HEAD")), Stream.filter((evt) => evt.properties.file.endsWith("HEAD")),
Stream.runForEach((_evt) => Stream.runForEach((_evt) =>
Effect.gen(function* () { Effect.gen(function* () {
+1 -4
View File
@@ -162,10 +162,7 @@ describe("Vcs diff", () => {
await $`git worktree add -b feature/test ${dir} HEAD`.cwd(tmp.path).quiet() await $`git worktree add -b feature/test ${dir} HEAD`.cwd(tmp.path).quiet()
await withVcsOnly(dir, async () => { await withVcsOnly(dir, async () => {
const [branch, base] = await Promise.all([ const [branch, base] = await Promise.all([Vcs.branch(), Vcs.defaultBranch()])
Vcs.branch(),
Vcs.defaultBranch(),
])
expect(branch).toBe("feature/test") expect(branch).toBe("feature/test")
expect(base).toBe("main") expect(base).toBe("main")
}) })