cp-toolkit 2.1.2 → 2.2.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.
- package/package.json +1 -1
- package/src/commands/init.js +212 -316
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* cp-
|
|
2
|
+
* cp-toolkit init command
|
|
3
3
|
*
|
|
4
4
|
* Initializes Copilot Kit with GitHub Copilot 2026 standard structure.
|
|
5
|
-
*
|
|
5
|
+
* Creates:
|
|
6
|
+
* .github/agents/ - Specialist agent definitions
|
|
7
|
+
* .github/instructions/ - Language/context-specific instructions
|
|
8
|
+
* .github/copilot-instructions.md - Main Copilot config
|
|
9
|
+
* .vscode/mcp.json - MCP server configuration
|
|
6
10
|
*/
|
|
7
11
|
|
|
8
12
|
import fs from 'fs-extra';
|
|
@@ -10,258 +14,16 @@ import path from 'path';
|
|
|
10
14
|
import chalk from 'chalk';
|
|
11
15
|
import ora from 'ora';
|
|
12
16
|
import prompts from 'prompts';
|
|
17
|
+
import { fileURLToPath } from 'url';
|
|
13
18
|
|
|
14
|
-
//
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
name: 'orchestrator',
|
|
18
|
-
description: 'Multi-domain task coordinator',
|
|
19
|
-
skills: ['intelligent-routing', 'parallel-agents', 'plan-writing'],
|
|
20
|
-
triggers: ['complex', 'multi-file', 'architecture', 'coordinate']
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'frontend-specialist',
|
|
24
|
-
description: 'React, Next.js, CSS expert',
|
|
25
|
-
skills: ['nextjs-react', 'accessibility', 'tailwind'],
|
|
26
|
-
triggers: ['ui', 'component', 'react', 'css', 'frontend', 'styling']
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
name: 'backend-specialist',
|
|
30
|
-
description: 'Node.js, Python, APIs expert',
|
|
31
|
-
skills: ['api-patterns', 'error-handling', 'caching'],
|
|
32
|
-
triggers: ['api', 'server', 'backend', 'endpoint', 'node', 'express']
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'database-architect',
|
|
36
|
-
description: 'Schema design, SQL, Prisma expert',
|
|
37
|
-
skills: ['prisma', 'query-optimization', 'migrations'],
|
|
38
|
-
triggers: ['database', 'schema', 'sql', 'prisma', 'migration', 'query']
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: 'security-auditor',
|
|
42
|
-
description: 'Security analysis, OWASP expert',
|
|
43
|
-
skills: ['vulnerability-scanner', 'auth-patterns'],
|
|
44
|
-
triggers: ['security', 'auth', 'vulnerability', 'owasp', 'audit']
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: 'test-engineer',
|
|
48
|
-
description: 'Testing strategies, coverage expert',
|
|
49
|
-
skills: ['testing-patterns', 'e2e-testing'],
|
|
50
|
-
triggers: ['test', 'coverage', 'jest', 'playwright', 'vitest']
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: 'debugger',
|
|
54
|
-
description: 'Troubleshooting, root cause analysis',
|
|
55
|
-
skills: ['debugging-strategies', 'performance-profiling'],
|
|
56
|
-
triggers: ['bug', 'error', 'fix', 'debug', 'why', 'crash']
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'devops-engineer',
|
|
60
|
-
description: 'CI/CD, Docker, infrastructure expert',
|
|
61
|
-
skills: ['docker-patterns', 'ci-cd-pipelines'],
|
|
62
|
-
triggers: ['deploy', 'docker', 'ci', 'pipeline', 'kubernetes', 'infra']
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
name: 'project-planner',
|
|
66
|
-
description: 'Architecture decisions, task planning',
|
|
67
|
-
skills: ['plan-writing', 'brainstorming'],
|
|
68
|
-
triggers: ['plan', 'architecture', 'design', 'roadmap', 'breakdown']
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: 'performance-optimizer',
|
|
72
|
-
description: 'Web performance, Core Web Vitals expert',
|
|
73
|
-
skills: ['performance-profiling', 'bundle-optimization'],
|
|
74
|
-
triggers: ['performance', 'speed', 'optimize', 'lighthouse', 'bundle']
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: 'mobile-developer',
|
|
78
|
-
description: 'React Native, Flutter, iOS, Android expert',
|
|
79
|
-
skills: ['mobile-patterns', 'cross-platform'],
|
|
80
|
-
triggers: ['mobile', 'ios', 'android', 'react-native', 'flutter', 'app']
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
name: 'documentation-writer',
|
|
84
|
-
description: 'Technical docs, API documentation expert',
|
|
85
|
-
skills: ['technical-writing', 'api-docs'],
|
|
86
|
-
triggers: ['docs', 'documentation', 'readme', 'api-docs', 'jsdoc']
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: 'seo-specialist',
|
|
90
|
-
description: 'SEO optimization, meta tags expert',
|
|
91
|
-
skills: ['seo-patterns', 'structured-data'],
|
|
92
|
-
triggers: ['seo', 'meta', 'search', 'ranking', 'sitemap']
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'code-archaeologist',
|
|
96
|
-
description: 'Legacy code analysis, refactoring expert',
|
|
97
|
-
skills: ['refactoring', 'code-analysis'],
|
|
98
|
-
triggers: ['legacy', 'refactor', 'understand', 'cleanup', 'technical-debt']
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
name: 'explorer-agent',
|
|
102
|
-
description: 'Codebase exploration and analysis',
|
|
103
|
-
skills: ['code-navigation', 'pattern-recognition'],
|
|
104
|
-
triggers: ['explore', 'find', 'search', 'where', 'locate']
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: 'game-developer',
|
|
108
|
-
description: 'Game logic, mechanics, interactive experiences',
|
|
109
|
-
skills: ['game-patterns', 'physics', 'graphics'],
|
|
110
|
-
triggers: ['game', 'physics', 'animation', 'canvas', 'webgl']
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: 'penetration-tester',
|
|
114
|
-
description: 'Offensive security, vulnerability exploitation',
|
|
115
|
-
skills: ['pentesting', 'exploitation'],
|
|
116
|
-
triggers: ['pentest', 'exploit', 'hack', 'red-team', 'attack']
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'product-owner',
|
|
120
|
-
description: 'Product strategy, backlog management',
|
|
121
|
-
skills: ['product-management', 'prioritization'],
|
|
122
|
-
triggers: ['backlog', 'priority', 'mvp', 'feature', 'user-story']
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: 'product-manager',
|
|
126
|
-
description: 'Requirements gathering, user research',
|
|
127
|
-
skills: ['requirements', 'user-research'],
|
|
128
|
-
triggers: ['requirements', 'spec', 'user', 'stakeholder', 'prd']
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: 'qa-automation-engineer',
|
|
132
|
-
description: 'E2E testing, CI pipelines, quality automation',
|
|
133
|
-
skills: ['automation', 'ci-testing'],
|
|
134
|
-
triggers: ['qa', 'automation', 'e2e', 'regression', 'quality']
|
|
135
|
-
}
|
|
136
|
-
];
|
|
137
|
-
|
|
138
|
-
const TEMPLATE_INSTRUCTIONS = {
|
|
139
|
-
typescript: {
|
|
140
|
-
applyTo: '**/*.ts,**/*.tsx,**/*.mts,**/*.cts',
|
|
141
|
-
content: `## TypeScript Guidelines
|
|
142
|
-
|
|
143
|
-
### Strict Mode
|
|
144
|
-
- Enable \`strict: true\` in tsconfig.json
|
|
145
|
-
- No \`any\` types - use \`unknown\` and narrow
|
|
146
|
-
- Explicit return types for public functions
|
|
147
|
-
|
|
148
|
-
### Patterns
|
|
149
|
-
- Prefer \`interface\` over \`type\` for objects
|
|
150
|
-
- Use \`as const\` for literal types
|
|
151
|
-
- Leverage discriminated unions for state
|
|
152
|
-
|
|
153
|
-
### Imports
|
|
154
|
-
- Use path aliases (@/components, @/lib)
|
|
155
|
-
- Barrel exports for public APIs only
|
|
156
|
-
- Tree-shakeable imports
|
|
157
|
-
|
|
158
|
-
### Error Handling
|
|
159
|
-
- Use Result<T, E> pattern for expected errors
|
|
160
|
-
- Throw only for unexpected errors
|
|
161
|
-
- Custom error classes extend Error`
|
|
162
|
-
},
|
|
163
|
-
python: {
|
|
164
|
-
applyTo: '**/*.py',
|
|
165
|
-
content: `## Python Guidelines
|
|
166
|
-
|
|
167
|
-
### Style
|
|
168
|
-
- Black formatter, line length 88
|
|
169
|
-
- Type hints for all public functions
|
|
170
|
-
- PEP 8 naming conventions
|
|
171
|
-
|
|
172
|
-
### Patterns
|
|
173
|
-
- Pydantic for data validation
|
|
174
|
-
- FastAPI for APIs
|
|
175
|
-
- Async/await for I/O operations
|
|
176
|
-
|
|
177
|
-
### Imports
|
|
178
|
-
- isort for import ordering
|
|
179
|
-
- Absolute imports preferred
|
|
180
|
-
- TYPE_CHECKING for type-only imports
|
|
181
|
-
|
|
182
|
-
### Error Handling
|
|
183
|
-
- Custom exceptions inherit from base
|
|
184
|
-
- Use \`raise from\` for chained exceptions
|
|
185
|
-
- Context managers for resources`
|
|
186
|
-
},
|
|
187
|
-
react: {
|
|
188
|
-
applyTo: '**/*.jsx,**/*.tsx,**/components/**',
|
|
189
|
-
content: `## React Guidelines
|
|
190
|
-
|
|
191
|
-
### Components
|
|
192
|
-
- Functional components only
|
|
193
|
-
- Custom hooks for shared logic
|
|
194
|
-
- Props interface above component
|
|
195
|
-
|
|
196
|
-
### State
|
|
197
|
-
- useState for local state
|
|
198
|
-
- useReducer for complex state
|
|
199
|
-
- Context for global, Zustand for app state
|
|
200
|
-
|
|
201
|
-
### Performance
|
|
202
|
-
- React.memo for expensive renders
|
|
203
|
-
- useMemo/useCallback judiciously
|
|
204
|
-
- Lazy load routes and heavy components
|
|
205
|
-
|
|
206
|
-
### Testing
|
|
207
|
-
- React Testing Library
|
|
208
|
-
- Test behavior, not implementation
|
|
209
|
-
- Mock at network boundary`
|
|
210
|
-
},
|
|
211
|
-
database: {
|
|
212
|
-
applyTo: '**/prisma/**,**/*.sql,**/migrations/**,**/schema.*',
|
|
213
|
-
content: `## Database Guidelines
|
|
214
|
-
|
|
215
|
-
### Schema Design
|
|
216
|
-
- UUID for primary keys
|
|
217
|
-
- Timestamps: createdAt, updatedAt
|
|
218
|
-
- Soft delete with deletedAt
|
|
219
|
-
|
|
220
|
-
### Prisma
|
|
221
|
-
- Use transactions for multi-table ops
|
|
222
|
-
- Select only needed fields
|
|
223
|
-
- Paginate with cursor, not offset
|
|
224
|
-
|
|
225
|
-
### Migrations
|
|
226
|
-
- One migration per feature
|
|
227
|
-
- Never modify applied migrations
|
|
228
|
-
- Test migrations on copy of prod data
|
|
229
|
-
|
|
230
|
-
### Security
|
|
231
|
-
- Parameterized queries only
|
|
232
|
-
- Row-level security where needed
|
|
233
|
-
- Encrypt PII at rest`
|
|
234
|
-
},
|
|
235
|
-
security: {
|
|
236
|
-
applyTo: '**/auth/**,**/security/**,**/*auth*,**/*token*,**/*session*',
|
|
237
|
-
content: `## Security Guidelines
|
|
238
|
-
|
|
239
|
-
### Authentication
|
|
240
|
-
- JWT with short expiry + refresh tokens
|
|
241
|
-
- HttpOnly cookies for web
|
|
242
|
-
- Rate limit auth endpoints
|
|
243
|
-
|
|
244
|
-
### Authorization
|
|
245
|
-
- RBAC or ABAC patterns
|
|
246
|
-
- Check permissions server-side
|
|
247
|
-
- Deny by default
|
|
248
|
-
|
|
249
|
-
### Data Protection
|
|
250
|
-
- Sanitize all inputs
|
|
251
|
-
- Escape outputs by context
|
|
252
|
-
- Never log sensitive data
|
|
253
|
-
|
|
254
|
-
### OWASP Top 10
|
|
255
|
-
- Validate content types
|
|
256
|
-
- CSRF tokens for state changes
|
|
257
|
-
- Security headers (CSP, HSTS)`
|
|
258
|
-
}
|
|
259
|
-
};
|
|
19
|
+
// Get __dirname equivalent for ESM
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
260
22
|
|
|
261
23
|
export async function initCommand(directory, options) {
|
|
262
24
|
const targetDir = directory ? path.resolve(directory) : process.cwd();
|
|
263
25
|
const dirName = path.basename(targetDir);
|
|
264
|
-
const templatesDir = path.join(
|
|
26
|
+
const templatesDir = path.join(__dirname, '../../templates');
|
|
265
27
|
|
|
266
28
|
console.log(chalk.bold.cyan('\n🚀 cp-toolkit - GitHub Copilot Agent Toolkit\n'));
|
|
267
29
|
|
|
@@ -272,12 +34,12 @@ export async function initCommand(directory, options) {
|
|
|
272
34
|
}
|
|
273
35
|
|
|
274
36
|
// Check for existing configuration
|
|
275
|
-
const
|
|
276
|
-
if (fs.existsSync(
|
|
37
|
+
const githubAgentsDir = path.join(targetDir, '.github', 'agents');
|
|
38
|
+
if (fs.existsSync(githubAgentsDir) && !options.force) {
|
|
277
39
|
const { overwrite } = await prompts({
|
|
278
40
|
type: 'confirm',
|
|
279
41
|
name: 'overwrite',
|
|
280
|
-
message: '
|
|
42
|
+
message: 'Copilot Kit (.github/agents) already exists. Overwrite?',
|
|
281
43
|
initial: false
|
|
282
44
|
});
|
|
283
45
|
|
|
@@ -304,51 +66,44 @@ export async function initCommand(directory, options) {
|
|
|
304
66
|
{
|
|
305
67
|
type: 'confirm',
|
|
306
68
|
name: 'installEverything',
|
|
307
|
-
message: 'Install full Copilot Kit (Agents,
|
|
69
|
+
message: 'Install full Copilot Kit (Agents, Instructions, Workflows)?',
|
|
308
70
|
initial: true
|
|
309
71
|
}
|
|
310
72
|
]);
|
|
311
|
-
|
|
73
|
+
config = { ...config, ...response };
|
|
312
74
|
}
|
|
313
75
|
|
|
314
76
|
const spinner = ora('Installing Copilot Kit...').start();
|
|
315
77
|
|
|
316
78
|
try {
|
|
317
|
-
// 1.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
});
|
|
79
|
+
// 1. Setup .github/agents/
|
|
80
|
+
spinner.text = 'Copying agents...';
|
|
81
|
+
const agentsSourceDir = path.join(templatesDir, 'agents');
|
|
82
|
+
const agentsTargetDir = path.join(targetDir, '.github', 'agents');
|
|
83
|
+
await fs.ensureDir(agentsTargetDir);
|
|
84
|
+
await fs.copy(agentsSourceDir, agentsTargetDir, { overwrite: true });
|
|
323
85
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
await fs.ensureDir(githubDir);
|
|
86
|
+
// 2. Setup .github/instructions/ (from skills that have instruction content)
|
|
87
|
+
spinner.text = 'Copying instructions...';
|
|
88
|
+
const instructionsTargetDir = path.join(targetDir, '.github', 'instructions');
|
|
89
|
+
await fs.ensureDir(instructionsTargetDir);
|
|
329
90
|
|
|
330
|
-
|
|
91
|
+
// Create standard instruction files
|
|
92
|
+
await createInstructionFiles(instructionsTargetDir);
|
|
93
|
+
|
|
94
|
+
// 3. Setup .github/copilot-instructions.md
|
|
95
|
+
spinner.text = 'Creating copilot-instructions.md...';
|
|
96
|
+
const instructionsPath = path.join(targetDir, '.github', 'copilot-instructions.md');
|
|
331
97
|
const instructionsContent = generateCopilotInstructions(config);
|
|
332
98
|
await fs.writeFile(instructionsPath, instructionsContent);
|
|
333
99
|
|
|
334
|
-
//
|
|
100
|
+
// 4. Setup .vscode/mcp.json
|
|
335
101
|
spinner.text = 'Configuring MCP Server...';
|
|
336
102
|
const vscodeDir = path.join(targetDir, '.vscode');
|
|
337
103
|
await fs.ensureDir(vscodeDir);
|
|
338
104
|
|
|
339
105
|
const mcpConfig = {
|
|
340
106
|
"mcpServers": {
|
|
341
|
-
"antigravity-toolkit": {
|
|
342
|
-
"command": "node",
|
|
343
|
-
"args": [
|
|
344
|
-
"${workspaceFolder}/.agent/scripts/mcp-server.js"
|
|
345
|
-
],
|
|
346
|
-
"env": {
|
|
347
|
-
"AGENT_ROOT": "${workspaceFolder}/.agent"
|
|
348
|
-
},
|
|
349
|
-
"disabled": false,
|
|
350
|
-
"autoApprove": []
|
|
351
|
-
},
|
|
352
107
|
"filesystem": {
|
|
353
108
|
"command": "npx",
|
|
354
109
|
"args": [
|
|
@@ -376,65 +131,206 @@ export async function initCommand(directory, options) {
|
|
|
376
131
|
JSON.stringify(mcpConfig, null, 2)
|
|
377
132
|
);
|
|
378
133
|
|
|
379
|
-
//
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
134
|
+
// 5. Copy workflows to .github/workflows-copilot/ (optional reference)
|
|
135
|
+
if (config.installEverything) {
|
|
136
|
+
spinner.text = 'Copying workflows...';
|
|
137
|
+
const workflowsSourceDir = path.join(templatesDir, 'workflows');
|
|
138
|
+
const workflowsTargetDir = path.join(targetDir, '.github', 'copilot-workflows');
|
|
139
|
+
if (fs.existsSync(workflowsSourceDir)) {
|
|
140
|
+
await fs.ensureDir(workflowsTargetDir);
|
|
141
|
+
await fs.copy(workflowsSourceDir, workflowsTargetDir, { overwrite: true });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
spinner.succeed(chalk.green('✨ Copilot Kit initialized successfully!'));
|
|
385
146
|
|
|
386
|
-
|
|
147
|
+
console.log(chalk.bold('\n📁 Created structure:'));
|
|
148
|
+
console.log(chalk.dim(' .github/'));
|
|
149
|
+
console.log(chalk.dim(' ├── agents/ ') + chalk.cyan('← 20 specialist agents'));
|
|
150
|
+
console.log(chalk.dim(' ├── instructions/ ') + chalk.cyan('← Language-specific rules'));
|
|
151
|
+
console.log(chalk.dim(' ├── copilot-workflows/') + chalk.cyan('← Workflow templates'));
|
|
152
|
+
console.log(chalk.dim(' └── copilot-instructions.md'));
|
|
153
|
+
console.log(chalk.dim(' .vscode/'));
|
|
154
|
+
console.log(chalk.dim(' └── mcp.json ') + chalk.cyan('← MCP server config'));
|
|
387
155
|
|
|
388
|
-
console.log(chalk.bold('\
|
|
389
|
-
console.log(`1.
|
|
390
|
-
console.log(`2.
|
|
391
|
-
console.log(`3.
|
|
156
|
+
console.log(chalk.bold('\n🚀 Next Steps:'));
|
|
157
|
+
console.log(` 1. ${chalk.cyan('Reload VS Code window')} to activate MCP servers`);
|
|
158
|
+
console.log(` 2. Open Copilot Chat and try: ${chalk.yellow('@workspace use the orchestrator agent')}`);
|
|
159
|
+
console.log(` 3. Or try a workflow: ${chalk.yellow('/create a React component')}`);
|
|
392
160
|
|
|
393
161
|
} catch (error) {
|
|
394
|
-
spinner.fail('
|
|
395
|
-
console.error(error);
|
|
162
|
+
spinner.fail(chalk.red('❌ Failed to initialize Copilot Kit'));
|
|
163
|
+
console.error(chalk.dim(error.message));
|
|
164
|
+
if (options.verbose) {
|
|
165
|
+
console.error(error);
|
|
166
|
+
}
|
|
396
167
|
}
|
|
397
168
|
}
|
|
398
169
|
|
|
399
|
-
function
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
description: ${agent.description}
|
|
404
|
-
skills: [${agent.skills.join(', ')}]
|
|
170
|
+
async function createInstructionFiles(instructionsDir) {
|
|
171
|
+
const instructions = {
|
|
172
|
+
'typescript.instructions.md': `---
|
|
173
|
+
applyTo: "**/*.ts,**/*.tsx,**/*.mts,**/*.cts"
|
|
405
174
|
---
|
|
406
175
|
|
|
407
|
-
#
|
|
176
|
+
# TypeScript Guidelines
|
|
408
177
|
|
|
409
|
-
|
|
410
|
-
|
|
178
|
+
## Strict Mode
|
|
179
|
+
- Enable \`strict: true\` in tsconfig.json
|
|
180
|
+
- No \`any\` types - use \`unknown\` and narrow with type guards
|
|
181
|
+
- Explicit return types for public functions
|
|
182
|
+
|
|
183
|
+
## Patterns
|
|
184
|
+
- Prefer \`interface\` over \`type\` for object shapes
|
|
185
|
+
- Use \`as const\` for literal types
|
|
186
|
+
- Leverage discriminated unions for state
|
|
187
|
+
|
|
188
|
+
## Imports
|
|
189
|
+
- Use type-only imports: \`import type { X } from 'y'\`
|
|
190
|
+
- Barrel exports for public APIs only
|
|
191
|
+
`,
|
|
192
|
+
|
|
193
|
+
'python.instructions.md': `---
|
|
194
|
+
applyTo: "**/*.py"
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
# Python Guidelines
|
|
198
|
+
|
|
199
|
+
## Type Hints
|
|
200
|
+
- Use type hints for all function signatures
|
|
201
|
+
- Use \`from __future__ import annotations\` for forward refs
|
|
202
|
+
- Prefer \`typing.Optional\` over \`X | None\` for Python 3.9 compat
|
|
203
|
+
|
|
204
|
+
## Patterns
|
|
205
|
+
- Use dataclasses or Pydantic for data structures
|
|
206
|
+
- Async/await for I/O bound operations
|
|
207
|
+
- Context managers for resource management
|
|
208
|
+
|
|
209
|
+
## Style
|
|
210
|
+
- Follow PEP 8
|
|
211
|
+
- Use Black for formatting
|
|
212
|
+
- Docstrings in Google style
|
|
213
|
+
`,
|
|
214
|
+
|
|
215
|
+
'security.instructions.md': `---
|
|
216
|
+
applyTo: "**/auth/**,**/security/**,**/*auth*,**/*token*,**/*session*"
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
# Security Guidelines
|
|
220
|
+
|
|
221
|
+
## Authentication
|
|
222
|
+
- JWT with short expiry + refresh tokens
|
|
223
|
+
- HttpOnly cookies for web sessions
|
|
224
|
+
- Rate limit authentication endpoints
|
|
225
|
+
|
|
226
|
+
## Authorization
|
|
227
|
+
- RBAC or ABAC patterns
|
|
228
|
+
- Check permissions server-side always
|
|
229
|
+
- Deny by default, allow explicitly
|
|
230
|
+
|
|
231
|
+
## Data Protection
|
|
232
|
+
- Sanitize all user inputs
|
|
233
|
+
- Escape outputs by context (HTML, SQL, etc.)
|
|
234
|
+
- Never log sensitive data (passwords, tokens, PII)
|
|
235
|
+
|
|
236
|
+
## OWASP Top 10
|
|
237
|
+
- Validate content types
|
|
238
|
+
- CSRF tokens for state-changing operations
|
|
239
|
+
- Security headers (CSP, HSTS, X-Frame-Options)
|
|
240
|
+
`,
|
|
241
|
+
|
|
242
|
+
'database.instructions.md': `---
|
|
243
|
+
applyTo: "**/prisma/**,**/*.sql,**/migrations/**,**/schema.*,**/db/**"
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
# Database Guidelines
|
|
247
|
+
|
|
248
|
+
## Schema Design
|
|
249
|
+
- UUID or ULID for primary keys
|
|
250
|
+
- Timestamps: createdAt, updatedAt on all tables
|
|
251
|
+
- Soft delete with deletedAt when needed
|
|
252
|
+
|
|
253
|
+
## Queries
|
|
254
|
+
- Use parameterized queries only (never string concat)
|
|
255
|
+
- Select only needed fields
|
|
256
|
+
- Use cursor-based pagination for large datasets
|
|
257
|
+
|
|
258
|
+
## Prisma
|
|
259
|
+
- Use transactions for multi-table operations
|
|
260
|
+
- Define indexes for frequently queried fields
|
|
261
|
+
- Use \`@map\` and \`@@map\` for legacy schemas
|
|
262
|
+
|
|
263
|
+
## Migrations
|
|
264
|
+
- One migration per feature
|
|
265
|
+
- Never modify already-applied migrations
|
|
266
|
+
- Test migrations on copy of production data
|
|
267
|
+
`
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
for (const [filename, content] of Object.entries(instructions)) {
|
|
271
|
+
await fs.writeFile(path.join(instructionsDir, filename), content);
|
|
272
|
+
}
|
|
411
273
|
}
|
|
412
274
|
|
|
413
275
|
function generateCopilotInstructions(config) {
|
|
414
276
|
return `# GitHub Copilot Instructions
|
|
415
277
|
|
|
416
|
-
> **Copilot Kit
|
|
417
|
-
|
|
278
|
+
> **Copilot Kit v2** - Project: ${config.projectName}
|
|
279
|
+
|
|
280
|
+
## 🤖 Agent System
|
|
281
|
+
|
|
282
|
+
This project uses specialized AI agents located in \`.github/agents/\`.
|
|
283
|
+
|
|
284
|
+
### Available Agents
|
|
285
|
+
|
|
286
|
+
| Agent | Specialty |
|
|
287
|
+
|-------|-----------|
|
|
288
|
+
| orchestrator | Multi-agent coordination, complex tasks |
|
|
289
|
+
| frontend-specialist | React, Next.js, CSS, accessibility |
|
|
290
|
+
| backend-specialist | Node.js, Python, APIs, microservices |
|
|
291
|
+
| database-architect | Schema design, SQL, Prisma, migrations |
|
|
292
|
+
| security-auditor | OWASP, auth, vulnerability analysis |
|
|
293
|
+
| test-engineer | Testing strategies, coverage, TDD |
|
|
294
|
+
| debugger | Troubleshooting, root cause analysis |
|
|
295
|
+
| devops-engineer | CI/CD, Docker, Kubernetes, infrastructure |
|
|
296
|
+
| performance-optimizer | Web vitals, profiling, optimization |
|
|
297
|
+
| documentation-writer | Technical docs, API documentation |
|
|
298
|
+
|
|
299
|
+
### How to Use Agents
|
|
300
|
+
|
|
301
|
+
To invoke an agent, reference it in your prompt:
|
|
302
|
+
- "Use the **orchestrator** to plan this feature"
|
|
303
|
+
- "Ask the **security-auditor** to review this code"
|
|
304
|
+
- "Have the **debugger** analyze this error"
|
|
305
|
+
|
|
306
|
+
## 📋 Language Instructions
|
|
307
|
+
|
|
308
|
+
Context-specific rules are in \`.github/instructions/\`:
|
|
309
|
+
- \`typescript.instructions.md\` - TS/TSX files
|
|
310
|
+
- \`python.instructions.md\` - Python files
|
|
311
|
+
- \`security.instructions.md\` - Auth/security code
|
|
312
|
+
- \`database.instructions.md\` - Database/Prisma code
|
|
418
313
|
|
|
419
|
-
##
|
|
314
|
+
## 🔧 MCP Servers
|
|
420
315
|
|
|
421
|
-
|
|
422
|
-
|
|
316
|
+
Configured in \`.vscode/mcp.json\`:
|
|
317
|
+
- **filesystem** - File system access
|
|
318
|
+
- **memory** - Persistent memory across sessions
|
|
423
319
|
|
|
424
|
-
|
|
425
|
-
- **Agents:** \`.agent/agents/\` (Specialist personas)
|
|
426
|
-
- **Skills:** \`.agent/skills/\` (Capabilities)
|
|
427
|
-
- **Workflows:** \`.agent/workflows/\` (Procedures)
|
|
428
|
-
- **Scripts:** \`.agent/scripts/\` (Tools)
|
|
320
|
+
## 🚀 Workflows
|
|
429
321
|
|
|
430
|
-
|
|
322
|
+
Workflow templates in \`.github/copilot-workflows/\`:
|
|
323
|
+
- \`/create\` - Scaffold new features
|
|
324
|
+
- \`/debug\` - Systematic debugging
|
|
325
|
+
- \`/test\` - Generate test suites
|
|
326
|
+
- \`/plan\` - Architecture planning
|
|
431
327
|
|
|
432
|
-
|
|
433
|
-
Always read \`.agent/rules/GEMINI.md\` first.
|
|
328
|
+
## 📝 General Guidelines
|
|
434
329
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
330
|
+
1. **Read before writing** - Understand existing patterns
|
|
331
|
+
2. **Small, focused changes** - One concern per commit
|
|
332
|
+
3. **Test coverage** - Write tests for new features
|
|
333
|
+
4. **Security first** - Validate inputs, sanitize outputs
|
|
438
334
|
`;
|
|
439
335
|
}
|
|
440
336
|
|