summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoropencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>2026-03-26 00:56:34 +0000
committeropencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>2026-03-26 00:56:34 +0000
commit31ad6e85ba62ff6d7ad375a584f5ea8a3b66aef3 (patch)
tree963b7fafc1565880141638e0f6369a1d85677005
parentea04b23745b34a9cab0c5d27053398db65e0dbf6 (diff)
downloadopencode-31ad6e85ba62ff6d7ad375a584f5ea8a3b66aef3.tar.gz
opencode-31ad6e85ba62ff6d7ad375a584f5ea8a3b66aef3.zip
chore: generate
-rw-r--r--packages/opencode/specs/effect-migration.md41
-rw-r--r--packages/opencode/src/file/index.ts8
-rw-r--r--packages/opencode/src/plugin/index.ts22
-rw-r--r--packages/opencode/src/project/vcs.ts30
-rw-r--r--packages/opencode/test/project/vcs.test.ts5
5 files changed, 51 insertions, 55 deletions
diff --git a/packages/opencode/specs/effect-migration.md b/packages/opencode/specs/effect-migration.md
index c95d131dc..43b319485 100644
--- a/packages/opencode/specs/effect-migration.md
+++ b/packages/opencode/specs/effect-migration.md
@@ -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:
```ts
-const bus = yield* Bus.Service
-
-const cache = yield* InstanceState.make<State>(
- Effect.fn("Foo.state")(function* (ctx) {
- // ... load state ...
-
- yield* bus
- .subscribeAll()
- .pipe(
- Stream.runForEach((event) => Effect.sync(() => { /* handle */ })),
+const bus = yield * Bus.Service
+
+const cache =
+ yield *
+ InstanceState.make<State>(
+ Effect.fn("Foo.state")(function* (ctx) {
+ // ... load state ...
+
+ yield* bus.subscribeAll().pipe(
+ Stream.runForEach((event) =>
+ Effect.sync(() => {
+ /* handle */
+ }),
+ ),
Effect.forkScoped,
)
- return { /* state */ }
- }),
-)
+ return {
+ /* state */
+ }
+ }),
+ )
```
- **Resource cleanup**: Use `Effect.acquireRelease` or `Effect.addFinalizer` for resources that need teardown (native watchers, process handles, etc.):
```ts
-yield* Effect.acquireRelease(
- Effect.sync(() => nativeAddon.watch(dir)),
- (watcher) => Effect.sync(() => watcher.close()),
-)
+yield *
+ Effect.acquireRelease(
+ Effect.sync(() => nativeAddon.watch(dir)),
+ (watcher) => Effect.sync(() => watcher.close()),
+ )
```
- **Background fibers**: Use `Effect.forkScoped` — the fiber is interrupted on disposal.
diff --git a/packages/opencode/src/file/index.ts b/packages/opencode/src/file/index.ts
index 61f1af89d..efc3fa7c9 100644
--- a/packages/opencode/src/file/index.ts
+++ b/packages/opencode/src/file/index.ts
@@ -404,15 +404,11 @@ export namespace File {
s.cache = next
})
- let cachedScan = yield* Effect.cached(
- scan().pipe(Effect.catchCause(() => Effect.void)),
- )
+ let cachedScan = yield* Effect.cached(scan().pipe(Effect.catchCause(() => Effect.void)))
const ensure = Effect.fn("File.ensure")(function* () {
yield* cachedScan
- cachedScan = yield* Effect.cached(
- scan().pipe(Effect.catchCause(() => Effect.void)),
- )
+ cachedScan = yield* Effect.cached(scan().pipe(Effect.catchCause(() => Effect.void)))
})
const init = Effect.fn("File.init")(function* () {
diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts
index cd4b91799..9804169a4 100644
--- a/packages/opencode/src/plugin/index.ts
+++ b/packages/opencode/src/plugin/index.ts
@@ -149,18 +149,16 @@ export namespace Plugin {
})
// Subscribe to bus events, fiber interrupted when scope closes
- yield* bus
- .subscribeAll()
- .pipe(
- Stream.runForEach((input) =>
- Effect.sync(() => {
- for (const hook of hooks) {
- hook["event"]?.({ event: input as any })
- }
- }),
- ),
- Effect.forkScoped,
- )
+ yield* bus.subscribeAll().pipe(
+ Stream.runForEach((input) =>
+ Effect.sync(() => {
+ for (const hook of hooks) {
+ hook["event"]?.({ event: input as any })
+ }
+ }),
+ ),
+ Effect.forkScoped,
+ )
return { hooks }
}),
diff --git a/packages/opencode/src/project/vcs.ts b/packages/opencode/src/project/vcs.ts
index 7df9dfb6f..daca1c75c 100644
--- a/packages/opencode/src/project/vcs.ts
+++ b/packages/opencode/src/project/vcs.ts
@@ -159,22 +159,20 @@ export namespace Vcs {
const value = { current, root }
log.info("initialized", { branch: value.current, default_branch: value.root?.name })
- yield* bus
- .subscribe(FileWatcher.Event.Updated)
- .pipe(
- Stream.filter((evt) => evt.properties.file.endsWith("HEAD")),
- Stream.runForEach((_evt) =>
- Effect.gen(function* () {
- const next = yield* Effect.promise(() => get())
- if (next !== value.current) {
- log.info("branch changed", { from: value.current, to: next })
- value.current = next
- yield* bus.publish(Event.BranchUpdated, { branch: next })
- }
- }),
- ),
- Effect.forkScoped,
- )
+ yield* bus.subscribe(FileWatcher.Event.Updated).pipe(
+ Stream.filter((evt) => evt.properties.file.endsWith("HEAD")),
+ Stream.runForEach((_evt) =>
+ Effect.gen(function* () {
+ const next = yield* Effect.promise(() => get())
+ if (next !== value.current) {
+ log.info("branch changed", { from: value.current, to: next })
+ value.current = next
+ yield* bus.publish(Event.BranchUpdated, { branch: next })
+ }
+ }),
+ ),
+ Effect.forkScoped,
+ )
return value
}),
diff --git a/packages/opencode/test/project/vcs.test.ts b/packages/opencode/test/project/vcs.test.ts
index 50282b5f6..a327f65fa 100644
--- a/packages/opencode/test/project/vcs.test.ts
+++ b/packages/opencode/test/project/vcs.test.ts
@@ -162,10 +162,7 @@ describe("Vcs diff", () => {
await $`git worktree add -b feature/test ${dir} HEAD`.cwd(tmp.path).quiet()
await withVcsOnly(dir, async () => {
- const [branch, base] = await Promise.all([
- Vcs.branch(),
- Vcs.defaultBranch(),
- ])
+ const [branch, base] = await Promise.all([Vcs.branch(), Vcs.defaultBranch()])
expect(branch).toBe("feature/test")
expect(base).toBe("main")
})