@@ -2,46 +2,39 @@ import { describe, expect, test } from "bun:test"
22import path from "path"
33import { pathToFileURL } from "url"
44import { LayerNode } from "@opencode-ai/core/effect/layer-node"
5- import { Effect , Layer } from "effect"
5+ import { Effect } from "effect"
66import { FSUtil } from "@opencode-ai/core/fs-util"
77import { provideInstance , TestInstance , tmpdirScoped } from "../fixture/fixture"
88import { ProviderAuth } from "@/provider/auth"
99
10- import { Plugin } from "@/plugin"
1110import { RuntimeFlags } from "@/effect/runtime-flags"
12- import { Auth } from "@/auth"
13- import { EventV2Bridge } from "@/event-v2-bridge"
1411import { TestConfig } from "../fixture/config"
1512import { testEffect } from "../lib/effect"
1613import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
1714import { ProviderV2 } from "@opencode-ai/core/provider"
15+ import { Config } from "@/config/config"
1816
1917const it = testEffect ( LayerNode . compile ( LayerNode . group ( [ CrossSpawnSpawner . node , FSUtil . node ] ) ) )
2018
21- function layer ( directory : string , plugins : string [ ] ) {
22- return ProviderAuth . layer . pipe (
23- Layer . provide ( Auth . defaultLayer ) ,
24- Layer . provide (
25- Plugin . layer . pipe (
26- Layer . provide ( EventV2Bridge . defaultLayer ) ,
27- Layer . provide ( RuntimeFlags . layer ( ) ) ,
28- Layer . provide (
29- TestConfig . layer ( {
30- get : ( ) =>
31- Effect . succeed ( {
32- plugin : plugins ,
33- plugin_origins : plugins . map ( ( plugin ) => ( {
34- spec : plugin ,
35- source : path . join ( directory , "opencode.json" ) ,
36- scope : "local" as const ,
37- } ) ) ,
38- } ) ,
39- directories : ( ) => Effect . succeed ( [ directory ] ) ,
19+ function providerAuthLayer ( directory : string , plugins : string [ ] ) {
20+ return LayerNode . compile ( ProviderAuth . node , [
21+ [
22+ Config . node ,
23+ TestConfig . layer ( {
24+ get : ( ) =>
25+ Effect . succeed ( {
26+ plugin : plugins ,
27+ plugin_origins : plugins . map ( ( plugin ) => ( {
28+ spec : plugin ,
29+ source : path . join ( directory , "opencode.json" ) ,
30+ scope : "local" as const ,
31+ } ) ) ,
4032 } ) ,
41- ) ,
42- ) ,
43- ) ,
44- )
33+ directories : ( ) => Effect . succeed ( [ directory ] ) ,
34+ } ) ,
35+ ] ,
36+ [ RuntimeFlags . node , RuntimeFlags . layer ( ) ] ,
37+ ] )
4538}
4639
4740describe ( "plugin.auth-override" , ( ) => {
@@ -74,10 +67,10 @@ describe("plugin.auth-override", () => {
7467
7568 const plain = yield * tmpdirScoped ( { git : true } )
7669 const plugin = pathToFileURL ( path . join ( pluginDir , "custom-copilot-auth.ts" ) ) . href
77- const methods = yield * ProviderAuth . use . methods ( ) . pipe ( Effect . provide ( layer ( tmp . directory , [ plugin ] ) ) )
70+ const methods = yield * ProviderAuth . use . methods ( ) . pipe ( Effect . provide ( providerAuthLayer ( tmp . directory , [ plugin ] ) ) )
7871 const plainMethods = yield * ProviderAuth . use
7972 . methods ( )
80- . pipe ( Effect . provide ( layer ( plain , [ ] ) ) , provideInstance ( plain ) )
73+ . pipe ( Effect . provide ( providerAuthLayer ( plain , [ ] ) ) , provideInstance ( plain ) )
8174
8275 const copilot = methods [ ProviderV2 . ID . make ( "github-copilot" ) ]
8376 expect ( copilot ) . toBeDefined ( )
0 commit comments