|
| 1 | +import type { AgentConfig } from './types/agent-config' |
| 2 | + |
| 3 | +const config: AgentConfig = { |
| 4 | + id: 'sonnet4-agent-builder', |
| 5 | + displayName: 'Bob the Agent Builder', |
| 6 | + model: 'anthropic/claude-4-sonnet-20250522', |
| 7 | + inputSchema: { |
| 8 | + prompt: { |
| 9 | + description: 'What agent type you would like to create or edit.', |
| 10 | + type: 'string', |
| 11 | + }, |
| 12 | + }, |
| 13 | + outputMode: 'json', |
| 14 | + includeMessageHistory: false, |
| 15 | + toolNames: [ |
| 16 | + 'write_file', |
| 17 | + 'str_replace', |
| 18 | + 'run_terminal_command', |
| 19 | + 'read_files', |
| 20 | + 'code_search', |
| 21 | + 'spawn_agents', |
| 22 | + 'add_message', |
| 23 | + 'set_output', |
| 24 | + 'end_turn', |
| 25 | + ], |
| 26 | + subagents: ['file-picker'], |
| 27 | + parentPrompt: |
| 28 | + 'Creates new agent templates for the codebuff mult-agent system', |
| 29 | + systemPrompt: |
| 30 | + '# Agent Builder\n\nYou are an expert agent builder specialized in creating new agent templates for the codebuff system. You have comprehensive knowledge of the agent template architecture and can create well-structured, purpose-built agents.\n\n## Agent Template Patterns\n\n1. **Base Agent Pattern**: Full-featured agents with comprehensive tool access\n2. **Specialized Agent Pattern**: Focused agents with limited tool sets\n3. **Thinking Agent Pattern**: Agents that spawn thinker sub-agents\n4. **Research Agent Pattern**: Agents that start with web search\n\n## Best Practices\n\n1. **Use as few fields as possible**: Leave out fields that are not needed to reduce complexity\n2. **Minimal Tools**: Only include tools the agent actually needs\n3. **Clear and Concise Prompts**: Write clear, specific prompts that have no unnecessary words\n4. **Consistent Naming**: Follow naming conventions (kebab-case for IDs)\n5. **Appropriate Model**: Choose the right model for the task complexity\n\n## Your Task\n\nWhen asked to create an agent template, you should:\n1. Understand the requested agent\'s purpose and capabilities\n2. Choose appropriate tools for the agent\'s function\n3. Write a comprehensive system prompt\n4. Create the complete agent template file in .agents/\n5. Ensure the template follows all conventions and best practices\n6. Use the AgentConfig interface for the configuration\n7. Start the file with: import type { AgentConfig } from "./types/agent-config"\n\nCreate agent templates that are focused, efficient, and well-documented. Always import the AgentConfig type and export a default configuration object.', |
| 31 | + instructionsPrompt: |
| 32 | + "You are helping to create or edit an agent template. The user will describe what kind of agent they want to create or how they want to modify an existing agent.\n\n## Example Agents for Reference\n\nYou have access to three example agents in `.agents/examples/` that demonstrate different complexity levels:\n\n1. **Level 1 - Code Reviewer**: Simple agent with basic tools (read_files, write_file, set_output, end_turn)\n2. **Level 2 - Test Generator**: Intermediate agent with subagents and handleSteps logic\n3. **Level 3 - Documentation Writer**: Advanced agent with comprehensive tools, multiple subagents, and complex orchestration\n\n**IMPORTANT**: When creating new agents, first examine these examples to find connections and patterns that relate to the user's request. Look for:\n- Similar tool combinations\n- Comparable complexity levels\n- Related functionality patterns\n- Appropriate model choices\n- Relevant prompt structures\n\nUse these examples as inspiration and starting points, adapting their patterns to fit the user's specific needs.\n\nFor new agents, analyze their request and create a complete agent template that:\n- Has a clear purpose and appropriate capabilities\n- Leaves out fields that are not needed\n- Uses only the tools it needs\n- Follows naming conventions\n- Is properly structured\n- Draws inspiration from relevant example agents\n\nFor editing existing agents:\n- First read the existing agent file they want to edit using read_files\n- Understand the current structure and functionality\n- Make the requested changes while preserving what works\n- Maintain best practices and ensure the agent still works effectively\n- Use str_replace for targeted edits or write_file for major restructuring\n\nWhen editing, always start by reading the current agent file to understand its structure before making changes. Ask clarifying questions if needed, then create or update the template file in the appropriate location.\n\nIMPORTANT: Always end your response with the end_turn tool when you have completed the agent creation or editing task.", |
| 33 | + stepPrompt: '', |
| 34 | + |
| 35 | + // Generator function that defines the agent's execution flow |
| 36 | + handleSteps: function* ({ agentState, prompt, params }) { |
| 37 | + const AGENT_TEMPLATES_DIR = '.agents' |
| 38 | + const TYPES_DIR = `${AGENT_TEMPLATES_DIR}/types` |
| 39 | + const TEMPLATE_TYPES_PATH = `${TYPES_DIR}/agent-config.d.ts` |
| 40 | + const TOOL_DEFINITIONS_PATH = `${TYPES_DIR}/tools.d.ts` |
| 41 | + |
| 42 | + // Step 1: Create directory structure |
| 43 | + yield { |
| 44 | + toolName: 'run_terminal_command', |
| 45 | + args: { |
| 46 | + command: `mkdir -p ${TYPES_DIR}`, |
| 47 | + process_type: 'SYNC', |
| 48 | + timeout_seconds: 10, |
| 49 | + }, |
| 50 | + } |
| 51 | + |
| 52 | + // Step 2: Read and write the agent config template |
| 53 | + const { toolResult: configResult } = yield { |
| 54 | + toolName: 'read_files', |
| 55 | + args: { |
| 56 | + paths: ['common/src/util/types/agent-config.ts'], |
| 57 | + }, |
| 58 | + } |
| 59 | + |
| 60 | + if (configResult?.result) { |
| 61 | + yield { |
| 62 | + toolName: 'write_file', |
| 63 | + args: { |
| 64 | + path: TEMPLATE_TYPES_PATH, |
| 65 | + instructions: 'Create agent template type definitions file', |
| 66 | + content: configResult.result, |
| 67 | + }, |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + // Step 3: Read and write the tools definitions |
| 72 | + const { toolResult: toolsResult } = yield { |
| 73 | + toolName: 'read_files', |
| 74 | + args: { |
| 75 | + paths: ['common/src/util/types/tools.d.ts'], |
| 76 | + }, |
| 77 | + } |
| 78 | + |
| 79 | + if (toolsResult?.result) { |
| 80 | + yield { |
| 81 | + toolName: 'write_file', |
| 82 | + args: { |
| 83 | + path: TOOL_DEFINITIONS_PATH, |
| 84 | + instructions: 'Create tools type file', |
| 85 | + content: toolsResult.result, |
| 86 | + }, |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + // Step 4: Copy example agents for reference |
| 91 | + const { toolResult: exampleAgentsResult } = yield { |
| 92 | + toolName: 'read_files', |
| 93 | + args: { |
| 94 | + paths: [ |
| 95 | + 'common/src/util/example-1.ts', |
| 96 | + 'common/src/util/example-2.ts', |
| 97 | + 'common/src/util/example-3.ts', |
| 98 | + ], |
| 99 | + }, |
| 100 | + } |
| 101 | + |
| 102 | + if (exampleAgentsResult?.result) { |
| 103 | + const exampleFiles = exampleAgentsResult.result |
| 104 | + .split('\n\n') |
| 105 | + .filter(Boolean) |
| 106 | + |
| 107 | + // Write example 1 |
| 108 | + if (exampleFiles[0]) { |
| 109 | + yield { |
| 110 | + toolName: 'write_file', |
| 111 | + args: { |
| 112 | + path: `${AGENT_TEMPLATES_DIR}/example-1.ts`, |
| 113 | + instructions: 'Copy example 1 agent', |
| 114 | + content: exampleFiles[0], |
| 115 | + }, |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + // Write example 2 |
| 120 | + if (exampleFiles[1]) { |
| 121 | + yield { |
| 122 | + toolName: 'write_file', |
| 123 | + args: { |
| 124 | + path: `${AGENT_TEMPLATES_DIR}/example-2.ts`, |
| 125 | + instructions: 'Copy example 2 agent', |
| 126 | + content: exampleFiles[1], |
| 127 | + }, |
| 128 | + } |
| 129 | + } |
| 130 | + |
| 131 | + // Write example 3 |
| 132 | + if (exampleFiles[2]) { |
| 133 | + yield { |
| 134 | + toolName: 'write_file', |
| 135 | + args: { |
| 136 | + path: `${AGENT_TEMPLATES_DIR}/example-3.ts`, |
| 137 | + instructions: 'Copy example 3 agent', |
| 138 | + content: exampleFiles[2], |
| 139 | + }, |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + |
| 144 | + // Step 5: Let the agent ask questions and understand what the user wants |
| 145 | + yield 'STEP_ALL' |
| 146 | + }, |
| 147 | +} |
| 148 | + |
| 149 | +export default config |
0 commit comments