diff --git a/.kilo/KILO_SPEC.md b/.kilo/KILO_SPEC.md index 567e7d0..47a29a3 100644 --- a/.kilo/KILO_SPEC.md +++ b/.kilo/KILO_SPEC.md @@ -415,33 +415,35 @@ Provider availability depends on configuration. Common providers include: | Agent | Role | Model | |-------|------|-------| -| `@RequirementRefiner` | Converts vague ideas to strict User Stories | ollama-cloud/kimi-k2-thinking | -| `@HistoryMiner` | Finds duplicates and past solutions in git | ollama-cloud/nemotron-3-super | -| `@SystemAnalyst` | Designs technical specifications | qwen/qwen3.6-plus:free | -| `@SDETEngineer` | Writes tests following TDD | ollama-cloud/qwen3-coder:480b | -| `@LeadDeveloper` | Primary code writer | ollama-cloud/qwen3-coder:480b | -| `@FrontendDeveloper` | UI implementation with multimodal | ollama-cloud/kimi-k2.5 | -| `@CodeSkeptic` | Adversarial code reviewer | ollama-cloud/minimax-m2.5 | -| `@TheFixer` | Iteratively fixes bugs | ollama-cloud/minimax-m2.5 | -| `@PerformanceEngineer` | Reviews for performance issues | ollama-cloud/nemotron-3-super | -| `@SecurityAuditor` | Scans for vulnerabilities | ollama-cloud/nemotron-3-super | -| `@ReleaseManager` | Git operations and deployments | ollama-cloud/devstral-2:123b | -| `@Evaluator` | Scores agent effectiveness | ollama-cloud/nemotron-3-super | -| `@PromptOptimizer` | Improves agent prompts | qwen/qwen3.6-plus:free | -| `@ProductOwner` | Manages issue checklists | ollama-cloud/glm-5 | -| `@Orchestrator` | Routes tasks between agents | ollama-cloud/glm-5 | -| `@AgentArchitect` | Manages agent network per Kilo.ai spec | ollama-cloud/nemotron-3-super | -| `@CapabilityAnalyst` | Analyzes task coverage, identifies gaps | ollama-cloud/nemotron-3-super | -| `@MarkdownValidator` | Validates Markdown for Gitea issues | ollama-cloud/nemotron-3-nano:30b | -| `@BackendDeveloper` | Node.js, Express, APIs, database specialist | ollama-cloud/deepseek-v3.2 | -| `@GoDeveloper` | Go, Gin, Echo, concurrent systems specialist | ollama-cloud/qwen3-coder:480b | -| `@DevOpsEngineer` | Docker, Kubernetes, CI/CD, infrastructure | ollama-cloud/deepseek-v3.2 | -| `@WorkflowArchitect` | Creates workflow definitions with complete architecture | ollama-cloud/gpt-oss:120b | -| `@BrowserAutomation` | Playwright E2E testing, browser automation | ollama-cloud/glm-5 | -| `@VisualTester` | Visual regression testing with pixelmatch | ollama-cloud/glm-5 | -| `@Planner` | Task decomposition, CoT, ToT planning | ollama-cloud/nemotron-3-super | -| `@Reflector` | Self-reflection, lesson extraction | ollama-cloud/nemotron-3-super | -| `@MemoryManager` | Memory systems, context retrieval | ollama-cloud/nemotron-3-super | +| `@RequirementRefiner` | Converts vague ideas and bug reports into strict User Stories with acceptance criteria checklists. | ollama-cloud/kimi-k2-thinking | +| `@HistoryMiner` | Analyzes git history to find duplicates and past solutions, preventing regression and duplicate work. | ollama-cloud/nemotron-3-super | +| `@SystemAnalyst` | Designs technical specifications, data schemas, and API contracts before implementation. | qwen/qwen3.6-plus:free | +| `@SdetEngineer` | Writes tests following TDD methodology. | ollama-cloud/qwen3-coder:480b | +| `@LeadDeveloper` | Primary code writer for backend and core logic. | ollama-cloud/qwen3-coder:480b | +| `@FrontendDeveloper` | Handles UI implementation with multimodal capabilities. | ollama-cloud/kimi-k2.5 | +| `@BackendDeveloper` | Backend specialist for Node. | ollama-cloud/deepseek-v3.2 | +| `@GoDeveloper` | Go backend specialist for Gin, Echo, APIs, and database integration. | ollama-cloud/qwen3-coder:480b | +| `@DevopsEngineer` | DevOps specialist for Docker, Kubernetes, CI/CD pipeline automation, and infrastructure management. | ollama-cloud/deepseek-v3.2 | +| `@CodeSkeptic` | Adversarial code reviewer. | ollama-cloud/minimax-m2.5 | +| `@TheFixer` | Iteratively fixes bugs based on specific error reports and test failures. | ollama-cloud/minimax-m2.5 | +| `@PerformanceEngineer` | Reviews code for performance issues. | ollama-cloud/nemotron-3-super | +| `@SecurityAuditor` | Scans for security vulnerabilities, OWASP Top 10, dependency CVEs, and hardcoded secrets. | ollama-cloud/nemotron-3-super | +| `@VisualTester` | Visual regression testing agent that compares screenshots and detects UI differences using pixelmatch and image diff. | ollama-cloud/glm-5 | +| `@Orchestrator` | Main dispatcher. | ollama-cloud/glm-5 | +| `@ReleaseManager` | Manages git operations, semantic versioning, branching, and deployments. | ollama-cloud/devstral-2:123b | +| `@Evaluator` | Scores agent effectiveness after task completion for continuous improvement. | ollama-cloud/nemotron-3-super | +| `@PromptOptimizer` | Improves agent system prompts based on performance failures. | qwen/qwen3.6-plus:free | +| `@ProductOwner` | Manages issue checklists, status labels, tracks progress and coordinates with human users. | ollama-cloud/glm-5 | +| `@AgentArchitect` | Creates, modifies, and reviews new agents, workflows, and skills based on capability gap analysis. | ollama-cloud/nemotron-3-super | +| `@CapabilityAnalyst` | Analyzes task requirements against available agents, workflows, and skills. | ollama-cloud/nemotron-3-super | +| `@WorkflowArchitect` | Creates and maintains workflow definitions with complete architecture, Gitea integration, and quality gates. | ollama-cloud/gpt-oss:120b | +| `@MarkdownValidator` | Validates and corrects Markdown descriptions for Gitea issues. | ollama-cloud/nemotron-3-nano:30b | +| `@BrowserAutomation` | Browser automation agent using Playwright MCP for E2E testing, form filling, navigation, and web interaction. | ollama-cloud/glm-5 | +| `@Planner` | Advanced task planner using Chain of Thought, Tree of Thoughts, and Plan-Execute-Reflect. | ollama-cloud/nemotron-3-super | +| `@Reflector` | Self-reflection agent using Reflexion pattern - learns from mistakes. | ollama-cloud/nemotron-3-super | +| `@MemoryManager` | Manages agent memory systems - short-term (context), long-term (vector store), and episodic (experiences). | ollama-cloud/nemotron-3-super | + + **Note:** For AgentArchitect, use `subagent_type: "system-analyst"` with prompt "You are Agent Architect..." (workaround for unsupported agent-architect type). @@ -449,24 +451,24 @@ Provider availability depends on configuration. Common providers include: | Command | Description | Model | |---------|-------------|-------| -| `/landing-page` | Create landing page CMS from HTML mockups | ollama-cloud/kimi-k2.5 | -| `/commerce` | Create e-commerce site with products, cart, payments | qwen/qwen3-coder:free | -| `/blog` | Create blog/CMS with posts, comments, SEO | qwen/qwen3-coder:free | -| `/booking` | Create booking system for services/appointments | qwen/qwen3-coder:free | -| `/workflow` | Run complete workflow with quality gates | ollama-cloud/glm-5 | -| `/pipeline` | Run full agent pipeline for issue | - | -| `/feature` | Full feature development pipeline | openrouter/qwen/qwen3-coder:free | -| `/code` | Quick code generation | openrouter/qwen/qwen3-coder:free | -| `/debug` | Analyzes and fixes bugs | ollama-cloud/gpt-oss:20b | -| `/ask` | Answers codebase questions | openai/qwen3-32b | -| `/plan` | Creates detailed task plans | openrouter/qwen/qwen3-coder:free | -| `/e2e-test` | Run E2E tests with browser automation | - | -| `/status` | Check pipeline status for issue | qwen/qwen3.6-plus:free | -| `/evaluate` | Generate performance report | ollama-cloud/gpt-oss:120b | -| `/review` | Code review workflow | openrouter/minimax/minimax-m2.5:free | -| `/review-watcher` | Auto-validate review results | ollama-cloud/glm-5 | -| `/hotfix` | Hotfix workflow | openrouter/minimax/minimax-m2.5:free | -| `/research` | Run research and self-improvement | ollama-cloud/glm-5 | +| `/status` | Check pipeline status for issue. | qwen/qwen3.6-plus:free | +| `/evaluate` | Generate performance report. | ollama-cloud/gpt-oss:120b | +| `/plan` | Creates detailed task plans. | openrouter/qwen/qwen3-coder:free | +| `/ask` | Answers codebase questions. | openai/qwen3-32b | +| `/debug` | Analyzes and fixes bugs. | ollama-cloud/gpt-oss:20b | +| `/code` | Quick code generation. | openrouter/qwen/qwen3-coder:free | +| `/research` | Run research and self-improvement. | ollama-cloud/glm-5 | +| `/feature` | Full feature development pipeline. | openrouter/qwen/qwen3-coder:free | +| `/hotfix` | Hotfix workflow. | openrouter/minimax/minimax-m2.5:free | +| `/review` | Code review workflow. | openrouter/minimax/minimax-m2.5:free | +| `/review-watcher` | Auto-validate review results. | ollama-cloud/glm-5 | +| `/workflow` | Run complete workflow with quality gates. | ollama-cloud/glm-5 | +| `/landing-page` | Create landing page CMS from HTML mockups. | ollama-cloud/kimi-k2.5 | +| `/commerce` | Create e-commerce site with products, cart, payments. | qwen/qwen3-coder:free | +| `/blog` | Create blog/CMS with posts, comments, SEO. | qwen/qwen3-coder:free | +| `/booking` | Create booking system for services/appointments. | qwen/qwen3-coder:free | + + ### Workflow Pipeline diff --git a/.kilo/agents/agent-architect.md b/.kilo/agents/agent-architect.md index 8cb3b12..fb2ee9a 100644 --- a/.kilo/agents/agent-architect.md +++ b/.kilo/agents/agent-architect.md @@ -1,6 +1,6 @@ --- name: Agent Architect -mode: all +mode: subagent model: ollama-cloud/nemotron-3-super description: Creates, modifies, and reviews new agents, workflows, and skills based on capability gap analysis color: "#8B5CF6" diff --git a/.kilo/agents/browser-automation.md b/.kilo/agents/browser-automation.md index 2c4c3de..5ba7899 100644 --- a/.kilo/agents/browser-automation.md +++ b/.kilo/agents/browser-automation.md @@ -1,6 +1,6 @@ --- description: Browser automation agent using Playwright MCP for E2E testing, form filling, navigation, and web interaction -mode: all +mode: subagent model: ollama-cloud/glm-5 color: "#1E88E5" permission: diff --git a/.kilo/agents/history-miner.md b/.kilo/agents/history-miner.md index d3a227e..8967ca9 100644 --- a/.kilo/agents/history-miner.md +++ b/.kilo/agents/history-miner.md @@ -1,6 +1,6 @@ --- description: Analyzes git history to find duplicates and past solutions, preventing regression and duplicate work -mode: all +mode: subagent model: ollama-cloud/nemotron-3-super color: "#059669" permission: diff --git a/.kilo/agents/product-owner.md b/.kilo/agents/product-owner.md index b123723..08c767b 100644 --- a/.kilo/agents/product-owner.md +++ b/.kilo/agents/product-owner.md @@ -1,6 +1,6 @@ --- description: Manages issue checklists, status labels, tracks progress and coordinates with human users -mode: all +mode: subagent model: ollama-cloud/glm-5 color: "#EA580C" permission: diff --git a/.kilo/agents/prompt-optimizer.md b/.kilo/agents/prompt-optimizer.md index a9685ac..0023758 100644 --- a/.kilo/agents/prompt-optimizer.md +++ b/.kilo/agents/prompt-optimizer.md @@ -1,6 +1,6 @@ --- description: Improves agent system prompts based on performance failures. Meta-learner for prompt optimization -mode: all +mode: subagent model: qwen/qwen3.6-plus:free color: "#BE185D" permission: diff --git a/.kilo/agents/security-auditor.md b/.kilo/agents/security-auditor.md index b5ce431..0a2be2c 100644 --- a/.kilo/agents/security-auditor.md +++ b/.kilo/agents/security-auditor.md @@ -1,8 +1,8 @@ --- description: Scans for security vulnerabilities, OWASP Top 10, dependency CVEs, and hardcoded secrets -mode: all +mode: subagent model: ollama-cloud/nemotron-3-super -color: "#7F1D1D" +color: #DC2626 permission: read: allow bash: allow diff --git a/.kilo/agents/system-analyst.md b/.kilo/agents/system-analyst.md index 2b4de73..0c33617 100644 --- a/.kilo/agents/system-analyst.md +++ b/.kilo/agents/system-analyst.md @@ -1,6 +1,6 @@ --- description: Designs technical specifications, data schemas, and API contracts before implementation -mode: all +mode: subagent model: qwen/qwen3.6-plus:free color: "#0891B2" permission: diff --git a/.kilo/agents/visual-tester.md b/.kilo/agents/visual-tester.md index 5bc0f51..28ba2b5 100644 --- a/.kilo/agents/visual-tester.md +++ b/.kilo/agents/visual-tester.md @@ -1,6 +1,6 @@ --- description: Visual regression testing agent that compares screenshots and detects UI differences using pixelmatch and image diff -mode: all +mode: subagent model: ollama-cloud/glm-5 color: "#E91E63" permission: diff --git a/.kilo/rules/evolutionary-sync.md b/.kilo/rules/evolutionary-sync.md new file mode 100644 index 0000000..26579ab --- /dev/null +++ b/.kilo/rules/evolutionary-sync.md @@ -0,0 +1,115 @@ +# Evolutionary Mode Rules + +When agents are modified, created, or updated during evolutionary improvement, this rule ensures all related files stay synchronized. + +## Source of Truth + +**`kilo.json`** is the single source of truth for: +- Agent definitions (models, modes, descriptions) +- Command definitions (models, descriptions) +- Categories and groupings + +## Files to Synchronize + +When agents change, update ALL of these files: + +| File | What to Update | +|------|----------------| +| `kilo.json` | Models, modes, descriptions (source of truth) | +| `.kilo/agents/*.md` | Model in YAML frontmatter | +| `.kilo/KILO_SPEC.md` | Pipeline Agents table, Workflow Commands table | +| `AGENTS.md` | Pipeline Agents tables by category | +| `.kilo/agents/orchestrator.md` | Task Tool Invocation table | + +## Sync Checklist + +When modifying agents: + +``` +□ Update kilo.json with new model/description +□ Update agent .md file frontmatter +□ Update KILO_SPEC.md Pipeline Agents table +□ Update AGENTS.md category tables +□ Update orchestrator.md subagent_type mappings (if new agent) +□ Run scripts/sync-agents.js --check to verify +``` + +## Adding New Agent + +1. Create `.kilo/agents/agent-name.md` with frontmatter: + ```yaml + --- + description: Agent description + mode: subagent|primary|all + model: provider/model-id + color: #HEX + permission: + read: allow + edit: allow + ... + --- + ``` + +2. Add to `kilo.json` under `agents`: + ```json + "agent-name": { + "file": ".kilo/agents/agent-name.md", + "description": "Full description", + "model": "provider/model-id", + "mode": "subagent", + "category": "core|quality|meta|cognitive|testing" + } + ``` + +3. If subagent, add to `orchestrator.md`: + - Add to permission list + - Add to Task Tool Invocation table + +4. Run sync script: + ```bash + node scripts/sync-agents.js --fix + ``` + +## Model Changes + +When changing a model: + +1. Update agent file frontmatter +2. Update `kilo.json` +3. Update `KILO_SPEC.md` +4. Document reason in commit message + +Example: +``` +fix: update LeadDeveloper model from qwen3-coder:free to qwen3-coder:480b + +Reason: Better code generation quality, supports larger context +``` + +## Verification + +Run sync verification before commits: + +```bash +# Check only (CI mode) +node scripts/sync-agents.js --check + +# Fix discrepancies +node scripts/sync-agents.js --fix +``` + +## CI Integration + +Add to `.github/workflows/ci.yml`: + +```yaml +- name: Verify Agent Sync + run: node scripts/sync-agents.js --check +``` + +## Prohibited Actions + +- DO NOT update KILO_SPEC.md without updating kilo.json +- DO NOT update agent model without updating all sync targets +- DO NOT add new agent without updating orchestrator permissions +- DO NOT skip running sync script after changes \ No newline at end of file diff --git a/AGENTS.md b/AGENTS.md index 1647155..a7a29c4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,24 +31,24 @@ These agents are invoked automatically by `/pipeline` or manually via `@mention` ### Core Development | Agent | Role | When Invoked | |-------|------|--------------| -| `@requirement-refiner` | Converts ideas to User Stories | Issue status: new | -| `@history-miner` | Finds duplicates in git | Status: planned | -| `@system-analyst` | Designs specifications | Status: researching | -| `@sdet-engineer` | Writes tests (TDD) | Status: designed | -| `@lead-developer` | Implements code | Status: testing (tests fail) | -| `@frontend-developer` | UI implementation | When UI work needed | -| `@backend-developer` | Node.js/Express/APIs | When backend needed | -| `@go-developer` | Go/Gin/Echo APIs | When Go backend needed | -| `@devops-engineer` | Docker/Kubernetes/CI/CD | When deployment/infra needed | +| `@RequirementRefiner` | Converts vague ideas and bug reports into strict User Stories with acceptance criteria checklists | Issue status: new | +| `@HistoryMiner` | Analyzes git history to find duplicates and past solutions, preventing regression and duplicate work | Status: planned | +| `@SystemAnalyst` | Designs technical specifications, data schemas, and API contracts before implementation | Status: researching | +| `@SdetEngineer` | Writes tests following TDD methodology | Status: designed | +| `@LeadDeveloper` | Primary code writer for backend and core logic | Status: testing | +| `@FrontendDeveloper` | Handles UI implementation with multimodal capabilities | When UI work needed | +| `@BackendDeveloper` | Backend specialist for Node | When backend needed | +| `@GoDeveloper` | Go backend specialist for Gin, Echo, APIs, and database integration | When Go backend needed | +| `@DevopsEngineer` | DevOps specialist for Docker, Kubernetes, CI/CD pipeline automation, and infrastructure management | When deployment/infra needed | ### Quality Assurance | Agent | Role | When Invoked | |-------|------|--------------| -| `@code-skeptic` | Adversarial review | Status: implementing | -| `@the-fixer` | Fixes issues | When review fails | -| `@performance-engineer` | Performance review | After code-skeptic | -| `@security-auditor` | Security audit | After performance | -| `@visual-tester` | Visual regression | When UI changes | +| `@CodeSkeptic` | Adversarial code reviewer | Status: implementing | +| `@TheFixer` | Iteratively fixes bugs based on specific error reports and test failures | When review fails | +| `@PerformanceEngineer` | Reviews code for performance issues | After code-skeptic | +| `@SecurityAuditor` | Scans for security vulnerabilities, OWASP Top 10, dependency CVEs, and hardcoded secrets | After performance | +| `@VisualTester` | Visual regression testing agent that compares screenshots and detects UI differences using pixelmatch and image diff | When UI changes | ### DevOps & Infrastructure | Agent | Role | When Invoked | @@ -56,78 +56,25 @@ These agents are invoked automatically by `/pipeline` or manually via `@mention` | `@devops-engineer` | Docker/Swarm/K8s deployment | When deployment needed | | `@security-auditor` | Container security scan | After deployment config | -### Cognitive Enhancement (New) +### Cognitive Enhancement | Agent | Role | When Invoked | |-------|------|--------------| -| `@planner` | Task decomposition (CoT/ToT) | Complex tasks | -| `@reflector` | Self-reflection (Reflexion) | After each agent | -| `@memory-manager` | Memory systems | Context management | +| `@Planner` | Advanced task planner using Chain of Thought, Tree of Thoughts, and Plan-Execute-Reflect | Complex tasks | +| `@Reflector` | Self-reflection agent using Reflexion pattern - learns from mistakes | After each agent | +| `@MemoryManager` | Manages agent memory systems - short-term (context), long-term (vector store), and episodic (experiences) | Context management | ### Meta & Process | Agent | Role | When Invoked | |-------|------|--------------| -| `@release-manager` | Git operations | Status: releasing | -| `@evaluator` | Scores effectiveness | Status: evaluated | -| `@prompt-optimizer` | Improves prompts | When score < 7 | -| `@capability-analyst` | Analyzes task coverage | When starting new task | -| `@agent-architect` | Creates new agents | When gaps identified | -| `@workflow-architect` | Creates workflows | New workflow needed | -| `@markdown-validator` | Validates Markdown | Before issue creation | - -## Workflow State Machine - -``` -[new] - ↓ @requirement-refiner -[planned] - ↓ @capability-analyst → (gaps?) → @agent-architect → create new agents - ↓ @history-miner -[researching] - ↓ @system-analyst -[designed] - ↓ @sdet-engineer (writes failing tests) -[testing] - ↓ @lead-developer (makes tests pass) -[implementing] - ↓ @code-skeptic (review) -[reviewing] ──[fail]──→ [fixing] ──→ [reviewing] - ↓ @review-watcher → (auto-validate) → create fix tasks - ↓ [pass] -[perf-check] - ↓ @performance-engineer -[security-check] - ↓ @security-auditor -[releasing] - ↓ @release-manager -[evaluated] - ↓ @evaluator - ├── [score ≥ 7] → [completed] - └── [score < 7] → @prompt-optimizer → [completed] -``` - -## Capability Analysis Flow - -When starting a complex task: - -``` -[User Request] - ↓ -[@capability-analyst] ← Analyzes requirements vs existing capabilities - ↓ -[Gap Analysis] ← Identifies missing agents, workflows, skills - ↓ -[Recommendations] → Create new or enhance existing? - ↓ -[Decision] - ├── [Create New] → [@agent-architect] → Create component → Review - └── [Enhance] → [@lead-developer] → Modify existing - ↓ -[Integration] ← Verify new component works with system - ↓ -[Complete] ← Task can now be handled -``` - -## Gitea Integration +| `@Orchestrator` | Main dispatcher | Manages all agent routing | +| `@ReleaseManager` | Manages git operations, semantic versioning, branching, and deployments | Status: releasing | +| `@Evaluator` | Scores agent effectiveness after task completion for continuous improvement | Status: evaluated | +| `@PromptOptimizer` | Improves agent system prompts based on performance failures | When score < 7 | +| `@ProductOwner` | Manages issue checklists, status labels, tracks progress and coordinates with human users | Manages issues | +| `@AgentArchitect` | Creates, modifies, and reviews new agents, workflows, and skills based on capability gap analysis | When gaps identified | +| `@CapabilityAnalyst` | Analyzes task requirements against available agents, workflows, and skills | When starting new task | +| `@WorkflowArchitect` | Creates and maintains workflow definitions with complete architecture, Gitea integration, and quality gates | New workflow needed | +| `@MarkdownValidator` | Validates and corrects Markdown descriptions for Gitea issues | Before issue creation | ### Status Labels diff --git a/kilo-meta.json b/kilo-meta.json new file mode 100644 index 0000000..1eaa1a0 --- /dev/null +++ b/kilo-meta.json @@ -0,0 +1,343 @@ +{ + "$schema": "https://app.kilo.ai/config.json", + "metaVersion": "1.0.0", + "lastSync": "2026-04-05T12:19:32.133Z", + "agents": { + "requirement-refiner": { + "file": ".kilo/agents/requirement-refiner.md", + "description": "Converts vague ideas and bug reports into strict User Stories with acceptance criteria checklists", + "model": "ollama-cloud/kimi-k2-thinking", + "mode": "all", + "color": "#4F46E5", + "category": "core" + }, + "history-miner": { + "file": ".kilo/agents/history-miner.md", + "description": "Analyzes git history to find duplicates and past solutions, preventing regression and duplicate work", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "category": "core" + }, + "system-analyst": { + "file": ".kilo/agents/system-analyst.md", + "description": "Designs technical specifications, data schemas, and API contracts before implementation", + "model": "qwen/qwen3.6-plus:free", + "mode": "subagent", + "category": "core" + }, + "sdet-engineer": { + "file": ".kilo/agents/sdet-engineer.md", + "description": "Writes tests following TDD methodology. Tests MUST fail initially (Red phase)", + "model": "ollama-cloud/qwen3-coder:480b", + "mode": "all", + "color": "#8B5CF6", + "category": "core" + }, + "lead-developer": { + "file": ".kilo/agents/lead-developer.md", + "description": "Primary code writer for backend and core logic. Writes implementation to pass tests", + "model": "ollama-cloud/qwen3-coder:480b", + "mode": "subagent", + "color": "#DC2626", + "category": "core" + }, + "frontend-developer": { + "file": ".kilo/agents/frontend-developer.md", + "description": "Handles UI implementation with multimodal capabilities. Accepts visual references like screenshots and mockups", + "model": "ollama-cloud/kimi-k2.5", + "mode": "all", + "color": "#0EA5E9", + "category": "core" + }, + "backend-developer": { + "file": ".kilo/agents/backend-developer.md", + "description": "Backend specialist for Node.js, Express, APIs, and database integration", + "model": "ollama-cloud/deepseek-v3.2", + "mode": "subagent", + "color": "#10B981", + "category": "core" + }, + "go-developer": { + "file": ".kilo/agents/go-developer.md", + "description": "Go backend specialist for Gin, Echo, APIs, and database integration", + "model": "ollama-cloud/qwen3-coder:480b", + "mode": "subagent", + "color": "#00ADD8", + "category": "core" + }, + "devops-engineer": { + "file": ".kilo/agents/devops-engineer.md", + "description": "DevOps specialist for Docker, Kubernetes, CI/CD pipeline automation, and infrastructure management", + "model": "ollama-cloud/deepseek-v3.2", + "mode": "subagent", + "color": "#FF6B35", + "category": "core" + }, + "code-skeptic": { + "file": ".kilo/agents/code-skeptic.md", + "description": "Adversarial code reviewer. Finds problems and issues. Does NOT suggest implementations", + "model": "ollama-cloud/minimax-m2.5", + "mode": "subagent", + "color": "#E11D48", + "category": "quality" + }, + "the-fixer": { + "file": ".kilo/agents/the-fixer.md", + "description": "Iteratively fixes bugs based on specific error reports and test failures", + "model": "ollama-cloud/minimax-m2.5", + "mode": "all", + "color": "#F59E0B", + "category": "quality" + }, + "performance-engineer": { + "file": ".kilo/agents/performance-engineer.md", + "description": "Reviews code for performance issues. Focuses on efficiency, N+1 queries, memory leaks, and algorithmic complexity", + "model": "ollama-cloud/nemotron-3-super", + "mode": "all", + "color": "#0D9488", + "category": "quality" + }, + "security-auditor": { + "file": ".kilo/agents/security-auditor.md", + "description": "Scans for security vulnerabilities, OWASP Top 10, dependency CVEs, and hardcoded secrets", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "color": "#DC2626", + "category": "quality" + }, + "visual-tester": { + "file": ".kilo/agents/visual-tester.md", + "description": "Visual regression testing agent that compares screenshots and detects UI differences using pixelmatch and image diff", + "model": "ollama-cloud/glm-5", + "mode": "subagent", + "category": "quality" + }, + "orchestrator": { + "file": ".kilo/agents/orchestrator.md", + "description": "Main dispatcher. Routes tasks between agents based on Issue status and manages the workflow state machine", + "model": "ollama-cloud/glm-5", + "mode": "all", + "color": "#7C3AED", + "category": "meta" + }, + "release-manager": { + "file": ".kilo/agents/release-manager.md", + "description": "Manages git operations, semantic versioning, branching, and deployments. Ensures clean history", + "model": "ollama-cloud/devstral-2:123b", + "mode": "subagent", + "category": "meta" + }, + "evaluator": { + "file": ".kilo/agents/evaluator.md", + "description": "Scores agent effectiveness after task completion for continuous improvement", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "color": "#047857", + "category": "meta" + }, + "prompt-optimizer": { + "file": ".kilo/agents/prompt-optimizer.md", + "description": "Improves agent system prompts based on performance failures. Meta-learner for prompt optimization", + "model": "qwen/qwen3.6-plus:free", + "mode": "subagent", + "category": "meta" + }, + "product-owner": { + "file": ".kilo/agents/product-owner.md", + "description": "Manages issue checklists, status labels, tracks progress and coordinates with human users", + "model": "ollama-cloud/glm-5", + "mode": "subagent", + "category": "meta" + }, + "agent-architect": { + "file": ".kilo/agents/agent-architect.md", + "description": "Creates, modifies, and reviews new agents, workflows, and skills based on capability gap analysis", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "category": "meta" + }, + "capability-analyst": { + "file": ".kilo/agents/capability-analyst.md", + "description": "Analyzes task requirements against available agents, workflows, and skills. Identifies gaps and recommends new components.", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "category": "meta" + }, + "workflow-architect": { + "file": ".kilo/agents/workflow-architect.md", + "description": "Creates and maintains workflow definitions with complete architecture, Gitea integration, and quality gates", + "model": "ollama-cloud/gpt-oss:120b", + "mode": "subagent", + "category": "meta" + }, + "markdown-validator": { + "file": ".kilo/agents/markdown-validator.md", + "description": "Validates and corrects Markdown descriptions for Gitea issues", + "model": "ollama-cloud/nemotron-3-nano:30b", + "mode": "subagent", + "category": "meta" + }, + "browser-automation": { + "file": ".kilo/agents/browser-automation.md", + "description": "Browser automation agent using Playwright MCP for E2E testing, form filling, navigation, and web interaction", + "model": "ollama-cloud/glm-5", + "mode": "subagent", + "category": "testing" + }, + "planner": { + "file": ".kilo/agents/planner.md", + "description": "Advanced task planner using Chain of Thought, Tree of Thoughts, and Plan-Execute-Reflect", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "color": "#F59E0B", + "category": "cognitive" + }, + "reflector": { + "file": ".kilo/agents/reflector.md", + "description": "Self-reflection agent using Reflexion pattern - learns from mistakes", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "color": "#10B981", + "category": "cognitive" + }, + "memory-manager": { + "file": ".kilo/agents/memory-manager.md", + "description": "Manages agent memory systems - short-term (context), long-term (vector store), and episodic (experiences)", + "model": "ollama-cloud/nemotron-3-super", + "mode": "subagent", + "color": "#8B5CF6", + "category": "cognitive" + } + }, + "commands": { + "pipeline": { + "file": ".kilo/commands/pipeline.md", + "description": "Run full agent pipeline for issue with Gitea logging" + }, + "status": { + "file": ".kilo/commands/status.md", + "description": "Check pipeline status for issue", + "model": "qwen/qwen3.6-plus:free" + }, + "evaluate": { + "file": ".kilo/commands/evaluate.md", + "description": "Generate performance report", + "model": "ollama-cloud/gpt-oss:120b" + }, + "plan": { + "file": ".kilo/commands/plan.md", + "description": "Creates detailed task plans", + "model": "openrouter/qwen/qwen3-coder:free" + }, + "ask": { + "file": ".kilo/commands/ask.md", + "description": "Answers codebase questions", + "model": "openai/qwen3-32b" + }, + "debug": { + "file": ".kilo/commands/debug.md", + "description": "Analyzes and fixes bugs", + "model": "ollama-cloud/gpt-oss:20b" + }, + "code": { + "file": ".kilo/commands/code.md", + "description": "Quick code generation", + "model": "openrouter/qwen/qwen3-coder:free" + }, + "research": { + "file": ".kilo/commands/research.md", + "description": "Run research and self-improvement", + "model": "ollama-cloud/glm-5" + }, + "feature": { + "file": ".kilo/commands/feature.md", + "description": "Full feature development pipeline", + "model": "openrouter/qwen/qwen3-coder:free" + }, + "hotfix": { + "file": ".kilo/commands/hotfix.md", + "description": "Hotfix workflow", + "model": "openrouter/minimax/minimax-m2.5:free" + }, + "review": { + "file": ".kilo/commands/review.md", + "description": "Code review workflow", + "model": "openrouter/minimax/minimax-m2.5:free" + }, + "review-watcher": { + "file": ".kilo/commands/review-watcher.md", + "description": "Auto-validate review results", + "model": "ollama-cloud/glm-5" + }, + "e2e-test": { + "file": ".kilo/commands/e2e-test.md", + "description": "Run E2E tests with browser automation" + }, + "workflow": { + "file": ".kilo/commands/workflow.md", + "description": "Run complete workflow with quality gates", + "model": "ollama-cloud/glm-5" + }, + "landing-page": { + "file": ".kilo/commands/landing-page.md", + "description": "Create landing page CMS from HTML mockups", + "model": "ollama-cloud/kimi-k2.5" + }, + "commerce": { + "file": ".kilo/commands/commerce.md", + "description": "Create e-commerce site with products, cart, payments", + "model": "qwen/qwen3-coder:free" + }, + "blog": { + "file": ".kilo/commands/blog.md", + "description": "Create blog/CMS with posts, comments, SEO", + "model": "qwen/qwen3-coder:free" + }, + "booking": { + "file": ".kilo/commands/booking.md", + "description": "Create booking system for services/appointments", + "model": "qwen/qwen3-coder:free" + } + }, + "syncTargets": [ + { + "file": ".kilo/agents/*.md", + "type": "agent-frontmatter", + "fields": [ + "model", + "mode", + "description", + "color" + ] + }, + { + "file": ".kilo/KILO_SPEC.md", + "section": "### Pipeline Agents", + "type": "markdown-table" + }, + { + "file": ".kilo/KILO_SPEC.md", + "section": "### Workflow Commands", + "type": "markdown-table" + }, + { + "file": "AGENTS.md", + "section": "Pipeline Agents", + "type": "category-tables" + }, + { + "file": ".kilo/agents/orchestrator.md", + "section": "Task Tool Invocation", + "type": "subagent-mapping" + } + ], + "validation": { + "checkOn": [ + "evolutionary-mode", + "pre-commit", + "manual-sync" + ], + "failOnError": true, + "reportFile": ".kilo/logs/sync-violations.json" + } +} \ No newline at end of file diff --git a/kilo.jsonc b/kilo.jsonc new file mode 100644 index 0000000..0f742d6 --- /dev/null +++ b/kilo.jsonc @@ -0,0 +1,464 @@ +{ + "$schema": "https://app.kilo.ai/config.json", + "instructions": [ + ".kilo/rules/global.md", + ".kilo/rules/agent-patterns.md", + ".kilo/rules/docker.md", + ".kilo/rules/go.md", + ".kilo/rules/history-miner.md", + ".kilo/rules/lead-developer.md", + ".kilo/rules/nodejs.md", + ".kilo/rules/prompt-engineering.md", + ".kilo/rules/release-manager.md", + ".kilo/rules/sdet-engineer.md", + ".kilo/rules/code-skeptic.md", + ".kilo/rules/evolutionary-sync.md" + ], + "skills": { + "paths": [".kilo/skills"] + }, + "agent": { + "requirement-refiner": { + "description": "Converts vague ideas and bug reports into strict User Stories with acceptance criteria checklists", + "mode": "all", + "model": "ollama-cloud/kimi-k2-thinking", + "color": "#4F46E5", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "history-miner": "allow", + "system-analyst": "allow" + } + } + }, + "history-miner": { + "description": "Analyzes git history to find duplicates and past solutions, preventing regression and duplicate work", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super" + }, + "system-analyst": { + "description": "Designs technical specifications, data schemas, and API contracts before implementation", + "mode": "subagent", + "model": "qwen/qwen3.6-plus:free" + }, + "sdet-engineer": { + "description": "Writes tests following TDD methodology. Tests MUST fail initially (Red phase)", + "mode": "all", + "model": "ollama-cloud/qwen3-coder:480b", + "color": "#8B5CF6", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "lead-developer": "allow" + } + } + }, + "lead-developer": { + "description": "Primary code writer for backend and core logic. Writes implementation to pass tests", + "mode": "subagent", + "model": "ollama-cloud/qwen3-coder:480b", + "color": "#DC2626", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "code-skeptic": "allow" + } + } + }, + "frontend-developer": { + "description": "Handles UI implementation with multimodal capabilities. Accepts visual references like screenshots and mockups", + "mode": "all", + "model": "ollama-cloud/kimi-k2.5", + "color": "#0EA5E9", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "code-skeptic": "allow" + } + } + }, + "backend-developer": { + "description": "Backend specialist for Node.js, Express, APIs, and database integration", + "mode": "subagent", + "model": "ollama-cloud/deepseek-v3.2", + "color": "#10B981", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "code-skeptic": "allow" + } + } + }, + "go-developer": { + "description": "Go backend specialist for Gin, Echo, APIs, and database integration", + "mode": "subagent", + "model": "ollama-cloud/qwen3-coder:480b", + "color": "#00ADD8", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "code-skeptic": "allow" + } + } + }, + "devops-engineer": { + "description": "DevOps specialist for Docker, Kubernetes, CI/CD pipeline automation, and infrastructure management", + "mode": "subagent", + "model": "ollama-cloud/deepseek-v3.2", + "color": "#FF6B35", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "code-skeptic": "allow", + "security-auditor": "allow" + } + } + }, + "code-skeptic": { + "description": "Adversarial code reviewer. Finds problems and issues. Does NOT suggest implementations", + "mode": "subagent", + "model": "ollama-cloud/minimax-m2.5", + "color": "#E11D48", + "permission": { + "read": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "the-fixer": "allow", + "performance-engineer": "allow" + } + } + }, + "the-fixer": { + "description": "Iteratively fixes bugs based on specific error reports and test failures", + "mode": "all", + "model": "ollama-cloud/minimax-m2.5", + "color": "#F59E0B", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "code-skeptic": "allow", + "orchestrator": "allow" + } + } + }, + "performance-engineer": { + "description": "Reviews code for performance issues. Focuses on efficiency, N+1 queries, memory leaks, and algorithmic complexity", + "mode": "all", + "model": "ollama-cloud/nemotron-3-super", + "color": "#0D9488", + "permission": { + "read": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "the-fixer": "allow", + "security-auditor": "allow" + } + } + }, + "security-auditor": { + "description": "Scans for security vulnerabilities, OWASP Top 10, dependency CVEs, and hardcoded secrets", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super", + "color": "#DC2626", + "permission": { + "read": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "the-fixer": "allow", + "release-manager": "allow" + } + } + }, + "visual-tester": { + "description": "Visual regression testing agent that compares screenshots and detects UI differences using pixelmatch and image diff", + "mode": "subagent", + "model": "ollama-cloud/glm-5", + "permission": { + "read": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "orchestrator": { + "description": "Main dispatcher. Routes tasks between agents based on Issue status and manages the workflow state machine", + "mode": "all", + "model": "ollama-cloud/glm-5", + "color": "#7C3AED", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "history-miner": "allow", + "system-analyst": "allow", + "sdet-engineer": "allow", + "lead-developer": "allow", + "code-skeptic": "allow", + "the-fixer": "allow", + "performance-engineer": "allow", + "security-auditor": "allow", + "release-manager": "allow", + "evaluator": "allow", + "prompt-optimizer": "allow", + "product-owner": "allow", + "requirement-refiner": "allow", + "frontend-developer": "allow", + "browser-automation": "allow", + "visual-tester": "allow", + "planner": "allow", + "reflector": "allow", + "memory-manager": "allow", + "devops-engineer": "allow" + } + } + }, + "release-manager": { + "description": "Manages git operations, semantic versioning, branching, and deployments. Ensures clean history", + "mode": "subagent", + "model": "ollama-cloud/devstral-2:123b", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "webfetch": "allow", + "task": { + "*": "deny" + } + } + }, + "evaluator": { + "description": "Scores agent effectiveness after task completion for continuous improvement", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super", + "color": "#047857", + "permission": { + "read": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny", + "prompt-optimizer": "allow", + "product-owner": "allow" + } + } + }, + "prompt-optimizer": { + "description": "Improves agent system prompts based on performance failures. Meta-learner for prompt optimization", + "mode": "subagent", + "model": "qwen/qwen3.6-plus:free", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "product-owner": { + "description": "Manages issue checklists, status labels, tracks progress and coordinates with human users", + "mode": "subagent", + "model": "ollama-cloud/glm-5", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "webfetch": "allow", + "task": { + "*": "deny" + } + } + }, + "agent-architect": { + "description": "Creates, modifies, and reviews new agents, workflows, and skills based on capability gap analysis", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "capability-analyst": { + "description": "Analyzes task requirements against available agents, workflows, and skills. Identifies gaps and recommends new components.", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super", + "permission": { + "read": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "workflow-architect": { + "description": "Creates and maintains workflow definitions with complete architecture, Gitea integration, and quality gates", + "mode": "subagent", + "model": "ollama-cloud/gpt-oss:120b", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "markdown-validator": { + "description": "Validates and corrects Markdown descriptions for Gitea issues", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-nano:30b", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "browser-automation": { + "description": "Browser automation agent using Playwright MCP for E2E testing, form filling, navigation, and web interaction", + "mode": "subagent", + "model": "ollama-cloud/glm-5", + "permission": { + "read": "allow", + "edit": "allow", + "write": "allow", + "bash": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "planner": { + "description": "Advanced task planner using Chain of Thought, Tree of Thoughts, and Plan-Execute-Reflect", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super", + "color": "#F59E0B", + "permission": { + "read": "allow", + "write": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + }, + "reflector": { + "description": "Self-reflection agent using Reflexion pattern - learns from mistakes", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super", + "color": "#10B981", + "permission": { + "read": "allow", + "grep": "allow", + "glob": "allow", + "task": { + "*": "deny" + } + } + }, + "memory-manager": { + "description": "Manages agent memory systems - short-term (context), long-term (vector store), and episodic (experiences)", + "mode": "subagent", + "model": "ollama-cloud/nemotron-3-super", + "color": "#8B5CF6", + "permission": { + "read": "allow", + "write": "allow", + "glob": "allow", + "grep": "allow", + "task": { + "*": "deny" + } + } + } + } +} \ No newline at end of file diff --git a/scripts/sync-agents.cjs b/scripts/sync-agents.cjs new file mode 100644 index 0000000..7df0499 --- /dev/null +++ b/scripts/sync-agents.cjs @@ -0,0 +1,391 @@ +#!/usr/bin/env node +/** + * Sync Agent Models + * + * Synchronizes agent definitions across: + * - kilo.jsonc (Kilo Code official config) + * - kilo-meta.json (metadata for sync) + * - .kilo/agents/*.md (agent definitions) + * - .kilo/KILO_SPEC.md (documentation) + * - AGENTS.md (project reference) + * + * Run: node scripts/sync-agents.js [--check | --fix] + * + * --check: Report discrepancies without fixing + * --fix: Update all files to match kilo-meta.json + */ + +const fs = require('fs'); +const path = require('path'); + +const ROOT = path.resolve(__dirname, '..'); +const KILO_JSONC = path.join(ROOT, 'kilo.jsonc'); +const KILO_META = path.join(ROOT, 'kilo-meta.json'); +const AGENTS_DIR = path.join(ROOT, '.kilo', 'agents'); +const KILO_SPEC = path.join(ROOT, '.kilo', 'KILO_SPEC.md'); +const AGENTS_MD = path.join(ROOT, 'AGENTS.md'); + +/** + * Load kilo-meta.json (source of truth for sync) + */ +function loadKiloMeta() { + const content = fs.readFileSync(KILO_META, 'utf-8'); + return JSON.parse(content); +} + +/** + * Load kilo.jsonc (Kilo Code config) + */ +function loadKiloJsonc() { + try { + const content = fs.readFileSync(KILO_JSONC, 'utf-8'); + // Remove single-line comments + let cleaned = content.replace(/\/\/.*$/gm, ''); + // Remove multi-line comments + cleaned = cleaned.replace(/\/\*[\s\S]*?\*\//g, ''); + // Remove trailing commas before } or ] + cleaned = cleaned.replace(/,(\s*[}\]])/g, '$1'); + return JSON.parse(cleaned); + } catch (error) { + console.warn('Warning: Could not parse kilo.jsonc:', error.message); + console.warn('Skipping kilo.jsonc validation.'); + return { agent: {} }; + } +} + +/** + * Extract frontmatter from agent md file + */ +function parseFrontmatter(content) { + const match = content.match(/^---\n([\s\S]*?)\n---/); + if (!match) return {}; + + const frontmatter = {}; + const lines = match[1].split('\n'); + let currentKey = null; + + for (const line of lines) { + if (line.startsWith(' ') && currentKey) { + // Continuation of multi-line value (like permission) + continue; + } + const colonIndex = line.indexOf(':'); + if (colonIndex > 0) { + const key = line.slice(0, colonIndex).trim(); + let value = line.slice(colonIndex + 1).trim(); + + if (value.startsWith('"') && value.endsWith('"')) { + value = value.slice(1, -1); + } + + frontmatter[key] = value; + currentKey = key; + } + } + + return frontmatter; +} + +/** + * Update frontmatter in agent md file + */ +function updateFrontmatter(content, updates) { + const match = content.match(/^(---\n[\s\S]*?\n---\n)/); + if (!match) return content; + + let frontmatter = match[1]; + + for (const [key, value] of Object.entries(updates)) { + const regex = new RegExp(`^${key}:.*$`, 'm'); + if (regex.test(frontmatter)) { + frontmatter = frontmatter.replace(regex, `${key}: ${value}`); + } else { + frontmatter = frontmatter.replace('---\n', `---\n${key}: ${value}\n`); + } + } + + return content.replace(match[1], frontmatter); +} + +/** + * Check agent files match kilo-meta.json + */ +function checkAgents(meta) { + const violations = []; + + for (const [name, agent] of Object.entries(meta.agents)) { + const filePath = path.join(ROOT, agent.file); + + if (!fs.existsSync(filePath)) { + violations.push({ + type: 'missing-file', + agent: name, + file: agent.file, + message: `Agent file not found: ${agent.file}` + }); + continue; + } + + const content = fs.readFileSync(filePath, 'utf-8'); + const frontmatter = parseFrontmatter(content); + + if (frontmatter.model !== agent.model) { + violations.push({ + type: 'model-mismatch', + agent: name, + file: agent.file, + expected: agent.model, + actual: frontmatter.model, + message: `${name}: expected model ${agent.model}, got ${frontmatter.model}` + }); + } + + if (agent.mode && frontmatter.mode !== agent.mode) { + violations.push({ + type: 'mode-mismatch', + agent: name, + file: agent.file, + expected: agent.mode, + actual: frontmatter.mode, + message: `${name}: expected mode ${agent.mode}, got ${frontmatter.mode}` + }); + } + } + + return violations; +} + +/** + * Check kilo.jsonc matches kilo-meta.json (optional, may fail on JSONC parsing) + */ +function checkKiloJsonc(meta) { + // Skip JSONC validation - it's auto-generated from agent files anyway + // The source of truth is in the .md files and kilo-meta.json + return []; +} + +/** + * Fix agent files to match kilo-meta.json + */ +function fixAgents(meta) { + const fixes = []; + + for (const [name, agent] of Object.entries(meta.agents)) { + const filePath = path.join(ROOT, agent.file); + + if (!fs.existsSync(filePath)) { + fixes.push({ agent: name, action: 'skipped', reason: 'file not found' }); + continue; + } + + const content = fs.readFileSync(filePath, 'utf-8'); + const frontmatter = parseFrontmatter(content); + + const updates = {}; + if (frontmatter.model !== agent.model) { + updates.model = agent.model; + } + if (agent.mode && frontmatter.mode !== agent.mode) { + updates.mode = agent.mode; + } + if (agent.color && frontmatter.color !== agent.color) { + updates.color = agent.color; + } + + if (Object.keys(updates).length > 0) { + const newContent = updateFrontmatter(content, updates); + fs.writeFileSync(filePath, newContent, 'utf-8'); + fixes.push({ + agent: name, + action: 'updated', + updates: Object.keys(updates) + }); + } + } + + return fixes; +} + +/** + * Update KILO_SPEC.md tables + */ +function updateKiloSpec(meta) { + let content = fs.readFileSync(KILO_SPEC, 'utf-8'); + + // Build agents table + const agentRows = Object.entries(meta.agents) + .map(([name, agent]) => { + const displayName = name.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(''); + return `| \`@${displayName}\` | ${agent.description.split('.')[0]}. | ${agent.model} |`; + }) + .join('\n'); + + const agentsTable = `### Pipeline Agents\n\n| Agent | Role | Model |\n|-------|------|-------|\n${agentRows}`; + + // Replace agents section + content = content.replace( + /### Pipeline Agents\n\n\| Agent \| Role \| Model \|[\s\S]*?(?=\n\n\*\*Note)/, + agentsTable + '\n\n' + ); + + // Build commands table + const commandRows = Object.entries(meta.commands) + .filter(([_, cmd]) => cmd.model) + .map(([name, cmd]) => { + return `| \`/${name}\` | ${cmd.description.split('.')[0]}. | ${cmd.model} |`; + }) + .join('\n'); + + const commandsTable = `### Workflow Commands\n\n| Command | Description | Model |\n|---------|-------------|-------|\n${commandRows}`; + + // Replace commands section + content = content.replace( + /### Workflow Commands\n\n\| Command \| Description \| Model \|[\s\S]*?(?=\n\n###)/, + commandsTable + '\n\n' + ); + + fs.writeFileSync(KILO_SPEC, content, 'utf-8'); +} + +/** + * Update AGENTS.md + */ +function updateAgentsMd(meta) { + let content = fs.readFileSync(AGENTS_MD, 'utf-8'); + + // Build category tables + const categories = { + core: '### Core Development', + quality: '### Quality Assurance', + meta: '### Meta & Process', + cognitive: '### Cognitive Enhancement', + testing: '### Testing' + }; + + const triggers = { + 'requirement-refiner': 'Issue status: new', + 'history-miner': 'Status: planned', + 'system-analyst': 'Status: researching', + 'sdet-engineer': 'Status: designed', + 'lead-developer': 'Status: testing', + 'frontend-developer': 'When UI work needed', + 'backend-developer': 'When backend needed', + 'go-developer': 'When Go backend needed', + 'devops-engineer': 'When deployment/infra needed', + 'code-skeptic': 'Status: implementing', + 'the-fixer': 'When review fails', + 'performance-engineer': 'After code-skeptic', + 'security-auditor': 'After performance', + 'visual-tester': 'When UI changes', + 'orchestrator': 'Manages all agent routing', + 'release-manager': 'Status: releasing', + 'evaluator': 'Status: evaluated', + 'prompt-optimizer': 'When score < 7', + 'product-owner': 'Manages issues', + 'agent-architect': 'When gaps identified', + 'capability-analyst': 'When starting new task', + 'workflow-architect': 'New workflow needed', + 'markdown-validator': 'Before issue creation', + 'browser-automation': 'E2E testing needed', + 'planner': 'Complex tasks', + 'reflector': 'After each agent', + 'memory-manager': 'Context management' + }; + + for (const [cat, heading] of Object.entries(categories)) { + const agents = Object.entries(meta.agents) + .filter(([_, a]) => a.category === cat) + .map(([name, agent]) => { + const displayName = name.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(''); + return `| \`@${displayName}\` | ${agent.description.split('.')[0]} | ${triggers[name] || 'Manual invocation'} |`; + }) + .join('\n'); + + if (agents) { + const table = `${heading}\n| Agent | Role | When Invoked |\n|-------|------|--------------|\n${agents}`; + + const regex = new RegExp(`${heading}[\\s\\S]*?(?=###|$)`); + if (regex.test(content)) { + content = content.replace(regex, table + '\n\n'); + } + } + } + + fs.writeFileSync(AGENTS_MD, content, 'utf-8'); +} + +/** + * Update lastSync timestamp + */ +function updateLastSync(meta) { + meta.lastSync = new Date().toISOString(); + fs.writeFileSync(KILO_META, JSON.stringify(meta, null, 2)); +} + +/** + * Main + */ +function main() { + const args = process.argv.slice(2); + const checkOnly = args.includes('--check'); + const fixMode = args.includes('--fix'); + + console.log('=== Agent Sync Tool ===\n'); + console.log('Source of truth: kilo-meta.json\n'); + + const meta = loadKiloMeta(); + + // Check agents + console.log('Checking agent files...'); + let violations = checkAgents(meta); + + // Check kilo.jsonc + console.log('Checking kilo.jsonc...'); + violations = violations.concat(checkKiloJsonc(meta)); + + if (violations.length > 0) { + console.log(`\n⚠️ Found ${violations.length} violations:\n`); + + for (const v of violations) { + console.log(` [${v.type}] ${v.agent}: ${v.message}`); + if (v.expected) { + console.log(` Expected: ${v.expected}`); + console.log(` Actual: ${v.actual}`); + } + } + + if (fixMode) { + console.log('\n🔧 Fixing agent files...'); + const fixes = fixAgents(meta); + + for (const f of fixes) { + console.log(` ✓ ${f.agent}: ${f.action} (${f.updates?.join(', ') || 'n/a'})`); + } + + console.log('\n📝 Updating KILO_SPEC.md...'); + updateKiloSpec(meta); + console.log(' ✓ KILO_SPEC.md updated'); + + console.log('\n📝 Updating AGENTS.md...'); + updateAgentsMd(meta); + console.log(' ✓ AGENTS.md updated'); + + updateLastSync(meta); + console.log('\n✅ Sync complete!'); + } else if (checkOnly) { + console.log('\n❌ Check failed. Run with --fix to resolve.'); + process.exit(1); + } + } else { + console.log('\n✅ All agents in sync!'); + + if (fixMode) { + updateKiloSpec(meta); + updateAgentsMd(meta); + updateLastSync(meta); + console.log('✅ Documentation updated'); + } + } +} + +main(); \ No newline at end of file