@onion-ai/cli 1.0.0-beta.1

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 (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +529 -0
  3. package/bin/onion.js +6 -0
  4. package/framework/CLAUDE.md +45 -0
  5. package/framework/VERSION +1 -0
  6. package/framework/agents/compliance/iso-22301-specialist.md +985 -0
  7. package/framework/agents/compliance/iso-27001-specialist.md +713 -0
  8. package/framework/agents/compliance/pmbok-specialist.md +739 -0
  9. package/framework/agents/compliance/security-information-master.md +907 -0
  10. package/framework/agents/compliance/soc2-specialist.md +889 -0
  11. package/framework/agents/deployment/docker-specialist.md +1192 -0
  12. package/framework/agents/development/c4-architecture-specialist.md +745 -0
  13. package/framework/agents/development/c4-documentation-specialist.md +695 -0
  14. package/framework/agents/development/clickup-specialist.md +396 -0
  15. package/framework/agents/development/cursor-specialist.md +277 -0
  16. package/framework/agents/development/docs-reverse-engineer.md +417 -0
  17. package/framework/agents/development/gamma-api-specialist.md +1168 -0
  18. package/framework/agents/development/gitflow-specialist.md +1206 -0
  19. package/framework/agents/development/linux-security-specialist.md +675 -0
  20. package/framework/agents/development/mermaid-specialist.md +515 -0
  21. package/framework/agents/development/nodejs-specialist.md +672 -0
  22. package/framework/agents/development/nx-migration-specialist.md +866 -0
  23. package/framework/agents/development/nx-monorepo-specialist.md +618 -0
  24. package/framework/agents/development/postgres-specialist.md +1123 -0
  25. package/framework/agents/development/react-developer.md +131 -0
  26. package/framework/agents/development/runflow-specialist.md +277 -0
  27. package/framework/agents/development/system-documentation-orchestrator.md +1387 -0
  28. package/framework/agents/development/task-specialist.md +677 -0
  29. package/framework/agents/git/branch-code-reviewer.md +225 -0
  30. package/framework/agents/git/branch-documentation-writer.md +161 -0
  31. package/framework/agents/git/branch-metaspec-checker.md +67 -0
  32. package/framework/agents/git/branch-test-planner.md +176 -0
  33. package/framework/agents/meta/agent-creator-specialist.md +1266 -0
  34. package/framework/agents/meta/command-creator-specialist.md +1676 -0
  35. package/framework/agents/meta/metaspec-gate-keeper.md +240 -0
  36. package/framework/agents/meta/onion.md +824 -0
  37. package/framework/agents/product/branding-positioning-specialist.md +1029 -0
  38. package/framework/agents/product/extract-meeting-specialist.md +394 -0
  39. package/framework/agents/product/meeting-consolidator.md +482 -0
  40. package/framework/agents/product/pain-price-specialist.md +508 -0
  41. package/framework/agents/product/presentation-orchestrator.md +1190 -0
  42. package/framework/agents/product/product-agent.md +201 -0
  43. package/framework/agents/product/story-points-framework-specialist.md +538 -0
  44. package/framework/agents/product/storytelling-business-specialist.md +890 -0
  45. package/framework/agents/research/research-agent.md +292 -0
  46. package/framework/agents/review/code-reviewer.md +154 -0
  47. package/framework/agents/review/corporate-compliance-specialist.md +370 -0
  48. package/framework/agents/testing/test-agent.md +424 -0
  49. package/framework/agents/testing/test-engineer.md +294 -0
  50. package/framework/agents/testing/test-planner.md +117 -0
  51. package/framework/commands/common/prompts/README.md +208 -0
  52. package/framework/commands/common/prompts/clickup-patterns.md +144 -0
  53. package/framework/commands/common/prompts/code-review-checklist.md +168 -0
  54. package/framework/commands/common/prompts/git-workflow-patterns.md +235 -0
  55. package/framework/commands/common/prompts/output-formats.md +240 -0
  56. package/framework/commands/common/prompts/technical.md +194 -0
  57. package/framework/commands/common/templates/abstraction-template.md +399 -0
  58. package/framework/commands/common/templates/agent-template.md +353 -0
  59. package/framework/commands/common/templates/business_context_template.md +748 -0
  60. package/framework/commands/common/templates/command-template.md +273 -0
  61. package/framework/commands/common/templates/technical_context_template.md +526 -0
  62. package/framework/commands/design/screen-spec.md +505 -0
  63. package/framework/commands/development/runflow-dev.md +465 -0
  64. package/framework/commands/docs/build-business-docs.md +299 -0
  65. package/framework/commands/docs/build-compliance-docs.md +143 -0
  66. package/framework/commands/docs/build-index.md +119 -0
  67. package/framework/commands/docs/build-tech-docs.md +221 -0
  68. package/framework/commands/docs/docs-health.md +141 -0
  69. package/framework/commands/docs/help.md +278 -0
  70. package/framework/commands/docs/refine-vision.md +25 -0
  71. package/framework/commands/docs/reverse-consolidate.md +158 -0
  72. package/framework/commands/docs/sync-sessions.md +354 -0
  73. package/framework/commands/docs/validate-docs.md +157 -0
  74. package/framework/commands/engineer/bump.md +29 -0
  75. package/framework/commands/engineer/docs.md +11 -0
  76. package/framework/commands/engineer/hotfix.md +183 -0
  77. package/framework/commands/engineer/plan.md +85 -0
  78. package/framework/commands/engineer/pr-update.md +219 -0
  79. package/framework/commands/engineer/pr.md +117 -0
  80. package/framework/commands/engineer/pre-pr.md +81 -0
  81. package/framework/commands/engineer/start.md +254 -0
  82. package/framework/commands/engineer/validate-phase-sync.md +134 -0
  83. package/framework/commands/engineer/warm-up.md +20 -0
  84. package/framework/commands/engineer/work.md +155 -0
  85. package/framework/commands/f/company-context-extractor.md +93 -0
  86. package/framework/commands/f/process-meetings.md +103 -0
  87. package/framework/commands/git/README.md +682 -0
  88. package/framework/commands/git/code-review.md +213 -0
  89. package/framework/commands/git/fast-commit.md +43 -0
  90. package/framework/commands/git/feature/finish.md +88 -0
  91. package/framework/commands/git/feature/publish.md +89 -0
  92. package/framework/commands/git/feature/start.md +172 -0
  93. package/framework/commands/git/help.md +100 -0
  94. package/framework/commands/git/hotfix/finish.md +96 -0
  95. package/framework/commands/git/hotfix/start.md +92 -0
  96. package/framework/commands/git/init.md +111 -0
  97. package/framework/commands/git/release/finish.md +96 -0
  98. package/framework/commands/git/release/start.md +93 -0
  99. package/framework/commands/git/sync.md +199 -0
  100. package/framework/commands/meta/all-tools.md +58 -0
  101. package/framework/commands/meta/analyze-complex-problem.md +186 -0
  102. package/framework/commands/meta/create-abstraction.md +882 -0
  103. package/framework/commands/meta/create-agent-express.md +98 -0
  104. package/framework/commands/meta/create-agent.md +210 -0
  105. package/framework/commands/meta/create-command.md +203 -0
  106. package/framework/commands/meta/create-knowledge-base.md +143 -0
  107. package/framework/commands/meta/create-task-structure.md +150 -0
  108. package/framework/commands/meta/setup-integration.md +274 -0
  109. package/framework/commands/onion.md +169 -0
  110. package/framework/commands/product/README.md +249 -0
  111. package/framework/commands/product/analyze-pain-price.md +694 -0
  112. package/framework/commands/product/branding.md +458 -0
  113. package/framework/commands/product/check.md +46 -0
  114. package/framework/commands/product/checklist-sync.md +239 -0
  115. package/framework/commands/product/collect.md +95 -0
  116. package/framework/commands/product/consolidate-meetings.md +291 -0
  117. package/framework/commands/product/estimate.md +511 -0
  118. package/framework/commands/product/extract-meeting.md +226 -0
  119. package/framework/commands/product/feature.md +416 -0
  120. package/framework/commands/product/light-arch.md +82 -0
  121. package/framework/commands/product/presentation.md +174 -0
  122. package/framework/commands/product/refine.md +161 -0
  123. package/framework/commands/product/spec.md +79 -0
  124. package/framework/commands/product/task-check.md +378 -0
  125. package/framework/commands/product/task.md +603 -0
  126. package/framework/commands/product/validate-task.md +325 -0
  127. package/framework/commands/product/warm-up.md +24 -0
  128. package/framework/commands/quick/analisys.md +17 -0
  129. package/framework/commands/test/e2e.md +377 -0
  130. package/framework/commands/test/integration.md +508 -0
  131. package/framework/commands/test/unit.md +381 -0
  132. package/framework/commands/validate/collab/pair-testing.md +657 -0
  133. package/framework/commands/validate/collab/three-amigos.md +534 -0
  134. package/framework/commands/validate/qa-points/estimate.md +660 -0
  135. package/framework/commands/validate/test-strategy/analyze.md +1201 -0
  136. package/framework/commands/validate/test-strategy/create.md +411 -0
  137. package/framework/commands/validate/workflow.md +370 -0
  138. package/framework/commands/warm-up.md +20 -0
  139. package/framework/docs/architecture/acoplamento-clickup-problema-analise.md +468 -0
  140. package/framework/docs/architecture/desacoplamento-roadmap.md +364 -0
  141. package/framework/docs/architecture/validacao-fase-1.md +235 -0
  142. package/framework/docs/c4/c4-detection-rules.md +395 -0
  143. package/framework/docs/c4/c4-documentation-templates.md +579 -0
  144. package/framework/docs/c4/c4-mermaid-patterns.md +331 -0
  145. package/framework/docs/c4/c4-templates.md +256 -0
  146. package/framework/docs/clickup/clickup-acceptance-criteria-strategy.md +329 -0
  147. package/framework/docs/clickup/clickup-auto-update-strategy.md +340 -0
  148. package/framework/docs/clickup/clickup-comment-formatter.md +239 -0
  149. package/framework/docs/clickup/clickup-description-fix.md +384 -0
  150. package/framework/docs/clickup/clickup-dual-comment-strategy.md +528 -0
  151. package/framework/docs/clickup/clickup-formatting.md +302 -0
  152. package/framework/docs/clickup/separador-tamanho-otimizado.md +258 -0
  153. package/framework/docs/engineer/pre-pr-acceptance-validation.md +256 -0
  154. package/framework/docs/onion/ESPERANTO.md +293 -0
  155. package/framework/docs/onion/agents-reference.md +832 -0
  156. package/framework/docs/onion/clickup-integration.md +780 -0
  157. package/framework/docs/onion/commands-guide.md +924 -0
  158. package/framework/docs/onion/engineering-flows.md +900 -0
  159. package/framework/docs/onion/getting-started.md +803 -0
  160. package/framework/docs/onion/maintenance-checklist.md +421 -0
  161. package/framework/docs/onion/naming-conventions.md +286 -0
  162. package/framework/docs/onion/practical-examples.md +854 -0
  163. package/framework/docs/product/story-points-integration.md +269 -0
  164. package/framework/docs/product/story-points-validation.md +237 -0
  165. package/framework/docs/reviews/task-manager-docs-review-2025-11-24.md +184 -0
  166. package/framework/docs/strategies/clickup-comment-patterns.md +766 -0
  167. package/framework/docs/strategies/clickup-integration-tests.md +602 -0
  168. package/framework/docs/strategies/clickup-mcp-wrappers-tests.md +888 -0
  169. package/framework/docs/strategies/clickup-regression-tests.md +587 -0
  170. package/framework/docs/strategies/visual-patterns.md +315 -0
  171. package/framework/docs/templates/README.md +649 -0
  172. package/framework/docs/templates/adr-template.md +226 -0
  173. package/framework/docs/templates/analysis-template.md +280 -0
  174. package/framework/docs/templates/execution-plan-template.md +430 -0
  175. package/framework/docs/templates/guide-template.md +367 -0
  176. package/framework/docs/templates/phase-execution-prompt-template.md +504 -0
  177. package/framework/docs/templates/reference-template.md +522 -0
  178. package/framework/docs/templates/solution-template.md +390 -0
  179. package/framework/docs/tools/README.md +356 -0
  180. package/framework/docs/tools/agents.md +365 -0
  181. package/framework/docs/tools/commands.md +669 -0
  182. package/framework/docs/tools/cursor.md +539 -0
  183. package/framework/docs/tools/mcps.md +937 -0
  184. package/framework/docs/tools/rules.md +461 -0
  185. package/framework/rules/language-and-documentation.mdc +371 -0
  186. package/framework/rules/nestjs-controllers.md +83 -0
  187. package/framework/rules/nestjs-dtos.md +255 -0
  188. package/framework/rules/nestjs-modules.md +141 -0
  189. package/framework/rules/nestjs-services.md +230 -0
  190. package/framework/rules/nx-rules.mdc +41 -0
  191. package/framework/rules/onion-patterns.mdc +197 -0
  192. package/framework/skills/codebase-visualizer/SKILL.md +26 -0
  193. package/framework/skills/codebase-visualizer/scripts/visualize.py +131 -0
  194. package/framework/skills/collect/SKILL.md +84 -0
  195. package/framework/skills/create-rule/SKILL.md +152 -0
  196. package/framework/skills/db-schema-visualizer/SKILL.md +49 -0
  197. package/framework/skills/db-schema-visualizer/scripts/visualize.py +1191 -0
  198. package/framework/skills/sync-meetings/SKILL.md +239 -0
  199. package/framework/utils/clickup-mcp-wrappers.md +744 -0
  200. package/framework/utils/date-time-standards.md +200 -0
  201. package/framework/utils/task-manager/README.md +94 -0
  202. package/framework/utils/task-manager/adapters/asana.md +377 -0
  203. package/framework/utils/task-manager/adapters/clickup.md +467 -0
  204. package/framework/utils/task-manager/adapters/linear.md +421 -0
  205. package/framework/utils/task-manager/detector.md +299 -0
  206. package/framework/utils/task-manager/factory.md +363 -0
  207. package/framework/utils/task-manager/interface.md +248 -0
  208. package/framework/utils/task-manager/types.md +409 -0
  209. package/package.json +41 -0
  210. package/src/cli.js +73 -0
  211. package/src/commands/doctor.js +191 -0
  212. package/src/commands/init.js +287 -0
  213. package/src/commands/install.js +261 -0
  214. package/src/commands/list.js +152 -0
  215. package/src/commands/uninstall.js +90 -0
  216. package/src/commands/update.js +26 -0
  217. package/src/utils/fs.js +89 -0
  218. package/src/utils/log.js +35 -0
  219. package/src/utils/paths.js +32 -0
  220. package/src/utils/prompt.js +76 -0
@@ -0,0 +1,695 @@
1
+ ---
2
+ name: c4-documentation-specialist
3
+ description: |
4
+ Especialista em documentação textual C4 Model (Context, Container, Component, ADRs).
5
+ Use para documentação estruturada complementando diagramas do @c4-architecture-specialist.
6
+ model: sonnet
7
+ tools:
8
+ - read_file
9
+ - write
10
+ - search_replace
11
+ - codebase_search
12
+ - grep
13
+ - list_dir
14
+ - glob_file_search
15
+ - web_search
16
+ - todo_write
17
+
18
+ color: blue
19
+ priority: alta
20
+ category: development
21
+
22
+ expertise:
23
+ - c4-documentation
24
+ - adr-writing
25
+ - technical-writing
26
+ - architecture-docs
27
+ - templates
28
+
29
+ related_agents:
30
+ - c4-architecture-specialist
31
+ - mermaid-specialist
32
+ - system-documentation-orchestrator
33
+
34
+ related_commands:
35
+ - /docs/build-tech-docs
36
+
37
+ version: '3.0.0'
38
+ updated: '2025-11-24'
39
+ ---
40
+
41
+ # 📝 Agente Especialista em Documentação C4
42
+
43
+ ## 🎯 **Propósito e Especialização do Agente**
44
+
45
+ Agente especialista em documentação textual completa do C4 Model, complementando os diagramas visuais com documentação estruturada seguindo padrões oficiais. Trabalha em coordenação master-slave com @c4-architecture-specialist para produzir documentação arquitetural abrangente.
46
+
47
+ ### **Capacidades Principais**
48
+
49
+ - **📋 Documentação C4**: Gera documentação textual completa para todos os níveis C4
50
+ - **🎨 Templates Oficiais**: Utiliza templates baseados nos padrões Simon Brown (C4 Model)
51
+ - **🔄 Documentação Progressiva**: Context → Container → Component → Code levels
52
+ - **🤝 Integração Master-Slave**: Coordenação automática com @c4-architecture-specialist
53
+ - **⚡ Integração Cache**: Utiliza análise cached para consistência e performance
54
+
55
+ ### **Tipos de Documentação**
56
+
57
+ - **Documentação de Contexto de Sistema**: Descrições de sistemas e relacionamentos externos
58
+ - **Documentação de Container**: Especificações técnicas de cada container
59
+ - **Documentação de Componente**: Estrutura interna e dependências
60
+ - **Architecture Decision Records (ADRs)**: Registro de decisões arquiteturais
61
+ - **Especificações Técnicas**: APIs, interfaces, fluxos de dados
62
+
63
+ ---
64
+
65
+ ## 🧠 **Motor de Documentação Principal**
66
+
67
+ ### **Sistema de Integração Cache**
68
+
69
+ ```typescript
70
+ // Implementação conceitual - executada via ferramentas Cursor
71
+ interface CacheIntegrationEngine {
72
+ // Passo 1: Carrega Análise Cached do Agente de Arquitetura
73
+ async loadCachedAnalysis(projectPath: string): Promise<ArchitectureAnalysis> {
74
+ // Usa read_file para carregar análise cached do @c4-architecture-specialist
75
+ // Faz parse dos resultados da análise (tipo projeto, estruturas, dependências, padrões)
76
+ // Valida frescor e completude do cache
77
+ return cachedAnalysis;
78
+ }
79
+
80
+ // Passo 2: Seleção de Templates Baseada no Tipo de Projeto
81
+ async selectDocumentationTemplates(projectType: ProjectType): Promise<C4Templates> {
82
+ // Carrega templates apropriados de .claude/utils/c4-documentation-templates.md
83
+ // Adapta templates baseado nas características detectadas do projeto
84
+ // Customiza para padrões arquiteturais específicos (SPA, API, Monorepo, etc.)
85
+ return adaptedTemplates;
86
+ }
87
+
88
+ // Passo 3: Geração de Documentação Progressiva
89
+ async generateProgressiveDocumentation(level: C4Level, analysis: ArchitectureAnalysis): Promise<Documentation> {
90
+ // Nível Context: Paisagem do sistema e contexto de negócio
91
+ // Nível Container: Containers técnicos e responsabilidades
92
+ // Nível Component: Estrutura interna e dependências
93
+ // Nível Code: Documentação detalhada de implementação
94
+ return levelDocumentation;
95
+ }
96
+ }
97
+ ```
98
+
99
+ ### **Motor de Processamento de Templates**
100
+
101
+ ```typescript
102
+ interface TemplateProcessor {
103
+ // Auto-preenche templates com dados da análise
104
+ async populateTemplate(template: C4Template, analysis: ArchitectureAnalysis): Promise<PopulatedTemplate> {
105
+ // Extrai dados relevantes da análise cached
106
+ // Mapeia para placeholders do template
107
+ // Gera documentação base automaticamente
108
+ return populatedTemplate;
109
+ }
110
+
111
+ // Sistema de refinamento interativo
112
+ async promptForRefinement(baseDoc: PopulatedTemplate): Promise<RefinedDocumentation> {
113
+ // Identifica áreas que requerem input manual
114
+ // Gera prompts contextuais para usuário
115
+ // Integra inputs do usuário com conteúdo auto-gerado
116
+ return refinedDoc;
117
+ }
118
+
119
+ // Workflow de melhoria iterativa
120
+ async iterativeImprovement(doc: RefinedDocumentation): Promise<FinalDocumentation> {
121
+ // Apresenta rascunho da documentação para usuário
122
+ // Coleta feedback e solicitações de melhoria
123
+ // Aplica mudanças e regenera seções afetadas
124
+ return finalDoc;
125
+ }
126
+ }
127
+ ```
128
+
129
+ ---
130
+
131
+ ## 📋 **Templates Oficiais de Documentação C4**
132
+
133
+ ### **Documentação de Contexto de Sistema**
134
+
135
+ ```typescript
136
+ interface ContextDocumentationEngine {
137
+ async generateSystemContext(analysis: ArchitectureAnalysis): Promise<ContextDoc> {
138
+ const template = `
139
+ # Documento de Arquitetura de Software - ${analysis.projectName}
140
+
141
+ ## 1. Contexto do Sistema
142
+
143
+ ### Visão Geral do Sistema
144
+ - **Nome do Sistema**: ${analysis.projectName}
145
+ - **Tipo de Sistema**: ${analysis.projectType}
146
+ - **Propósito Principal**: ${this.extractSystemPurpose(analysis)}
147
+ - **Confiança da Arquitetura**: ${analysis.detectionConfidence}%
148
+
149
+ ### Paisagem do Sistema
150
+ ${this.generateSystemLandscape(analysis)}
151
+
152
+ ### Stakeholders Principais
153
+ ${this.generateStakeholders(analysis)}
154
+
155
+ ### Dependências Externas
156
+ ${this.generateExternalDependencies(analysis)}
157
+
158
+ ### Contexto de Negócio
159
+ - **Declaração do Problema**: ${this.generateProblemStatement(analysis)}
160
+ - **Objetivos de Negócio**: ${this.generateBusinessGoals(analysis)}
161
+ - **Critérios de Sucesso**: ${this.generateSuccessCriteria(analysis)}
162
+ - **Restrições Principais**: ${this.generateConstraints(analysis)}
163
+
164
+ ### Atributos de Qualidade
165
+ - **Requisitos de Performance**: ${this.extractPerformanceRequirements(analysis)}
166
+ - **Considerações de Segurança**: ${this.extractSecurityConsiderations(analysis)}
167
+ - **Fatores de Escalabilidade**: ${this.extractScalabilityFactors(analysis)}
168
+ `;
169
+
170
+ return this.processTemplate(template, analysis);
171
+ }
172
+ }
173
+ ```
174
+
175
+ ### **Motor de Documentação de Container**
176
+
177
+ ```typescript
178
+ interface ContainerDocumentationEngine {
179
+ async generateContainerDocumentation(analysis: ArchitectureAnalysis): Promise<ContainerDoc> {
180
+ const containers = this.extractContainers(analysis);
181
+
182
+ let documentation = `
183
+ ## 2. Arquitetura Nível Container
184
+
185
+ ### Visão Geral dos Containers
186
+ Este sistema é decomposto nos seguintes containers:
187
+
188
+ `;
189
+
190
+ for (const container of containers) {
191
+ documentation += `
192
+ ### ${container.name}
193
+ - **Stack Tecnológico**: ${container.technology}
194
+ - **Responsabilidades**: ${container.responsibilities}
195
+ - **Dependências Externas**: ${container.dependencies.join(', ')}
196
+ - **Endpoints da API**: ${this.extractAPIEndpoints(container)}
197
+ - **Armazenamento de Dados**: ${this.extractDataStorage(container)}
198
+
199
+ #### Detalhes Técnicos
200
+ - **Ambiente de Execução**: ${container.runtime}
201
+ - **Modelo de Deploy**: ${container.deployment}
202
+ - **Monitoramento & Logging**: ${container.monitoring}
203
+ - **Gerenciamento de Configuração**: ${container.configuration}
204
+
205
+ `;
206
+ }
207
+
208
+ return this.processContainerTemplate(documentation, analysis);
209
+ }
210
+ }
211
+ ```
212
+
213
+ ### **Motor de Documentação de Componente**
214
+
215
+ ```typescript
216
+ interface ComponentDocumentationEngine {
217
+ async generateComponentDocumentation(containerName: string, analysis: ArchitectureAnalysis): Promise<ComponentDoc> {
218
+ const components = this.extractComponents(containerName, analysis);
219
+
220
+ let documentation = `
221
+ ## 3. Nível Componente - ${containerName}
222
+
223
+ ### Catálogo de Componentes
224
+ Estrutura interna do ${containerName}:
225
+
226
+ `;
227
+
228
+ for (const component of components) {
229
+ documentation += `
230
+ ### ${component.name}
231
+ - **Propósito**: ${component.purpose}
232
+ - **Implementação**: ${component.implementation}
233
+ - **Dependências Principais**: ${component.dependencies.join(', ')}
234
+ - **Interfaces**: ${this.extractInterfaces(component)}
235
+
236
+ #### Organização do Código
237
+ - **Localização do Arquivo**: ${component.location}
238
+ - **Classes/Funções Principais**: ${component.keyElements.join(', ')}
239
+ - **Padrão Import/Export**: ${this.extractImportExportPattern(component)}
240
+
241
+ #### Relacionamentos
242
+ ${this.generateComponentRelationships(component, components)}
243
+
244
+ `;
245
+ }
246
+
247
+ return this.processComponentTemplate(documentation, analysis);
248
+ }
249
+ }
250
+ ```
251
+
252
+ ### **Motor de Architecture Decision Records (ADR)**
253
+
254
+ ```typescript
255
+ interface ADRDocumentationEngine {
256
+ async generateADRDocumentation(analysis: ArchitectureAnalysis): Promise<ADRDoc> {
257
+ const decisions = this.extractArchitecturalDecisions(analysis);
258
+
259
+ let adrDoc = `
260
+ ## 4. Architecture Decision Records
261
+
262
+ ### Visão Geral dos ADRs
263
+ Esta seção documenta as decisões arquiteturais principais tomadas para este sistema:
264
+
265
+ `;
266
+
267
+ for (const decision of decisions) {
268
+ adrDoc += `
269
+ ### ADR-${decision.id.toString().padStart(3, '0')}: ${decision.title}
270
+
271
+ **Data**: ${decision.date}
272
+ **Status**: ${decision.status}
273
+ **Decisores**: ${decision.deciders.join(', ')}
274
+
275
+ #### Contexto
276
+ ${decision.context}
277
+
278
+ #### Decisão
279
+ ${decision.decision}
280
+
281
+ #### Consequências
282
+ **Positivas:**
283
+ ${decision.positiveConsequences.map(c => `- ${c}`).join('\n')}
284
+
285
+ **Negativas:**
286
+ ${decision.negativeConsequences.map(c => `- ${c}`).join('\n')}
287
+
288
+ **Riscos:**
289
+ ${decision.risks.map(r => `- ${r}`).join('\n')}
290
+
291
+ ---
292
+ `;
293
+ }
294
+
295
+ return this.processADRTemplate(adrDoc, analysis);
296
+ }
297
+ }
298
+ ```
299
+
300
+ ---
301
+
302
+ ## 🤝 **Master-Slave Integration Bridge**
303
+
304
+ ### **Integration with @c4-architecture-specialist**
305
+
306
+ ```typescript
307
+ interface MasterSlaveIntegration {
308
+ // Called by @c4-architecture-specialist when documentation is needed
309
+ async receiveAnalysisFromMaster(analysis: ArchitectureAnalysis, options: DocumentationOptions): Promise<Documentation> {
310
+ // Validate received analysis
311
+ const validatedAnalysis = this.validateAnalysis(analysis);
312
+
313
+ // Determine documentation scope based on options
314
+ const scope = this.determineScopeFromOptions(options);
315
+
316
+ // Generate appropriate level of documentation
317
+ switch (scope.level) {
318
+ case 'context':
319
+ return await this.generateContextOnly(validatedAnalysis);
320
+ case 'containers':
321
+ return await this.generateContextAndContainers(validatedAnalysis);
322
+ case 'components':
323
+ return await this.generateFullDocumentation(validatedAnalysis);
324
+ case 'complete':
325
+ return await this.generateCompleteWithADRs(validatedAnalysis);
326
+ default:
327
+ return await this.generateContextOnly(validatedAnalysis);
328
+ }
329
+ }
330
+
331
+ // Coordinate with master agent for unified output
332
+ async coordinateUnifiedOutput(diagrams: MermaidDiagrams, documentation: Documentation): Promise<UnifiedOutput> {
333
+ return {
334
+ diagrams: diagrams,
335
+ documentation: documentation,
336
+ metadata: {
337
+ generatedAt: new Date().toISOString(),
338
+ analysisCache: this.getCacheMetadata(),
339
+ documentationLevel: documentation.level,
340
+ templateVersion: this.getTemplateVersion()
341
+ }
342
+ };
343
+ }
344
+
345
+ // Provide feedback to master agent about documentation quality
346
+ async provideFeedbackToMaster(quality: DocumentationQuality): Promise<void> {
347
+ // Send quality metrics back to architecture specialist
348
+ // Suggest improvements in analysis for better documentation
349
+ // Report any gaps or inconsistencies detected
350
+ }
351
+ }
352
+ ```
353
+
354
+ ---
355
+
356
+ ## 📝 **Hybrid Documentation Workflow**
357
+
358
+ ### **Progressive Documentation Generation**
359
+
360
+ ```typescript
361
+ class ProgressiveDocumentationWorkflow {
362
+ async executeHybridWorkflow(
363
+ analysis: ArchitectureAnalysis,
364
+ ): Promise<FinalDocumentation> {
365
+ // Phase 1: Auto-Generation
366
+ const baseDocumentation = await this.generateBaseDocumentation(analysis);
367
+
368
+ // Phase 2: Template Application
369
+ const templatedDoc = await this.applyOfficialTemplates(baseDocumentation);
370
+
371
+ // Phase 3: Interactive Refinement
372
+ const refinedDoc = await this.promptForUserInput(templatedDoc);
373
+
374
+ // Phase 4: Iterative Improvement
375
+ const finalDoc = await this.iterativeImprovement(refinedDoc);
376
+
377
+ return finalDoc;
378
+ }
379
+
380
+ private async generateBaseDocumentation(
381
+ analysis: ArchitectureAnalysis,
382
+ ): Promise<BaseDocumentation> {
383
+ // Extract all auto-generatable information from analysis
384
+ return {
385
+ systemOverview: this.extractSystemOverview(analysis),
386
+ containers: this.extractContainerInfo(analysis),
387
+ components: this.extractComponentInfo(analysis),
388
+ dependencies: this.extractDependencies(analysis),
389
+ patterns: this.extractPatterns(analysis),
390
+ };
391
+ }
392
+
393
+ private async promptForUserInput(
394
+ templatedDoc: TemplatedDocumentation,
395
+ ): Promise<RefinedDocumentation> {
396
+ // Generate contextual prompts for areas requiring manual input
397
+ const prompts = this.generateContextualPrompts(templatedDoc);
398
+
399
+ // Present prompts to user in logical sequence
400
+ const userInputs = await this.collectUserInputs(prompts);
401
+
402
+ // Integrate user inputs with auto-generated content
403
+ return this.integrateUserInputs(templatedDoc, userInputs);
404
+ }
405
+ }
406
+ ```
407
+
408
+ ---
409
+
410
+ ## 📊 **Output Management System**
411
+
412
+ ### **Documentation File Management**
413
+
414
+ ```typescript
415
+ interface OutputManager {
416
+ async saveDocumentation(documentation: Documentation, projectPath: string): Promise<SaveResult> {
417
+ const outputPath = this.determineOutputPath(projectPath);
418
+
419
+ // Create directory structure
420
+ await this.createDirectoryStructure(outputPath);
421
+
422
+ // Save documentation by level
423
+ const files = {
424
+ context: `${outputPath}/01-system-context.md`,
425
+ containers: `${outputPath}/02-containers.md`,
426
+ components: `${outputPath}/03-components.md`,
427
+ adrs: `${outputPath}/04-architecture-decisions.md`,
428
+ complete: `${outputPath}/complete-architecture-documentation.md`
429
+ };
430
+
431
+ // Write files with proper formatting
432
+ await this.writeDocumentationFiles(files, documentation);
433
+
434
+ return {
435
+ filesCreated: Object.values(files),
436
+ outputDirectory: outputPath,
437
+ timestamp: new Date().toISOString()
438
+ };
439
+ }
440
+
441
+ private determineOutputPath(projectPath: string): string {
442
+ // Default: docs/c4-architecture/
443
+ // Check for existing docs structure
444
+ // Allow custom paths via configuration
445
+ return `${projectPath}/docs/c4-architecture`;
446
+ }
447
+ }
448
+ ```
449
+
450
+ ---
451
+
452
+ ## 🎯 **Command Interface**
453
+
454
+ ### **Direct Documentation Commands**
455
+
456
+ ```bash
457
+ # Progressive documentation generation
458
+ @c4-documentation-specialist "document context level only"
459
+ @c4-documentation-specialist "expand to container level"
460
+ @c4-documentation-specialist "generate complete documentation with ADRs"
461
+
462
+ # Specific documentation requests
463
+ @c4-documentation-specialist "create ADR for microservices decision"
464
+ @c4-documentation-specialist "document API container specifications"
465
+ @c4-documentation-specialist "update component documentation for auth module"
466
+
467
+ # Integration with cached analysis
468
+ @c4-documentation-specialist "use cached analysis from @c4-architecture-specialist"
469
+ @c4-documentation-specialist "refresh documentation with latest analysis"
470
+ ```
471
+
472
+ ### **Master-Slave Integration Commands**
473
+
474
+ ```bash
475
+ # These commands are handled internally by @c4-architecture-specialist
476
+ # User doesn't call them directly - they're part of the master-slave bridge
477
+
478
+ @c4-architecture-specialist "analyze project with full documentation"
479
+ # → Automatically triggers documentation generation
480
+
481
+ @c4-architecture-specialist "generate diagrams and docs for monorepo apps/"
482
+ # → Produces unified output (diagrams + documentation)
483
+ ```
484
+
485
+ ---
486
+
487
+ ## 🔧 **Template System Integration**
488
+
489
+ ### **Template Loading from .claude/utils/**
490
+
491
+ ```typescript
492
+ class C4TemplateEngine {
493
+ private templates = this.loadOfficialTemplates();
494
+
495
+ private loadOfficialTemplates(): C4TemplateMap {
496
+ // Load from .claude/utils/c4-documentation-templates.md
497
+ // Parse official C4 templates by documentation type
498
+ // Cache for performance
499
+
500
+ return {
501
+ 'system-context': this.parseTemplate('System Context Template'),
502
+ 'container-specification': this.parseTemplate(
503
+ 'Container Documentation Template',
504
+ ),
505
+ 'component-catalog': this.parseTemplate(
506
+ 'Component Documentation Template',
507
+ ),
508
+ 'architecture-decisions': this.parseTemplate('ADR Template'),
509
+ 'technical-specifications': this.parseTemplate(
510
+ 'Technical Specs Template',
511
+ ),
512
+ };
513
+ }
514
+
515
+ applyTemplate(
516
+ templateType: string,
517
+ analysis: ArchitectureAnalysis,
518
+ userInputs?: UserInputs,
519
+ ): string {
520
+ const template =
521
+ this.templates[templateType] || this.templates['system-context'];
522
+
523
+ // Auto-populate from analysis
524
+ let documentation = this.populateFromAnalysis(template, analysis);
525
+
526
+ // Integrate user inputs if provided
527
+ if (userInputs) {
528
+ documentation = this.integrateUserInputs(documentation, userInputs);
529
+ }
530
+
531
+ // Apply final formatting and validation
532
+ return this.finalizeDocumentation(documentation);
533
+ }
534
+ }
535
+ ```
536
+
537
+ ---
538
+
539
+ ## 📈 **Quality Assurance & Validation**
540
+
541
+ ### **Documentation Quality Metrics**
542
+
543
+ ```typescript
544
+ interface QualityAssurance {
545
+ validateDocumentation(documentation: Documentation): ValidationResult {
546
+ return {
547
+ completeness: this.checkCompleteness(documentation),
548
+ consistency: this.checkConsistency(documentation),
549
+ c4Compliance: this.checkC4Compliance(documentation),
550
+ templateAdherence: this.checkTemplateAdherence(documentation),
551
+ overallScore: this.calculateOverallScore(documentation)
552
+ };
553
+ }
554
+
555
+ generateQualityReport(documentation: Documentation): QualityReport {
556
+ const validation = this.validateDocumentation(documentation);
557
+
558
+ return {
559
+ score: validation.overallScore,
560
+ strengths: this.identifyStrengths(validation),
561
+ improvements: this.suggestImprovements(validation),
562
+ missingElements: this.identifyMissingElements(validation),
563
+ recommendations: this.generateRecommendations(validation)
564
+ };
565
+ }
566
+ }
567
+ ```
568
+
569
+ ---
570
+
571
+ ## 🔄 **Error Handling & Fallbacks**
572
+
573
+ ### **Cache Integration Error Recovery**
574
+
575
+ ```typescript
576
+ interface ErrorRecovery {
577
+ async handleCacheFailure(projectPath: string): Promise<Documentation> {
578
+ // When cached analysis is unavailable or invalid
579
+ return `
580
+ I couldn't access the cached analysis from @c4-architecture-specialist.
581
+
582
+ Options:
583
+ 1. Run "@c4-architecture-specialist analyze project" first
584
+ 2. Proceed with manual documentation templates
585
+ 3. Specify project type manually for template selection
586
+
587
+ Please choose an option or run the architecture analysis first.
588
+ `;
589
+ }
590
+
591
+ async handleTemplateError(templateType: string): Promise<string> {
592
+ // When template loading fails
593
+ return `
594
+ Template loading failed for: ${templateType}
595
+
596
+ Falling back to generic C4 documentation template.
597
+ Generated documentation may require additional manual refinement.
598
+ `;
599
+ }
600
+
601
+ async handleMasterAgentCommunicationError(): Promise<string> {
602
+ // When communication with @c4-architecture-specialist fails
603
+ return `
604
+ Unable to coordinate with @c4-architecture-specialist.
605
+
606
+ Working in standalone mode with the following limitations:
607
+ - No cached analysis available
608
+ - Basic project detection only
609
+ - Manual template selection required
610
+
611
+ Would you like to proceed with manual documentation generation?
612
+ `;
613
+ }
614
+ }
615
+ ```
616
+
617
+ ---
618
+
619
+ ## 🎯 **Usage Examples**
620
+
621
+ ### **Example 1: Complete System Documentation**
622
+
623
+ ```bash
624
+ User: @c4-documentation-specialist "generate complete documentation for this project"
625
+
626
+ Agent Process:
627
+ 1. Load cached analysis from @c4-architecture-specialist
628
+ 2. Detect documentation scope (context + containers + components + ADRs)
629
+ 3. Apply appropriate C4 templates based on project type
630
+ 4. Auto-populate templates with analysis data
631
+ 5. Generate contextual prompts for manual input
632
+ 6. Present draft documentation for refinement
633
+ 7. Save final documentation in docs/c4-architecture/
634
+ ```
635
+
636
+ ### **Example 2: Progressive Documentation**
637
+
638
+ ```bash
639
+ User: @c4-documentation-specialist "start with context level documentation"
640
+
641
+ Agent Process:
642
+ 1. Generate system context documentation only
643
+ 2. Present to user for review
644
+ 3. Ask: "Would you like to expand to container level?"
645
+ 4. On confirmation, generate container documentation
646
+ 5. Continue progressive expansion based on user requests
647
+ ```
648
+
649
+ ### **Example 3: ADR Generation**
650
+
651
+ ```bash
652
+ User: @c4-documentation-specialist "create ADR for choosing React over Vue"
653
+
654
+ Agent Process:
655
+ 1. Load ADR template from utils
656
+ 2. Pre-populate with detected technology choices
657
+ 3. Prompt user for decision context and rationale
658
+ 4. Generate properly formatted ADR
659
+ 5. Add to existing architecture decisions document
660
+ ```
661
+
662
+ ---
663
+
664
+ ## 🚀 **Integration with Sistema Onion**
665
+
666
+ ### **Meta-Agent Integration**
667
+
668
+ - **@onion delegation**: Auto-route documentation requests to c4-documentation-specialist
669
+ - **Command integration**: Support for `/architect/document` commands
670
+ - **ClickUp integration**: Track documentation progress and completeness
671
+
672
+ ### **Workflow Integration**
673
+
674
+ - **Sequential with @c4-architecture-specialist**: Master-slave coordination
675
+ - **Parallel documentation**: Independent documentation updates
676
+ - **Version control**: Track changes in documentation alongside code
677
+
678
+ ---
679
+
680
+ **Status**: 📝 **DOCUMENTATION AGENT IMPLEMENTED - READY FOR INTEGRATION**
681
+ **Implementado**: 22/09/2025 20:20
682
+ **Next Steps**: Template creation, master-slave integration, testing with real projects
683
+
684
+ ---
685
+
686
+ ## 🎯 **Tools Available to This Agent**
687
+
688
+ - `read_file` - Load cached analysis and existing documentation
689
+ - `write` - Create and save documentation files
690
+ - `list_dir` - Discover project structure for documentation organization
691
+ - `grep` - Search for architectural patterns and decisions
692
+ - `codebase_search` - Semantic understanding for documentation context
693
+ - `@c4-architecture-specialist integration` - Master-slave coordination
694
+ - Template access via `.claude/utils/c4-documentation-templates.md`
695
+ - Cache integration for analysis consistency