@onion-architect-ai/cli 4.1.0-beta.4 → 4.1.0-beta.5

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 (97) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/cli.js.map +1 -1
  3. package/package.json +1 -1
  4. package/templates/.cursor/agents/development/c4-architecture-specialist.md +712 -0
  5. package/templates/.cursor/agents/development/c4-documentation-specialist.md +658 -0
  6. package/templates/.cursor/agents/development/clickup-specialist.md +397 -0
  7. package/templates/.cursor/agents/development/cursor-specialist.md +249 -0
  8. package/templates/.cursor/agents/development/docs-reverse-engineer.md +418 -0
  9. package/templates/.cursor/agents/development/gamma-api-specialist.md +1169 -0
  10. package/templates/.cursor/agents/development/gitflow-specialist.md +1207 -0
  11. package/templates/.cursor/agents/development/linux-security-specialist.md +676 -0
  12. package/templates/.cursor/agents/development/mermaid-specialist.md +516 -0
  13. package/templates/.cursor/agents/development/nodejs-specialist.md +673 -0
  14. package/templates/.cursor/agents/development/nx-migration-specialist.md +867 -0
  15. package/templates/.cursor/agents/development/nx-monorepo-specialist.md +619 -0
  16. package/templates/.cursor/agents/development/postgres-specialist.md +1124 -0
  17. package/templates/.cursor/agents/development/react-developer.md +132 -0
  18. package/templates/.cursor/agents/development/runflow-specialist.md +278 -0
  19. package/templates/.cursor/agents/development/system-documentation-orchestrator.md +1388 -0
  20. package/templates/.cursor/agents/development/task-specialist.md +618 -0
  21. package/templates/.cursor/agents/development/whisper-specialist.md +373 -0
  22. package/templates/.cursor/agents/development/zen-engine-specialist.md +421 -0
  23. package/templates/.cursor/agents/git/branch-code-reviewer.md +200 -0
  24. package/templates/.cursor/agents/git/branch-documentation-writer.md +162 -0
  25. package/templates/.cursor/agents/git/branch-metaspec-checker.md +68 -0
  26. package/templates/.cursor/agents/git/branch-test-planner.md +177 -0
  27. package/templates/.cursor/agents/product/branding-positioning-specialist.md +1030 -0
  28. package/templates/.cursor/agents/product/extract-meeting-specialist.md +395 -0
  29. package/templates/.cursor/agents/product/meeting-consolidator.md +483 -0
  30. package/templates/.cursor/agents/product/pain-price-specialist.md +509 -0
  31. package/templates/.cursor/agents/product/presentation-orchestrator.md +1191 -0
  32. package/templates/.cursor/agents/product/product-agent.md +202 -0
  33. package/templates/.cursor/agents/product/story-points-framework-specialist.md +539 -0
  34. package/templates/.cursor/agents/product/storytelling-business-specialist.md +891 -0
  35. package/templates/.cursor/agents/review/code-reviewer.md +155 -0
  36. package/templates/.cursor/agents/testing/test-agent.md +425 -0
  37. package/templates/.cursor/agents/testing/test-engineer.md +295 -0
  38. package/templates/.cursor/agents/testing/test-planner.md +118 -0
  39. package/templates/.cursor/commands/docs/build-business-docs.md +276 -0
  40. package/templates/.cursor/commands/docs/build-index.md +128 -0
  41. package/templates/.cursor/commands/docs/build-tech-docs.md +204 -0
  42. package/templates/.cursor/commands/docs/consolidate-documents.md +424 -0
  43. package/templates/.cursor/commands/docs/docs-health.md +142 -0
  44. package/templates/.cursor/commands/docs/help.md +306 -0
  45. package/templates/.cursor/commands/docs/refine-vision.md +27 -0
  46. package/templates/.cursor/commands/docs/reverse-consolidate.md +160 -0
  47. package/templates/.cursor/commands/docs/sync-sessions.md +320 -0
  48. package/templates/.cursor/commands/docs/validate-docs.md +159 -0
  49. package/templates/.cursor/commands/engineer/bump.md +43 -0
  50. package/templates/.cursor/commands/engineer/docs.md +39 -0
  51. package/templates/.cursor/commands/engineer/help.md +329 -0
  52. package/templates/.cursor/commands/engineer/hotfix.md +186 -0
  53. package/templates/.cursor/commands/engineer/plan.md +111 -0
  54. package/templates/.cursor/commands/engineer/pr-update.md +198 -0
  55. package/templates/.cursor/commands/engineer/pr.md +136 -0
  56. package/templates/.cursor/commands/engineer/pre-pr.md +91 -0
  57. package/templates/.cursor/commands/engineer/start.md +266 -0
  58. package/templates/.cursor/commands/engineer/validate-phase-sync.md +118 -0
  59. package/templates/.cursor/commands/engineer/warm-up.md +173 -0
  60. package/templates/.cursor/commands/engineer/work.md +169 -0
  61. package/templates/.cursor/commands/git/code-review.md +215 -0
  62. package/templates/.cursor/commands/git/fast-commit.md +45 -0
  63. package/templates/.cursor/commands/git/feature/finish.md +90 -0
  64. package/templates/.cursor/commands/git/feature/publish.md +91 -0
  65. package/templates/.cursor/commands/git/feature/start.md +158 -0
  66. package/templates/.cursor/commands/git/help.md +306 -0
  67. package/templates/.cursor/commands/git/hotfix/finish.md +98 -0
  68. package/templates/.cursor/commands/git/hotfix/start.md +94 -0
  69. package/templates/.cursor/commands/git/init.md +139 -0
  70. package/templates/.cursor/commands/git/release/finish.md +98 -0
  71. package/templates/.cursor/commands/git/release/start.md +95 -0
  72. package/templates/.cursor/commands/git/sync.md +228 -0
  73. package/templates/.cursor/commands/global/help.md +388 -0
  74. package/templates/.cursor/commands/product/analyze-pain-price.md +709 -0
  75. package/templates/.cursor/commands/product/branding.md +460 -0
  76. package/templates/.cursor/commands/product/check.md +48 -0
  77. package/templates/.cursor/commands/product/checklist-sync.md +241 -0
  78. package/templates/.cursor/commands/product/collect.md +96 -0
  79. package/templates/.cursor/commands/product/consolidate-meetings.md +306 -0
  80. package/templates/.cursor/commands/product/convert-to-tasks.md +220 -0
  81. package/templates/.cursor/commands/product/estimate.md +519 -0
  82. package/templates/.cursor/commands/product/extract-meeting.md +241 -0
  83. package/templates/.cursor/commands/product/feature.md +431 -0
  84. package/templates/.cursor/commands/product/help.md +212 -0
  85. package/templates/.cursor/commands/product/light-arch.md +97 -0
  86. package/templates/.cursor/commands/product/presentation.md +189 -0
  87. package/templates/.cursor/commands/product/refine.md +186 -0
  88. package/templates/.cursor/commands/product/spec.md +107 -0
  89. package/templates/.cursor/commands/product/task-check.md +340 -0
  90. package/templates/.cursor/commands/product/task.md +585 -0
  91. package/templates/.cursor/commands/product/transform-consolidated.md +592 -0
  92. package/templates/.cursor/commands/product/validate-task.md +294 -0
  93. package/templates/.cursor/commands/product/warm-up.md +187 -0
  94. package/templates/.cursor/commands/product/whisper.md +325 -0
  95. package/templates/.cursor/commands/test/e2e.md +392 -0
  96. package/templates/.cursor/commands/test/integration.md +523 -0
  97. package/templates/.cursor/commands/test/unit.md +378 -0
@@ -0,0 +1,378 @@
1
+ ---
2
+ name: unit
3
+ description: |
4
+ Gera e executa testes unitários automaticamente com detecção de framework.
5
+ Use para criar testes seguindo padrões do projeto e executá-los com coverage.
6
+ model: sonnet
7
+
8
+ parameters:
9
+ - name: file-path
10
+ description: Caminho do arquivo fonte para testar (obrigatório)
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: --coverage
19
+ description: Inclui relatório de coverage na execução
20
+ required: false
21
+ - name: --watch
22
+ description: Modo watch para re-execução automática
23
+ required: false
24
+ - name: --framework
25
+ description: Framework específico (sobrescreve auto-detecção: jest|vitest|pytest|junit)
26
+ required: false
27
+
28
+ category: test
29
+ tags:
30
+ - testing
31
+ - unit-tests
32
+ - test-generation
33
+ - code-quality
34
+ - automation
35
+ - coverage
36
+
37
+ version: "4.0.0"
38
+ updated: "2025-12-20"
39
+
40
+ related_commands:
41
+ - /test/integration
42
+ - /test/e2e
43
+ - /validate/test-strategy/create
44
+ - /engineer/work
45
+ - /git/code-review
46
+
47
+ related_agents:
48
+ - test-engineer
49
+ - test-planner
50
+ level: intermediate
51
+ context: technical
52
+ ---
53
+
54
+ # 🧪 Test Unit
55
+
56
+ Gera e executa testes unitários automaticamente com detecção inteligente de framework, análise de código e integração com ferramentas de coverage.
57
+
58
+ ## 🎯 Objetivo
59
+
60
+ Automatizar o ciclo completo de testes unitários:
61
+ - **Auto-detecção** de framework de teste baseado em configurações do projeto
62
+ - **Análise de código** para identificar funções/métodos públicos testáveis
63
+ - **Geração automática** de arquivos de teste seguindo padrões do projeto
64
+ - **Execução inteligente** com suporte a coverage e watch mode
65
+ - **Integração** com pipeline de testes existente
66
+
67
+ ## ⚡ Fluxo de Execução
68
+
69
+ ### Passo 1: Validar Arquivo Fonte
70
+
71
+ ```bash
72
+ # Verificar se arquivo existe
73
+ if [ ! -f "{{file-path}}" ]; then
74
+ echo "❌ ERRO: Arquivo não encontrado: {{file-path}}"
75
+ exit 1
76
+ fi
77
+
78
+ # Extrair informações do arquivo
79
+ - Extensão: .js, .ts, .tsx, .py, .java, etc.
80
+ - Diretório base
81
+ - Nome do arquivo (sem extensão)
82
+ ```
83
+
84
+ **Validações:**
85
+ ```markdown
86
+ SE arquivo não existe:
87
+ ❌ ERRO: Arquivo não encontrado: {{file-path}}
88
+ 💡 Verifique o caminho e tente novamente
89
+
90
+ SE arquivo não é código fonte suportado:
91
+ ⚠️ AVISO: Tipo de arquivo pode não ser suportado
92
+ Tipos suportados: .js, .ts, .tsx, .jsx, .py, .java, .go, .rs
93
+ ```
94
+
95
+ ### Passo 2: Detectar Framework de Teste
96
+
97
+ **Estratégia de Detecção (em ordem de prioridade):**
98
+
99
+ 1. **Verificar configurações:** `package.json` (Jest/Vitest), `pytest.ini` (PyTest), `pom.xml`/`build.gradle` (JUnit), `go.mod` (Go), `Cargo.toml` (Rust)
100
+ 2. **Buscar arquivos de teste existentes:** `**/*.test.{js,ts}`, `**/test_*.py`, `**/*_test.go`, `**/*Test.java`
101
+ 3. **Inferir por linguagem:** Jest/Vitest (JS/TS), PyTest (Python), JUnit (Java), testing (Go), cargo test (Rust)
102
+
103
+ **Output:**
104
+ ```markdown
105
+ ✅ Framework: [jest|vitest|pytest|junit|go-test|rust-test]
106
+ 📁 Config: [caminho]
107
+ 📦 Package manager: [npm|pnpm|yarn|pip|maven|gradle|cargo]
108
+ ```
109
+
110
+ **Se `--framework` fornecido:** Sobrescreve detecção automática
111
+
112
+ ### Passo 3: Analisar Código Fonte
113
+
114
+ **Objetivo:** Identificar funções/métodos públicos que precisam de testes.
115
+
116
+ #### 3.1 Ler Arquivo Fonte
117
+
118
+ ```bash
119
+ read_file {{file-path}}
120
+ ```
121
+
122
+ #### 3.2 Extrair Funções/Métodos Públicos
123
+
124
+ **Padrões por linguagem:**
125
+ - **JS/TS:** `export function/const/class`, `export default`
126
+ - **Python:** `def nome_funcao` (sem `_` inicial), classes públicas
127
+ - **Java:** `public methods`, `@Test` annotations
128
+ - **Go:** `func NomeFuncao` (maiúscula inicial)
129
+ - **Rust:** `pub fn`, `pub struct`, `impl` públicos
130
+
131
+ #### 3.3 Identificar Dependências Externas
132
+
133
+ - Imports/requires externos, APIs, arquivos/DB, dependências para mocks
134
+
135
+ **Output da Análise:**
136
+ ```markdown
137
+ 📊 Análise de Código:
138
+ ∟ Funções públicas encontradas: [N]
139
+ ∟ Classes encontradas: [N]
140
+ ∟ Dependências externas: [lista]
141
+ ∟ Complexidade estimada: [baixa|média|alta]
142
+ ```
143
+
144
+ ### Passo 4: Verificar Arquivo de Teste Existente
145
+
146
+ **Padrões de nomenclatura:**
147
+ - **Jest/Vitest:** `{{file}}.test.{js,ts,tsx}`
148
+ - **PyTest:** `test_{{file}}.py` ou `tests/test_{{file}}.py`
149
+ - **JUnit:** `{{Class}}Test.java` em `src/test/`
150
+ - **Go:** `{{file}}_test.go`
151
+ - **Rust:** `#[cfg(test)]` no mesmo arquivo
152
+
153
+ **Decisão:**
154
+ ```markdown
155
+ SE arquivo existe:
156
+ ✅ Encontrado: [caminho]
157
+ SE --generate: ⚠️ Pula geração, continua execução
158
+ SENÃO: Continua execução
159
+
160
+ SE não existe:
161
+ SE --generate: → Gerar (Passo 5)
162
+ SENÃO: ❌ ERRO: Use --generate para criar
163
+ ```
164
+
165
+ ### Passo 5: Gerar Arquivo de Teste (SE --generate)
166
+
167
+ **Estratégia:**
168
+ 1. **Ler padrões existentes:** Buscar `**/*.test.{js,ts}`, `**/test_*.py` para extrair estrutura, imports, nomenclatura
169
+ 2. **Gerar testes base:** Padrão AAA (Arrange, Act, Assert) para cada função pública:
170
+ - Happy path: entrada válida → saída esperada
171
+ - Edge cases: null, vazios, limites
172
+ - Error handling: entradas inválidas → exceções
173
+ 3. **Configurar mocks:** Para dependências externas (Jest: `jest.mock()`, Vitest: `vi.mock()`)
174
+ 4. **Criar arquivo:** `write {{test-file-path}}`
175
+
176
+ **Exemplo estrutura (Jest/Vitest):**
177
+ ```typescript
178
+ describe('nomeFuncao', () => {
179
+ test('should return expected result with valid input', () => {
180
+ const result = nomeFuncao('valid input')
181
+ expect(result).toBe('expected output')
182
+ })
183
+ test('should handle edge case', () => {
184
+ expect(() => nomeFuncao(null)).toThrow()
185
+ })
186
+ })
187
+ ```
188
+
189
+ **Validação:** ✅ Arquivo gerado: {{test-file-path}}, [N] testes (happy path: X, edge: Y, errors: Z)
190
+
191
+ ### Passo 6: Executar Testes (SE --run)
192
+
193
+ **Comandos por framework:**
194
+
195
+ - **Jest:** `npx jest {{test-file}} [--coverage] [--watch]` ou `pnpm jest`
196
+ - **Vitest:** `npx vitest [run] {{test-file}} [--coverage]` ou `pnpm vitest`
197
+ - **PyTest:** `pytest {{test-file}} [--cov={{dir}} --cov-report=html]` ou `ptw` (watch)
198
+ - **JUnit:** `mvn test -Dtest={{Class}}` ou `./gradlew test --tests {{Class}}`
199
+ - **Go:** `go test ./{{pkg}} [-v] [-cover]`
200
+ - **Rust:** `cargo test {{name}}`
201
+
202
+ **Construir comando:** Base + `--coverage` (se flag) + `--watch` (se flag) + execução única (se não watch)
203
+
204
+ **Executar:** `run_terminal_cmd [comando]` e capturar: resultados (pass/fail), coverage (se aplicável), erros, tempo
205
+
206
+ ### Passo 7: Apresentar Resultados
207
+
208
+ ## 📤 Output Esperado
209
+
210
+ ```
211
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
212
+ ✅ TESTES UNITÁRIOS - {{file-path}}
213
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
214
+
215
+ 🔍 Detecção:
216
+ ∟ Framework: [jest|vitest|pytest|junit|go-test|rust-test]
217
+ ∟ Config: [caminho do arquivo de config]
218
+ ∟ Package manager: [npm|pnpm|yarn|pip|maven|gradle|cargo]
219
+
220
+ 📊 Análise de Código:
221
+ ∟ Arquivo fonte: {{file-path}}
222
+ ∟ Funções públicas: [N]
223
+ ∟ Classes: [N]
224
+ ∟ Dependências externas: [lista]
225
+ ∟ Complexidade: [baixa|média|alta]
226
+
227
+ 📝 Arquivo de Teste:
228
+ ∟ Status: [✅ Existente | ✅ Gerado | ❌ Não encontrado]
229
+ ∟ Caminho: {{test-file-path}}
230
+ ∟ Testes: [N] casos de teste
231
+ ├─ Happy path: [N]
232
+ ├─ Edge cases: [N]
233
+ └─ Error handling: [N]
234
+
235
+ 🧪 Execução:
236
+ ∟ Comando: [comando executado]
237
+ ∟ Status: [✅ Passou | ❌ Falhou | ⚠️ Parcial]
238
+ ∟ Testes executados: [X/Y] passaram
239
+ ∟ Tempo: [X]s
240
+
241
+ 📈 Coverage (se --coverage):
242
+ ∟ Statements: [X]%
243
+ ∟ Branches: [X]%
244
+ ∟ Functions: [X]%
245
+ ∟ Lines: [X]%
246
+ ∟ Arquivo: [caminho do relatório]
247
+
248
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
249
+
250
+ 🚀 Próximos Passos:
251
+ 1. Revisar testes gerados e adicionar casos específicos
252
+ 2. Executar novamente: /test/unit {{file-path}} --run
253
+ 3. Integrar no pipeline: /validate/test-strategy/create
254
+ 4. Code review: /git/code-review
255
+
256
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
257
+ ```
258
+
259
+ ## 📋 Exemplos de Uso
260
+
261
+ **1. Gerar e executar com coverage:**
262
+ ```bash
263
+ /test/unit src/utils/validation.js --generate --run --coverage
264
+ ```
265
+ → Detecta framework, analisa código, gera `validation.test.js`, executa com coverage
266
+
267
+ **2. Apenas gerar teste:**
268
+ ```bash
269
+ /test/unit app/models/user.py --generate --framework pytest
270
+ ```
271
+ → Força PyTest, gera `test_user.py`, não executa
272
+
273
+ **3. Executar com watch:**
274
+ ```bash
275
+ /test/unit components/Button.tsx --run --watch
276
+ ```
277
+ → Detecta framework, executa `Button.test.tsx` em modo watch
278
+
279
+ **4. Executar teste existente:**
280
+ ```bash
281
+ /test/unit src/services/api.ts --run --coverage
282
+ ```
283
+ → Encontra `api.test.ts`, executa com coverage, não gera novo arquivo
284
+
285
+ ## ⚙️ Parâmetros Detalhados
286
+
287
+ | Parâmetro | Tipo | Obrigatório | Descrição |
288
+ |-----------|------|-------------|-----------|
289
+ | `file-path` | string | ✅ | Caminho do arquivo fonte para testar |
290
+ | `--generate` | flag | ❌ | Gera arquivo de teste se não existir |
291
+ | `--run` | flag | ❌ | Executa os testes após gerar/validar |
292
+ | `--coverage` | flag | ❌ | Inclui relatório de coverage |
293
+ | `--watch` | flag | ❌ | Modo watch para re-execução automática |
294
+ | `--framework` | string | ❌ | Framework específico (sobrescreve auto-detecção) |
295
+
296
+ ## 🔗 Comandos Relacionados
297
+
298
+ - `/test/integration` - Testes de integração (Grey-box)
299
+ - `/test/e2e` - Testes end-to-end (Black-box)
300
+ - `/validate/test-strategy/create` - Criar estratégia completa de testes
301
+ - `/engineer/work` - Continuar desenvolvimento com testes
302
+ - `/git/code-review` - Revisar código incluindo testes
303
+
304
+ ## ⚠️ Validações e Regras
305
+
306
+ ### Validações Obrigatórias
307
+
308
+ 1. **Arquivo fonte deve existir:**
309
+ ```markdown
310
+ SE arquivo não encontrado:
311
+ ❌ ERRO: Arquivo não encontrado: {{file-path}}
312
+ ```
313
+
314
+ 2. **Framework deve ser detectável ou fornecido:**
315
+ ```markdown
316
+ SE nenhum framework detectado E --framework não fornecido:
317
+ ❌ ERRO: Não foi possível detectar framework de teste
318
+ 💡 Instale um framework ou use --framework [nome]
319
+ ```
320
+
321
+ 3. **Arquivo de teste deve existir para execução:**
322
+ ```markdown
323
+ SE --run fornecido E arquivo de teste não existe E --generate não fornecido:
324
+ ❌ ERRO: Arquivo de teste não encontrado
325
+ 💡 Use --generate para criar automaticamente
326
+ ```
327
+
328
+ ### Regras de Negócio
329
+
330
+ 1. **Auto-detecção tem prioridade** sobre --framework, exceto se --framework fornecido
331
+ 2. **Geração segue padrões** do projeto (analisa testes existentes)
332
+ 3. **Coverage requer** framework com suporte (Jest, Vitest, PyTest)
333
+ 4. **Watch mode** mantém processo rodando até interrupção
334
+ 5. **Testes gerados** cobrem happy path, edge cases e error handling básicos
335
+
336
+ ## 🔧 Suporte por Linguagem
337
+
338
+ | Linguagem | Frameworks | Coverage | Watch |
339
+ |-----------|-----------|----------|-------|
340
+ | JS/TS | Jest, Vitest, Mocha | ✅ | ✅ |
341
+ | Python | PyTest, unittest | ✅ | ⚠️ |
342
+ | Java | JUnit 5/4 | ✅ | ❌ |
343
+ | Go | testing (built-in) | ✅ | ⚠️ |
344
+ | Rust | cargo test | ⚠️ | ❌ |
345
+
346
+ ## 📚 Referências
347
+
348
+ - **Agente de Testes:** @test-engineer
349
+ - **Framework de Testes:** `docs/knowbase/frameworks/framework_testes.md`
350
+ - **Padrões de Teste:** `.cursor/agents/testing/test-engineer.md`
351
+
352
+ ## ⚠️ Notas Importantes
353
+
354
+ - **Auto-detecção inteligente:** Analisa configurações e padrões do projeto
355
+ - **Geração conservadora:** Cria testes básicos, desenvolvedor deve expandir
356
+ - **Integração com pipeline:** Testes gerados seguem padrões do projeto
357
+ - **Coverage opcional:** Requer configuração prévia do framework
358
+ - **Watch mode:** Mantém processo ativo, use Ctrl+C para parar
359
+
360
+ ---
361
+
362
+ **Versão:** 3.0.0
363
+ **Última atualização:** 2025-11-24
364
+ **Mantido por:** Sistema Onion
365
+
366
+
367
+
368
+ ---
369
+
370
+ ## 📚 Pré-requisitos
371
+
372
+ Domine comandos starter antes de usar este comando intermediate/advanced.
373
+
374
+ Consulte os comandos help para ver hierarquia completa e comandos relacionados:
375
+ - /business/help --level=starter
376
+ - /technical/help --level=starter
377
+
378
+ 💡 Comandos intermediate/advanced assumem familiaridade com workflows básicos do contexto.