# Self-Evolution Protocol When task requirements exceed existing agent capabilities. ## Trigger Conditions 1. No agent matches task requirements 2. Required domain knowledge not in any skill 3. Complex multi-step task needs new workflow pattern 4. `@capability-analyst` reports critical gap ## Evolution Flow ``` [Gap Detected] ↓ 1. Create Gitea Milestone → "[Evolution] {gap_description}" ↓ 2. Create Research Issue → Track research phase ↓ 3. Run History Search → @history-miner checks git history ↓ 4. Analyze Gap → @capability-analyst classifies gap ↓ 5. Design Component → @agent-architect creates specification ↓ 6. Decision: Agent/Skill/Workflow? ↓ 7. Create File → .kilo/agents/{name}.md (or skill/workflow) ↓ 8. Self-Modify → Add permission to orchestrator.md whitelist ↓ 9. Update capability-index.yaml → Register capabilities ↓ 10. Verify Access → Test call to new agent ↓ 11. Update Documentation → KILO_SPEC.md, AGENTS.md, EVOLUTION_LOG.md ↓ 12. Close Milestone → Record results in Gitea ↓ [New Capability Available] ``` ## Self-Modification Rules 1. ONLY modify own permission whitelist 2. NEVER modify other agents' definitions 3. ALWAYS create milestone before changes 4. ALWAYS verify access after changes 5. ALWAYS log results to `.kilo/EVOLUTION_LOG.md` 6. NEVER skip verification step ## Evolution Triggers - Task type not in capability Routing Map - capability-analyst reports critical gap - Repeated task failures for same reason - User requests new specialized capability ## File Modifications (in order) 1. Create `.kilo/agents/{new-agent}.md` (or skill/workflow) 2. Update `.kilo/agents/orchestrator.md` (add permission) 3. Update `.kilo/capability-index.yaml` (register capabilities) 4. Update `.kilo/KILO_SPEC.md` (document) 5. Update `AGENTS.md` (reference) 6. Append to `.kilo/EVOLUTION_LOG.md` (log entry) ## Verification Checklist After each evolution: - [ ] Agent file created and valid YAML frontmatter - [ ] Permission added to orchestrator.md - [ ] Capability registered in capability-index.yaml - [ ] Test call succeeds (Task tool returns valid response) - [ ] KILO_SPEC.md updated with new agent - [ ] AGENTS.md updated with new agent - [ ] EVOLUTION_LOG.md updated with entry - [ ] Gitea milestone closed with results