@@ -185,7 +185,9 @@ export namespace Config {
185185 if ( Flag . OPENCODE_CONFIG_CONTENT ) {
186186 result = merge (
187187 result ,
188- await load ( Flag . OPENCODE_CONFIG_CONTENT , path . join ( Instance . directory , "OPENCODE_CONFIG_CONTENT" ) ) ,
188+ await load ( Flag . OPENCODE_CONFIG_CONTENT , path . join ( Instance . directory , "OPENCODE_CONFIG_CONTENT" ) , {
189+ writeback : false ,
190+ } ) ,
189191 )
190192 log . debug ( "loaded custom config from OPENCODE_CONFIG_CONTENT" )
191193 }
@@ -1292,7 +1294,8 @@ export namespace Config {
12921294 return load ( text , filepath )
12931295 }
12941296
1295- async function load ( text : string , configFilepath : string ) {
1297+ async function load ( text : string , configFilepath : string , options : { writeback ?: boolean } = { } ) {
1298+ const writeback = options . writeback ?? true
12961299 const original = text
12971300 text = text . replace ( / \{ e n v : ( [ ^ } ] + ) \} / g, ( _ , varName ) => {
12981301 return process . env [ varName ] || ""
@@ -1361,9 +1364,11 @@ export namespace Config {
13611364 if ( parsed . success ) {
13621365 if ( ! parsed . data . $schema ) {
13631366 parsed . data . $schema = "https://opencode.ai/config.json"
1364- // Write the $schema to the original text to preserve variables like {env:VAR}
1365- const updated = original . replace ( / ^ \s * \{ / , '{\n "$schema": "https://opencode.ai/config.json",' )
1366- await Filesystem . write ( configFilepath , updated ) . catch ( ( ) => { } )
1367+ if ( writeback ) {
1368+ // Write the $schema to the original text to preserve variables like {env:VAR}
1369+ const updated = original . replace ( / ^ \s * \{ / , '{\n "$schema": "https://opencode.ai/config.json",' )
1370+ await Filesystem . write ( configFilepath , updated ) . catch ( ( ) => { } )
1371+ }
13671372 }
13681373 const data = parsed . data
13691374 if ( data . plugin ) {
0 commit comments