Skip to content

Commit 4d08b2c

Browse files
kitlangtonleohenon
authored andcommitted
test(agent): isolate plugin agent regression (anomalyco#26948)
1 parent 01f431f commit 4d08b2c

5 files changed

Lines changed: 60 additions & 1 deletion

File tree

packages/opencode/test/agent/plugin-agent-regression.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import { expect } from "bun:test"
2+
import { AppFileSystem } from "@opencode-ai/core/filesystem"
23
import { Effect, Layer } from "effect"
34
import path from "path"
45
import { pathToFileURL } from "url"
56
import { Agent } from "../../src/agent/agent"
7+
import { Bus } from "../../src/bus"
8+
import { Config } from "../../src/config/config"
9+
import { Env } from "../../src/env"
610
import { Plugin } from "../../src/plugin"
11+
import { AccountTest } from "../fake/account"
12+
import { AuthTest } from "../fake/auth"
13+
import { NpmTest } from "../fake/npm"
14+
import { ProviderTest } from "../fake/provider"
15+
import { SkillTest } from "../fake/skill"
716
import { testEffect } from "../lib/effect"
817
import { PLUGIN_AGENT } from "../fixture/agent-plugin.constants"
918

@@ -12,7 +21,24 @@ import { PLUGIN_AGENT } from "../fixture/agent-plugin.constants"
1221
// to verify plugin → config hook → Agent.list.
1322
const pluginUrl = pathToFileURL(path.join(import.meta.dir, "..", "fixture", "agent-plugin.ts")).href
1423

15-
const it = testEffect(Layer.mergeAll(Agent.defaultLayer, Plugin.defaultLayer))
24+
const provider = ProviderTest.fake()
25+
const configLayer = Config.layer.pipe(
26+
Layer.provide(AppFileSystem.defaultLayer),
27+
Layer.provide(Env.defaultLayer),
28+
Layer.provide(AuthTest.empty),
29+
Layer.provide(AccountTest.empty),
30+
Layer.provide(NpmTest.noop),
31+
)
32+
const pluginLayer = Plugin.layer.pipe(Layer.provide(Bus.layer), Layer.provide(configLayer))
33+
const agentLayer = Agent.layer.pipe(
34+
Layer.provide(configLayer),
35+
Layer.provide(AuthTest.empty),
36+
Layer.provide(SkillTest.empty),
37+
Layer.provide(provider.layer),
38+
Layer.provide(pluginLayer),
39+
)
40+
41+
const it = testEffect(Layer.mergeAll(agentLayer, pluginLayer))
1642

1743
it.instance(
1844
"plugin-registered agents appear in Agent.list",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Effect, Layer, Option } from "effect"
2+
import { Account } from "../../src/account/account"
3+
4+
export const empty = Layer.mock(Account.Service)({
5+
active: () => Effect.succeed(Option.none()),
6+
activeOrg: () => Effect.succeed(Option.none()),
7+
})
8+
9+
export * as AccountTest from "./account"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Effect, Layer } from "effect"
2+
import { Auth } from "../../src/auth"
3+
4+
export const empty = Layer.mock(Auth.Service)({
5+
all: () => Effect.succeed({}),
6+
})
7+
8+
export * as AuthTest from "./auth"

packages/opencode/test/fake/npm.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Npm } from "@opencode-ai/core/npm"
2+
import { Effect, Layer } from "effect"
3+
4+
export const noop = Layer.mock(Npm.Service)({
5+
install: () => Effect.void,
6+
})
7+
8+
export * as NpmTest from "./npm"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Effect, Layer } from "effect"
2+
import { Skill } from "../../src/skill"
3+
4+
export const empty = Layer.mock(Skill.Service)({
5+
dirs: () => Effect.succeed([]),
6+
})
7+
8+
export * as SkillTest from "./skill"

0 commit comments

Comments
 (0)