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
package/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # cp-toolkit
2
+
3
+ > GitHub Copilot Agent Toolkit - Initialize and manage AI agents for your project
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Global install
9
+ npm install -g cp-toolkit
10
+
11
+ # Or use with npx
12
+ npx cp-toolkit init
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ # Initialize in current directory
19
+ cp-kit init
20
+
21
+ # Initialize in new directory
22
+ cp-kit init my-project
23
+
24
+ # Skip prompts (use defaults)
25
+ cp-kit init -y
26
+ ```
27
+
28
+ ## Commands
29
+
30
+ ### `cp-kit init [directory]`
31
+
32
+ Initialize cp-kit with GitHub Copilot 2026 structure:
33
+
34
+ ```
35
+ .github/
36
+ ├── copilot-instructions.md # Global instructions (always active)
37
+ ├── agents/ # Agent definitions
38
+ │ ├── orchestrator.md
39
+ │ ├── frontend-specialist.md
40
+ │ └── backend-specialist.md
41
+ └── instructions/ # Path-specific rules
42
+ ├── typescript.instructions.md
43
+ ├── python.instructions.md
44
+ └── security.instructions.md
45
+
46
+ AGENTS.md # Universal AI instructions
47
+ .vscode/mcp.json # MCP server configuration
48
+ ```
49
+
50
+ Options:
51
+ - `-y, --yes` - Skip prompts, use defaults
52
+ - `-f, --force` - Overwrite existing configuration
53
+
54
+ ### `cp-kit add <type> <name>`
55
+
56
+ Add new components:
57
+
58
+ ```bash
59
+ # Add a new agent
60
+ cp-kit add agent my-specialist
61
+
62
+ # Add a new instruction
63
+ cp-kit add instruction golang
64
+ ```
65
+
66
+ ### `cp-kit list [type]`
67
+
68
+ List available components:
69
+
70
+ ```bash
71
+ cp-kit list agents # List all agents
72
+ cp-kit list instructions # List all instructions
73
+ cp-kit list all # List everything
74
+ ```
75
+
76
+ ### `cp-kit doctor`
77
+
78
+ Check configuration and diagnose issues:
79
+
80
+ ```bash
81
+ cp-kit doctor
82
+ ```
83
+
84
+ ## GitHub Copilot Integration
85
+
86
+ After initialization, GitHub Copilot automatically loads:
87
+
88
+ 1. **copilot-instructions.md** - Always active, global rules
89
+ 2. **agents/*.md** - Invokable with `@agent-name`
90
+ 3. **instructions/*.instructions.md** - Applied based on `applyTo` patterns
91
+
92
+ ### Using Agents
93
+
94
+ In GitHub Copilot Chat:
95
+
96
+ ```
97
+ @frontend-specialist Create a responsive navbar component
98
+ @security-auditor Review this authentication flow
99
+ @orchestrator Implement user dashboard with API
100
+ ```
101
+
102
+ ### Path-Specific Instructions
103
+
104
+ Instructions are applied automatically based on file patterns:
105
+
106
+ ```yaml
107
+ # typescript.instructions.md
108
+ ---
109
+ applyTo: "**/*.ts,**/*.tsx"
110
+ ---
111
+
112
+ ## TypeScript Guidelines
113
+ - Enable strict mode
114
+ - No any types
115
+ ...
116
+ ```
117
+
118
+ ## Structure
119
+
120
+ | File | Purpose |
121
+ |------|---------|
122
+ | `.github/copilot-instructions.md` | Global instructions (always active) |
123
+ | `.github/agents/*.md` | Agent definitions |
124
+ | `.github/instructions/*.instructions.md` | Path-specific rules |
125
+ | `AGENTS.md` | Universal AI instructions |
126
+ | `.vscode/mcp.json` | MCP server configuration |
127
+
128
+ ## License
129
+
130
+ MIT
package/bin/cp-kit.js ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * cp-kit - GitHub Copilot Agent Toolkit
5
+ *
6
+ * Initialize and manage AI agents for GitHub Copilot.
7
+ *
8
+ * Usage:
9
+ * npx cp-kit init # Initialize in current directory
10
+ * npx cp-kit init my-project # Initialize in new directory
11
+ * cp-kit add agent <name> # Add a new agent
12
+ * cp-kit add instruction <name># Add a new instruction
13
+ * cp-kit list agents # List available agents
14
+ * cp-kit list instructions # List available instructions
15
+ * cp-kit doctor # Check configuration
16
+ *
17
+ * @version 1.0.0
18
+ * @license MIT
19
+ */
20
+
21
+ import { Command } from 'commander';
22
+ import chalk from 'chalk';
23
+ import { initCommand } from '../src/commands/init.js';
24
+ import { addCommand } from '../src/commands/add.js';
25
+ import { listCommand } from '../src/commands/list.js';
26
+ import { doctorCommand } from '../src/commands/doctor.js';
27
+
28
+ const program = new Command();
29
+
30
+ program
31
+ .name('cp-kit')
32
+ .description('GitHub Copilot Agent Toolkit - Initialize AI agents for your project')
33
+ .version('1.0.0');
34
+
35
+ // cp-kit init [directory]
36
+ program
37
+ .command('init [directory]')
38
+ .description('Initialize cp-kit in a directory (creates .github/ structure)')
39
+ .option('-y, --yes', 'Skip prompts and use defaults')
40
+ .option('-f, --force', 'Overwrite existing configuration')
41
+ .action(initCommand);
42
+
43
+ // cp-kit add <type> <name>
44
+ program
45
+ .command('add <type> <name>')
46
+ .description('Add a new agent or instruction')
47
+ .option('-t, --template <template>', 'Use a specific template')
48
+ .action(addCommand);
49
+
50
+ // cp-kit list [type]
51
+ program
52
+ .command('list [type]')
53
+ .description('List available agents or instructions')
54
+ .action((type = 'all') => listCommand(type));
55
+
56
+ // cp-kit doctor
57
+ program
58
+ .command('doctor')
59
+ .description('Check cp-kit configuration and diagnose issues')
60
+ .action(doctorCommand);
61
+
62
+ // Show help if no command provided
63
+ if (process.argv.length === 2) {
64
+ console.log('');
65
+ console.log(chalk.bold.cyan(' 🤖 cp-kit - GitHub Copilot Agent Toolkit'));
66
+ console.log('');
67
+ console.log(chalk.gray(' Initialize AI agents and instructions for GitHub Copilot'));
68
+ console.log('');
69
+ program.outputHelp();
70
+ }
71
+
72
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "cp-toolkit",
3
+ "version": "2.0.0",
4
+ "description": "Copilot Toolkit - AI Agent framework for GitHub Copilot, Claude, Gemini CLI, and other AI assistants",
5
+ "keywords": [
6
+ "ai-agents",
7
+ "github-copilot",
8
+ "copilot",
9
+ "gemini-cli",
10
+ "claude",
11
+ "mcp",
12
+ "model-context-protocol",
13
+ "agent-toolkit"
14
+ ],
15
+ "author": "NuvemTalk",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/gensart-projs/cp-kit"
20
+ },
21
+ "type": "module",
22
+ "bin": {
23
+ "cp-kit": "./bin/cp-kit.js"
24
+ },
25
+ "main": "./src/index.js",
26
+ "files": [
27
+ "bin",
28
+ "src",
29
+ "templates",
30
+ "README.md"
31
+ ],
32
+ "scripts": {
33
+ "test": "node --test src/**/*.test.js",
34
+ "start": "node bin/cp-kit.js"
35
+ },
36
+ "dependencies": {
37
+ "commander": "^12.0.0",
38
+ "chalk": "^5.3.0",
39
+ "ora": "^8.0.0",
40
+ "prompts": "^2.4.2",
41
+ "fs-extra": "^11.2.0"
42
+ },
43
+ "engines": {
44
+ "node": ">=20.0.0"
45
+ }
46
+ }
@@ -0,0 +1,212 @@
1
+ /**
2
+ * cp-kit add command
3
+ *
4
+ * Add new agents or instructions to a cp-kit project.
5
+ */
6
+
7
+ import fs from 'fs-extra';
8
+ import path from 'path';
9
+ import chalk from 'chalk';
10
+ import prompts from 'prompts';
11
+
12
+ const AGENT_TEMPLATES = {
13
+ specialist: (name, description, triggers) => `---
14
+ name: ${name}
15
+ description: ${description}
16
+ ---
17
+
18
+ # ${name}
19
+
20
+ > ${description}
21
+
22
+ ## When to Use
23
+
24
+ Invoke this agent for:
25
+ ${triggers.map(t => `- ${t} related tasks`).join('\n')}
26
+
27
+ ## Trigger Keywords
28
+
29
+ \`${triggers.join('`, `')}\`
30
+
31
+ ## Response Format
32
+
33
+ \`\`\`
34
+ 🤖 **Applying @${name}...**
35
+
36
+ [specialized response]
37
+ \`\`\`
38
+ `,
39
+ reviewer: (name, description, triggers) => `---
40
+ name: ${name}
41
+ description: ${description}
42
+ ---
43
+
44
+ # ${name}
45
+
46
+ > ${description}
47
+
48
+ ## Review Checklist
49
+
50
+ - [ ] Code follows project conventions
51
+ - [ ] No security vulnerabilities
52
+ - [ ] Adequate test coverage
53
+ - [ ] Performance considerations
54
+ - [ ] Documentation updated
55
+
56
+ ## Trigger Keywords
57
+
58
+ \`${triggers.join('`, `')}\`
59
+
60
+ ## Response Format
61
+
62
+ \`\`\`
63
+ 🔍 **Review by @${name}**
64
+
65
+ ### Summary
66
+ [brief overview]
67
+
68
+ ### Issues Found
69
+ [list with severity]
70
+
71
+ ### Recommendations
72
+ [suggested improvements]
73
+ \`\`\`
74
+ `
75
+ };
76
+
77
+ export async function addCommand(type, name, options) {
78
+ const targetDir = process.cwd();
79
+
80
+ // Validate type
81
+ const validTypes = ['agent', 'instruction'];
82
+ if (!validTypes.includes(type)) {
83
+ console.log(chalk.red(`❌ Unknown type: ${type}`));
84
+ console.log(chalk.dim(` Valid types: ${validTypes.join(', ')}`));
85
+ return;
86
+ }
87
+
88
+ // Check if cp-kit is initialized
89
+ const githubDir = path.join(targetDir, '.github');
90
+ if (!fs.existsSync(path.join(githubDir, 'copilot-instructions.md'))) {
91
+ console.log(chalk.red('❌ cp-kit not initialized.'));
92
+ console.log(chalk.dim(' Run: cp-kit init'));
93
+ return;
94
+ }
95
+
96
+ console.log(chalk.bold.cyan(`\n➕ Adding ${type}: ${name}\n`));
97
+
98
+ switch (type) {
99
+ case 'agent':
100
+ await addAgent(githubDir, name, options);
101
+ break;
102
+ case 'instruction':
103
+ await addInstruction(githubDir, name, options);
104
+ break;
105
+ }
106
+ }
107
+
108
+ async function addAgent(githubDir, name, options) {
109
+ const agentFile = path.join(githubDir, 'agents', `${name}.md`);
110
+
111
+ if (fs.existsSync(agentFile)) {
112
+ console.log(chalk.yellow(`⚠️ Agent "${name}" already exists.`));
113
+ return;
114
+ }
115
+
116
+ const response = await prompts([
117
+ {
118
+ type: 'text',
119
+ name: 'description',
120
+ message: 'Agent description:',
121
+ initial: `${name} specialist agent`
122
+ },
123
+ {
124
+ type: 'text',
125
+ name: 'triggers',
126
+ message: 'Trigger keywords (comma-separated):',
127
+ initial: name.replace(/-/g, ', ')
128
+ },
129
+ {
130
+ type: 'select',
131
+ name: 'template',
132
+ message: 'Template:',
133
+ choices: [
134
+ { title: 'Specialist - General purpose', value: 'specialist' },
135
+ { title: 'Reviewer - Code review focus', value: 'reviewer' }
136
+ ]
137
+ }
138
+ ]);
139
+
140
+ if (!response.description) {
141
+ console.log(chalk.yellow('Aborted.'));
142
+ return;
143
+ }
144
+
145
+ const triggers = response.triggers.split(',').map(t => t.trim());
146
+ const content = AGENT_TEMPLATES[response.template](name, response.description, triggers);
147
+
148
+ await fs.ensureDir(path.dirname(agentFile));
149
+ await fs.writeFile(agentFile, content);
150
+
151
+ console.log(chalk.green(`✅ Created agent: .github/agents/${name}.md`));
152
+ console.log(chalk.dim(` Invoke with @${name} in Copilot Chat`));
153
+ }
154
+
155
+ async function addInstruction(githubDir, name, options) {
156
+ const instrFile = path.join(githubDir, 'instructions', `${name}.instructions.md`);
157
+
158
+ if (fs.existsSync(instrFile)) {
159
+ console.log(chalk.yellow(`⚠️ Instruction "${name}" already exists.`));
160
+ return;
161
+ }
162
+
163
+ const response = await prompts([
164
+ {
165
+ type: 'text',
166
+ name: 'applyTo',
167
+ message: 'Apply to files (glob pattern):',
168
+ initial: `**/*.${name},**/${name}/**`
169
+ },
170
+ {
171
+ type: 'text',
172
+ name: 'description',
173
+ message: 'Brief description:',
174
+ initial: `${name} coding guidelines`
175
+ }
176
+ ]);
177
+
178
+ if (!response.applyTo) {
179
+ console.log(chalk.yellow('Aborted.'));
180
+ return;
181
+ }
182
+
183
+ const content = `---
184
+ applyTo: "${response.applyTo}"
185
+ ---
186
+
187
+ ## ${name.charAt(0).toUpperCase() + name.slice(1)} Guidelines
188
+
189
+ > ${response.description}
190
+
191
+ ### Style
192
+ - Follow project conventions
193
+ - Consistent formatting
194
+ - Document public APIs
195
+
196
+ ### Patterns
197
+ - Use established patterns
198
+ - Avoid anti-patterns
199
+ - Consider maintainability
200
+
201
+ ### Best Practices
202
+ - [Add specific guidelines here]
203
+ `;
204
+
205
+ await fs.ensureDir(path.dirname(instrFile));
206
+ await fs.writeFile(instrFile, content);
207
+
208
+ console.log(chalk.green(`✅ Created instruction: .github/instructions/${name}.instructions.md`));
209
+ console.log(chalk.dim(` Will apply to: ${response.applyTo}`));
210
+ }
211
+
212
+ export default addCommand;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * cp-kit doctor command
3
+ *
4
+ * Diagnose cp-kit configuration and suggest fixes.
5
+ */
6
+
7
+ import fs from 'fs-extra';
8
+ import path from 'path';
9
+ import chalk from 'chalk';
10
+
11
+ const CHECKS = [
12
+ {
13
+ name: '.github/ directory exists',
14
+ check: async (dir) => fs.pathExists(path.join(dir, '.github')),
15
+ fix: 'Run: cp-kit init'
16
+ },
17
+ {
18
+ name: 'copilot-instructions.md exists',
19
+ check: async (dir) => fs.pathExists(path.join(dir, '.github', 'copilot-instructions.md')),
20
+ fix: 'Run: cp-kit init'
21
+ },
22
+ {
23
+ name: 'agents/ directory exists',
24
+ check: async (dir) => fs.pathExists(path.join(dir, '.github', 'agents')),
25
+ fix: 'Run: cp-kit init'
26
+ },
27
+ {
28
+ name: 'At least one agent defined',
29
+ check: async (dir) => {
30
+ const agentsDir = path.join(dir, '.github', 'agents');
31
+ if (!await fs.pathExists(agentsDir)) return false;
32
+ const files = await fs.readdir(agentsDir);
33
+ return files.some(f => f.endsWith('.md'));
34
+ },
35
+ fix: 'Run: cp-kit add agent <name>'
36
+ },
37
+ {
38
+ name: 'instructions/ directory exists',
39
+ check: async (dir) => fs.pathExists(path.join(dir, '.github', 'instructions')),
40
+ fix: 'Run: cp-kit init'
41
+ },
42
+ {
43
+ name: 'At least one instruction defined',
44
+ check: async (dir) => {
45
+ const instrDir = path.join(dir, '.github', 'instructions');
46
+ if (!await fs.pathExists(instrDir)) return false;
47
+ const files = await fs.readdir(instrDir);
48
+ return files.some(f => f.endsWith('.instructions.md'));
49
+ },
50
+ fix: 'Run: cp-kit add instruction <name>'
51
+ },
52
+ {
53
+ name: 'AGENTS.md exists at root',
54
+ check: async (dir) => fs.pathExists(path.join(dir, 'AGENTS.md')),
55
+ fix: 'Run: cp-kit init'
56
+ },
57
+ {
58
+ name: '.vscode/mcp.json exists',
59
+ check: async (dir) => fs.pathExists(path.join(dir, '.vscode', 'mcp.json')),
60
+ optional: true,
61
+ fix: 'Run: cp-kit init (with MCP option)'
62
+ },
63
+ {
64
+ name: 'Instructions have valid applyTo',
65
+ check: async (dir) => {
66
+ const instrDir = path.join(dir, '.github', 'instructions');
67
+ if (!await fs.pathExists(instrDir)) return true;
68
+ const files = await fs.readdir(instrDir);
69
+ for (const file of files.filter(f => f.endsWith('.instructions.md'))) {
70
+ const content = await fs.readFile(path.join(instrDir, file), 'utf-8');
71
+ if (!content.includes('applyTo:')) return false;
72
+ }
73
+ return true;
74
+ },
75
+ fix: 'Add applyTo frontmatter to instruction files'
76
+ },
77
+ {
78
+ name: 'Agents have valid frontmatter',
79
+ check: async (dir) => {
80
+ const agentsDir = path.join(dir, '.github', 'agents');
81
+ if (!await fs.pathExists(agentsDir)) return true;
82
+ const files = await fs.readdir(agentsDir);
83
+ for (const file of files.filter(f => f.endsWith('.md'))) {
84
+ const content = await fs.readFile(path.join(agentsDir, file), 'utf-8');
85
+ if (!content.startsWith('---')) return false;
86
+ if (!content.includes('name:')) return false;
87
+ }
88
+ return true;
89
+ },
90
+ fix: 'Add frontmatter with name: to agent files'
91
+ }
92
+ ];
93
+
94
+ export async function doctorCommand() {
95
+ const targetDir = process.cwd();
96
+
97
+ console.log('');
98
+ console.log(chalk.bold.cyan('🩺 cp-kit Doctor'));
99
+ console.log(chalk.gray('─'.repeat(50)));
100
+ console.log(chalk.gray(`Checking: ${targetDir}`));
101
+ console.log('');
102
+
103
+ let passed = 0;
104
+ let failed = 0;
105
+ let warnings = 0;
106
+
107
+ for (const check of CHECKS) {
108
+ try {
109
+ const result = await check.check(targetDir);
110
+
111
+ if (result) {
112
+ console.log(chalk.green(' ✓ ') + check.name);
113
+ passed++;
114
+ } else if (check.optional) {
115
+ console.log(chalk.yellow(' ⚠ ') + check.name + chalk.gray(' (optional)'));
116
+ warnings++;
117
+ } else {
118
+ console.log(chalk.red(' ✗ ') + check.name);
119
+ if (check.fix) {
120
+ console.log(chalk.gray(' ' + check.fix));
121
+ }
122
+ failed++;
123
+ }
124
+ } catch (error) {
125
+ console.log(chalk.red(' ✗ ') + check.name + chalk.gray(` (${error.message})`));
126
+ failed++;
127
+ }
128
+ }
129
+
130
+ console.log('');
131
+ console.log(chalk.gray('─'.repeat(50)));
132
+
133
+ if (failed === 0) {
134
+ if (warnings > 0) {
135
+ console.log(chalk.green.bold(`✓ All checks passed!`) + chalk.gray(` (${passed} passed, ${warnings} optional)`));
136
+ } else {
137
+ console.log(chalk.green.bold(`✓ All checks passed! (${passed}/${passed})`));
138
+ }
139
+ console.log('');
140
+ console.log(chalk.green('✨ cp-kit is healthy!'));
141
+ } else {
142
+ console.log(chalk.red.bold(`✗ ${failed} checks failed`) + chalk.gray(` (${passed} passed, ${warnings} optional)`));
143
+ console.log('');
144
+ console.log(chalk.yellow('Run suggested fixes above.'));
145
+ }
146
+ console.log('');
147
+ }
148
+
149
+ export default doctorCommand;