cp-toolkit 2.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 (196) hide show
  1. package/README.md +130 -0
  2. package/bin/cp-kit.js +72 -0
  3. package/package.json +46 -0
  4. package/src/commands/add.js +212 -0
  5. package/src/commands/doctor.js +149 -0
  6. package/src/commands/init.js +662 -0
  7. package/src/commands/list.js +128 -0
  8. package/src/index.js +13 -0
  9. package/templates/agents/backend-specialist.md +263 -0
  10. package/templates/agents/code-archaeologist.md +106 -0
  11. package/templates/agents/database-architect.md +226 -0
  12. package/templates/agents/debugger.md +225 -0
  13. package/templates/agents/devops-engineer.md +242 -0
  14. package/templates/agents/documentation-writer.md +104 -0
  15. package/templates/agents/explorer-agent.md +73 -0
  16. package/templates/agents/frontend-specialist.md +556 -0
  17. package/templates/agents/game-developer.md +162 -0
  18. package/templates/agents/mobile-developer.md +377 -0
  19. package/templates/agents/orchestrator.md +416 -0
  20. package/templates/agents/penetration-tester.md +188 -0
  21. package/templates/agents/performance-optimizer.md +187 -0
  22. package/templates/agents/product-manager.md +112 -0
  23. package/templates/agents/product-owner.md +95 -0
  24. package/templates/agents/project-planner.md +406 -0
  25. package/templates/agents/qa-automation-engineer.md +103 -0
  26. package/templates/agents/security-auditor.md +170 -0
  27. package/templates/agents/seo-specialist.md +111 -0
  28. package/templates/agents/test-engineer.md +158 -0
  29. package/templates/github/agents/backend-specialist.md +67 -0
  30. package/templates/github/agents/code-archaeologist.md +61 -0
  31. package/templates/github/agents/database-architect.md +73 -0
  32. package/templates/github/agents/debugger.md +71 -0
  33. package/templates/github/agents/devops-engineer.md +85 -0
  34. package/templates/github/agents/documentation-writer.md +107 -0
  35. package/templates/github/agents/explorer-agent.md +87 -0
  36. package/templates/github/agents/frontend-specialist.md +54 -0
  37. package/templates/github/agents/game-developer.md +94 -0
  38. package/templates/github/agents/mobile-developer.md +75 -0
  39. package/templates/github/agents/orchestrator.md +48 -0
  40. package/templates/github/agents/penetration-tester.md +87 -0
  41. package/templates/github/agents/performance-optimizer.md +70 -0
  42. package/templates/github/agents/product-manager.md +85 -0
  43. package/templates/github/agents/product-owner.md +77 -0
  44. package/templates/github/agents/project-planner.md +83 -0
  45. package/templates/github/agents/qa-automation-engineer.md +95 -0
  46. package/templates/github/agents/security-auditor.md +72 -0
  47. package/templates/github/agents/seo-specialist.md +78 -0
  48. package/templates/github/agents/test-engineer.md +79 -0
  49. package/templates/github/instructions/database.instructions.md +74 -0
  50. package/templates/github/instructions/python.instructions.md +76 -0
  51. package/templates/github/instructions/security.instructions.md +73 -0
  52. package/templates/github/instructions/typescript.instructions.md +50 -0
  53. package/templates/rules/GEMINI.md +273 -0
  54. package/templates/scripts/mcp-server.js +704 -0
  55. package/templates/skills/core/behavioral-modes/SKILL.md +242 -0
  56. package/templates/skills/core/brainstorming/SKILL.md +163 -0
  57. package/templates/skills/core/brainstorming/dynamic-questioning.md +350 -0
  58. package/templates/skills/core/clean-code/SKILL.md +201 -0
  59. package/templates/skills/core/intelligent-routing/SKILL.md +335 -0
  60. package/templates/skills/core/mcp-builder/SKILL.md +176 -0
  61. package/templates/skills/core/parallel-agents/SKILL.md +175 -0
  62. package/templates/skills/core/plan-writing/SKILL.md +152 -0
  63. package/templates/skills/optional/api-patterns/SKILL.md +81 -0
  64. package/templates/skills/optional/api-patterns/api-style.md +42 -0
  65. package/templates/skills/optional/api-patterns/auth.md +24 -0
  66. package/templates/skills/optional/api-patterns/documentation.md +26 -0
  67. package/templates/skills/optional/api-patterns/graphql.md +41 -0
  68. package/templates/skills/optional/api-patterns/rate-limiting.md +31 -0
  69. package/templates/skills/optional/api-patterns/response.md +37 -0
  70. package/templates/skills/optional/api-patterns/rest.md +40 -0
  71. package/templates/skills/optional/api-patterns/scripts/api_validator.py +211 -0
  72. package/templates/skills/optional/api-patterns/security-testing.md +122 -0
  73. package/templates/skills/optional/api-patterns/trpc.md +41 -0
  74. package/templates/skills/optional/api-patterns/versioning.md +22 -0
  75. package/templates/skills/optional/app-builder/SKILL.md +75 -0
  76. package/templates/skills/optional/app-builder/agent-coordination.md +71 -0
  77. package/templates/skills/optional/app-builder/feature-building.md +53 -0
  78. package/templates/skills/optional/app-builder/project-detection.md +34 -0
  79. package/templates/skills/optional/app-builder/scaffolding.md +118 -0
  80. package/templates/skills/optional/app-builder/tech-stack.md +40 -0
  81. package/templates/skills/optional/app-builder/templates/SKILL.md +39 -0
  82. package/templates/skills/optional/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  83. package/templates/skills/optional/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  84. package/templates/skills/optional/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  85. package/templates/skills/optional/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  86. package/templates/skills/optional/app-builder/templates/express-api/TEMPLATE.md +83 -0
  87. package/templates/skills/optional/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  88. package/templates/skills/optional/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  89. package/templates/skills/optional/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
  90. package/templates/skills/optional/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
  91. package/templates/skills/optional/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
  92. package/templates/skills/optional/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
  93. package/templates/skills/optional/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  94. package/templates/skills/optional/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
  95. package/templates/skills/optional/architecture/SKILL.md +55 -0
  96. package/templates/skills/optional/architecture/context-discovery.md +43 -0
  97. package/templates/skills/optional/architecture/examples.md +94 -0
  98. package/templates/skills/optional/architecture/pattern-selection.md +68 -0
  99. package/templates/skills/optional/architecture/patterns-reference.md +50 -0
  100. package/templates/skills/optional/architecture/trade-off-analysis.md +77 -0
  101. package/templates/skills/optional/bash-linux/SKILL.md +199 -0
  102. package/templates/skills/optional/code-review-checklist/SKILL.md +109 -0
  103. package/templates/skills/optional/database-design/SKILL.md +52 -0
  104. package/templates/skills/optional/database-design/database-selection.md +43 -0
  105. package/templates/skills/optional/database-design/indexing.md +39 -0
  106. package/templates/skills/optional/database-design/migrations.md +48 -0
  107. package/templates/skills/optional/database-design/optimization.md +36 -0
  108. package/templates/skills/optional/database-design/orm-selection.md +30 -0
  109. package/templates/skills/optional/database-design/schema-design.md +56 -0
  110. package/templates/skills/optional/database-design/scripts/schema_validator.py +172 -0
  111. package/templates/skills/optional/deployment-procedures/SKILL.md +241 -0
  112. package/templates/skills/optional/documentation-templates/SKILL.md +194 -0
  113. package/templates/skills/optional/frontend-design/SKILL.md +418 -0
  114. package/templates/skills/optional/frontend-design/animation-guide.md +331 -0
  115. package/templates/skills/optional/frontend-design/color-system.md +311 -0
  116. package/templates/skills/optional/frontend-design/decision-trees.md +418 -0
  117. package/templates/skills/optional/frontend-design/motion-graphics.md +306 -0
  118. package/templates/skills/optional/frontend-design/scripts/accessibility_checker.py +183 -0
  119. package/templates/skills/optional/frontend-design/scripts/ux_audit.py +722 -0
  120. package/templates/skills/optional/frontend-design/typography-system.md +345 -0
  121. package/templates/skills/optional/frontend-design/ux-psychology.md +541 -0
  122. package/templates/skills/optional/frontend-design/visual-effects.md +383 -0
  123. package/templates/skills/optional/game-development/2d-games/SKILL.md +119 -0
  124. package/templates/skills/optional/game-development/3d-games/SKILL.md +135 -0
  125. package/templates/skills/optional/game-development/SKILL.md +167 -0
  126. package/templates/skills/optional/game-development/game-art/SKILL.md +185 -0
  127. package/templates/skills/optional/game-development/game-audio/SKILL.md +190 -0
  128. package/templates/skills/optional/game-development/game-design/SKILL.md +129 -0
  129. package/templates/skills/optional/game-development/mobile-games/SKILL.md +108 -0
  130. package/templates/skills/optional/game-development/multiplayer/SKILL.md +132 -0
  131. package/templates/skills/optional/game-development/pc-games/SKILL.md +144 -0
  132. package/templates/skills/optional/game-development/vr-ar/SKILL.md +123 -0
  133. package/templates/skills/optional/game-development/web-games/SKILL.md +150 -0
  134. package/templates/skills/optional/geo-fundamentals/SKILL.md +156 -0
  135. package/templates/skills/optional/geo-fundamentals/scripts/geo_checker.py +289 -0
  136. package/templates/skills/optional/i18n-localization/SKILL.md +154 -0
  137. package/templates/skills/optional/i18n-localization/scripts/i18n_checker.py +241 -0
  138. package/templates/skills/optional/lint-and-validate/SKILL.md +45 -0
  139. package/templates/skills/optional/lint-and-validate/scripts/lint_runner.py +172 -0
  140. package/templates/skills/optional/lint-and-validate/scripts/type_coverage.py +173 -0
  141. package/templates/skills/optional/mobile-design/SKILL.md +394 -0
  142. package/templates/skills/optional/mobile-design/decision-trees.md +516 -0
  143. package/templates/skills/optional/mobile-design/mobile-backend.md +491 -0
  144. package/templates/skills/optional/mobile-design/mobile-color-system.md +420 -0
  145. package/templates/skills/optional/mobile-design/mobile-debugging.md +122 -0
  146. package/templates/skills/optional/mobile-design/mobile-design-thinking.md +357 -0
  147. package/templates/skills/optional/mobile-design/mobile-navigation.md +458 -0
  148. package/templates/skills/optional/mobile-design/mobile-performance.md +767 -0
  149. package/templates/skills/optional/mobile-design/mobile-testing.md +356 -0
  150. package/templates/skills/optional/mobile-design/mobile-typography.md +433 -0
  151. package/templates/skills/optional/mobile-design/platform-android.md +666 -0
  152. package/templates/skills/optional/mobile-design/platform-ios.md +561 -0
  153. package/templates/skills/optional/mobile-design/scripts/mobile_audit.py +670 -0
  154. package/templates/skills/optional/mobile-design/touch-psychology.md +537 -0
  155. package/templates/skills/optional/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
  156. package/templates/skills/optional/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
  157. package/templates/skills/optional/nextjs-react-expert/3-server-server-side-performance.md +490 -0
  158. package/templates/skills/optional/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
  159. package/templates/skills/optional/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
  160. package/templates/skills/optional/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
  161. package/templates/skills/optional/nextjs-react-expert/7-js-javascript-performance.md +684 -0
  162. package/templates/skills/optional/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
  163. package/templates/skills/optional/nextjs-react-expert/SKILL.md +267 -0
  164. package/templates/skills/optional/nextjs-react-expert/scripts/convert_rules.py +222 -0
  165. package/templates/skills/optional/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
  166. package/templates/skills/optional/nodejs-best-practices/SKILL.md +333 -0
  167. package/templates/skills/optional/performance-profiling/SKILL.md +143 -0
  168. package/templates/skills/optional/performance-profiling/scripts/lighthouse_audit.py +76 -0
  169. package/templates/skills/optional/powershell-windows/SKILL.md +167 -0
  170. package/templates/skills/optional/python-patterns/SKILL.md +441 -0
  171. package/templates/skills/optional/red-team-tactics/SKILL.md +199 -0
  172. package/templates/skills/optional/seo-fundamentals/SKILL.md +129 -0
  173. package/templates/skills/optional/seo-fundamentals/scripts/seo_checker.py +219 -0
  174. package/templates/skills/optional/server-management/SKILL.md +161 -0
  175. package/templates/skills/optional/systematic-debugging/SKILL.md +109 -0
  176. package/templates/skills/optional/tailwind-patterns/SKILL.md +269 -0
  177. package/templates/skills/optional/tdd-workflow/SKILL.md +149 -0
  178. package/templates/skills/optional/testing-patterns/SKILL.md +178 -0
  179. package/templates/skills/optional/testing-patterns/scripts/test_runner.py +219 -0
  180. package/templates/skills/optional/vulnerability-scanner/SKILL.md +276 -0
  181. package/templates/skills/optional/vulnerability-scanner/checklists.md +121 -0
  182. package/templates/skills/optional/vulnerability-scanner/scripts/security_scan.py +458 -0
  183. package/templates/skills/optional/web-design-guidelines/SKILL.md +57 -0
  184. package/templates/skills/optional/webapp-testing/SKILL.md +187 -0
  185. package/templates/skills/optional/webapp-testing/scripts/playwright_runner.py +173 -0
  186. package/templates/workflows/brainstorm.md +113 -0
  187. package/templates/workflows/create.md +59 -0
  188. package/templates/workflows/debug.md +103 -0
  189. package/templates/workflows/deploy.md +176 -0
  190. package/templates/workflows/enhance.md +63 -0
  191. package/templates/workflows/orchestrate.md +237 -0
  192. package/templates/workflows/plan.md +89 -0
  193. package/templates/workflows/preview.md +81 -0
  194. package/templates/workflows/status.md +86 -0
  195. package/templates/workflows/test.md +144 -0
  196. package/templates/workflows/ui-ux-pro-max.md +296 -0
@@ -0,0 +1,662 @@
1
+ /**
2
+ * cp-kit init command
3
+ *
4
+ * Initializes Copilot Kit with GitHub Copilot 2026 standard structure.
5
+ * Primary structure: .github/ (GitHub Copilot native)
6
+ */
7
+
8
+ import fs from 'fs-extra';
9
+ import path from 'path';
10
+ import chalk from 'chalk';
11
+ import ora from 'ora';
12
+ import prompts from 'prompts';
13
+
14
+ // Template definitions - All 20 agents
15
+ const TEMPLATE_AGENTS = [
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
+ };
260
+
261
+ export async function initCommand(directory, options) {
262
+ const targetDir = directory ? path.resolve(directory) : process.cwd();
263
+ const dirName = path.basename(targetDir);
264
+
265
+ console.log(chalk.bold.cyan('\n🚀 cp-kit - GitHub Copilot Agent Toolkit\n'));
266
+
267
+ // Create directory if needed
268
+ if (directory && !fs.existsSync(targetDir)) {
269
+ fs.mkdirSync(targetDir, { recursive: true });
270
+ console.log(chalk.green(`📁 Created directory: ${dirName}`));
271
+ }
272
+
273
+ // Check for existing configuration
274
+ const githubDir = path.join(targetDir, '.github');
275
+ const copilotFile = path.join(githubDir, 'copilot-instructions.md');
276
+
277
+ if (fs.existsSync(copilotFile) && !options.force) {
278
+ const { overwrite } = await prompts({
279
+ type: 'confirm',
280
+ name: 'overwrite',
281
+ message: 'cp-kit already initialized. Overwrite?',
282
+ initial: false
283
+ });
284
+
285
+ if (!overwrite) {
286
+ console.log(chalk.yellow('⚠️ Aborted. Use --force to overwrite.'));
287
+ return;
288
+ }
289
+ }
290
+
291
+ // Interactive configuration - defaults include ALL agents and languages
292
+ const ALL_AGENT_NAMES = TEMPLATE_AGENTS.map(a => a.name);
293
+ const ALL_LANGUAGES = ['typescript', 'python', 'react'];
294
+
295
+ let config = {
296
+ projectName: dirName,
297
+ projectType: 'app',
298
+ languages: ALL_LANGUAGES,
299
+ agents: ALL_AGENT_NAMES,
300
+ includeMcp: true
301
+ };
302
+
303
+ if (!options.yes) {
304
+ const response = await prompts([
305
+ {
306
+ type: 'text',
307
+ name: 'projectName',
308
+ message: 'Project name:',
309
+ initial: dirName
310
+ },
311
+ {
312
+ type: 'select',
313
+ name: 'projectType',
314
+ message: 'Project type:',
315
+ choices: [
316
+ { title: 'Single App', value: 'app' },
317
+ { title: 'Monorepo', value: 'monorepo' },
318
+ { title: 'Library/Package', value: 'library' },
319
+ { title: 'API Only', value: 'api' }
320
+ ],
321
+ initial: 0
322
+ },
323
+ {
324
+ type: 'multiselect',
325
+ name: 'languages',
326
+ message: 'Languages used:',
327
+ choices: [
328
+ { title: 'TypeScript', value: 'typescript', selected: true },
329
+ { title: 'Python', value: 'python', selected: true },
330
+ { title: 'React/JSX', value: 'react', selected: true }
331
+ ],
332
+ min: 1
333
+ },
334
+ {
335
+ type: 'multiselect',
336
+ name: 'agents',
337
+ message: 'Select agents:',
338
+ choices: TEMPLATE_AGENTS.map(a => ({
339
+ title: `${a.name} - ${a.description}`,
340
+ value: a.name,
341
+ selected: true // All agents selected by default
342
+ })),
343
+ min: 1
344
+ },
345
+ {
346
+ type: 'confirm',
347
+ name: 'includeMcp',
348
+ message: 'Include MCP server configuration?',
349
+ initial: true
350
+ }
351
+ ]);
352
+
353
+ if (!response.projectName) {
354
+ console.log(chalk.yellow('Aborted.'));
355
+ return;
356
+ }
357
+
358
+ config = { ...config, ...response };
359
+ }
360
+
361
+ // Start installation
362
+ const spinner = ora('Creating cp-kit structure...').start();
363
+
364
+ try {
365
+ // Create .github structure
366
+ await fs.ensureDir(path.join(githubDir, 'agents'));
367
+ await fs.ensureDir(path.join(githubDir, 'instructions'));
368
+
369
+ spinner.text = 'Creating copilot-instructions.md...';
370
+
371
+ // Create main copilot-instructions.md
372
+ await fs.writeFile(copilotFile, generateCopilotInstructions(config));
373
+
374
+ spinner.text = 'Creating agents...';
375
+
376
+ // Create agents
377
+ for (const agentName of config.agents) {
378
+ const agent = TEMPLATE_AGENTS.find(a => a.name === agentName);
379
+ if (agent) {
380
+ await fs.writeFile(
381
+ path.join(githubDir, 'agents', `${agent.name}.md`),
382
+ generateAgentFile(agent)
383
+ );
384
+ }
385
+ }
386
+
387
+ spinner.text = 'Creating instructions...';
388
+
389
+ // Create instructions based on languages
390
+ const instructionsToCreate = new Set(['security', 'database']);
391
+ config.languages.forEach(lang => {
392
+ instructionsToCreate.add(lang);
393
+ if (lang === 'react') instructionsToCreate.add('typescript');
394
+ });
395
+
396
+ for (const instrName of instructionsToCreate) {
397
+ const instr = TEMPLATE_INSTRUCTIONS[instrName];
398
+ if (instr) {
399
+ await fs.writeFile(
400
+ path.join(githubDir, 'instructions', `${instrName}.instructions.md`),
401
+ `---\napplyTo: "${instr.applyTo}"\n---\n\n${instr.content}\n`
402
+ );
403
+ }
404
+ }
405
+
406
+ spinner.text = 'Creating AGENTS.md...';
407
+
408
+ // Create AGENTS.md at root
409
+ await fs.writeFile(path.join(targetDir, 'AGENTS.md'), generateAgentsMd(config));
410
+
411
+ // Create MCP configuration if requested
412
+ if (config.includeMcp) {
413
+ spinner.text = 'Setting up MCP...';
414
+ await fs.ensureDir(path.join(targetDir, '.vscode'));
415
+ await fs.writeFile(
416
+ path.join(targetDir, '.vscode', 'mcp.json'),
417
+ JSON.stringify(generateMcpConfig(), null, 2)
418
+ );
419
+ }
420
+
421
+ spinner.succeed(chalk.green('cp-kit initialized successfully!'));
422
+
423
+ // Print summary
424
+ console.log('');
425
+ console.log(chalk.bold('📁 Created structure:'));
426
+ console.log(chalk.gray(''));
427
+ console.log(chalk.gray(' .github/'));
428
+ console.log(chalk.gray(' ├── copilot-instructions.md # Global instructions'));
429
+ console.log(chalk.gray(' ├── agents/'));
430
+ config.agents.forEach((a, i) => {
431
+ const prefix = i === config.agents.length - 1 ? '└──' : '├──';
432
+ console.log(chalk.gray(` │ ${prefix} ${a}.md`));
433
+ });
434
+ console.log(chalk.gray(' └── instructions/'));
435
+ const instrArray = Array.from(instructionsToCreate);
436
+ instrArray.forEach((i, idx) => {
437
+ const prefix = idx === instrArray.length - 1 ? '└──' : '├──';
438
+ console.log(chalk.gray(` ${prefix} ${i}.instructions.md`));
439
+ });
440
+ console.log(chalk.gray(''));
441
+ console.log(chalk.gray(' AGENTS.md # Universal AI instructions'));
442
+ if (config.includeMcp) {
443
+ console.log(chalk.gray(' .vscode/mcp.json # MCP configuration'));
444
+ }
445
+
446
+ console.log('');
447
+ console.log(chalk.green('✓ GitHub Copilot will automatically load these instructions'));
448
+ console.log('');
449
+ console.log(chalk.bold('Next steps:'));
450
+ console.log(chalk.cyan(' 1. Review .github/copilot-instructions.md'));
451
+ console.log(chalk.cyan(' 2. Add agents with: cp-kit add agent <name>'));
452
+ console.log(chalk.cyan(' 3. Verify setup with: cp-kit doctor'));
453
+ console.log('');
454
+
455
+ } catch (error) {
456
+ spinner.fail(chalk.red('Failed to initialize cp-kit'));
457
+ console.error(chalk.red(error.message));
458
+ process.exit(1);
459
+ }
460
+ }
461
+
462
+ function generateCopilotInstructions(config) {
463
+ const langList = config.languages.map(l => {
464
+ switch (l) {
465
+ case 'typescript': return '**TypeScript**: Strict mode, ESLint + Prettier';
466
+ case 'python': return '**Python**: Black formatter, type hints, PEP 8';
467
+ case 'react': return '**React**: Functional components, hooks, Testing Library';
468
+ default: return l;
469
+ }
470
+ }).join('\n- ');
471
+
472
+ return `# GitHub Copilot Instructions
473
+
474
+ > Repository-wide instructions for GitHub Copilot (2026 Standard)
475
+ > Generated by cp-kit v1.0.0
476
+
477
+ ## Project Context
478
+
479
+ **${config.projectName}** is a ${config.projectType} project.
480
+
481
+ ## Code Style
482
+
483
+ - ${langList}
484
+ - **Commits**: Conventional Commits format (\`feat:\`, \`fix:\`, \`docs:\`)
485
+
486
+ ## AI Agent Protocol
487
+
488
+ ### Available Agents
489
+
490
+ ${config.agents.map(a => {
491
+ const agent = TEMPLATE_AGENTS.find(t => t.name === a);
492
+ return `- **@${a}**: ${agent?.description || 'Specialist agent'}`;
493
+ }).join('\n')}
494
+
495
+ ### Invoking Agents
496
+
497
+ Use \`@agent-name\` in Copilot Chat:
498
+ \`\`\`
499
+ @frontend-specialist Create a responsive navbar component
500
+ @security-auditor Review this authentication flow
501
+ @orchestrator Implement user dashboard with API integration
502
+ \`\`\`
503
+
504
+ ### Behavioral Modes
505
+
506
+ | Mode | Trigger | Behavior |
507
+ |------|---------|----------|
508
+ | **BRAINSTORM** | "let's think", "options" | Explore ideas, no code |
509
+ | **IMPLEMENT** | "build", "create" | Production-ready code |
510
+ | **DEBUG** | "fix", "why", "error" | Root cause analysis |
511
+ | **REVIEW** | "review", "check" | Quality assessment |
512
+
513
+ ## Socratic Gate
514
+
515
+ For complex requests, **ASK before implementing**:
516
+ - What is the expected behavior?
517
+ - What are the edge cases?
518
+ - What are the dependencies?
519
+
520
+ ## File References
521
+
522
+ - Agent definitions: \`.github/agents/\`
523
+ - Path-specific rules: \`.github/instructions/\`
524
+ - Universal instructions: \`AGENTS.md\`
525
+ ${config.includeMcp ? `- MCP configuration: \`.vscode/mcp.json\`` : ''}
526
+
527
+ ## Do NOT
528
+
529
+ - Skip understanding context before coding
530
+ - Write code without identifying the domain
531
+ - Ignore the Socratic Gate for complex requests
532
+ - Use deprecated patterns without checking instructions
533
+ `;
534
+ }
535
+
536
+ function generateAgentFile(agent) {
537
+ return `---
538
+ name: ${agent.name}
539
+ description: ${agent.description}
540
+ ---
541
+
542
+ # ${agent.name}
543
+
544
+ > ${agent.description}
545
+
546
+ ## When to Use
547
+
548
+ Invoke this agent for:
549
+ ${agent.triggers.map(t => `- ${t} related tasks`).join('\n')}
550
+
551
+ ## Trigger Keywords
552
+
553
+ \`${agent.triggers.join('`, `')}\`
554
+
555
+ ## Skills
556
+
557
+ ${agent.skills.map(s => `- ${s}`).join('\n')}
558
+
559
+ ## Response Format
560
+
561
+ \`\`\`
562
+ 🤖 **Applying @${agent.name}...**
563
+
564
+ [specialized response following skill guidelines]
565
+ \`\`\`
566
+
567
+ ## Integration
568
+
569
+ This agent can collaborate with:
570
+ - \`@orchestrator\` for multi-domain coordination
571
+ - Other specialists via handoff protocol
572
+ `;
573
+ }
574
+
575
+ function generateAgentsMd(config) {
576
+ return `# AGENTS.md
577
+
578
+ > Universal Agent Instructions for AI Coding Assistants (2026 Standard)
579
+ > Generated by cp-kit v1.0.0
580
+
581
+ ---
582
+
583
+ ## 🏗️ Project Overview
584
+
585
+ **${config.projectName}** - ${config.projectType}
586
+
587
+ ### Technologies
588
+
589
+ ${config.languages.map(l => `- ${l.charAt(0).toUpperCase() + l.slice(1)}`).join('\n')}
590
+
591
+ ---
592
+
593
+ ## 🤖 AI Agent Protocol
594
+
595
+ ### Available Agents
596
+
597
+ | Agent | Domain | Triggers |
598
+ |-------|--------|----------|
599
+ ${config.agents.map(a => {
600
+ const agent = TEMPLATE_AGENTS.find(t => t.name === a);
601
+ return `| \`@${a}\` | ${agent?.description || '-'} | ${agent?.triggers.join(', ') || '-'} |`;
602
+ }).join('\n')}
603
+
604
+ ### Request Classification
605
+
606
+ | Type | Keywords | Action |
607
+ |------|----------|--------|
608
+ | **QUESTION** | "what is", "explain" | Text response only |
609
+ | **SIMPLE CODE** | "fix", "add" (single file) | Inline edit |
610
+ | **COMPLEX CODE** | "build", "create" | Use @orchestrator |
611
+ | **REVIEW** | "review", "check" | Quality assessment |
612
+
613
+ ### Behavioral Modes
614
+
615
+ | Mode | Behavior |
616
+ |------|----------|
617
+ | **BRAINSTORM** | Ask questions, explore options, no code |
618
+ | **IMPLEMENT** | Fast execution, production-ready code |
619
+ | **DEBUG** | Systematic investigation, root cause analysis |
620
+ | **REVIEW** | Code quality, security, performance check |
621
+
622
+ ---
623
+
624
+ ## 📂 Structure
625
+
626
+ \`\`\`
627
+ .github/
628
+ ├── copilot-instructions.md # Global instructions (always active)
629
+ ├── agents/ # Agent definitions
630
+ └── instructions/ # Path-specific rules
631
+ \`\`\`
632
+
633
+ ---
634
+
635
+ *Generated by [cp-kit](https://github.com/anthropics/cp-kit) v1.0.0*
636
+ `;
637
+ }
638
+
639
+ function generateMcpConfig() {
640
+ return {
641
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode/main/src/vs/workbench/contrib/mcp/browser/mcpConfigSchema.json",
642
+ servers: {
643
+ filesystem: {
644
+ type: "stdio",
645
+ command: "npx",
646
+ args: ["-y", "@anthropic-ai/mcp-server-filesystem@latest", "${workspaceFolder}"]
647
+ },
648
+ memory: {
649
+ type: "stdio",
650
+ command: "npx",
651
+ args: ["-y", "@anthropic-ai/mcp-server-memory@latest"]
652
+ },
653
+ sequentialThinking: {
654
+ type: "stdio",
655
+ command: "npx",
656
+ args: ["-y", "@anthropic-ai/mcp-server-sequential-thinking@latest"]
657
+ }
658
+ }
659
+ };
660
+ }
661
+
662
+ export default initCommand;