up-cc 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/package.json +9 -9
  2. package/{agents → up/agents}/up-architecture-supervisor.md +1 -1
  3. package/{agents → up/agents}/up-audit-supervisor.md +1 -1
  4. package/{agents → up/agents}/up-backend-specialist.md +13 -3
  5. package/{agents → up/agents}/up-chief-architect.md +1 -1
  6. package/{agents → up/agents}/up-chief-engineer.md +1 -1
  7. package/{agents → up/agents}/up-chief-operations.md +2 -2
  8. package/{agents → up/agents}/up-chief-product.md +1 -1
  9. package/{agents → up/agents}/up-chief-quality.md +1 -1
  10. package/{agents → up/agents}/up-code-reviewer.md +2 -2
  11. package/{agents → up/agents}/up-database-specialist.md +13 -3
  12. package/{agents → up/agents}/up-execution-supervisor.md +4 -4
  13. package/{agents → up/agents}/up-executor.md +107 -9
  14. package/{agents → up/agents}/up-frontend-specialist.md +13 -3
  15. package/{agents → up/agents}/up-operations-supervisor.md +1 -1
  16. package/{agents → up/agents}/up-planejador.md +17 -1
  17. package/{agents → up/agents}/up-planning-supervisor.md +3 -3
  18. package/{agents → up/agents}/up-product-supervisor.md +1 -1
  19. package/{agents → up/agents}/up-project-ceo.md +2 -2
  20. package/{agents → up/agents}/up-quality-supervisor.md +1 -1
  21. package/{agents → up/agents}/up-system-designer.md +2 -2
  22. package/{agents → up/agents}/up-verification-supervisor.md +1 -1
  23. package/{agents → up/agents}/up-visual-critic.md +1 -1
  24. package/{bin → up/bin}/lib/core.cjs +132 -0
  25. package/{bin → up/bin}/up-tools.cjs +1341 -3
  26. package/up/commands/adicionar-fase.md +47 -0
  27. package/up/commands/configurar.md +219 -0
  28. package/{commands → up/commands}/depurar.md +1 -1
  29. package/{commands → up/commands}/planejar-fase.md +4 -2
  30. package/up/templates/config.json +8 -0
  31. package/up/workflows/build.md +650 -0
  32. package/{workflows → up/workflows}/builder.md +766 -35
  33. package/{workflows → up/workflows}/executar-plano.md +69 -0
  34. package/{workflows → up/workflows}/governance.md +3 -3
  35. package/{workflows → up/workflows}/plan.md +214 -29
  36. package/{workflows → up/workflows}/planejar-fase.md +63 -5
  37. package/commands/adicionar-fase.md +0 -33
  38. package/commands/configurar.md +0 -106
  39. package/templates/config.json +0 -6
  40. package/workflows/build.md +0 -431
  41. /package/{agents → up/agents}/up-analista-codigo.md +0 -0
  42. /package/{agents → up/agents}/up-api-tester.md +0 -0
  43. /package/{agents → up/agents}/up-arquiteto.md +0 -0
  44. /package/{agents → up/agents}/up-auditor-modernidade.md +0 -0
  45. /package/{agents → up/agents}/up-auditor-performance.md +0 -0
  46. /package/{agents → up/agents}/up-auditor-ux.md +0 -0
  47. /package/{agents → up/agents}/up-blind-validator.md +0 -0
  48. /package/{agents → up/agents}/up-clone-crawler.md +0 -0
  49. /package/{agents → up/agents}/up-clone-design-extractor.md +0 -0
  50. /package/{agents → up/agents}/up-clone-feature-mapper.md +0 -0
  51. /package/{agents → up/agents}/up-clone-prd-writer.md +0 -0
  52. /package/{agents → up/agents}/up-clone-verifier.md +0 -0
  53. /package/{agents → up/agents}/up-consolidador-ideias.md +0 -0
  54. /package/{agents → up/agents}/up-delivery-auditor.md +0 -0
  55. /package/{agents → up/agents}/up-depurador.md +0 -0
  56. /package/{agents → up/agents}/up-devops-agent.md +0 -0
  57. /package/{agents → up/agents}/up-exhaustive-tester.md +0 -0
  58. /package/{agents → up/agents}/up-mapeador-codigo.md +0 -0
  59. /package/{agents → up/agents}/up-pesquisador-mercado.md +0 -0
  60. /package/{agents → up/agents}/up-pesquisador-projeto.md +0 -0
  61. /package/{agents → up/agents}/up-planning-auditor.md +0 -0
  62. /package/{agents → up/agents}/up-product-analyst.md +0 -0
  63. /package/{agents → up/agents}/up-qa-agent.md +0 -0
  64. /package/{agents → up/agents}/up-requirements-validator.md +0 -0
  65. /package/{agents → up/agents}/up-roteirista.md +0 -0
  66. /package/{agents → up/agents}/up-security-reviewer.md +0 -0
  67. /package/{agents → up/agents}/up-sintetizador-melhorias.md +0 -0
  68. /package/{agents → up/agents}/up-sintetizador.md +0 -0
  69. /package/{agents → up/agents}/up-technical-writer.md +0 -0
  70. /package/{agents → up/agents}/up-verificador.md +0 -0
  71. /package/{bin → up/bin}/install.js +0 -0
  72. /package/{bin → up/bin}/up-instrument.cjs +0 -0
  73. /package/{commands → up/commands}/adicionar-testes.md +0 -0
  74. /package/{commands → up/commands}/ajuda.md +0 -0
  75. /package/{commands → up/commands}/atualizar.md +0 -0
  76. /package/{commands → up/commands}/build.md +0 -0
  77. /package/{commands → up/commands}/clone-builder.md +0 -0
  78. /package/{commands → up/commands}/custos.md +0 -0
  79. /package/{commands → up/commands}/dashboard.md +0 -0
  80. /package/{commands → up/commands}/discutir-fase.md +0 -0
  81. /package/{commands → up/commands}/executar-fase.md +0 -0
  82. /package/{commands → up/commands}/ideias.md +0 -0
  83. /package/{commands → up/commands}/iniciar.md +0 -0
  84. /package/{commands → up/commands}/mapear-codigo.md +0 -0
  85. /package/{commands → up/commands}/melhorias.md +0 -0
  86. /package/{commands → up/commands}/mobile-first.md +0 -0
  87. /package/{commands → up/commands}/modo-builder.md +0 -0
  88. /package/{commands → up/commands}/novo-projeto.md +0 -0
  89. /package/{commands → up/commands}/onboard.md +0 -0
  90. /package/{commands → up/commands}/pausar.md +0 -0
  91. /package/{commands → up/commands}/plan.md +0 -0
  92. /package/{commands → up/commands}/progresso.md +0 -0
  93. /package/{commands → up/commands}/rapido.md +0 -0
  94. /package/{commands → up/commands}/remover-fase.md +0 -0
  95. /package/{commands → up/commands}/resetar.md +0 -0
  96. /package/{commands → up/commands}/retomar.md +0 -0
  97. /package/{commands → up/commands}/saude.md +0 -0
  98. /package/{commands → up/commands}/testar.md +0 -0
  99. /package/{commands → up/commands}/ux-tester.md +0 -0
  100. /package/{commands → up/commands}/verificar-trabalho.md +0 -0
  101. /package/{hooks → up/hooks}/up-context-monitor.js +0 -0
  102. /package/{hooks → up/hooks}/up-statusline.js +0 -0
  103. /package/{references → up/references}/audit-modernidade.md +0 -0
  104. /package/{references → up/references}/audit-performance.md +0 -0
  105. /package/{references → up/references}/audit-ux.md +0 -0
  106. /package/{references → up/references}/blueprints/audit.md +0 -0
  107. /package/{references → up/references}/blueprints/booking.md +0 -0
  108. /package/{references → up/references}/blueprints/community.md +0 -0
  109. /package/{references → up/references}/blueprints/crm.md +0 -0
  110. /package/{references → up/references}/blueprints/dashboard.md +0 -0
  111. /package/{references → up/references}/blueprints/data-management.md +0 -0
  112. /package/{references → up/references}/blueprints/ecommerce.md +0 -0
  113. /package/{references → up/references}/blueprints/marketplace.md +0 -0
  114. /package/{references → up/references}/blueprints/notifications.md +0 -0
  115. /package/{references → up/references}/blueprints/saas-users.md +0 -0
  116. /package/{references → up/references}/blueprints/settings.md +0 -0
  117. /package/{references → up/references}/checkpoints.md +0 -0
  118. /package/{references → up/references}/engineering-principles-compressed.md +0 -0
  119. /package/{references → up/references}/engineering-principles.md +0 -0
  120. /package/{references → up/references}/git-integration.md +0 -0
  121. /package/{references → up/references}/governance-rules-compressed.md +0 -0
  122. /package/{references → up/references}/governance-rules.md +0 -0
  123. /package/{references → up/references}/production-requirements-compressed.md +0 -0
  124. /package/{references → up/references}/production-requirements.md +0 -0
  125. /package/{references → up/references}/questioning.md +0 -0
  126. /package/{references → up/references}/rework-limits-compressed.md +0 -0
  127. /package/{references → up/references}/rework-limits.md +0 -0
  128. /package/{references → up/references}/severity-levels.md +0 -0
  129. /package/{references → up/references}/state-persistence.md +0 -0
  130. /package/{references → up/references}/ui-brand.md +0 -0
  131. /package/{templates → up/templates}/audit-plan.md +0 -0
  132. /package/{templates → up/templates}/audit-report.md +0 -0
  133. /package/{templates → up/templates}/builder-defaults.md +0 -0
  134. /package/{templates → up/templates}/checklist.md +0 -0
  135. /package/{templates → up/templates}/continue-here.md +0 -0
  136. /package/{templates → up/templates}/delivery.md +0 -0
  137. /package/{templates → up/templates}/design-tokens.md +0 -0
  138. /package/{templates → up/templates}/owner-profile.md +0 -0
  139. /package/{templates → up/templates}/owner.md +0 -0
  140. /package/{templates → up/templates}/pending.md +0 -0
  141. /package/{templates → up/templates}/plan-ready.md +0 -0
  142. /package/{templates → up/templates}/project.md +0 -0
  143. /package/{templates → up/templates}/report.md +0 -0
  144. /package/{templates → up/templates}/requirements.md +0 -0
  145. /package/{templates → up/templates}/roadmap.md +0 -0
  146. /package/{templates → up/templates}/state.md +0 -0
  147. /package/{templates → up/templates}/suggestion.md +0 -0
  148. /package/{templates → up/templates}/summary.md +0 -0
  149. /package/{workflows → up/workflows}/adicionar-fase.md +0 -0
  150. /package/{workflows → up/workflows}/builder-e2e.md +0 -0
  151. /package/{workflows → up/workflows}/ceo-intake.md +0 -0
  152. /package/{workflows → up/workflows}/ceo-updates.md +0 -0
  153. /package/{workflows → up/workflows}/clone-builder.md +0 -0
  154. /package/{workflows → up/workflows}/dcrv.md +0 -0
  155. /package/{workflows → up/workflows}/discutir-fase.md +0 -0
  156. /package/{workflows → up/workflows}/executar-fase.md +0 -0
  157. /package/{workflows → up/workflows}/ideias.md +0 -0
  158. /package/{workflows → up/workflows}/iniciar.md +0 -0
  159. /package/{workflows → up/workflows}/mapear-codigo.md +0 -0
  160. /package/{workflows → up/workflows}/melhorias.md +0 -0
  161. /package/{workflows → up/workflows}/mobile-first.md +0 -0
  162. /package/{workflows → up/workflows}/novo-projeto.md +0 -0
  163. /package/{workflows → up/workflows}/onboarding.md +0 -0
  164. /package/{workflows → up/workflows}/pausar.md +0 -0
  165. /package/{workflows → up/workflows}/progresso.md +0 -0
  166. /package/{workflows → up/workflows}/rapido.md +0 -0
  167. /package/{workflows → up/workflows}/remover-fase.md +0 -0
  168. /package/{workflows → up/workflows}/resetar.md +0 -0
  169. /package/{workflows → up/workflows}/retomar.md +0 -0
  170. /package/{workflows → up/workflows}/ux-tester.md +0 -0
  171. /package/{workflows → up/workflows}/verificar-trabalho.md +0 -0
@@ -0,0 +1,650 @@
1
+ <purpose>
2
+ Workflow `/up:build` — Execucao de projeto previamente planejado.
3
+
4
+ Requer `.plano/PLAN-READY.md` (gerado por `/up:plan`).
5
+
6
+ Conduz Estagios 3 (Build) + 4 (Quality Gate) + 4.5 (Delivery Audit) + 5 (Delivery).
7
+
8
+ Pode executar projeto planejado em outro runtime — confia no PLAN-READY.md.
9
+ </purpose>
10
+
11
+ <core_principle>
12
+ Este workflow assume que o projeto foi completamente planejado por `/up:plan`.
13
+
14
+ Diferenca do builder:
15
+ - Builder: planeja + executa em sequencia, no mesmo runtime
16
+ - Build: SO executa, le PLAN-READY.md gerado anteriormente (mesmo runtime ou outro)
17
+
18
+ **Model routing configuravel (v0.9.0+):**
19
+ Antes de spawnar qualquer agente, resolver o modelo:
20
+ ```bash
21
+ MODEL=$(node "$HOME/.claude/up/bin/up-tools.cjs" config resolve-model {agent-name} --raw)
22
+ ```
23
+ Se `default`: nao passar `model=`. Se `opus/sonnet/haiku`: passar `model="{MODEL}"` no spawn.
24
+ Isso permite que o usuario configure via `/up:configurar` quais agentes usam qual modelo.
25
+ Sem configuracao, todos usam o modelo do runtime (comportamento v0.6.0).
26
+
27
+ **Re-plan local permitido (max 2):**
28
+ Se durante execucao o execution-supervisor detectar que um plano esta inviavel,
29
+ ele pode pedir REQUEST_REPLAN. O planejador local refaz o plano daquela fase.
30
+ NUNCA volta pro runtime que planejou originalmente.
31
+
32
+ **REGRA ANTI-COLAPSO — SEPARACAO RIGIDA DE AGENTES:**
33
+
34
+ O LLM tende a otimizar colapsando passos — dar ao mesmo agente tarefas de executar + verificar,
35
+ ou pular supervisores por parecer "overhead". Isso e PROIBIDO.
36
+
37
+ **Cada passo do Stage 3 DEVE ser um Agent() SEPARADO.**
38
+ **NUNCA combinar dois passos em um unico spawn.**
39
+ **NUNCA instruir um agente a fazer o trabalho de outro.**
40
+
41
+ Exemplo do que NAO fazer:
42
+ ```
43
+ # ERRADO — combina execucao + verificacao
44
+ Agent(subagent_type="up-executor", prompt="Executar E verificar a fase...")
45
+
46
+ # ERRADO — pula supervisor
47
+ # (executar e marcar completa sem passar por execution-supervisor)
48
+ ```
49
+
50
+ **Mecanismo de enforcement: GATES verificaveis.**
51
+ Cada supervisor DEVE escrever no `.plano/governance/approvals.log`.
52
+ Cada GATE verifica que o log tem a entry esperada.
53
+ Se o gate falha, NAO avance — spawne o agente faltante.
54
+
55
+ **Pipeline obrigatorio por fase:**
56
+ ```
57
+ Specialist → [GATE A] → EXECUTION-SUPERVISOR → [GATE B] → Verificador → [GATE C] → VERIFICATION-SUPERVISOR → [GATE D] → E2E + DCRV → CHIEF-ENGINEER → [GATE E] → Marcar completa
58
+ ```
59
+ </core_principle>
60
+
61
+ <process>
62
+
63
+ ## Estagio 0: GATES OBRIGATORIOS
64
+
65
+ ### 0.1 Owner Profile (LOCAL)
66
+
67
+ ```bash
68
+ if [ ! -f ~/.claude/up/owner-profile.md ]; then
69
+ echo "Owner profile nao existe NESTE runtime. Rodando /up:onboard..."
70
+ # Delegar pro workflow onboarding.md
71
+ fi
72
+ ```
73
+
74
+ **IMPORTANTE:** O profile e do RUNTIME ATUAL, nao do runtime que planejou. Cada runtime tem seu profile.
75
+
76
+ ### 0.2 PLAN-READY.md Existe?
77
+
78
+ ```bash
79
+ if [ ! -f .plano/PLAN-READY.md ]; then
80
+ echo "ERRO: Este projeto nao foi planejado."
81
+ echo ""
82
+ echo "Use /up:plan primeiro pra planejar o projeto."
83
+ echo "Ou /up:modo-builder pra planejar e executar de uma vez."
84
+ exit 1
85
+ fi
86
+ ```
87
+
88
+ ### 0.3 Crash Recovery
89
+
90
+ ```bash
91
+ ls .plano/LOCK.md 2>/dev/null
92
+ ```
93
+
94
+ Se LOCK.md existe e `stage: build`: retomar.
95
+
96
+ ## Estagio V: VALIDACAO LIGHT
97
+
98
+ **Confiar no PLAN-READY.md, mas spot-check estrutura.**
99
+
100
+ ### V.1 Parsear PLAN-READY.md
101
+
102
+ ```bash
103
+ # Extrair frontmatter
104
+ PLANNED_RUNTIME=$(grep "runtime:" .plano/PLAN-READY.md | head -1 | awk '{print $2}')
105
+ INTENDED_RUNTIME=$(grep -A1 "intended_execution:" .plano/PLAN-READY.md | tail -1 | awk '{print $2}')
106
+ TOTAL_PHASES=$(grep "total_phases:" .plano/PLAN-READY.md | awk '{print $2}')
107
+ CONFIDENCE=$(grep "planning_confidence:" .plano/PLAN-READY.md | awk '{print $2}')
108
+ ```
109
+
110
+ ### V.2 Validacao de Compatibilidade
111
+
112
+ ```bash
113
+ CURRENT_RUNTIME="claude-code" # detectar
114
+ [ -d ~/.config/opencode ] && CURRENT_RUNTIME="opencode"
115
+ [ -d ~/.gemini ] && CURRENT_RUNTIME="gemini-cli"
116
+
117
+ # Se intended_execution especifica um runtime e nao e o atual, alertar
118
+ if [ "$INTENDED_RUNTIME" != "same" ] && [ "$INTENDED_RUNTIME" != "any" ] && [ "$INTENDED_RUNTIME" != "$CURRENT_RUNTIME" ]; then
119
+ echo "AVISO: Plano gerado pra $INTENDED_RUNTIME, voce esta em $CURRENT_RUNTIME"
120
+ echo "Pode haver incompatibilidades. Continuar mesmo assim?"
121
+ # AskUserQuestion sim/nao
122
+ fi
123
+ ```
124
+
125
+ ### V.3 Validar Artefatos Esperados
126
+
127
+ ```bash
128
+ [ -f .plano/PROJECT.md ] || { echo "FALTANDO: PROJECT.md"; FAIL=1; }
129
+ [ -f .plano/ROADMAP.md ] || { echo "FALTANDO: ROADMAP.md"; FAIL=1; }
130
+ [ -f .plano/REQUIREMENTS.md ] || { echo "FALTANDO: REQUIREMENTS.md"; FAIL=1; }
131
+ [ -f .plano/SYSTEM-DESIGN.md ] || { echo "FALTANDO: SYSTEM-DESIGN.md"; FAIL=1; }
132
+ ```
133
+
134
+ ### V.4 Validar Planos Listados
135
+
136
+ Pra cada plano listado em PLAN-READY.md, checar se arquivo existe:
137
+
138
+ ```bash
139
+ # Extrair lista de planos do PLAN-READY.md
140
+ PLANS=$(grep -oE "fases/[0-9]+-[a-z-]+/[0-9]+-[0-9]+-PLAN.md" .plano/PLAN-READY.md)
141
+
142
+ for plan in $PLANS; do
143
+ if [ ! -f ".plano/$plan" ]; then
144
+ echo "FALTANDO: $plan"
145
+ FAIL=1
146
+ fi
147
+ done
148
+ ```
149
+
150
+ ### V.5 Decidir
151
+
152
+ **Se todos arquivos OK:** prosseguir.
153
+
154
+ **Se algo falta:**
155
+ - Alertar usuario
156
+ - Oferecer: "Posso planejar localmente?" (re-roda /up:plan)
157
+ - Ou abortar
158
+
159
+ ## Estagio C: CEO CONFIRMA
160
+
161
+ Spawnar CEO local:
162
+
163
+ ```python
164
+ Agent(
165
+ subagent_type="up-project-ceo",
166
+ prompt="""
167
+ Confirmar execucao de projeto previamente planejado.
168
+
169
+ <files_to_read>
170
+ - ~/.claude/up/owner-profile.md (perfil LOCAL deste runtime)
171
+ - .plano/BRIEFING.md (briefing original)
172
+ - .plano/PLAN-READY.md (resumo do planejamento)
173
+ - .plano/AUDIT-PLAN.md (audit do planejamento)
174
+ - .plano/PENDING.md
175
+ </files_to_read>
176
+
177
+ Apresentar ao dono:
178
+ - "Detectei projeto planejado em {runtime} por {ceo_name_anterior}"
179
+ - Resumo: N fases, M planos
180
+ - Planning confidence: X/100
181
+ - Pendencias conhecidas
182
+ - "Iniciar execucao? (enter pra continuar)"
183
+
184
+ Se dono confirmar: prosseguir.
185
+ Se recusar: abortar.
186
+ """
187
+ )
188
+ ```
189
+
190
+ ## Estagio 3: BUILD (loop por fase — com GATES verificaveis)
191
+
192
+ **Inicializar governance:**
193
+ ```bash
194
+ mkdir -p .plano/governance
195
+ touch .plano/governance/approvals.log
196
+ echo "# Build governance initialized at $(date -u +%Y-%m-%dT%H:%M:%SZ)" >> .plano/governance/approvals.log
197
+ ```
198
+
199
+ Para cada fase em ROADMAP.md (em ordem):
200
+
201
+ ### 3.1 Carregar Plano da Fase
202
+
203
+ ```bash
204
+ PHASE_DIR=$(ls -d .plano/fases/{phase_number}-* 2>/dev/null)
205
+ PLAN=$(ls "$PHASE_DIR"/*-PLAN.md | head -1)
206
+ ```
207
+
208
+ ### 3.2 Detectar Tipo de Plano (Specialist Routing)
209
+
210
+ Ler o frontmatter do plano pra determinar qual specialist usar:
211
+ - Frontend tasks → up-frontend-specialist
212
+ - Backend tasks → up-backend-specialist
213
+ - Database tasks → up-database-specialist
214
+ - Misto → up-executor
215
+
216
+ ### 3.3 Spawnar Specialist (PASSO 1 — Agent SEPARADO)
217
+
218
+ **Wave 2 (v0.11+) — pre-inline context:**
219
+ ANTES do spawn, montar contexto via `up-tools.cjs context`. Isso injeta
220
+ PLAN, STATE, config, governance comprimida, engineering principles,
221
+ requirements-slice direto no prompt. O agente NAO refaz Read desses
222
+ arquivos. Economiza ~30k tokens por spawn.
223
+
224
+ ```bash
225
+ SPECIALIST_AGENT="up-executor" # ou specialist baseado em type do plano
226
+
227
+ # Wave 6+ — manifest filtra refs por papel
228
+ CTX=$(node "$HOME/.claude/up/bin/up-tools.cjs" context \
229
+ --plan "${PLAN}" \
230
+ --state \
231
+ --config \
232
+ --requirements "${PHASE_NUMBER}" \
233
+ --manifest "${SPECIALIST_AGENT}" \
234
+ --raw)
235
+
236
+ # Wave 5+ — complexity-aware model routing per plan
237
+ MODEL=$(node "$HOME/.claude/up/bin/up-tools.cjs" resolve-model-for-plan \
238
+ "${PLAN}" "${SPECIALIST_AGENT}" --raw)
239
+ CLASSIFY=$(node "$HOME/.claude/up/bin/up-tools.cjs" classify-task "${PLAN}" --raw)
240
+ COMPLEXITY=$(echo "$CLASSIFY" | grep -oE '"complexity"[^,]+' | grep -oE '"(simple|standard|complex)"' | tr -d '"')
241
+ SCORE=$(echo "$CLASSIFY" | grep -oE '"score"\s*:\s*[0-9]+' | grep -oE '[0-9]+')
242
+
243
+ # Wave 6+ — Iron rule: validar plan
244
+ VALIDATE=$(node "$HOME/.claude/up/bin/up-tools.cjs" validate-plan "${PLAN}" --raw)
245
+ VALIDATE_PASS=$(echo "$VALIDATE" | grep -oE '"pass"\s*:\s*(true|false)' | grep -oE '(true|false)')
246
+ if [ "$VALIDATE_PASS" = "false" ]; then
247
+ echo "IRON RULE FALHOU: Plan ${PLAN} excede limites. Voltando pro planejador."
248
+ echo "$VALIDATE" | grep -A 20 'suggestions'
249
+ exit 1
250
+ fi
251
+
252
+ node "$HOME/.claude/up/bin/up-tools.cjs" routing-log \
253
+ --plan "${PLAN}" --agent "${SPECIALIST_AGENT}" --model "${MODEL}" \
254
+ --complexity "${COMPLEXITY}" --score "${SCORE}" --outcome pending
255
+ ```
256
+
257
+ ```python
258
+ Agent(
259
+ subagent_type="{up-specialist}",
260
+ prompt=f"""
261
+ Executar Plano da Fase {phase_number}.
262
+
263
+ <prompt_context>
264
+ {CTX}
265
+ </prompt_context>
266
+
267
+ <production_requirements_compressed>
268
+ Categorias a respeitar (71 requisitos no total):
269
+ - UIST (UI States): loading/error/empty/success em TODA operacao async
270
+ - ERR (Error handling): boundaries, try/catch, sessao expirada, 404
271
+ - PERF: lazy loading, code split, debounce, pagination > 20 items, cache
272
+ - FORM: validacao inline, mensagens especificas, autofocus, mascaras
273
+ - RESP: 375px funcional, touch 44x44, hamburger mobile
274
+ - A11Y: alt, labels, focus visible, keyboard, contraste 4.5:1
275
+ - SEC: rotas protegidas, CSRF, XSS, rate limit, env vars, RLS
276
+ - POLISH: hover, transicoes 150-300ms, design tokens
277
+ </production_requirements_compressed>
278
+
279
+ <files_to_read>
280
+ O contexto principal ja esta no <prompt_context> acima. Ler do disco APENAS:
281
+ - ./CLAUDE.md (se existir)
282
+ - .plano/fases/{phase_number}/PHASE.md (se existir, complemento curto)
283
+ - .plano/DESIGN-TOKENS.md (so se frontend e existir)
284
+ - Arquivos referenciados em <files> das tarefas (codigo a editar)
285
+
286
+ TIER 3 — Sob demanda apenas:
287
+ - .plano/PROJECT.md (so se precisar visao geral)
288
+ - .plano/SYSTEM-DESIGN.md (so se decisao de arquitetura aparecer)
289
+ - .plano/REQUIREMENTS.md (so se a slice nao tiver info suficiente)
290
+
291
+ NAO refazer Read em PLAN, STATE.md, config.json, REQUIREMENTS-SLICE.md,
292
+ engineering-principles — ja estao inline em <prompt_context>.
293
+ </files_to_read>
294
+
295
+ Implementar todas as tarefas. Commitar atomicamente.
296
+ Gerar SUMMARY.md.
297
+ """
298
+ )
299
+ ```
300
+
301
+ ### --- GATE A: Verificar que execucao produziu artefatos ---
302
+
303
+ ```bash
304
+ echo "=== GATE A: Verificando artefatos da execucao (Fase ${PHASE_NUMBER}) ==="
305
+ SUMMARY_COUNT=$(ls ${PHASE_DIR}/*-SUMMARY.md 2>/dev/null | wc -l)
306
+ [ "$SUMMARY_COUNT" -eq 0 ] && echo "GATE A FALHOU: Nenhum SUMMARY.md. Re-executar specialist." && exit 1
307
+ echo "GATE A OK: ${SUMMARY_COUNT} SUMMARY(s)"
308
+ ```
309
+
310
+ ### --- Patch routing outcome (Wave 5+) ---
311
+
312
+ ```bash
313
+ if [ "$SUMMARY_COUNT" -gt 0 ]; then
314
+ OUTCOME=success
315
+ elif echo "$SPAWN_RETURN" | grep -q "^ABORTED:"; then
316
+ OUTCOME=abort
317
+ else
318
+ OUTCOME=rework
319
+ fi
320
+
321
+ node "$HOME/.claude/up/bin/up-tools.cjs" routing-log --update \
322
+ --plan "${PLAN}" --agent "${SPECIALIST_AGENT}" --model "${MODEL}" \
323
+ --complexity "${COMPLEXITY}" --score "${SCORE}" \
324
+ --outcome "${OUTCOME}" --rework-cycles "${REWORK_COUNT:-0}"
325
+ ```
326
+
327
+ ### 3.4 Execution Supervisor Revisa (PASSO 2 — Agent SEPARADO)
328
+
329
+ ```python
330
+ Agent(
331
+ subagent_type="up-execution-supervisor",
332
+ prompt=f"""
333
+ Revisar execucao da Fase {phase_number}.
334
+
335
+ <governance_compressed>
336
+ DECISOES: APPROVE | REQUEST_CHANGES | REQUEST_REPLAN | ESCALATE
337
+ REWORK: max 3 ciclos antes de forcar approval com debito
338
+ NUNCA APROVAR: trabalho nao verificado, evidencia ambigua, claim sem backing,
339
+ stub/placeholder, falta de wiring
340
+ </governance_compressed>
341
+
342
+ <engineering_principles_compressed>
343
+ 1. Implementacao real (zero placeholder)
344
+ 2. Correto, nao rapido
345
+ 3. Conectado ponta a ponta
346
+ 4. Consistencia (seguir patterns existentes)
347
+ 5. Dados reais
348
+ 6. Custo futuro
349
+ </engineering_principles_compressed>
350
+
351
+ <files_to_read>
352
+ - {PLAN}
353
+ - {PHASE_DIR}/*-SUMMARY.md
354
+ - git diff (use Bash)
355
+ - .plano/fases/{phase_number}/REQUIREMENTS-SLICE.md (se existir)
356
+
357
+ Sob demanda apenas:
358
+ - $HOME/.claude/up/references/engineering-principles-compressed.md (exemplos)
359
+ - $HOME/.claude/up/references/governance-rules-compressed.md (hierarquia)
360
+ - $HOME/.claude/up/references/rework-limits-compressed.md (fluxos)
361
+ - $HOME/.claude/up/references/production-requirements-compressed.md (IDs especificos)
362
+ </files_to_read>
363
+
364
+ Decisao: APPROVE | REQUEST_CHANGES | REQUEST_REPLAN | ESCALATE
365
+
366
+ REQUEST_REPLAN: Se descobrir que o plano e fundamentalmente errado/inviavel.
367
+ Max 2 re-plans por projeto.
368
+
369
+ **OUTPUT OBRIGATORIO (fazer ANTES de retornar):**
370
+ ```bash
371
+ echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) | phase-{phase_number} | execution-supervisor | {{DECISAO}} | {{motivo}}" >> .plano/governance/approvals.log
372
+ ```
373
+ Sem este log, o GATE B vai bloquear o avanço.
374
+ """
375
+ )
376
+ ```
377
+
378
+ ### --- GATE B: Verificar que execution-supervisor logou ---
379
+
380
+ ```bash
381
+ echo "=== GATE B: Verificando governance da execucao (Fase ${PHASE_NUMBER}) ==="
382
+ EXEC_ENTRY=$(grep "phase-${PHASE_NUMBER}.*execution-supervisor" .plano/governance/approvals.log 2>/dev/null | tail -1)
383
+ [ -z "$EXEC_ENTRY" ] && echo "GATE B FALHOU: execution-supervisor NAO logou. Spawnar agora." && exit 1
384
+ echo "GATE B OK: $EXEC_ENTRY"
385
+ ```
386
+
387
+ ### 3.5 Processar Decisao do Supervisor
388
+
389
+ **Se APPROVE:** prosseguir para verificacao.
390
+
391
+ **Se REQUEST_CHANGES:** re-spawn specialist com feedback (max 3 ciclos).
392
+
393
+ **Se REQUEST_REPLAN:**
394
+
395
+ ```bash
396
+ REPLAN_COUNT=$(cat .plano/governance/replans.log 2>/dev/null | wc -l)
397
+ if [ "$REPLAN_COUNT" -ge 2 ]; then
398
+ echo "Max re-plans atingido. Escalando pro CEO."
399
+ # ESCALATE
400
+ else
401
+ # Re-planejar fase localmente
402
+ echo "REQUEST_REPLAN aprovado. Re-planejando fase {phase_number} localmente..."
403
+
404
+ # Spawnar planejador LOCAL (Agent SEPARADO)
405
+ Agent(
406
+ subagent_type="up-planejador",
407
+ prompt=f"""
408
+ RE-PLAN da Fase {phase_number}.
409
+
410
+ Plano original: {PLAN}
411
+ Razao do re-plan: {execution_supervisor_reason}
412
+
413
+ Refaca o plano corrigindo o problema descoberto.
414
+ """
415
+ )
416
+
417
+ # Salvar como -PLAN-v2.md
418
+ mv "$PLAN" "${PLAN%-PLAN.md}-PLAN-v1.md"
419
+
420
+ # Registrar
421
+ echo "$(date -u) | phase-{phase_number} | execution-supervisor | REPLAN | reason: {reason}" >> .plano/governance/replans.log
422
+
423
+ # Planning-supervisor revisa novo plano (Agent SEPARADO)
424
+ Agent(subagent_type="up-planning-supervisor", prompt="""
425
+ Revisar re-plan da fase {phase_number}.
426
+ **OUTPUT OBRIGATORIO:** logar em .plano/governance/approvals.log
427
+ """)
428
+
429
+ # Voltar pro 3.3 (re-spawn specialist)
430
+ fi
431
+ ```
432
+
433
+ **Se ESCALATE:** chief-engineer entra.
434
+
435
+ ### 3.6 Verificacao (PASSO 3 — Agent SEPARADO)
436
+
437
+ **Wave 4 (v0.13+) — Verification Ladder Determinística**
438
+
439
+ ANTES do verificador-LLM, rodar checks deterministicos:
440
+
441
+ ```bash
442
+ STATIC=$(node "$HOME/.claude/up/bin/up-tools.cjs" verify-static --raw)
443
+ STATIC_OVERALL=$(echo "$STATIC" | grep -oE 'overall.{1,20}' | head -1 | grep -oE '"(pass|fail|skip)"' | tr -d '"')
444
+
445
+ if [ "$STATIC_OVERALL" = "pass" ]; then
446
+ # Pular verificador-LLM, criar VERIFICATION.md sintetico
447
+ cat > "${PHASE_DIR}/VERIFICATION.md" <<EOF
448
+ ---
449
+ status: passed
450
+ verifier: static-only
451
+ phase: ${PHASE_NUMBER}
452
+ checks_passed: lint+typecheck+test+audit
453
+ ---
454
+ Aprovacao automatica via verificacao estatica.
455
+ EOF
456
+ echo "Verification: PASSED via static checks (LLM skipped)"
457
+ fi
458
+ ```
459
+
460
+ Se STATIC=fail ou skip: spawnar verificador-LLM com static logs como contexto:
461
+
462
+ ```python
463
+ Agent(subagent_type="up-verificador", prompt=f"""
464
+ Verificar fase {phase_number}.
465
+
466
+ <static_check_results overall="{STATIC_OVERALL}">
467
+ Logs em .plano/runtime/verify-static-*.log
468
+ </static_check_results>
469
+
470
+ FOCAR no que falhou nos checks. Nao reexecutar tudo.
471
+ """)
472
+ ```
473
+
474
+ ### --- GATE C: Verificar que verificacao produziu artefatos ---
475
+
476
+ ```bash
477
+ echo "=== GATE C: Verificando artefatos da verificacao (Fase ${PHASE_NUMBER}) ==="
478
+ VERIF_COUNT=$(ls ${PHASE_DIR}/*-VERIFICATION.md 2>/dev/null | wc -l)
479
+ [ "$VERIF_COUNT" -eq 0 ] && echo "GATE C FALHOU: Sem VERIFICATION.md. Spawnar verificador." && exit 1
480
+ echo "GATE C OK: ${VERIF_COUNT} VERIFICATION(s)"
481
+ ```
482
+
483
+ ### 3.6.1 Verification Supervisor (PASSO 4 — Agent SEPARADO)
484
+
485
+ ```python
486
+ Agent(subagent_type="up-verification-supervisor", prompt=f"""
487
+ Revisar verificacao da Fase {phase_number}.
488
+ Decisao: APPROVE | REQUEST_CHANGES | ESCALATE
489
+
490
+ **OUTPUT OBRIGATORIO (fazer ANTES de retornar):**
491
+ ```bash
492
+ echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) | phase-{phase_number} | verification-supervisor | {{DECISAO}} | {{motivo}}" >> .plano/governance/approvals.log
493
+ ```
494
+ """)
495
+ ```
496
+
497
+ ### --- GATE D: Verificar que AMBOS supervisores logaram ---
498
+
499
+ ```bash
500
+ echo "=== GATE D: Verificando governance completa (Fase ${PHASE_NUMBER}) ==="
501
+ EXEC_OK=$(grep -c "phase-${PHASE_NUMBER}.*execution-supervisor" .plano/governance/approvals.log 2>/dev/null)
502
+ VERIF_OK=$(grep -c "phase-${PHASE_NUMBER}.*verification-supervisor" .plano/governance/approvals.log 2>/dev/null)
503
+ [ "$EXEC_OK" -eq 0 ] || [ "$VERIF_OK" -eq 0 ] && echo "GATE D FALHOU: supervisor faltante" && exit 1
504
+ echo "GATE D OK: ambos supervisores logaram"
505
+ ```
506
+
507
+ ### 3.7 E2E + DCRV (PASSO 5)
508
+
509
+ Ver builder.md secao 3.1.5 (E2E) e 3.1.5.1 (DCRV).
510
+
511
+ ### 3.8 Chief-engineer Aprova Fase (PASSO 6 — Agent SEPARADO)
512
+
513
+ ```python
514
+ Agent(
515
+ subagent_type="up-chief-engineer",
516
+ prompt=f"""
517
+ Revisar Fase {phase_number} consolidada.
518
+ Validar coerencia plano vs execucao vs verificacao.
519
+ Decidir: APPROVE | REQUEST_CHANGES | ESCALATE_CEO
520
+
521
+ **OUTPUT OBRIGATORIO (fazer ANTES de retornar):**
522
+ ```bash
523
+ echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) | phase-{phase_number} | chief-engineer | {{DECISAO}} | {{motivo}}" >> .plano/governance/approvals.log
524
+ ```
525
+ """
526
+ )
527
+ ```
528
+
529
+ ### --- GATE E: Verificar TODA governanca antes de marcar completa ---
530
+
531
+ ```bash
532
+ echo "=== GATE E: Verificacao FINAL (Fase ${PHASE_NUMBER}) ==="
533
+ SUMMARY_OK=$(ls ${PHASE_DIR}/*-SUMMARY.md 2>/dev/null | wc -l)
534
+ VERIF_FILE_OK=$(ls ${PHASE_DIR}/*-VERIFICATION.md 2>/dev/null | wc -l)
535
+ EXEC_OK=$(grep -c "phase-${PHASE_NUMBER}.*execution-supervisor" .plano/governance/approvals.log 2>/dev/null)
536
+ VERIF_OK=$(grep -c "phase-${PHASE_NUMBER}.*verification-supervisor" .plano/governance/approvals.log 2>/dev/null)
537
+ CHIEF_OK=$(grep -c "phase-${PHASE_NUMBER}.*chief-engineer" .plano/governance/approvals.log 2>/dev/null)
538
+
539
+ PASS=true
540
+ [ "$SUMMARY_OK" -eq 0 ] && echo "FALHA: Sem SUMMARY.md" && PASS=false
541
+ [ "$VERIF_FILE_OK" -eq 0 ] && echo "FALHA: Sem VERIFICATION.md" && PASS=false
542
+ [ "$EXEC_OK" -eq 0 ] && echo "FALHA: execution-supervisor NAO rodou" && PASS=false
543
+ [ "$VERIF_OK" -eq 0 ] && echo "FALHA: verification-supervisor NAO rodou" && PASS=false
544
+ [ "$CHIEF_OK" -eq 0 ] && echo "FALHA: chief-engineer NAO rodou" && PASS=false
545
+
546
+ if [ "$PASS" = false ]; then
547
+ echo "GATE E FALHOU: Voltar e executar passos faltantes."
548
+ exit 1
549
+ else
550
+ echo "GATE E OK: Todos 5 checks passaram."
551
+ fi
552
+ ```
553
+
554
+ ### 3.9 Marcar Completa e Avancar
555
+
556
+ **So apos GATE E passar.**
557
+
558
+ ## Estagio 4: QUALITY GATE GLOBAL
559
+
560
+ Mesmo processo do builder.md secao Estagio 4. Sem model routing.
561
+
562
+ ## Estagio 4.5: DELIVERY AUDIT
563
+
564
+ ```python
565
+ Agent(subagent_type="up-delivery-auditor", ...)
566
+ ```
567
+
568
+ ## Estagio 5: DELIVERY
569
+
570
+ Mesmo processo. CEO local apresenta resultado.
571
+
572
+ ### 5.X Marcar Projeto Completo
573
+
574
+ ```bash
575
+ # PLAN-READY.md → PROJECT-COMPLETE.md
576
+ mv .plano/PLAN-READY.md .plano/PROJECT-COMPLETE.md
577
+ ```
578
+
579
+ Adicionar ao frontmatter:
580
+ ```yaml
581
+ status: complete
582
+ completed_at: [timestamp]
583
+ completed_by:
584
+ runtime: [current]
585
+ ceo_name: [local]
586
+ final_confidence: [from audit]
587
+ ```
588
+
589
+ </process>
590
+
591
+ <replans>
592
+
593
+ ## Re-plans Locais (max 2)
594
+
595
+ Quando: execution-supervisor descobre que o plano original esta inviavel.
596
+
597
+ Como funciona:
598
+
599
+ ```
600
+ Execution falha
601
+
602
+ execution-supervisor analisa
603
+
604
+ Decide: REQUEST_REPLAN
605
+
606
+ Verifica replans.log < 2?
607
+ ├─ Sim: prosseguir
608
+ └─ Nao: ESCALATE pro CEO
609
+
610
+ Spawnar planejador LOCAL no runtime atual
611
+
612
+ Refaz plano daquela fase
613
+
614
+ Salva como PLAN-v2.md (preserva v1 pra historico)
615
+
616
+ Planning-supervisor LOCAL revisa
617
+
618
+ Se APPROVE: voltar pro executor com novo plano
619
+ Se REJECT: ESCALATE pro chief-engineer
620
+ ```
621
+
622
+ Registro em `.plano/governance/replans.log`:
623
+ ```
624
+ 2026-04-11T15:30:00Z | phase-3 | execution-supervisor | REPLAN | cycle 1/2
625
+ reason: Library X discontinued, need to use Y instead
626
+ original_plan: 03-01-PLAN-v1.md
627
+ new_plan: 03-01-PLAN.md (was v2)
628
+ ```
629
+
630
+ </replans>
631
+
632
+ <success_criteria>
633
+ - [ ] Owner profile LOCAL validado
634
+ - [ ] PLAN-READY.md existe e parseado
635
+ - [ ] Validacao light passou (artefatos + planos existem)
636
+ - [ ] CEO confirmou execucao
637
+ - [ ] Governance inicializada (.plano/governance/approvals.log)
638
+ - [ ] Todas fases executadas com SUMMARY.md (GATE A por fase)
639
+ - [ ] Execution-supervisor revisou CADA fase (GATE B — logou em approvals.log)
640
+ - [ ] Verificador produziu VERIFICATION.md por fase (GATE C)
641
+ - [ ] Verification-supervisor revisou CADA verificacao (GATE D — logou em approvals.log)
642
+ - [ ] Chief-engineer aprovou CADA fase (GATE E — logou em approvals.log)
643
+ - [ ] GATE E passou para CADA fase (todos 5 checks OK)
644
+ - [ ] Re-plans registrados (se houve)
645
+ - [ ] Quality Gate global passou
646
+ - [ ] Delivery audit aprovou
647
+ - [ ] CEO apresentou resultado
648
+ - [ ] PLAN-READY.md → PROJECT-COMPLETE.md
649
+ - [ ] .plano/governance/approvals.log tem entries de TODOS supervisores e chiefs
650
+ </success_criteria>