@@ -76,37 +76,14 @@ export async function enterAgentsBuffer(rl: any, onExit: () => void) {
7676 } ,
7777 ]
7878
79- // Add edit option if there are custom agents
79+ // Get custom agent files for display purposes
8080 const agentsDir = path . join ( getProjectRoot ( ) , AGENT_TEMPLATES_DIR )
8181 let customAgentFiles : string [ ] = [ ]
8282 if ( fs . existsSync ( agentsDir ) ) {
8383 const files = fs . readdirSync ( agentsDir )
8484 customAgentFiles = filterCustomAgentFiles ( files )
8585 }
8686
87- if ( customAgentFiles . length > 0 ) {
88- const cliInstance = CLI . getInstance ( )
89-
90- const editAgentOption =
91- cliInstance . agent === AgentTemplateTypes . sonnet4_agent_builder
92- ? {
93- id : '__edit_agent__' ,
94- name : '← Back to Base Agent' ,
95- description : 'Switch back to the default Codebuff assistant' ,
96- isBuiltIn : false ,
97- isEditAgent : true ,
98- }
99- : {
100- id : '__edit_agent__' ,
101- name : '✏️ Edit Agents' ,
102- description : 'Edit existing custom agents' ,
103- isBuiltIn : false ,
104- isEditAgent : true ,
105- }
106-
107- actions . push ( editAgentOption )
108- }
109-
11087 // Add agents section header
11188 actions . push ( {
11289 id : '__agents_header__' ,
@@ -417,7 +394,7 @@ function renderAgentsList() {
417394 }
418395
419396 // Display status line at bottom
420- const statusLine = `\n${ gray ( `Use ↑/↓/j/k to navigate, Enter to select, n to create new, ESC to go back` ) } `
397+ const statusLine = `\n${ gray ( `Use ↑/↓/j/k to navigate, Enter to select, ESC to go back` ) } `
421398
422399 process . stdout . write ( statusLine )
423400 process . stdout . write ( HIDE_CURSOR )
@@ -462,10 +439,7 @@ function setupAgentsKeyHandler(rl: any, onExit: () => void) {
462439
463440 if ( selectedAgent . isCreateNew ) {
464441 exitAgentsBuffer ( rl )
465- startAgentCreationChat ( rl , onExit , ( ) => { } )
466- } else if ( selectedAgent . isEditAgent ) {
467- exitAgentsBuffer ( rl )
468- startAgentEditFlow ( rl , onExit )
442+ startDirectAgentCreation ( onExit )
469443 } else {
470444 exitAgentsBuffer ( rl )
471445 // Start spinner for agent switching
@@ -504,7 +478,6 @@ function setupAgentsKeyHandler(rl: any, onExit: () => void) {
504478 centerSelectedItem ( )
505479 }
506480
507- const statusLine = `\n${ gray ( `Use ↑/↓/j/k to navigate, Enter to select, ESC to go back` ) } `
508481 renderAgentsList ( )
509482 return
510483 }
@@ -571,93 +544,25 @@ function setupAgentsKeyHandler(rl: any, onExit: () => void) {
571544 }
572545}
573546
574- function startAgentCreationChatHandler ( rl : any , onExit : ( ) => void ) {
575- startAgentCreationChat ( rl , onExit , async ( requirements ) => {
576- await createAgentFromRequirements ( requirements )
577- onExit ( )
578- } )
579- }
580-
581- function startAgentEditFlow ( rl : any , onExit : ( ) => void ) {
582- const cliInstance = CLI . getInstance ( )
583-
584- if ( cliInstance . agent === AgentTemplateTypes . sonnet4_agent_builder ) {
585- cliInstance
586- . resetAgent ( undefined ) // Reset to base agent (no specific agent)
587- . then ( ( ) => {
588- cliInstance . freshPrompt ( )
589- } )
590- . catch ( ( error ) => {
591- console . error ( red ( 'Error switching back to base agent:' ) , error )
592- onExit ( )
593- } )
594- return
595- }
547+ function startDirectAgentCreation ( onExit : ( ) => void ) {
548+ // Send request directly to @Bob the Agent Builder without questionnaire
549+ const prompt = `@Bob the Agent Builder create a new custom agent template for me. Please ask me what kind of agent I'd like to create and help me build it.`
596550
597- // Get list of custom agents to show in the prompt
598- const agentsDir = path . join ( getProjectRoot ( ) , AGENT_TEMPLATES_DIR )
599- if ( ! fs . existsSync ( agentsDir ) ) {
600- console . log ( yellow ( 'No custom agents found to edit.' ) )
601- onExit ( )
602- return
603- }
551+ console . log (
552+ green ( '\n🤖 Starting agent creation with Bob the Agent Builder...' ) ,
553+ )
554+ console . log ( gray ( 'Tell Bob what kind of agent you want to create.' ) )
604555
605- const files = fs . readdirSync ( agentsDir )
606- const customAgentFiles = filterCustomAgentFiles ( files )
556+ const cliInstance = CLI . getInstance ( )
557+ // Pre-fill the prompt and simulate Enter key press to send it
558+ cliInstance . freshPrompt ( prompt )
607559
608- if ( customAgentFiles . length === 0 ) {
609- console . log ( yellow ( 'No custom agents found to edit.' ) )
610- onExit ( )
611- return
612- }
560+ // Simulate pressing Enter to send the prompt
561+ setTimeout ( ( ) => {
562+ cliInstance . rl . write ( '\n' )
563+ } , 100 )
613564
614- // Build list of available agents for the prompt
615- const localAgents = getLoadedAgentNames ( )
616- const agentsList = customAgentFiles
617- . map ( ( file ) => {
618- const agentId = extractAgentIdFromFileName ( file )
619- const agentName = localAgents [ agentId ] || agentId
620- const filePath = path . join ( agentsDir , file )
621- return `- **${ agentName } ** (${ agentId } ) - ${ path . relative ( getProjectRoot ( ) , filePath ) } `
622- } )
623- . join ( '\n' )
624-
625- // Create edit prompt for agent-builder
626- const editPrompt = `I want to edit one of my existing custom agent templates. Here are the available agents:
627-
628- ${ agentsList }
629-
630- Please help me modify one of these agents. Just tell me which agent you'd like to edit and what changes you want to make. I can:
631- - Change the agent's name, purpose, or specialty
632- - Update the system prompt
633- - Modify the tools and capabilities
634- - Adjust the model or other settings
635- - Update the parentInstructions
636-
637- Which agent would you like to edit and what changes do you want to make?`
638-
639- // Use the agent-builder to edit agents
640- cliInstance
641- . resetAgent (
642- AgentTemplateTypes . sonnet4_agent_builder ,
643- {
644- editMode : true ,
645- } ,
646- editPrompt ,
647- )
648- . then ( ( ) => {
649- console . log ( green ( `\n✏️ Ready to edit your agents!` ) )
650- console . log (
651- gray (
652- 'Tell the agent-builder which agent to edit and what changes to make.' ,
653- ) ,
654- )
655- cliInstance . freshPrompt ( )
656- } )
657- . catch ( ( error ) => {
658- console . error ( red ( 'Error starting agent edit:' ) , error )
659- onExit ( )
660- } )
565+ onExit ( )
661566}
662567
663568// Cleanup function
0 commit comments