cp-toolkit 2.2.2 → 2.2.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/commands/init.js +356 -49
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cp-toolkit",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Copilot Toolkit - AI Agent framework for GitHub Copilot, Claude, Gemini CLI, and other AI assistants",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -207,7 +207,17 @@ export async function initCommand(directory, options) {
207
207
  console.log(chalk.dim(' .github/'));
208
208
  console.log(chalk.dim(' ├── agents/ ') + chalk.cyan('← 20 specialist agents'));
209
209
  console.log(chalk.dim(' ├── skills/ ') + chalk.cyan('← Essential skills library'));
210
- console.log(chalk.dim(' ├── instructions/ ') + chalk.cyan('← Language-specific rules'));
210
+ console.log(chalk.dim(' ├── instructions/ ') + chalk.cyan('← 10 specialized instruction files'));
211
+ console.log(chalk.dim(' │ ├── typescript-development.instructions.md'));
212
+ console.log(chalk.dim(' │ ├── javascript-development.instructions.md'));
213
+ console.log(chalk.dim(' │ ├── react-development.instructions.md'));
214
+ console.log(chalk.dim(' │ ├── nextjs-development.instructions.md'));
215
+ console.log(chalk.dim(' │ ├── python-development.instructions.md'));
216
+ console.log(chalk.dim(' │ ├── security-development.instructions.md'));
217
+ console.log(chalk.dim(' │ ├── database-development.instructions.md'));
218
+ console.log(chalk.dim(' │ ├── testing-development.instructions.md'));
219
+ console.log(chalk.dim(' │ ├── api-development.instructions.md'));
220
+ console.log(chalk.dim(' │ └── github-actions.instructions.md'));
211
221
  console.log(chalk.dim(' ├── copilot-workflows/') + chalk.cyan('← Workflow templates'));
212
222
  console.log(chalk.dim(' ├── scripts/ ') + chalk.cyan('← MCP server & utilities'));
213
223
  console.log(chalk.dim(' ├── rules/ ') + chalk.cyan('← Global AI rules'));
@@ -232,101 +242,392 @@ export async function initCommand(directory, options) {
232
242
 
233
243
  async function createInstructionFiles(instructionsDir) {
234
244
  const instructions = {
235
- 'typescript.instructions.md': `---
245
+ 'typescript-development.instructions.md': `---
236
246
  applyTo: "**/*.ts,**/*.tsx,**/*.mts,**/*.cts"
237
247
  ---
238
248
 
239
- # TypeScript Guidelines
249
+ # TypeScript Development Guidelines
240
250
 
241
- ## Strict Mode
251
+ ## Strict Mode & Type Safety
242
252
  - Enable \`strict: true\` in tsconfig.json
243
253
  - No \`any\` types - use \`unknown\` and narrow with type guards
244
254
  - Explicit return types for public functions
255
+ - Use \`strictNullChecks\` and \`noImplicitAny\`
245
256
 
246
- ## Patterns
257
+ ## Code Patterns
247
258
  - Prefer \`interface\` over \`type\` for object shapes
248
- - Use \`as const\` for literal types
249
- - Leverage discriminated unions for state
259
+ - Use \`as const\` for literal types and enums
260
+ - Leverage discriminated unions for state management
261
+ - Use mapped types for transformations
262
+ - Prefer \`readonly\` for immutable data
250
263
 
251
- ## Imports
264
+ ## Imports & Modules
252
265
  - Use type-only imports: \`import type { X } from 'y'\`
253
266
  - Barrel exports for public APIs only
267
+ - Avoid relative imports with \`../\` - use absolute paths
268
+
269
+ ## Error Handling
270
+ - Use custom error classes extending \`Error\`
271
+ - Prefer Result types over throwing exceptions
272
+ - Use try/catch only for external operations
273
+ `,
274
+
275
+ 'javascript-development.instructions.md': `---
276
+ applyTo: "**/*.js,**/*.mjs,**/*.cjs"
277
+ ---
278
+
279
+ # JavaScript Development Guidelines
280
+
281
+ ## ES6+ Features
282
+ - Use \`const\` and \`let\` instead of \`var\`
283
+ - Arrow functions for callbacks and anonymous functions
284
+ - Template literals over string concatenation
285
+ - Destructuring for objects and arrays
286
+ - Spread/rest operators for manipulation
287
+
288
+ ## Code Patterns
289
+ - Prefer functional programming approaches
290
+ - Use async/await over Promises for readability
291
+ - Implement proper error handling with try/catch
292
+ - Use Map/Set for collections when appropriate
293
+ - Leverage object destructuring for configuration
294
+
295
+ ## Best Practices
296
+ - Strict mode: \`'use strict'\` at file/module level
297
+ - Consistent naming: camelCase for variables/functions
298
+ - Meaningful variable names over abbreviations
299
+ - Single responsibility principle for functions
300
+
301
+ ## Performance
302
+ - Avoid global variables
303
+ - Use efficient algorithms and data structures
304
+ - Minimize DOM manipulation
305
+ - Cache expensive operations
254
306
  `,
255
307
 
256
- 'python.instructions.md': `---
308
+ 'react-development.instructions.md': `---
309
+ applyTo: "**/*.jsx,**/*.tsx,**/*react*"
310
+ ---
311
+
312
+ # React Development Guidelines
313
+
314
+ ## Component Patterns
315
+ - Functional components with hooks over class components
316
+ - Custom hooks for reusable logic
317
+ - Compound components for complex UI patterns
318
+ - Container/Presentational separation when appropriate
319
+
320
+ ## State Management
321
+ - useState for local component state
322
+ - useReducer for complex state logic
323
+ - Context API for theme/configuration
324
+ - External libraries (Zustand, Redux) for app-wide state
325
+
326
+ ## Performance
327
+ - React.memo for expensive components
328
+ - useMemo for expensive calculations
329
+ - useCallback for event handlers
330
+ - Lazy loading with React.lazy and Suspense
331
+ - Code splitting for large applications
332
+
333
+ ## Hooks Best Practices
334
+ - Custom hooks for side effects
335
+ - useEffect cleanup functions
336
+ - Dependency arrays correctly specified
337
+ - Avoid conditional hook calls
338
+
339
+ ## Accessibility
340
+ - Semantic HTML elements
341
+ - ARIA attributes when needed
342
+ - Keyboard navigation support
343
+ - Screen reader compatibility
344
+ `,
345
+
346
+ 'nextjs-development.instructions.md': `---
347
+ applyTo: "**/pages/**,**/app/**,**/components/**,**/lib/**,**/utils/**"
348
+ ---
349
+
350
+ # Next.js Development Guidelines
351
+
352
+ ## App Router (App Directory)
353
+ - Server Components by default
354
+ - Client Components with 'use client' directive
355
+ - Server Actions for form handling
356
+ - Route Groups for organization: (auth), (dashboard)
357
+
358
+ ## File Structure
359
+ - \`app/\` for routing and layouts
360
+ - \`components/\` for reusable UI
361
+ - \`lib/\` for utilities and configurations
362
+ - \`utils/\` for helper functions
363
+ - \`types/\` for TypeScript definitions
364
+
365
+ ## Data Fetching
366
+ - Server Components for initial data
367
+ - Client Components for interactive data
368
+ - SWR or React Query for client-side fetching
369
+ - Server Actions for mutations
370
+
371
+ ## Performance
372
+ - Image optimization with next/image
373
+ - Font optimization with next/font
374
+ - Code splitting automatic
375
+ - Static generation when possible
376
+ - ISR for dynamic content
377
+
378
+ ## SEO & Metadata
379
+ - Metadata API for dynamic meta tags
380
+ - Static metadata exports
381
+ - Open Graph and Twitter cards
382
+ - Structured data with JSON-LD
383
+ `,
384
+
385
+ 'python-development.instructions.md': `---
257
386
  applyTo: "**/*.py"
258
387
  ---
259
388
 
260
- # Python Guidelines
389
+ # Python Development Guidelines
261
390
 
262
- ## Type Hints
391
+ ## Type Hints & Annotations
263
392
  - Use type hints for all function signatures
264
393
  - Use \`from __future__ import annotations\` for forward refs
265
394
  - Prefer \`typing.Optional\` over \`X | None\` for Python 3.9 compat
395
+ - Generic types with \`TypeVar\` when needed
266
396
 
267
- ## Patterns
397
+ ## Code Patterns
268
398
  - Use dataclasses or Pydantic for data structures
269
399
  - Async/await for I/O bound operations
270
- - Context managers for resource management
271
-
272
- ## Style
273
- - Follow PEP 8
274
- - Use Black for formatting
275
- - Docstrings in Google style
400
+ - Context managers (\`with\` statements) for resource management
401
+ - List/dict comprehensions for transformations
402
+ - Generator functions for large datasets
403
+
404
+ ## Best Practices
405
+ - Follow PEP 8 style guidelines
406
+ - Use Black for code formatting
407
+ - Google/NumPy style docstrings
408
+ - Meaningful variable names
409
+ - Single responsibility principle
410
+
411
+ ## Error Handling
412
+ - Custom exception classes
413
+ - Specific exception types over generic Exception
414
+ - Proper exception chaining
415
+ - Logging with appropriate levels
416
+
417
+ ## Testing
418
+ - pytest framework preferred
419
+ - Unit tests for functions/classes
420
+ - Integration tests for workflows
421
+ - Mock external dependencies
276
422
  `,
277
423
 
278
- 'security.instructions.md': `---
279
- applyTo: "**/auth/**,**/security/**,**/*auth*,**/*token*,**/*session*"
424
+ 'security-development.instructions.md': `---
425
+ applyTo: "**/auth/**,**/security/**,**/*auth*,**/*token*,**/*session*,**/middleware/**"
280
426
  ---
281
427
 
282
- # Security Guidelines
428
+ # Security Development Guidelines
283
429
 
284
- ## Authentication
430
+ ## Authentication & Authorization
285
431
  - JWT with short expiry + refresh tokens
286
432
  - HttpOnly cookies for web sessions
287
- - Rate limit authentication endpoints
288
-
289
- ## Authorization
290
- - RBAC or ABAC patterns
291
- - Check permissions server-side always
292
- - Deny by default, allow explicitly
433
+ - Rate limiting on authentication endpoints
434
+ - RBAC or ABAC patterns implemented
435
+ - Server-side permission checks always
293
436
 
294
437
  ## Data Protection
295
- - Sanitize all user inputs
296
- - Escape outputs by context (HTML, SQL, etc.)
438
+ - Input sanitization and validation
439
+ - Output encoding by context (HTML, SQL, JSON)
297
440
  - Never log sensitive data (passwords, tokens, PII)
441
+ - Encryption at rest and in transit
442
+ - Secure password hashing (bcrypt, Argon2)
298
443
 
299
- ## OWASP Top 10
300
- - Validate content types
444
+ ## Web Security
301
445
  - CSRF tokens for state-changing operations
302
- - Security headers (CSP, HSTS, X-Frame-Options)
446
+ - Content Security Policy (CSP) headers
447
+ - HTTPS enforcement (HSTS)
448
+ - Secure headers (X-Frame-Options, etc.)
449
+ - XSS prevention with proper escaping
450
+
451
+ ## API Security
452
+ - API versioning for breaking changes
453
+ - Request/response validation schemas
454
+ - CORS configuration for allowed origins
455
+ - API rate limiting and throttling
456
+ - Proper error messages (no sensitive info)
457
+
458
+ ## OWASP Top 10
459
+ - Injection prevention (parameterized queries)
460
+ - Broken authentication handling
461
+ - Sensitive data exposure protection
462
+ - XML external entity prevention
463
+ - Access control enforcement
303
464
  `,
304
465
 
305
- 'database.instructions.md': `---
306
- applyTo: "**/prisma/**,**/*.sql,**/migrations/**,**/schema.*,**/db/**"
466
+ 'database-development.instructions.md': `---
467
+ applyTo: "**/prisma/**,**/*.sql,**/migrations/**,**/schema.*,**/db/**,**/models/**"
307
468
  ---
308
469
 
309
- # Database Guidelines
470
+ # Database Development Guidelines
310
471
 
311
472
  ## Schema Design
312
- - UUID or ULID for primary keys
473
+ - UUID or ULID for primary keys (not auto-increment)
313
474
  - Timestamps: createdAt, updatedAt on all tables
314
475
  - Soft delete with deletedAt when needed
476
+ - Proper foreign key relationships
477
+ - Normalized schemas with good indexing
315
478
 
316
- ## Queries
479
+ ## Query Optimization
317
480
  - Use parameterized queries only (never string concat)
318
- - Select only needed fields
481
+ - Select only needed fields (avoid SELECT *)
319
482
  - Use cursor-based pagination for large datasets
483
+ - Proper indexing on frequently queried fields
484
+ - Query execution plan analysis
320
485
 
321
- ## Prisma
486
+ ## ORM Best Practices
322
487
  - Use transactions for multi-table operations
323
- - Define indexes for frequently queried fields
324
- - Use \`@map\` and \`@@map\` for legacy schemas
488
+ - N+1 query problem avoidance
489
+ - Proper eager/lazy loading
490
+ - Migration scripts for schema changes
491
+ - Database constraints and validations
325
492
 
326
- ## Migrations
327
- - One migration per feature
493
+ ## Migration Safety
494
+ - One migration per feature/change
328
495
  - Never modify already-applied migrations
329
- - Test migrations on copy of production data
496
+ - Test migrations on production-like data
497
+ - Rollback scripts for emergency recovery
498
+ - Version control for migration files
499
+
500
+ ## Performance
501
+ - Connection pooling configuration
502
+ - Query result caching strategies
503
+ - Database indexing strategy
504
+ - Read/write splitting when appropriate
505
+ - Monitoring and alerting setup
506
+ `,
507
+
508
+ 'testing-development.instructions.md': `---
509
+ applyTo: "**/*.test.*,**/*.spec.*,**/tests/**,**/__tests__/**"
510
+ ---
511
+
512
+ # Testing Development Guidelines
513
+
514
+ ## Test Structure
515
+ - Unit tests for individual functions/classes
516
+ - Integration tests for component interactions
517
+ - End-to-end tests for user workflows
518
+ - Performance tests for critical paths
519
+ - Accessibility tests for UI components
520
+
521
+ ## Testing Frameworks
522
+ - Jest for JavaScript/TypeScript
523
+ - pytest for Python
524
+ - RSpec for Ruby
525
+ - JUnit for Java
526
+ - Appropriate framework per language
527
+
528
+ ## Test Patterns
529
+ - Arrange-Act-Assert (AAA) pattern
530
+ - Descriptive test names (not test1, test2)
531
+ - One assertion per test when possible
532
+ - Mock external dependencies
533
+ - Test edge cases and error conditions
534
+
535
+ ## Code Coverage
536
+ - Aim for 80%+ coverage on critical code
537
+ - Focus on business logic over getters/setters
538
+ - Integration tests for coverage gaps
539
+ - Coverage reports in CI/CD pipeline
540
+
541
+ ## Best Practices
542
+ - Tests run independently (no shared state)
543
+ - Fast execution for developer experience
544
+ - CI/CD integration with quality gates
545
+ - Test data management and cleanup
546
+ - Documentation of test scenarios
547
+ `,
548
+
549
+ 'api-development.instructions.md': `---
550
+ applyTo: "**/api/**,**/routes/**,**/controllers/**,**/services/**,**/*api*,**/*endpoint*"
551
+ ---
552
+
553
+ # API Development Guidelines
554
+
555
+ ## RESTful Design
556
+ - Proper HTTP methods (GET, POST, PUT, DELETE)
557
+ - Resource-based URLs (/users, /users/{id})
558
+ - Status codes: 200, 201, 400, 401, 403, 404, 500
559
+ - Content-Type and Accept headers
560
+ - Idempotent operations where appropriate
561
+
562
+ ## API Versioning
563
+ - URL versioning: /api/v1/users
564
+ - Header versioning when needed
565
+ - Backward compatibility maintenance
566
+ - Deprecation notices for breaking changes
567
+ - Version documentation
568
+
569
+ ## Request/Response
570
+ - JSON as primary format
571
+ - Consistent response structure
572
+ - Pagination for list endpoints
573
+ - Filtering and sorting parameters
574
+ - Rate limiting headers
575
+
576
+ ## Error Handling
577
+ - Consistent error response format
578
+ - Appropriate HTTP status codes
579
+ - User-friendly error messages
580
+ - Error logging and monitoring
581
+ - Graceful degradation
582
+
583
+ ## Documentation
584
+ - OpenAPI/Swagger specifications
585
+ - Interactive API documentation
586
+ - Authentication examples
587
+ - Rate limiting information
588
+ - Changelog for API versions
589
+ `,
590
+
591
+ 'github-actions.instructions.md': `---
592
+ applyTo: ".github/workflows/**/*.yml,.github/workflows/**/*.yaml"
593
+ ---
594
+
595
+ # GitHub Actions Development Guidelines
596
+
597
+ ## Workflow Structure
598
+ - Descriptive workflow names and jobs
599
+ - Matrix builds for multiple environments
600
+ - Proper job dependencies with needs
601
+ - Conditional execution with if statements
602
+ - Timeout settings for long-running jobs
603
+
604
+ ## Security
605
+ - Use trusted actions from GitHub Marketplace
606
+ - Pin action versions to specific SHAs
607
+ - Use secrets for sensitive data
608
+ - CodeQL for security scanning
609
+ - Dependency review for PRs
610
+
611
+ ## Best Practices
612
+ - Cache dependencies for faster builds
613
+ - Use self-hosted runners when appropriate
614
+ - Proper artifact management
615
+ - Notification configuration
616
+ - Workflow reusability with composite actions
617
+
618
+ ## CI/CD Pipeline
619
+ - Build → Test → Deploy stages
620
+ - Parallel job execution
621
+ - Failure handling and notifications
622
+ - Rollback capabilities
623
+ - Environment-specific configurations
624
+
625
+ ## Performance
626
+ - Efficient caching strategies
627
+ - Minimal artifact sizes
628
+ - Parallel job execution
629
+ - Resource optimization
630
+ - Build time monitoring
330
631
  `
331
632
  };
332
633
 
@@ -369,10 +670,16 @@ To invoke an agent, reference it in your prompt:
369
670
  ## 📋 Language Instructions
370
671
 
371
672
  Context-specific rules are in \`.github/instructions/\`:
372
- - \`typescript.instructions.md\` - TS/TSX files
373
- - \`python.instructions.md\` - Python files
374
- - \`security.instructions.md\` - Auth/security code
375
- - \`database.instructions.md\` - Database/Prisma code
673
+ - \`typescript-development.instructions.md\` - TypeScript files
674
+ - \`javascript-development.instructions.md\` - JavaScript files
675
+ - \`react-development.instructions.md\` - React components
676
+ - \`nextjs-development.instructions.md\` - Next.js applications
677
+ - \`python-development.instructions.md\` - Python files
678
+ - \`security-development.instructions.md\` - Auth/security code
679
+ - \`database-development.instructions.md\` - Database/ORM code
680
+ - \`testing-development.instructions.md\` - Test files
681
+ - \`api-development.instructions.md\` - API endpoints
682
+ - \`github-actions.instructions.md\` - GitHub Actions workflows
376
683
 
377
684
  ## 🔧 MCP Servers
378
685