Sistema completo de gestión de tokens para subagentes NEXUS v4.0: Nuevas directivas SIMCO: - SIMCO-SUBAGENTE.md: Protocolo para agentes en modo subagente - SIMCO-CCA-SUBAGENTE.md: CCA ligero para subagentes (~1,500 tokens) - SIMCO-CONTROL-TOKENS.md: Gestión de límites de tokens - SIMCO-DELEGACION-PARALELA.md: Delegación paralela Perfiles compact (~250 tokens cada uno): - PERFIL-BACKEND-COMPACT.md - PERFIL-FRONTEND-COMPACT.md - PERFIL-DATABASE-COMPACT.md - PERFIL-DEVOPS-COMPACT.md - PERFIL-ML-COMPACT.md - PERFIL-GENERIC-SUBAGENT.md Templates de delegación escalonados: - TEMPLATE-DELEGACION-MINIMA.md (~250 tokens) - TEMPLATE-DELEGACION-ESTANDAR.md (~600 tokens) - TEMPLATE-DELEGACION-COMPLETA.md (~1,800 tokens) Nuevos perfiles especializados: - PERFIL-MCP-ARCHITECT.md - PERFIL-MCP-DEVELOPER.md - PERFIL-RAG-ENGINEER.md - PERFIL-CICD-SPECIALIST.md - PERFIL-PRODUCTION-MANAGER.md - PERFIL-MONITORING-AGENT.md - PERFIL-SECRETS-MANAGER.md - PERFIL-PROPAGATION-TRACKER.md Checklists y documentación: - CHECKLIST-PRE-DELEGACION.md - Análisis y planes de implementación Métricas de mejora: - ~59% reducción de tokens por delegación - Perfiles compact: 69% más ligeros - CCA subagente: 85% más ligero 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1174 lines
26 KiB
Markdown
1174 lines
26 KiB
Markdown
---
|
|
version: "1.0.0"
|
|
fecha: "2026-01-07"
|
|
tipo: plan
|
|
fase: "7 - Completado"
|
|
autor: "Claude Code (Opus 4.5)"
|
|
objetivo: "Plan de correcciones para optimizar gestión de contexto/tokens en subagentes"
|
|
estado: "COMPLETADO"
|
|
fecha_finalizacion: "2026-01-07"
|
|
---
|
|
|
|
# PLAN DE CORRECCIÓN: GESTIÓN DE CONTEXTO Y TOKENS EN SUBAGENTES
|
|
|
|
## 1. RESUMEN DEL PLAN
|
|
|
|
### 1.1 Objetivo
|
|
Optimizar el consumo de tokens en subagentes mediante:
|
|
1. Creación de perfiles compactos para subagentes
|
|
2. Nuevas directivas específicas para modo subagente
|
|
3. Templates de delegación escalonados
|
|
4. Checklist de validación pre-delegación
|
|
5. Protocolo CCA ligero para subagentes
|
|
|
|
### 1.2 Ahorro Estimado
|
|
- **Por delegación:** 3,050 tokens (59% de reducción)
|
|
- **Por sesión típica (10 delegaciones):** 30,500 tokens
|
|
|
|
### 1.3 Archivos a Crear (13 nuevos)
|
|
| Archivo | Ubicación | Tokens Est. |
|
|
|---------|-----------|-------------|
|
|
| SIMCO-SUBAGENTE.md | directivas/simco/ | ~500 |
|
|
| SIMCO-CCA-SUBAGENTE.md | directivas/simco/ | ~400 |
|
|
| CHECKLIST-PRE-DELEGACION.md | checklists/ | ~300 |
|
|
| PERFIL-BACKEND-COMPACT.md | agents/perfiles/compact/ | ~250 |
|
|
| PERFIL-FRONTEND-COMPACT.md | agents/perfiles/compact/ | ~250 |
|
|
| PERFIL-DATABASE-COMPACT.md | agents/perfiles/compact/ | ~250 |
|
|
| PERFIL-DEVOPS-COMPACT.md | agents/perfiles/compact/ | ~250 |
|
|
| PERFIL-ML-COMPACT.md | agents/perfiles/compact/ | ~250 |
|
|
| PERFIL-GENERIC-SUBAGENT.md | agents/perfiles/compact/ | ~200 |
|
|
| _MAP-COMPACT.md | agents/perfiles/compact/ | ~150 |
|
|
| TEMPLATE-DELEGACION-ESTANDAR.md | templates/ | ~600 |
|
|
| TEMPLATE-DELEGACION-MINIMA.md | templates/ | ~250 |
|
|
| README.md | agents/perfiles/compact/ | ~150 |
|
|
|
|
### 1.4 Archivos a Modificar (6)
|
|
| Archivo | Modificación |
|
|
|---------|--------------|
|
|
| SIMCO-DELEGACION.md | + Matriz de decisión herencia |
|
|
| SIMCO-CONTROL-TOKENS.md | + Integración con checklist |
|
|
| SIMCO-INICIALIZACION.md | + Referencia a CCA-SUBAGENTE |
|
|
| TEMPLATE-DELEGACION-SUBAGENTE.md | Renombrar a COMPLETA |
|
|
| _MAP.md (perfiles) | + Referencia a compact/ |
|
|
| PERFIL-ORQUESTADOR.md | + Nuevo flujo de delegación |
|
|
|
|
---
|
|
|
|
## 2. SPRINT 1: FUNDAMENTOS (Prioridad Alta)
|
|
|
|
### 2.1 Crear SIMCO-SUBAGENTE.md
|
|
|
|
**Ruta:** `orchestration/directivas/simco/SIMCO-SUBAGENTE.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# SIMCO: PROTOCOLO PARA SUBAGENTES
|
|
|
|
**Versión:** 1.0.0
|
|
**Sistema:** SIMCO - NEXUS v4.0
|
|
**Propósito:** Protocolo optimizado para agentes que operan en modo subagente
|
|
**Fecha:** 2026-01-07
|
|
|
|
---
|
|
|
|
## PRINCIPIO FUNDAMENTAL
|
|
|
|
> **Subagente = Agente con contexto heredado + Tarea específica + CCA ligero**
|
|
>
|
|
> Un subagente NO debe cargar el mismo contexto que ya tiene el orquestador.
|
|
> Un subagente DEBE usar versiones compactas de perfiles y directivas.
|
|
|
|
---
|
|
|
|
## DIFERENCIA: AGENTE vs SUBAGENTE
|
|
|
|
| Aspecto | Agente Principal | Subagente |
|
|
|---------|------------------|-----------|
|
|
| Inicia sesión | Nuevo | Heredado |
|
|
| Carga de contexto | CCA completo (18 min) | CCA-SUBAGENTE (5 min) |
|
|
| Perfil | PERFIL-*.md (~800 tokens) | PERFIL-*-COMPACT.md (~250 tokens) |
|
|
| SIMCO cargados | 2-3 | 1 específico |
|
|
| Contexto de proyecto | Lee CONTEXTO-PROYECTO.md | Heredado del orquestador |
|
|
| Recovery | Ejecuta @TPL_RECOVERY_CTX | Escala a orquestador |
|
|
| Delega tareas | Sí (si es orquestador) | NO |
|
|
|
|
---
|
|
|
|
## PROTOCOLO DE INICIALIZACIÓN (CCA-SUBAGENTE)
|
|
|
|
```yaml
|
|
# Al recibir delegación del orquestador
|
|
|
|
PASO_1_VERIFICAR_HERENCIA:
|
|
# Confirmar que contexto heredado está presente
|
|
verificar:
|
|
- variables_proyecto: "resueltas (sin placeholders)"
|
|
- aliases: "resueltos (rutas completas)"
|
|
- tarea: "específica (1-2 archivos máx)"
|
|
si_falta_algo: "ESCALAR a orquestador - NO asumir"
|
|
|
|
PASO_2_CARGAR_PERFIL_COMPACT:
|
|
# Cargar versión compacta del perfil
|
|
leer:
|
|
- orchestration/agents/perfiles/compact/PERFIL-{TIPO}-COMPACT.md
|
|
tokens: ~250
|
|
|
|
PASO_3_CARGAR_SIMCO_ESPECIFICO:
|
|
# Solo 1 SIMCO según operación
|
|
segun_operacion:
|
|
crear: "SIMCO-CREAR.md"
|
|
modificar: "SIMCO-MODIFICAR.md"
|
|
validar: "SIMCO-VALIDAR.md"
|
|
tokens: ~800
|
|
|
|
PASO_4_CONFIRMAR:
|
|
responder: "READY_TO_EXECUTE como subagente"
|
|
tokens_totales: ~1,050 (vs ~4,000 de CCA completo)
|
|
```
|
|
|
|
---
|
|
|
|
## RESTRICCIONES DE SUBAGENTE
|
|
|
|
```yaml
|
|
NO_HACER:
|
|
- NO cargar CCA completo
|
|
- NO leer CONTEXTO-PROYECTO.md (ya heredado)
|
|
- NO leer 6 principios completos (ya en perfil compacto)
|
|
- NO delegar a otros subagentes
|
|
- NO ejecutar recovery completo
|
|
- NO crear archivos fuera del alcance
|
|
|
|
SI_HACER:
|
|
- Usar contexto heredado del orquestador
|
|
- Cargar solo PERFIL-*-COMPACT.md
|
|
- Cargar solo 1 SIMCO específico
|
|
- Ejecutar tarea delimitada
|
|
- Reportar resultado en formato compacto
|
|
- Escalar si hay dudas
|
|
```
|
|
|
|
---
|
|
|
|
## FORMATO DE REPORTE (COMPACTO)
|
|
|
|
```yaml
|
|
# Al completar tarea, reportar en máximo 500 tokens
|
|
|
|
REPORTE_SUBAGENTE:
|
|
subtarea_id: "ST-XXX"
|
|
estado: "COMPLETADO | FALLIDO | BLOQUEADO"
|
|
|
|
archivos:
|
|
creados: ["ruta/archivo1.ext"]
|
|
modificados: ["ruta/archivo2.ext"]
|
|
|
|
validaciones:
|
|
build: "PASS | FAIL | SKIP"
|
|
lint: "PASS | FAIL | SKIP"
|
|
|
|
siguiente_paso: "Descripción breve"
|
|
|
|
# Solo si hay problemas
|
|
problemas: []
|
|
```
|
|
|
|
---
|
|
|
|
## RECOVERY DE SUBAGENTE
|
|
|
|
```yaml
|
|
SI_PIERDO_CONTEXTO:
|
|
señales:
|
|
- "No recuerdo qué tarea debo hacer"
|
|
- "No tengo variables resueltas"
|
|
- "No sé qué archivo crear"
|
|
|
|
accion: "ESCALAR A ORQUESTADOR"
|
|
formato: |
|
|
RECOVERY_SUBAGENTE:
|
|
problema: "Perdí contexto de {qué}"
|
|
necesito: "Re-delegación con contexto"
|
|
|
|
NO_HACER: "Intentar recovery completo"
|
|
```
|
|
|
|
---
|
|
|
|
## INTEGRACIÓN CON CAPVED
|
|
|
|
```yaml
|
|
SUBAGENTE_EN_CAPVED:
|
|
ejecuta:
|
|
- E (Ejecutar): "Única fase que ejecuta"
|
|
|
|
no_ejecuta:
|
|
- C (Contexto): "Heredado del orquestador"
|
|
- A (Análisis): "Ya hecho por orquestador"
|
|
- P (Plan): "Ya definido por orquestador"
|
|
- V (Validación): "El orquestador valida"
|
|
- D (Documentar): "El orquestador documenta"
|
|
```
|
|
|
|
---
|
|
|
|
## REFERENCIAS
|
|
|
|
| Documento | Propósito |
|
|
|-----------|-----------|
|
|
| `SIMCO-CCA-SUBAGENTE.md` | CCA ligero |
|
|
| `PERFIL-*-COMPACT.md` | Perfiles para subagentes |
|
|
| `SIMCO-DELEGACION.md` | Cómo recibir delegación |
|
|
| `CHECKLIST-PRE-DELEGACION.md` | Validación del orquestador |
|
|
|
|
---
|
|
|
|
**Versión:** 1.0.0 | **Sistema:** SIMCO-NEXUS v4.0 | **Tipo:** Directiva de Subagente
|
|
```
|
|
|
|
**Tokens estimados:** ~500
|
|
|
|
---
|
|
|
|
### 2.2 Crear SIMCO-CCA-SUBAGENTE.md
|
|
|
|
**Ruta:** `orchestration/directivas/simco/SIMCO-CCA-SUBAGENTE.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# SIMCO: CCA PARA SUBAGENTES (Versión Ligera)
|
|
|
|
**Versión:** 1.0.0
|
|
**Sistema:** SIMCO - NEXUS v4.0
|
|
**Propósito:** Carga de Contexto Automática optimizada para subagentes
|
|
**Fecha:** 2026-01-07
|
|
|
|
---
|
|
|
|
## COMPARATIVA CCA
|
|
|
|
| Aspecto | CCA Completo | CCA-SUBAGENTE |
|
|
|---------|--------------|---------------|
|
|
| Fases | 4 | 2 |
|
|
| Archivos | ~15 | ~3 |
|
|
| Tiempo | ~18 min | ~5 min |
|
|
| Tokens | ~10,000 | ~1,500 |
|
|
|
|
---
|
|
|
|
## PROTOCOLO CCA-SUBAGENTE
|
|
|
|
```yaml
|
|
# 2 Fases en lugar de 4
|
|
|
|
FASE_1_PERFIL_COMPACTO:
|
|
leer: "PERFIL-{TIPO}-COMPACT.md"
|
|
desde: "orchestration/agents/perfiles/compact/"
|
|
tokens: ~250
|
|
|
|
contiene:
|
|
- Identidad mínima
|
|
- Responsabilidades clave (5-7 items)
|
|
- Stack tecnológico
|
|
- Validaciones obligatorias
|
|
- Alias relevantes
|
|
|
|
FASE_2_SIMCO_UNICO:
|
|
determinar:
|
|
si_crear: "SIMCO-CREAR.md"
|
|
si_modificar: "SIMCO-MODIFICAR.md"
|
|
si_validar: "SIMCO-VALIDAR.md"
|
|
tokens: ~800
|
|
|
|
NO_cargar:
|
|
- SIMCO-TAREA.md (para orquestadores)
|
|
- SIMCO-DELEGACION.md (para orquestadores)
|
|
- SIMCO-CAPVED-PLUS.md (para orquestadores)
|
|
|
|
RESULTADO:
|
|
mensaje: "CCA-SUBAGENTE completado"
|
|
tokens_totales: ~1,050
|
|
ready: true
|
|
```
|
|
|
|
---
|
|
|
|
## LO QUE NO SE CARGA
|
|
|
|
```yaml
|
|
# Contexto que VIENE HEREDADO (no cargar)
|
|
|
|
HEREDADO_DEL_ORQUESTADOR:
|
|
- Variables de proyecto (DB_NAME, BACKEND_ROOT, etc.)
|
|
- Aliases resueltos (@DDL, @BACKEND, etc.)
|
|
- Estado actual (tablas, entities existentes)
|
|
- Documentación de referencia específica
|
|
- Criterios de aceptación
|
|
|
|
# Contexto que NO APLICA a subagentes
|
|
|
|
NO_APLICA:
|
|
- 6 Principios completos (resumen en perfil compact)
|
|
- CONTEXTO-PROYECTO.md
|
|
- PROXIMA-ACCION.md
|
|
- SIMCO-TAREA.md
|
|
- Múltiples inventarios
|
|
```
|
|
|
|
---
|
|
|
|
## VALIDACIÓN POST-CCA
|
|
|
|
```yaml
|
|
CHECKLIST_SUBAGENTE:
|
|
- [ ] Lei PERFIL-{TIPO}-COMPACT.md
|
|
- [ ] Lei SIMCO de operación
|
|
- [ ] Tengo contexto heredado (variables, aliases)
|
|
- [ ] Entiendo la tarea específica
|
|
- [ ] Sé qué archivo(s) crear/modificar
|
|
|
|
READY_TO_EXECUTE: true
|
|
```
|
|
|
|
---
|
|
|
|
**Versión:** 1.0.0 | **Sistema:** SIMCO-NEXUS v4.0 | **Tipo:** Directiva CCA Ligero
|
|
```
|
|
|
|
**Tokens estimados:** ~400
|
|
|
|
---
|
|
|
|
### 2.3 Crear CHECKLIST-PRE-DELEGACION.md
|
|
|
|
**Ruta:** `orchestration/checklists/CHECKLIST-PRE-DELEGACION.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# CHECKLIST: PRE-DELEGACIÓN A SUBAGENTE
|
|
|
|
**Versión:** 1.0.0
|
|
**Sistema:** SIMCO - NEXUS v4.0
|
|
**Uso:** Validar ANTES de delegar cualquier tarea a subagente
|
|
**Obligatorio:** SÍ para todas las delegaciones
|
|
|
|
---
|
|
|
|
## CHECKLIST RÁPIDO (5 puntos)
|
|
|
|
```yaml
|
|
ANTES_DE_DELEGAR:
|
|
- [ ] 1. Tarea delimitada (máx 2 archivos)
|
|
- [ ] 2. Template correcto seleccionado
|
|
- [ ] 3. Contexto heredado incluido
|
|
- [ ] 4. Tokens estimados < 2,500
|
|
- [ ] 5. Perfil COMPACT especificado
|
|
```
|
|
|
|
---
|
|
|
|
## CHECKLIST DETALLADO
|
|
|
|
### 1. Validación de Tarea
|
|
|
|
```yaml
|
|
TAREA:
|
|
- [ ] Descripción en 1-2 oraciones
|
|
- [ ] Máximo 2 archivos a crear/modificar
|
|
- [ ] Criterios de aceptación (máx 5)
|
|
- [ ] SIN dependencias no resueltas
|
|
|
|
alerta_roja:
|
|
- "Crear módulo completo" → DESGLOSAR
|
|
- ">3 archivos" → DESGLOSAR
|
|
- "Múltiples endpoints" → DESGLOSAR
|
|
```
|
|
|
|
### 2. Selección de Template
|
|
|
|
```yaml
|
|
TEMPLATE_SEGUN_COMPLEJIDAD:
|
|
simple:
|
|
condicion: "1 archivo, tarea clara"
|
|
usar: "TEMPLATE-DELEGACION-MINIMA.md"
|
|
tokens: ~300
|
|
|
|
estandar:
|
|
condicion: "2 archivos, tarea estándar"
|
|
usar: "TEMPLATE-DELEGACION-ESTANDAR.md"
|
|
tokens: ~800
|
|
|
|
compleja:
|
|
condicion: ">2 archivos, multidependencia"
|
|
accion: "DESGLOSAR en subtareas"
|
|
usar: "TEMPLATE-DELEGACION-COMPLETA.md"
|
|
tokens: ~1,800
|
|
```
|
|
|
|
### 3. Contexto Heredado
|
|
|
|
```yaml
|
|
CONTEXTO_OBLIGATORIO:
|
|
- [ ] Variables proyecto resueltas (sin placeholders)
|
|
- [ ] Aliases resueltos (rutas completas)
|
|
- [ ] Estado actual (tablas/entities existentes)
|
|
- [ ] Código de referencia (file:line, no inline)
|
|
|
|
FORMATO_SEGUN_TOKENS_DISPONIBLES:
|
|
>15,000: "Formato Completo (~1,000 tokens)"
|
|
8,000-15,000: "Formato Compactado (~300 tokens)"
|
|
<8,000: "Formato Ultra-compactado (~100 tokens)"
|
|
```
|
|
|
|
### 4. Estimación de Tokens
|
|
|
|
```yaml
|
|
CALCULAR:
|
|
template: "{300 | 800 | 1800} tokens"
|
|
perfil_compact: "~250 tokens"
|
|
simco: "~800 tokens"
|
|
contexto_heredado: "{100 | 300 | 1000} tokens"
|
|
---
|
|
TOTAL_ESTIMADO: "Sumar arriba"
|
|
|
|
LIMITES:
|
|
seguro: "<2,500 tokens total"
|
|
alerta: ">2,500 tokens → revisar"
|
|
error: ">3,500 tokens → DESGLOSAR"
|
|
```
|
|
|
|
### 5. Perfil de Subagente
|
|
|
|
```yaml
|
|
ESPECIFICAR:
|
|
- [ ] Perfil: "PERFIL-{TIPO}-COMPACT.md"
|
|
- [ ] Ruta: "orchestration/agents/perfiles/compact/"
|
|
|
|
NUNCA_USAR:
|
|
- Perfil completo (PERFIL-*.md) para subagentes
|
|
- Perfil no existente en compact/
|
|
```
|
|
|
|
---
|
|
|
|
## RESUMEN VISUAL
|
|
|
|
```
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ ANTES DE DELEGAR │
|
|
├─────────────────────────────────────────────────────────────────┤
|
|
│ │
|
|
│ 1. TAREA 2. TEMPLATE │
|
|
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
│ │ □ 1-2 oraciones │ │ □ MINIMA (300) │ │
|
|
│ │ □ Máx 2 archivos │ │ □ ESTANDAR (800) │ │
|
|
│ │ □ 5 criterios │ │ □ COMPLETA (1800)│ │
|
|
│ └──────────────────┘ └──────────────────┘ │
|
|
│ │
|
|
│ 3. CONTEXTO 4. TOKENS │
|
|
│ ┌──────────────────┐ ┌──────────────────┐ │
|
|
│ │ □ Variables OK │ │ □ Template: ___ │ │
|
|
│ │ □ Aliases OK │ │ □ Perfil: 250 │ │
|
|
│ │ □ Estado actual │ │ □ SIMCO: 800 │ │
|
|
│ │ □ Refs file:line │ │ □ Contexto: ___ │ │
|
|
│ └──────────────────┘ │ TOTAL: < 2,500 │ │
|
|
│ └──────────────────┘ │
|
|
│ 5. PERFIL │
|
|
│ ┌──────────────────┐ │
|
|
│ │ □ COMPACT.md │ ✅ LISTO PARA DELEGAR │
|
|
│ └──────────────────┘ ❌ REVISAR O DESGLOSAR │
|
|
│ │
|
|
└─────────────────────────────────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## REFERENCIAS
|
|
|
|
| Documento | Usar para |
|
|
|-----------|-----------|
|
|
| `SIMCO-SUBAGENTE.md` | Protocolo de subagente |
|
|
| `SIMCO-CONTROL-TOKENS.md` | Límites de tokens |
|
|
| `TEMPLATE-DELEGACION-*.md` | Templates por complejidad |
|
|
| `agents/perfiles/compact/` | Perfiles compactos |
|
|
|
|
---
|
|
|
|
**Versión:** 1.0.0 | **Sistema:** SIMCO-NEXUS v4.0 | **Tipo:** Checklist Obligatorio
|
|
```
|
|
|
|
**Tokens estimados:** ~300
|
|
|
|
---
|
|
|
|
## 3. SPRINT 2: PERFILES COMPACTOS (Prioridad Alta)
|
|
|
|
### 3.1 Estructura de Directorio
|
|
|
|
**Crear:** `orchestration/agents/perfiles/compact/`
|
|
|
|
### 3.2 PERFIL-BACKEND-COMPACT.md
|
|
|
|
**Ruta:** `orchestration/agents/perfiles/compact/PERFIL-BACKEND-COMPACT.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# PERFIL COMPACTO: BACKEND-AGENT
|
|
|
|
**Uso:** Solo para subagentes | **Tokens:** ~250
|
|
|
|
---
|
|
|
|
## IDENTIDAD
|
|
|
|
```yaml
|
|
Nombre: Backend-Agent (Subagente)
|
|
Dominio: API REST con NestJS/TypeScript
|
|
```
|
|
|
|
## RESPONSABILIDADES
|
|
|
|
- Crear entities (TypeORM)
|
|
- Crear services con CRUD
|
|
- Crear controllers con Swagger
|
|
- Crear DTOs con validaciones
|
|
- Ejecutar `npm run build/lint`
|
|
|
|
## NO HAGO
|
|
|
|
- Crear tablas DDL → Database-Agent
|
|
- Crear componentes React → Frontend-Agent
|
|
|
|
## VALIDACIÓN
|
|
|
|
```bash
|
|
npm run build && npm run lint
|
|
```
|
|
|
|
## ALIAS
|
|
|
|
```yaml
|
|
@BACKEND: "{BACKEND_SRC}/modules/"
|
|
@INV_BE: "orchestration/inventarios/BACKEND_INVENTORY.yml"
|
|
```
|
|
|
|
## SIMCO
|
|
|
|
- Crear: `SIMCO-CREAR.md`
|
|
- Modificar: `SIMCO-MODIFICAR.md`
|
|
|
|
---
|
|
|
|
**Perfil Completo:** Ver `PERFIL-BACKEND.md`
|
|
```
|
|
|
|
**Tokens estimados:** ~250
|
|
|
|
---
|
|
|
|
### 3.3 PERFIL-FRONTEND-COMPACT.md
|
|
|
|
**Ruta:** `orchestration/agents/perfiles/compact/PERFIL-FRONTEND-COMPACT.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# PERFIL COMPACTO: FRONTEND-AGENT
|
|
|
|
**Uso:** Solo para subagentes | **Tokens:** ~250
|
|
|
|
---
|
|
|
|
## IDENTIDAD
|
|
|
|
```yaml
|
|
Nombre: Frontend-Agent (Subagente)
|
|
Dominio: React/TypeScript con Tailwind
|
|
```
|
|
|
|
## RESPONSABILIDADES
|
|
|
|
- Crear componentes React
|
|
- Crear hooks personalizados
|
|
- Crear types TypeScript
|
|
- Integrar con API (endpoints)
|
|
- Ejecutar `npm run build/lint`
|
|
|
|
## NO HAGO
|
|
|
|
- Crear endpoints → Backend-Agent
|
|
- Crear tablas → Database-Agent
|
|
|
|
## VALIDACIÓN
|
|
|
|
```bash
|
|
npm run build && npm run lint && npm run typecheck
|
|
```
|
|
|
|
## ALIAS
|
|
|
|
```yaml
|
|
@FRONTEND: "{FRONTEND_SRC}/"
|
|
@INV_FE: "orchestration/inventarios/FRONTEND_INVENTORY.yml"
|
|
```
|
|
|
|
## SIMCO
|
|
|
|
- Crear: `SIMCO-CREAR.md`
|
|
- Modificar: `SIMCO-MODIFICAR.md`
|
|
|
|
---
|
|
|
|
**Perfil Completo:** Ver `PERFIL-FRONTEND.md`
|
|
```
|
|
|
|
**Tokens estimados:** ~250
|
|
|
|
---
|
|
|
|
### 3.4 PERFIL-DATABASE-COMPACT.md
|
|
|
|
**Ruta:** `orchestration/agents/perfiles/compact/PERFIL-DATABASE-COMPACT.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# PERFIL COMPACTO: DATABASE-AGENT
|
|
|
|
**Uso:** Solo para subagentes | **Tokens:** ~250
|
|
|
|
---
|
|
|
|
## IDENTIDAD
|
|
|
|
```yaml
|
|
Nombre: Database-Agent (Subagente)
|
|
Dominio: PostgreSQL DDL/DML
|
|
```
|
|
|
|
## RESPONSABILIDADES
|
|
|
|
- Crear tablas con DDL
|
|
- Crear índices y constraints
|
|
- Crear seeds de datos
|
|
- Incluir COMMENT ON
|
|
- Ejecutar carga limpia
|
|
|
|
## NO HAGO
|
|
|
|
- Crear entities → Backend-Agent
|
|
- Crear componentes → Frontend-Agent
|
|
|
|
## VALIDACIÓN
|
|
|
|
```bash
|
|
./{RECREATE_CMD}
|
|
psql -d {DB_NAME} -c "\dt {schema}.*"
|
|
```
|
|
|
|
## ALIAS
|
|
|
|
```yaml
|
|
@DDL: "{DB_DDL_PATH}/"
|
|
@INV_DB: "orchestration/inventarios/DATABASE_INVENTORY.yml"
|
|
```
|
|
|
|
## SIMCO
|
|
|
|
- Crear: `SIMCO-CREAR.md + SIMCO-DDL.md`
|
|
- Modificar: `SIMCO-MODIFICAR.md`
|
|
|
|
---
|
|
|
|
**Perfil Completo:** Ver `PERFIL-DATABASE.md`
|
|
```
|
|
|
|
**Tokens estimados:** ~250
|
|
|
|
---
|
|
|
|
### 3.5 PERFIL-GENERIC-SUBAGENT.md
|
|
|
|
**Ruta:** `orchestration/agents/perfiles/compact/PERFIL-GENERIC-SUBAGENT.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# PERFIL COMPACTO: SUBAGENTE GENÉRICO
|
|
|
|
**Uso:** Base para cualquier subagente sin perfil específico
|
|
|
|
---
|
|
|
|
## IDENTIDAD
|
|
|
|
```yaml
|
|
Nombre: Subagente Genérico
|
|
Modo: Tarea única y específica
|
|
```
|
|
|
|
## PROTOCOLO
|
|
|
|
1. Verificar contexto heredado
|
|
2. Cargar 1 SIMCO de operación
|
|
3. Ejecutar tarea delimitada
|
|
4. Reportar en formato compacto
|
|
5. Escalar si hay dudas
|
|
|
|
## RESTRICCIONES
|
|
|
|
- NO cargar CCA completo
|
|
- NO delegar subtareas
|
|
- NO ejecutar recovery
|
|
- NO crear fuera del alcance
|
|
|
|
## REPORTE
|
|
|
|
```yaml
|
|
estado: "COMPLETADO | FALLIDO"
|
|
archivos: ["lista"]
|
|
validaciones: {build: "PASS", lint: "PASS"}
|
|
```
|
|
|
|
---
|
|
|
|
**Ver:** `SIMCO-SUBAGENTE.md`
|
|
```
|
|
|
|
**Tokens estimados:** ~200
|
|
|
|
---
|
|
|
|
### 3.6 _MAP-COMPACT.md
|
|
|
|
**Ruta:** `orchestration/agents/perfiles/compact/_MAP-COMPACT.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# MAPA DE PERFILES COMPACTOS
|
|
|
|
## Cuándo Usar
|
|
|
|
Usar perfiles compactos cuando:
|
|
- Agente opera como **subagente** (recibe delegación)
|
|
- Se necesita optimizar tokens
|
|
- Tarea es específica (1-2 archivos)
|
|
|
|
## Perfiles Disponibles
|
|
|
|
| Perfil | Dominio | Tokens |
|
|
|--------|---------|--------|
|
|
| PERFIL-BACKEND-COMPACT.md | NestJS/TypeScript | ~250 |
|
|
| PERFIL-FRONTEND-COMPACT.md | React/TypeScript | ~250 |
|
|
| PERFIL-DATABASE-COMPACT.md | PostgreSQL DDL | ~250 |
|
|
| PERFIL-DEVOPS-COMPACT.md | Docker/CI/CD | ~250 |
|
|
| PERFIL-ML-COMPACT.md | Python/ML | ~250 |
|
|
| PERFIL-GENERIC-SUBAGENT.md | Cualquier tarea | ~200 |
|
|
|
|
## Referencia
|
|
|
|
Para perfiles completos (agentes principales): Ver `../`
|
|
```
|
|
|
|
**Tokens estimados:** ~150
|
|
|
|
---
|
|
|
|
## 4. SPRINT 3: TEMPLATES ESCALONADOS (Prioridad Alta)
|
|
|
|
### 4.1 Renombrar Template Existente
|
|
|
|
**Acción:** Renombrar `TEMPLATE-DELEGACION-SUBAGENTE.md` → `TEMPLATE-DELEGACION-COMPLETA.md`
|
|
|
|
### 4.2 TEMPLATE-DELEGACION-ESTANDAR.md
|
|
|
|
**Ruta:** `orchestration/templates/TEMPLATE-DELEGACION-ESTANDAR.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# TEMPLATE: DELEGACIÓN ESTÁNDAR
|
|
|
|
**Uso:** Tareas de 1-2 archivos | **Tokens:** ~600
|
|
|
|
---
|
|
|
|
## DELEGACIÓN
|
|
|
|
### Subagente
|
|
```yaml
|
|
perfil: "PERFIL-{TIPO}-COMPACT.md"
|
|
proyecto: "{nombre}"
|
|
simco: "SIMCO-{OPERACION}.md"
|
|
```
|
|
|
|
### Contexto Heredado
|
|
```yaml
|
|
variables:
|
|
BACKEND_ROOT: "{valor}"
|
|
DB_NAME: "{valor}"
|
|
|
|
aliases:
|
|
@BACKEND: "{ruta}"
|
|
@DDL: "{ruta}"
|
|
```
|
|
|
|
### Tarea
|
|
```yaml
|
|
descripcion: "{1-2 oraciones}"
|
|
archivos:
|
|
- crear: "{ruta/archivo}"
|
|
referencia: "{ruta/patron}:líneas"
|
|
```
|
|
|
|
### Criterios
|
|
```yaml
|
|
- [ ] {criterio 1}
|
|
- [ ] {criterio 2}
|
|
- [ ] Build pasa
|
|
```
|
|
|
|
### Validación
|
|
```bash
|
|
{comando de validación}
|
|
```
|
|
|
|
---
|
|
|
|
**Ver:** `TEMPLATE-DELEGACION-COMPLETA.md` para tareas complejas
|
|
```
|
|
|
|
**Tokens estimados:** ~600
|
|
|
|
---
|
|
|
|
### 4.3 TEMPLATE-DELEGACION-MINIMA.md
|
|
|
|
**Ruta:** `orchestration/templates/TEMPLATE-DELEGACION-MINIMA.md`
|
|
|
|
**Contenido propuesto:**
|
|
|
|
```markdown
|
|
# TEMPLATE: DELEGACIÓN MÍNIMA
|
|
|
|
**Uso:** Tareas simples de 1 archivo | **Tokens:** ~250
|
|
|
|
---
|
|
|
|
## DELEGACIÓN
|
|
|
|
```yaml
|
|
subagente: "PERFIL-{TIPO}-COMPACT.md"
|
|
proyecto: "{nombre}"
|
|
tarea: "{descripción en 1 oración}"
|
|
crear: "{ruta/archivo}"
|
|
referencia: "{ruta/patron}:líneas"
|
|
criterio: "{criterio único}"
|
|
validar: "{comando}"
|
|
```
|
|
|
|
---
|
|
|
|
**Ejemplo:**
|
|
|
|
```yaml
|
|
subagente: "PERFIL-DATABASE-COMPACT.md"
|
|
proyecto: "trading-platform"
|
|
tarea: "Crear tabla notifications"
|
|
crear: "apps/database/ddl/schemas/notification_system/05-notifications.sql"
|
|
referencia: "apps/database/ddl/schemas/notification_system/02-notification_templates.sql:1-30"
|
|
criterio: "Carga limpia pasa"
|
|
validar: "./drop-and-recreate-database.sh"
|
|
```
|
|
```
|
|
|
|
**Tokens estimados:** ~250
|
|
|
|
---
|
|
|
|
## 5. SPRINT 4: INTEGRACIÓN (Prioridad Media)
|
|
|
|
### 5.1 Modificar SIMCO-DELEGACION.md
|
|
|
|
**Agregar al final del archivo existente:**
|
|
|
|
```markdown
|
|
---
|
|
|
|
## MATRIZ DE DECISIÓN: FORMATO DE HERENCIA
|
|
|
|
```yaml
|
|
CALCULAR_TOKENS_DISPONIBLES:
|
|
limite_seguro: 18000
|
|
contexto_actual: "{estimar}"
|
|
disponibles: "18000 - contexto_actual"
|
|
|
|
ELEGIR_FORMATO:
|
|
si_disponibles > 15000:
|
|
usar: "Formato Completo"
|
|
tokens_herencia: ~1000
|
|
incluir: "Variables + Aliases + Estado + Docs + Patrones"
|
|
|
|
si_disponibles 8000-15000:
|
|
usar: "Formato Compactado"
|
|
tokens_herencia: ~300
|
|
incluir: "Variables + Aliases (solo esenciales)"
|
|
|
|
si_disponibles < 8000:
|
|
usar: "Formato Ultra-compactado"
|
|
tokens_herencia: ~100
|
|
incluir: "Solo tarea + 1 referencia"
|
|
```
|
|
|
|
---
|
|
|
|
## SELECCIÓN DE TEMPLATE
|
|
|
|
```yaml
|
|
SEGUN_COMPLEJIDAD:
|
|
simple:
|
|
archivos: 1
|
|
usar: "TEMPLATE-DELEGACION-MINIMA.md"
|
|
tokens: ~250
|
|
|
|
estandar:
|
|
archivos: 2
|
|
usar: "TEMPLATE-DELEGACION-ESTANDAR.md"
|
|
tokens: ~600
|
|
|
|
compleja:
|
|
archivos: >2
|
|
accion: "DESGLOSAR en subtareas"
|
|
usar: "TEMPLATE-DELEGACION-COMPLETA.md"
|
|
tokens: ~1800
|
|
```
|
|
|
|
---
|
|
|
|
## FLUJO RECOMENDADO
|
|
|
|
```
|
|
1. Ejecutar CHECKLIST-PRE-DELEGACION.md
|
|
2. Calcular tokens disponibles
|
|
3. Seleccionar template según complejidad
|
|
4. Seleccionar formato herencia según tokens
|
|
5. Especificar PERFIL-*-COMPACT.md
|
|
6. Delegar
|
|
```
|
|
|
|
---
|
|
|
|
## PERFILES COMPACTOS
|
|
|
|
Para subagentes, usar perfiles en:
|
|
`orchestration/agents/perfiles/compact/`
|
|
|
|
Ver: `_MAP-COMPACT.md`
|
|
```
|
|
|
|
---
|
|
|
|
### 5.2 Modificar SIMCO-CONTROL-TOKENS.md
|
|
|
|
**Agregar después de CHECKLIST PRE-DELEGACIÓN:**
|
|
|
|
```markdown
|
|
---
|
|
|
|
## INTEGRACIÓN CON DELEGACIÓN
|
|
|
|
### Referencia Obligatoria
|
|
|
|
Antes de delegar, ejecutar:
|
|
- `orchestration/checklists/CHECKLIST-PRE-DELEGACION.md`
|
|
|
|
### Templates por Tokens
|
|
|
|
| Tokens Disponibles | Template | Formato Herencia |
|
|
|--------------------|----------|------------------|
|
|
| >15,000 | ESTANDAR o COMPLETA | Completo |
|
|
| 8,000-15,000 | ESTANDAR o MINIMA | Compactado |
|
|
| <8,000 | MINIMA | Ultra-compactado |
|
|
|
|
### Perfiles Compactos
|
|
|
|
Para subagentes, usar:
|
|
- `orchestration/agents/perfiles/compact/PERFIL-*-COMPACT.md`
|
|
- Ahorro: ~550 tokens por perfil
|
|
```
|
|
|
|
---
|
|
|
|
### 5.3 Modificar SIMCO-INICIALIZACION.md
|
|
|
|
**Agregar después del protocolo CCA:**
|
|
|
|
```markdown
|
|
---
|
|
|
|
## CCA PARA SUBAGENTES
|
|
|
|
Si estás operando como **subagente** (recibiste delegación):
|
|
|
|
1. **NO ejecutar CCA completo**
|
|
2. Seguir: `SIMCO-CCA-SUBAGENTE.md`
|
|
3. Usar: `PERFIL-*-COMPACT.md`
|
|
|
|
Ver: `orchestration/directivas/simco/SIMCO-SUBAGENTE.md`
|
|
```
|
|
|
|
---
|
|
|
|
### 5.4 Modificar _MAP.md (perfiles)
|
|
|
|
**Agregar sección:**
|
|
|
|
```markdown
|
|
---
|
|
|
|
## PERFILES COMPACTOS (PARA SUBAGENTES)
|
|
|
|
Ubicación: `compact/`
|
|
|
|
| Perfil | Uso | Tokens |
|
|
|--------|-----|--------|
|
|
| PERFIL-BACKEND-COMPACT.md | Subagente Backend | ~250 |
|
|
| PERFIL-FRONTEND-COMPACT.md | Subagente Frontend | ~250 |
|
|
| PERFIL-DATABASE-COMPACT.md | Subagente Database | ~250 |
|
|
| PERFIL-DEVOPS-COMPACT.md | Subagente DevOps | ~250 |
|
|
| PERFIL-ML-COMPACT.md | Subagente ML | ~250 |
|
|
| PERFIL-GENERIC-SUBAGENT.md | Subagente genérico | ~200 |
|
|
|
|
**Cuándo usar:**
|
|
- Agente recibe delegación (es subagente)
|
|
- Tarea específica de 1-2 archivos
|
|
- Optimización de tokens necesaria
|
|
|
|
Ver: `compact/_MAP-COMPACT.md`
|
|
```
|
|
|
|
---
|
|
|
|
## 6. SPRINT 5: PERFILES ADICIONALES (Prioridad Baja)
|
|
|
|
### 6.1 PERFIL-DEVOPS-COMPACT.md
|
|
|
|
Similar estructura a BACKEND-COMPACT, enfocado en Docker/CI/CD.
|
|
|
|
### 6.2 PERFIL-ML-COMPACT.md
|
|
|
|
Similar estructura, enfocado en Python/ML.
|
|
|
|
---
|
|
|
|
## 7. VALIDACIÓN DEL PLAN
|
|
|
|
### 7.1 Checklist de Completitud
|
|
|
|
```yaml
|
|
ARCHIVOS_NUEVOS:
|
|
sprint_1:
|
|
- [x] SIMCO-SUBAGENTE.md
|
|
- [x] SIMCO-CCA-SUBAGENTE.md
|
|
- [x] CHECKLIST-PRE-DELEGACION.md
|
|
|
|
sprint_2:
|
|
- [x] compact/ directorio
|
|
- [x] PERFIL-BACKEND-COMPACT.md
|
|
- [x] PERFIL-FRONTEND-COMPACT.md
|
|
- [x] PERFIL-DATABASE-COMPACT.md
|
|
- [x] PERFIL-DEVOPS-COMPACT.md
|
|
- [x] PERFIL-ML-COMPACT.md
|
|
- [x] PERFIL-GENERIC-SUBAGENT.md
|
|
- [x] _MAP-COMPACT.md
|
|
- [x] README.md
|
|
|
|
sprint_3:
|
|
- [x] TEMPLATE-DELEGACION-ESTANDAR.md
|
|
- [x] TEMPLATE-DELEGACION-MINIMA.md
|
|
- [x] Renombrar existente a COMPLETA
|
|
|
|
sprint_5:
|
|
- [x] PERFIL-DEVOPS-COMPACT.md
|
|
- [x] PERFIL-ML-COMPACT.md
|
|
|
|
ARCHIVOS_MODIFICADOS:
|
|
sprint_4:
|
|
- [x] SIMCO-DELEGACION.md
|
|
- [x] SIMCO-CONTROL-TOKENS.md
|
|
- [x] SIMCO-INICIALIZACION.md
|
|
- [x] _MAP.md (perfiles)
|
|
- [x] _INDEX.md (agregadas nuevas directivas)
|
|
```
|
|
|
|
### 7.2 Dependencias Validadas
|
|
|
|
```yaml
|
|
SIMCO-SUBAGENTE.md:
|
|
requiere:
|
|
- PERFIL-*-COMPACT.md (deben existir)
|
|
- SIMCO-CCA-SUBAGENTE.md
|
|
referenciado_por:
|
|
- Todos los perfiles compactos
|
|
- CHECKLIST-PRE-DELEGACION.md
|
|
|
|
PERFILES_COMPACT:
|
|
requieren:
|
|
- Perfiles originales (para referencia completa)
|
|
referenciados_por:
|
|
- SIMCO-SUBAGENTE.md
|
|
- TEMPLATE-DELEGACION-*.md
|
|
- _MAP.md
|
|
|
|
TEMPLATES:
|
|
requieren:
|
|
- PERFILES_COMPACT
|
|
- SIMCO-SUBAGENTE.md
|
|
referenciados_por:
|
|
- SIMCO-DELEGACION.md
|
|
- CHECKLIST-PRE-DELEGACION.md
|
|
```
|
|
|
|
---
|
|
|
|
## 8. PRÓXIMOS PASOS
|
|
|
|
### Fase 4: Validación
|
|
1. Revisar cada archivo propuesto
|
|
2. Verificar tokens estimados
|
|
3. Validar dependencias
|
|
|
|
### Fase 5: Refinamiento
|
|
1. Ajustar según feedback
|
|
2. Agregar ejemplos si es necesario
|
|
|
|
### Fase 6: Ejecución
|
|
1. Crear archivos en orden de sprints
|
|
2. Ejecutar modificaciones
|
|
3. Validar integridad
|
|
|
|
### Fase 7: Validación Final
|
|
1. Verificar todos los archivos creados
|
|
2. Probar flujo completo de delegación
|
|
3. Documentar resultados
|
|
|
|
---
|
|
|
|
## 9. MÉTRICAS DE ÉXITO
|
|
|
|
| Métrica | Antes | Después | Mejora |
|
|
|---------|-------|---------|--------|
|
|
| Tokens/perfil subagente | ~800 | ~250 | 69% |
|
|
| Tokens/delegación | ~1,800 | ~600 | 67% |
|
|
| Tokens/CCA subagente | ~10,000 | ~1,500 | 85% |
|
|
| Total por delegación | ~5,200 | ~2,150 | 59% |
|
|
|
|
---
|
|
|
|
**Estado:** COMPLETADO | **Fecha Finalizacion:** 2026-01-07
|