Add FASE 5: Smart Specification Engine (BrainGrid-style)

Inspired by https://www.braingrid.ai/ - Adding intelligent specification
generation layer to achieve 5-star rating in all categories:

New FASE 5 includes:
- Spec generation with Claude API (goals, architecture, edge cases)
- Smart clarification questions (Q&A system)
- Automatic task decomposition with dependencies
- Context management and codebase indexing
- Schema extensions for specifications
- Frontend integration with wizard UI
- New API endpoints for spec workflow

Goal: From vague idea to production - AI plans, codes, and deploys

Comparison with competition:
- BrainGrid: Planning only (no execution/deploy)
- Cursor/Windsurf: Coding only (no planning/deploy)
- Vercel v0: Good at all, but not self-hosted
- AiWorker: Will be 5 stars in everything (Planning + Code + Deploy + Infra)

MVP (Phases 1-4) remains priority, FASE 5 comes after.

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hector Ros
2026-01-20 01:20:32 +01:00
parent 7c843494ce
commit 231bb543e2

View File

@@ -274,6 +274,244 @@ kubectl get pods -n control-plane
---
### FASE 5: Smart Specification Engine (BrainGrid-style) 🧠
**Inspiración**: https://www.braingrid.ai/
**Objetivo**: Generación inteligente de especificaciones antes del coding
#### 5.1 Spec Generation con Claude API
**Objetivo**: Convertir ideas vagas en especificaciones detalladas
**Tareas**:
- [ ] Integrar Claude API para generation
- [ ] Prompt engineering para specs estructuradas
- [ ] Templates para diferentes tipos de features
- [ ] Output: Goals, Context, Architecture, Edge Cases, Acceptance Criteria
**Ejemplo flow**:
```typescript
User: "Add user authentication"
Claude API generates:
{
goals: ["Secure login", "Session management", "Password reset"],
context: "Current app has no auth, needs to protect /dashboard routes",
architecture: "JWT-based with refresh tokens, bcrypt for passwords",
edgeCases: [
"Concurrent logins from multiple devices",
"Token expiration during active session",
"Password reset with expired token"
],
acceptanceCriteria: [
"User can register with email/password",
"Login returns valid JWT token",
"Protected routes return 401 without token",
"Password reset flow works end-to-end"
]
}
```
#### 5.2 Smart Clarification Questions
**Objetivo**: AI hace preguntas inteligentes para descubrir edge cases
**Tareas**:
- [ ] Sistema de Q&A conversacional
- [ ] Detectar ambigüedades en task description
- [ ] Generar preguntas relevantes por tipo de feature
- [ ] Guardar respuestas para context enrichment
**Ejemplo**:
```typescript
Task: "Add payment processing"
AI Questions:
1. "Which payment providers? (Stripe, PayPal, both?)"
2. "Subscription or one-time payments?"
3. "Currency support? (USD only or multi-currency?)"
4. "Refund/chargeback handling required?"
5. "PCI compliance needed or using hosted checkout?"
User answers
Enhanced specification generated
```
#### 5.3 Automatic Task Decomposition
**Objetivo**: Dividir features grandes en subtasks atómicas
**Tareas**:
- [ ] Algoritmo para detectar complejidad
- [ ] Heurísticas para dividir en subtasks
- [ ] Dependencias entre subtasks
- [ ] Estimación automática de effort
**Ejemplo**:
```typescript
Feature: "User authentication system"
Decomposed into:
[
{
id: 1,
title: "Setup database schema for users",
dependencies: [],
estimatedTime: "30min"
},
{
id: 2,
title: "Implement password hashing with bcrypt",
dependencies: [1],
estimatedTime: "45min"
},
{
id: 3,
title: "Create JWT token generation/validation",
dependencies: [1],
estimatedTime: "1h"
},
{
id: 4,
title: "Build registration endpoint",
dependencies: [1, 2, 3],
estimatedTime: "1h"
},
...
]
```
#### 5.4 Context Management
**Objetivo**: Mantener contexto de proyecto para mejores specs
**Tareas**:
- [ ] Indexar codebase existente
- [ ] Detectar patrones de arquitectura
- [ ] Identificar tecnologías usadas
- [ ] Generar spec consistente con codebase
**Features**:
- Vectorización de código con embeddings
- Búsqueda semántica de componentes similares
- Detección automática de breaking changes
- Sugerencias de refactoring cuando aplique
#### 5.5 Schema Extensions
**Objetivo**: Extender DB schema para soportar specs
**Tareas**:
- [ ] Agregar campos a tabla `tasks`
- [ ] Nueva tabla `task_specifications`
- [ ] Nueva tabla `clarification_questions`
- [ ] Nueva tabla `subtasks` con dependencias
**Schema**:
```typescript
// Extender tasks table
tasks {
...existing fields
hasSpecification: boolean
specificationId: varchar(36)
needsClarification: boolean
isDecomposed: boolean
}
// Nueva tabla
task_specifications {
id: varchar(36)
taskId: varchar(36)
goals: json
context: text
architecture: text
edgeCases: json
acceptanceCriteria: json
estimatedComplexity: enum('low','medium','high','very_high')
generatedAt: timestamp
approvedByUser: boolean
}
clarification_questions {
id: varchar(36)
taskId: varchar(36)
question: text
answer: text
askedAt: timestamp
answeredAt: timestamp
}
subtasks {
id: varchar(36)
parentTaskId: varchar(36)
title: varchar(255)
description: text
dependencies: json // Array of subtask IDs
estimatedTime: varchar(20)
order: int
status: enum('pending','in_progress','completed')
}
```
#### 5.6 Frontend Integration
**Objetivo**: UI para spec generation y Q&A
**Tareas**:
- [ ] Modal de "Generate Specification"
- [ ] Chat interface para clarification questions
- [ ] Vista de specification preview
- [ ] Editor de specs generados (allow edits)
- [ ] Visualización de subtasks tree con dependencias
**Components**:
```typescript
<SpecificationWizard taskId={taskId} />
Step 1: Initial task description
Step 2: AI clarification questions (chat UI)
Step 3: Generated spec preview
Step 4: Task decomposition view (tree)
Step 5: Approve & queue for agents
```
#### 5.7 API Endpoints
**Objetivo**: Endpoints para spec generation
**Tareas**:
```typescript
POST /api/tasks/:id/generate-spec
Trigger Claude API to generate specification
POST /api/tasks/:id/ask-questions
Generate clarification questions
POST /api/tasks/:id/answer-question
Submit answer to question, regenerate spec if needed
POST /api/tasks/:id/decompose
Break task into subtasks with dependencies
PATCH /api/tasks/:id/specification
Update/edit generated specification
GET /api/tasks/:id/specification
Get current specification details
```
---
## 📊 ROADMAP VISUAL - Estado de Features
### Comparación con Competencia
| Feature | BrainGrid | Cursor | Vercel v0 | **AiWorker MVP** | **AiWorker + Phase 5** |
|---------|-----------|--------|-----------|------------------|------------------------|
| **Smart Planning** | ⭐⭐⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐⭐⭐ |
| **AI Coding** | ❌ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| **Deploy Automation** | ❌ | ❌ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| **Infrastructure** | ❌ | ❌ | ⭐⭐⭐ (Vercel) | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| **Preview Envs** | ❌ | ❌ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| **GitOps** | ❌ | ❌ | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
### Value Proposition por Fase
**Fase 1-4 (MVP)**:
> "From task to production - fully automated pipeline with HA infrastructure"
**Fase 5 (+ Smart Specs)**:
> "From vague idea to production - AI plans, codes, and deploys your features end-to-end"
---
## 📚 DOCUMENTACIÓN EXISTENTE
### Arquitectura
@@ -435,15 +673,19 @@ kubectl logs -n gitea-actions deployment/gitea-runner -c runner
## 📊 PROGRESO GENERAL
```
Infraestructura: ████████████████████ 100%
Backend: ████░░░░░░░░░░░░░░░░ 20%
Frontend: ░░░░░░░░░░░░░░░░░░░░ 0%
Agentes: ░░░░░░░░░░░░░░░░░░░░ 0%
GitOps/Deploy: ██░░░░░░░░░░░░░░░░░░ 10%
──────────────────────────────────────────
Total: █████░░░░░░░░░░░░░░ 26%
FASE 1 - Backend: ████████████████████ 100%
FASE 2 - Frontend: ░░░░░░░░░░░░░░░░░░░░ 0%
FASE 3 - Agentes: ░░░░░░░░░░░░░░░░░░░░ 0%
FASE 4 - GitOps/Deploy: ██░░░░░░░░░░░░░░░░░░ 10%
FASE 5 - Smart Specs: ░░░░░░░░░░░░░░░░░░░░ 0%
──────────────────────────────────────────────────
Total MVP (Fases 1-4): █████░░░░░░░░░░░░░░ 28%
Total con AI Planning: ████░░░░░░░░░░░░░░░░ 22%
```
**Última sesión completada**: 2026-01-19 (Backend API + MCP Server)
**Próxima sesión**: Frontend Dashboard + Primer Agente
---
## 🚀 QUICK START para Próxima Sesión
@@ -517,15 +759,38 @@ open https://git.fuq.tv/admin/aiworker-backend/actions
## 🎯 OBJETIVO FINAL
Sistema completo de orquestación de agentes IA que automatiza:
Sistema completo de orquestación de agentes IA que automatiza **de idea a producción**:
### MVP (Fases 1-4)
1. Usuario crea tarea en Dashboard
2. Agente Claude Code toma tarea vía MCP
3. Agente trabaja: código, commits, PR
4. Deploy automático en preview environment
5. Usuario aprueba → Staging → Production
**Todo automático, todo con HA, todo monitoreado.**
### Full Vision (+ Fase 5)
1. Usuario describe idea vaga: *"Add payments"*
2. **AI hace preguntas inteligentes**: *"Stripe or PayPal? Subscriptions?"*
3. **AI genera spec completa**: Goals, Architecture, Edge Cases, Tests
4. **AI descompone en subtasks** atómicas con dependencias
5. Agente Claude Code ejecuta cada subtask automáticamente
6. Deploy automático en preview environment
7. Usuario aprueba → Staging → Production
**Todo automático, todo con HA, todo monitoreado, todo inteligente.**
---
**💪 ¡Hemos construido bases sólidas! El siguiente paso más lógico es completar el Backend para tener la API funcional.**
## 🚀 NEXT STEPS
**Ahora mismo**: Completado FASE 1 (Backend API + MCP Server) ✅
**Siguiente sesión**: FASE 2 + 3 (Frontend Dashboard + Primer Agente)
**Después**: FASE 4 (GitOps + Preview Environments)
**Futuro**: FASE 5 (Smart Specification Engine - BrainGrid style)
---
**💪 ¡Bases sólidas construidas! Rumbo al MVP completo, y después... ¡5 estrellas en todo! ⭐⭐⭐⭐⭐**