@@ -61,103 +61,11 @@ import { builtinTools, createCallOmoAgent, createBackgroundTools, createLookAt,
6161import { BackgroundManager } from "./features/background-agent" ;
6262import { createBuiltinMcps } from "./mcp" ;
6363import { OhMyOpenCodeConfigSchema , type OhMyOpenCodeConfig , type HookName } from "./config" ;
64- import { log , deepMerge , getUserConfigDir , addConfigLoadError , parseJsonc , detectConfigFile } from "./shared" ;
64+ import { log , deepMerge , getUserConfigDir , addConfigLoadError , parseJsonc , detectConfigFile , migrateConfigFile } from "./shared" ;
6565import { PLAN_SYSTEM_PROMPT , PLAN_PERMISSION } from "./agents/plan-prompt" ;
6666import * as fs from "fs" ;
6767import * as path from "path" ;
6868
69- // Migration map: old keys → new keys (for backward compatibility)
70- const AGENT_NAME_MAP : Record < string , string > = {
71- // Legacy names (backward compatibility)
72- omo : "Sisyphus" ,
73- "OmO" : "Sisyphus" ,
74- "OmO-Plan" : "Planner-Sisyphus" ,
75- "omo-plan" : "Planner-Sisyphus" ,
76- // Current names
77- sisyphus : "Sisyphus" ,
78- "planner-sisyphus" : "Planner-Sisyphus" ,
79- build : "build" ,
80- oracle : "oracle" ,
81- librarian : "librarian" ,
82- explore : "explore" ,
83- "frontend-ui-ux-engineer" : "frontend-ui-ux-engineer" ,
84- "document-writer" : "document-writer" ,
85- "multimodal-looker" : "multimodal-looker" ,
86- } ;
87-
88- // Migration map: old hook names → new hook names (for backward compatibility)
89- const HOOK_NAME_MAP : Record < string , string > = {
90- // Legacy names (backward compatibility)
91- "anthropic-auto-compact" : "anthropic-context-window-limit-recovery" ,
92- } ;
93-
94- function migrateAgentNames ( agents : Record < string , unknown > ) : { migrated : Record < string , unknown > ; changed : boolean } {
95- const migrated : Record < string , unknown > = { } ;
96- let changed = false ;
97-
98- for ( const [ key , value ] of Object . entries ( agents ) ) {
99- const newKey = AGENT_NAME_MAP [ key . toLowerCase ( ) ] ?? AGENT_NAME_MAP [ key ] ?? key ;
100- if ( newKey !== key ) {
101- changed = true ;
102- }
103- migrated [ newKey ] = value ;
104- }
105-
106- return { migrated, changed } ;
107- }
108-
109- function migrateHookNames ( hooks : string [ ] ) : { migrated : string [ ] ; changed : boolean } {
110- const migrated : string [ ] = [ ] ;
111- let changed = false ;
112-
113- for ( const hook of hooks ) {
114- const newHook = HOOK_NAME_MAP [ hook ] ?? hook ;
115- if ( newHook !== hook ) {
116- changed = true ;
117- }
118- migrated . push ( newHook ) ;
119- }
120-
121- return { migrated, changed } ;
122- }
123-
124- function migrateConfigFile ( configPath : string , rawConfig : Record < string , unknown > ) : boolean {
125- let needsWrite = false ;
126-
127- if ( rawConfig . agents && typeof rawConfig . agents === "object" ) {
128- const { migrated, changed } = migrateAgentNames ( rawConfig . agents as Record < string , unknown > ) ;
129- if ( changed ) {
130- rawConfig . agents = migrated ;
131- needsWrite = true ;
132- }
133- }
134-
135- if ( rawConfig . omo_agent ) {
136- rawConfig . sisyphus_agent = rawConfig . omo_agent ;
137- delete rawConfig . omo_agent ;
138- needsWrite = true ;
139- }
140-
141- if ( rawConfig . disabled_hooks && Array . isArray ( rawConfig . disabled_hooks ) ) {
142- const { migrated, changed } = migrateHookNames ( rawConfig . disabled_hooks as string [ ] ) ;
143- if ( changed ) {
144- rawConfig . disabled_hooks = migrated ;
145- needsWrite = true ;
146- }
147- }
148-
149- if ( needsWrite ) {
150- try {
151- fs . writeFileSync ( configPath , JSON . stringify ( rawConfig , null , 2 ) + "\n" , "utf-8" ) ;
152- log ( `Migrated config file: ${ configPath } ` ) ;
153- } catch ( err ) {
154- log ( `Failed to write migrated config to ${ configPath } :` , err ) ;
155- }
156- }
157-
158- return needsWrite ;
159- }
160-
16169function loadConfigFromPath ( configPath : string , ctx : any ) : OhMyOpenCodeConfig | null {
16270 try {
16371 if ( fs . existsSync ( configPath ) ) {
0 commit comments