jarvis-ai-framework 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/AGENTS.md +416 -0
  2. package/LICENSE +21 -0
  3. package/README.md +190 -0
  4. package/agents/AGENTS.md +234 -0
  5. package/agents/README.md +309 -0
  6. package/agents/engineering/data/eng.data-engineer.agent.md +309 -0
  7. package/agents/engineering/eng.agent.md +303 -0
  8. package/agents/engineering/eng.bug-hunter.md +386 -0
  9. package/agents/engineering/eng.cybersecurity.agent.md +503 -0
  10. package/agents/engineering/eng.dev-code-reviewer.md +148 -0
  11. package/agents/engineering/eng.docs-writer.md +152 -0
  12. package/agents/engineering/eng.frontend.agent.md +117 -0
  13. package/agents/engineering/eng.rpa.agent.md +215 -0
  14. package/agents/engineering/eng.tech-analyst.agent.md +102 -0
  15. package/agents/engineering/eng.ux-designer.agent.md +193 -0
  16. package/agents/engineering/qa/eng.qa.cypress-specialist.md +109 -0
  17. package/agents/engineering/qa/eng.qa.quality-champion-task-agent.md +85 -0
  18. package/agents/engineering/qa/eng.qa.quality-strategist.md +111 -0
  19. package/agents/engineering/qa/eng.qa.test-architect.md +400 -0
  20. package/agents/engineering/qa/eng.qa.test-planner.md +477 -0
  21. package/agents/engineering/qa/eng.qa.testing-engineer.md +339 -0
  22. package/agents/product/prod.pm-checker.md +52 -0
  23. package/bin/commands/docs-publish.js +184 -0
  24. package/bin/commands/docs-sync.js +139 -0
  25. package/bin/commands/info.js +87 -0
  26. package/bin/commands/init.js +237 -0
  27. package/bin/commands/install-rtk.js +90 -0
  28. package/bin/commands/list.js +48 -0
  29. package/bin/commands/qa-signoff.js +112 -0
  30. package/bin/commands/whoami.js +43 -0
  31. package/bin/jarvis.js +159 -0
  32. package/bin/lib/auth/session.js +56 -0
  33. package/bin/lib/config/constants.js +123 -0
  34. package/bin/lib/config/ide-config.js +233 -0
  35. package/bin/lib/core/scanner.js +124 -0
  36. package/bin/lib/core/sync-engine.js +551 -0
  37. package/bin/lib/docs/fetch-file.sh +41 -0
  38. package/bin/lib/docs/publish-file.sh +284 -0
  39. package/bin/lib/docs/validate-frontmatter.js +157 -0
  40. package/bin/lib/env-loader.js +198 -0
  41. package/bin/lib/tasks/comment.js +131 -0
  42. package/bin/lib/utils/git-parser.js +145 -0
  43. package/bin/lib/utils/logger.js +104 -0
  44. package/bin/lib/utils/npmrc-parser.js +106 -0
  45. package/bin/lib/utils/paths.js +55 -0
  46. package/bin/lib/utils/ui.js +59 -0
  47. package/bin/lib/vcs/api.js +312 -0
  48. package/bin/lib/vcs/create-issue.js +43 -0
  49. package/bin/lib/vcs/create-merge.js +43 -0
  50. package/bin/lib/vcs/fetch-raw.js +30 -0
  51. package/bin/postinstall.js +41 -0
  52. package/members.md +25 -0
  53. package/package.json +55 -0
  54. package/rules/AGENTS.md +205 -0
  55. package/rules/engineering/data/data-rules.md +200 -0
  56. package/rules/engineering/eng-rules.md +243 -0
  57. package/rules/engineering/eng-security-rules.md +186 -0
  58. package/rules/engineering/eng.breakdown-subtasks-rules.md +585 -0
  59. package/rules/engineering/eng.bump-rules.md +27 -0
  60. package/rules/engineering/eng.docs-scraping-rules.md +64 -0
  61. package/rules/engineering/eng.downstream-flow-rules.md +297 -0
  62. package/rules/engineering/eng.integrations-rules.md +73 -0
  63. package/rules/engineering/eng.plan-rules.md +333 -0
  64. package/rules/engineering/eng.pr-rules.md +359 -0
  65. package/rules/engineering/eng.pre-pr-rules.md +103 -0
  66. package/rules/engineering/eng.start-rules.md +246 -0
  67. package/rules/engineering/eng.tech-spec-rules.md +968 -0
  68. package/rules/engineering/eng.work-rules.md +312 -0
  69. package/rules/engineering/frontend/eng.frontend-rules.md +147 -0
  70. package/rules/engineering/qa/eng.qa.cypress-standards-rules.md +259 -0
  71. package/rules/engineering/qa/eng.qa.exploratory-session-rules.md +137 -0
  72. package/rules/engineering/qa/eng.qa.quality-gate-scoring-rules.md +181 -0
  73. package/rules/engineering/qa/eng.qa.tech-spec-validation-criteria-rules.md +120 -0
  74. package/rules/engineering/rpa/eng.rpa-rules.md +230 -0
  75. package/rules/product/README.md +24 -0
  76. package/rules/product/prod-rules.md +151 -0
  77. package/rules/rtk-rules.md +68 -0
  78. package/skills/AGENTS.md +290 -0
  79. package/skills/SKILLS-ROADMAP.md +333 -0
  80. package/skills/churn-audit/SKILL.md +385 -0
  81. package/skills/context-detect/SKILL.md +399 -0
  82. package/skills/context-detect/assets/context-profile-template.md +127 -0
  83. package/skills/docs-central/README.md +310 -0
  84. package/skills/docs-central/SKILL.md +423 -0
  85. package/skills/docs-index/SKILL.md +377 -0
  86. package/skills/eng-ai-engineer/SKILL.md +296 -0
  87. package/skills/eng-arch-c4/SKILL.md +358 -0
  88. package/skills/eng-arch-c4/assets/example-code.md +189 -0
  89. package/skills/eng-arch-c4/assets/example-component.md +105 -0
  90. package/skills/eng-arch-c4/assets/example-container.md +104 -0
  91. package/skills/eng-arch-c4/assets/example-context.md +81 -0
  92. package/skills/eng-backend/SKILL.md +776 -0
  93. package/skills/eng-browser-extension-builder/SKILL.md +385 -0
  94. package/skills/eng-cybersecurity/SKILL.md +645 -0
  95. package/skills/eng-data-bi/SKILL.md +199 -0
  96. package/skills/eng-data-debug/SKILL.md +307 -0
  97. package/skills/eng-data-engineer/SKILL.md +256 -0
  98. package/skills/eng-data-onboard/SKILL.md +310 -0
  99. package/skills/eng-data-orchestrator/SKILL.md +426 -0
  100. package/skills/eng-design-system/SKILL.md +619 -0
  101. package/skills/eng-docs-write/SKILL.md +312 -0
  102. package/skills/eng-frontend/SKILL.md +913 -0
  103. package/skills/eng-jira-comment/SKILL.md +17 -0
  104. package/skills/eng-microfrontend/SKILL.md +602 -0
  105. package/skills/eng-ms-trace/SKILL.md +469 -0
  106. package/skills/eng-nestjs/SKILL.md +791 -0
  107. package/skills/eng-performance-engineer/SKILL.md +312 -0
  108. package/skills/eng-pr/SKILL.md +339 -0
  109. package/skills/eng-qa-a11y-audit/SKILL.md +269 -0
  110. package/skills/eng-qa-bug-report/SKILL.md +1088 -0
  111. package/skills/eng-qa-bug-report/TASK_MANAGERS.md +138 -0
  112. package/skills/eng-qa-cypress-e2e/SKILL.md +177 -0
  113. package/skills/eng-qa-dev-guide/SKILL.md +164 -0
  114. package/skills/eng-qa-e2e/SKILL.md +400 -0
  115. package/skills/eng-qa-e2e-spec-writer/SKILL.md +322 -0
  116. package/skills/eng-qa-exploratory/SKILL.md +188 -0
  117. package/skills/eng-qa-gate/SKILL.md +370 -0
  118. package/skills/eng-qa-gate/assets/checklist-validacao.md +291 -0
  119. package/skills/eng-qa-graphql-contract/SKILL.md +256 -0
  120. package/skills/eng-qa-quality-report/SKILL.md +412 -0
  121. package/skills/eng-qa-test-plan/SKILL.md +466 -0
  122. package/skills/eng-qa-test-plan/assets/test-coverage-template.md +92 -0
  123. package/skills/eng-qa-test-plan/assets/test-patterns.md +178 -0
  124. package/skills/eng-qa-testsprite/SKILL.md +325 -0
  125. package/skills/eng-qa-testsprite/references/testsprite-mcp.md +224 -0
  126. package/skills/eng-qa-unit-test/SKILL.md +471 -0
  127. package/skills/eng-rabbitmq/SKILL.md +661 -0
  128. package/skills/eng-scraper/SKILL.md +683 -0
  129. package/skills/eng-scraper-robot-builder/SKILL.md +370 -0
  130. package/skills/eng-security-patch/SKILL.md +378 -0
  131. package/skills/eng-security-triage/SKILL.md +266 -0
  132. package/skills/eng-task-comment/SKILL.md +60 -0
  133. package/skills/eng-tech-analyst/SKILL.md +529 -0
  134. package/skills/eng-threat-model/SKILL.md +161 -0
  135. package/skills/init-jarvis/SKILL.md +1304 -0
  136. package/skills/init-jarvis/assets/mcp-configs.md +389 -0
  137. package/skills/init-jarvis/assets/onboarding-checklist.md +104 -0
  138. package/skills/init-jarvis/assets/setup-guide.md +360 -0
  139. package/skills/lovable-prompt-generator/SKILL.md +304 -0
  140. package/skills/prod-roadmap-report/README.md +303 -0
  141. package/skills/prod-roadmap-report/SKILL.md +198 -0
  142. package/skills/prod-roadmap-report/commands/status.compiled.single.team.md +23 -0
  143. package/skills/prod-roadmap-report/commands/status.list.projects.md +17 -0
  144. package/skills/prod-roadmap-report/commands/status.memory.md +192 -0
  145. package/skills/prod-roadmap-report/commands/status.roadmap.preview.md +94 -0
  146. package/skills/prod-roadmap-report/references/detailed-guide.md +236 -0
  147. package/skills/prod-roadmap-report/rules/detailed-guide.md +237 -0
  148. package/skills/prod-roadmap-report/rules/status-report-rules.md +44 -0
  149. package/skills/prod-roadmap-report/templates/template-multiple-teams-compiled-status.md +53 -0
  150. package/skills/prod-roadmap-report/templates/template-projects-list.md +23 -0
  151. package/skills/prod-roadmap-report/templates/template-single-team-compiled-status.md +60 -0
  152. package/skills/prod-roadmap-report/templates/template-single-team-status.md +49 -0
  153. package/skills/prod-specs/SKILL.md +108 -0
  154. package/skills/prod-specs/references/prod.spec.clarify.md +176 -0
  155. package/skills/prod-specs/references/prod.spec.epic.md +107 -0
  156. package/skills/prod-specs/references/prod.spec.frd.md +135 -0
  157. package/skills/prod-specs/references/prod.spec.issue.md +145 -0
  158. package/skills/prod-specs/references/prod.spec.prd.md +118 -0
  159. package/skills/prod-specs/rules/prod-spec-rules.md +186 -0
  160. package/skills/prod-specs/templates/prod-breakdown-template.md +136 -0
  161. package/skills/prod-specs/templates/prod-epic-template.md +76 -0
  162. package/skills/prod-specs/templates/prod-frd-template.md +172 -0
  163. package/skills/prod-specs/templates/prod-issue-template.md +68 -0
  164. package/skills/prod-specs/templates/prod-prd-full-template.md +159 -0
  165. package/skills/prod-specs/templates/prod-prd-template.md +173 -0
  166. package/skills/prod-specs-update/SKILL.md +272 -0
  167. package/skills/report-issue/SKILL.md +156 -0
  168. package/taxonomy.md +270 -0
  169. package/templates/AGENTS.md +189 -0
  170. package/templates/CDD aplicado a Prompts.md +182 -0
  171. package/templates/ENV-template.md +187 -0
  172. package/templates/engineering/AGENTS-template.md +71 -0
  173. package/templates/engineering/ARD-template.md +193 -0
  174. package/templates/engineering/CONTACTS-template.md +135 -0
  175. package/templates/engineering/PR-template.md +40 -0
  176. package/templates/engineering/RFC-Playbook.md +325 -0
  177. package/templates/engineering/RFC-template.md +199 -0
  178. package/templates/engineering/architecture-template.md +277 -0
  179. package/templates/engineering/breakdown-subtasks-template.md +582 -0
  180. package/templates/engineering/c4-model-template.md +516 -0
  181. package/templates/engineering/data-contract-template.md +135 -0
  182. package/templates/engineering/data-pipeline-template.md +163 -0
  183. package/templates/engineering/plan-template.md +255 -0
  184. package/templates/engineering/qa/eng.qa.quality-gate-examples-template.md +311 -0
  185. package/templates/engineering/qa/eng.qa.quality-gate-report-template.md +249 -0
  186. package/templates/engineering/qa/qa.cypress-test-template.md +172 -0
  187. package/templates/engineering/qa/qa.exploratory-session-template.md +148 -0
  188. package/templates/engineering/qa/qa.quality-report-template.md +130 -0
  189. package/templates/engineering/qa/qa.release-signoff-template.md +54 -0
  190. package/templates/engineering/qa/qa.sprint-plan-template.md +49 -0
  191. package/templates/engineering/swagger-template.md +145 -0
  192. package/templates/engineering/tech-spec-template.md +497 -0
  193. package/templates/engineering/work-progress-template.md +155 -0
  194. package/workflows/AGENTS.md +240 -0
  195. package/workflows/README.md +160 -0
  196. package/workflows/all-tools.md +11 -0
  197. package/workflows/engineering/data/data.contract.md +202 -0
  198. package/workflows/engineering/data/data.new-pipeline.md +234 -0
  199. package/workflows/engineering/eng.breakdown-subtasks.md +420 -0
  200. package/workflows/engineering/eng.bug-audit.md +591 -0
  201. package/workflows/engineering/eng.build-tech-spec.md +1116 -0
  202. package/workflows/engineering/eng.create-ard-from-code.md +259 -0
  203. package/workflows/engineering/eng.create-ard.md +382 -0
  204. package/workflows/engineering/eng.create-rfc.md +245 -0
  205. package/workflows/engineering/eng.debug.md +479 -0
  206. package/workflows/engineering/eng.docs.md +40 -0
  207. package/workflows/engineering/eng.light-arch.md +84 -0
  208. package/workflows/engineering/eng.plan.md +213 -0
  209. package/workflows/engineering/eng.pr.md +466 -0
  210. package/workflows/engineering/eng.pre-pr.md +167 -0
  211. package/workflows/engineering/eng.review.md +185 -0
  212. package/workflows/engineering/eng.rpa.robot.md +342 -0
  213. package/workflows/engineering/eng.security-audit.md +312 -0
  214. package/workflows/engineering/eng.security-incident.md +275 -0
  215. package/workflows/engineering/eng.security-pipeline.md +210 -0
  216. package/workflows/engineering/eng.security-review.md +235 -0
  217. package/workflows/engineering/eng.start.md +494 -0
  218. package/workflows/engineering/eng.work.md +558 -0
  219. package/workflows/engineering/frontend/eng.frontend-component.md +190 -0
  220. package/workflows/engineering/frontend/eng.frontend-perf-audit.md +375 -0
  221. package/workflows/engineering/frontend/eng.frontend-review.md +185 -0
  222. package/workflows/engineering/qa/eng.qa-dev-quality-guide.md +51 -0
  223. package/workflows/engineering/qa/eng.qa-e2e-test-generation.md +51 -0
  224. package/workflows/engineering/qa/eng.qa-exploratory-session.md +60 -0
  225. package/workflows/engineering/qa/eng.qa-quality-gate-validation.md +202 -0
  226. package/workflows/engineering/qa/eng.qa-quality-report.md +83 -0
  227. package/workflows/engineering/qa/eng.qa-refinement-entry.md +83 -0
  228. package/workflows/engineering/qa/eng.qa-release-signoff.md +170 -0
  229. package/workflows/engineering/qa/eng.qa-sprint-planning.md +100 -0
  230. package/workflows/engineering/ta/eng.ta.atendimento.md +93 -0
  231. package/workflows/product/prod.roadmap.preview.md +110 -0
  232. package/workflows/product/prod.spec.breakdown.md +163 -0
  233. package/workflows/product/prod.spec.clarify.md +178 -0
  234. package/workflows/product/prod.spec.epic.md +154 -0
  235. package/workflows/product/prod.spec.frd.md +96 -0
  236. package/workflows/product/prod.spec.issue.md +145 -0
  237. package/workflows/product/prod.spec.md +60 -0
  238. package/workflows/product/prod.spec.prd.md +100 -0
  239. package/workflows/taxonomy.md +92 -0
  240. package/workflows/warm-up.md +574 -0
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: eng-jira-comment
3
+ description: >
4
+ Alias de eng-task-comment. Adiciona comentário no card do TASK_MANAGER
5
+ (Jira, Linear, GitHub Issues ou Asana).
6
+ argument-hint: "{TASK_MANAGER_KEY} {mensagem}"
7
+ disable-model-invocation: false
8
+ allowed-tools: Read Bash MCP
9
+ ---
10
+
11
+ # eng-jira-comment (alias)
12
+
13
+ Este skill foi unificado em **`eng-task-comment`**.
14
+
15
+ Execute o playbook de `$IDE/skills/eng-task-comment/SKILL.md` com os mesmos argumentos `{TASK_MANAGER_KEY} {mensagem}`.
16
+
17
+ `{TASK_MANAGER_KEY}` — identificador do card no `TASK_MANAGER` do ENV.md.
@@ -0,0 +1,602 @@
1
+ ---
2
+ name: eng-microfrontend
3
+ description: >
4
+ Especialista em arquitetura micro frontend com Module Federation.
5
+ Cobre shell/remote apps, contratos de interface, shared dependencies, event bus,
6
+ monorepo frontend, desenvolvimento local standalone e estratégias de deploy independente.
7
+ Trigger: Use para criar novo remote, configurar Module Federation, integrar ao shell,
8
+ definir contrato de interface entre apps, resolver conflitos de shared libs ou planejar
9
+ migração para arquitetura micro frontend.
10
+ license: AGPL-3.0
11
+ compatibility: Designed for Claude Code (or similar products)
12
+ allowed-tools: Read Write Edit Glob Grep Bash
13
+ metadata:
14
+ author: jarvis-team
15
+ version: "1.0"
16
+ argument-hint: "[novo-remote|shell|contrato|shared-deps|monorepo|debug] [contexto]"
17
+ disable-model-invocation: false
18
+ ---
19
+
20
+ # Eng Micro Frontend — Especialista em Arquitetura Distribuída de Frontend
21
+
22
+ Você é um **especialista em micro frontend com Module Federation** — arquitetura onde múltiplas
23
+ aplicações frontend independentes colaboram para formar um produto coeso.
24
+
25
+ ## Objetivo
26
+
27
+ Projetar, implementar e manter micro frontends corretos, isolados e evoluíveis — com contratos
28
+ claros entre shell e remotes, shared dependencies controladas e deploys verdadeiramente independentes.
29
+
30
+ ## Conceitos Centrais
31
+
32
+ ```
33
+ Shell (Host) — orquestra a composição; monta os remotes nas rotas certas
34
+ Remote (MFE) — feature isolada; expõe componentes/rotas para o shell consumir
35
+ Design System — pacote compartilhado de componentes e tokens (não é um remote)
36
+ Event Bus — canal de comunicação desacoplado entre shell e remotes
37
+ Contrato de Interface — tipos TypeScript que definem o que o remote expõe e o que espera do shell
38
+ ```
39
+
40
+ ## Entrada
41
+
42
+ - `$ARGUMENTS` — o que será feito: `novo-remote`, `shell`, `contrato`, `shared-deps`, `monorepo`, `debug`
43
+
44
+ ## Recursos
45
+
46
+ - **ENV**: `$IDE/ENV.md`
47
+ - **Skill complementar**: `eng-frontend` (componentes), `eng-design-system` (tokens e componentes compartilhados)
48
+
49
+ ---
50
+
51
+ ## Pré-requisito
52
+
53
+ Verificar `ENV.md` antes de executar. Confirmar bundler em uso:
54
+
55
+ ```bash
56
+ # Vite com @originjs/vite-plugin-federation
57
+ grep -r "vite-plugin-federation\|@module-federation" package.json
58
+
59
+ # Webpack com ModuleFederationPlugin
60
+ grep -r "ModuleFederationPlugin\|webpack" package.json
61
+ ```
62
+
63
+ > **Nota de stack:** Os exemplos de código neste skill usam **Vite + @originjs/vite-plugin-federation**
64
+ > por ser a configuração mais comum em projetos novos. Se o projeto usa **Webpack**, os conceitos
65
+ > são idênticos — apenas a configuração do `ModuleFederationPlugin` muda.
66
+ > A seção "Criando um Remote" inclui referência para ambos os bundlers onde relevante.
67
+
68
+ ---
69
+
70
+ ## Árvore de Decisão
71
+
72
+ ```
73
+ O que será feito?
74
+ ├── Criar novo remote → Seção: Criando um Remote
75
+ ├── Configurar o shell → Seção: Configurando o Shell
76
+ ├── Definir contrato de interface → Seção: Contratos de Interface
77
+ ├── Gerenciar shared dependencies → Seção: Shared Dependencies
78
+ ├── Configurar monorepo → Seção: Monorepo Frontend
79
+ ├── Comunicação entre apps → Seção: Event Bus
80
+ ├── Deploy independente → Seção: Estratégia de Deploy
81
+ └── Debug de problema → Seção: Troubleshooting
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Criando um Remote
87
+
88
+ ### Estrutura de um remote
89
+
90
+ ```
91
+ apps/
92
+ └── {nome-remote}/
93
+ ├── src/
94
+ │ ├── bootstrap.ts ← entry point async (necessário para Module Federation)
95
+ │ ├── index.ts ← importa e executa bootstrap
96
+ │ ├── App.tsx ← root do remote (para modo standalone)
97
+ │ ├── routes/ ← rotas do remote
98
+ │ ├── components/ ← componentes locais do remote
99
+ │ └── exposed/ ← o que será exposto via Module Federation
100
+ │ ├── index.ts ← re-exporta tudo que é público
101
+ │ └── RemoteApp.tsx ← componente raiz exposto ao shell
102
+ ├── vite.config.ts ← ou webpack.config.ts
103
+ ├── package.json
104
+ └── tsconfig.json
105
+ ```
106
+
107
+ ### Por que `bootstrap.ts` é obrigatório?
108
+
109
+ ```typescript
110
+ // src/index.ts — entry point síncrono
111
+ import('./bootstrap') // import() dinâmico é necessário para Module Federation funcionar
112
+
113
+ // src/bootstrap.ts — inicialização real
114
+ import React from 'react'
115
+ import ReactDOM from 'react-dom/client'
116
+ import App from './App'
117
+
118
+ ReactDOM.createRoot(document.getElementById('root')!).render(
119
+ <React.StrictMode>
120
+ <App />
121
+ </React.StrictMode>
122
+ )
123
+ ```
124
+
125
+ > Sem o `bootstrap.ts`, o eager consumption de shared libs causa erro em runtime.
126
+
127
+ ### Configuração Vite (vite-plugin-federation)
128
+
129
+ ```typescript
130
+ // vite.config.ts do remote
131
+ import { defineConfig } from 'vite'
132
+ import react from '@vitejs/plugin-react'
133
+ import federation from '@originjs/vite-plugin-federation'
134
+
135
+ export default defineConfig({
136
+ plugins: [
137
+ react(),
138
+ federation({
139
+ name: '{nome-remote}', // identificador único do remote
140
+ filename: 'remoteEntry.js', // arquivo gerado
141
+ exposes: {
142
+ './App': './src/exposed/RemoteApp', // o que o shell pode importar
143
+ './routes': './src/exposed/routes', // rotas para shell carregar
144
+ },
145
+ shared: {
146
+ react: { singleton: true, requiredVersion: '^18.0.0' },
147
+ 'react-dom': { singleton: true, requiredVersion: '^18.0.0' },
148
+ 'react-router-dom': { singleton: true },
149
+ // design system — sempre singleton para evitar instâncias duplicadas
150
+ '@{org}/design-system': { singleton: true },
151
+ },
152
+ }),
153
+ ],
154
+ build: {
155
+ target: 'esnext',
156
+ minify: false, // facilita debug; ativar em prod via CI flag
157
+ cssCodeSplit: false, // evita problemas com CSS em remotes
158
+ },
159
+ })
160
+ ```
161
+
162
+ ### Modo standalone (obrigatório para dev local)
163
+
164
+ ```typescript
165
+ // src/App.tsx — funciona sem shell
166
+ import { BrowserRouter } from 'react-router-dom'
167
+ import { AppRoutes } from './routes'
168
+
169
+ export default function App() {
170
+ return (
171
+ <BrowserRouter>
172
+ <AppRoutes />
173
+ </BrowserRouter>
174
+ )
175
+ }
176
+ ```
177
+
178
+ ```json
179
+ // package.json do remote
180
+ {
181
+ "scripts": {
182
+ "dev": "vite --port 3001", // standalone
183
+ "dev:federated": "vite --port 3001 --mode federated", // com Module Federation ativo
184
+ "build": "vite build",
185
+ "preview": "vite preview --port 3001"
186
+ }
187
+ }
188
+ ```
189
+
190
+ ---
191
+
192
+ ## Configurando o Shell
193
+
194
+ ```typescript
195
+ // vite.config.ts do shell
196
+ import federation from '@originjs/vite-plugin-federation'
197
+
198
+ export default defineConfig({
199
+ plugins: [
200
+ react(),
201
+ federation({
202
+ name: 'shell',
203
+ remotes: {
204
+ '{nome-remote}': 'http://localhost:3001/assets/remoteEntry.js',
205
+ // Em produção, usar variável de ambiente:
206
+ // '{nome-remote}': process.env.VITE_REMOTE_URL_NOME_REMOTE,
207
+ },
208
+ shared: {
209
+ react: { singleton: true },
210
+ 'react-dom': { singleton: true },
211
+ 'react-router-dom': { singleton: true },
212
+ '@{org}/design-system': { singleton: true },
213
+ },
214
+ }),
215
+ ],
216
+ })
217
+ ```
218
+
219
+ ### Lazy loading de remotes no shell
220
+
221
+ ```typescript
222
+ // src/routes/index.tsx — shell monta remotes por rota
223
+ import { lazy, Suspense } from 'react'
224
+ import { Routes, Route } from 'react-router-dom'
225
+
226
+ // Tipagem do remote (importar do contrato de interface)
227
+ const RemoteApp = lazy(() =>
228
+ import('{nome-remote}/App').then((m) => ({ default: m.default }))
229
+ )
230
+
231
+ function ErrorFallback({ error }: { error: Error }) {
232
+ return (
233
+ <div role="alert">
234
+ <p>Falha ao carregar módulo. <button onClick={() => window.location.reload()}>Tentar novamente</button></p>
235
+ </div>
236
+ )
237
+ }
238
+
239
+ export function ShellRoutes() {
240
+ return (
241
+ <Routes>
242
+ <Route
243
+ path="/{caminho-remote}/*"
244
+ element={
245
+ <Suspense fallback={<div>Carregando...</div>}>
246
+ <ErrorBoundary FallbackComponent={ErrorFallback}>
247
+ <RemoteApp />
248
+ </ErrorBoundary>
249
+ </Suspense>
250
+ }
251
+ />
252
+ </Routes>
253
+ )
254
+ }
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Contratos de Interface
260
+
261
+ O contrato é o **acordo formal** entre shell e remote — define o que o remote expõe e o que espera receber.
262
+
263
+ ### Estrutura do pacote de contratos
264
+
265
+ ```
266
+ packages/
267
+ └── mfe-contracts/
268
+ ├── src/
269
+ │ ├── remotes/
270
+ │ │ ├── {nome-remote}.contract.ts ← contrato do remote
271
+ │ │ └── index.ts
272
+ │ ├── shell/
273
+ │ │ └── shell.context.ts ← o que o shell injeta nos remotes
274
+ │ └── index.ts
275
+ ├── package.json
276
+ └── tsconfig.json
277
+ ```
278
+
279
+ ### Definindo um contrato
280
+
281
+ ```typescript
282
+ // packages/mfe-contracts/src/remotes/{nome-remote}.contract.ts
283
+
284
+ // O que o remote expõe ao shell
285
+ export interface {NomeRemote}Exports {
286
+ default: React.ComponentType<{NomeRemote}Props>
287
+ }
288
+
289
+ // Props que o shell passa ao montar o remote
290
+ export interface {NomeRemote}Props {
291
+ basePath: string
292
+ onNavigate?: (path: string) => void
293
+ }
294
+
295
+ // Eventos que o remote emite no event bus
296
+ export interface {NomeRemote}Events {
297
+ '{nome-remote}:action-completed': { id: string; result: unknown }
298
+ '{nome-remote}:error': { code: string; message: string }
299
+ }
300
+ ```
301
+
302
+ ### Contexto do shell (injetado em todos os remotes)
303
+
304
+ ```typescript
305
+ // packages/mfe-contracts/src/shell/shell.context.ts
306
+ export interface ShellContext {
307
+ user: {
308
+ id: string
309
+ name: string
310
+ permissions: string[]
311
+ }
312
+ theme: 'light' | 'dark'
313
+ locale: string
314
+ onNavigate: (path: string) => void
315
+ }
316
+
317
+ // Hook disponível em todos os remotes
318
+ export const ShellContextReact = React.createContext<ShellContext | null>(null)
319
+
320
+ export function useShellContext(): ShellContext {
321
+ const ctx = React.useContext(ShellContextReact)
322
+ if (!ctx) throw new Error('useShellContext deve ser usado dentro do ShellProvider')
323
+ return ctx
324
+ }
325
+ ```
326
+
327
+ ---
328
+
329
+ ## Shared Dependencies
330
+
331
+ ### Regras críticas
332
+
333
+ ```
334
+ singleton: true → apenas uma instância em toda a aplicação (obrigatório para React, React DOM)
335
+ eager: false → NÃO usar eager para shared libs (causa bootstrap error)
336
+ requiredVersion → sempre declarar para evitar conflitos silenciosos
337
+ ```
338
+
339
+ ### Checklist de shared deps
340
+
341
+ ```typescript
342
+ shared: {
343
+ // Core React — sempre singleton
344
+ 'react': { singleton: true, requiredVersion: '^18.0.0' },
345
+ 'react-dom': { singleton: true, requiredVersion: '^18.0.0' },
346
+
347
+ // Router — singleton para evitar múltiplos contextos de roteamento
348
+ 'react-router-dom': { singleton: true, requiredVersion: '^6.0.0' },
349
+
350
+ // Design system — singleton obrigatório (CSS e contexto de tema)
351
+ '@{org}/design-system': { singleton: true },
352
+
353
+ // Estado global — singleton se compartilhado entre remotes
354
+ 'zustand': { singleton: true },
355
+
356
+ // NÃO compartilhar: libs utilitárias pequenas (date-fns, lodash)
357
+ // → melhor cada remote ter sua versão para evitar lock de versão
358
+ }
359
+ ```
360
+
361
+ ### Conflito de versão (diagnóstico)
362
+
363
+ ```bash
364
+ # Ver qual versão de react cada remote está carregando
365
+ # No DevTools → Network → filtrar por "remoteEntry.js"
366
+ # Abrir arquivo e buscar por "shared"
367
+
368
+ # Via CLI — verificar versões no monorepo
369
+ pnpm list react --recursive
370
+ ```
371
+
372
+ ---
373
+
374
+ ## Event Bus
375
+
376
+ Remote e shell se comunicam via evento — nunca via import direto.
377
+
378
+ ```typescript
379
+ // packages/mfe-contracts/src/event-bus.ts
380
+
381
+ type EventHandler<T> = (payload: T) => void
382
+
383
+ class MFEEventBus {
384
+ private listeners = new Map<string, Set<EventHandler<unknown>>>()
385
+
386
+ emit<T>(event: string, payload: T): void {
387
+ this.listeners.get(event)?.forEach((handler) => handler(payload as unknown))
388
+ }
389
+
390
+ on<T>(event: string, handler: EventHandler<T>): () => void {
391
+ if (!this.listeners.has(event)) {
392
+ this.listeners.set(event, new Set())
393
+ }
394
+ this.listeners.get(event)!.add(handler as EventHandler<unknown>)
395
+
396
+ // retorna função de cleanup
397
+ return () => this.listeners.get(event)?.delete(handler as EventHandler<unknown>)
398
+ }
399
+ }
400
+
401
+ // Singleton global — compartilhado via shell context
402
+ export const eventBus = new MFEEventBus()
403
+ ```
404
+
405
+ ```typescript
406
+ // Uso em um remote
407
+ import { useShellContext } from '@{org}/mfe-contracts'
408
+
409
+ function CheckoutButton({ orderId }: { orderId: string }) {
410
+ const { eventBus } = useShellContext()
411
+
412
+ return (
413
+ <button onClick={() => eventBus.emit('checkout:initiated', { orderId })}>
414
+ Finalizar compra
415
+ </button>
416
+ )
417
+ }
418
+
419
+ // Uso no shell — escutar eventos de remotes
420
+ useEffect(() => {
421
+ const unsubscribe = eventBus.on('checkout:initiated', ({ orderId }) => {
422
+ navigate(`/checkout/${orderId}`)
423
+ })
424
+ return unsubscribe
425
+ }, [])
426
+ ```
427
+
428
+ ---
429
+
430
+ ## Monorepo Frontend
431
+
432
+ ### Estrutura recomendada
433
+
434
+ ```
435
+ {repo}/
436
+ ├── apps/
437
+ │ ├── shell/ ← host application
438
+ │ ├── {remote-a}/ ← micro frontend A
439
+ │ └── {remote-b}/ ← micro frontend B
440
+ ├── packages/
441
+ │ ├── design-system/ ← componentes e tokens compartilhados
442
+ │ ├── mfe-contracts/ ← tipos TypeScript de contratos de interface
443
+ │ └── utils/ ← utilitários compartilhados
444
+ ├── pnpm-workspace.yaml
445
+ └── turbo.json
446
+ ```
447
+
448
+ ```yaml
449
+ # pnpm-workspace.yaml
450
+ packages:
451
+ - 'apps/*'
452
+ - 'packages/*'
453
+ ```
454
+
455
+ ```json
456
+ // turbo.json
457
+ {
458
+ "pipeline": {
459
+ "build": {
460
+ "dependsOn": ["^build"],
461
+ "outputs": ["dist/**"]
462
+ },
463
+ "dev": {
464
+ "cache": false,
465
+ "persistent": true
466
+ },
467
+ "test": {
468
+ "dependsOn": ["^build"]
469
+ }
470
+ }
471
+ }
472
+ ```
473
+
474
+ ---
475
+
476
+ ## Estratégia de Deploy
477
+
478
+ ### Deploy independente (objetivo central do micro frontend)
479
+
480
+ ```
481
+ Cada remote tem seu próprio pipeline de CI/CD:
482
+ push → build → test → deploy → atualizar URL no shell (via env var ou config service)
483
+
484
+ Shell NÃO precisa ser re-deployed quando um remote é atualizado.
485
+ ```
486
+
487
+ ### Variáveis de ambiente por remote
488
+
489
+ ```bash
490
+ # .env.production do shell
491
+ VITE_REMOTE_URL_NOME_REMOTE=https://cdn.example.com/nome-remote/remoteEntry.js
492
+ VITE_REMOTE_URL_OUTRO_REMOTE=https://cdn.example.com/outro-remote/remoteEntry.js
493
+ ```
494
+
495
+ ### Versionamento de remotes
496
+
497
+ ```
498
+ Sem breaking change na API exposta → patch ou minor → URL permanece a mesma
499
+ Breaking change na API exposta (props, eventos) → major → nova URL + migração no shell
500
+ ```
501
+
502
+ ---
503
+
504
+ ## Troubleshooting
505
+
506
+ ### Erro: "Shared module is not available for eager consumption"
507
+
508
+ ```typescript
509
+ // ❌ Causa: eager: true em shared lib com React
510
+ shared: { react: { singleton: true, eager: true } } // NÃO FAZER
511
+
512
+ // ✅ Solução: usar bootstrap.ts com import() dinâmico
513
+ // src/index.ts
514
+ import('./bootstrap') // async bootstrap resolve o problema
515
+ ```
516
+
517
+ ### Erro: "Remote container is not available"
518
+
519
+ ```bash
520
+ # 1. Verificar se o remote está rodando
521
+ curl http://localhost:3001/assets/remoteEntry.js
522
+
523
+ # 2. Verificar CORS no servidor do remote
524
+ # O remoteEntry.js precisa ser acessível pelo shell
525
+
526
+ # 3. Verificar se a URL no shell está correta
527
+ grep -r "remoteEntry" vite.config.ts
528
+ ```
529
+
530
+ ### Componente do remote não re-renderiza após update de state do shell
531
+
532
+ ```typescript
533
+ // Causa provável: contexto do shell não está sendo re-injetado no remote
534
+ // Solução: passar o contexto via props no ponto de montagem, não via módulo compartilhado
535
+
536
+ // ❌ Problemático
537
+ import { useShellStore } from 'shell/store' // import direto entre remote e shell
538
+
539
+ // ✅ Correto
540
+ // Shell passa estado via props ao montar o remote
541
+ <RemoteApp user={currentUser} onNavigate={navigate} />
542
+ ```
543
+
544
+ ---
545
+
546
+ ## Checklist de Novo Remote
547
+
548
+ - [ ] `bootstrap.ts` com import dinâmico
549
+ - [ ] Funciona em modo standalone (`npm run dev`)
550
+ - [ ] `exposed/` contém apenas a API pública
551
+ - [ ] Contrato de interface criado em `mfe-contracts`
552
+ - [ ] Shared dependencies declaradas com `singleton: true` e `requiredVersion`
553
+ - [ ] ErrorBoundary no ponto de montagem do shell
554
+ - [ ] Testes de integração com shell (ao menos smoke test)
555
+ - [ ] URL de deploy configurada via variável de ambiente
556
+ - [ ] Breaking changes documentadas e comunicadas ao time do shell
557
+
558
+ ---
559
+
560
+ ## Regras
561
+
562
+ ### Nunca
563
+ - Importar diretamente de outro remote (rompe isolamento e cria acoplamento)
564
+ - Compartilhar estado via módulo — usar event bus ou props via shell
565
+ - Deploy do shell acoplado ao deploy de um remote (derrota o propósito)
566
+ - `eager: true` em shared libs (causa erro de bootstrap)
567
+ - Hardcodar URL do remoteEntry (sempre via variável de ambiente)
568
+
569
+ ### Sempre
570
+ - Cada remote funciona standalone para desenvolvimento local
571
+ - Contratos de interface em TypeScript antes de integrar ao shell
572
+ - `singleton: true` para React, React DOM, React Router e design system
573
+ - ErrorBoundary no shell ao montar cada remote
574
+ - Versionar breaking changes no contrato com semver
575
+
576
+ ---
577
+
578
+ ## Output
579
+
580
+ | Artefato | Descrição |
581
+ |----------|-----------|
582
+ | Configuração Module Federation | `vite.config.ts` ou `webpack.config.ts` do remote e/ou shell |
583
+ | Contrato de interface | Types em `mfe-contracts` |
584
+ | Ponto de montagem | Lazy import + ErrorBoundary no shell |
585
+ | Event bus | Tipos de eventos e usage examples |
586
+ | Pipeline CI | Configuração de build/deploy independente |
587
+
588
+ ---
589
+
590
+ ## Mensagem de Conclusão
591
+
592
+ ```
593
+ Micro Frontend configurado!
594
+
595
+ Remote: {nome}
596
+ Expõe: {lista do exposed}
597
+ Contrato: {arquivo de tipos criado}
598
+ Shared deps: {lista das dependências compartilhadas}
599
+ Standalone: {porta de dev local}
600
+
601
+ Próximo passo: {integrar ao shell | definir contrato | configurar CI}
602
+ ```