create-agent.sh 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. #!/bin/bash
  2. # Creates a new agent with proper structure
  3. set -e
  4. CATEGORY=$1
  5. AGENT=$2
  6. if [ -z "$CATEGORY" ] || [ -z "$AGENT" ]; then
  7. echo "Usage: ./create-agent.sh <category> <agent-name>"
  8. echo ""
  9. echo "Categories:"
  10. echo " core - System-level agents"
  11. echo " development - Development specialists"
  12. echo " content - Content creation specialists"
  13. echo " product - Product & strategy specialists"
  14. echo " data - Data & analysis specialists"
  15. echo " learning - Education & coaching specialists"
  16. echo ""
  17. echo "Example: ./create-agent.sh development frontend-specialist"
  18. exit 1
  19. fi
  20. AGENT_FILE=".opencode/agent/$CATEGORY/$AGENT.md"
  21. PROMPTS_DIR=".opencode/prompts/$CATEGORY/$AGENT"
  22. EVALS_DIR="evals/agents/$CATEGORY/$AGENT"
  23. # Check if agent already exists
  24. if [ -f "$AGENT_FILE" ]; then
  25. echo "❌ Agent already exists: $AGENT_FILE"
  26. exit 1
  27. fi
  28. echo "Creating agent: $CATEGORY/$AGENT"
  29. echo ""
  30. # Create agent file with template
  31. mkdir -p ".opencode/agent/$CATEGORY"
  32. agent_title=$(echo "$AGENT" | sed 's/-/ /g' | sed 's/\b\(.\)/\u\1/g')
  33. cat > "$AGENT_FILE" <<EOF
  34. ---
  35. # Basic Info
  36. id: $AGENT
  37. name: $agent_title
  38. description: Brief description of what this agent does
  39. category: $CATEGORY
  40. type: standard
  41. version: 1.0.0
  42. author: your-name
  43. # Agent Configuration
  44. mode: primary
  45. model: anthropic/claude-sonnet-4-5
  46. temperature: 0.1
  47. # Tools
  48. tools:
  49. read: true
  50. write: true
  51. edit: true
  52. bash: false
  53. glob: true
  54. grep: true
  55. task: true
  56. # Dependencies
  57. dependencies:
  58. context:
  59. - $CATEGORY/patterns
  60. tools: []
  61. # Prompt Variants
  62. variants:
  63. - gpt
  64. - llama
  65. # Tags
  66. tags:
  67. - $CATEGORY
  68. ---
  69. # $agent_title
  70. You are a specialist in...
  71. ## Your Role
  72. [Define the agent's role and responsibilities]
  73. ## Context Loading Strategy
  74. BEFORE any implementation:
  75. 1. Read project context to understand requirements
  76. 2. Load appropriate patterns from context files
  77. 3. Apply domain-specific best practices
  78. ## Workflow
  79. 1. **Analyze** - Understand the request
  80. 2. **Plan** - Create implementation plan
  81. 3. **Request Approval** - Present plan to user
  82. 4. **Implement** - Execute following patterns
  83. 5. **Validate** - Test and verify
  84. ## Best Practices
  85. - [Add domain-specific best practices]
  86. - [Add quality guidelines]
  87. - [Add common patterns]
  88. EOF
  89. echo "✅ Created agent file: $AGENT_FILE"
  90. echo " (This file IS the default prompt, optimized for Claude)"
  91. # Create prompts structure for model-specific variants
  92. mkdir -p "$PROMPTS_DIR"
  93. # Create GPT variant template
  94. cat > "$PROMPTS_DIR/gpt.md" <<EOF
  95. ---
  96. # Copy frontmatter from agent file and customize for GPT
  97. # Agent file: .opencode/agent/$CATEGORY/$AGENT.md
  98. ---
  99. # $agent_title - GPT Optimized
  100. [Customize the prompt for GPT-4/GPT-4o characteristics:
  101. - More explicit instructions
  102. - Clearer step-by-step breakdowns
  103. - More examples if needed]
  104. ## Your Role
  105. [Copy from agent file and adapt for GPT]
  106. EOF
  107. # Create Llama variant template
  108. cat > "$PROMPTS_DIR/llama.md" <<EOF
  109. ---
  110. # Copy frontmatter from agent file and customize for Llama/OSS
  111. # Agent file: .opencode/agent/$CATEGORY/$AGENT.md
  112. ---
  113. # $agent_title - Llama/OSS Optimized
  114. [Customize the prompt for Llama/OSS models:
  115. - Simpler language
  116. - More structured format
  117. - Clear delimiters and sections]
  118. ## Your Role
  119. [Copy from agent file and adapt for Llama/OSS]
  120. EOF
  121. cat > "$PROMPTS_DIR/TEMPLATE.md" <<EOF
  122. ---
  123. # Copy frontmatter from agent file (.opencode/agent/$CATEGORY/$AGENT.md)
  124. # and customize for your target model
  125. ---
  126. # Agent prompt optimized for [MODEL NAME]
  127. [Customize the prompt for specific model characteristics]
  128. EOF
  129. cat > "$PROMPTS_DIR/README.md" <<EOF
  130. # $AGENT Prompt Variants
  131. ## Default Prompt
  132. The **default prompt** is the agent file itself: \`.opencode/agent/$CATEGORY/$AGENT.md\`
  133. This is optimized for **Claude** (Anthropic models) and serves as the baseline.
  134. ## Model-Specific Variants
  135. This directory contains optimizations for other model families:
  136. | Variant | Model Family | Status | Best For |
  137. |---------|--------------|--------|----------|
  138. | gpt.md | GPT | 🚧 Experimental | GPT-4, GPT-4o |
  139. | llama.md | Llama/OSS | 🚧 Experimental | Llama, Qwen, DeepSeek |
  140. ## Testing Variants
  141. \`\`\`bash
  142. cd evals/framework
  143. # Test default (agent file itself)
  144. npm run eval:sdk -- --agent=$CATEGORY/$AGENT
  145. # Test GPT variant
  146. npm run eval:sdk -- --agent=$CATEGORY/$AGENT --prompt-variant=gpt
  147. # Test Llama variant
  148. npm run eval:sdk -- --agent=$CATEGORY/$AGENT --prompt-variant=llama
  149. \`\`\`
  150. ## Results
  151. | Variant | Pass Rate | Notes |
  152. |---------|-----------|-------|
  153. | default (agent file) | - | Not yet tested |
  154. | gpt | - | Not yet tested |
  155. | llama | - | Not yet tested |
  156. EOF
  157. echo "✅ Created prompts structure: $PROMPTS_DIR"
  158. # Create eval structure
  159. mkdir -p "$EVALS_DIR/config"
  160. mkdir -p "$EVALS_DIR/tests"
  161. cat > "$EVALS_DIR/config/config.yaml" <<EOF
  162. agent: $CATEGORY/$AGENT
  163. model: anthropic/claude-sonnet-4-5
  164. timeout: 60000
  165. EOF
  166. cat > "$EVALS_DIR/tests/smoke-test.yaml" <<EOF
  167. id: smoke-test
  168. name: "Smoke Test: $AGENT"
  169. description: Basic functionality test
  170. category: smoke
  171. agent: $CATEGORY/$AGENT
  172. model: anthropic/claude-sonnet-4-5
  173. prompt: "Hello, can you introduce yourself and explain what you do?"
  174. behavior:
  175. mustUseAnyOf: []
  176. requiresApproval: false
  177. minToolCalls: 0
  178. approvalStrategy:
  179. type: none
  180. timeout: 30000
  181. tags:
  182. - smoke-test
  183. - basic
  184. EOF
  185. cat > "$EVALS_DIR/README.md" <<EOF
  186. # $AGENT Test Suite
  187. ## Test Coverage
  188. | Category | Tests | Status |
  189. |----------|-------|--------|
  190. | Smoke | 1 | 🚧 Not yet run |
  191. ## Running Tests
  192. \`\`\`bash
  193. cd evals/framework
  194. # Run all tests
  195. npm run eval:sdk -- --agent=$CATEGORY/$AGENT
  196. # Run smoke test only
  197. npm run eval:sdk -- --agent=$CATEGORY/$AGENT --pattern="smoke-test.yaml"
  198. \`\`\`
  199. ## Test Results
  200. Not yet tested.
  201. EOF
  202. echo "✅ Created eval structure: $EVALS_DIR"
  203. # Create context directory if it doesn't exist
  204. if [ ! -d ".opencode/context/$CATEGORY" ]; then
  205. mkdir -p ".opencode/context/$CATEGORY"
  206. touch ".opencode/context/$CATEGORY/.gitkeep"
  207. echo "✅ Created context directory: .opencode/context/$CATEGORY"
  208. fi
  209. echo ""
  210. echo "========================================"
  211. echo "✅ Agent created successfully!"
  212. echo "========================================"
  213. echo ""
  214. echo "Next steps:"
  215. echo ""
  216. echo "1. Edit agent file:"
  217. echo " vim $AGENT_FILE"
  218. echo ""
  219. echo "2. Customize model-specific variants (optional):"
  220. echo " vim $PROMPTS_DIR/gpt.md # GPT optimization"
  221. echo " vim $PROMPTS_DIR/llama.md # Llama/OSS optimization"
  222. echo " Note: The agent file itself is the default prompt"
  223. echo ""
  224. echo "3. Add context files:"
  225. echo " vim .opencode/context/$CATEGORY/patterns.md"
  226. echo ""
  227. echo "4. Create tests:"
  228. echo " vim $EVALS_DIR/tests/your-test.yaml"
  229. echo ""
  230. echo "5. Validate structure:"
  231. echo " ./scripts/registry/validate-agent-structure.sh"
  232. echo ""
  233. echo "6. Test agent:"
  234. echo " cd evals/framework"
  235. echo " npm run eval:sdk -- --agent=$CATEGORY/$AGENT"
  236. echo ""