|
| 1 | +# OpenCode Agent Subfolder Structure |
| 2 | + |
| 3 | +This document describes the new subfolder organization for OpenCode agents and the platform-specific management system. |
| 4 | + |
| 5 | +## Directory Structure |
| 6 | + |
| 7 | +``` |
| 8 | +.opencode/agent/ |
| 9 | +├── common/ # Always active agents |
| 10 | +│ ├── agent-orchestrator.md |
| 11 | +│ ├── code-reviewer.md |
| 12 | +│ ├── test-engineer.md |
| 13 | +│ └── ... |
| 14 | +├── platforms/ # Platform-specific agents |
| 15 | +│ ├── codeberg/ |
| 16 | +│ │ ├── codeberg-specialist.md |
| 17 | +│ │ └── codeberg-workflow-manager.md |
| 18 | +│ ├── github/ |
| 19 | +│ │ ├── github-specialist.md.disabled |
| 20 | +│ │ └── github-workflow-manager.md.disabled |
| 21 | +│ └── ... |
| 22 | +├── domains/ # Domain-specific agents |
| 23 | +│ ├── api/ |
| 24 | +│ │ ├── api-designer.md |
| 25 | +│ │ └── database-specialist.md |
| 26 | +│ ├── ui/ |
| 27 | +│ │ └── ui-ux-designer.md |
| 28 | +│ └── auth/ |
| 29 | +└── general/ # General-purpose agents |
| 30 | + ├── agent-creator.md |
| 31 | + ├── code-architect.md |
| 32 | + └── ... |
| 33 | +``` |
| 34 | + |
| 35 | +## Platform Management |
| 36 | + |
| 37 | +### Automatic Platform Detection |
| 38 | + |
| 39 | +The system automatically detects your git platform based on repository files: |
| 40 | + |
| 41 | +```bash |
| 42 | +# Detect platform |
| 43 | +npm run platform:detect |
| 44 | + |
| 45 | +# Output: Detected platform: codeberg |
| 46 | +``` |
| 47 | + |
| 48 | +### Manual Platform Activation |
| 49 | + |
| 50 | +```bash |
| 51 | +# Activate Codeberg agents |
| 52 | +npm run platform:codeberg |
| 53 | + |
| 54 | +# Activate GitHub agents |
| 55 | +npm run platform:github |
| 56 | + |
| 57 | +# Activate other platforms |
| 58 | +npm run platform:gitlab |
| 59 | +npm run platform:gitea |
| 60 | +npm run platform:forgejo |
| 61 | +``` |
| 62 | + |
| 63 | +### Setup for New Projects |
| 64 | + |
| 65 | +```bash |
| 66 | +# Auto-setup based on detected platform |
| 67 | +npm run platform:setup |
| 68 | + |
| 69 | +# This will: |
| 70 | +# 1. Detect your git platform |
| 71 | +# 2. Activate appropriate agents |
| 72 | +# 3. Deactivate conflicting agents |
| 73 | +``` |
| 74 | + |
| 75 | +## Agent Categories |
| 76 | + |
| 77 | +### Common Agents (Always Active) |
| 78 | +- **agent-orchestrator**: Coordinates complex tasks |
| 79 | +- **code-reviewer**: Code quality and security analysis |
| 80 | +- **test-engineer**: Testing strategy and implementation |
| 81 | +- **security-auditor**: Security assessments |
| 82 | +- **performance-optimizer**: Performance analysis |
| 83 | +- **documentation-maintainer**: Documentation management |
| 84 | + |
| 85 | +### Platform-Specific Agents |
| 86 | +- **codeberg-specialist**: Codeberg repository management |
| 87 | +- **github-specialist**: GitHub repository management |
| 88 | +- **gitlab-specialist**: GitLab repository management |
| 89 | +- **gitea-specialist**: Gitea repository management |
| 90 | +- **forgejo-specialist**: Forgejo repository management |
| 91 | + |
| 92 | +### Domain-Specific Agents |
| 93 | +- **api-designer**: RESTful and GraphQL API design |
| 94 | +- **database-specialist**: Database schema and optimization |
| 95 | +- **ui-ux-designer**: User interface and experience design |
| 96 | + |
| 97 | +### General-Purpose Agents |
| 98 | +- **agent-creator**: Create and manage OpenCode agents |
| 99 | +- **code-architect**: System architecture design |
| 100 | +- **ci-cd-manager**: CI/CD pipeline management |
| 101 | +- **deployment-specialist**: Deployment and environment management |
| 102 | + |
| 103 | +## Scripts |
| 104 | + |
| 105 | +### Platform Management |
| 106 | +```bash |
| 107 | +npm run platform:detect # Detect git platform |
| 108 | +npm run platform:setup # Auto-setup for detected platform |
| 109 | +npm run platform:codeberg # Activate Codeberg agents |
| 110 | +npm run platform:github # Activate GitHub agents |
| 111 | +npm run platform:gitlab # Activate GitLab agents |
| 112 | +npm run platform:gitea # Activate Gitea agents |
| 113 | +npm run platform:forgejo # Activate Forgejo agents |
| 114 | +``` |
| 115 | + |
| 116 | +### Agent Management |
| 117 | +```bash |
| 118 | +npm run agents:list # List active agents |
| 119 | +npm run agents:validate # Validate agent dependencies |
| 120 | +npm run agents:clean # Remove deactivated agents |
| 121 | +``` |
| 122 | + |
| 123 | +## Agent Dependencies |
| 124 | + |
| 125 | +The system includes dependency management to ensure proper agent activation: |
| 126 | + |
| 127 | +```json |
| 128 | +{ |
| 129 | + "codeberg-specialist": { |
| 130 | + "requires": ["agent-orchestrator"], |
| 131 | + "conflicts": ["github-specialist", "gitlab-specialist"], |
| 132 | + "platform": "codeberg" |
| 133 | + } |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | +### Validation |
| 138 | +```bash |
| 139 | +npm run agents:validate |
| 140 | +``` |
| 141 | + |
| 142 | +This checks: |
| 143 | +- Required agents are present and active |
| 144 | +- Conflicting agents are not active |
| 145 | +- Platform-specific agents match the current platform |
| 146 | + |
| 147 | +## File Organization Rules |
| 148 | + |
| 149 | +### Agent File Naming |
| 150 | +- Active agents: `agent-name.md` |
| 151 | +- Inactive agents: `agent-name.md.disabled` |
| 152 | + |
| 153 | +### Platform Detection Logic |
| 154 | +1. Check for `.codeberg/` directory → Codeberg |
| 155 | +2. Check for `.github/workflows/` → GitHub |
| 156 | +3. Check for `.gitlab-ci.yml` → GitLab |
| 157 | +4. Check for `.gitea/` directory → Gitea |
| 158 | +5. Check for `.forgejo/` directory → Forgejo |
| 159 | +6. Default to generic |
| 160 | + |
| 161 | +## Migration Guide |
| 162 | + |
| 163 | +### For Existing Projects |
| 164 | + |
| 165 | +1. **Backup current agents**: |
| 166 | + ```bash |
| 167 | + cp -r .opencode/agent .opencode/agent.backup |
| 168 | + ``` |
| 169 | + |
| 170 | +2. **Run platform setup**: |
| 171 | + ```bash |
| 172 | + npm run platform:setup |
| 173 | + ``` |
| 174 | + |
| 175 | +3. **Validate setup**: |
| 176 | + ```bash |
| 177 | + npm run agents:validate |
| 178 | + npm run agents:list |
| 179 | + ``` |
| 180 | + |
| 181 | +### For New Projects |
| 182 | + |
| 183 | +1. **Initialize with platform detection**: |
| 184 | + ```bash |
| 185 | + npm run platform:setup |
| 186 | + ``` |
| 187 | + |
| 188 | +2. **Customize as needed**: |
| 189 | + ```bash |
| 190 | + # Edit agent configurations |
| 191 | + # Add domain-specific agents |
| 192 | + # Modify platform-specific settings |
| 193 | + ``` |
| 194 | + |
| 195 | +## Best Practices |
| 196 | + |
| 197 | +### 1. Platform Consistency |
| 198 | +- Use the same platform for all repositories in an organization |
| 199 | +- Document platform choice in project README |
| 200 | +- Set up platform-specific CI/CD workflows |
| 201 | + |
| 202 | +### 2. Agent Customization |
| 203 | +- Start with common agents for all projects |
| 204 | +- Add platform-specific agents based on needs |
| 205 | +- Create domain-specific agents for complex projects |
| 206 | + |
| 207 | +### 3. Dependency Management |
| 208 | +- Always run validation after agent changes |
| 209 | +- Check for conflicts before activating new agents |
| 210 | +- Keep agent dependencies documented |
| 211 | + |
| 212 | +### 4. Version Control |
| 213 | +- Commit active agent configurations |
| 214 | +- Use .disabled for inactive agents (they're ignored) |
| 215 | +- Document platform-specific customizations |
| 216 | + |
| 217 | +## Troubleshooting |
| 218 | + |
| 219 | +### Platform Not Detected |
| 220 | +```bash |
| 221 | +# Check repository structure |
| 222 | +ls -la | grep -E '\.(github|codeberg|gitlab|gitea|forgejo)' |
| 223 | + |
| 224 | +# Manual platform activation |
| 225 | +npm run platform:codeberg # or your platform |
| 226 | +``` |
| 227 | + |
| 228 | +### Agent Conflicts |
| 229 | +```bash |
| 230 | +# Validate dependencies |
| 231 | +npm run agents:validate |
| 232 | + |
| 233 | +# Check active agents |
| 234 | +npm run agents:list |
| 235 | + |
| 236 | +# Clean up deactivated agents |
| 237 | +npm run agents:clean |
| 238 | +``` |
| 239 | + |
| 240 | +### Missing Required Agents |
| 241 | +```bash |
| 242 | +# Check if required agents exist |
| 243 | +find .opencode/agent -name "*required-agent*" |
| 244 | + |
| 245 | +# Re-run platform setup |
| 246 | +npm run platform:setup |
| 247 | +``` |
| 248 | + |
| 249 | +## Integration with CI/CD |
| 250 | + |
| 251 | +### GitHub Actions Example |
| 252 | +```yaml |
| 253 | +- name: Setup OpenCode Platform |
| 254 | + run: npm run platform:setup |
| 255 | + |
| 256 | +- name: Validate Agent Configuration |
| 257 | + run: npm run agents:validate |
| 258 | +``` |
| 259 | +
|
| 260 | +### Codeberg Actions Example |
| 261 | +```yaml |
| 262 | +- name: Setup OpenCode Platform |
| 263 | + run: npm run platform:setup |
| 264 | + |
| 265 | +- name: Validate Agent Configuration |
| 266 | + run: npm run agents:validate |
| 267 | +``` |
| 268 | +
|
| 269 | +This subfolder structure provides excellent organization, platform flexibility, and maintainability for OpenCode projects. |
0 commit comments