@onion-architect-ai/cli 4.1.0-beta.1 → 4.1.0-beta.3

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 (207) hide show
  1. package/dist/cli.js +8 -19
  2. package/dist/cli.js.map +1 -1
  3. package/package.json +4 -3
  4. package/templates/.cursor/agents/compliance/iso-22301-specialist.md +917 -0
  5. package/templates/.cursor/agents/compliance/iso-27001-specialist.md +641 -0
  6. package/templates/.cursor/agents/compliance/pmbok-specialist.md +669 -0
  7. package/templates/.cursor/agents/compliance/security-information-master.md +824 -0
  8. package/templates/.cursor/agents/compliance/soc2-specialist.md +818 -0
  9. package/templates/.cursor/agents/deployment/docker-specialist.md +1192 -0
  10. package/templates/.cursor/agents/meta/agent-creator-specialist.md +1135 -0
  11. package/templates/.cursor/agents/meta/command-creator-specialist.md +1519 -0
  12. package/templates/.cursor/agents/meta/metaspec-gate-keeper.md +240 -0
  13. package/templates/.cursor/agents/meta/onion.md +753 -0
  14. package/templates/.cursor/agents/research/research-agent.md +292 -0
  15. package/templates/.cursor/agents/review/corporate-compliance-specialist.md +370 -0
  16. package/templates/.cursor/commands/common/prompts/README.md +187 -0
  17. package/templates/.cursor/commands/common/prompts/clickup-patterns.md +144 -0
  18. package/templates/.cursor/commands/common/prompts/code-review-checklist.md +168 -0
  19. package/templates/.cursor/commands/common/prompts/git-workflow-patterns.md +235 -0
  20. package/templates/.cursor/commands/common/prompts/output-formats.md +240 -0
  21. package/templates/.cursor/commands/common/prompts/technical.md +172 -0
  22. package/templates/.cursor/commands/common/prompts/validation-rules.md +173 -0
  23. package/templates/.cursor/commands/common/templates/abstraction-template.md +400 -0
  24. package/templates/.cursor/commands/common/templates/agent-template.md +353 -0
  25. package/templates/.cursor/commands/common/templates/business_context_template.md +748 -0
  26. package/templates/.cursor/commands/common/templates/command-template.md +273 -0
  27. package/templates/.cursor/commands/common/templates/technical_context_template.md +526 -0
  28. package/templates/.cursor/commands/development/runflow-dev.md +465 -0
  29. package/templates/.cursor/commands/docs/build-compliance-docs.md +143 -0
  30. package/templates/.cursor/commands/git/README.md +606 -0
  31. package/templates/.cursor/commands/meta/all-tools.md +50 -0
  32. package/templates/.cursor/commands/meta/analyze-complex-problem.md +186 -0
  33. package/templates/.cursor/commands/meta/create-abstraction.md +859 -0
  34. package/templates/.cursor/commands/meta/create-agent-express.md +83 -0
  35. package/templates/.cursor/commands/meta/create-agent.md +210 -0
  36. package/templates/.cursor/commands/meta/create-command.md +203 -0
  37. package/templates/.cursor/commands/meta/create-knowledge-base.md +143 -0
  38. package/templates/.cursor/commands/meta/create-task-structure.md +150 -0
  39. package/templates/.cursor/commands/meta/setup-integration.md +257 -0
  40. package/templates/.cursor/commands/onion/setup.md +843 -0
  41. package/templates/.cursor/commands/onion.md +168 -0
  42. package/templates/.cursor/commands/product/README.md +230 -0
  43. package/templates/.cursor/commands/quick/analisys.md +17 -0
  44. package/templates/.cursor/commands/validate/collab/pair-testing.md +633 -0
  45. package/templates/.cursor/commands/validate/collab/three-amigos.md +505 -0
  46. package/templates/.cursor/commands/validate/qa-points/estimate.md +660 -0
  47. package/templates/.cursor/commands/validate/test-strategy/analyze.md +1134 -0
  48. package/templates/.cursor/commands/validate/test-strategy/create.md +392 -0
  49. package/templates/.cursor/commands/validate/workflow.md +360 -0
  50. package/templates/.cursor/commands/warm-up.md +91 -0
  51. package/templates/.cursor/docs/architecture/acoplamento-clickup-problema-analise.md +446 -0
  52. package/templates/.cursor/docs/architecture/desacoplamento-roadmap.md +360 -0
  53. package/templates/.cursor/docs/architecture/validacao-fase-1.md +219 -0
  54. package/templates/.cursor/docs/c4/c4-detection-rules.md +395 -0
  55. package/templates/.cursor/docs/c4/c4-documentation-templates.md +579 -0
  56. package/templates/.cursor/docs/c4/c4-mermaid-patterns.md +331 -0
  57. package/templates/.cursor/docs/c4/c4-templates.md +256 -0
  58. package/templates/.cursor/docs/clickup/clickup-acceptance-criteria-strategy.md +329 -0
  59. package/templates/.cursor/docs/clickup/clickup-auto-update-strategy.md +318 -0
  60. package/templates/.cursor/docs/clickup/clickup-comment-formatter.md +239 -0
  61. package/templates/.cursor/docs/clickup/clickup-description-fix.md +355 -0
  62. package/templates/.cursor/docs/clickup/clickup-dual-comment-strategy.md +505 -0
  63. package/templates/.cursor/docs/clickup/clickup-formatting.md +302 -0
  64. package/templates/.cursor/docs/clickup/separador-tamanho-otimizado.md +256 -0
  65. package/templates/.cursor/docs/engineer/pre-pr-acceptance-validation.md +256 -0
  66. package/templates/.cursor/docs/onion/ESPERANTO.md +278 -0
  67. package/templates/.cursor/docs/onion/agents-reference.md +832 -0
  68. package/templates/.cursor/docs/onion/clickup-integration.md +738 -0
  69. package/templates/.cursor/docs/onion/commands-guide.md +807 -0
  70. package/templates/.cursor/docs/onion/engineering-flows.md +865 -0
  71. package/templates/.cursor/docs/onion/getting-started.md +741 -0
  72. package/templates/.cursor/docs/onion/maintenance-checklist.md +388 -0
  73. package/templates/.cursor/docs/onion/naming-conventions.md +268 -0
  74. package/templates/.cursor/docs/onion/practical-examples.md +782 -0
  75. package/templates/.cursor/docs/product/story-points-integration.md +254 -0
  76. package/templates/.cursor/docs/product/story-points-validation.md +224 -0
  77. package/templates/.cursor/docs/reviews/task-manager-docs-review-2025-11-24.md +167 -0
  78. package/templates/.cursor/docs/strategies/clickup-comment-patterns.md +766 -0
  79. package/templates/.cursor/docs/strategies/clickup-integration-tests.md +599 -0
  80. package/templates/.cursor/docs/strategies/clickup-mcp-wrappers-tests.md +854 -0
  81. package/templates/.cursor/docs/strategies/clickup-regression-tests.md +589 -0
  82. package/templates/.cursor/docs/strategies/visual-patterns.md +308 -0
  83. package/templates/.cursor/docs/templates/README.md +624 -0
  84. package/templates/.cursor/docs/templates/adr-template.md +226 -0
  85. package/templates/.cursor/docs/templates/analysis-template.md +280 -0
  86. package/templates/.cursor/docs/templates/execution-plan-template.md +430 -0
  87. package/templates/.cursor/docs/templates/guide-template.md +367 -0
  88. package/templates/.cursor/docs/templates/phase-execution-prompt-template.md +504 -0
  89. package/templates/.cursor/docs/templates/reference-template.md +522 -0
  90. package/templates/.cursor/docs/templates/solution-template.md +390 -0
  91. package/templates/.cursor/docs/tools/README.md +325 -0
  92. package/templates/.cursor/docs/tools/agents.md +330 -0
  93. package/templates/.cursor/docs/tools/commands.md +606 -0
  94. package/templates/.cursor/docs/tools/cursor.md +498 -0
  95. package/templates/.cursor/docs/tools/mcps.md +858 -0
  96. package/templates/.cursor/docs/tools/rules.md +423 -0
  97. package/templates/.cursor/rules/language-and-documentation.mdc +371 -0
  98. package/templates/.cursor/rules/onion-patterns.mdc +197 -0
  99. package/templates/.cursor/rules/validation-rules.mdc +194 -0
  100. package/templates/.cursor/utils/clickup-mcp-wrappers.md +671 -0
  101. package/templates/.cursor/utils/date-time-standards.md +182 -0
  102. package/templates/.cursor/utils/task-manager/README.md +94 -0
  103. package/templates/.cursor/utils/task-manager/adapters/asana.md +377 -0
  104. package/templates/.cursor/utils/task-manager/adapters/clickup.md +467 -0
  105. package/templates/.cursor/utils/task-manager/adapters/linear.md +421 -0
  106. package/templates/.cursor/utils/task-manager/detector.md +290 -0
  107. package/templates/.cursor/utils/task-manager/factory.md +363 -0
  108. package/templates/.cursor/utils/task-manager/interface.md +248 -0
  109. package/templates/.cursor/utils/task-manager/types.md +409 -0
  110. package/templates/.cursor/validation/product-task-validation.md +344 -0
  111. package/templates/.onion/contexts/business/.context-config.yml +52 -0
  112. package/templates/.onion/contexts/business/README.md +222 -0
  113. package/templates/.onion/contexts/business/agents/branding-specialist.md +1030 -0
  114. package/templates/.onion/contexts/business/agents/clickup-specialist.md +397 -0
  115. package/templates/.onion/contexts/business/agents/extract-meeting-specialist.md +395 -0
  116. package/templates/.onion/contexts/business/agents/gamma-specialist.md +1169 -0
  117. package/templates/.onion/contexts/business/agents/meeting-consolidator.md +483 -0
  118. package/templates/.onion/contexts/business/agents/pain-price-specialist.md +509 -0
  119. package/templates/.onion/contexts/business/agents/presentation-orchestrator.md +1191 -0
  120. package/templates/.onion/contexts/business/agents/product-agent.md +202 -0
  121. package/templates/.onion/contexts/business/agents/story-points-specialist.md +539 -0
  122. package/templates/.onion/contexts/business/agents/storytelling-specialist.md +891 -0
  123. package/templates/.onion/contexts/business/agents/task-specialist.md +618 -0
  124. package/templates/.onion/contexts/business/agents/whisper-specialist.md +373 -0
  125. package/templates/.onion/contexts/business/commands/advanced/analyze-pain-price.md +709 -0
  126. package/templates/.onion/contexts/business/commands/advanced/branding.md +460 -0
  127. package/templates/.onion/contexts/business/commands/advanced/checklist-sync.md +241 -0
  128. package/templates/.onion/contexts/business/commands/advanced/presentation.md +189 -0
  129. package/templates/.onion/contexts/business/commands/advanced/transform-consolidated.md +592 -0
  130. package/templates/.onion/contexts/business/commands/help.md +212 -0
  131. package/templates/.onion/contexts/business/commands/intermediate/check.md +48 -0
  132. package/templates/.onion/contexts/business/commands/intermediate/collect.md +96 -0
  133. package/templates/.onion/contexts/business/commands/intermediate/consolidate-meetings.md +306 -0
  134. package/templates/.onion/contexts/business/commands/intermediate/convert-to-tasks.md +220 -0
  135. package/templates/.onion/contexts/business/commands/intermediate/extract-meeting.md +241 -0
  136. package/templates/.onion/contexts/business/commands/intermediate/feature.md +431 -0
  137. package/templates/.onion/contexts/business/commands/intermediate/light-arch.md +97 -0
  138. package/templates/.onion/contexts/business/commands/intermediate/task-check.md +340 -0
  139. package/templates/.onion/contexts/business/commands/intermediate/validate-task.md +294 -0
  140. package/templates/.onion/contexts/business/commands/intermediate/whisper.md +325 -0
  141. package/templates/.onion/contexts/business/commands/starter/estimate.md +519 -0
  142. package/templates/.onion/contexts/business/commands/starter/refine.md +186 -0
  143. package/templates/.onion/contexts/business/commands/starter/spec.md +107 -0
  144. package/templates/.onion/contexts/business/commands/starter/task.md +585 -0
  145. package/templates/.onion/contexts/business/commands/starter/warm-up.md +187 -0
  146. package/templates/.onion/contexts/technical/.context-config.yml +64 -0
  147. package/templates/.onion/contexts/technical/README.md +238 -0
  148. package/templates/.onion/contexts/technical/agents/branch-code-reviewer.md +200 -0
  149. package/templates/.onion/contexts/technical/agents/branch-doc-writer.md +162 -0
  150. package/templates/.onion/contexts/technical/agents/branch-metaspec-checker.md +68 -0
  151. package/templates/.onion/contexts/technical/agents/branch-test-planner.md +177 -0
  152. package/templates/.onion/contexts/technical/agents/c4-architecture-specialist.md +712 -0
  153. package/templates/.onion/contexts/technical/agents/c4-documentation-specialist.md +658 -0
  154. package/templates/.onion/contexts/technical/agents/code-reviewer.md +155 -0
  155. package/templates/.onion/contexts/technical/agents/cursor-specialist.md +249 -0
  156. package/templates/.onion/contexts/technical/agents/docs-reverse-engineer.md +418 -0
  157. package/templates/.onion/contexts/technical/agents/gitflow-specialist.md +1207 -0
  158. package/templates/.onion/contexts/technical/agents/linux-security-specialist.md +676 -0
  159. package/templates/.onion/contexts/technical/agents/mermaid-specialist.md +516 -0
  160. package/templates/.onion/contexts/technical/agents/nodejs-specialist.md +673 -0
  161. package/templates/.onion/contexts/technical/agents/nx-migration-specialist.md +867 -0
  162. package/templates/.onion/contexts/technical/agents/nx-monorepo-specialist.md +619 -0
  163. package/templates/.onion/contexts/technical/agents/postgres-specialist.md +1124 -0
  164. package/templates/.onion/contexts/technical/agents/react-developer.md +132 -0
  165. package/templates/.onion/contexts/technical/agents/runflow-specialist.md +278 -0
  166. package/templates/.onion/contexts/technical/agents/system-doc-orchestrator.md +1388 -0
  167. package/templates/.onion/contexts/technical/agents/test-agent.md +425 -0
  168. package/templates/.onion/contexts/technical/agents/test-engineer.md +295 -0
  169. package/templates/.onion/contexts/technical/agents/test-planner.md +118 -0
  170. package/templates/.onion/contexts/technical/agents/zen-engine-specialist.md +421 -0
  171. package/templates/.onion/contexts/technical/commands/advanced/bump.md +43 -0
  172. package/templates/.onion/contexts/technical/commands/advanced/consolidate-documents.md +424 -0
  173. package/templates/.onion/contexts/technical/commands/advanced/e2e.md +392 -0
  174. package/templates/.onion/contexts/technical/commands/advanced/feature-finish.md +90 -0
  175. package/templates/.onion/contexts/technical/commands/advanced/feature-publish.md +91 -0
  176. package/templates/.onion/contexts/technical/commands/advanced/feature-start.md +158 -0
  177. package/templates/.onion/contexts/technical/commands/advanced/hotfix-finish.md +98 -0
  178. package/templates/.onion/contexts/technical/commands/advanced/hotfix-start.md +94 -0
  179. package/templates/.onion/contexts/technical/commands/advanced/hotfix.md +186 -0
  180. package/templates/.onion/contexts/technical/commands/advanced/refine-vision.md +27 -0
  181. package/templates/.onion/contexts/technical/commands/advanced/release-finish.md +98 -0
  182. package/templates/.onion/contexts/technical/commands/advanced/release-start.md +95 -0
  183. package/templates/.onion/contexts/technical/commands/advanced/reverse-consolidate.md +160 -0
  184. package/templates/.onion/contexts/technical/commands/advanced/validate-phase-sync.md +118 -0
  185. package/templates/.onion/contexts/technical/commands/help.md +329 -0
  186. package/templates/.onion/contexts/technical/commands/intermediate/build-business-docs.md +276 -0
  187. package/templates/.onion/contexts/technical/commands/intermediate/build-index.md +128 -0
  188. package/templates/.onion/contexts/technical/commands/intermediate/build-tech-docs.md +204 -0
  189. package/templates/.onion/contexts/technical/commands/intermediate/code-review.md +215 -0
  190. package/templates/.onion/contexts/technical/commands/intermediate/docs-health.md +142 -0
  191. package/templates/.onion/contexts/technical/commands/intermediate/fast-commit.md +45 -0
  192. package/templates/.onion/contexts/technical/commands/intermediate/integration.md +523 -0
  193. package/templates/.onion/contexts/technical/commands/intermediate/pr-update.md +198 -0
  194. package/templates/.onion/contexts/technical/commands/intermediate/pre-pr.md +91 -0
  195. package/templates/.onion/contexts/technical/commands/intermediate/start.md +266 -0
  196. package/templates/.onion/contexts/technical/commands/intermediate/sync-sessions.md +320 -0
  197. package/templates/.onion/contexts/technical/commands/intermediate/unit.md +378 -0
  198. package/templates/.onion/contexts/technical/commands/intermediate/validate-docs.md +159 -0
  199. package/templates/.onion/contexts/technical/commands/starter/docs.md +39 -0
  200. package/templates/.onion/contexts/technical/commands/starter/help.md +306 -0
  201. package/templates/.onion/contexts/technical/commands/starter/init.md +139 -0
  202. package/templates/.onion/contexts/technical/commands/starter/plan.md +111 -0
  203. package/templates/.onion/contexts/technical/commands/starter/pr.md +136 -0
  204. package/templates/.onion/contexts/technical/commands/starter/sync.md +228 -0
  205. package/templates/.onion/contexts/technical/commands/starter/warm-up.md +173 -0
  206. package/templates/.onion/contexts/technical/commands/starter/work.md +169 -0
  207. package/templates/.onion/core/commands/help.md +388 -0
@@ -0,0 +1,523 @@
1
+ ---
2
+ name: integration
3
+ description: |
4
+ Gera e executa testes de integração automaticamente com detecção de framework.
5
+ Use para criar testes de integração (Grey-box) seguindo padrões do projeto, incluindo API contract testing, boundary testing e fuzzing.
6
+ model: sonnet
7
+
8
+ parameters:
9
+ - name: api-endpoint
10
+ description: Endpoint da API ou serviço para testar (ex: "/api/users", "UserService")
11
+ required: true
12
+ - name: --generate
13
+ description: Gera arquivo de teste se não existir
14
+ required: false
15
+ - name: --run
16
+ description: Executa os testes após gerar/validar
17
+ required: false
18
+ - name: --contract
19
+ description: Foca em contract testing (valida schemas e contratos)
20
+ required: false
21
+ - name: --boundary
22
+ description: Foca em boundary testing (timeouts, erros, limites)
23
+ required: false
24
+ - name: --fuzz
25
+ description: Inclui fuzzing de API (testes com dados malformados)
26
+ required: false
27
+ - name: --framework
28
+ description: Framework específico (sobrescreve auto-detecção: supertest|pact|postman|wiremock|jest|vitest)
29
+ required: false
30
+ - name: --mock-external
31
+ description: Mocka serviços externos (default: true para testes isolados)
32
+ required: false
33
+
34
+ category: test
35
+ tags:
36
+ - testing
37
+ - integration-tests
38
+ - grey-box-testing
39
+ - api-testing
40
+ - contract-testing
41
+ - test-generation
42
+ - automation
43
+
44
+ version: "4.0.0"
45
+ updated: "2025-12-20"
46
+
47
+ related_commands:
48
+ - /test/unit
49
+ - /test/e2e
50
+ - /validate/test-strategy/create
51
+ - /engineer/work
52
+
53
+ related_agents:
54
+ - test-engineer
55
+ - test-planner
56
+ - test-agent
57
+ level: intermediate
58
+ context: technical
59
+ ---
60
+
61
+ # 🔗 Test Integration
62
+
63
+ Gera e executa testes de integração automaticamente com detecção inteligente de framework, foco em Grey-box testing (API contract testing, boundary testing, fuzzing) seguindo o Framework de Testes.
64
+
65
+ ## 🎯 Objetivo
66
+
67
+ Automatizar o ciclo completo de testes de integração (Grey-box perspective):
68
+ - **Auto-detecção** de framework de integração (Supertest, Pact, Postman, Wiremock)
69
+ - **Análise de API/service** para identificar endpoints e contratos
70
+ - **Geração automática** de testes de integração seguindo padrões do projeto
71
+ - **Suporte a contract testing** (validação de schemas e contratos)
72
+ - **Suporte a boundary testing** (timeouts, erros, limites)
73
+ - **Suporte a fuzzing** (dados malformados e edge cases)
74
+ - **Execução inteligente** com mocks de serviços externos
75
+
76
+ ## ⚡ Fluxo de Execução
77
+
78
+ ### Passo 1: Validar Endpoint/Service
79
+
80
+ ```bash
81
+ # Validar formato
82
+ if [[ -z "{{api-endpoint}}" ]]; then
83
+ echo "❌ ERRO: Endpoint ou serviço é obrigatório"
84
+ exit 1
85
+ fi
86
+ ```
87
+
88
+ **Validações:**
89
+ ```markdown
90
+ SE api-endpoint vazio:
91
+ ❌ ERRO: Endpoint ou serviço é obrigatório
92
+ 💡 Exemplos: "/api/users", "UserService", "payment-gateway"
93
+
94
+ SE formato inválido:
95
+ ⚠️ AVISO: Endpoint deve ser caminho de API ou nome de serviço
96
+ ```
97
+
98
+ ### Passo 2: Detectar Framework de Integração
99
+
100
+ **Estratégia de Detecção (em ordem de prioridade):**
101
+
102
+ 1. **Verificar configurações:**
103
+ - `pact.config.{js,ts}` → Pact detectado
104
+ - `postman.json` ou `postman/` → Postman detectado
105
+ - `wiremock/` ou `mocks/` → Wiremock detectado
106
+ - `package.json` → `supertest`, `@pact-foundation/pact`, `postman`, `wiremock` em dependencies
107
+ - `jest.config.{js,ts}` ou `vitest.config.{js,ts}` → Jest/Vitest com Supertest
108
+
109
+ 2. **Buscar arquivos de teste existentes:**
110
+ - `**/*.integration.{js,ts}`
111
+ - `**/integration/**/*.spec.{js,ts}`
112
+ - `**/tests/integration/**/*.{js,ts}`
113
+ - `**/contracts/**/*.{js,ts}` (Pact)
114
+ - `**/pacts/**/*.json` (Pact)
115
+
116
+ 3. **Inferir por estrutura:**
117
+ - Diretório `contracts/` ou `pacts/` → Pact
118
+ - Diretório `mocks/` ou `wiremock/` → Wiremock
119
+ - Arquivos `*.postman_collection.json` → Postman
120
+ - Uso de `supertest` em testes → Supertest
121
+
122
+ **Output:**
123
+ ```markdown
124
+ ✅ Framework detectado: [supertest|pact|postman|wiremock|jest|vitest]
125
+ 📁 Config: [caminho do arquivo de config]
126
+ 🔧 Test runner: [jest|vitest|mocha]
127
+ 🌐 Mock strategy: [wiremock|nock|msw]
128
+ ```
129
+
130
+ **Se `--framework` fornecido:** Sobrescreve detecção automática
131
+
132
+ ### Passo 3: Analisar API/Service
133
+
134
+ **Objetivo:** Identificar endpoints, contratos e dependências externas.
135
+
136
+ #### 3.1 Detectar Tipo de Endpoint
137
+
138
+ **Buscar no código:**
139
+ - Rotas de API: `app.get()`, `router.post()`, `@Get()`, `@Post()`
140
+ - Serviços: Classes com métodos públicos, interfaces
141
+ - GraphQL: `schema.graphql`, resolvers
142
+
143
+ #### 3.2 Extrair Contratos
144
+
145
+ **Buscar schemas e contratos:**
146
+ - OpenAPI/Swagger: `openapi.yaml`, `swagger.json`
147
+ - JSON Schema: `schema.json`, `*.schema.json`
148
+ - Pact contracts: `pacts/*.json`
149
+ - TypeScript types/interfaces
150
+ - GraphQL schema
151
+
152
+ #### 3.3 Identificar Dependências Externas
153
+
154
+ - APIs externas (HTTP calls)
155
+ - Serviços de terceiros
156
+ - Bancos de dados
157
+ - Message queues
158
+ - Cache services
159
+
160
+ **Output da Análise:**
161
+ ```markdown
162
+ 📊 Análise de API/Service:
163
+ ∟ Tipo: [REST API|GraphQL|Service|Microservice]
164
+ ∟ Endpoints encontrados: [N]
165
+ ∟ Contratos encontrados: [Sim/Não]
166
+ ∟ Dependências externas: [lista]
167
+ ∟ Mock strategy: [wiremock|nock|msw|manual]
168
+ ```
169
+
170
+ ### Passo 4: Verificar Arquivo de Teste Existente
171
+
172
+ **Padrões de nomenclatura:**
173
+ - **Supertest:** `{{endpoint}}.integration.test.{js,ts}`
174
+ - **Pact:** `{{consumer}}-{{provider}}.spec.{js,ts}` ou `contracts/{{name}}.spec.{js,ts}`
175
+ - **Postman:** `{{collection}}.postman_collection.json`
176
+ - **Jest/Vitest:** `{{endpoint}}.integration.{js,ts}` ou `integration/{{endpoint}}.spec.{js,ts}`
177
+
178
+ **Decisão:**
179
+ ```markdown
180
+ SE arquivo existe:
181
+ ✅ Encontrado: [caminho]
182
+ SE --generate: ⚠️ Pula geração, continua execução
183
+ SENÃO: Continua execução
184
+
185
+ SE não existe:
186
+ SE --generate: → Gerar (Passo 5)
187
+ SENÃO: ❌ ERRO: Use --generate para criar
188
+ ```
189
+
190
+ ### Passo 5: Gerar Arquivo de Teste (SE --generate)
191
+
192
+ **Estratégia:**
193
+ 1. **Ler padrões existentes:** Buscar `**/*.integration.{js,ts}`, `**/contracts/**/*.{js,ts}` para extrair estrutura
194
+ 2. **Gerar testes base:** Padrão AAA (Arrange, Act, Assert) para cada endpoint:
195
+ - **Contract tests:** Validação de schema, tipos, estruturas
196
+ - **Boundary tests:** Timeouts, erros, limites, edge cases
197
+ - **Fuzzing tests:** Dados malformados, tipos incorretos, valores extremos
198
+ 3. **Configurar mocks:** Para dependências externas (Wiremock, Nock, MSW)
199
+ 4. **Criar arquivo:** `write {{test-file-path}}`
200
+
201
+ **Exemplo estrutura (Supertest + Jest):**
202
+ ```typescript
203
+ import request from 'supertest';
204
+ import app from '../src/app';
205
+
206
+ describe('API Integration: {{api-endpoint}}', () => {
207
+ beforeEach(() => {
208
+ // Setup mocks para serviços externos
209
+ });
210
+
211
+ describe('Contract Testing', () => {
212
+ test('should return valid schema for GET /api/users', async () => {
213
+ const response = await request(app)
214
+ .get('/api/users')
215
+ .expect(200);
216
+
217
+ expect(response.body).toMatchSchema({
218
+ users: expect.arrayContaining([
219
+ expect.objectContaining({
220
+ id: expect.any(String),
221
+ name: expect.any(String),
222
+ email: expect.any(String)
223
+ })
224
+ ])
225
+ });
226
+ });
227
+ });
228
+
229
+ describe('Boundary Testing', () => {
230
+ test('should handle timeout from external service', async () => {
231
+ // Mock timeout
232
+ mockExternalService.timeout();
233
+
234
+ const response = await request(app)
235
+ .get('/api/users')
236
+ .expect(500);
237
+
238
+ expect(response.body.error).toBe('Service timeout');
239
+ });
240
+
241
+ test('should handle invalid response from external service', async () => {
242
+ mockExternalService.returnsInvalidData();
243
+
244
+ const response = await request(app)
245
+ .get('/api/users')
246
+ .expect(500);
247
+ });
248
+ });
249
+
250
+ describe('Fuzzing Tests', () => {
251
+ test('should handle malformed JSON gracefully', async () => {
252
+ const malformedInputs = [
253
+ '{"name": incomplete',
254
+ '{"name": null, "email": ""}',
255
+ '{"name": "' + 'x'.repeat(10000) + '"}',
256
+ ];
257
+
258
+ for (const input of malformedInputs) {
259
+ const response = await request(app)
260
+ .post('/api/users')
261
+ .send(input)
262
+ .expect(400);
263
+
264
+ expect(response.body.error).toBeDefined();
265
+ }
266
+ });
267
+ });
268
+ });
269
+ ```
270
+
271
+ **Exemplo estrutura (Pact):**
272
+ ```typescript
273
+ import { Pact } from '@pact-foundation/pact';
274
+
275
+ describe('Pact Contract: UserService', () => {
276
+ const provider = new Pact({
277
+ consumer: 'Frontend',
278
+ provider: 'UserService',
279
+ });
280
+
281
+ beforeAll(() => provider.setup());
282
+ afterAll(() => provider.finalize());
283
+
284
+ test('should return user list', async () => {
285
+ await provider.addInteraction({
286
+ state: 'users exist',
287
+ uponReceiving: 'a request for users',
288
+ withRequest: {
289
+ method: 'GET',
290
+ path: '/api/users',
291
+ },
292
+ willRespondWith: {
293
+ status: 200,
294
+ body: {
295
+ users: Matchers.arrayContaining([
296
+ Matchers.like({
297
+ id: Matchers.string('123'),
298
+ name: Matchers.string('John'),
299
+ }),
300
+ ]),
301
+ },
302
+ },
303
+ });
304
+
305
+ // Execute test
306
+ const response = await fetch('/api/users');
307
+ expect(response.status).toBe(200);
308
+ });
309
+ });
310
+ ```
311
+
312
+ **Validação:** ✅ Arquivo gerado: {{test-file-path}}, [N] testes (contract: X, boundary: Y, fuzzing: Z)
313
+
314
+ ### Passo 6: Executar Testes (SE --run)
315
+
316
+ **Comandos por framework:**
317
+
318
+ - **Supertest + Jest:** `npx jest {{test-file}} [--coverage]` ou `pnpm jest`
319
+ - **Supertest + Vitest:** `npx vitest [run] {{test-file}}` ou `pnpm vitest`
320
+ - **Pact:** `npx pact-provider-verifier` ou `pnpm pact:verify`
321
+ - **Postman:** `npx newman run {{collection}}.json` ou `pnpm postman:test`
322
+ - **Wiremock:** `java -jar wiremock.jar --port 8080` (setup) + testes
323
+
324
+ **Construir comando:** Base + flags específicas + execução
325
+
326
+ **Executar:** `run_terminal_cmd [comando]` e capturar: resultados (pass/fail), contratos validados, erros, tempo
327
+
328
+ ### Passo 7: Apresentar Resultados
329
+
330
+ ## 📤 Output Esperado
331
+
332
+ ```
333
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
334
+ ✅ TESTES DE INTEGRAÇÃO - {{api-endpoint}}
335
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
336
+
337
+ 🔍 Detecção:
338
+ ∟ Framework: [supertest|pact|postman|wiremock|jest|vitest]
339
+ ∟ Config: [caminho do arquivo de config]
340
+ ∟ Test runner: [jest|vitest|mocha]
341
+ ∟ Mock strategy: [wiremock|nock|msw|manual]
342
+
343
+ 📊 Análise de API/Service:
344
+ ∟ Endpoint/Service: {{api-endpoint}}
345
+ ∟ Tipo: [REST API|GraphQL|Service|Microservice]
346
+ ∟ Endpoints encontrados: [N]
347
+ ∟ Contratos encontrados: [Sim/Não]
348
+ ∟ Dependências externas: [lista]
349
+ ∟ Mock strategy recomendada: [wiremock|nock|msw]
350
+
351
+ 📝 Arquivo de Teste:
352
+ ∟ Status: [✅ Existente | ✅ Gerado | ❌ Não encontrado]
353
+ ∟ Caminho: {{test-file-path}}
354
+ ∟ Testes: [N] casos de teste
355
+ ├─ Contract tests: [N]
356
+ ├─ Boundary tests: [N]
357
+ └─ Fuzzing tests: [N]
358
+
359
+ 🧪 Execução:
360
+ ∟ Comando: [comando executado]
361
+ ∟ Status: [✅ Passou | ❌ Falhou | ⚠️ Parcial]
362
+ ∟ Testes executados: [X/Y] passaram
363
+ ∟ Contratos validados: [X/Y]
364
+ ∟ Tempo: [X]s
365
+
366
+ 📊 Resultados Detalhados:
367
+ ∟ Contract Tests: [X/Y] ✅
368
+ └─ Schemas validados: [lista]
369
+ └─ Contratos verificados: [lista]
370
+ ∟ Boundary Tests: [X/Y] ✅
371
+ └─ Timeouts testados: [N]
372
+ └─ Erros tratados: [N]
373
+ ∟ Fuzzing Tests: [X/Y] ✅
374
+ └─ Inputs malformados: [N]
375
+ └─ Edge cases: [N]
376
+
377
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
378
+
379
+ 🚀 Próximos Passos:
380
+ 1. Revisar testes gerados e adicionar casos específicos
381
+ 2. Executar novamente: /test/integration {{api-endpoint}} --run
382
+ 3. Adicionar contract tests: /test/integration {{api-endpoint}} --contract
383
+ 4. Integrar no pipeline: /validate/test-strategy/create
384
+
385
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
386
+ ```
387
+
388
+ ## 📋 Exemplos de Uso
389
+
390
+ **1. Gerar e executar com contract testing:**
391
+ ```bash
392
+ /test/integration /api/users --generate --run --contract
393
+ ```
394
+ → Detecta framework, analisa API, gera `users.integration.test.js` com contract tests, executa
395
+
396
+ **2. Apenas gerar testes de boundary:**
397
+ ```bash
398
+ /test/integration payment-service --generate --boundary --framework supertest
399
+ ```
400
+ → Força Supertest, gera testes de boundary (timeouts, erros), não executa
401
+
402
+ **3. Executar com fuzzing:**
403
+ ```bash
404
+ /test/integration /api/orders --run --fuzz
405
+ ```
406
+ → Executa `orders.integration.test.js` existente com fuzzing habilitado
407
+
408
+ **4. Gerar testes completos (contract + boundary + fuzzing):**
409
+ ```bash
410
+ /test/integration user-service --generate --contract --boundary --fuzz
411
+ ```
412
+ → Gera suite completa de testes de integração
413
+
414
+ **5. Executar teste existente sem mockar externos:**
415
+ ```bash
416
+ /test/integration /api/products --run --mock-external false
417
+ ```
418
+ → Executa contra serviços reais (útil para staging)
419
+
420
+ ## ⚙️ Parâmetros Detalhados
421
+
422
+ | Parâmetro | Tipo | Obrigatório | Descrição |
423
+ |-----------|------|-------------|-----------|
424
+ | `api-endpoint` | string | ✅ | Endpoint da API ou nome do serviço |
425
+ | `--generate` | flag | ❌ | Gera arquivo de teste se não existir |
426
+ | `--run` | flag | ❌ | Executa os testes após gerar/validar |
427
+ | `--contract` | flag | ❌ | Foca em contract testing (schemas) |
428
+ | `--boundary` | flag | ❌ | Foca em boundary testing (timeouts, erros) |
429
+ | `--fuzz` | flag | ❌ | Inclui fuzzing de API (dados malformados) |
430
+ | `--framework` | string | ❌ | Framework específico (sobrescreve auto-detecção) |
431
+ | `--mock-external` | boolean | ❌ | Mocka serviços externos (default: true) |
432
+
433
+ ## 🔗 Comandos Relacionados
434
+
435
+ - `/test/unit` - Testes unitários (White-box)
436
+ - `/test/e2e` - Testes end-to-end (Black-box)
437
+ - `/validate/test-strategy/create` - Criar estratégia completa de testes
438
+ - `/engineer/work` - Continuar desenvolvimento com testes
439
+
440
+ ## ⚠️ Validações e Regras
441
+
442
+ ### Validações Obrigatórias
443
+
444
+ 1. **Endpoint/Service deve ser fornecido:**
445
+ ```markdown
446
+ SE api-endpoint vazio:
447
+ ❌ ERRO: Endpoint ou serviço é obrigatório
448
+ ```
449
+
450
+ 2. **Framework deve ser detectável ou fornecido:**
451
+ ```markdown
452
+ SE nenhum framework detectado E --framework não fornecido:
453
+ ❌ ERRO: Não foi possível detectar framework de integração
454
+ 💡 Instale um framework ou use --framework [nome]
455
+ ```
456
+
457
+ 3. **Arquivo de teste deve existir para execução:**
458
+ ```markdown
459
+ SE --run fornecido E arquivo de teste não existe E --generate não fornecido:
460
+ ❌ ERRO: Arquivo de teste não encontrado
461
+ 💡 Use --generate para criar automaticamente
462
+ ```
463
+
464
+ ### Regras de Negócio
465
+
466
+ 1. **Auto-detecção tem prioridade** sobre --framework, exceto se --framework fornecido
467
+ 2. **Geração segue padrões** do projeto (analisa testes existentes)
468
+ 3. **Contract testing** valida schemas, tipos e estruturas de resposta
469
+ 4. **Boundary testing** foca em timeouts, erros e limites de integração
470
+ 5. **Fuzzing** testa robustez com dados malformados e edge cases
471
+ 6. **Mock externo é default** (true) para isolamento, use `--mock-external false` para testes reais
472
+ 7. **Testes gerados** seguem perspectiva Grey-box (dev testando outro dev)
473
+
474
+ ## 🔧 Suporte por Framework
475
+
476
+ | Framework | Contract | Boundary | Fuzzing | Mock Strategy |
477
+ |-----------|----------|----------|---------|---------------|
478
+ | Supertest | ✅ | ✅ | ✅ | Nock, MSW |
479
+ | Pact | ✅ | ⚠️ | ❌ | Pact Mock Service |
480
+ | Postman | ✅ | ✅ | ⚠️ | Postman Mock Server |
481
+ | Wiremock | ⚠️ | ✅ | ⚠️ | Wiremock |
482
+ | Jest/Vitest | ✅ | ✅ | ✅ | Jest/Vitest mocks |
483
+
484
+ ## 📚 Referências
485
+
486
+ - **Agente de Testes:** @test-engineer, @test-agent
487
+ - **Framework de Testes:** `docs/knowbase/frameworks/framework_testes.md`
488
+ - **Grey-box Testing:** Seção "Padrões Grey-box" do framework
489
+ - **API Contract Testing:** Seção "Teste de Contrato de API"
490
+ - **Supertest Docs:** https://github.com/visionmedia/supertest
491
+ - **Pact Docs:** https://docs.pact.io
492
+ - **Wiremock Docs:** https://wiremock.org
493
+
494
+ ## ⚠️ Notas Importantes
495
+
496
+ - **Auto-detecção inteligente:** Analisa configurações e padrões do projeto
497
+ - **Geração conservadora:** Cria testes básicos, desenvolvedor deve expandir
498
+ - **Perspectiva Grey-box:** Foco em integração entre componentes (dev testando outro dev)
499
+ - **Contract testing:** Valida contratos entre serviços (100% coverage conforme framework)
500
+ - **Boundary testing:** Testa fronteiras de integração (timeouts, erros, limites)
501
+ - **Fuzzing opcional:** Use `--fuzz` para testes de robustez
502
+ - **Mock por padrão:** Isola testes de serviços externos, use `--mock-external false` para testes reais
503
+ - **Integração com pipeline:** Testes gerados seguem padrões do projeto
504
+
505
+ ---
506
+
507
+ **Versão:** 3.0.0
508
+ **Última atualização:** 2025-12-03
509
+ **Mantido por:** Sistema Onion
510
+
511
+
512
+
513
+ ---
514
+
515
+ ## 📚 Pré-requisitos
516
+
517
+ Domine comandos starter antes de usar este comando intermediate/advanced.
518
+
519
+ Consulte os comandos help para ver hierarquia completa e comandos relacionados:
520
+ - /business/help --level=starter
521
+ - /technical/help --level=starter
522
+
523
+ 💡 Comandos intermediate/advanced assumem familiaridade com workflows básicos do contexto.