maestro-bundle 1.3.1 → 1.5.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 (128) hide show
  1. package/README.md +19 -6
  2. package/package.json +1 -1
  3. package/src/cli.mjs +12 -1
  4. package/templates/bundle-ai-agents/AGENTS.md +6 -0
  5. package/templates/bundle-ai-agents/PRD_TEMPLATE.md +161 -0
  6. package/templates/bundle-ai-agents/skills/agent-orchestration/SKILL.md +107 -41
  7. package/templates/bundle-ai-agents/skills/agent-orchestration/references/graph-patterns.md +50 -0
  8. package/templates/bundle-ai-agents/skills/agent-orchestration/references/routing-strategies.md +47 -0
  9. package/templates/bundle-ai-agents/skills/api-design/SKILL.md +125 -16
  10. package/templates/bundle-ai-agents/skills/api-design/references/pydantic-patterns.md +72 -0
  11. package/templates/bundle-ai-agents/skills/api-design/references/rest-conventions.md +51 -0
  12. package/templates/bundle-ai-agents/skills/clean-architecture/SKILL.md +113 -21
  13. package/templates/bundle-ai-agents/skills/clean-architecture/references/dependency-injection.md +60 -0
  14. package/templates/bundle-ai-agents/skills/clean-architecture/references/layer-rules.md +56 -0
  15. package/templates/bundle-ai-agents/skills/context-engineering/SKILL.md +104 -36
  16. package/templates/bundle-ai-agents/skills/context-engineering/references/compression-techniques.md +76 -0
  17. package/templates/bundle-ai-agents/skills/context-engineering/references/context-budget-calculator.md +45 -0
  18. package/templates/bundle-ai-agents/skills/database-modeling/SKILL.md +146 -19
  19. package/templates/bundle-ai-agents/skills/database-modeling/references/index-strategies.md +48 -0
  20. package/templates/bundle-ai-agents/skills/database-modeling/references/naming-conventions.md +27 -0
  21. package/templates/bundle-ai-agents/skills/docker-containerization/SKILL.md +124 -15
  22. package/templates/bundle-ai-agents/skills/docker-containerization/references/compose-patterns.md +97 -0
  23. package/templates/bundle-ai-agents/skills/docker-containerization/references/dockerfile-checklist.md +37 -0
  24. package/templates/bundle-ai-agents/skills/eval-testing/SKILL.md +113 -25
  25. package/templates/bundle-ai-agents/skills/eval-testing/references/eval-types.md +52 -0
  26. package/templates/bundle-ai-agents/skills/eval-testing/references/golden-dataset-template.md +59 -0
  27. package/templates/bundle-ai-agents/skills/memory-management/SKILL.md +112 -28
  28. package/templates/bundle-ai-agents/skills/memory-management/references/memory-tiers.md +41 -0
  29. package/templates/bundle-ai-agents/skills/memory-management/references/namespace-conventions.md +41 -0
  30. package/templates/bundle-ai-agents/skills/prompt-engineering/SKILL.md +139 -47
  31. package/templates/bundle-ai-agents/skills/prompt-engineering/references/anti-patterns.md +59 -0
  32. package/templates/bundle-ai-agents/skills/prompt-engineering/references/prompt-templates.md +75 -0
  33. package/templates/bundle-ai-agents/skills/rag-pipeline/SKILL.md +104 -27
  34. package/templates/bundle-ai-agents/skills/rag-pipeline/references/chunking-strategies.md +27 -0
  35. package/templates/bundle-ai-agents/skills/rag-pipeline/references/embedding-models.md +31 -0
  36. package/templates/bundle-ai-agents/skills/rag-pipeline/references/rag-evaluation.md +39 -0
  37. package/templates/bundle-ai-agents/skills/testing-strategy/SKILL.md +127 -18
  38. package/templates/bundle-ai-agents/skills/testing-strategy/references/fixture-patterns.md +81 -0
  39. package/templates/bundle-ai-agents/skills/testing-strategy/references/naming-conventions.md +69 -0
  40. package/templates/bundle-base/skills/branch-strategy/SKILL.md +134 -21
  41. package/templates/bundle-base/skills/branch-strategy/references/branch-rules.md +40 -0
  42. package/templates/bundle-base/skills/code-review/SKILL.md +123 -38
  43. package/templates/bundle-base/skills/code-review/references/review-checklist.md +45 -0
  44. package/templates/bundle-base/skills/commit-pattern/SKILL.md +98 -39
  45. package/templates/bundle-base/skills/commit-pattern/references/conventional-commits.md +40 -0
  46. package/templates/bundle-data-pipeline/AGENTS.md +6 -0
  47. package/templates/bundle-data-pipeline/PRD_TEMPLATE.md +161 -0
  48. package/templates/bundle-data-pipeline/skills/data-preprocessing/SKILL.md +110 -19
  49. package/templates/bundle-data-pipeline/skills/data-preprocessing/references/pandas-cheatsheet.md +63 -0
  50. package/templates/bundle-data-pipeline/skills/data-preprocessing/references/pandera-schemas.md +44 -0
  51. package/templates/bundle-data-pipeline/skills/docker-containerization/SKILL.md +132 -16
  52. package/templates/bundle-data-pipeline/skills/docker-containerization/references/compose-patterns.md +82 -0
  53. package/templates/bundle-data-pipeline/skills/docker-containerization/references/dockerfile-best-practices.md +57 -0
  54. package/templates/bundle-data-pipeline/skills/feature-engineering/SKILL.md +143 -45
  55. package/templates/bundle-data-pipeline/skills/feature-engineering/references/encoding-guide.md +41 -0
  56. package/templates/bundle-data-pipeline/skills/feature-engineering/references/scaling-guide.md +38 -0
  57. package/templates/bundle-data-pipeline/skills/mlops-pipeline/SKILL.md +156 -37
  58. package/templates/bundle-data-pipeline/skills/mlops-pipeline/references/mlflow-commands.md +69 -0
  59. package/templates/bundle-data-pipeline/skills/model-training/SKILL.md +152 -33
  60. package/templates/bundle-data-pipeline/skills/model-training/references/evaluation-metrics.md +52 -0
  61. package/templates/bundle-data-pipeline/skills/model-training/references/model-selection-guide.md +41 -0
  62. package/templates/bundle-data-pipeline/skills/rag-pipeline/SKILL.md +127 -39
  63. package/templates/bundle-data-pipeline/skills/rag-pipeline/references/chunking-strategies.md +51 -0
  64. package/templates/bundle-data-pipeline/skills/rag-pipeline/references/embedding-models.md +49 -0
  65. package/templates/bundle-frontend-spa/AGENTS.md +6 -0
  66. package/templates/bundle-frontend-spa/PRD_TEMPLATE.md +161 -0
  67. package/templates/bundle-frontend-spa/skills/authentication/SKILL.md +196 -13
  68. package/templates/bundle-frontend-spa/skills/authentication/references/jwt-security.md +41 -0
  69. package/templates/bundle-frontend-spa/skills/component-design/SKILL.md +191 -41
  70. package/templates/bundle-frontend-spa/skills/component-design/references/accessibility-checklist.md +41 -0
  71. package/templates/bundle-frontend-spa/skills/component-design/references/tailwind-patterns.md +65 -0
  72. package/templates/bundle-frontend-spa/skills/e2e-testing/SKILL.md +241 -79
  73. package/templates/bundle-frontend-spa/skills/e2e-testing/references/playwright-selectors.md +66 -0
  74. package/templates/bundle-frontend-spa/skills/e2e-testing/references/test-patterns.md +82 -0
  75. package/templates/bundle-frontend-spa/skills/integration-api/SKILL.md +221 -31
  76. package/templates/bundle-frontend-spa/skills/integration-api/references/api-patterns.md +81 -0
  77. package/templates/bundle-frontend-spa/skills/react-patterns/SKILL.md +195 -70
  78. package/templates/bundle-frontend-spa/skills/react-patterns/references/component-checklist.md +22 -0
  79. package/templates/bundle-frontend-spa/skills/react-patterns/references/hook-patterns.md +63 -0
  80. package/templates/bundle-frontend-spa/skills/responsive-layout/SKILL.md +162 -22
  81. package/templates/bundle-frontend-spa/skills/responsive-layout/references/breakpoint-guide.md +63 -0
  82. package/templates/bundle-frontend-spa/skills/state-management/SKILL.md +158 -30
  83. package/templates/bundle-frontend-spa/skills/state-management/references/react-query-config.md +64 -0
  84. package/templates/bundle-frontend-spa/skills/state-management/references/state-patterns.md +78 -0
  85. package/templates/bundle-jhipster-microservices/AGENTS.md +6 -0
  86. package/templates/bundle-jhipster-microservices/PRD_TEMPLATE.md +161 -0
  87. package/templates/bundle-jhipster-microservices/skills/ci-cd-pipeline/SKILL.md +135 -45
  88. package/templates/bundle-jhipster-microservices/skills/ci-cd-pipeline/references/gitlab-ci-templates.md +93 -0
  89. package/templates/bundle-jhipster-microservices/skills/clean-architecture/SKILL.md +87 -21
  90. package/templates/bundle-jhipster-microservices/skills/clean-architecture/references/layer-rules.md +78 -0
  91. package/templates/bundle-jhipster-microservices/skills/ddd-tactical/SKILL.md +94 -25
  92. package/templates/bundle-jhipster-microservices/skills/ddd-tactical/references/ddd-patterns.md +48 -0
  93. package/templates/bundle-jhipster-microservices/skills/jhipster-angular/SKILL.md +63 -21
  94. package/templates/bundle-jhipster-microservices/skills/jhipster-angular/references/angular-microservices.md +40 -0
  95. package/templates/bundle-jhipster-microservices/skills/jhipster-angular/references/angular-structure.md +59 -0
  96. package/templates/bundle-jhipster-microservices/skills/jhipster-docker-k8s/SKILL.md +125 -91
  97. package/templates/bundle-jhipster-microservices/skills/jhipster-docker-k8s/references/docker-k8s-commands.md +68 -0
  98. package/templates/bundle-jhipster-microservices/skills/jhipster-entities/SKILL.md +72 -20
  99. package/templates/bundle-jhipster-microservices/skills/jhipster-entities/references/cross-service-entities.md +36 -0
  100. package/templates/bundle-jhipster-microservices/skills/jhipster-entities/references/jdl-types.md +56 -0
  101. package/templates/bundle-jhipster-microservices/skills/jhipster-gateway/SKILL.md +80 -8
  102. package/templates/bundle-jhipster-microservices/skills/jhipster-gateway/references/gateway-config.md +43 -0
  103. package/templates/bundle-jhipster-microservices/skills/jhipster-kafka/SKILL.md +115 -22
  104. package/templates/bundle-jhipster-microservices/skills/jhipster-kafka/references/kafka-events.md +39 -0
  105. package/templates/bundle-jhipster-microservices/skills/jhipster-registry/SKILL.md +92 -23
  106. package/templates/bundle-jhipster-microservices/skills/jhipster-registry/references/consul-config.md +61 -0
  107. package/templates/bundle-jhipster-microservices/skills/jhipster-service/SKILL.md +81 -18
  108. package/templates/bundle-jhipster-microservices/skills/jhipster-service/references/service-patterns.md +40 -0
  109. package/templates/bundle-jhipster-microservices/skills/testing-strategy/SKILL.md +101 -20
  110. package/templates/bundle-jhipster-microservices/skills/testing-strategy/references/test-naming.md +55 -0
  111. package/templates/bundle-jhipster-monorepo/AGENTS.md +6 -0
  112. package/templates/bundle-jhipster-monorepo/PRD_TEMPLATE.md +161 -0
  113. package/templates/bundle-jhipster-monorepo/skills/clean-architecture/SKILL.md +87 -21
  114. package/templates/bundle-jhipster-monorepo/skills/clean-architecture/references/layer-rules.md +78 -0
  115. package/templates/bundle-jhipster-monorepo/skills/ddd-tactical/SKILL.md +94 -25
  116. package/templates/bundle-jhipster-monorepo/skills/ddd-tactical/references/ddd-patterns.md +48 -0
  117. package/templates/bundle-jhipster-monorepo/skills/jhipster-angular/SKILL.md +99 -52
  118. package/templates/bundle-jhipster-monorepo/skills/jhipster-angular/references/angular-structure.md +59 -0
  119. package/templates/bundle-jhipster-monorepo/skills/jhipster-entities/SKILL.md +89 -36
  120. package/templates/bundle-jhipster-monorepo/skills/jhipster-entities/references/jdl-types.md +56 -0
  121. package/templates/bundle-jhipster-monorepo/skills/jhipster-liquibase/SKILL.md +123 -23
  122. package/templates/bundle-jhipster-monorepo/skills/jhipster-liquibase/references/liquibase-operations.md +95 -0
  123. package/templates/bundle-jhipster-monorepo/skills/jhipster-security/SKILL.md +106 -19
  124. package/templates/bundle-jhipster-monorepo/skills/jhipster-security/references/security-checklist.md +47 -0
  125. package/templates/bundle-jhipster-monorepo/skills/jhipster-spring/SKILL.md +84 -16
  126. package/templates/bundle-jhipster-monorepo/skills/jhipster-spring/references/spring-layers.md +41 -0
  127. package/templates/bundle-jhipster-monorepo/skills/testing-strategy/SKILL.md +101 -20
  128. package/templates/bundle-jhipster-monorepo/skills/testing-strategy/references/test-naming.md +55 -0
package/README.md CHANGED
@@ -9,12 +9,22 @@ npx maestro-bundle ai-agents claude
9
9
  ## O que faz
10
10
 
11
11
  1. Instala **AGENTS.md** + **skills** no formato correto do seu editor
12
- 2. Instala o [GitHub Spec Kit](https://github.com/github/spec-kit) (`specify-cli@v0.4.3`) no projeto
13
- 3. Roda `specify init` que registra os commands `/speckit.*` no editor
14
- 4. Integra o `constitution.md` do bundle com os princípios do projeto
12
+ 2. Cria **PRD.md** template de requisitos para o analista/dev preencher
13
+ 3. Instala o [GitHub Spec Kit](https://github.com/github/spec-kit) (`specify-cli@v0.4.3`) no projeto
14
+ 4. Roda `specify init` que registra os commands `/speckit.*` no editor
15
+ 5. Integra o `constitution.md` do bundle com os princípios do projeto
15
16
 
16
17
  O dev abre o editor e já tem skills + `/speckit.specify` funcionando.
17
18
 
19
+ ## AGENTS.md vs PRD.md
20
+
21
+ | Arquivo | Quem escreve | O que contém | Para que serve |
22
+ |---|---|---|---|
23
+ | **AGENTS.md** | Bundle (automático) | Stack, padrões, estrutura, convenções | Define COMO o agente trabalha |
24
+ | **PRD.md** | Analista / Dev | User stories, requisitos, API spec, modelo de dados | Define O QUE deve ser construído |
25
+
26
+ O `AGENTS.md` vem pronto no bundle. O `PRD.md` vem como template — o dev/analista preenche com os requisitos do projeto antes de começar a codar. O agente AI usa ambos como contexto.
27
+
18
28
  ## Editores suportados
19
29
 
20
30
  | Editor | Comando | O que instala |
@@ -71,7 +81,8 @@ $ npx maestro-bundle ai-agents claude
71
81
  ```
72
82
  seu-projeto/
73
83
  ├── CLAUDE.md # @AGENTS.md (aponta pro AGENTS.md)
74
- ├── AGENTS.md # Instruções do bundle
84
+ ├── AGENTS.md # Define COMO o agente trabalha
85
+ ├── PRD.md # Define O QUE construir (preencher!)
75
86
  ├── .claude/
76
87
  │ ├── skills/ # Skills do bundle
77
88
  │ │ ├── rag-pipeline/SKILL.md
@@ -96,7 +107,8 @@ seu-projeto/
96
107
 
97
108
  ```
98
109
  seu-projeto/
99
- ├── AGENTS.md # Instruções (Cursor automaticamente)
110
+ ├── AGENTS.md # Define COMO o agente trabalha
111
+ ├── PRD.md # Define O QUE construir (preencher!)
100
112
  ├── .cursor/
101
113
  │ ├── skills/ # Skills do bundle
102
114
  │ │ ├── rag-pipeline/SKILL.md
@@ -113,7 +125,8 @@ seu-projeto/
113
125
 
114
126
  ```
115
127
  seu-projeto/
116
- ├── AGENTS.md # Instruções (Codex automaticamente)
128
+ ├── AGENTS.md # Define COMO o agente trabalha
129
+ ├── PRD.md # Define O QUE construir (preencher!)
117
130
  ├── .agents/
118
131
  │ └── skills/ # Commands do Spec Kit (como skills)
119
132
  │ ├── speckit-constitution/SKILL.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maestro-bundle",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Instala bundles de governança para projetos com AI agents. Um comando, tudo configurado.",
5
5
  "bin": {
6
6
  "maestro-bundle": "./src/cli.mjs"
package/src/cli.mjs CHANGED
@@ -301,7 +301,18 @@ async function main() {
301
301
  spinner.succeed(`${EDITORS[editorKey].name}: ${results.join(", ")}`);
302
302
  }
303
303
 
304
- // 2. Skills canônicas (sempre, para Deep Agents e referência)
304
+ // 2. PRD template
305
+ const prdTemplate = join(bundleDir, "PRD_TEMPLATE.md");
306
+ if (existsSync(prdTemplate)) {
307
+ const prdDest = join(targetDir, "PRD.md");
308
+ if (!existsSync(prdDest)) {
309
+ cpSync(prdTemplate, prdDest);
310
+ const spinnerPrd = ora("PRD.md template instalado").start();
311
+ spinnerPrd.succeed("PRD.md template instalado (preencha com os requisitos do produto)");
312
+ }
313
+ }
314
+
315
+ // 3. Skills canônicas (sempre, para Deep Agents e referência)
305
316
  const spinner2 = ora("Instalando skills canônicas").start();
306
317
  const skillsDest = join(targetDir, "skills");
307
318
  ensureDir(skillsDest);
@@ -14,6 +14,12 @@ Este projeto usa **GitHub Spec Kit** para governança. Antes de implementar qual
14
14
 
15
15
  Nunca pular direto para código. Spec primeiro, código depois.
16
16
 
17
+ ## Product Requirements Document
18
+
19
+ O arquivo `PRD.md` na raiz do projeto contém os requisitos do produto definidos pelo analista/dev. Consulte-o para entender O QUE construir, as user stories, critérios de aceite, modelo de dados e API specification. Este AGENTS.md define COMO o agente deve trabalhar; o PRD define O QUE deve ser construído.
20
+
21
+ - `PRD.md` — Requisitos do produto, user stories, API spec, modelo de dados
22
+
17
23
  ## References
18
24
 
19
25
  Documentos de referência que o agente deve consultar quando necessário:
@@ -0,0 +1,161 @@
1
+ # Product Requirements Document (PRD)
2
+
3
+ > Este documento define os requisitos do produto. Deve ser preenchido pelo analista de requisitos e/ou pelo dev antes de iniciar o desenvolvimento. O agente AI usa este documento como contexto para entender O QUE construir.
4
+
5
+ ## 1. Resumo Executivo
6
+
7
+ <!-- Descreva em 2-3 frases o que é o produto e qual problema resolve -->
8
+
9
+ ## 2. Usuários Alvo
10
+
11
+ <!-- Quem vai usar o sistema? Descreva as personas -->
12
+
13
+ ### Persona 1: [Nome]
14
+ - **Perfil:**
15
+ - **Objetivos:**
16
+ - **Dores:**
17
+
18
+ ## 3. Escopo do MVP
19
+
20
+ ### Incluído no MVP
21
+ - [ ] Feature 1
22
+ - [ ] Feature 2
23
+ - [ ] Feature 3
24
+
25
+ ### Fora do MVP (futuro)
26
+ - [ ] Feature futura 1
27
+ - [ ] Feature futura 2
28
+
29
+ ## 4. User Stories
30
+
31
+ ### US01: [Título]
32
+ **Como** [persona], **quero** [ação], **para** [benefício].
33
+
34
+ **Critérios de aceite:**
35
+ - [ ] CA1:
36
+ - [ ] CA2:
37
+
38
+ ### US02: [Título]
39
+ **Como** [persona], **quero** [ação], **para** [benefício].
40
+
41
+ **Critérios de aceite:**
42
+ - [ ] CA1:
43
+ - [ ] CA2:
44
+
45
+ ## 5. Arquitetura de Alto Nível
46
+
47
+ <!-- Diagrama em Mermaid ou ASCII mostrando os componentes principais -->
48
+
49
+ ```mermaid
50
+ graph LR
51
+ A[Frontend] --> B[API]
52
+ B --> C[Database]
53
+ ```
54
+
55
+ ### Estrutura de Diretórios
56
+
57
+ ```
58
+ project/
59
+ ├── src/
60
+ ├── tests/
61
+ └── ...
62
+ ```
63
+
64
+ ## 6. Features Detalhadas
65
+
66
+ ### Feature 1: [Nome]
67
+ - **Descrição:**
68
+ - **Regras de negócio:**
69
+ -
70
+ - **Inputs:**
71
+ - **Outputs:**
72
+ - **Edge cases:**
73
+ -
74
+
75
+ ### Feature 2: [Nome]
76
+ - **Descrição:**
77
+ - **Regras de negócio:**
78
+ -
79
+
80
+ ## 7. Stack Tecnológica
81
+
82
+ | Componente | Tecnologia | Justificativa |
83
+ |---|---|---|
84
+ | Backend | | |
85
+ | Frontend | | |
86
+ | Banco de dados | | |
87
+ | Cache | | |
88
+ | Deploy | | |
89
+
90
+ ## 8. API Specification
91
+
92
+ ### Endpoints
93
+
94
+ #### `GET /api/v1/resource`
95
+ - **Descrição:**
96
+ - **Response:** `200 OK`
97
+ ```json
98
+ {
99
+ "items": [],
100
+ "total": 0,
101
+ "page": 1,
102
+ "size": 20
103
+ }
104
+ ```
105
+
106
+ #### `POST /api/v1/resource`
107
+ - **Descrição:**
108
+ - **Body:**
109
+ ```json
110
+ {
111
+ "field": "value"
112
+ }
113
+ ```
114
+ - **Response:** `201 Created`
115
+
116
+ ## 9. Modelo de Dados
117
+
118
+ ```sql
119
+ CREATE TABLE example (
120
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
121
+ name VARCHAR(100) NOT NULL,
122
+ created_at TIMESTAMP DEFAULT NOW()
123
+ );
124
+ ```
125
+
126
+ ## 10. Requisitos Não-Funcionais
127
+
128
+ | Requisito | Alvo | Prioridade |
129
+ |---|---|---|
130
+ | Performance | Response time < 500ms | Alta |
131
+ | Disponibilidade | 99.9% uptime | Média |
132
+ | Segurança | OWASP Top 10 | Alta |
133
+ | Escalabilidade | Até X usuários simultâneos | Média |
134
+
135
+ ## 11. Fases de Implementação
136
+
137
+ ### Fase 1: Foundation
138
+ - [ ] Setup do projeto
139
+ - [ ] Modelo de dados
140
+ - [ ] Endpoints básicos
141
+
142
+ ### Fase 2: Core Features
143
+ - [ ] Feature 1 completa
144
+ - [ ] Feature 2 completa
145
+
146
+ ### Fase 3: Polish
147
+ - [ ] Testes E2E
148
+ - [ ] Performance
149
+ - [ ] Documentação
150
+
151
+ ## 12. Riscos e Mitigações
152
+
153
+ | Risco | Impacto | Probabilidade | Mitigação |
154
+ |---|---|---|---|
155
+ | | | | |
156
+
157
+ ## 13. Critérios de Sucesso
158
+
159
+ - [ ] Critério 1
160
+ - [ ] Critério 2
161
+ - [ ] Critério 3
@@ -1,24 +1,35 @@
1
1
  ---
2
2
  name: agent-orchestration
3
- description: Criar sistemas multi-agente com LangGraph incluindo orquestrador, subagentes, roteamento e delegação. Use quando precisar coordenar múltiplos agentes, criar times de agentes, ou implementar orquestração com LangGraph.
3
+ description: Build multi-agent systems with LangGraph including orchestrator, subagents, routing, and delegation. Use when coordinating multiple agents, creating agent teams, or implementing orchestration workflows.
4
+ version: 1.0.0
5
+ author: Maestro
4
6
  ---
5
7
 
6
- # Orquestração de Agentes
8
+ # Agent Orchestration
7
9
 
8
- ## Arquitetura Multi-Agente
10
+ Design and implement multi-agent systems where an orchestrator coordinates specialized subagents through task planning, intelligent routing, compliance validation, and human-in-the-loop approval.
9
11
 
10
- ```
11
- Orquestrador (LangGraph StateGraph)
12
- ├── Router Node decide qual agente executar
13
- ├── Agent Frontend executa tasks de frontend
14
- ├── Agent Backend executa tasks de backend
15
- ├── Agent DevOps executa tasks de infra
16
- ├── Validator Node → valida compliance com bundle
17
- ├── Human Review → interrupt para aprovação
18
- └── Merger Node mergea branches dos agentes
19
- ```
12
+ ## When to Use
13
+ - Coordinating multiple specialized agents (frontend, backend, devops)
14
+ - Implementing task decomposition and delegation workflows
15
+ - Building a LangGraph StateGraph with routing logic
16
+ - Adding human-in-the-loop approval gates for destructive operations
17
+ - Creating agent pipelines that validate compliance before merging work
18
+
19
+ ## Available Operations
20
+ 1. Define orchestrator state schema
21
+ 2. Build the orchestrator graph with nodes and edges
22
+ 3. Implement intelligent task routing
23
+ 4. Delegate tasks to specialized subagents
24
+ 5. Add compliance validation nodes
25
+ 6. Wire up human-in-the-loop interrupt gates
26
+ 7. Merge work from multiple agent branches
20
27
 
21
- ## AgentState
28
+ ## Multi-Step Workflow
29
+
30
+ ### Step 1: Define the Orchestrator State
31
+
32
+ Create a typed state schema that tracks the full lifecycle of a demand.
22
33
 
23
34
  ```python
24
35
  from typing import TypedDict, Annotated, Literal
@@ -36,14 +47,17 @@ class OrchestratorState(TypedDict):
36
47
  final_status: str
37
48
  ```
38
49
 
39
- ## Grafo do Orquestrador
50
+ ### Step 2: Build the Graph Structure
51
+
52
+ Wire up the orchestrator nodes and conditional edges.
40
53
 
41
54
  ```python
42
55
  from langgraph.graph import StateGraph, START, END
56
+ from langgraph.checkpoint.postgres import PostgresSaver
43
57
 
44
58
  graph = StateGraph(OrchestratorState)
45
59
 
46
- # Nós
60
+ # Add nodes
47
61
  graph.add_node("analyze_demand", analyze_demand_node)
48
62
  graph.add_node("plan_tasks", plan_tasks_node)
49
63
  graph.add_node("route_to_agent", route_to_agent_node)
@@ -52,7 +66,7 @@ graph.add_node("validate_compliance", validate_compliance_node)
52
66
  graph.add_node("human_review", human_review_node)
53
67
  graph.add_node("merge_work", merge_work_node)
54
68
 
55
- # Edges
69
+ # Wire edges
56
70
  graph.add_edge(START, "analyze_demand")
57
71
  graph.add_edge("analyze_demand", "plan_tasks")
58
72
  graph.add_edge("plan_tasks", "route_to_agent")
@@ -71,14 +85,37 @@ graph.add_edge("merge_work", END)
71
85
  app = graph.compile(checkpointer=PostgresSaver(conn))
72
86
  ```
73
87
 
74
- ## Delegação para subagentes
88
+ ### Step 3: Implement Intelligent Routing
89
+
90
+ Route tasks to the right subagent based on keywords or LLM classification.
91
+
92
+ ```python
93
+ def route_to_agent(state: OrchestratorState) -> dict:
94
+ task = state["task_plan"][state["current_task_index"]]
95
+
96
+ routing_map = {
97
+ "frontend": ["ui", "component", "screen", "react", "css"],
98
+ "backend": ["api", "endpoint", "database", "service", "entity"],
99
+ "devops": ["deploy", "pipeline", "docker", "k8s", "ci"],
100
+ }
101
+
102
+ for agent_type, keywords in routing_map.items():
103
+ if any(kw in task["description"].lower() for kw in keywords):
104
+ return {"assigned_agents": {task["id"]: agent_type}}
105
+
106
+ # Fallback: use LLM to decide
107
+ return {"assigned_agents": {task["id"]: llm_route(task)}}
108
+ ```
109
+
110
+ ### Step 4: Delegate to Subagents
111
+
112
+ Each subagent has its own graph, tools, and worktree.
75
113
 
76
114
  ```python
77
115
  async def execute_agent_node(state: OrchestratorState):
78
116
  task = state["task_plan"][state["current_task_index"]]
79
117
  agent_type = state["assigned_agents"][task["id"]]
80
118
 
81
- # Cada agente tem seu próprio grafo/tools
82
119
  agent = agent_registry.get(agent_type)
83
120
  result = await agent.ainvoke({
84
121
  "task": task,
@@ -95,28 +132,9 @@ async def execute_agent_node(state: OrchestratorState):
95
132
  }
96
133
  ```
97
134
 
98
- ## Roteamento inteligente
99
-
100
- ```python
101
- def route_to_agent(state: OrchestratorState) -> dict:
102
- """Decide qual tipo de agente executar baseado na task"""
103
- task = state["task_plan"][state["current_task_index"]]
104
-
105
- routing_map = {
106
- "frontend": ["ui", "componente", "tela", "react", "css"],
107
- "backend": ["api", "endpoint", "banco", "service", "entity"],
108
- "devops": ["deploy", "pipeline", "docker", "k8s", "ci"],
109
- }
110
-
111
- for agent_type, keywords in routing_map.items():
112
- if any(kw in task["description"].lower() for kw in keywords):
113
- return {"assigned_agents": {task["id"]: agent_type}}
114
-
115
- # Fallback: usar LLM para decidir
116
- return {"assigned_agents": {task["id"]: llm_route(task)}}
117
- ```
135
+ ### Step 5: Add Human-in-the-Loop Approval
118
136
 
119
- ## Human-in-the-loop
137
+ Use LangGraph interrupts for merge approval gates.
120
138
 
121
139
  ```python
122
140
  from langgraph.types import interrupt
@@ -126,7 +144,55 @@ def human_review_node(state: OrchestratorState):
126
144
  "type": "merge_approval",
127
145
  "branches": state["branch_status"],
128
146
  "compliance": state["compliance_results"],
129
- "message": "Aprovar merge dos branches?"
147
+ "message": "Approve merging branches?"
130
148
  })
131
149
  return {"needs_human_review": False, "final_status": approval["decision"]}
132
150
  ```
151
+
152
+ ### Step 6: Run and Test the Orchestrator
153
+
154
+ ```bash
155
+ # Run the orchestrator with a test demand
156
+ python -m orchestrator.run --demand "Create CRUD for demands with REST API and React UI"
157
+
158
+ # Verify the graph structure
159
+ python -c "from orchestrator.graph import app; app.get_graph().print_ascii()"
160
+ ```
161
+
162
+ ## Resources
163
+ - `references/graph-patterns.md` - Common LangGraph graph patterns for orchestration
164
+ - `references/routing-strategies.md` - Detailed routing strategies and fallback mechanisms
165
+
166
+ ## Examples
167
+
168
+ ### Example 1: Decompose and Execute a Full-Stack Demand
169
+ User asks: "Set up an orchestrator that decomposes a demand into frontend and backend tasks and delegates them."
170
+ Response approach:
171
+ 1. Define OrchestratorState with task_plan and assigned_agents
172
+ 2. Create analyze_demand node that uses LLM to break down the demand
173
+ 3. Create plan_tasks node that structures tasks with dependencies
174
+ 4. Implement keyword-based routing for frontend vs backend
175
+ 5. Wire up execute_agent to delegate each task to the right subagent
176
+ 6. Add compliance validation before merge
177
+
178
+ ### Example 2: Add a New Agent Type
179
+ User asks: "Add a QA agent that runs tests after backend tasks complete."
180
+ Response approach:
181
+ 1. Create a QA agent graph with test-running tools
182
+ 2. Register it in the agent_registry
183
+ 3. Add "qa" keywords to the routing map (e.g., "test", "quality", "coverage")
184
+ 4. Add a conditional edge from execute_agent to route QA tasks after backend
185
+
186
+ ### Example 3: Implement Parallel Agent Execution
187
+ User asks: "Make frontend and backend agents run in parallel instead of sequentially."
188
+ Response approach:
189
+ 1. Use LangGraph's `Send` API to fan out to multiple agents simultaneously
190
+ 2. Add a `join_results` node that waits for all parallel branches
191
+ 3. Wire conditional edges from join_results to validate_compliance
192
+
193
+ ## Notes
194
+ - Always use a checkpointer (PostgresSaver) so the orchestrator can resume after failures
195
+ - Each subagent should operate in its own git worktree to avoid conflicts
196
+ - Compliance validation should run before any merge operation
197
+ - Human review gates are mandatory for destructive operations (merges, deployments)
198
+ - Use thread_id based on demand_id for consistent state across invocations
@@ -0,0 +1,50 @@
1
+ # Graph Patterns Reference
2
+
3
+ ## Common LangGraph Orchestration Patterns
4
+
5
+ ### 1. Sequential Pipeline
6
+ ```
7
+ START -> analyze -> plan -> execute -> validate -> END
8
+ ```
9
+ Best for: Simple workflows with no branching.
10
+
11
+ ### 2. Router Pattern
12
+ ```
13
+ START -> analyze -> router --(frontend)--> agent_frontend -> merge
14
+ \--(backend)---> agent_backend -> merge
15
+ \--(devops)----> agent_devops -> merge
16
+ ```
17
+ Best for: Task delegation to specialized agents.
18
+
19
+ ### 3. Loop with Exit Condition
20
+ ```
21
+ START -> plan -> execute -> check_done --(more tasks)--> execute
22
+ \--(all done)---> validate -> END
23
+ ```
24
+ Best for: Iterating through a task list.
25
+
26
+ ### 4. Fan-Out / Fan-In (Parallel)
27
+ ```python
28
+ from langgraph.types import Send
29
+
30
+ def fan_out(state):
31
+ return [Send("execute_agent", {"task": t}) for t in state["task_plan"]]
32
+ ```
33
+ Best for: Independent tasks that can run concurrently.
34
+
35
+ ### 5. Human-in-the-Loop Gate
36
+ ```python
37
+ from langgraph.types import interrupt
38
+
39
+ def approval_gate(state):
40
+ result = interrupt({"message": "Approve?", "data": state["summary"]})
41
+ return {"approved": result["decision"] == "yes"}
42
+ ```
43
+ Best for: Destructive operations requiring human approval.
44
+
45
+ ## State Design Principles
46
+
47
+ - Use `Annotated[list, add_messages]` for message accumulation.
48
+ - Use `dict[str, str]` for mappings that grow over time (branch_status, assigned_agents).
49
+ - Keep state flat -- avoid deeply nested structures.
50
+ - Include a `current_task_index` integer for loop-based task execution.
@@ -0,0 +1,47 @@
1
+ # Routing Strategies Reference
2
+
3
+ ## Strategy 1: Keyword-Based Routing
4
+
5
+ Fast, deterministic, zero-cost. Use as primary router.
6
+
7
+ ```python
8
+ routing_map = {
9
+ "frontend": ["ui", "component", "screen", "react", "css", "layout", "form"],
10
+ "backend": ["api", "endpoint", "database", "service", "entity", "migration"],
11
+ "devops": ["deploy", "pipeline", "docker", "k8s", "ci", "monitoring"],
12
+ "qa": ["test", "coverage", "quality", "e2e", "integration test"],
13
+ }
14
+ ```
15
+
16
+ ## Strategy 2: LLM-Based Routing (Fallback)
17
+
18
+ Use when keywords are ambiguous. Costs tokens but handles edge cases.
19
+
20
+ ```python
21
+ async def llm_route(task: dict) -> str:
22
+ response = await llm.ainvoke(f"""
23
+ Classify this task into exactly one category: frontend, backend, devops, qa.
24
+ Task: {task['description']}
25
+ Respond with just the category name.
26
+ """)
27
+ return response.content.strip().lower()
28
+ ```
29
+
30
+ ## Strategy 3: Embedding Similarity
31
+
32
+ Pre-embed descriptions for each agent type, route by cosine similarity.
33
+
34
+ ```python
35
+ agent_descriptions = {
36
+ "frontend": "UI components, React, CSS, forms, layouts, user interactions",
37
+ "backend": "REST APIs, business logic, database operations, services",
38
+ "devops": "Docker, CI/CD, deployments, infrastructure, monitoring",
39
+ }
40
+ ```
41
+
42
+ ## Fallback Chain
43
+
44
+ 1. Try keyword match first (fastest).
45
+ 2. If no match, try embedding similarity (medium cost).
46
+ 3. If confidence < 0.7, use LLM routing (highest cost, best accuracy).
47
+ 4. If LLM is uncertain, default to "backend" and flag for human review.