@@ -21,6 +21,17 @@ export namespace Config {
2121 result = mergeDeep ( result , await load ( resolved ) )
2222 }
2323 }
24+
25+ // Handle migration from autoshare to share field
26+ if ( result . autoshare === true && ! result . share ) {
27+ result . share = "auto"
28+ }
29+
30+ if ( ! result . username ) {
31+ const os = await import ( "os" )
32+ result . username = os . userInfo ( ) . username
33+ }
34+
2435 log . info ( "loaded" , result )
2536
2637 return result
@@ -117,12 +128,21 @@ export namespace Config {
117128 $schema : z . string ( ) . optional ( ) . describe ( "JSON schema reference for configuration validation" ) ,
118129 theme : z . string ( ) . optional ( ) . describe ( "Theme name to use for the interface" ) ,
119130 keybinds : Keybinds . optional ( ) . describe ( "Custom keybind configurations" ) ,
120- share : z . enum ( [ "auto" , "disabled" ] ) . optional ( ) . describe ( "Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables all sharing" ) ,
121- autoshare : z . boolean ( ) . optional ( ) . describe ( "@deprecated Use 'share' field instead. Share newly created sessions automatically" ) ,
131+ share : z
132+ . enum ( [ "auto" , "disabled" ] )
133+ . optional ( )
134+ . describe ( "Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables all sharing" ) ,
135+ autoshare : z
136+ . boolean ( )
137+ . optional ( )
138+ . describe ( "@deprecated Use 'share' field instead. Share newly created sessions automatically" ) ,
122139 autoupdate : z . boolean ( ) . optional ( ) . describe ( "Automatically update to the latest version" ) ,
123140 disabled_providers : z . array ( z . string ( ) ) . optional ( ) . describe ( "Disable providers that are loaded automatically" ) ,
124141 model : z . string ( ) . describe ( "Model to use in the format of provider/model, eg anthropic/claude-2" ) . optional ( ) ,
125- username : z . string ( ) . optional ( ) . describe ( "Custom username to display in conversations instead of system username" ) ,
142+ username : z
143+ . string ( )
144+ . optional ( )
145+ . describe ( "Custom username to display in conversations instead of system username" ) ,
126146 mode : z
127147 . object ( {
128148 build : Mode . optional ( ) ,
@@ -234,11 +254,6 @@ export namespace Config {
234254
235255 const parsed = Info . safeParse ( data )
236256 if ( parsed . success ) {
237- // Handle migration from autoshare to share field
238- if ( parsed . data . autoshare === true && ! parsed . data . share ) {
239- parsed . data . share = "auto"
240- }
241-
242257 if ( ! parsed . data . $schema ) {
243258 parsed . data . $schema = "https://opencode.ai/config.json"
244259 await Bun . write ( configPath , JSON . stringify ( parsed . data , null , 2 ) )
@@ -265,6 +280,4 @@ export namespace Config {
265280 export function get ( ) {
266281 return state ( )
267282 }
268-
269-
270283}
0 commit comments