@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,236 @@
1
+ import { EnrichedTemplateContext, TemplateContext } from '../../types.js';
2
+ import { getEnriched } from '../template-helpers.js';
3
+
4
+ /**
5
+ * Detecta padrões arquiteturais nos módulos do projeto
6
+ * e gera skills/documentação para o diretório skills/.
7
+ */
8
+
9
+ interface DetectedPattern {
10
+ name: string;
11
+ description: string;
12
+ examples: string[];
13
+ howToCreate: string;
14
+ }
15
+
16
+ /**
17
+ * Analisa módulos e detecta padrões recorrentes (adapters, factories, extractors, etc.)
18
+ */
19
+ function detectPatterns(ctx: TemplateContext | EnrichedTemplateContext): DetectedPattern[] {
20
+ const enriched = getEnriched(ctx);
21
+ const modules = enriched.modules || [];
22
+ const patterns: DetectedPattern[] = [];
23
+
24
+ // Collect all file/class names from modules
25
+ const allFiles: string[] = [];
26
+ const allServices: string[] = [];
27
+ const allControllers: string[] = [];
28
+ const allEntities: string[] = [];
29
+
30
+ for (const mod of modules) {
31
+ allServices.push(...mod.services);
32
+ allControllers.push(...mod.controllers);
33
+ allEntities.push(...mod.entities);
34
+ allFiles.push(...mod.testFiles);
35
+ }
36
+
37
+ const allNames = [...allServices, ...allControllers, ...allEntities, ...allFiles];
38
+
39
+ // Detect Adapter pattern
40
+ const adapters = allNames.filter(n => /adapter/i.test(n));
41
+ if (adapters.length > 0) {
42
+ patterns.push({
43
+ name: 'Adapter Pattern',
44
+ description: 'O projeto utiliza o padrão Adapter para abstrair integrações externas e garantir desacoplamento.',
45
+ examples: adapters.slice(0, 5),
46
+ howToCreate: `1. Criar interface no domínio: \`I{Nome}Port\`
47
+ 2. Implementar adapter: \`{Nome}Adapter implements I{Nome}Port\`
48
+ 3. Registrar no container de DI
49
+ 4. Escrever testes unitários com mock do adapter
50
+ 5. Garantir que o domínio nunca importe o adapter diretamente`,
51
+ });
52
+ }
53
+
54
+ // Detect Factory pattern
55
+ const factories = allNames.filter(n => /factory/i.test(n));
56
+ if (factories.length > 0) {
57
+ patterns.push({
58
+ name: 'Factory Pattern',
59
+ description: 'Factories são usadas para encapsular a lógica de criação de objetos complexos.',
60
+ examples: factories.slice(0, 5),
61
+ howToCreate: `1. Criar classe factory: \`{Nome}Factory\`
62
+ 2. Método principal: \`create({params}): {Tipo}\`
63
+ 3. Encapsular validações e defaults
64
+ 4. Escrever testes para cada variação de criação`,
65
+ });
66
+ }
67
+
68
+ // Detect Extractor pattern
69
+ const extractors = allNames.filter(n => /extractor|parser|reader/i.test(n));
70
+ if (extractors.length > 0) {
71
+ patterns.push({
72
+ name: 'Extractor/Parser Pattern',
73
+ description: 'Extractors/Parsers são usados para extrair e transformar dados de fontes externas (PDFs, APIs, arquivos).',
74
+ examples: extractors.slice(0, 5),
75
+ howToCreate: `1. Criar interface: \`I{Tipo}Extractor\`
76
+ 2. Implementar: \`{Tipo}Extractor implements I{Tipo}Extractor\`
77
+ 3. Método principal: \`extract(source): ExtractedData\`
78
+ 4. Testar com fixtures (dados de exemplo)
79
+ 5. Tratar edge cases: dados vazios, formato inválido, timeout`,
80
+ });
81
+ }
82
+
83
+ // Detect Repository pattern
84
+ const repositories = allNames.filter(n => /repository|repo/i.test(n));
85
+ if (repositories.length > 0) {
86
+ patterns.push({
87
+ name: 'Repository Pattern',
88
+ description: 'Repositories abstraem o acesso a dados, separando lógica de negócio da persistência.',
89
+ examples: repositories.slice(0, 5),
90
+ howToCreate: `1. Criar interface: \`I{Entidade}Repository\`
91
+ 2. Métodos padrão: findById, findAll, save, delete
92
+ 3. Implementar com ORM ou query builder
93
+ 4. Testar com banco in-memory ou mock`,
94
+ });
95
+ }
96
+
97
+ // Detect Middleware/Guard pattern
98
+ const middlewares = allNames.filter(n => /middleware|guard|interceptor|pipe/i.test(n));
99
+ if (middlewares.length > 0) {
100
+ patterns.push({
101
+ name: 'Middleware/Guard Pattern',
102
+ description: 'Middlewares e Guards implementam cross-cutting concerns (auth, logging, validation).',
103
+ examples: middlewares.slice(0, 5),
104
+ howToCreate: `1. Criar middleware/guard com interface do framework
105
+ 2. Implementar lógica de interceptação
106
+ 3. Registrar no pipeline de request
107
+ 4. Testar isoladamente com request mocking`,
108
+ });
109
+ }
110
+
111
+ // Detect DTO/Schema pattern
112
+ const dtos = allNames.filter(n => /dto|schema|model|entity/i.test(n));
113
+ if (dtos.length > 2) { // Only if there are several
114
+ patterns.push({
115
+ name: 'DTO/Schema Pattern',
116
+ description: 'DTOs e Schemas definem contratos de entrada/saída e validações.',
117
+ examples: dtos.slice(0, 5),
118
+ howToCreate: `1. Criar DTO/Schema para cada endpoint
119
+ 2. Validações no DTO (não no controller)
120
+ 3. Separar RequestDTO e ResponseDTO
121
+ 4. Documentar campos obrigatórios e opcionais
122
+ 5. Usar validação automática do framework`,
123
+ });
124
+ }
125
+
126
+ // Detect Service Layer pattern (almost always present)
127
+ if (allServices.length > 1) {
128
+ patterns.push({
129
+ name: 'Service Layer Pattern',
130
+ description: 'Services encapsulam toda a lógica de negócio, mantendo controllers finos.',
131
+ examples: allServices.slice(0, 5),
132
+ howToCreate: `1. Criar service: \`{Domínio}Service\`
133
+ 2. Injetar dependências via constructor
134
+ 3. Um método por caso de uso (SRP)
135
+ 4. Lançar exceções de domínio (não HTTP)
136
+ 5. Testar unitariamente com mocks de dependências`,
137
+ });
138
+ }
139
+
140
+ return patterns;
141
+ }
142
+
143
+ /**
144
+ * Gera conteúdo do skill principal do projeto
145
+ */
146
+ export function generateProjectSkills(ctx: TemplateContext | EnrichedTemplateContext): string | null {
147
+ const enriched = getEnriched(ctx);
148
+ const patterns = detectPatterns(ctx);
149
+ const stack = 'stack' in ctx ? ctx.stack : undefined;
150
+ const domain = enriched.domain;
151
+
152
+ if (patterns.length === 0) {
153
+ return null; // Não gerar se não houver padrões detectados
154
+ }
155
+
156
+ const langs = stack?.languages.map((l) => l.toLowerCase()) || [];
157
+ const isPython = langs.includes('python');
158
+ const isDart = langs.includes('dart');
159
+ const isGo = langs.includes('go');
160
+
161
+ // Naming convention per language
162
+ let fileConvention = 'camelCase para arquivos, PascalCase para classes';
163
+ if (isPython) fileConvention = 'snake_case para arquivos e funções, PascalCase para classes';
164
+ else if (isDart) fileConvention = 'snake_case para arquivos, camelCase para funções, PascalCase para classes';
165
+ else if (isGo) fileConvention = 'lowercase para pacotes, PascalCase para exports, camelCase para privados';
166
+
167
+ // Build frameworks label from enriched detectedFrameworks (most accurate) or stack.frameworks
168
+ const detectedFw = enriched.detectedFrameworks;
169
+ const frameworksLabel = detectedFw && detectedFw.length > 0
170
+ ? detectedFw.map(f => f.version ? `${f.name} v${f.version}` : f.name).join(', ')
171
+ : (stack?.frameworks.length ? stack.frameworks.join(', ') : 'Não detectados');
172
+
173
+ const patternsContent = patterns.map(p => `### ${p.name}
174
+
175
+ ${p.description}
176
+
177
+ **Exemplos no projeto:**
178
+ ${p.examples.map(e => `- \`${e}\``).join('\n')}
179
+
180
+ **Como criar um novo:**
181
+ ${p.howToCreate}
182
+ `).join('\n---\n\n');
183
+
184
+ const domainSection = domain ? `
185
+ ---
186
+
187
+ ## Padrões de Domínio: ${domain.domain}${domain.subDomain ? ` / ${domain.subDomain}` : ''}
188
+
189
+ ${domain.businessEntities?.length ? `### Entidades de Negócio
190
+ ${domain.businessEntities.map(e => `- **${e.name}**: ${e.fields?.join(', ') || 'campos detectados'}`).join('\n')}` : ''}
191
+
192
+ ${domain.integrations?.length ? `### Integrações
193
+ ${domain.integrations.map(i => `- **${i.name}** (${i.type})`).join('\n')}` : ''}
194
+
195
+ ${domain.compliance?.length ? `### Compliance
196
+ ${domain.compliance.map(c => `- **${c.name}**: ${c.reason}`).join('\n')}` : ''}
197
+ ` : '';
198
+
199
+ return `---
200
+ antigravity:
201
+ trigger: 'on_demand'
202
+ description: 'Padrões e convenções específicos do projeto'
203
+ version: 3.1.0
204
+ ---
205
+
206
+ # 📚 Skills: Padrões do Projeto
207
+
208
+ > Referência rápida dos padrões arquiteturais detectados e como seguí-los.
209
+
210
+ ---
211
+
212
+ ## Convenções
213
+
214
+ - **Nomenclatura de arquivos:** ${fileConvention}
215
+ - **Stack:** ${stack?.languages.join(', ') || 'Não detectada'}
216
+ - **Frameworks:** ${frameworksLabel}
217
+
218
+ ---
219
+
220
+ ## Padrões Arquiteturais Detectados
221
+
222
+ ${patternsContent}
223
+ ${domainSection}
224
+ ---
225
+
226
+ ## Checklist para Novo Código
227
+
228
+ \`\`\`
229
+ □ Segue os padrões acima?
230
+ □ Testes escritos antes do código (TDD)?
231
+ □ Nomenclatura consistente com convenções?
232
+ □ Sem duplicação de lógica existente?
233
+ □ Documentação atualizada (JSDoc/docstring)?
234
+ \`\`\`
235
+ `;
236
+ }
@@ -0,0 +1,239 @@
1
+ import { TemplateContext } from '../../types.js';
2
+
3
+ /**
4
+ * Generates enterprise-grade fix-bug.md workflow.
5
+ * 10 steps: diagnosis → localization → root cause → RED test → fix → regression → docs.
6
+ */
7
+ export function generateFixBugWorkflow(ctx: TemplateContext): string {
8
+ const { stack, projectName, config, report } = ctx;
9
+
10
+ return `---
11
+ antigravity:
12
+ trigger: 'on_demand'
13
+ description: 'Workflow completo para correção de bug em ${projectName}'
14
+ ---
15
+
16
+ # 🐛 Workflow: Fix Bug
17
+
18
+ > **Bugs não se corrigem por tentativa e erro.**
19
+ > Diagnóstico rigoroso → reprodução → root cause → teste RED → fix → regressão.
20
+
21
+ ---
22
+
23
+ ## Pré-requisitos
24
+
25
+ \`\`\`
26
+ □ Li INDEX.md e PREFLIGHT.md
27
+ □ Li LESSONS-LEARNED.md (se existir) — talvez esse bug já aconteceu
28
+ □ Li ERROR-PATTERNS.md (se existir) — talvez é um padrão conhecido
29
+ □ Estou em uma branch fix/ ou hotfix/ (NUNCA main/develop)
30
+ □ Build e testes passando ANTES da minha alteração
31
+ \`\`\`
32
+
33
+ ---
34
+
35
+ ## Step 1: Diagnóstico Inicial
36
+
37
+ \`\`\`
38
+ Bug: [descrição clara do problema]
39
+ Reportado por: [quem reportou]
40
+ Ambiente: [produção / staging / dev]
41
+ Severidade: [CRITICAL / HIGH / MEDIUM / LOW]
42
+
43
+ Comportamento atual: [o que acontece]
44
+ Comportamento esperado: [o que deveria acontecer]
45
+ Como reproduzir:
46
+ 1. [passo 1]
47
+ 2. [passo 2]
48
+ 3. [resultado errado]
49
+ \`\`\`
50
+
51
+ ---
52
+
53
+ ## Step 2: Leitura de Contexto
54
+
55
+ \`\`\`bash
56
+ # Verificar LESSONS-LEARNED para bugs similares
57
+ grep -i "[termo do bug]" LESSONS-LEARNED.md 2>/dev/null
58
+
59
+ # Verificar ERROR-PATTERNS
60
+ grep -i "[termo do bug]" ERROR-PATTERNS.md 2>/dev/null
61
+
62
+ # Verificar regras de negócio relevantes
63
+ grep -i "[domínio do bug]" BUSINESS-RULES.md 2>/dev/null
64
+
65
+ # Histórico de commits na área afetada
66
+ git log --oneline -20 -- [arquivo ou diretório afetado]
67
+ \`\`\`
68
+
69
+ ---
70
+
71
+ ## Step 3: Localização do Problema
72
+
73
+ \`\`\`bash
74
+ # Buscar no código
75
+ grep -rn "[termo do erro]" --include="*.${stack.primary === 'Python' ? 'py' : stack.primary === 'Dart' ? 'dart' : 'ts'}" src/
76
+
77
+ # Verificar logs (se disponível)
78
+ # Verificar stack trace
79
+
80
+ # Mapear o fluxo de dados:
81
+ # Input → [onde entra] → [como transforma] → [onde sai] → Output
82
+ \`\`\`
83
+
84
+ \`\`\`
85
+ Arquivo(s) suspeito(s): _______________
86
+ Função/método suspeito: _______________
87
+ Linha(s) suspeita(s): _______________
88
+ \`\`\`
89
+
90
+ ---
91
+
92
+ ## Step 4: Root Cause — Identificação da Causa Raiz
93
+
94
+ \`\`\`
95
+ ╔══════════════════════════════════════════════╗
96
+ ║ NUNCA corrigir o SINTOMA. ║
97
+ ║ SEMPRE encontrar a CAUSA RAIZ. ║
98
+ ║ ║
99
+ ║ Técnica dos 5 Porquês: ║
100
+ ║ 1. Por que o bug acontece? → porque... ║
101
+ ║ 2. Por que isso? → porque... ║
102
+ ║ 3. Por que isso? → porque... ║
103
+ ║ 4. Por que isso? → porque... ║
104
+ ║ 5. Por que isso? → CAUSA RAIZ ║
105
+ ╚══════════════════════════════════════════════╝
106
+ \`\`\`
107
+
108
+ \`\`\`
109
+ Causa raiz: _______________
110
+ Confiança: [ ] Alta (reproduzi) [ ] Média (hipótese forte) [ ] Baixa (preciso investigar mais)
111
+ \`\`\`
112
+
113
+ > **Se confiança é Baixa → PARAR e investigar mais. Não chutar.**
114
+
115
+ ---
116
+
117
+ ## Step 5: Verificar Testes Existentes
118
+
119
+ \`\`\`bash
120
+ # Testes que cobrem a área afetada
121
+ grep -rn "[nome da função/classe]" --include="*.test.*" --include="*.spec.*" tests/ src/
122
+
123
+ # Rodar testes existentes
124
+ ${stack.testFramework === 'pytest' ? 'pytest -v -k "[nome do módulo]"' : stack.testFramework === 'flutter_test' ? 'flutter test test/[modulo]_test.dart' : 'npx jest --testPathPattern="[modulo]"'}
125
+ \`\`\`
126
+
127
+ \`\`\`
128
+ □ Existem testes para a área afetada? [sim/não]
129
+ □ Os testes passam? [sim/não]
130
+ □ Os testes cobrem o cenário do bug? [sim/não — se não, criar no Step 6]
131
+ \`\`\`
132
+
133
+ ---
134
+
135
+ ## Step 6: Criar Teste RED
136
+
137
+ > **PRIMEIRO criar um teste que FALHA reproduzindo o bug.**
138
+ > Só depois corrigir o código.
139
+
140
+ \`\`\`
141
+ Teste: [nome descritivo do teste]
142
+ Input: [dados que reproduzem o bug]
143
+ Expected: [resultado correto]
144
+ Actual: [resultado errado — o teste deve FALHAR]
145
+ \`\`\`
146
+
147
+ \`\`\`bash
148
+ # Rodar e confirmar que FALHA (RED)
149
+ ${stack.testFramework === 'pytest' ? 'pytest -v -k "[nome do teste]"' : 'npx jest --testNamePattern="[nome do teste]"'}
150
+ # DEVE FALHAR ❌
151
+ \`\`\`
152
+
153
+ ---
154
+
155
+ ## Step 7: Correção Mínima
156
+
157
+ \`\`\`
158
+ ╔══════════════════════════════════════════════╗
159
+ ║ REGRA: Correção MÍNIMA. ║
160
+ ║ ║
161
+ ║ ✓ Corrigir APENAS a causa raiz ║
162
+ ║ ✓ Menor quantidade de linhas possível ║
163
+ ║ ✗ NÃO refatorar código adjacente ║
164
+ ║ ✗ NÃO "aproveitar" para melhorar outra coisa║
165
+ ║ ✗ NÃO adicionar features junto com o fix ║
166
+ ╚══════════════════════════════════════════════╝
167
+ \`\`\`
168
+
169
+ Após corrigir:
170
+ \`\`\`bash
171
+ # Rodar o teste do Step 6 — agora deve PASSAR (GREEN)
172
+ ${stack.testFramework === 'pytest' ? 'pytest -v -k "[nome do teste]"' : 'npx jest --testNamePattern="[nome do teste]"'}
173
+ # DEVE PASSAR ✅
174
+ \`\`\`
175
+
176
+ ---
177
+
178
+ ## Step 8: Teste de Regressão
179
+
180
+ \`\`\`bash
181
+ # Rodar TODOS os testes (não só o novo)
182
+ ${stack.testFramework === 'pytest' ? 'pytest' : stack.testFramework === 'flutter_test' ? 'flutter test' : 'npm run test'}
183
+
184
+ # Build completo
185
+ ${stack.packageManager === 'npm' ? 'npm run build' : 'make build'}
186
+
187
+ # Score
188
+ npx @girardelli/architect score .
189
+ \`\`\`
190
+
191
+ \`\`\`
192
+ □ Teste do bug passa (GREEN) ✓
193
+ □ TODOS os outros testes passam ✓
194
+ □ Build compila ✓
195
+ □ Score não regrediu ✓
196
+ \`\`\`
197
+
198
+ ---
199
+
200
+ ## Step 9: Verificação de Fluxos Existentes
201
+
202
+ \`\`\`
203
+ □ Verifiquei que features dependentes não foram afetadas
204
+ □ Verifiquei edge cases relacionados
205
+ □ Se o bug era em API → verifiquei clientes da API
206
+ □ Se o bug era em banco → verifiquei migrations e seeds
207
+ \`\`\`
208
+
209
+ ---
210
+
211
+ ## Step 10: Documentação
212
+
213
+ \`\`\`
214
+ □ Atualizar LESSONS-LEARNED.md:
215
+ - O que aconteceu
216
+ - Causa raiz
217
+ - Como foi corrigido
218
+ - Como prevenir no futuro
219
+
220
+ □ Atualizar ERROR-PATTERNS.md (se é um padrão novo):
221
+ - Padrão do erro
222
+ - Sintomas
223
+ - Solução
224
+
225
+ □ Commit com mensagem semântica:
226
+ fix: [descrição clara do que foi corrigido]
227
+
228
+ □ PR criado com:
229
+ - Descrição do bug
230
+ - Causa raiz
231
+ - Solução aplicada
232
+ - Testes adicionados
233
+ \`\`\`
234
+
235
+ ---
236
+
237
+ **Gerado por Architect v3.1 · Score: ${report.score.overall}/100 · ${new Date().toISOString().split('T')[0]}**
238
+ `;
239
+ }