Skip to content

Commit d84cc33

Browse files
authored
refactor(plugin): return Effect from ToolContext.ask (#21986)
1 parent c92c462 commit d84cc33

4 files changed

Lines changed: 5 additions & 3 deletions

File tree

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencode/src/tool/registry.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { Glob } from "../util/glob"
3030
import path from "path"
3131
import { pathToFileURL } from "url"
3232
import { Effect, Layer, Context } from "effect"
33-
import { EffectLogger } from "@/effect/logger"
3433
import { FetchHttpClient, HttpClient } from "effect/unstable/http"
3534
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner"
3635
import * as CrossSpawnSpawner from "@/effect/cross-spawn-spawner"
@@ -137,7 +136,7 @@ export namespace ToolRegistry {
137136
Effect.gen(function* () {
138137
const pluginCtx: PluginToolContext = {
139138
...toolCtx,
140-
ask: (req) => Effect.runPromise(toolCtx.ask(req).pipe(Effect.provide(EffectLogger.layer))),
139+
ask: (req) => toolCtx.ask(req),
141140
directory: ctx.directory,
142141
worktree: ctx.worktree,
143142
}

packages/plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
],
1919
"dependencies": {
2020
"@opencode-ai/sdk": "workspace:*",
21+
"effect": "catalog:",
2122
"zod": "catalog:"
2223
},
2324
"peerDependencies": {

packages/plugin/src/tool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { z } from "zod"
2+
import { Effect } from "effect"
23

34
export type ToolContext = {
45
sessionID: string
@@ -16,7 +17,7 @@ export type ToolContext = {
1617
worktree: string
1718
abort: AbortSignal
1819
metadata(input: { title?: string; metadata?: { [key: string]: any } }): void
19-
ask(input: AskInput): Promise<void>
20+
ask(input: AskInput): Effect.Effect<void>
2021
}
2122

2223
type AskInput = {

0 commit comments

Comments
 (0)