cp-toolkit 2.2.10 → 2.2.12
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.
- package/README.md +73 -0
- package/package.json +1 -1
- package/src/commands/init.js +2 -70
- package/templates/copilot-instructions.md +75 -0
package/README.md
CHANGED
|
@@ -124,6 +124,79 @@ applyTo: "**/*.ts,**/*.tsx"
|
|
|
124
124
|
| `.github/instructions/*.instructions.md` | Path-specific rules |
|
|
125
125
|
| `AGENTS.md` | Universal AI instructions |
|
|
126
126
|
| `.vscode/mcp.json` | MCP server configuration |
|
|
127
|
+
| `.github/cp-kit-models.yaml` | AI model allocation matrix |
|
|
128
|
+
|
|
129
|
+
## Architect-Builder Strategy
|
|
130
|
+
|
|
131
|
+
cp-toolkit implements the **Architect-Builder Pattern** for optimal AI agent performance. This strategy separates reasoning from execution:
|
|
132
|
+
|
|
133
|
+
### Dual-Mode Architecture
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
137
|
+
│ SINGLE MODE HYBRID MODE (Architect-Builder) │
|
|
138
|
+
│ ───────────── ─────────────────────────────── │
|
|
139
|
+
│ │
|
|
140
|
+
│ ┌─────────────────┐ PLANNER EXECUTOR │
|
|
141
|
+
│ │ High-IQ Model │ (Architect) (Builder) │
|
|
142
|
+
│ │ Pure Reasoning │ ┌──────────┐ ┌──────────┐ │
|
|
143
|
+
│ └─────────────────┘ │ temp 0.1 │ → │ temp 0.3 │ │
|
|
144
|
+
│ │ Strategy │ │ Code Gen │ │
|
|
145
|
+
│ • orchestrator └──────────┘ └──────────┘ │
|
|
146
|
+
│ • security-auditor │
|
|
147
|
+
│ • debugger • backend-specialist │
|
|
148
|
+
│ • documentation-writer • frontend-specialist │
|
|
149
|
+
│ • devops-engineer │
|
|
150
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Mode Selection
|
|
154
|
+
|
|
155
|
+
| Mode | Temperature | Use Case |
|
|
156
|
+
|------|-------------|----------|
|
|
157
|
+
| **Single** | 0.1 | Pure reasoning tasks (analysis, planning, auditing) |
|
|
158
|
+
| **Hybrid Planner** | 0.1 | Strategic thinking, architecture decisions |
|
|
159
|
+
| **Hybrid Executor** | 0.3 | Code generation, implementation |
|
|
160
|
+
|
|
161
|
+
### Agent Categories
|
|
162
|
+
|
|
163
|
+
1. **Leadership & Strategy** (Single Mode)
|
|
164
|
+
- `orchestrator`, `product-manager`, `product-owner`, `project-planner`
|
|
165
|
+
|
|
166
|
+
2. **Development Core** (Hybrid Mode)
|
|
167
|
+
- `backend-specialist`, `frontend-specialist`, `mobile-developer`, `game-developer`
|
|
168
|
+
|
|
169
|
+
3. **Infrastructure & Ops** (Hybrid Mode)
|
|
170
|
+
- `devops-engineer`, `database-architect`, `security-auditor`, `penetration-tester`
|
|
171
|
+
|
|
172
|
+
4. **Quality & Optimization** (Hybrid Mode)
|
|
173
|
+
- `qa-automation-engineer`, `test-engineer`, `performance-optimizer`, `debugger`
|
|
174
|
+
|
|
175
|
+
5. **Specialists & Research** (Mixed)
|
|
176
|
+
- `code-archaeologist`, `documentation-writer`, `seo-specialist`, `explorer-agent`
|
|
177
|
+
|
|
178
|
+
### Why This Works
|
|
179
|
+
|
|
180
|
+
- **Planner (Architect)**: Uses high-reasoning models with low temperature for accurate strategic decisions
|
|
181
|
+
- **Executor (Builder)**: Uses fast code-generation models with slightly higher temperature for creative implementation
|
|
182
|
+
- **Cost Optimization**: Expensive models only for planning; economical models for bulk code generation
|
|
183
|
+
- **Quality Assurance**: Clear separation prevents "hallucination drift" in long implementations
|
|
184
|
+
|
|
185
|
+
### Models Configuration
|
|
186
|
+
|
|
187
|
+
The `cp-kit-models.yaml` file defines the model allocation:
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
agents:
|
|
191
|
+
backend-specialist:
|
|
192
|
+
mode: "hybrid"
|
|
193
|
+
planner:
|
|
194
|
+
model: "gpt-5.2"
|
|
195
|
+
task: "API architecture, security and data modeling"
|
|
196
|
+
executor:
|
|
197
|
+
model: "gpt-5.2-codex"
|
|
198
|
+
task: "Route and service implementation with perfect typing"
|
|
199
|
+
```
|
|
127
200
|
|
|
128
201
|
## License
|
|
129
202
|
|
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -119,8 +119,8 @@ export async function initCommand(directory, options) {
|
|
|
119
119
|
// 5. Setup .github/copilot-instructions.md
|
|
120
120
|
spinner.text = 'Creating copilot-instructions.md...';
|
|
121
121
|
const instructionsPath = path.join(targetDir, '.github', 'copilot-instructions.md');
|
|
122
|
-
const
|
|
123
|
-
await fs.
|
|
122
|
+
const instructionsTemplatePath = path.join(templatesDir, 'copilot-instructions.md');
|
|
123
|
+
await fs.copy(instructionsTemplatePath, instructionsPath);
|
|
124
124
|
|
|
125
125
|
// 6. Setup .github/cp-kit-models.yaml
|
|
126
126
|
spinner.text = 'Creating cp-kit-models.yaml...';
|
|
@@ -689,74 +689,6 @@ applyTo: ".github/workflows/**/*.yml,.github/workflows/**/*.yaml"
|
|
|
689
689
|
}
|
|
690
690
|
}
|
|
691
691
|
|
|
692
|
-
function generateCopilotInstructions(config) {
|
|
693
|
-
return `# GitHub Copilot Instructions
|
|
694
|
-
|
|
695
|
-
> **Copilot Kit v2** - Project: ${config.projectName}
|
|
696
|
-
|
|
697
|
-
## 🤖 Agent System
|
|
698
|
-
|
|
699
|
-
This project uses specialized AI agents located in \`.github/agents/\`.
|
|
700
|
-
|
|
701
|
-
### Available Agents
|
|
702
|
-
|
|
703
|
-
| Agent | Specialty |
|
|
704
|
-
|-------|-----------|
|
|
705
|
-
| orchestrator | Multi-agent coordination, complex tasks |
|
|
706
|
-
| frontend-specialist | React, Next.js, CSS, accessibility |
|
|
707
|
-
| backend-specialist | Node.js, Python, APIs, microservices |
|
|
708
|
-
| database-architect | Schema design, SQL, Prisma, migrations |
|
|
709
|
-
| security-auditor | OWASP, auth, vulnerability analysis |
|
|
710
|
-
| test-engineer | Testing strategies, coverage, TDD |
|
|
711
|
-
| debugger | Troubleshooting, root cause analysis |
|
|
712
|
-
| devops-engineer | CI/CD, Docker, Kubernetes, infrastructure |
|
|
713
|
-
| performance-optimizer | Web vitals, profiling, optimization |
|
|
714
|
-
| documentation-writer | Technical docs, API documentation |
|
|
715
|
-
|
|
716
|
-
### How to Use Agents
|
|
717
|
-
|
|
718
|
-
To invoke an agent, reference it in your prompt:
|
|
719
|
-
- "Use the **orchestrator** to plan this feature"
|
|
720
|
-
- "Ask the **security-auditor** to review this code"
|
|
721
|
-
- "Have the **debugger** analyze this error"
|
|
722
|
-
|
|
723
|
-
## 📋 Language Instructions
|
|
724
|
-
|
|
725
|
-
Context-specific rules are in \`.github/instructions/\`:
|
|
726
|
-
- \`typescript-development.instructions.md\` - TypeScript files
|
|
727
|
-
- \`javascript-development.instructions.md\` - JavaScript files
|
|
728
|
-
- \`react-development.instructions.md\` - React components
|
|
729
|
-
- \`nextjs-development.instructions.md\` - Next.js applications
|
|
730
|
-
- \`python-development.instructions.md\` - Python files
|
|
731
|
-
- \`security-development.instructions.md\` - Auth/security code
|
|
732
|
-
- \`database-development.instructions.md\` - Database/ORM code
|
|
733
|
-
- \`testing-development.instructions.md\` - Test files
|
|
734
|
-
- \`api-development.instructions.md\` - API endpoints
|
|
735
|
-
- \`github-actions.instructions.md\` - GitHub Actions workflows
|
|
736
|
-
|
|
737
|
-
## 🔧 MCP Servers
|
|
738
|
-
|
|
739
|
-
Configured in \`.vscode/mcp.json\`:
|
|
740
|
-
- **filesystem** - File system access
|
|
741
|
-
- **memory** - Persistent memory across sessions
|
|
742
|
-
|
|
743
|
-
## 🚀 Workflows
|
|
744
|
-
|
|
745
|
-
Workflow templates in \`.github/copilot-workflows/\`:
|
|
746
|
-
- \`/create\` - Scaffold new features
|
|
747
|
-
- \`/debug\` - Systematic debugging
|
|
748
|
-
- \`/test\` - Generate test suites
|
|
749
|
-
- \`/plan\` - Architecture planning
|
|
750
|
-
|
|
751
|
-
## 📝 General Guidelines
|
|
752
|
-
|
|
753
|
-
1. **Read before writing** - Understand existing patterns
|
|
754
|
-
2. **Small, focused changes** - One concern per commit
|
|
755
|
-
3. **Test coverage** - Write tests for new features
|
|
756
|
-
4. **Security first** - Validate inputs, sanitize outputs
|
|
757
|
-
`;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
692
|
function generateModelsConfig() {
|
|
761
693
|
return `# .github/cp-kit-models.yaml
|
|
762
694
|
# Matriz de Alocação de Modelos v3.0 (Full 20-Agent Suite)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# GitHub Copilot Agent Toolkit (CP-Toolkit) - System Instructions
|
|
2
|
+
|
|
3
|
+
Você é assistido por um **Sistema Multi-Agente Avançado** definido no diretório `.github/agents/`.
|
|
4
|
+
Sua tarefa primária é identificar a intenção do usuário ou o contexto do arquivo e adotar a **Persona**, **Regras** e **Limitações** do agente especialista apropriado.
|
|
5
|
+
|
|
6
|
+
## 🚦 Roteamento de Agentes (Master Router)
|
|
7
|
+
|
|
8
|
+
Quando o usuário invocar um agente (ex: "Atue como QA") ou o contexto exigir, carregue as instruções do arquivo correspondente:
|
|
9
|
+
|
|
10
|
+
### 1. Liderança & Estratégia
|
|
11
|
+
| Gatilho / Intenção | Agente (Alias) | Fonte de Instruções |
|
|
12
|
+
| :--- | :--- | :--- |
|
|
13
|
+
| Coordenação geral, Workflow | **@Orchestrator** | `.github/agents/orchestrator.md` |
|
|
14
|
+
| Visão de produto, Negócios | **@ProductManager** | `.github/agents/product-manager.md` |
|
|
15
|
+
| Backlog, User Stories, Requisitos | **@ProductOwner** | `.github/agents/product-owner.md` |
|
|
16
|
+
| Cronogramas, Prazos, Gantt | **@ProjectPlanner** | `.github/agents/project-planner.md` |
|
|
17
|
+
|
|
18
|
+
### 2. Desenvolvimento Core
|
|
19
|
+
| Gatilho / Intenção | Agente (Alias) | Fonte de Instruções |
|
|
20
|
+
| :--- | :--- | :--- |
|
|
21
|
+
| API, Node, Python, Server-side | **@Backend** | `.github/agents/backend-specialist.md` |
|
|
22
|
+
| React, CSS, UX, Interface | **@Frontend** | `.github/agents/frontend-specialist.md` |
|
|
23
|
+
| iOS, Android, Swift, Kotlin, RN | **@Mobile** | `.github/agents/mobile-developer.md` |
|
|
24
|
+
| Unity, Unreal, C++, Gamedev | **@GameDev** | `.github/agents/game-developer.md` |
|
|
25
|
+
|
|
26
|
+
### 3. Infraestrutura & Dados
|
|
27
|
+
| Gatilho / Intenção | Agente (Alias) | Fonte de Instruções |
|
|
28
|
+
| :--- | :--- | :--- |
|
|
29
|
+
| SQL, Prisma, Modelagem ER | **@DBA** | `.github/agents/database-architect.md` |
|
|
30
|
+
| Docker, CI/CD, AWS, Terraform | **@DevOps** | `.github/agents/devops-engineer.md` |
|
|
31
|
+
|
|
32
|
+
### 4. Qualidade & Segurança
|
|
33
|
+
| Gatilho / Intenção | Agente (Alias) | Fonte de Instruções |
|
|
34
|
+
| :--- | :--- | :--- |
|
|
35
|
+
| Scripts de Teste (E2E/Unit) | **@QA** | `.github/agents/qa-automation-engineer.md` |
|
|
36
|
+
| TDD, Cobertura de Testes | **@Tester** | `.github/agents/test-engineer.md` |
|
|
37
|
+
| Análise de Vulnerabilidades | **@Security** | `.github/agents/security-auditor.md` |
|
|
38
|
+
| Pentest, Ataque Ético | **@RedTeam** | `.github/agents/penetration-tester.md` |
|
|
39
|
+
| Bugs complexos, Logs | **@Debugger** | `.github/agents/debugger.md` |
|
|
40
|
+
| Performance, Otimização, Latência | **@PerfOptimizer** | `.github/agents/performance-optimizer.md` |
|
|
41
|
+
|
|
42
|
+
### 5. Especialistas & Pesquisa
|
|
43
|
+
| Gatilho / Intenção | Agente (Alias) | Fonte de Instruções |
|
|
44
|
+
| :--- | :--- | :--- |
|
|
45
|
+
| Código Legado, Refatoração | **@Archaeologist** | `.github/agents/code-archaeologist.md` |
|
|
46
|
+
| Documentação Técnica, Markdown | **@TechWriter** | `.github/agents/documentation-writer.md` |
|
|
47
|
+
| SEO, Meta tags, Analytics | **@SEO** | `.github/agents/seo-specialist.md` |
|
|
48
|
+
| Ideação, Brainstorming, R&D | **@Explorer** | `.github/agents/explorer-agent.md` |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## ⚡ Protocolos de Ativação
|
|
53
|
+
|
|
54
|
+
### 1. Invocação Explícita
|
|
55
|
+
Se o usuário disser: *"Aja como [Agente]"*, *"Como [Agente] faria isso?"* ou usar o alias (ex: *"@DevOps, corrija o pipeline"*), você **DEVE** carregar o arquivo `.md` correspondente no contexto imediatamente.
|
|
56
|
+
|
|
57
|
+
### 2. Contexto Inteligente (Smart Context)
|
|
58
|
+
Se nenhum agente for chamado, verifique o arquivo aberto:
|
|
59
|
+
* Arquivo `.tsx` ou `.css` → Ative **@Frontend**.
|
|
60
|
+
* Arquivo `Dockerfile` ou `.yml` → Ative **@DevOps**.
|
|
61
|
+
* Arquivo `.sql` ou `schema.prisma` → Ative **@DBA**.
|
|
62
|
+
* Arquivos com "legacy" ou "old" no nome → Ative **@Archaeologist**.
|
|
63
|
+
|
|
64
|
+
### 3. Protocolo Architect-Builder (Para tarefas complexas)
|
|
65
|
+
Para solicitações grandes (ex: "Crie um novo módulo de pagamentos"):
|
|
66
|
+
1. Comece com o **@Orchestrator** ou **@Backend** (Planner Mode) para gerar um arquivo `PLAN.md`.
|
|
67
|
+
2. **NÃO escreva código de implementação** até que o plano seja aprovado.
|
|
68
|
+
3. Após o plano, mude para o agente executor (ex: @Backend Executor) para implementar o código passo-a-passo.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 🛡️ Diretrizes Globais
|
|
73
|
+
* **Segurança:** Nunca gere chaves de API reais ou senhas hardcoded.
|
|
74
|
+
* **Qualidade:** Sempre prefira código limpo, tipado (TypeScript) e testável.
|
|
75
|
+
* **Idioma:** Responda no idioma do usuário (Português por padrão), mas mantenha termos técnicos em inglês quando padrão da indústria.
|