refactor(tool): convert apply_patch to Tool.defineEffect (#21938)

This commit is contained in:
Kit Langton 2026-04-10 19:42:14 -04:00 committed by GitHub
commit 0556774097
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 268 additions and 234 deletions

View file

@ -1,11 +1,17 @@
import { describe, expect, test } from "bun:test"
import path from "path"
import * as fs from "fs/promises"
import { Effect, ManagedRuntime, Layer } from "effect"
import { ApplyPatchTool } from "../../src/tool/apply_patch"
import { Instance } from "../../src/project/instance"
import { LSP } from "../../src/lsp"
import { AppFileSystem } from "../../src/filesystem"
import { Format } from "../../src/format"
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 baseCtx = {
sessionID: SessionID.make("ses_test"),
messageID: MessageID.make(""),
@ -40,7 +46,8 @@ type ToolCtx = typeof baseCtx & {
}
const execute = async (params: { patchText: string }, ctx: ToolCtx) => {
const tool = await ApplyPatchTool.init()
const info = await runtime.runPromise(ApplyPatchTool)
const tool = await info.init()
return tool.execute(params, ctx)
}