11import { 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"
35import path from "path"
46import { pathToFileURL } from "url"
7+ import { Account } from "../../src/account/account"
58import { 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"
613import { Plugin } from "../../src/plugin"
14+ import { Skill } from "../../src/skill"
15+ import { ProviderTest } from "../fake/provider"
716import { testEffect } from "../lib/effect"
817import { 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.
1322const 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
1760it . instance (
1861 "plugin-registered agents appear in Agent.list" ,
0 commit comments