@@ -70,7 +70,9 @@ describe("Config", () => {
7070 Effect . sync ( ( ) => {
7171 expect ( ConfigMigrateV1 . isV1 ( { snapshot : false } ) ) . toBe ( true )
7272 expect ( ConfigMigrateV1 . isV1 ( { snapshot : false , agents : { } } ) ) . toBe ( true )
73+ expect ( ConfigMigrateV1 . isV1 ( { reference : { } } ) ) . toBe ( true )
7374 expect ( ConfigMigrateV1 . isV1 ( { shell : "/bin/zsh" , model : "anthropic/claude" } ) ) . toBe ( false )
75+ expect ( ConfigMigrateV1 . isV1 ( { references : { } } ) ) . toBe ( false )
7476 } ) ,
7577 )
7678
@@ -431,6 +433,42 @@ describe("Config", () => {
431433 ) ,
432434 )
433435
436+ it . live ( "migrates the deprecated reference key into references" , ( ) =>
437+ Effect . acquireRelease (
438+ Effect . promise ( ( ) => tmpdir ( ) ) ,
439+ ( tmp ) => Effect . promise ( ( ) => tmp [ Symbol . asyncDispose ] ( ) ) ,
440+ ) . pipe (
441+ Effect . flatMap ( ( tmp ) =>
442+ Effect . gen ( function * ( ) {
443+ yield * Effect . promise ( ( ) =>
444+ fs . writeFile (
445+ path . join ( tmp . path , "opencode.json" ) ,
446+ JSON . stringify ( {
447+ reference : {
448+ local : { path : "../library" } ,
449+ sdk : { repository : "github.com/example/sdk" , branch : "main" } ,
450+ shorthand : "github.com/example/docs" ,
451+ } ,
452+ } ) ,
453+ ) ,
454+ )
455+
456+ return yield * Effect . gen ( function * ( ) {
457+ const config = yield * Config . Service
458+ const documents = ( yield * config . entries ( ) ) . filter ( ( entry ) => entry . type === "document" )
459+
460+ expect ( documents ) . toHaveLength ( 1 )
461+ expect ( documents [ 0 ] ?. info . references ) . toEqual ( {
462+ local : { path : "../library" } ,
463+ sdk : { repository : "github.com/example/sdk" , branch : "main" } ,
464+ shorthand : "github.com/example/docs" ,
465+ } )
466+ } ) . pipe ( Effect . provide ( testLayer ( tmp . path ) ) )
467+ } ) ,
468+ ) ,
469+ ) ,
470+ )
471+
434472 it . live ( "migrates v1 configuration when a v1-only key is present" , ( ) =>
435473 Effect . acquireRelease (
436474 Effect . promise ( ( ) => tmpdir ( ) ) ,
0 commit comments