From d84d1421aeb2552a8ed438dd16a212d2465679e1 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Thu, 27 Aug 2026 22:43:09 -0400 Subject: [PATCH] test(core): bind acquired test services (#45711) --- packages/core/test/ripgrep.test.ts | 15 ++++++++++----- packages/core/test/tool-output.test.ts | 3 ++- packages/core/test/tool-search.test.ts | 7 +++---- packages/core/test/tool-shell.test.ts | 3 ++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/core/test/ripgrep.test.ts b/packages/core/test/ripgrep.test.ts index 5d0c5efbc7b..8a9be3177c3 100644 --- a/packages/core/test/ripgrep.test.ts +++ b/packages/core/test/ripgrep.test.ts @@ -22,7 +22,8 @@ describe("Ripgrep", () => { yield* Effect.promise(() => fs.mkdir(path.join(tmp.path, "src"))) yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "src", "match.ts"), "needle\n")) - const result = yield* (yield* Ripgrep.Service).glob({ cwd: tmp.path, pattern: "**/*.ts", limit: 10 }) + const ripgrep = yield* Ripgrep.Service + const result = yield* ripgrep.glob({ cwd: tmp.path, pattern: "**/*.ts", limit: 10 }) expect(result.map((item) => item.path)).toEqual([RelativePath.make("src/match.ts")]) }), (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), @@ -38,7 +39,8 @@ describe("Ripgrep", () => { yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "src", "match.ts"), "needle\n")) yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "src", "skip.txt"), "needle\n")) - const result = yield* (yield* Ripgrep.Service).grep({ + const ripgrep = yield* Ripgrep.Service + const result = yield* ripgrep.grep({ cwd: tmp.path, pattern: "needle", include: "*.ts", @@ -64,7 +66,8 @@ describe("Ripgrep", () => { yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "node_modules", "pkg", "index.js"), "ignored\n")) yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "src", "index.js"), "included\n")) - const files = yield* (yield* Ripgrep.Service).find({ cwd: tmp.path, pattern: "*", limit: 10 }) + const ripgrep = yield* Ripgrep.Service + const files = yield* ripgrep.find({ cwd: tmp.path, pattern: "*", limit: 10 }) expect(files.map((item) => item.path)).toContain(RelativePath.make("src/index.js")) expect(files.map((item) => item.path)).not.toContain(RelativePath.make("node_modules/pkg/index.js")) }), @@ -113,7 +116,8 @@ describe("Ripgrep", () => { yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "Pictures", "private.jpg"), "private\n")) yield* Effect.promise(() => fs.writeFile(path.join(tmp.path, "visible.txt"), "visible\n")) - const files = yield* (yield* Ripgrep.Service).find({ + const ripgrep = yield* Ripgrep.Service + const files = yield* ripgrep.find({ cwd: tmp.path, pattern: "*", limit: 10, @@ -136,7 +140,8 @@ describe("Ripgrep", () => { fs.writeFile(path.join(tmp.path, "generated.ts"), `Cloudflare${"x".repeat(70 * 1024)}\n`), ) - const matches = yield* (yield* Ripgrep.Service).grep({ + const ripgrep = yield* Ripgrep.Service + const matches = yield* ripgrep.grep({ cwd: tmp.path, pattern: "Cloudflare", limit: 10, diff --git a/packages/core/test/tool-output.test.ts b/packages/core/test/tool-output.test.ts index 86b9d8eec35..b5fa2d14aad 100644 --- a/packages/core/test/tool-output.test.ts +++ b/packages/core/test/tool-output.test.ts @@ -22,8 +22,9 @@ const withStore = ( ]) return Effect.gen(function* () { const output = yield* ToolOutput.Service + const fs = yield* FSUtil.Service if (limits) yield* output.transform((draft) => draft.configure(limits)) - return yield* body(output, yield* FSUtil.Service, tmp.path) + return yield* body(output, fs, tmp.path) }).pipe(Effect.provide(layer)) }, (tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()), diff --git a/packages/core/test/tool-search.test.ts b/packages/core/test/tool-search.test.ts index e8b953a26b5..0627d3555e9 100644 --- a/packages/core/test/tool-search.test.ts +++ b/packages/core/test/tool-search.test.ts @@ -18,7 +18,7 @@ import { GrepTool } from "@opencode-ai/core/tool/plugin/grep" import { Tool } from "@opencode-ai/core/tool" import { location } from "./fixture/location" import { tmpdir } from "./fixture/tmpdir" -import { testEffect } from "./lib/effect" +import { it } from "./lib/effect" import { permissionLayer } from "./lib/permission" import { executeTool, registerToolPlugin, toolIdentity } from "./lib/tool" @@ -40,7 +40,8 @@ const withTools = ( assertions?: Permission.AssertInput[], ) => Effect.gen(function* () { - return yield* body(yield* Tool.Service) + const registry = yield* Tool.Service + return yield* body(registry) }).pipe( Effect.provide( AppNodeBuilder.build(LayerNode.group([Tool.node, globToolNode, grepToolNode]), [ @@ -67,8 +68,6 @@ const call = (name: "glob" | "grep", input: unknown) => ({ call: { type: "tool-call" as const, id: `call-${name}`, name, input }, }) -const it = testEffect(Layer.empty) - describe("search tools", () => { it.live("bounds omitted glob and grep limits", () => Effect.acquireUseRelease( diff --git a/packages/core/test/tool-shell.test.ts b/packages/core/test/tool-shell.test.ts index 9a62fc6c920..4de9ff16dea 100644 --- a/packages/core/test/tool-shell.test.ts +++ b/packages/core/test/tool-shell.test.ts @@ -215,7 +215,8 @@ const withSession = (directory: string, body: (registry: Tool.Interface const locations = yield* LocationServiceMap.Service const locationLayer = locations.get(location) return yield* Effect.gen(function* () { - yield* (yield* PluginSupervisor.Service).flush + const plugins = yield* PluginSupervisor.Service + yield* plugins.flush const registry = yield* Tool.Service return yield* body(registry) }).pipe(Effect.provide(locationLayer), Effect.ensuring(locations.invalidate(location)))