refactor(tool): Tool.Def.execute returns Effect, rename defineEffect → define (#21961)

This commit is contained in:
Kit Langton
2026-04-10 22:36:02 -04:00
committed by GitHub
parent f99812443c
commit c5fb6281f0
39 changed files with 674 additions and 721 deletions

View File

@@ -7,10 +7,11 @@ import { Instance } from "../../src/project/instance"
import { LSP } from "../../src/lsp"
import { AppFileSystem } from "../../src/filesystem"
import { Format } from "../../src/format"
import { Bus } from "../../src/bus"
import { tmpdir } from "../fixture/fixture"
import { SessionID, MessageID } from "../../src/session/schema"
const runtime = ManagedRuntime.make(Layer.mergeAll(LSP.defaultLayer, AppFileSystem.defaultLayer, Format.defaultLayer))
const runtime = ManagedRuntime.make(Layer.mergeAll(LSP.defaultLayer, AppFileSystem.defaultLayer, Format.defaultLayer, Bus.layer))
const baseCtx = {
sessionID: SessionID.make("ses_test"),
@@ -42,22 +43,21 @@ type AskInput = {
}
type ToolCtx = typeof baseCtx & {
ask: (input: AskInput) => Promise<void>
ask: (input: AskInput) => Effect.Effect<void>
}
const execute = async (params: { patchText: string }, ctx: ToolCtx) => {
const info = await runtime.runPromise(ApplyPatchTool)
const tool = await info.init()
return tool.execute(params, ctx)
return Effect.runPromise(tool.execute(params, ctx))
}
const makeCtx = () => {
const calls: AskInput[] = []
const ctx: ToolCtx = {
...baseCtx,
ask: async (input) => {
calls.push(input)
},
ask: (input) =>
Effect.sync(() => { calls.push(input) }),
}
return { ctx, calls }