@girardelli/architect 2.2.0 → 4.0.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 (296) hide show
  1. package/README.md +105 -116
  2. package/__test_agent_output__/INDEX.md +1 -0
  3. package/__test_agent_output__/agents/AGENT-ORCHESTRATOR.md +1 -0
  4. package/__test_agent_output__/agents/DATABASE-ENGINEER.md +174 -0
  5. package/__test_agent_output__/agents/QA-TEST-ENGINEER.md +138 -0
  6. package/__test_agent_output__/agents/SECURITY-AUDITOR.md +106 -0
  7. package/__test_agent_output__/agents/TECH-DEBT-CONTROLLER.md +104 -0
  8. package/__test_agent_output__/agents/TYPESCRIPT-BACKEND-DEVELOPER.md +135 -0
  9. package/__test_agent_output__/guards/CODE-REVIEW-CHECKLIST.md +95 -0
  10. package/__test_agent_output__/guards/PREFLIGHT.md +200 -0
  11. package/__test_agent_output__/guards/QUALITY-GATES.md +1 -0
  12. package/__test_agent_output__/rules/00-general.md +229 -0
  13. package/__test_agent_output__/rules/01-architecture.md +191 -0
  14. package/__test_agent_output__/rules/02-security.md +402 -0
  15. package/__test_agent_output__/rules/03-nestjs.md +124 -0
  16. package/__test_agent_output__/templates/ADR.md +95 -0
  17. package/__test_agent_output__/templates/BDD.md +58 -0
  18. package/__test_agent_output__/templates/C4.md +68 -0
  19. package/__test_agent_output__/templates/TDD.md +86 -0
  20. package/__test_agent_output__/templates/THREAT-MODEL.md +82 -0
  21. package/__test_agent_output__/workflows/fix-bug.md +228 -0
  22. package/__test_agent_output__/workflows/new-feature.md +311 -0
  23. package/__test_agent_output__/workflows/review.md +95 -0
  24. package/__test_context_7RvUrO/src/modules/empty/empty.ts +0 -0
  25. package/__test_context_Rf5fNJ/src/modules/mixed/mixed.ts +5 -0
  26. package/__test_context_WRCnYH/src/modules/test/test.ts +10 -0
  27. package/__test_context_YsnVS3/src/modules/test/test.ts +10 -0
  28. package/__test_context_w7XZeH/src/modules/mixed/mixed.ts +5 -0
  29. package/__test_context_y5noh6/src/modules/empty/empty.ts +0 -0
  30. package/__test_framework__24OjAu/package.json +1 -0
  31. package/__test_framework__3ZDZsx/pyproject.toml +8 -0
  32. package/__test_framework__4T54Jn/package.json +1 -0
  33. package/__test_framework__4tlXu9/pyproject.toml +8 -0
  34. package/__test_framework__6boWqQ/Pipfile +6 -0
  35. package/__test_framework__6gygMU/pom.xml +10 -0
  36. package/__test_framework__6kxj0N/go.mod +8 -0
  37. package/__test_framework__7CEoXw/pom.xml +10 -0
  38. package/__test_framework__85DDz0/Pipfile +6 -0
  39. package/__test_framework__9WrRIr/pom.xml +7 -0
  40. package/__test_framework__ANqGKl/Gemfile +5 -0
  41. package/__test_framework__BCXTEM/go.mod +3 -0
  42. package/__test_framework__BHiPNq/setup.py +2 -0
  43. package/__test_framework__BqkiKv/package.json +1 -0
  44. package/__test_framework__C5yd8X/Pipfile.lock +1 -0
  45. package/__test_framework__C5yd8X/requirements.txt +1 -0
  46. package/__test_framework__C87d3a/manage.py +1 -0
  47. package/__test_framework__C87d3a/requirements.txt +2 -0
  48. package/__test_framework__DXNwc5/build.gradle +7 -0
  49. package/__test_framework__GhHSt3/build.gradle.kts +4 -0
  50. package/__test_framework__GzklJP/Cargo.toml +7 -0
  51. package/__test_framework__H4hd13/go.mod +8 -0
  52. package/__test_framework__HKjOXO/composer.json +1 -0
  53. package/__test_framework__HaDN45/Gemfile +3 -0
  54. package/__test_framework__IBO7YG/pyproject.toml +9 -0
  55. package/__test_framework__JwSOyF/pyproject.toml +6 -0
  56. package/__test_framework__K6HrCr/build.gradle +2 -0
  57. package/__test_framework__KzRPlh/pubspec.yaml +9 -0
  58. package/__test_framework__L6uIym/pyproject.toml +6 -0
  59. package/__test_framework__LOdoGK/requirements.txt +4 -0
  60. package/__test_framework__LgHzss/package.json +1 -0
  61. package/__test_framework__M76M6q/Gemfile +5 -0
  62. package/__test_framework__Mr9vWW/composer.json +1 -0
  63. package/__test_framework__N03Gnv/package.json +1 -0
  64. package/__test_framework__Num4UE/requirements +1 -0
  65. package/__test_framework__OAGw3Y/build.gradle +7 -0
  66. package/__test_framework__OQc8yG/pubspec.yaml +9 -0
  67. package/__test_framework__OwKZcd/requirements.txt +3 -0
  68. package/__test_framework__P0gFv7/requirements +1 -0
  69. package/__test_framework__PN55Rq/package.json +1 -0
  70. package/__test_framework__PQiqX8/pubspec.yaml +3 -0
  71. package/__test_framework__RBHsg7/composer.json +1 -0
  72. package/__test_framework__RHxif4/Cargo.toml +7 -0
  73. package/__test_framework__T0v0p1/Cargo.toml +4 -0
  74. package/__test_framework__Tu0clt/Pipfile.lock +1 -0
  75. package/__test_framework__Tu0clt/requirements.txt +1 -0
  76. package/__test_framework__TwDj9P/Cargo.toml +4 -0
  77. package/__test_framework__VQJNC4/pom.xml +7 -0
  78. package/__test_framework__W6sm05/package.json +1 -0
  79. package/__test_framework__W7vBLy/pyproject.toml +4 -0
  80. package/__test_framework__WNJOWT/setup.py +2 -0
  81. package/__test_framework__WSJs7U/package.json +1 -0
  82. package/__test_framework__YQ5VpA/build.gradle.kts +4 -0
  83. package/__test_framework__ZNEUEs/package.json +1 -0
  84. package/__test_framework__Znt922/pom.xml +7 -0
  85. package/__test_framework__azyg0h/pom.xml +7 -0
  86. package/__test_framework__c6otLr/package.json +1 -0
  87. package/__test_framework__cl9S9G/build.gradle +2 -0
  88. package/__test_framework__eilvV4/composer.json +1 -0
  89. package/__test_framework__gQZxXO/manage.py +1 -0
  90. package/__test_framework__gQZxXO/requirements.txt +2 -0
  91. package/__test_framework__ghvl26/poetry.lock +1 -0
  92. package/__test_framework__ghvl26/pyproject.toml +2 -0
  93. package/__test_framework__hR7b9U/Makefile +11 -0
  94. package/__test_framework__iESVsi/composer.json +1 -0
  95. package/__test_framework__jm6TJy/package.json +1 -0
  96. package/__test_framework__kBUpjs/pyproject.toml +9 -0
  97. package/__test_framework__kqoZrw/requirements.txt +4 -0
  98. package/__test_framework__lWkoyO/pyproject.toml +4 -0
  99. package/__test_framework__mTKnUO/package.json +1 -0
  100. package/__test_framework__nCeZwe/Makefile +11 -0
  101. package/__test_framework__oljsU0/package.json +1 -0
  102. package/__test_framework__osRG4q/go.mod +3 -0
  103. package/__test_framework__pCHH4F/package.json +1 -0
  104. package/__test_framework__pExx6E/Gemfile +3 -0
  105. package/__test_framework__pyBoGd/pyproject.toml +5 -0
  106. package/__test_framework__qw16VQ/package.json +1 -0
  107. package/__test_framework__rRayrG/package.json +1 -0
  108. package/__test_framework__s82zO5/package.json +1 -0
  109. package/__test_framework__tp8MFK/pyproject.toml +5 -0
  110. package/__test_framework__w44k4w/composer.json +1 -0
  111. package/__test_framework__yefPZY/poetry.lock +1 -0
  112. package/__test_framework__yefPZY/pyproject.toml +2 -0
  113. package/__test_framework__zCiyDT/requirements.txt +3 -0
  114. package/__test_framework__zGZN3j/pubspec.yaml +3 -0
  115. package/__test_framework__zXpnxL/package.json +1 -0
  116. package/architect-run.sh +431 -0
  117. package/assets/banner-v3.html +561 -0
  118. package/dist/agent-generator/context-enricher.d.ts +58 -0
  119. package/dist/agent-generator/context-enricher.d.ts.map +1 -0
  120. package/dist/agent-generator/context-enricher.js +581 -0
  121. package/dist/agent-generator/context-enricher.js.map +1 -0
  122. package/dist/agent-generator/domain-inferrer.d.ts +52 -0
  123. package/dist/agent-generator/domain-inferrer.d.ts.map +1 -0
  124. package/dist/agent-generator/domain-inferrer.js +575 -0
  125. package/dist/agent-generator/domain-inferrer.js.map +1 -0
  126. package/dist/agent-generator/framework-detector.d.ts +40 -0
  127. package/dist/agent-generator/framework-detector.d.ts.map +1 -0
  128. package/dist/agent-generator/framework-detector.js +611 -0
  129. package/dist/agent-generator/framework-detector.js.map +1 -0
  130. package/dist/agent-generator/index.d.ts +33 -0
  131. package/dist/agent-generator/index.d.ts.map +1 -0
  132. package/dist/agent-generator/index.js +477 -0
  133. package/dist/agent-generator/index.js.map +1 -0
  134. package/dist/agent-generator/stack-detector.d.ts +12 -0
  135. package/dist/agent-generator/stack-detector.d.ts.map +1 -0
  136. package/dist/agent-generator/stack-detector.js +128 -0
  137. package/dist/agent-generator/stack-detector.js.map +1 -0
  138. package/dist/agent-generator/templates/core/agents.d.ts +17 -0
  139. package/dist/agent-generator/templates/core/agents.d.ts.map +1 -0
  140. package/dist/agent-generator/templates/core/agents.js +1252 -0
  141. package/dist/agent-generator/templates/core/agents.js.map +1 -0
  142. package/dist/agent-generator/templates/core/architecture-rules.d.ts +7 -0
  143. package/dist/agent-generator/templates/core/architecture-rules.d.ts.map +1 -0
  144. package/dist/agent-generator/templates/core/architecture-rules.js +274 -0
  145. package/dist/agent-generator/templates/core/architecture-rules.js.map +1 -0
  146. package/dist/agent-generator/templates/core/general-rules.d.ts +8 -0
  147. package/dist/agent-generator/templates/core/general-rules.d.ts.map +1 -0
  148. package/dist/agent-generator/templates/core/general-rules.js +301 -0
  149. package/dist/agent-generator/templates/core/general-rules.js.map +1 -0
  150. package/dist/agent-generator/templates/core/index-md.d.ts +7 -0
  151. package/dist/agent-generator/templates/core/index-md.d.ts.map +1 -0
  152. package/dist/agent-generator/templates/core/index-md.js +246 -0
  153. package/dist/agent-generator/templates/core/index-md.js.map +1 -0
  154. package/dist/agent-generator/templates/core/orchestrator.d.ts +8 -0
  155. package/dist/agent-generator/templates/core/orchestrator.d.ts.map +1 -0
  156. package/dist/agent-generator/templates/core/orchestrator.js +422 -0
  157. package/dist/agent-generator/templates/core/orchestrator.js.map +1 -0
  158. package/dist/agent-generator/templates/core/preflight.d.ts +8 -0
  159. package/dist/agent-generator/templates/core/preflight.d.ts.map +1 -0
  160. package/dist/agent-generator/templates/core/preflight.js +213 -0
  161. package/dist/agent-generator/templates/core/preflight.js.map +1 -0
  162. package/dist/agent-generator/templates/core/quality-gates.d.ts +11 -0
  163. package/dist/agent-generator/templates/core/quality-gates.d.ts.map +1 -0
  164. package/dist/agent-generator/templates/core/quality-gates.js +254 -0
  165. package/dist/agent-generator/templates/core/quality-gates.js.map +1 -0
  166. package/dist/agent-generator/templates/core/security-rules.d.ts +7 -0
  167. package/dist/agent-generator/templates/core/security-rules.d.ts.map +1 -0
  168. package/dist/agent-generator/templates/core/security-rules.js +528 -0
  169. package/dist/agent-generator/templates/core/security-rules.js.map +1 -0
  170. package/dist/agent-generator/templates/core/skills-generator.d.ts +6 -0
  171. package/dist/agent-generator/templates/core/skills-generator.d.ts.map +1 -0
  172. package/dist/agent-generator/templates/core/skills-generator.js +207 -0
  173. package/dist/agent-generator/templates/core/skills-generator.js.map +1 -0
  174. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts +7 -0
  175. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts.map +1 -0
  176. package/dist/agent-generator/templates/core/workflow-fix-bug.js +237 -0
  177. package/dist/agent-generator/templates/core/workflow-fix-bug.js.map +1 -0
  178. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts +8 -0
  179. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts.map +1 -0
  180. package/dist/agent-generator/templates/core/workflow-new-feature.js +321 -0
  181. package/dist/agent-generator/templates/core/workflow-new-feature.js.map +1 -0
  182. package/dist/agent-generator/templates/core/workflow-review.d.ts +7 -0
  183. package/dist/agent-generator/templates/core/workflow-review.d.ts.map +1 -0
  184. package/dist/agent-generator/templates/core/workflow-review.js +104 -0
  185. package/dist/agent-generator/templates/core/workflow-review.js.map +1 -0
  186. package/dist/agent-generator/templates/domain/index.d.ts +22 -0
  187. package/dist/agent-generator/templates/domain/index.d.ts.map +1 -0
  188. package/dist/agent-generator/templates/domain/index.js +1176 -0
  189. package/dist/agent-generator/templates/domain/index.js.map +1 -0
  190. package/dist/agent-generator/templates/stack/index.d.ts +8 -0
  191. package/dist/agent-generator/templates/stack/index.d.ts.map +1 -0
  192. package/dist/agent-generator/templates/stack/index.js +695 -0
  193. package/dist/agent-generator/templates/stack/index.js.map +1 -0
  194. package/dist/agent-generator/templates/template-helpers.d.ts +75 -0
  195. package/dist/agent-generator/templates/template-helpers.d.ts.map +1 -0
  196. package/dist/agent-generator/templates/template-helpers.js +726 -0
  197. package/dist/agent-generator/templates/template-helpers.js.map +1 -0
  198. package/dist/agent-generator/types.d.ts +196 -0
  199. package/dist/agent-generator/types.d.ts.map +1 -0
  200. package/dist/agent-generator/types.js +27 -0
  201. package/dist/agent-generator/types.js.map +1 -0
  202. package/dist/analyzer.d.ts +5 -0
  203. package/dist/analyzer.d.ts.map +1 -1
  204. package/dist/analyzer.js +35 -4
  205. package/dist/analyzer.js.map +1 -1
  206. package/dist/analyzers/forecast.d.ts +85 -0
  207. package/dist/analyzers/forecast.d.ts.map +1 -0
  208. package/dist/analyzers/forecast.js +337 -0
  209. package/dist/analyzers/forecast.js.map +1 -0
  210. package/dist/analyzers/git-cache.d.ts +7 -0
  211. package/dist/analyzers/git-cache.d.ts.map +1 -0
  212. package/dist/analyzers/git-cache.js +41 -0
  213. package/dist/analyzers/git-cache.js.map +1 -0
  214. package/dist/analyzers/git-history.d.ts +113 -0
  215. package/dist/analyzers/git-history.d.ts.map +1 -0
  216. package/dist/analyzers/git-history.js +333 -0
  217. package/dist/analyzers/git-history.js.map +1 -0
  218. package/dist/analyzers/index.d.ts +10 -0
  219. package/dist/analyzers/index.d.ts.map +1 -0
  220. package/dist/analyzers/index.js +7 -0
  221. package/dist/analyzers/index.js.map +1 -0
  222. package/dist/analyzers/temporal-scorer.d.ts +72 -0
  223. package/dist/analyzers/temporal-scorer.d.ts.map +1 -0
  224. package/dist/analyzers/temporal-scorer.js +140 -0
  225. package/dist/analyzers/temporal-scorer.js.map +1 -0
  226. package/dist/cli.d.ts +2 -3
  227. package/dist/cli.d.ts.map +1 -1
  228. package/dist/cli.js +275 -113
  229. package/dist/cli.js.map +1 -1
  230. package/dist/html-reporter.d.ts +3 -1
  231. package/dist/html-reporter.d.ts.map +1 -1
  232. package/dist/html-reporter.js +248 -12
  233. package/dist/html-reporter.js.map +1 -1
  234. package/dist/index.d.ts +16 -3
  235. package/dist/index.d.ts.map +1 -1
  236. package/dist/index.js +63 -4
  237. package/dist/index.js.map +1 -1
  238. package/dist/project-summarizer.d.ts +18 -0
  239. package/dist/project-summarizer.d.ts.map +1 -0
  240. package/dist/project-summarizer.js +306 -0
  241. package/dist/project-summarizer.js.map +1 -0
  242. package/dist/refactor-reporter.js +1 -1
  243. package/dist/types.d.ts +13 -0
  244. package/dist/types.d.ts.map +1 -1
  245. package/package.json +12 -3
  246. package/src/agent-generator/context-enricher.ts +643 -0
  247. package/src/agent-generator/domain-inferrer.ts +625 -0
  248. package/src/agent-generator/framework-detector.ts +669 -0
  249. package/src/agent-generator/index.ts +555 -0
  250. package/src/agent-generator/stack-detector.ts +103 -0
  251. package/src/agent-generator/templates/core/agents.ts +1293 -0
  252. package/src/agent-generator/templates/core/architecture-rules.ts +287 -0
  253. package/src/agent-generator/templates/core/general-rules.ts +306 -0
  254. package/src/agent-generator/templates/core/index-md.ts +260 -0
  255. package/src/agent-generator/templates/core/orchestrator.ts +459 -0
  256. package/src/agent-generator/templates/core/preflight.ts +215 -0
  257. package/src/agent-generator/templates/core/quality-gates.ts +256 -0
  258. package/src/agent-generator/templates/core/security-rules.ts +543 -0
  259. package/src/agent-generator/templates/core/skills-generator.ts +236 -0
  260. package/src/agent-generator/templates/core/workflow-fix-bug.ts +239 -0
  261. package/src/agent-generator/templates/core/workflow-new-feature.ts +323 -0
  262. package/src/agent-generator/templates/core/workflow-review.ts +106 -0
  263. package/src/agent-generator/templates/domain/index.ts +1201 -0
  264. package/src/agent-generator/templates/stack/index.ts +705 -0
  265. package/src/agent-generator/templates/template-helpers.ts +776 -0
  266. package/src/agent-generator/types.ts +232 -0
  267. package/src/analyzer.ts +38 -4
  268. package/src/analyzers/forecast.ts +496 -0
  269. package/src/analyzers/git-cache.ts +52 -0
  270. package/src/analyzers/git-history.ts +488 -0
  271. package/src/analyzers/index.ts +33 -0
  272. package/src/analyzers/temporal-scorer.ts +227 -0
  273. package/src/cli.ts +316 -117
  274. package/src/html-reporter.ts +263 -13
  275. package/src/index.ts +92 -9
  276. package/src/project-summarizer.ts +347 -0
  277. package/src/refactor-reporter.ts +1 -1
  278. package/src/types.ts +10 -0
  279. package/tests/agent-generator.test.ts +411 -0
  280. package/tests/analyzers-integration.test.ts +174 -0
  281. package/tests/architect-adapter-enrichment.test.ts +9 -0
  282. package/tests/context-enricher.test.ts +971 -0
  283. package/tests/forecast.test.ts +509 -0
  284. package/tests/framework-detector.test.ts +1172 -0
  285. package/tests/git-history.test.ts +254 -0
  286. package/tests/scanner.test.ts +7 -8
  287. package/tests/scorer.test.ts +588 -0
  288. package/tests/stack-detector.test.ts +241 -0
  289. package/tests/template-generation.test.ts +706 -0
  290. package/tests/template-helpers.test.ts +1152 -0
  291. package/tests/temporal-scorer.test.ts +307 -0
  292. package/dist/agent-generator.d.ts +0 -106
  293. package/dist/agent-generator.d.ts.map +0 -1
  294. package/dist/agent-generator.js +0 -1398
  295. package/dist/agent-generator.js.map +0 -1
  296. package/src/agent-generator.ts +0 -1526
@@ -0,0 +1,459 @@
1
+ import { TemplateContext, EnrichedTemplateContext } from '../../types.js';
2
+ import {
3
+ getEnriched,
4
+ isEnriched,
5
+ depthScale,
6
+ depthAtLeast,
7
+ domainBadge,
8
+ complianceBadges,
9
+ depthIndicator,
10
+ modulesSummaryTable,
11
+ integrationsSummary,
12
+ frameworkBadge,
13
+ toolchainCommands,
14
+ projectStructureBadge,
15
+ } from '../template-helpers.js';
16
+
17
+ /**
18
+ * Generates enterprise-grade AGENT-ORCHESTRATOR.md
19
+ * ~800+ lines: 5-phase protocol, mandatory artifact gates, business interrogation,
20
+ * parallel dispatch, C4/BDD/TDD inline templates, risk matrix, implementation order.
21
+ */
22
+ export function generateOrchestrator(ctx: TemplateContext | EnrichedTemplateContext): string {
23
+ const { report, stack, projectName, stackLabel, plan, config } = ctx;
24
+ const layers = report.layers.map(l => l.name).join(', ') || 'Not detected';
25
+ const antiPatterns = report.antiPatterns.map(a => `${a.name} (${a.severity})`).join(', ') || 'None';
26
+ const agentDispatch = buildAgentDispatch(ctx);
27
+ const businessQuestions = buildBusinessQuestions(ctx);
28
+
29
+ // Extract toolchain commands for Quality Gates (dynamic per-stack)
30
+ const enrichedCtx = isEnriched(ctx) ? ctx : null;
31
+ const buildCmd = enrichedCtx?.toolchain?.buildCmd || 'npm run build';
32
+ const testCmd = enrichedCtx?.toolchain?.testCmd || 'npm run test';
33
+
34
+ return `---
35
+ antigravity:
36
+ trigger: 'always_on'
37
+ globs: ['**/*']
38
+ description: 'META-AGENT ORQUESTRADOR — Centro de comando para ${projectName}'
39
+ priority: CRITICAL
40
+ agent_card:
41
+ id: 'orchestrator'
42
+ name: 'Agent Orchestrator'
43
+ role: 'coordination'
44
+ capabilities: [request-decomposition, agent-dispatch, plan-consolidation, quality-verification, artifact-gating]
45
+ inputs: [user-story, feature-request, bug-report, refactoring-request]
46
+ outputs: [consolidated-plan, implementation-blocks, effort-estimate, architecture-docs]
47
+ depends_on: []
48
+ version: 3.1.0
49
+ ---
50
+
51
+ # 🎭 AGENT-ORCHESTRATOR: ${projectName}
52
+
53
+ > **Centro de comando.** Toda requisição passa por aqui.
54
+ > **Nenhuma linha de código é escrita sem os artefatos obrigatórios.**
55
+
56
+ ---
57
+
58
+ ## ⛔ REGRA ABSOLUTA: ARTEFATOS ANTES DE CÓDIGO
59
+
60
+ \`\`\`
61
+ ╔══════════════════════════════════════════════════════════════╗
62
+ ║ ║
63
+ ║ ANTES de escrever QUALQUER linha de código, os seguintes ║
64
+ ║ artefatos DEVEM existir e ser APROVADOS pelo humano: ║
65
+ ║ ║
66
+ ║ 1. 🎨 MOCKUP (se tem UI) ║
67
+ ║ → Todas as telas, estados, erros, modais, mensagens ║
68
+ ║ → Seguir padrão visual do sistema ║
69
+ ║ ║
70
+ ║ 2. 📖 USER STORIES ║
71
+ ║ → Como [ator], quero [ação], para [benefício] ║
72
+ ║ → Critérios de aceite mensuráveis ║
73
+ ║ ║
74
+ ║ 3. 🏗️ ARQUITETURA (C4) ║
75
+ ║ → Contexto, Container, Componente, Código ║
76
+ ║ → Decisões arquiteturais (ADR) ║
77
+ ║ ║
78
+ ║ 4. 📋 TAREFAS ║
79
+ ║ → Breakdown com TASK-XXX ║
80
+ ║ → Estimativa T-shirt (XS/S/M/L/XL) ║
81
+ ║ ║
82
+ ║ 5. 🧪 BDD (cenários) ║
83
+ ║ → Given/When/Then para cada critério de aceite ║
84
+ ║ ║
85
+ ║ 6. 🔬 TDD (casos de teste) ║
86
+ ║ → RED → GREEN → REFACTOR ║
87
+ ║ → Cobertura mínima: ${config.coverageMinimum}% ║
88
+ ║ ║
89
+ ║ ⚠️ PRODUZIR APENAS UM IMPLEMENTATION PLAN SEM ESTES ║
90
+ ║ ARTEFATOS É VIOLAÇÃO DO PROTOCOLO. ║
91
+ ║ ║
92
+ ║ ORDEM DE IMPLEMENTAÇÃO: ║
93
+ ║ 1° Backend → 2° Doc. Integração → 3° Frontend/App ║
94
+ ║ ║
95
+ ╚══════════════════════════════════════════════════════════════╝
96
+ \`\`\`
97
+
98
+ ---
99
+
100
+ ## 📊 Contexto do Projeto
101
+
102
+ | Métrica | Valor |
103
+ |---------|-------|
104
+ | **Projeto** | ${projectName} |
105
+ | **Stack** | ${stackLabel} |
106
+ | **Score Atual** | ${report.score.overall}/100 |
107
+ | **Meta de Score** | ${Math.min(100, report.score.overall + 10)}/100 |
108
+ | **Camadas** | ${layers} |
109
+ | **Anti-Patterns** | ${antiPatterns} |
110
+ | **Arquivos** | ${report.projectInfo.totalFiles} |
111
+ | **Linhas** | ${report.projectInfo.totalLines.toLocaleString()} |
112
+ | **Cobertura Mínima** | ${config.coverageMinimum}% |
113
+ | **Refatorações Pendentes** | ${plan.steps.length} steps |
114
+
115
+ ${depthAtLeast(ctx, 'medium') ? `\n---\n\n## 📍 Contexto Enriquecido\n\n${depthIndicator(ctx)} · ${projectStructureBadge(ctx)}\n\n${frameworkBadge(ctx)}\n${domainBadge(ctx)}${modulesSummaryTable(ctx) ? `\n### 📦 Resumo de Módulos\n\n${modulesSummaryTable(ctx)}` : ''}${integrationsSummary(ctx)}${complianceBadges(ctx)}${toolchainCommands(ctx)}` : ''}
116
+
117
+ ---
118
+
119
+ ## 🔄 Protocolo de Orquestração (5 Fases)
120
+
121
+ ### FASE 0: Parsing da Requisição
122
+
123
+ Ao receber qualquer requisição, CLASSIFICAR imediatamente:
124
+
125
+ \`\`\`
126
+ ✓ Nome da feature/fix: _______________
127
+ ✓ Tipo: [ ] Feature [ ] Bug Fix [ ] Refactoring [ ] Documentation
128
+ ✓ Camadas tocadas: [ ] Backend [ ] Frontend [ ] Mobile [ ] Database
129
+ ✓ Tem UI: [ ] Sim [ ] Não
130
+ ✓ Complexidade: [ ] XS (<2h) [ ] S (2-4h) [ ] M (4-8h) [ ] L (1-3d) [ ] XL (3d+)
131
+ ✓ Assunções (listar): _______________
132
+ ✓ Riscos identificados: _______________
133
+ \`\`\`
134
+
135
+ Se houver QUALQUER dúvida na classificação → **PERGUNTAR ao humano**.
136
+
137
+ ### FASE 1: Interrogação de Negócio
138
+
139
+ Antes de qualquer design, RESPONDER estas perguntas:
140
+
141
+ ${businessQuestions}
142
+
143
+ > **Se não conseguir responder ≥ 70% das perguntas relevantes → PERGUNTAR ao humano.**
144
+
145
+ ### FASE 2: Disparo de Agentes (Paralelo)
146
+
147
+ \`\`\`
148
+ ORQUESTRADOR decompõe a requisição
149
+
150
+ ${agentDispatch} │
151
+ └──→ CONSOLIDAÇÃO
152
+ \`\`\`
153
+
154
+ Cada agente recebe:
155
+ - Contexto do projeto (score, stack, anti-patterns)
156
+ - Requisição decomposta (sua parte)
157
+ - Constraints (regras, patterns proibidos)
158
+ - Output esperado (formato e escopo)
159
+
160
+ ### FASE 3: Consolidação
161
+
162
+ O orquestrador consolida as respostas dos agentes em:
163
+
164
+ 1. **Plano Unificado** com:
165
+ - Diagrama de arquitetura (C4)
166
+ - Cenários BDD
167
+ - Casos de teste TDD
168
+ - Estimativa de esforço (T-shirt)
169
+ - Riscos e mitigações
170
+ - Decisões arquiteturais (ADR)
171
+
172
+ 2. **6 Gates para Aprovação** (apresentar um de cada vez):
173
+ - Gate 1: MOCKUP → \`/approved\`
174
+ - Gate 2: User Stories → \`/approved\`
175
+ - Gate 3: Arquitetura → \`/approved\`
176
+ - Gate 4: Tasks → \`/approved\`
177
+ - Gate 5: BDD → \`/approved\`
178
+ - Gate 6: TDD → \`/approved\`
179
+
180
+ ### FASE 4: Implementação (Após Todas Aprovações)
181
+
182
+ \`\`\`
183
+ ╔════════════════════════════════════════════════╗
184
+ ║ ORDEM OBRIGATÓRIA DE IMPLEMENTAÇÃO: ║
185
+ ║ ║
186
+ ║ 1° BACKEND ║
187
+ ║ └─→ Controllers, Services, Entities, DTOs ║
188
+ ║ └─→ Testes unitários + integração ║
189
+ ║ └─→ Migrations (se houver) ║
190
+ ║ ║
191
+ ║ 2° DOCUMENTO DE INTEGRAÇÃO ║
192
+ ║ └─→ Endpoints, payloads, erros ║
193
+ ║ └─→ Exemplos de request/response ║
194
+ ║ └─→ Contrato para frontend/app ║
195
+ ║ ║
196
+ ║ 3° FRONTEND / APP ║
197
+ ║ └─→ Baseado no documento de integração ║
198
+ ║ └─→ Componentes, pages, state ║
199
+ ║ └─→ Testes e2e ║
200
+ ╚════════════════════════════════════════════════╝
201
+ \`\`\`
202
+
203
+ ### FASE 5: Verificação e Entrega
204
+
205
+ \`\`\`
206
+ □ Build compila sem erros
207
+ □ Todos os testes passam
208
+ □ Cobertura ≥ ${config.coverageMinimum}%
209
+ □ Score ≥ ${config.scoreThreshold}/100
210
+ □ Zero anti-patterns CRITICAL novos
211
+ □ Sem regressão de score
212
+ □ Lint sem warnings
213
+ □ Documentação atualizada
214
+ \`\`\`
215
+
216
+ ---
217
+
218
+ ## 📐 Templates Inline
219
+
220
+ ### Template: User Story
221
+
222
+ \`\`\`markdown
223
+ ## US-XXX: [Título]
224
+
225
+ **Como** [ator],
226
+ **Quero** [ação],
227
+ **Para** [benefício].
228
+
229
+ ### Critérios de Aceite
230
+
231
+ - CA1: [critério mensurável]
232
+ - CA2: [critério mensurável]
233
+ - CA3: [critério mensurável]
234
+
235
+ ### Regras de Negócio
236
+
237
+ - RN1: [regra]
238
+ - RN2: [regra]
239
+
240
+ ### Notas Técnicas
241
+
242
+ - [observação relevante]
243
+ \`\`\`
244
+
245
+ ### Template: Task Breakdown
246
+
247
+ \`\`\`markdown
248
+ ## TASK-XXX: [Título]
249
+
250
+ **User Story:** US-XXX
251
+ **Estimativa:** [XS|S|M|L|XL]
252
+ **Camada:** [Backend|Frontend|App|Database]
253
+ **Agente:** [nome do agente]
254
+
255
+ ### Descrição
256
+ [o que precisa ser feito]
257
+
258
+ ### Critério de Done
259
+ - [ ] Implementado
260
+ - [ ] Testado (cobertura ≥ ${config.coverageMinimum}%)
261
+ - [ ] Code review
262
+ - [ ] Documentação
263
+ \`\`\`
264
+
265
+ ### Template: ADR (Architecture Decision Record)
266
+
267
+ \`\`\`markdown
268
+ ## ADR-XXX: [Título da Decisão]
269
+
270
+ **Status:** [proposed | accepted | deprecated | superseded]
271
+ **Data:** [YYYY-MM-DD]
272
+
273
+ ### Contexto
274
+ [Por que essa decisão é necessária?]
275
+
276
+ ### Decisão
277
+ [O que foi decidido?]
278
+
279
+ ### Consequências
280
+ [Positivas e negativas]
281
+
282
+ ### Alternativas Consideradas
283
+ 1. [alternativa 1] — descartada porque...
284
+ 2. [alternativa 2] — descartada porque...
285
+ \`\`\`
286
+
287
+ ---
288
+
289
+ ## ⚖️ Matriz de Risco
290
+
291
+ | Risco | Probabilidade | Impacto | Mitigação |
292
+ |-------|-------------|---------|-----------|
293
+ | Regressão de testes | Média | Alto | CI/CD com gate obrigatório |
294
+ | Degradação de score | Média | Médio | architect score antes de PR |
295
+ | Breaking changes em API | Alta | Crítico | Versionamento + integration doc |
296
+ | Security vulnerability | Baixa | Crítico | SECURITY-AUDITOR em toda feature |
297
+ | Performance degradation | Média | Alto | Benchmark antes/depois |
298
+
299
+ ---
300
+
301
+ ## 🏷️ T-Shirt Sizing
302
+
303
+ | Size | Duração | Scope | Gates |
304
+ |------|---------|-------|-------|
305
+ | **XS** | < 2h | Fix pontual, 1 arquivo | Simplificado (skip mockup se sem UI) |
306
+ | **S** | 2-4h | Fix + teste, 2-3 arquivos | Gates 2, 5, 6 obrigatórios |
307
+ | **M** | 4-8h | Feature pequena, 1 camada | Todos os 6 gates |
308
+ | **L** | 1-3 dias | Feature multi-camada | Todos + ADR |
309
+ | **XL** | 3+ dias | Feature épica | Todos + ADR + Threat Model |
310
+
311
+ ---
312
+
313
+ ## 🔀 Protocolo de Conflitos
314
+
315
+ Quando dois agentes discordam:
316
+
317
+ 1. **Identificar** o ponto de conflito
318
+ 2. **Documentar** ambas as posições com prós/contras
319
+ 3. **Escalar** ao humano com recomendação
320
+ 4. **Registrar** a decisão como ADR
321
+
322
+ > **NUNCA resolver conflitos automaticamente.** O humano decide.
323
+
324
+ ---
325
+
326
+ ## 🔧 Quality Gates (Enforcement)
327
+
328
+ \`\`\`
329
+ ╔══════════════════════════════════════════╗
330
+ ║ BUILD GATE ║
331
+ ║ $ ${buildCmd}
332
+ ║ Resultado: PASS ou BLOCK ║
333
+ ╠══════════════════════════════════════════╣
334
+ ║ TEST GATE ║
335
+ ║ $ ${testCmd}
336
+
337
+ ║ Resultado: PASS ou BLOCK ║
338
+ ╠══════════════════════════════════════════╣
339
+ ║ COVERAGE GATE ║
340
+ ║ Mínimo: ${config.coverageMinimum}% ║
341
+ ║ Resultado: PASS ou BLOCK ║
342
+ ║ ⚠️ INEGOCIÁVEL ║
343
+ ╠══════════════════════════════════════════╣
344
+ ║ SCORE GATE ║
345
+ ║ $ architect score ./src ║
346
+ ║ Mínimo: ${config.scoreThreshold}/100 ║
347
+ ║ Regressão: NÃO PERMITIDA ║
348
+ ╚══════════════════════════════════════════╝
349
+ \`\`\`
350
+
351
+ ---
352
+
353
+ **Gerado por Architect v3.1 · Score: ${report.score.overall}/100 · ${new Date().toISOString().split('T')[0]}**
354
+ `;
355
+ }
356
+
357
+ function buildAgentDispatch(ctx: TemplateContext | EnrichedTemplateContext): string {
358
+ const { stack } = ctx;
359
+ let dispatch = '';
360
+
361
+ // Add module context if enriched
362
+ const enriched = isEnriched(ctx) ? ctx : null;
363
+ const moduleContext = enriched?.modules?.length
364
+ ? ` (${enriched.modules.slice(0, 3).map((m: any) => m.name).join(', ')})`
365
+ : '';
366
+
367
+ if (stack.hasBackend) {
368
+ dispatch += ` ├──→ [${stack.primary.toUpperCase()}-BACKEND-DEVELOPER]${moduleContext}\n`;
369
+ dispatch += ` │ • Arquitetura de serviços e APIs\n`;
370
+ dispatch += ` │ • Lógica de negócio e validações\n`;
371
+ dispatch += ` │ • Entities, DTOs, migrations\n`;
372
+ dispatch += ` │\n`;
373
+ }
374
+ if (stack.hasFrontend) {
375
+ const fw = stack.frameworks.find(f => ['Angular', 'Vue', 'Next.js', 'React'].includes(f)) || 'FRONTEND';
376
+ dispatch += ` ├──→ [${fw.toUpperCase().replace('.', '')}-FRONTEND-DEVELOPER]\n`;
377
+ dispatch += ` │ • Componentes e páginas\n`;
378
+ dispatch += ` │ • State management e formulários\n`;
379
+ dispatch += ` │ • UX responsiva\n`;
380
+ dispatch += ` │\n`;
381
+ }
382
+ if (stack.hasMobile) {
383
+ dispatch += ` ├──→ [FLUTTER-UI-DEVELOPER]\n`;
384
+ dispatch += ` │ • Screens e widgets\n`;
385
+ dispatch += ` │ • Navegação e integração API\n`;
386
+ dispatch += ` │\n`;
387
+ }
388
+ if (stack.hasDatabase) {
389
+ dispatch += ` ├──→ [DATABASE-ENGINEER]\n`;
390
+ dispatch += ` │ • Schema design e migrations\n`;
391
+ dispatch += ` │ • Índices e performance de queries\n`;
392
+ dispatch += ` │\n`;
393
+ }
394
+
395
+ dispatch += ` ├──→ [SECURITY-AUDITOR]\n`;
396
+ dispatch += ` │ • Análise de ameaças (STRIDE)\n`;
397
+ dispatch += ` │ • Compliance check\n`;
398
+ dispatch += ` │\n`;
399
+ dispatch += ` ├──→ [QA-TEST-ENGINEER]\n`;
400
+ dispatch += ` │ • Plano de testes\n`;
401
+ dispatch += ` │ • Cobertura mínima: ${ctx.config.coverageMinimum}%\n`;
402
+ dispatch += ` │\n`;
403
+ dispatch += ` └──→ [TECH-DEBT-CONTROLLER]\n`;
404
+ dispatch += ` • Débito técnico existente\n`;
405
+ dispatch += ` • Refatorações pré-requisito\n`;
406
+
407
+ return dispatch;
408
+ }
409
+
410
+ function buildBusinessQuestions(ctx: TemplateContext | EnrichedTemplateContext): string {
411
+ const questions = [
412
+ 'Q1: Quem são os atores envolvidos? (personas)',
413
+ 'Q2: Qual o impacto em receita/negócio?',
414
+ 'Q3: Existem regras de negócio específicas?',
415
+ 'Q4: Quais métricas de sucesso?',
416
+ 'Q5: Há requisitos de compliance (LGPD, PCI, etc)?',
417
+ 'Q6: Quais módulos/serviços são afetados?',
418
+ 'Q7: Quais entidades de banco são tocadas?',
419
+ 'Q8: Existe fluxo de dados entre sistemas?',
420
+ 'Q9: Precisa de versionamento de API?',
421
+ 'Q10: Há integrações externas envolvidas?',
422
+ ];
423
+
424
+ // Add domain-specific questions if enriched context available
425
+ const enriched = isEnriched(ctx) ? ctx : null;
426
+ if (enriched?.domain) {
427
+ const { domain } = enriched;
428
+ questions.push(`Q11: Como isso se alinha com o domínio ${domain.domain}?`);
429
+
430
+ if (domain.compliance?.length) {
431
+ const complianceNames = domain.compliance.map((c: any) => c.name).join(', ');
432
+ questions.push(`Q12: Como garantir conformidade com ${complianceNames}?`);
433
+ }
434
+
435
+ if (domain.integrations?.length) {
436
+ const integrationNames = domain.integrations.slice(0, 3).map((i: any) => i.name).join(', ');
437
+ questions.push(`Q13: Como essa mudança afeta as integrações com ${integrationNames}?`);
438
+ }
439
+ }
440
+
441
+ if (ctx.stack.hasDatabase) {
442
+ const startIdx = enriched?.domain ? 14 : 11;
443
+ questions.push(
444
+ `Q${startIdx}: Volume estimado de dados?`,
445
+ `Q${startIdx + 1}: Há picos de uso previsíveis?`,
446
+ `Q${startIdx + 2}: Processamento síncrono ou assíncrono?`,
447
+ );
448
+ }
449
+
450
+ let nextQ = questions.length + 1;
451
+ questions.push(
452
+ `Q${nextQ++}: Quem precisa de autenticação?`,
453
+ `Q${nextQ++}: Quais permissões são necessárias?`,
454
+ `Q${nextQ++}: Há dados sensíveis envolvidos?`,
455
+ `Q${nextQ++}: Quais ameaças são relevantes?`,
456
+ );
457
+
458
+ return questions.map(q => `- **${q}**`).join('\n');
459
+ }
@@ -0,0 +1,215 @@
1
+ import { TemplateContext, EnrichedTemplateContext } from '../../types.js';
2
+ import { getEnriched } from '../template-helpers.js';
3
+
4
+ /**
5
+ * Generates enterprise-grade PREFLIGHT.md
6
+ * 6-phase checklist: mental prep → mandatory reads → environment → business rules →
7
+ * before-code by layer → before-done. Red flags, diagnostic template, delivery checklist.
8
+ */
9
+ export function generatePreflight(ctx: TemplateContext): string {
10
+ const { stack, projectName, config, report } = ctx;
11
+ const enriched = getEnriched(ctx);
12
+ const tc = enriched.toolchain;
13
+
14
+ return `---
15
+ antigravity:
16
+ trigger: 'always_on'
17
+ globs: ['**/*']
18
+ description: 'PREFLIGHT — Checklist obrigatório pré-ação para ${projectName}'
19
+ priority: CRITICAL
20
+ ---
21
+
22
+ # ✈️ PREFLIGHT — Checklist Pré-Ação
23
+
24
+ > **NENHUMA ação de código é permitida antes de completar este checklist.**
25
+ > Pular qualquer fase é violação do protocolo.
26
+
27
+ ---
28
+
29
+ ## FASE 0: Preparação Mental
30
+
31
+ Antes de abrir qualquer arquivo:
32
+
33
+ \`\`\`
34
+ □ Li e entendi a requisição COMPLETAMENTE
35
+ □ Sei qual WORKFLOW estou seguindo (new-feature / fix-bug / review)
36
+ □ Identifiquei as CAMADAS envolvidas (Backend / Frontend / App / Database)
37
+ □ Tenho CLAREZA sobre o que é esperado como entrega
38
+ □ Se algo não está claro → PAREI e PERGUNTEI ao humano
39
+ \`\`\`
40
+
41
+ ---
42
+
43
+ ## FASE 1: Leitura Obrigatória
44
+
45
+ \`\`\`
46
+ □ [00-general.md](../rules/00-general.md) → Regras de Ouro do projeto
47
+ □ [QUALITY-GATES.md](./QUALITY-GATES.md) → Métricas e blockers
48
+ □ LESSONS-LEARNED.md (se existir) → Erros passados
49
+ □ ERROR-PATTERNS.md (se existir) → Padrões de erro conhecidos
50
+ □ BUSINESS-RULES.md (se existir) → Regras de negócio do domínio
51
+ \`\`\`
52
+
53
+ > **Objetivo:** Não repetir erros e entender o contexto antes de agir.
54
+
55
+ ---
56
+
57
+ ## FASE 2: Verificação de Ambiente
58
+
59
+ \`\`\`bash
60
+ # Git: verificar branch e status
61
+ git branch --show-current # NUNCA em main/develop direto
62
+ git status # Limpo antes de começar
63
+ git pull origin <branch> # Sincronizado
64
+
65
+ # Deps: verificar se está tudo instalado
66
+ ${tc?.installCmd || (stack.packageManager === 'npm' ? 'npm ci' : stack.packageManager === 'pip' ? 'pip install -r requirements.txt' : stack.packageManager === 'pub' ? 'flutter pub get' : `${stack.packageManager} install`)}
67
+
68
+ # Build: verificar se compila
69
+ ${tc?.buildCmd || (stack.packageManager === 'npm' ? 'npm run build' : stack.packageManager === 'pub' ? 'flutter build' : 'make build')}
70
+
71
+ # Tests: verificar se passam ANTES de começar
72
+ ${tc?.testCmd || (stack.testFramework === 'pytest' ? 'pytest' : stack.testFramework === 'flutter_test' ? 'flutter test' : stack.testFramework === 'go test' ? 'go test ./...' : 'npm run test')}
73
+ \`\`\`
74
+
75
+ \`\`\`
76
+ □ Branch correta (NUNCA main/develop)
77
+ □ Working tree limpa
78
+ □ Dependências instaladas
79
+ □ Build passando
80
+ □ Testes passando ANTES da minha alteração
81
+ \`\`\`
82
+
83
+ ---
84
+
85
+ ## FASE 3: Verificação de Regras de Negócio
86
+
87
+ \`\`\`
88
+ □ Entendo QUEM são os atores afetados
89
+ □ Entendo QUAL é a regra de negócio envolvida
90
+ □ Verifiquei se existe documentação do domínio
91
+ □ Se a feature envolve dinheiro/pagamento → ATENÇÃO REDOBRADA
92
+ □ Se a feature envolve dados pessoais → verificar LGPD/compliance
93
+ □ Se a feature muda um fluxo existente → verificar impacto em features dependentes
94
+ \`\`\`
95
+
96
+ ---
97
+
98
+ ## FASE 4: Before-Code Checklist (por Camada)
99
+
100
+ ### 4A: Backend ${stack.hasBackend ? '✅' : '⬜ (skip se não aplicável)'}
101
+
102
+ \`\`\`
103
+ □ Entendo a estrutura de módulos existente
104
+ □ Sei onde criar/modificar controllers, services, entities
105
+ □ Verifiquei se já existe código similar (DRY)
106
+ □ DTOs e validações planejados
107
+ □ Tratamento de erros definido
108
+ □ Sei qual padrão de teste usar (unitário + integração)
109
+ □ Migrations planejadas (se houver alteração de banco)
110
+ \`\`\`
111
+
112
+ ### 4B: Frontend ${stack.hasFrontend ? '✅' : '⬜ (skip se não aplicável)'}
113
+
114
+ \`\`\`
115
+ □ MOCKUP aprovado pelo humano
116
+ □ Entendo o state management utilizado
117
+ □ Sei onde criar/modificar componentes
118
+ □ Verificar padrão visual (cores, fontes, espaçamentos)
119
+ □ Responsividade considerada
120
+ □ Acessibilidade básica (labels, aria, contraste)
121
+ □ Documento de integração do backend disponível
122
+ \`\`\`
123
+
124
+ ### 4C: Mobile (Flutter) ${stack.hasMobile ? '✅' : '⬜ (skip se não aplicável)'}
125
+
126
+ \`\`\`
127
+ □ MOCKUP aprovado pelo humano
128
+ □ Entendo a navegação atual do app
129
+ □ Sei onde criar/modificar screens e widgets
130
+ □ Verificar padrão visual do app
131
+ □ Comportamento offline considerado
132
+ □ Documento de integração do backend disponível
133
+ \`\`\`
134
+
135
+ ### 4D: Database ${stack.hasDatabase ? '✅' : '⬜ (skip se não aplicável)'}
136
+
137
+ \`\`\`
138
+ □ Schema atual compreendido
139
+ □ Migration reversível planejada
140
+ □ Índices necessários identificados
141
+ □ Impacto em queries existentes avaliado
142
+ □ Seed data / fixtures atualizados
143
+ □ Backup strategy para dados existentes
144
+ \`\`\`
145
+
146
+ ---
147
+
148
+ ## FASE 5: Before-Commit
149
+
150
+ \`\`\`
151
+ □ Build compila sem erros
152
+ □ TODOS os testes passam (velhos + novos)
153
+ □ Cobertura ≥ ${config.coverageMinimum}%
154
+ □ Lint sem warnings
155
+ □ Sem console.log / print() em produção
156
+ □ Sem TODO / FIXME sem issue
157
+ □ Sem secrets hardcoded
158
+ □ Sem arquivos > 500 linhas sem justificativa
159
+ □ Commit message segue padrão (feat: / fix: / refactor: / docs:)
160
+ □ Branch está atualizada com base (rebase se necessário)
161
+ \`\`\`
162
+
163
+ ---
164
+
165
+ ## FASE 6: Before-Done
166
+
167
+ \`\`\`
168
+ □ TODOS os critérios de aceite estão cobertos
169
+ □ Score não regrediu: architect score ./src ≥ ${config.scoreThreshold}/100
170
+ □ Documentação atualizada (se necessário)
171
+ □ LESSONS-LEARNED atualizado (se descobri algo novo)
172
+ □ PR criado com descrição completa
173
+ □ Code review solicitado
174
+ \`\`\`
175
+
176
+ ---
177
+
178
+ ## 🚩 Red Flags — PARE IMEDIATAMENTE SE:
179
+
180
+ | Red Flag | Ação |
181
+ |----------|------|
182
+ | Não entendo a requisição | PARAR → Perguntar ao humano |
183
+ | Código que mexo tem 0% de cobertura | PARAR → Escrever testes ANTES |
184
+ | Estou modificando > 10 arquivos | PARAR → Reavaliar escopo |
185
+ | Build quebrou após minha mudança | PARAR → Reverter → Investigar |
186
+ | Estou copiando/colando código | PARAR → Extrair abstração |
187
+ | Estou trabalhando em main/develop | PARAR → Criar branch |
188
+ | Não tenho mockup e a feature tem UI | PARAR → Gate 1 primeiro |
189
+ | Estou escrevendo código sem testes | PARAR → TDD |
190
+
191
+ ---
192
+
193
+ ## 🔍 Template de Diagnóstico
194
+
195
+ Execute antes de qualquer implementação:
196
+
197
+ \`\`\`bash
198
+ # Estrutura do projeto
199
+ find . -type f -name "*.${stack.primary === 'Python' ? 'py' : stack.primary === 'Dart' ? 'dart' : 'ts'}" | head -30
200
+
201
+ # Dependências do módulo que vou modificar
202
+ grep -r "import.*${stack.primary === 'Python' ? 'from' : 'from'}" --include="*.${stack.primary === 'Python' ? 'py' : 'ts'}" [modulo]/ | head -20
203
+
204
+ # Testes existentes
205
+ find . -name "*.test.*" -o -name "*.spec.*" -o -name "*_test.*" | head -20
206
+
207
+ # Score atual
208
+ npx @girardelli/architect score .
209
+ \`\`\`
210
+
211
+ ---
212
+
213
+ **Gerado por Architect v3.1 · Score: ${report.score.overall}/100 · ${new Date().toISOString().split('T')[0]}**
214
+ `;
215
+ }