specpilot 1.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 (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +430 -0
  3. package/cli.js +3 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +67 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/commands/init.d.ts +9 -0
  9. package/dist/commands/init.d.ts.map +1 -0
  10. package/dist/commands/init.js +72 -0
  11. package/dist/commands/init.js.map +1 -0
  12. package/dist/commands/list.d.ts +6 -0
  13. package/dist/commands/list.d.ts.map +1 -0
  14. package/dist/commands/list.js +53 -0
  15. package/dist/commands/list.js.map +1 -0
  16. package/dist/commands/migrate.d.ts +8 -0
  17. package/dist/commands/migrate.d.ts.map +1 -0
  18. package/dist/commands/migrate.js +55 -0
  19. package/dist/commands/migrate.js.map +1 -0
  20. package/dist/commands/specify.d.ts +8 -0
  21. package/dist/commands/specify.d.ts.map +1 -0
  22. package/dist/commands/specify.js +194 -0
  23. package/dist/commands/specify.js.map +1 -0
  24. package/dist/commands/validate.d.ts +7 -0
  25. package/dist/commands/validate.d.ts.map +1 -0
  26. package/dist/commands/validate.js +54 -0
  27. package/dist/commands/validate.js.map +1 -0
  28. package/dist/utils/logger.d.ts +8 -0
  29. package/dist/utils/logger.d.ts.map +1 -0
  30. package/dist/utils/logger.js +28 -0
  31. package/dist/utils/logger.js.map +1 -0
  32. package/dist/utils/projectMigrator.d.ts +25 -0
  33. package/dist/utils/projectMigrator.d.ts.map +1 -0
  34. package/dist/utils/projectMigrator.js +227 -0
  35. package/dist/utils/projectMigrator.js.map +1 -0
  36. package/dist/utils/specGenerator.d.ts +45 -0
  37. package/dist/utils/specGenerator.d.ts.map +1 -0
  38. package/dist/utils/specGenerator.js +1109 -0
  39. package/dist/utils/specGenerator.js.map +1 -0
  40. package/dist/utils/specValidator.d.ts +33 -0
  41. package/dist/utils/specValidator.d.ts.map +1 -0
  42. package/dist/utils/specValidator.js +425 -0
  43. package/dist/utils/specValidator.js.map +1 -0
  44. package/dist/utils/templateEngine.d.ts +22 -0
  45. package/dist/utils/templateEngine.d.ts.map +1 -0
  46. package/dist/utils/templateEngine.js +213 -0
  47. package/dist/utils/templateEngine.js.map +1 -0
  48. package/dist/utils/templateRegistry.d.ts +14 -0
  49. package/dist/utils/templateRegistry.d.ts.map +1 -0
  50. package/dist/utils/templateRegistry.js +101 -0
  51. package/dist/utils/templateRegistry.js.map +1 -0
  52. package/package.json +72 -0
@@ -0,0 +1,1109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SpecGenerator = void 0;
4
+ const path_1 = require("path");
5
+ const fs_1 = require("fs");
6
+ class SpecGenerator {
7
+ constructor(templateEngine) {
8
+ this.templateEngine = templateEngine;
9
+ }
10
+ async generateSpecs(options) {
11
+ const specsDir = (0, path_1.join)(options.targetDir, options.specsName);
12
+ // Create .specs directory
13
+ (0, fs_1.mkdirSync)(specsDir, { recursive: true });
14
+ const context = {
15
+ projectName: options.projectName,
16
+ language: options.language,
17
+ framework: options.framework,
18
+ author: options.author || 'Your Name',
19
+ description: options.description || `A ${options.language} project${options.framework ? ` using ${options.framework}` : ''}`
20
+ };
21
+ // Generate all 8 core spec files
22
+ await this.generateProjectYaml(specsDir, context);
23
+ await this.generateArchitectureMd(specsDir, context);
24
+ await this.generateRequirementsMd(specsDir, context);
25
+ await this.generateApiYaml(specsDir, context);
26
+ await this.generateTestsMd(specsDir, context);
27
+ await this.generateTasksMd(specsDir, context);
28
+ await this.generateContextMd(specsDir, context);
29
+ await this.generatePromptsMd(specsDir, context);
30
+ await this.generateDocsMd(specsDir, context);
31
+ }
32
+ async generateProjectYaml(specsDir, context) {
33
+ const template = this.templateEngine.getBuiltinTemplate(context.language, context.framework, 'project.yaml');
34
+ const content = this.templateEngine.renderFromString(template, context);
35
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'project.yaml'), content);
36
+ }
37
+ async generateArchitectureMd(specsDir, context) {
38
+ const template = this.templateEngine.getBuiltinTemplate(context.language, context.framework, 'architecture.md');
39
+ const content = this.templateEngine.renderFromString(template, context);
40
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'architecture.md'), content);
41
+ }
42
+ async generateRequirementsMd(specsDir, context) {
43
+ const content = `# {{projectName}} Requirements
44
+
45
+ ## Project Overview
46
+ {{description}}
47
+
48
+ ## Functional Requirements
49
+
50
+ ### Core Features
51
+ 1. **Feature 1**: [Describe the primary functionality]
52
+ - User can [specific action]
53
+ - System should [expected behavior]
54
+ - Success criteria: [measurable outcome]
55
+
56
+ 2. **Feature 2**: [Describe secondary functionality]
57
+ - User can [specific action]
58
+ - System should [expected behavior]
59
+ - Success criteria: [measurable outcome]
60
+
61
+ ## Non-Functional Requirements
62
+
63
+ ### Performance
64
+ - Response time: < 200ms for API calls
65
+ - Throughput: Support [X] concurrent users
66
+ - Scalability: Horizontal scaling capability
67
+
68
+ ### Security
69
+ - Authentication and authorization
70
+ - Data encryption at rest and in transit
71
+ - Input validation and sanitization
72
+
73
+ ### Reliability
74
+ - 99.9% uptime availability
75
+ - Graceful error handling
76
+ - Automated backup and recovery
77
+
78
+ ### Usability
79
+ - Intuitive user interface
80
+ - Responsive design for mobile devices
81
+ - Accessibility compliance (WCAG 2.1)
82
+
83
+ ## Technical Requirements
84
+
85
+ ### ${context.language} Specific
86
+ ${this.getTechnicalRequirements(context.language, context.framework)}
87
+
88
+ ## User Stories
89
+
90
+ ### Epic 1: Core Functionality
91
+ - **US-001**: As a [user type], I want to [action] so that [benefit]
92
+ - **AC1**: Given [precondition], when [action], then [expected result]
93
+ - **AC2**: Given [precondition], when [action], then [expected result]
94
+
95
+ ### Epic 2: Additional Features
96
+ - **US-002**: As a [user type], I want to [action] so that [benefit]
97
+ - **AC1**: Given [precondition], when [action], then [expected result]
98
+
99
+ ## Acceptance Criteria
100
+ All features must:
101
+ - Have comprehensive test coverage (>90%)
102
+ - Pass security review
103
+ - Meet performance benchmarks
104
+ - Include proper documentation
105
+
106
+ ## Constraints and Assumptions
107
+ - **Budget**: [if applicable]
108
+ - **Timeline**: [project deadlines]
109
+ - **Technology**: Must use ${context.language}${context.framework ? ` with ${context.framework}` : ''}
110
+ - **Compliance**: [regulatory requirements]
111
+
112
+ ---
113
+ *Last updated: {{currentDate}}*`;
114
+ const rendered = this.templateEngine.renderFromString(content, context);
115
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'requirements.md'), rendered);
116
+ }
117
+ getTechnicalRequirements(language, framework) {
118
+ if (language === 'typescript') {
119
+ return `- TypeScript strict mode enabled
120
+ - Modern ES2020+ features
121
+ - Node.js LTS version
122
+ ${framework === 'react' ? '- React 18+ with hooks' : ''}
123
+ ${framework === 'express' ? '- Express.js with middleware' : ''}
124
+ - Comprehensive type definitions`;
125
+ }
126
+ if (language === 'python') {
127
+ return `- Python 3.9+ compatibility
128
+ - Type hints throughout codebase
129
+ - Virtual environment management
130
+ ${framework === 'django' ? '- Django 4.0+ framework' : ''}
131
+ ${framework === 'fastapi' ? '- FastAPI with async support' : ''}
132
+ - PEP 8 code style compliance`;
133
+ }
134
+ if (language === 'java') {
135
+ return `- Java 17+ LTS version
136
+ - Maven or Gradle build system
137
+ ${framework === 'spring-boot' ? '- Spring Boot 3.0+' : ''}
138
+ - JUnit 5 for testing
139
+ - SonarQube code quality`;
140
+ }
141
+ return `- ${language} best practices
142
+ - Comprehensive testing
143
+ - Code quality standards`;
144
+ }
145
+ async generateApiYaml(specsDir, context) {
146
+ const content = `# {{projectName}} API Specification
147
+
148
+ openapi: 3.0.3
149
+ info:
150
+ title: {{projectName}} API
151
+ description: {{description}}
152
+ version: 1.0.0
153
+ contact:
154
+ name: {{author}}
155
+
156
+ servers:
157
+ - url: http://localhost:3000/api
158
+ description: Development server
159
+ - url: https://api.{{lowercase projectName}}.com
160
+ description: Production server
161
+
162
+ paths:
163
+ /health:
164
+ get:
165
+ summary: Health check endpoint
166
+ description: Returns the health status of the API
167
+ responses:
168
+ '200':
169
+ description: API is healthy
170
+ content:
171
+ application/json:
172
+ schema:
173
+ type: object
174
+ properties:
175
+ status:
176
+ type: string
177
+ example: "healthy"
178
+ timestamp:
179
+ type: string
180
+ format: date-time
181
+
182
+ # Add your API endpoints here
183
+ /users:
184
+ get:
185
+ summary: Get users
186
+ description: Retrieve a list of users
187
+ parameters:
188
+ - name: limit
189
+ in: query
190
+ schema:
191
+ type: integer
192
+ default: 10
193
+ - name: offset
194
+ in: query
195
+ schema:
196
+ type: integer
197
+ default: 0
198
+ responses:
199
+ '200':
200
+ description: List of users
201
+ content:
202
+ application/json:
203
+ schema:
204
+ type: object
205
+ properties:
206
+ users:
207
+ type: array
208
+ items:
209
+ $ref: '#/components/schemas/User'
210
+ total:
211
+ type: integer
212
+
213
+ components:
214
+ schemas:
215
+ User:
216
+ type: object
217
+ required:
218
+ - id
219
+ - email
220
+ properties:
221
+ id:
222
+ type: string
223
+ format: uuid
224
+ email:
225
+ type: string
226
+ format: email
227
+ name:
228
+ type: string
229
+ created_at:
230
+ type: string
231
+ format: date-time
232
+
233
+ Error:
234
+ type: object
235
+ required:
236
+ - message
237
+ - code
238
+ properties:
239
+ message:
240
+ type: string
241
+ code:
242
+ type: string
243
+ details:
244
+ type: object
245
+
246
+ securitySchemes:
247
+ BearerAuth:
248
+ type: http
249
+ scheme: bearer
250
+ bearerFormat: JWT
251
+
252
+ security:
253
+ - BearerAuth: []
254
+
255
+ ---
256
+ # Data Models and Schemas
257
+
258
+ ## Database Schema (if applicable)
259
+
260
+ ### Users Table
261
+ \`\`\`sql
262
+ CREATE TABLE users (
263
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
264
+ email VARCHAR(255) UNIQUE NOT NULL,
265
+ name VARCHAR(255),
266
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
267
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
268
+ );
269
+ \`\`\`
270
+
271
+ ## Message Formats
272
+
273
+ ### Event Schema (if using event-driven architecture)
274
+ \`\`\`json
275
+ {
276
+ "event_type": "user.created",
277
+ "timestamp": "2024-01-01T00:00:00Z",
278
+ "payload": {
279
+ "user_id": "uuid",
280
+ "email": "user@example.com"
281
+ }
282
+ }
283
+ \`\`\`
284
+
285
+ ---
286
+ *Last updated: {{currentDate}}*`;
287
+ const rendered = this.templateEngine.renderFromString(content, context);
288
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'api.yaml'), rendered);
289
+ }
290
+ async generateTestsMd(specsDir, context) {
291
+ const content = `# {{projectName}} Test Strategy
292
+
293
+ ## Overview
294
+ This document outlines the testing strategy and approach for {{projectName}}.
295
+
296
+ ## Test Pyramid
297
+
298
+ ### Unit Tests (70%)
299
+ - **Scope**: Individual functions, classes, and modules
300
+ - **Framework**: ${this.getTestFramework(context.language)}
301
+ - **Coverage Target**: >90%
302
+ - **Location**: Alongside source code in \`__tests__\` directories
303
+
304
+ ### Integration Tests (20%)
305
+ - **Scope**: Component interactions and external dependencies
306
+ - **Framework**: ${this.getIntegrationTestFramework(context.language)}
307
+ - **Coverage**: Critical user paths and API endpoints
308
+ - **Location**: \`tests/integration/\`
309
+
310
+ ### End-to-End Tests (10%)
311
+ - **Scope**: Complete user workflows
312
+ - **Framework**: ${this.getE2ETestFramework(context.language, context.framework)}
313
+ - **Coverage**: Critical business scenarios
314
+ - **Location**: \`tests/e2e/\`
315
+
316
+ ## Test Categories
317
+
318
+ ### Functional Testing
319
+ - ✅ **Feature tests**: Core functionality works as expected
320
+ - ✅ **API tests**: All endpoints return correct responses
321
+ - ✅ **Data validation**: Input validation and sanitization
322
+ - ✅ **Error handling**: Proper error responses and logging
323
+
324
+ ### Non-Functional Testing
325
+ - ✅ **Performance**: Response times and throughput
326
+ - ✅ **Security**: Authentication, authorization, and input validation
327
+ - ✅ **Load**: System behavior under expected load
328
+ - ✅ **Stress**: System behavior under extreme conditions
329
+
330
+ ## Test Data Management
331
+ - **Test fixtures**: Predefined data sets for consistent testing
332
+ - **Data factories**: Generate test data programmatically
333
+ - **Database seeding**: Set up test databases with known state
334
+ - **Cleanup**: Ensure tests don't interfere with each other
335
+
336
+ ## Continuous Integration
337
+
338
+ ### Pre-commit Hooks
339
+ - Run linting and basic tests
340
+ - Ensure code quality standards
341
+
342
+ ### CI Pipeline
343
+ 1. **Static Analysis**: Code quality and security scanning
344
+ 2. **Unit Tests**: Fast feedback on individual components
345
+ 3. **Integration Tests**: Verify component interactions
346
+ 4. **E2E Tests**: Validate complete user workflows
347
+ 5. **Performance Tests**: Monitor regression in performance
348
+
349
+ ## Test Environment
350
+
351
+ ### Local Development
352
+ - Docker containers for dependencies
353
+ - Test database separate from development
354
+ - Mock external services
355
+
356
+ ### CI/CD Environment
357
+ - Isolated test databases
358
+ - Service mocks and stubs
359
+ - Parallel test execution
360
+
361
+ ## Acceptance Criteria
362
+
363
+ All features must have:
364
+ - [ ] Unit tests covering happy path and edge cases
365
+ - [ ] Integration tests for external dependencies
366
+ - [ ] API tests for all endpoints
367
+ - [ ] Error scenario tests
368
+ - [ ] Performance benchmarks
369
+
370
+ ## Test Automation
371
+
372
+ ### Testing Checklist
373
+ - [ ] All tests pass locally before commit
374
+ - [ ] CI pipeline passes before merge
375
+ - [ ] Code coverage meets threshold
376
+ - [ ] Performance tests within acceptable limits
377
+ - [ ] Security tests pass
378
+
379
+ ### Monitoring
380
+ - Track test execution time
381
+ - Monitor flaky test patterns
382
+ - Regular review of test coverage
383
+ - Performance trend analysis
384
+
385
+ ---
386
+ *Last updated: {{currentDate}}*`;
387
+ const rendered = this.templateEngine.renderFromString(content, context);
388
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'tests.md'), rendered);
389
+ }
390
+ getTestFramework(language) {
391
+ const frameworks = {
392
+ typescript: 'Jest with ts-jest',
393
+ python: 'pytest',
394
+ java: 'JUnit 5'
395
+ };
396
+ return frameworks[language] || 'Framework specific to language';
397
+ }
398
+ getIntegrationTestFramework(language) {
399
+ const frameworks = {
400
+ typescript: 'Jest with supertest',
401
+ python: 'pytest with requests',
402
+ java: 'Spring Boot Test'
403
+ };
404
+ return frameworks[language] || 'Integration testing framework';
405
+ }
406
+ getE2ETestFramework(language, framework) {
407
+ if (framework === 'react' || framework === 'next')
408
+ return 'Playwright or Cypress';
409
+ if (language === 'python')
410
+ return 'Selenium with pytest';
411
+ if (language === 'java')
412
+ return 'Selenium WebDriver';
413
+ return 'Playwright or Selenium';
414
+ }
415
+ async generateTasksMd(specsDir, context) {
416
+ const content = `# {{projectName}} Task Management
417
+
418
+ ## Project Status: 🟡 In Progress
419
+
420
+ ## Current Sprint
421
+
422
+ ### In Progress
423
+ - [ ] **Setup project foundation**
424
+ - Initialize ${context.language} project structure
425
+ - Configure development environment
426
+ - Set up basic CI/CD pipeline
427
+
428
+ ### Ready for Development
429
+ - [ ] **Implement core features**
430
+ - Define main application logic
431
+ - Set up data models and schemas
432
+ - Create API endpoints (if applicable)
433
+
434
+ ### Blocked
435
+ - [ ] **External integrations**
436
+ - Waiting for third-party API access
437
+ - Pending security review approval
438
+
439
+ ## Backlog
440
+
441
+ ### Phase 1: Foundation
442
+ - [ ] Project setup and configuration
443
+ - [ ] Development environment setup
444
+ - [ ] Basic project structure
445
+ - [ ] Initial documentation
446
+
447
+ ### Phase 2: Core Development
448
+ - [ ] Implement primary features
449
+ - [ ] Database setup and migrations
450
+ - [ ] API development
451
+ - [ ] User interface (if applicable)
452
+
453
+ ### Phase 3: Testing & Quality
454
+ - [ ] Unit test implementation
455
+ - [ ] Integration testing
456
+ - [ ] Performance optimization
457
+ - [ ] Security review
458
+
459
+ ### Phase 4: Deployment
460
+ - [ ] Production environment setup
461
+ - [ ] Deployment pipeline
462
+ - [ ] Monitoring and logging
463
+ - [ ] Documentation finalization
464
+
465
+ ## Completed
466
+
467
+ ### ✅ Project Initialization
468
+ - [x] Created project specifications
469
+ - [x] Set up ${context.language} development environment
470
+ - [x] Initial .specs/ structure created
471
+ - [x] Basic project configuration
472
+
473
+ ## Notes
474
+
475
+ ### Development Guidelines
476
+ - All tasks should be linked to requirements in requirements.md
477
+ - Update this file regularly during development
478
+ - Use proper branch naming: feature/task-description
479
+ - Ensure all tasks have acceptance criteria
480
+
481
+ ### Estimation Guide
482
+ - **Small**: 1-2 days
483
+ - **Medium**: 3-5 days
484
+ - **Large**: 1-2 weeks
485
+ - **Extra Large**: Break into smaller tasks
486
+
487
+ ---
488
+ *Last updated: {{currentDate}}*`;
489
+ const rendered = this.templateEngine.renderFromString(content, context);
490
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'tasks.md'), rendered);
491
+ }
492
+ async generateContextMd(specsDir, context) {
493
+ const content = `# {{projectName}} Development Context
494
+
495
+ ## Project Memory
496
+
497
+ ### Key Decisions Made
498
+ - **{{currentDate}}**: Initialized project with ${context.language}${context.framework ? ` and ${context.framework}` : ''}
499
+ - **{{currentDate}}**: Chose specification-driven development approach
500
+ - **{{currentDate}}**: Set up simplified .specs/ structure (8 files)
501
+
502
+ ### Architecture Patterns
503
+ - **Primary Pattern**: [To be determined based on requirements]
504
+ - **Data Flow**: [To be defined during architecture phase]
505
+ - **State Management**: [Framework-specific approach]
506
+
507
+ ### Development Patterns
508
+
509
+ #### Code Organization
510
+ - Follow ${context.language} best practices
511
+ - Maintain clear separation of concerns
512
+ - Use dependency injection where applicable
513
+ - Implement proper error handling
514
+
515
+ #### Testing Strategy
516
+ - Test-driven development (TDD) preferred
517
+ - Comprehensive test coverage (>90%)
518
+ - Mock external dependencies
519
+ - Use factories for test data
520
+
521
+ ## Common Issues and Solutions
522
+
523
+ ### Issue: [Placeholder - will be filled during development]
524
+ - **Problem**: [Description of the issue]
525
+ - **Solution**: [How it was resolved]
526
+ - **Prevention**: [How to avoid in future]
527
+
528
+ ### Issue: Development Environment Setup
529
+ - **Problem**: Inconsistent development environments across team
530
+ - **Solution**: Use Docker containers and/or detailed setup documentation
531
+ - **Prevention**: Automated environment setup scripts
532
+
533
+ ## Lessons Learned
534
+
535
+ ### Development Process
536
+ - Start with specifications before coding
537
+ - Regular validation of requirements
538
+ - Maintain up-to-date documentation
539
+ - **MANDATE**: Always update prompts.md with AI interactions
540
+
541
+ ### Technical Learnings
542
+ - [To be populated during development]
543
+ - Focus on maintainable, readable code
544
+ - Proper error handling from the beginning
545
+ - Performance considerations early in design
546
+
547
+ ## Team Knowledge
548
+
549
+ ### Onboarding Guide
550
+ 1. Review all .specs/ files
551
+ 2. Set up local development environment
552
+ 3. Run existing tests to verify setup
553
+ 4. Review coding standards and practices
554
+ 5. Understand deployment process
555
+
556
+ ### Contact Information
557
+ - **Project Lead**: {{author}}
558
+ - **Technical Lead**: [To be assigned]
559
+ - **Product Owner**: [To be assigned]
560
+
561
+ ## External Resources
562
+
563
+ ### Documentation Links
564
+ - [Framework documentation]
565
+ - [Language-specific resources]
566
+ - [Third-party service documentation]
567
+
568
+ ### Tools and Services
569
+ - **Version Control**: Git
570
+ - **CI/CD**: [To be configured]
571
+ - **Monitoring**: [To be set up]
572
+ - **Deployment**: [To be configured]
573
+
574
+ ## Change Log
575
+
576
+ ### {{currentDate}}
577
+ - Initial project setup with SpecPilot SDD CLI
578
+ - Created basic .specs/ structure
579
+ - Configured ${context.language} development environment
580
+
581
+ ---
582
+ *Last updated: {{currentDate}}*`;
583
+ const rendered = this.templateEngine.renderFromString(content, context);
584
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'context.md'), rendered);
585
+ }
586
+ async generatePromptsMd(specsDir, context) {
587
+ const content = `# Development Prompts Log
588
+
589
+ ## Overview
590
+ This file contains ALL AI interactions and development prompts for {{projectName}}, maintaining complete traceability of the development process.
591
+
592
+ **🚨 MANDATE**: This file MUST be updated with every AI interaction during development.
593
+
594
+ ## Latest Entries
595
+
596
+ ### Project Initialization ({{currentDate}})
597
+
598
+ #### Prompt: Initial Project Setup
599
+ **Prompt**: "Create a new ${context.language} project${context.framework ? ` using ${context.framework}` : ''} with specification-driven development structure"
600
+
601
+ **Context**: Starting new project with SpecPilot SDD CLI tool
602
+
603
+ **Response**:
604
+ - Generated complete .specs/ directory structure
605
+ - Created 8 core specification files
606
+ - Set up ${context.language} project foundation
607
+ - Implemented mandate for prompt tracking
608
+
609
+ **Files Modified**: All .specs/ files created
610
+
611
+ **Next Actions**: Begin development according to requirements.md
612
+
613
+ ---
614
+
615
+ ## Development Sessions
616
+
617
+ ### Session 1: Project Foundation
618
+ **Date**: {{currentDate}}
619
+ **Duration**: [To be filled]
620
+ **Participants**: {{author}}, AI Assistant
621
+
622
+ #### Prompts and Responses
623
+
624
+ 1. **Setup Request**
625
+ - **Prompt**: "Initialize {{projectName}} with ${context.language}"
626
+ - **Response**: Created project structure and specifications
627
+ - **Outcome**: Foundation established
628
+
629
+ #### Decisions Made
630
+ - Use specification-driven development approach
631
+ - Implement simplified .specs/ structure
632
+ - Enforce prompt tracking mandate
633
+
634
+ #### Issues Encountered
635
+ - None during initialization
636
+
637
+ ---
638
+
639
+ ## Template for Future Entries
640
+
641
+ ### Session [N]: [Session Title]
642
+ **Date**: [YYYY-MM-DD]
643
+ **Duration**: [Time spent]
644
+ **Participants**: [Team members, AI interactions]
645
+
646
+ #### Prompts and Responses
647
+
648
+ 1. **[Prompt Category]**
649
+ - **Prompt**: "[Exact prompt text]"
650
+ - **Context**: "[Why this prompt was needed]"
651
+ - **Response**: "[Summary of AI response]"
652
+ - **Code Generated**: "[File paths and brief description]"
653
+ - **Outcome**: "[Result of the interaction]"
654
+
655
+ #### Decisions Made
656
+ - [List any architectural or design decisions]
657
+ - [Include rationale for each decision]
658
+
659
+ #### Issues Encountered
660
+ - [Any problems that came up]
661
+ - [Solutions implemented]
662
+
663
+ #### Files Modified
664
+ - [List of files changed]
665
+ - [Brief description of changes]
666
+
667
+ #### Next Steps
668
+ - [What needs to be done next]
669
+ - [Any follow-up prompts planned]
670
+
671
+ ---
672
+
673
+ ## Prompt Categories
674
+
675
+ ### 🏗️ Architecture & Design
676
+ - System design decisions
677
+ - Architecture patterns
678
+ - Technology choices
679
+
680
+ ### 💻 Implementation
681
+ - Code generation requests
682
+ - Bug fixes
683
+ - Feature implementations
684
+
685
+ ### 🧪 Testing
686
+ - Test creation
687
+ - Test strategy discussions
688
+ - Bug investigations
689
+
690
+ ### 📚 Documentation
691
+ - Documentation updates
692
+ - API documentation
693
+ - User guides
694
+
695
+ ### 🚀 Deployment
696
+ - CI/CD setup
697
+ - Production deployments
698
+ - Infrastructure changes
699
+
700
+ ### 🐛 Debugging
701
+ - Problem investigation
702
+ - Error resolution
703
+ - Performance issues
704
+
705
+ ---
706
+
707
+ ## Usage Guidelines
708
+
709
+ ### For Team Members
710
+ 1. **Always update when using AI**: No exceptions
711
+ 2. **Include full context**: Not just the prompt, but why it was needed
712
+ 3. **Record outcomes**: What was actually implemented or decided
713
+ 4. **Link to code changes**: Reference specific files and commits
714
+ 5. **Maintain chronological order**: Latest entries at the top
715
+
716
+ ### For AI Assistants
717
+ 1. **Remind about this file**: Always mention updating prompts.md
718
+ 2. **Provide structured responses**: Use the template format
719
+ 3. **Include relevant context**: Reference previous decisions when applicable
720
+ 4. **Track dependencies**: Note when prompts relate to previous work
721
+
722
+ ### Quality Standards
723
+ - ✅ All AI interactions documented
724
+ - ✅ Chronological order maintained
725
+ - ✅ Full context provided for each prompt
726
+ - ✅ Outcomes and decisions recorded
727
+ - ✅ Files and changes referenced
728
+
729
+ ---
730
+ *Last updated: {{currentDate}}*`;
731
+ const rendered = this.templateEngine.renderFromString(content, context);
732
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'prompts.md'), rendered);
733
+ }
734
+ async generateDocsMd(specsDir, context) {
735
+ const content = `# {{projectName}} Development Documentation
736
+
737
+ ## Project Overview
738
+ This document provides comprehensive development and deployment guidelines for {{projectName}}.
739
+
740
+ ## Getting Started
741
+
742
+ ### Prerequisites
743
+ ${this.getPrerequisites(context.language, context.framework)}
744
+
745
+ ### Installation
746
+ \`\`\`bash
747
+ # Clone the repository
748
+ git clone [repository-url]
749
+ cd {{projectName}}
750
+
751
+ # Install dependencies
752
+ ${this.getInstallCommand(context.language)}
753
+
754
+ # Set up environment
755
+ ${this.getEnvironmentSetup(context.language)}
756
+ \`\`\`
757
+
758
+ ### Development Workflow
759
+
760
+ #### 1. Specification Review
761
+ - Review .specs/requirements.md for current requirements
762
+ - Check .specs/architecture.md for technical decisions
763
+ - Understand API contracts in .specs/api.yaml
764
+
765
+ #### 2. Development Process
766
+ 1. Create feature branch: \`git checkout -b feature/description\`
767
+ 2. Update specifications if needed
768
+ 3. Implement feature following TDD approach
769
+ 4. Update tests and documentation
770
+ 5. Submit pull request with specification updates
771
+
772
+ #### 3. Code Standards
773
+ ${this.getCodeStandards(context.language)}
774
+
775
+ #### 4. Testing Requirements
776
+ - Unit tests: >90% coverage
777
+ - Integration tests for external dependencies
778
+ - End-to-end tests for critical paths
779
+ - Performance benchmarks for key operations
780
+
781
+ ### 🚨 MANDATORY: AI Interaction Tracking
782
+ 6. **MANDATE: Track ALL AI Prompts**: Update .specs/prompts.md with every AI interaction, including timestamps and context
783
+ - **Required for all team members**
784
+ - **Include full prompt and response context**
785
+ - **Maintain chronological order**
786
+ - **Link to code changes and decisions**
787
+
788
+ ## Project Structure
789
+
790
+ \`\`\`
791
+ ${this.getProjectStructure(context.language, context.framework)}
792
+ \`\`\`
793
+
794
+ ## Available Scripts
795
+
796
+ ${this.getAvailableScripts(context.language, context.framework)}
797
+
798
+ ## Environment Configuration
799
+
800
+ ### Development
801
+ \`\`\`env
802
+ NODE_ENV=development
803
+ DATABASE_URL=postgresql://localhost/{{lowercase projectName}}_dev
804
+ API_KEY=dev-api-key
805
+ LOG_LEVEL=debug
806
+ \`\`\`
807
+
808
+ ### Production
809
+ \`\`\`env
810
+ NODE_ENV=production
811
+ DATABASE_URL=${this.getDatabaseUrl(context.language)}
812
+ API_KEY=prod-api-key
813
+ LOG_LEVEL=info
814
+ \`\`\`
815
+
816
+ ## API Documentation
817
+
818
+ ### Base URL
819
+ - **Development**: \`http://localhost:3000\`
820
+ - **Production**: \`https://api.{{lowercase projectName}}.com\`
821
+
822
+ ### Authentication
823
+ ${this.getAuthenticationDocs(context.framework)}
824
+
825
+ ### Rate Limiting
826
+ - 100 requests per minute per IP
827
+ - 1000 requests per hour per authenticated user
828
+
829
+ ## Database
830
+
831
+ ### Migrations
832
+ \`\`\`bash
833
+ ${this.getMigrationCommands(context.language, context.framework)}
834
+ \`\`\`
835
+
836
+ ### Backup and Recovery
837
+ \`\`\`bash
838
+ ${this.getBackupCommands(context.language)}
839
+ \`\`\`
840
+
841
+ ## Deployment
842
+
843
+ ### CI/CD Pipeline
844
+ 1. **Code Quality**: Linting, type checking, security scanning
845
+ 2. **Testing**: Unit, integration, and e2e tests
846
+ 3. **Build**: Compile and package application
847
+ 4. **Deploy**: Automated deployment to staging/production
848
+
849
+ ### Production Deployment
850
+ \`\`\`bash
851
+ # Build for production
852
+ ${this.getBuildCommand(context.language)}
853
+
854
+ # Deploy to production
855
+ ${this.getDeployCommand(context.language)}
856
+ \`\`\`
857
+
858
+ ### Monitoring and Logging
859
+ - **Application Logs**: Structured JSON logging
860
+ - **Error Tracking**: [Error tracking service]
861
+ - **Performance Monitoring**: [APM service]
862
+ - **Health Checks**: \`/api/health\` endpoint
863
+
864
+ ## Troubleshooting
865
+
866
+ ### Common Issues
867
+
868
+ #### Development Environment
869
+ **Issue**: Dependencies not installing
870
+ **Solution**:
871
+ \`\`\`bash
872
+ ${this.getTroubleshootingCommands(context.language)}
873
+ \`\`\`
874
+
875
+ #### Database Connection
876
+ **Issue**: Cannot connect to database
877
+ **Solutions**:
878
+ - Verify database is running
879
+ - Check connection string in environment
880
+ - Ensure proper permissions
881
+
882
+ #### Build Failures
883
+ **Issue**: Build process fails
884
+ **Solutions**:
885
+ - Check for TypeScript/syntax errors
886
+ - Verify all dependencies are installed
887
+ - Clear build cache and rebuild
888
+
889
+ ## AI Integration Guidelines
890
+
891
+ ### Development with AI Assistants
892
+ - **MANDATE: Automatic prompt logging** - Log all AI interactions to .specs/prompts.md
893
+ - **MANDATE: Complete context inclusion** - Include full prompt and response
894
+ - **MANDATE: Chronological order** - Maintain timeline of all interactions
895
+ - **MANDATE: Full traceability** - Link prompts to specific development phases
896
+
897
+ ### Best Practices
898
+ 1. Provide clear context in prompts
899
+ 2. Reference existing specifications
900
+ 3. Ask for code that follows project standards
901
+ 4. Request tests along with implementation
902
+ 5. Always update documentation
903
+
904
+ ## Team Collaboration
905
+
906
+ ### Code Reviews
907
+ - All changes require peer review
908
+ - Focus on specification compliance
909
+ - Verify test coverage and quality
910
+ - Check for security vulnerabilities
911
+
912
+ ### Communication
913
+ - Use project management tool for task tracking
914
+ - Update .specs/tasks.md regularly
915
+ - Document decisions in .specs/context.md
916
+ - Maintain .specs/prompts.md for AI interactions
917
+
918
+ ## Resources
919
+
920
+ ### Documentation
921
+ - [${context.language} Documentation](${this.getLanguageDocsUrl(context.language)})
922
+ ${context.framework ? `- [${context.framework} Documentation](${this.getFrameworkDocsUrl(context.framework)})` : ''}
923
+ - [Project API Documentation](./api.yaml)
924
+
925
+ ### Tools
926
+ - **IDE**: VSCode with recommended extensions
927
+ - **Testing**: ${this.getTestFramework(context.language)}
928
+ - **Linting**: ${this.getLintingTools(context.language)}
929
+ - **Version Control**: Git with conventional commits
930
+
931
+ ---
932
+ *Last updated: {{currentDate}}*`;
933
+ const rendered = this.templateEngine.renderFromString(content, context);
934
+ (0, fs_1.writeFileSync)((0, path_1.join)(specsDir, 'docs.md'), rendered);
935
+ }
936
+ getPrerequisites(language, framework) {
937
+ if (language === 'typescript') {
938
+ return `- Node.js 18+ LTS
939
+ - npm or yarn package manager
940
+ - Git for version control
941
+ ${framework === 'react' ? '- Modern web browser for development' : ''}`;
942
+ }
943
+ if (language === 'python') {
944
+ return `- Python 3.9+
945
+ - pip package manager
946
+ - Virtual environment (venv or conda)
947
+ - Git for version control`;
948
+ }
949
+ if (language === 'java') {
950
+ return `- Java 17+ JDK
951
+ - Maven 3.8+ or Gradle 7+
952
+ - Git for version control
953
+ - IDE (IntelliJ IDEA or Eclipse recommended)`;
954
+ }
955
+ return `- ${language} development environment
956
+ - Package manager
957
+ - Git for version control`;
958
+ }
959
+ getInstallCommand(language) {
960
+ if (language === 'typescript')
961
+ return 'npm install';
962
+ if (language === 'python')
963
+ return 'pip install -r requirements.txt';
964
+ if (language === 'java')
965
+ return 'mvn install';
966
+ return '# Install dependencies';
967
+ }
968
+ getEnvironmentSetup(language) {
969
+ if (language === 'typescript')
970
+ return 'cp .env.example .env';
971
+ if (language === 'python')
972
+ return 'python -m venv venv && source venv/bin/activate';
973
+ if (language === 'java')
974
+ return '# Set JAVA_HOME if needed';
975
+ return '# Set up environment variables';
976
+ }
977
+ getCodeStandards(language) {
978
+ if (language === 'typescript') {
979
+ return `- Use TypeScript strict mode
980
+ - Follow ESLint configuration
981
+ - Use Prettier for formatting
982
+ - Prefer functional programming patterns
983
+ - Comprehensive JSDoc comments`;
984
+ }
985
+ if (language === 'python') {
986
+ return `- Follow PEP 8 style guide
987
+ - Use type hints throughout
988
+ - Docstrings for all functions/classes
989
+ - Use Black for code formatting
990
+ - Maximum line length: 88 characters`;
991
+ }
992
+ if (language === 'java') {
993
+ return `- Follow Google Java Style Guide
994
+ - Use Checkstyle for enforcement
995
+ - Comprehensive Javadoc comments
996
+ - Prefer composition over inheritance
997
+ - Use modern Java features (17+)`;
998
+ }
999
+ return `- Follow ${language} best practices
1000
+ - Consistent code formatting
1001
+ - Comprehensive documentation`;
1002
+ }
1003
+ getProjectStructure(language, framework) {
1004
+ if (language === 'typescript' && framework === 'react') {
1005
+ return `├── src/
1006
+ │ ├── components/
1007
+ │ ├── hooks/
1008
+ │ ├── pages/
1009
+ │ ├── services/
1010
+ │ ├── utils/
1011
+ │ └── types/
1012
+ ├── public/
1013
+ ├── tests/
1014
+ └── .specs/`;
1015
+ }
1016
+ if (language === 'typescript' && framework === 'express') {
1017
+ return `├── src/
1018
+ │ ├── controllers/
1019
+ │ ├── middleware/
1020
+ │ ├── models/
1021
+ │ ├── routes/
1022
+ │ ├── services/
1023
+ │ └── utils/
1024
+ ├── tests/
1025
+ └── .specs/`;
1026
+ }
1027
+ return `├── src/
1028
+ │ ├── [source files]
1029
+ ├── tests/
1030
+ └── .specs/`;
1031
+ }
1032
+ getAvailableScripts(language, framework) {
1033
+ if (language === 'typescript') {
1034
+ return `\`\`\`bash
1035
+ npm run dev # Start development server
1036
+ npm run build # Build for production
1037
+ npm run test # Run test suite
1038
+ npm run lint # Run linting
1039
+ npm run type-check # TypeScript type checking
1040
+ \`\`\``;
1041
+ }
1042
+ return `\`\`\`bash
1043
+ # Add project-specific scripts here
1044
+ \`\`\``;
1045
+ }
1046
+ getDatabaseUrl(language) {
1047
+ return 'postgresql://user:pass@host/db';
1048
+ }
1049
+ getAuthenticationDocs(framework) {
1050
+ return `Bearer token authentication required for protected endpoints.
1051
+ Include in header: \`Authorization: Bearer <token>\``;
1052
+ }
1053
+ getMigrationCommands(language, framework) {
1054
+ return `# Run migrations
1055
+ # Add database migration commands here`;
1056
+ }
1057
+ getBackupCommands(language) {
1058
+ return `# Create backup
1059
+ # Add backup commands here`;
1060
+ }
1061
+ getBuildCommand(language) {
1062
+ if (language === 'typescript')
1063
+ return 'npm run build';
1064
+ if (language === 'python')
1065
+ return 'python -m build';
1066
+ if (language === 'java')
1067
+ return 'mvn package';
1068
+ return '# Build command';
1069
+ }
1070
+ getDeployCommand(language) {
1071
+ return '# Deploy command - configure based on deployment target';
1072
+ }
1073
+ getTroubleshootingCommands(language) {
1074
+ if (language === 'typescript') {
1075
+ return `rm -rf node_modules package-lock.json
1076
+ npm install`;
1077
+ }
1078
+ return '# Troubleshooting commands';
1079
+ }
1080
+ getLanguageDocsUrl(language) {
1081
+ const urls = {
1082
+ typescript: 'https://www.typescriptlang.org/docs/',
1083
+ python: 'https://docs.python.org/',
1084
+ java: 'https://docs.oracle.com/en/java/'
1085
+ };
1086
+ return urls[language] || '#';
1087
+ }
1088
+ getFrameworkDocsUrl(framework) {
1089
+ const urls = {
1090
+ react: 'https://react.dev/',
1091
+ express: 'https://expressjs.com/',
1092
+ django: 'https://docs.djangoproject.com/',
1093
+ fastapi: 'https://fastapi.tiangolo.com/',
1094
+ 'spring-boot': 'https://spring.io/projects/spring-boot'
1095
+ };
1096
+ return urls[framework || ''] || '#';
1097
+ }
1098
+ getLintingTools(language) {
1099
+ if (language === 'typescript')
1100
+ return 'ESLint + Prettier';
1101
+ if (language === 'python')
1102
+ return 'flake8 + black';
1103
+ if (language === 'java')
1104
+ return 'Checkstyle + SpotBugs';
1105
+ return 'Language-specific linting tools';
1106
+ }
1107
+ }
1108
+ exports.SpecGenerator = SpecGenerator;
1109
+ //# sourceMappingURL=specGenerator.js.map