@@ -254,6 +254,64 @@ describe("Config", () => {
254254 ) ,
255255 )
256256
257+ it . live ( "skips project sources and preserves global config when project config is disabled" , ( ) =>
258+ Effect . acquireUseRelease (
259+ Effect . sync ( ( ) => {
260+ const previous = process . env . OPENCODE_DISABLE_PROJECT_CONFIG
261+ process . env . OPENCODE_DISABLE_PROJECT_CONFIG = "true"
262+ return previous
263+ } ) ,
264+ ( ) =>
265+ Effect . acquireUseRelease (
266+ Effect . promise ( ( ) => tmpdir ( ) ) ,
267+ ( tmp ) =>
268+ Effect . gen ( function * ( ) {
269+ const global = path . join ( tmp . path , "global" )
270+ const project = path . join ( tmp . path , "project" )
271+ yield * Effect . promise ( async ( ) => {
272+ await Promise . all ( [
273+ fs . mkdir ( path . join ( project , ".opencode" ) , { recursive : true } ) ,
274+ fs . mkdir ( path . join ( project , ".claude" ) , { recursive : true } ) ,
275+ fs . mkdir ( path . join ( project , ".agents" ) , { recursive : true } ) ,
276+ fs . mkdir ( global , { recursive : true } ) ,
277+ ] )
278+ await Promise . all ( [
279+ fs . writeFile ( path . join ( project , "opencode.json" ) , JSON . stringify ( { shell : "project" } ) ) ,
280+ fs . writeFile (
281+ path . join ( project , ".opencode" , "opencode.json" ) ,
282+ JSON . stringify ( { username : "project" } ) ,
283+ ) ,
284+ fs . writeFile ( path . join ( global , "opencode.json" ) , JSON . stringify ( { shell : "global" } ) ) ,
285+ ] )
286+ } )
287+
288+ const entries = yield * Config . Service . pipe (
289+ Effect . flatMap ( ( config ) => config . entries ( ) ) ,
290+ Effect . provide ( testLayer ( project , global , project ) ) ,
291+ )
292+
293+ expect ( entries . filter ( ( entry ) => entry . type === "document" ) ) . toEqual ( [
294+ new Config . Document ( {
295+ type : "document" ,
296+ path : path . join ( global , "opencode.json" ) ,
297+ info : new Config . Info ( { shell : "global" } ) ,
298+ } ) ,
299+ ] )
300+ expect ( entries . filter ( ( entry ) => entry . type === "directory" ) ) . toEqual ( [
301+ new Config . Directory ( { type : "directory" , path : AbsolutePath . make ( global ) } ) ,
302+ ] )
303+ expect ( entries . filter ( ( entry ) => entry . type === "claude" || entry . type === "agents" ) ) . toEqual ( [ ] )
304+ } ) ,
305+ ( tmp ) => Effect . promise ( ( ) => tmp [ Symbol . asyncDispose ] ( ) ) ,
306+ ) ,
307+ ( previous ) =>
308+ Effect . sync ( ( ) => {
309+ if ( previous === undefined ) delete process . env . OPENCODE_DISABLE_PROJECT_CONFIG
310+ else process . env . OPENCODE_DISABLE_PROJECT_CONFIG = previous
311+ } ) ,
312+ ) ,
313+ )
314+
257315 it . live ( "does not watch ecosystem config roots" , ( ) =>
258316 Effect . acquireRelease (
259317 Effect . promise ( ( ) => tmpdir ( ) ) ,
0 commit comments