Skip to content

Commit 94d3e96

Browse files
committed
test(agent): isolate plugin agent regression
1 parent a5c35bf commit 94d3e96

1 file changed

Lines changed: 45 additions & 2 deletions

File tree

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

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import { expect } from "bun:test"
2-
import { Effect, Layer } from "effect"
2+
import { Npm } from "@opencode-ai/core/npm"
3+
import { AppFileSystem } from "@opencode-ai/core/filesystem"
4+
import { Effect, Layer, Option } from "effect"
35
import path from "path"
46
import { pathToFileURL } from "url"
7+
import { Account } from "../../src/account/account"
58
import { Agent } from "../../src/agent/agent"
9+
import { Auth } from "../../src/auth"
10+
import { Bus } from "../../src/bus"
11+
import { Config } from "../../src/config/config"
12+
import { Env } from "../../src/env"
613
import { Plugin } from "../../src/plugin"
14+
import { Skill } from "../../src/skill"
15+
import { ProviderTest } from "../fake/provider"
716
import { testEffect } from "../lib/effect"
817
import { PLUGIN_AGENT } from "../fixture/agent-plugin.constants"
918

@@ -12,7 +21,41 @@ 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 emptyAccount = Layer.mock(Account.Service)({
25+
active: () => Effect.succeed(Option.none()),
26+
activeOrg: () => Effect.succeed(Option.none()),
27+
})
28+
29+
const emptyAuth = Layer.mock(Auth.Service)({
30+
all: () => Effect.succeed({}),
31+
})
32+
33+
const emptySkill = Layer.mock(Skill.Service)({
34+
dirs: () => Effect.succeed([]),
35+
})
36+
37+
const noopNpm = Layer.mock(Npm.Service)({
38+
install: () => Effect.void,
39+
})
40+
41+
const provider = ProviderTest.fake()
42+
const configLayer = Config.layer.pipe(
43+
Layer.provide(AppFileSystem.defaultLayer),
44+
Layer.provide(Env.defaultLayer),
45+
Layer.provide(emptyAuth),
46+
Layer.provide(emptyAccount),
47+
Layer.provide(noopNpm),
48+
)
49+
const pluginLayer = Plugin.layer.pipe(Layer.provide(Bus.layer), Layer.provide(configLayer))
50+
const agentLayer = Agent.layer.pipe(
51+
Layer.provide(configLayer),
52+
Layer.provide(emptyAuth),
53+
Layer.provide(emptySkill),
54+
Layer.provide(provider.layer),
55+
Layer.provide(pluginLayer),
56+
)
57+
58+
const it = testEffect(Layer.mergeAll(agentLayer, pluginLayer))
1659

1760
it.instance(
1861
"plugin-registered agents appear in Agent.list",

0 commit comments

Comments
 (0)