@girardelli/architect 2.2.0 → 5.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 (212) hide show
  1. package/README.md +105 -116
  2. package/architect-run.sh +431 -0
  3. package/assets/banner-v3.html +561 -0
  4. package/dist/agent-generator/context-enricher.d.ts +58 -0
  5. package/dist/agent-generator/context-enricher.d.ts.map +1 -0
  6. package/dist/agent-generator/context-enricher.js +613 -0
  7. package/dist/agent-generator/context-enricher.js.map +1 -0
  8. package/dist/agent-generator/domain-inferrer.d.ts +52 -0
  9. package/dist/agent-generator/domain-inferrer.d.ts.map +1 -0
  10. package/dist/agent-generator/domain-inferrer.js +585 -0
  11. package/dist/agent-generator/domain-inferrer.js.map +1 -0
  12. package/dist/agent-generator/framework-detector.d.ts +40 -0
  13. package/dist/agent-generator/framework-detector.d.ts.map +1 -0
  14. package/dist/agent-generator/framework-detector.js +611 -0
  15. package/dist/agent-generator/framework-detector.js.map +1 -0
  16. package/dist/agent-generator/index.d.ts +47 -0
  17. package/dist/agent-generator/index.d.ts.map +1 -0
  18. package/dist/agent-generator/index.js +545 -0
  19. package/dist/agent-generator/index.js.map +1 -0
  20. package/dist/agent-generator/stack-detector.d.ts +14 -0
  21. package/dist/agent-generator/stack-detector.d.ts.map +1 -0
  22. package/dist/agent-generator/stack-detector.js +124 -0
  23. package/dist/agent-generator/stack-detector.js.map +1 -0
  24. package/dist/agent-generator/templates/core/agents.d.ts +17 -0
  25. package/dist/agent-generator/templates/core/agents.d.ts.map +1 -0
  26. package/dist/agent-generator/templates/core/agents.js +1256 -0
  27. package/dist/agent-generator/templates/core/agents.js.map +1 -0
  28. package/dist/agent-generator/templates/core/architecture-rules.d.ts +7 -0
  29. package/dist/agent-generator/templates/core/architecture-rules.d.ts.map +1 -0
  30. package/dist/agent-generator/templates/core/architecture-rules.js +274 -0
  31. package/dist/agent-generator/templates/core/architecture-rules.js.map +1 -0
  32. package/dist/agent-generator/templates/core/general-rules.d.ts +8 -0
  33. package/dist/agent-generator/templates/core/general-rules.d.ts.map +1 -0
  34. package/dist/agent-generator/templates/core/general-rules.js +301 -0
  35. package/dist/agent-generator/templates/core/general-rules.js.map +1 -0
  36. package/dist/agent-generator/templates/core/hooks-generator.d.ts +21 -0
  37. package/dist/agent-generator/templates/core/hooks-generator.d.ts.map +1 -0
  38. package/dist/agent-generator/templates/core/hooks-generator.js +233 -0
  39. package/dist/agent-generator/templates/core/hooks-generator.js.map +1 -0
  40. package/dist/agent-generator/templates/core/index-md.d.ts +7 -0
  41. package/dist/agent-generator/templates/core/index-md.d.ts.map +1 -0
  42. package/dist/agent-generator/templates/core/index-md.js +246 -0
  43. package/dist/agent-generator/templates/core/index-md.js.map +1 -0
  44. package/dist/agent-generator/templates/core/orchestrator.d.ts +8 -0
  45. package/dist/agent-generator/templates/core/orchestrator.d.ts.map +1 -0
  46. package/dist/agent-generator/templates/core/orchestrator.js +422 -0
  47. package/dist/agent-generator/templates/core/orchestrator.js.map +1 -0
  48. package/dist/agent-generator/templates/core/preflight.d.ts +8 -0
  49. package/dist/agent-generator/templates/core/preflight.d.ts.map +1 -0
  50. package/dist/agent-generator/templates/core/preflight.js +213 -0
  51. package/dist/agent-generator/templates/core/preflight.js.map +1 -0
  52. package/dist/agent-generator/templates/core/quality-gates.d.ts +11 -0
  53. package/dist/agent-generator/templates/core/quality-gates.d.ts.map +1 -0
  54. package/dist/agent-generator/templates/core/quality-gates.js +254 -0
  55. package/dist/agent-generator/templates/core/quality-gates.js.map +1 -0
  56. package/dist/agent-generator/templates/core/security-rules.d.ts +7 -0
  57. package/dist/agent-generator/templates/core/security-rules.d.ts.map +1 -0
  58. package/dist/agent-generator/templates/core/security-rules.js +528 -0
  59. package/dist/agent-generator/templates/core/security-rules.js.map +1 -0
  60. package/dist/agent-generator/templates/core/skills-generator.d.ts +19 -0
  61. package/dist/agent-generator/templates/core/skills-generator.d.ts.map +1 -0
  62. package/dist/agent-generator/templates/core/skills-generator.js +546 -0
  63. package/dist/agent-generator/templates/core/skills-generator.js.map +1 -0
  64. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts +7 -0
  65. package/dist/agent-generator/templates/core/workflow-fix-bug.d.ts.map +1 -0
  66. package/dist/agent-generator/templates/core/workflow-fix-bug.js +237 -0
  67. package/dist/agent-generator/templates/core/workflow-fix-bug.js.map +1 -0
  68. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts +8 -0
  69. package/dist/agent-generator/templates/core/workflow-new-feature.d.ts.map +1 -0
  70. package/dist/agent-generator/templates/core/workflow-new-feature.js +321 -0
  71. package/dist/agent-generator/templates/core/workflow-new-feature.js.map +1 -0
  72. package/dist/agent-generator/templates/core/workflow-review.d.ts +7 -0
  73. package/dist/agent-generator/templates/core/workflow-review.d.ts.map +1 -0
  74. package/dist/agent-generator/templates/core/workflow-review.js +104 -0
  75. package/dist/agent-generator/templates/core/workflow-review.js.map +1 -0
  76. package/dist/agent-generator/templates/domain/index.d.ts +22 -0
  77. package/dist/agent-generator/templates/domain/index.d.ts.map +1 -0
  78. package/dist/agent-generator/templates/domain/index.js +1176 -0
  79. package/dist/agent-generator/templates/domain/index.js.map +1 -0
  80. package/dist/agent-generator/templates/stack/index.d.ts +8 -0
  81. package/dist/agent-generator/templates/stack/index.d.ts.map +1 -0
  82. package/dist/agent-generator/templates/stack/index.js +695 -0
  83. package/dist/agent-generator/templates/stack/index.js.map +1 -0
  84. package/dist/agent-generator/templates/template-helpers.d.ts +75 -0
  85. package/dist/agent-generator/templates/template-helpers.d.ts.map +1 -0
  86. package/dist/agent-generator/templates/template-helpers.js +726 -0
  87. package/dist/agent-generator/templates/template-helpers.js.map +1 -0
  88. package/dist/agent-generator/types.d.ts +196 -0
  89. package/dist/agent-generator/types.d.ts.map +1 -0
  90. package/dist/agent-generator/types.js +27 -0
  91. package/dist/agent-generator/types.js.map +1 -0
  92. package/dist/analyzer.d.ts +5 -0
  93. package/dist/analyzer.d.ts.map +1 -1
  94. package/dist/analyzer.js +46 -5
  95. package/dist/analyzer.js.map +1 -1
  96. package/dist/analyzers/forecast.d.ts +85 -0
  97. package/dist/analyzers/forecast.d.ts.map +1 -0
  98. package/dist/analyzers/forecast.js +337 -0
  99. package/dist/analyzers/forecast.js.map +1 -0
  100. package/dist/analyzers/git-cache.d.ts +7 -0
  101. package/dist/analyzers/git-cache.d.ts.map +1 -0
  102. package/dist/analyzers/git-cache.js +41 -0
  103. package/dist/analyzers/git-cache.js.map +1 -0
  104. package/dist/analyzers/git-history.d.ts +113 -0
  105. package/dist/analyzers/git-history.d.ts.map +1 -0
  106. package/dist/analyzers/git-history.js +333 -0
  107. package/dist/analyzers/git-history.js.map +1 -0
  108. package/dist/analyzers/index.d.ts +10 -0
  109. package/dist/analyzers/index.d.ts.map +1 -0
  110. package/dist/analyzers/index.js +7 -0
  111. package/dist/analyzers/index.js.map +1 -0
  112. package/dist/analyzers/temporal-scorer.d.ts +72 -0
  113. package/dist/analyzers/temporal-scorer.d.ts.map +1 -0
  114. package/dist/analyzers/temporal-scorer.js +140 -0
  115. package/dist/analyzers/temporal-scorer.js.map +1 -0
  116. package/dist/anti-patterns.d.ts +7 -0
  117. package/dist/anti-patterns.d.ts.map +1 -1
  118. package/dist/anti-patterns.js +25 -6
  119. package/dist/anti-patterns.js.map +1 -1
  120. package/dist/cli.d.ts +2 -3
  121. package/dist/cli.d.ts.map +1 -1
  122. package/dist/cli.js +275 -113
  123. package/dist/cli.js.map +1 -1
  124. package/dist/config.d.ts +6 -0
  125. package/dist/config.d.ts.map +1 -1
  126. package/dist/config.js +48 -11
  127. package/dist/config.js.map +1 -1
  128. package/dist/html-reporter.d.ts +3 -1
  129. package/dist/html-reporter.d.ts.map +1 -1
  130. package/dist/html-reporter.js +248 -12
  131. package/dist/html-reporter.js.map +1 -1
  132. package/dist/index.d.ts +16 -3
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +63 -4
  135. package/dist/index.js.map +1 -1
  136. package/dist/project-summarizer.d.ts +38 -0
  137. package/dist/project-summarizer.d.ts.map +1 -0
  138. package/dist/project-summarizer.js +463 -0
  139. package/dist/project-summarizer.js.map +1 -0
  140. package/dist/refactor-reporter.js +1 -1
  141. package/dist/scanner.d.ts +8 -2
  142. package/dist/scanner.d.ts.map +1 -1
  143. package/dist/scanner.js +153 -113
  144. package/dist/scanner.js.map +1 -1
  145. package/dist/scorer.d.ts.map +1 -1
  146. package/dist/scorer.js +24 -11
  147. package/dist/scorer.js.map +1 -1
  148. package/dist/types.d.ts +29 -0
  149. package/dist/types.d.ts.map +1 -1
  150. package/package.json +12 -3
  151. package/src/agent-generator/context-enricher.ts +672 -0
  152. package/src/agent-generator/domain-inferrer.ts +635 -0
  153. package/src/agent-generator/framework-detector.ts +669 -0
  154. package/src/agent-generator/index.ts +634 -0
  155. package/src/agent-generator/stack-detector.ts +115 -0
  156. package/src/agent-generator/templates/core/agents.ts +1296 -0
  157. package/src/agent-generator/templates/core/architecture-rules.ts +287 -0
  158. package/src/agent-generator/templates/core/general-rules.ts +306 -0
  159. package/src/agent-generator/templates/core/hooks-generator.ts +242 -0
  160. package/src/agent-generator/templates/core/index-md.ts +260 -0
  161. package/src/agent-generator/templates/core/orchestrator.ts +459 -0
  162. package/src/agent-generator/templates/core/preflight.ts +215 -0
  163. package/src/agent-generator/templates/core/quality-gates.ts +256 -0
  164. package/src/agent-generator/templates/core/security-rules.ts +543 -0
  165. package/src/agent-generator/templates/core/skills-generator.ts +585 -0
  166. package/src/agent-generator/templates/core/workflow-fix-bug.ts +239 -0
  167. package/src/agent-generator/templates/core/workflow-new-feature.ts +323 -0
  168. package/src/agent-generator/templates/core/workflow-review.ts +106 -0
  169. package/src/agent-generator/templates/domain/index.ts +1201 -0
  170. package/src/agent-generator/templates/stack/index.ts +705 -0
  171. package/src/agent-generator/templates/template-helpers.ts +776 -0
  172. package/src/agent-generator/types.ts +232 -0
  173. package/src/analyzer.ts +51 -5
  174. package/src/analyzers/forecast.ts +496 -0
  175. package/src/analyzers/git-cache.ts +52 -0
  176. package/src/analyzers/git-history.ts +488 -0
  177. package/src/analyzers/index.ts +33 -0
  178. package/src/analyzers/temporal-scorer.ts +227 -0
  179. package/src/anti-patterns.ts +29 -6
  180. package/src/cli.ts +316 -117
  181. package/src/config.ts +52 -11
  182. package/src/html-reporter.ts +263 -13
  183. package/src/index.ts +93 -10
  184. package/src/project-summarizer.ts +521 -0
  185. package/src/refactor-reporter.ts +1 -1
  186. package/src/scanner.ts +136 -90
  187. package/src/scorer.ts +26 -11
  188. package/src/types.ts +27 -0
  189. package/tests/agent-generator.test.ts +427 -0
  190. package/tests/analyzers-integration.test.ts +174 -0
  191. package/tests/architect-adapter-enrichment.test.ts +9 -0
  192. package/tests/context-enricher.test.ts +971 -0
  193. package/tests/fixtures/monorepo/package.json +6 -0
  194. package/tests/fixtures/monorepo/packages/app/package.json +12 -0
  195. package/tests/fixtures/monorepo/packages/app/src/index.ts +6 -0
  196. package/tests/fixtures/monorepo/packages/core/package.json +7 -0
  197. package/tests/fixtures/monorepo/packages/core/src/index.ts +7 -0
  198. package/tests/forecast.test.ts +509 -0
  199. package/tests/framework-detector.test.ts +1172 -0
  200. package/tests/git-history.test.ts +254 -0
  201. package/tests/monorepo-scan.test.ts +170 -0
  202. package/tests/scanner.test.ts +7 -8
  203. package/tests/scorer.test.ts +594 -0
  204. package/tests/stack-detector.test.ts +241 -0
  205. package/tests/template-generation.test.ts +706 -0
  206. package/tests/template-helpers.test.ts +1152 -0
  207. package/tests/temporal-scorer.test.ts +307 -0
  208. package/dist/agent-generator.d.ts +0 -106
  209. package/dist/agent-generator.d.ts.map +0 -1
  210. package/dist/agent-generator.js +0 -1398
  211. package/dist/agent-generator.js.map +0 -1
  212. package/src/agent-generator.ts +0 -1526
@@ -0,0 +1,242 @@
1
+ import { TemplateContext, EnrichedTemplateContext } from '../../types.js';
2
+ import { getEnriched } from '../template-helpers.js';
3
+
4
+ /**
5
+ * Generates executable hook scripts (.sh) for the .agent/hooks/ directory.
6
+ * These are real, runnable shell scripts tied to git lifecycle events.
7
+ *
8
+ * v5.1: Uses project-specific toolchain commands, score thresholds,
9
+ * and coverage targets from the enriched context.
10
+ */
11
+
12
+ /**
13
+ * Pre-commit hook: lint + build check
14
+ */
15
+ export function generatePreCommitHook(ctx: TemplateContext | EnrichedTemplateContext): string {
16
+ const enriched = getEnriched(ctx);
17
+ const tc = enriched.toolchain;
18
+ const config = ctx.config;
19
+ const projectName = ctx.projectName;
20
+
21
+ const lintCmd = tc?.lintCmd || 'npx eslint .';
22
+ const buildCmd = tc?.buildCmd || 'npm run build';
23
+
24
+ return `#!/bin/bash
25
+ # ============================================================
26
+ # PRE-COMMIT HOOK — ${projectName}
27
+ # Gerado por Architect v5.1
28
+ #
29
+ # Instalação:
30
+ # cp .agent/hooks/pre-commit.sh .git/hooks/pre-commit
31
+ # chmod +x .git/hooks/pre-commit
32
+ # ============================================================
33
+
34
+ set -e
35
+
36
+ echo "🔍 [pre-commit] Verificando qualidade do código..."
37
+
38
+ # ── 1. Branch Safety ──
39
+ BRANCH=$(git branch --show-current)
40
+ if [[ "$BRANCH" == "main" || "$BRANCH" == "master" || "$BRANCH" == "staging" || "$BRANCH" == "develop" ]]; then
41
+ echo "❌ BLOQUEADO: Commit direto em '$BRANCH' é proibido."
42
+ echo " Crie uma branch: git checkout -b feature/<nome>"
43
+ exit 1
44
+ fi
45
+
46
+ # ── 2. Secrets Check ──
47
+ echo "🔐 Verificando secrets..."
48
+ SECRETS_PATTERN='(password|secret|api[_-]?key|access[_-]?token|private[_-]?key)\\s*[:=]\\s*["\\'\\x60][^"\\x60]{8,}'
49
+
50
+ STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)
51
+ if echo "$STAGED_FILES" | xargs grep -ilE "$SECRETS_PATTERN" 2>/dev/null; then
52
+ echo "❌ BLOQUEADO: Possível secret detectado nos arquivos staged."
53
+ echo " Remova o secret e use variáveis de ambiente."
54
+ exit 1
55
+ fi
56
+
57
+ # ── 3. File Size Check ──
58
+ echo "📏 Verificando tamanho de arquivos..."
59
+ for file in $STAGED_FILES; do
60
+ if [ -f "$file" ]; then
61
+ LINES=$(wc -l < "$file" 2>/dev/null || echo "0")
62
+ if [ "$LINES" -gt 500 ]; then
63
+ echo "⚠️ AVISO: $file tem $LINES linhas (limite: 500)"
64
+ fi
65
+ fi
66
+ done
67
+
68
+ # ── 4. Lint ──
69
+ echo "🧹 Executando lint..."
70
+ ${lintCmd} --quiet 2>/dev/null || {
71
+ echo "❌ BLOQUEADO: Lint falhou."
72
+ echo " Corrija: ${lintCmd}"
73
+ exit 1
74
+ }
75
+
76
+ # ── 5. Build ──
77
+ echo "🔨 Verificando build..."
78
+ ${buildCmd} 2>/dev/null || {
79
+ echo "❌ BLOQUEADO: Build falhou."
80
+ echo " Corrija: ${buildCmd}"
81
+ exit 1
82
+ }
83
+
84
+ # ── 6. Debug Statements ──
85
+ echo "🐛 Verificando debug statements..."
86
+ if echo "$STAGED_FILES" | xargs grep -n 'console\\.log\\|debugger\\|print(' 2>/dev/null | grep -v 'node_modules' | grep -v '.test.'; then
87
+ echo "⚠️ AVISO: Debug statements encontrados. Remova antes do merge."
88
+ fi
89
+
90
+ echo "✅ [pre-commit] Tudo OK — commit liberado."
91
+ exit 0
92
+ `;
93
+ }
94
+
95
+ /**
96
+ * Pre-push hook: test + score gate
97
+ */
98
+ export function generatePrePushHook(ctx: TemplateContext | EnrichedTemplateContext): string {
99
+ const enriched = getEnriched(ctx);
100
+ const tc = enriched.toolchain;
101
+ const config = ctx.config;
102
+ const projectName = ctx.projectName;
103
+
104
+ const testCmd = tc?.testCmd || 'npm test';
105
+ const coverageCmd = tc?.coverageCmd || 'npm run test -- --coverage';
106
+
107
+ return `#!/bin/bash
108
+ # ============================================================
109
+ # PRE-PUSH HOOK — ${projectName}
110
+ # Gerado por Architect v5.1
111
+ #
112
+ # Instalação:
113
+ # cp .agent/hooks/pre-push.sh .git/hooks/pre-push
114
+ # chmod +x .git/hooks/pre-push
115
+ # ============================================================
116
+
117
+ set -e
118
+
119
+ echo "🚀 [pre-push] Verificação completa antes do push..."
120
+
121
+ # ── 1. Branch Safety ──
122
+ BRANCH=$(git branch --show-current)
123
+ if [[ "$BRANCH" == "main" || "$BRANCH" == "master" ]]; then
124
+ echo "❌ BLOQUEADO: Push direto para '$BRANCH' é proibido."
125
+ echo " Use Pull Request."
126
+ exit 1
127
+ fi
128
+
129
+ # ── 2. Full Test Suite ──
130
+ echo "🧪 Executando testes completos..."
131
+ ${testCmd} || {
132
+ echo "❌ BLOQUEADO: Testes falharam."
133
+ echo " Corrija antes de fazer push."
134
+ exit 1
135
+ }
136
+
137
+ # ── 3. Coverage Gate ──
138
+ echo "📊 Verificando cobertura (mínimo: ${config.coverageMinimum}%)..."
139
+ COVERAGE_OUTPUT=$(${coverageCmd} 2>&1 || true)
140
+ echo "$COVERAGE_OUTPUT" | tail -5
141
+
142
+ # Parse coverage percentage (works with Jest/Istanbul output)
143
+ COVERAGE=$(echo "$COVERAGE_OUTPUT" | grep -oP 'All files[^|]*\\|\\s*[\\d.]+' | grep -oP '[\\d.]+$' || echo "0")
144
+ if [ -n "$COVERAGE" ]; then
145
+ COVERAGE_INT=\${COVERAGE%.*}
146
+ if [ "$COVERAGE_INT" -lt ${config.coverageMinimum} ] 2>/dev/null; then
147
+ echo "⚠️ AVISO: Cobertura ($COVERAGE_INT%) abaixo do mínimo (${config.coverageMinimum}%)"
148
+ fi
149
+ fi
150
+
151
+ # ── 4. Architecture Score Gate ──
152
+ echo "🏗️ Verificando score de arquitetura (mínimo: ${config.scoreThreshold}/100)..."
153
+ if command -v architect &> /dev/null; then
154
+ SCORE=$(architect score . --json 2>/dev/null | grep -oP '"overall":\\s*\\K[0-9]+' || echo "N/A")
155
+ if [ "$SCORE" != "N/A" ] && [ "$SCORE" -lt ${config.scoreThreshold} ] 2>/dev/null; then
156
+ echo "❌ BLOQUEADO: Score ($SCORE/100) abaixo do mínimo (${config.scoreThreshold}/100)"
157
+ exit 1
158
+ fi
159
+ echo " Score: $SCORE/100 ✅"
160
+ else
161
+ echo " ⏭️ architect não instalado — skip score gate"
162
+ fi
163
+
164
+ echo "✅ [pre-push] Tudo OK — push liberado."
165
+ exit 0
166
+ `;
167
+ }
168
+
169
+ /**
170
+ * Post-analysis hook: remediation actions
171
+ */
172
+ export function generatePostAnalysisHook(ctx: TemplateContext | EnrichedTemplateContext): string {
173
+ const enriched = getEnriched(ctx);
174
+ const projectName = ctx.projectName;
175
+ const report = ctx.report;
176
+
177
+ return `#!/bin/bash
178
+ # ============================================================
179
+ # POST-ANALYSIS HOOK — ${projectName}
180
+ # Gerado por Architect v5.1
181
+ #
182
+ # Executa após 'architect analyze .' para gerar ações
183
+ # de remediação automáticas.
184
+ #
185
+ # Uso:
186
+ # architect analyze . && bash .agent/hooks/post-analysis.sh
187
+ # ============================================================
188
+
189
+ set -e
190
+
191
+ echo "🔧 [post-analysis] Processando resultados da análise..."
192
+
193
+ REPORT_JSON="architect-report.json"
194
+ REPORT_HTML="architect-report.html"
195
+
196
+ # ── 1. Score Evolution ──
197
+ CURRENT_SCORE=${report.score.overall}
198
+ echo "📊 Score atual: $CURRENT_SCORE/100"
199
+ echo " Meta curto prazo: ${Math.min(100, report.score.overall + 5)}/100"
200
+ echo " Meta médio prazo: ${Math.min(100, report.score.overall + 10)}/100"
201
+
202
+ # ── 2. Critical Anti-Patterns Alert ──
203
+ CRITICAL_COUNT=$(grep -c '"severity":"CRITICAL"' "$REPORT_JSON" 2>/dev/null || echo "0")
204
+ HIGH_COUNT=$(grep -c '"severity":"HIGH"' "$REPORT_JSON" 2>/dev/null || echo "0")
205
+
206
+ if [ "$CRITICAL_COUNT" -gt 0 ]; then
207
+ echo ""
208
+ echo "🔴 ATENÇÃO: $CRITICAL_COUNT anti-patterns CRÍTICOS detectados!"
209
+ echo " Resolva antes do próximo sprint."
210
+ fi
211
+
212
+ if [ "$HIGH_COUNT" -gt 0 ]; then
213
+ echo "🟠 $HIGH_COUNT anti-patterns HIGH detectados."
214
+ fi
215
+
216
+ # ── 3. Generate Summary ──
217
+ echo ""
218
+ echo "📋 Resumo:"
219
+ echo " Arquivos: ${report.projectInfo.totalFiles}"
220
+ echo " Linhas: ${report.projectInfo.totalLines.toLocaleString()}"
221
+ echo " Anti-patterns: ${report.antiPatterns.length}"
222
+ echo ""
223
+
224
+ # ── 4. Suggestions ──
225
+ if [ -f "$REPORT_JSON" ]; then
226
+ echo "💡 Top 5 sugestões:"
227
+ cat "$REPORT_JSON" | python3 -c "
228
+ import json, sys
229
+ data = json.load(sys.stdin)
230
+ for s in data.get('suggestions', [])[:5]:
231
+ print(f' → {s.get(\"description\", \"\")}')
232
+ " 2>/dev/null || echo " (instale python3 para ver sugestões)"
233
+ fi
234
+
235
+ echo ""
236
+ echo "📄 Report HTML: $REPORT_HTML"
237
+ echo "📦 Report JSON: $REPORT_JSON"
238
+ echo ""
239
+ echo "✅ [post-analysis] Concluído."
240
+ exit 0
241
+ `;
242
+ }
@@ -0,0 +1,260 @@
1
+ import { TemplateContext } from '../../types.js';
2
+
3
+ /**
4
+ * Generates enterprise-grade INDEX.md — master navigation guide for the agent framework.
5
+ * ~350+ lines with: mandatory reads, situational guide, agent catalog, templates, flow diagram.
6
+ */
7
+ export function generateIndexMd(ctx: TemplateContext): string {
8
+ const { report, stack, projectName, stackLabel, plan, config } = ctx;
9
+
10
+ const agents = buildAgentCatalog(ctx);
11
+ const situationalGuide = buildSituationalGuide(ctx);
12
+ const templates = buildTemplatesCatalog();
13
+
14
+ return `# ${projectName} — Agent Framework
15
+
16
+ > **Auto-generated by [Architect v3.1](https://github.com/camilooscargbaptista/architect)**
17
+ > Stack: **${stackLabel}** | Score: **${report.score.overall}/100** | Files: **${report.projectInfo.totalFiles}** | Lines: **${report.projectInfo.totalLines.toLocaleString()}**
18
+
19
+ ---
20
+
21
+ ## ⛔ PARE AQUI — LEITURA OBRIGATÓRIA
22
+
23
+ > **Antes de qualquer ação, leia estes documentos NA ORDEM.**
24
+ > Pular esta etapa é violação do protocolo.
25
+
26
+ | # | Arquivo | O que contém | Quando ler |
27
+ |---|---------|-------------|-----------|
28
+ | 1 | [00-general.md](./rules/00-general.md) | Regras de Ouro, convenções, identidade do projeto | **SEMPRE** |
29
+ | 2 | [PREFLIGHT.md](./guards/PREFLIGHT.md) | Checklist pré-ação por camada | **SEMPRE** |
30
+ | 3 | [QUALITY-GATES.md](./guards/QUALITY-GATES.md) | Métricas mínimas, blockers, processo de verificação | **SEMPRE** |
31
+ | 4 | [CODE-REVIEW-CHECKLIST.md](./guards/CODE-REVIEW-CHECKLIST.md) | Pontos obrigatórios de revisão | Antes de PR |
32
+
33
+ ---
34
+
35
+ ## 🗺️ Guia Situacional
36
+
37
+ > **"O que vou fazer?"** → Siga a coluna correspondente.
38
+
39
+ ${situationalGuide}
40
+
41
+ ---
42
+
43
+ ## 🤖 Agentes Disponíveis
44
+
45
+ ${agents}
46
+
47
+ ---
48
+
49
+ ## 📋 Templates Disponíveis
50
+
51
+ ${templates}
52
+
53
+ ---
54
+
55
+ ## 📁 Estrutura do Framework
56
+
57
+ \`\`\`
58
+ .agent/
59
+ ├── INDEX.md ← VOCÊ ESTÁ AQUI
60
+ ├── agents/ → Agentes especializados
61
+ │ ├── AGENT-ORCHESTRATOR.md
62
+ ${stack.hasBackend ? `│ ├── ${stack.primary.toUpperCase()}-BACKEND-DEVELOPER.md\n` : ''}${stack.hasFrontend ? `│ ├── FRONTEND-DEVELOPER.md\n` : ''}${stack.hasMobile ? `│ ├── FLUTTER-UI-DEVELOPER.md\n` : ''}${stack.hasDatabase ? `│ ├── DATABASE-ENGINEER.md\n` : ''}│ ├── SECURITY-AUDITOR.md
63
+ │ ├── QA-TEST-ENGINEER.md
64
+ │ └── TECH-DEBT-CONTROLLER.md
65
+ ├── rules/ → Regras de codificação
66
+ │ ├── 00-general.md
67
+ │ ├── 01-architecture.md
68
+ │ └── 02-security.md
69
+ ├── guards/ → Checklists e quality gates
70
+ │ ├── PREFLIGHT.md
71
+ │ ├── QUALITY-GATES.md
72
+ │ └── CODE-REVIEW-CHECKLIST.md
73
+ ├── workflows/ → Fluxos de trabalho
74
+ │ ├── new-feature.md
75
+ │ ├── fix-bug.md
76
+ │ └── review.md
77
+ ├── templates/ → Templates reutilizáveis
78
+ │ ├── C4.md
79
+ │ ├── BDD.md
80
+ │ ├── TDD.md
81
+ │ ├── ADR.md
82
+ │ └── THREAT-MODEL.md
83
+ └── skills/ → Padrões e referências
84
+ \`\`\`
85
+
86
+ ---
87
+
88
+ ## 🔄 Fluxo Completo de Desenvolvimento
89
+
90
+ \`\`\`
91
+ REQUISIÇÃO RECEBIDA
92
+
93
+
94
+ ┌──────────────────┐
95
+ │ PREFLIGHT.md │ ← Ler OBRIGATÓRIO
96
+ │ (diagnóstico) │
97
+ └────────┬─────────┘
98
+
99
+
100
+ ┌──────────────────┐
101
+ │ ORCHESTRATOR │ ← Decompõe a requisição
102
+ │ (classificar) │
103
+ └────────┬─────────┘
104
+
105
+
106
+ ┌──────────────────────────────────────┐
107
+ │ 6 GATES OBRIGATÓRIOS │
108
+ │ │
109
+ │ 1. MOCKUP (se tem UI) │
110
+ │ 2. User Stories │
111
+ │ 3. Arquitetura (C4) │
112
+ │ 4. Tarefas (breakdown) │
113
+ │ 5. BDD (cenários) │
114
+ │ 6. TDD (casos de teste) │
115
+ │ │
116
+ │ ⚠️ /approved após cada gate │
117
+ └────────┬─────────────────────────────┘
118
+
119
+
120
+ ┌──────────────────────────────────────┐
121
+ │ IMPLEMENTAÇÃO (ordenada) │
122
+ │ │
123
+ │ 1° Backend (se houver) │
124
+ │ 2° Documento de Integração │
125
+ │ 3° Frontend / App (se houver) │
126
+ └────────┬─────────────────────────────┘
127
+
128
+
129
+ ┌──────────────────┐
130
+ │ QUALITY-GATES │ ← Build + Coverage ≥ ${config.coverageMinimum}%
131
+ │ (verificação) │
132
+ └────────┬─────────┘
133
+
134
+
135
+ ┌──────────────────┐
136
+ │ CODE REVIEW │ ← Checklist obrigatório
137
+ │ (PR) │
138
+ └────────┬─────────┘
139
+
140
+
141
+ ✅ DONE
142
+ \`\`\`
143
+
144
+ ---
145
+
146
+ ## ⚡ Atalhos Rápidos
147
+
148
+ | Situação | Comando / Workflow |
149
+ |----------|-------------------|
150
+ | Nova feature | \`/new-feature\` → [workflow](./workflows/new-feature.md) |
151
+ | Corrigir bug | \`/fix-bug\` → [workflow](./workflows/fix-bug.md) |
152
+ | Code review | \`/review\` → [workflow](./workflows/review.md) |
153
+ | Verificar qualidade | \`architect score ./src\` |
154
+ | Analisar arquitetura | \`architect analyze ./src\` |
155
+
156
+ ---
157
+
158
+ ## 🔌 Plugin Recomendado
159
+
160
+ Para análise contínua de arquitetura e manutenção do score:
161
+
162
+ \`\`\`
163
+ ┌─────────────────────────────────────────────┐
164
+ │ 📦 @girardelli/architect │
165
+ │ Plugin para Claude Code │
166
+ │ │
167
+ │ npm install -g @girardelli/architect │
168
+ │ │
169
+ │ Comandos: │
170
+ │ • architect analyze ./src │
171
+ │ • architect score ./src │
172
+ │ • architect agents ./src │
173
+ │ • architect refactor ./src │
174
+ │ │
175
+ │ Score atual: ${String(report.score.overall).padEnd(2)}/100 │
176
+ │ Meta: ${String(Math.min(100, report.score.overall + 10)).padEnd(3)}/100 │
177
+ └─────────────────────────────────────────────┘
178
+ \`\`\`
179
+
180
+ ---
181
+
182
+ ## ⚠️ REGRA DE OURO
183
+
184
+ > **Na dúvida, PARA e PERGUNTA ao humano.**
185
+ > Nunca assuma. Nunca decida sozinho. Sempre valide.
186
+
187
+ ---
188
+
189
+ **Gerado por Architect v3.1 · Score: ${report.score.overall}/100 · ${new Date().toISOString().split('T')[0]}**
190
+ `;
191
+ }
192
+
193
+ function buildAgentCatalog(ctx: TemplateContext): string {
194
+ const { stack } = ctx;
195
+ const rows: string[] = [];
196
+
197
+ rows.push('| Agente | Role | Capabilities |');
198
+ rows.push('|--------|------|-------------|');
199
+ rows.push('| [AGENT-ORCHESTRATOR](./agents/AGENT-ORCHESTRATOR.md) | coordination | Decomposição, dispatch, consolidação, quality gate |');
200
+
201
+ if (stack.hasBackend) {
202
+ rows.push(`| [${stack.primary.toUpperCase()}-BACKEND-DEVELOPER](./agents/${stack.primary.toUpperCase()}-BACKEND-DEVELOPER.md) | development | APIs, serviços, lógica de negócio, migrations |`);
203
+ }
204
+ if (stack.hasFrontend) {
205
+ const fw = stack.frameworks.find(f => ['Angular', 'Vue', 'Next.js', 'React'].includes(f)) || 'FRONTEND';
206
+ rows.push(`| [${fw.toUpperCase().replace('.', '')}-FRONTEND-DEVELOPER](./agents/${fw.toUpperCase().replace('.', '')}-FRONTEND-DEVELOPER.md) | development | Componentes, state management, UX responsiva |`);
207
+ }
208
+ if (stack.hasMobile) {
209
+ rows.push('| [FLUTTER-UI-DEVELOPER](./agents/FLUTTER-UI-DEVELOPER.md) | development | Screens, widgets, navegação, integração API |');
210
+ }
211
+ if (stack.hasDatabase) {
212
+ rows.push('| [DATABASE-ENGINEER](./agents/DATABASE-ENGINEER.md) | development | Schema, migrations, indexação, performance |');
213
+ }
214
+
215
+ rows.push('| [SECURITY-AUDITOR](./agents/SECURITY-AUDITOR.md) | quality | Ameaças STRIDE, OWASP, LGPD, vulnerabilidades |');
216
+ rows.push('| [QA-TEST-ENGINEER](./agents/QA-TEST-ENGINEER.md) | quality | Planos de teste, BDD/TDD, cobertura, regressão |');
217
+ rows.push('| [TECH-DEBT-CONTROLLER](./agents/TECH-DEBT-CONTROLLER.md) | governance | Débito técnico, refatorações, metas de score |');
218
+
219
+ return rows.join('\n');
220
+ }
221
+
222
+ function buildSituationalGuide(ctx: TemplateContext): string {
223
+ const { stack } = ctx;
224
+ const rows: string[] = [];
225
+
226
+ rows.push('| Ação | Leia antes | Workflow | Agente principal |');
227
+ rows.push('|------|-----------|---------|-----------------|');
228
+ rows.push('| Nova feature | 00-general + PREFLIGHT | [new-feature](./workflows/new-feature.md) | ORCHESTRATOR |');
229
+ rows.push('| Corrigir bug | 00-general + PREFLIGHT | [fix-bug](./workflows/fix-bug.md) | ORCHESTRATOR |');
230
+
231
+ if (stack.hasBackend) {
232
+ rows.push(`| Mexer em backend | 00-general + 01-architecture | new-feature ou fix-bug | ${stack.primary.toUpperCase()}-BACKEND |`);
233
+ }
234
+ if (stack.hasFrontend) {
235
+ rows.push('| Mexer em frontend | 00-general + 01-architecture | new-feature ou fix-bug | FRONTEND |');
236
+ }
237
+ if (stack.hasMobile) {
238
+ rows.push('| Mexer no app | 00-general | new-feature ou fix-bug | FLUTTER-UI |');
239
+ }
240
+ if (stack.hasDatabase) {
241
+ rows.push('| Mexer em banco | 00-general + 01-architecture | new-feature | DATABASE-ENGINEER |');
242
+ }
243
+
244
+ rows.push('| Segurança | 02-security | — | SECURITY-AUDITOR |');
245
+ rows.push('| Testes | 00-general | — | QA-TEST-ENGINEER |');
246
+ rows.push('| Refatoração | QUALITY-GATES | — | TECH-DEBT-CONTROLLER |');
247
+ rows.push('| Code review | CODE-REVIEW-CHECKLIST | [review](./workflows/review.md) | QA-TEST-ENGINEER |');
248
+
249
+ return rows.join('\n');
250
+ }
251
+
252
+ function buildTemplatesCatalog(): string {
253
+ return `| Template | Arquivo | Quando usar |
254
+ |----------|---------|-----------|
255
+ | C4 Architecture | [C4.md](./templates/C4.md) | Documentar arquitetura de qualquer feature |
256
+ | BDD Scenarios | [BDD.md](./templates/BDD.md) | Antes de implementar — cenários de aceite |
257
+ | TDD Cases | [TDD.md](./templates/TDD.md) | Antes de implementar — casos de teste |
258
+ | ADR | [ADR.md](./templates/ADR.md) | Decisões arquiteturais significativas |
259
+ | Threat Model | [THREAT-MODEL.md](./templates/THREAT-MODEL.md) | Features que lidam com dados sensíveis |`;
260
+ }