@@ -33,6 +33,8 @@ class IdeSetup {
33
33
return this . setupRoo ( installDir , selectedAgent ) ;
34
34
case "cline" :
35
35
return this . setupCline ( installDir , selectedAgent ) ;
36
+ case "gemini" :
37
+ return this . setupGeminiCli ( installDir , selectedAgent ) ;
36
38
default :
37
39
console . log ( chalk . yellow ( `\nIDE ${ ide } not yet supported` ) ) ;
38
40
return false ;
@@ -411,6 +413,63 @@ class IdeSetup {
411
413
412
414
return true ;
413
415
}
416
+
417
+ async setupGeminiCli ( installDir , selectedAgent ) {
418
+ await initializeModules ( ) ;
419
+ const geminiDir = path . join ( installDir , ".gemini" ) ;
420
+ const agentsContextDir = path . join ( geminiDir , "agents" ) ;
421
+ await fileManager . ensureDirectory ( agentsContextDir ) ;
422
+
423
+ // Get all available agents
424
+ const agents = await this . getAllAgentIds ( installDir ) ;
425
+ const agentContextFiles = [ ] ;
426
+
427
+ for ( const agentId of agents ) {
428
+ // Find the source agent file
429
+ let agentPath = path . join ( installDir , ".bmad-core" , "agents" , `${ agentId } .md` ) ;
430
+ if ( ! ( await fileManager . pathExists ( agentPath ) ) ) {
431
+ agentPath = path . join ( installDir , "agents" , `${ agentId } .md` ) ;
432
+ }
433
+
434
+ if ( await fileManager . pathExists ( agentPath ) ) {
435
+ const agentContent = await fileManager . readFile ( agentPath ) ;
436
+ const contextFilePath = path . join ( agentsContextDir , `${ agentId } .md` ) ;
437
+
438
+ // Copy the agent content directly into its own context file
439
+ await fileManager . writeFile ( contextFilePath , agentContent ) ;
440
+
441
+ // Store the relative path for settings.json
442
+ const relativePath = path . relative ( geminiDir , contextFilePath ) ;
443
+ agentContextFiles . push ( relativePath . replace ( / \\ / g, '/' ) ) ; // Ensure forward slashes for consistency
444
+ console . log ( chalk . green ( `✓ Created context file for @${ agentId } ` ) ) ;
445
+ }
446
+ }
447
+
448
+ console . log ( chalk . green ( `\n✓ Created individual agent context files in ${ agentsContextDir } ` ) ) ;
449
+
450
+ // Create or update settings.json
451
+ const settingsPath = path . join ( geminiDir , "settings.json" ) ;
452
+ let settings = { } ;
453
+
454
+ if ( await fileManager . pathExists ( settingsPath ) ) {
455
+ try {
456
+ const existingSettings = await fileManager . readFile ( settingsPath ) ;
457
+ settings = JSON . parse ( existingSettings ) ;
458
+ console . log ( chalk . yellow ( "Found existing .gemini/settings.json. Merging settings..." ) ) ;
459
+ } catch ( e ) {
460
+ console . error ( chalk . red ( "Error parsing existing settings.json. It will be overwritten." ) , e ) ;
461
+ settings = { } ;
462
+ }
463
+ }
464
+
465
+ // Set contextFileName to our new array of files
466
+ settings . contextFileName = agentContextFiles ;
467
+
468
+ await fileManager . writeFile ( settingsPath , JSON . stringify ( settings , null , 2 ) ) ;
469
+ console . log ( chalk . green ( `✓ Configured .gemini/settings.json to load all agent context files.` ) ) ;
470
+
471
+ return true ;
472
+ }
414
473
}
415
474
416
475
module . exports = new IdeSetup ( ) ;
0 commit comments