You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/opencode/specs/effect-migration.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,11 +235,27 @@ Once individual tools are effectified, change `Tool.Info` (`tool/tool.ts`) so `i
235
235
2. Update `Tool.define()` factory to work with Effects
236
236
3. Update `SessionPrompt` to `yield*` tool results instead of `await`ing
237
237
238
+
### Tool migration details
239
+
240
+
Until the tool interface itself returns `Effect`, use this transitional pattern for migrated tools:
241
+
242
+
-`Tool.defineEffect(...)` should `yield*` the services the tool depends on and close over them in the returned tool definition.
243
+
- Keep the bridge at the Promise boundary only. Prefer a single `Effect.runPromise(...)` in the temporary `async execute(...)` implementation, and move the inner logic into `Effect.fn(...)` helpers instead of scattering `runPromise` islands through the tool body.
244
+
- If a tool starts requiring new services, wire them into `ToolRegistry.defaultLayer` so production callers resolve the same dependencies as tests.
245
+
246
+
Tool tests should use the existing Effect helpers in `packages/opencode/test/lib/effect.ts`:
247
+
248
+
- Use `testEffect(...)` / `it.live(...)` instead of creating fake local wrappers around effectful tools.
249
+
- Yield the real tool export, then initialize it: `const info = yield* ReadTool`, `const tool = yield* Effect.promise(() => info.init())`.
250
+
- Run tests inside a real instance with `provideTmpdirInstance(...)` or `provideInstance(tmpdirScoped(...))` so instance-scoped services resolve exactly as they do in production.
251
+
252
+
This keeps migrated tool tests aligned with the production service graph today, and makes the eventual `Tool.Info` → `Effect` cleanup mostly mechanical later.
253
+
238
254
Individual tools, ordered by value:
239
255
240
256
-[ ]`apply_patch.ts` — HIGH: multi-step orchestration, error accumulation, Bus events
0 commit comments