sumulige-claude 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.claude/hooks/code-formatter.cjs +7 -2
  2. package/.claude/hooks/multi-session.cjs +9 -3
  3. package/.claude/hooks/pre-commit.cjs +0 -0
  4. package/.claude/hooks/pre-push.cjs +0 -0
  5. package/.claude/hooks/project-kickoff.cjs +22 -11
  6. package/.claude/hooks/rag-skill-loader.cjs +7 -0
  7. package/.claude/hooks/thinking-silent.cjs +9 -3
  8. package/.claude/hooks/todo-manager.cjs +19 -13
  9. package/.claude/hooks/verify-work.cjs +10 -4
  10. package/.claude/quality-gate.json +9 -3
  11. package/.claude/settings.local.json +18 -1
  12. package/.claude/templates/hooks/README.md +302 -0
  13. package/.claude/templates/hooks/hook.sh.template +94 -0
  14. package/.claude/templates/hooks/user-prompt-submit.cjs.template +116 -0
  15. package/.claude/templates/hooks/user-response-submit.cjs.template +94 -0
  16. package/.claude/templates/hooks/validate.js +173 -0
  17. package/.claude/workflow/document-scanner.js +426 -0
  18. package/.claude/workflow/knowledge-engine.js +941 -0
  19. package/.claude/workflow/notebooklm/browser.js +1028 -0
  20. package/.claude/workflow/phases/phase1-research.js +578 -0
  21. package/.claude/workflow/phases/phase1-research.ts +465 -0
  22. package/.claude/workflow/phases/phase2-approve.js +722 -0
  23. package/.claude/workflow/phases/phase3-plan.js +1200 -0
  24. package/.claude/workflow/phases/phase4-develop.js +894 -0
  25. package/.claude/workflow/search-cache.js +230 -0
  26. package/.claude/workflow/templates/approval.md +315 -0
  27. package/.claude/workflow/templates/development.md +377 -0
  28. package/.claude/workflow/templates/planning.md +328 -0
  29. package/.claude/workflow/templates/research.md +250 -0
  30. package/.claude/workflow/types.js +37 -0
  31. package/.claude/workflow/web-search.js +278 -0
  32. package/.claude-plugin/marketplace.json +2 -2
  33. package/AGENTS.md +416 -1
  34. package/CHANGELOG.md +7 -14
  35. package/Q&A.md +230 -213
  36. package/README.md +256 -230
  37. package/cli.js +20 -0
  38. package/config/quality-gate.json +9 -3
  39. package/development/cache/web-search/search_1193d605f8eb364651fc2f2041b58a31.json +36 -0
  40. package/development/cache/web-search/search_3798bf06960edc125f744a1abb5b72c5.json +36 -0
  41. package/development/cache/web-search/search_37c7d4843a53f0d83f1122a6f908a2a3.json +36 -0
  42. package/development/cache/web-search/search_44166fa0153709ee168485a22aa0ab40.json +36 -0
  43. package/development/cache/web-search/search_4deaebb1f77e86a8ca066dc5a49c59fd.json +36 -0
  44. package/development/cache/web-search/search_94da91789466070a7f545612e73c7372.json +36 -0
  45. package/development/cache/web-search/search_dd5de8491b8b803a3cb01339cd210fb0.json +36 -0
  46. package/development/knowledge-base/.index.clean.json +0 -0
  47. package/development/knowledge-base/.index.json +486 -0
  48. package/development/knowledge-base/test-best-practices.md +29 -0
  49. package/development/projects/proj_mkh1pazz_ixmt1/phase1/feasibility-report.md +160 -0
  50. package/development/projects/proj_mkh4jvnb_z7rwf/phase1/feasibility-report.md +160 -0
  51. package/development/projects/proj_mkh4jxkd_ewz5a/phase1/feasibility-report.md +160 -0
  52. package/development/projects/proj_mkh4k84n_ni73k/phase1/feasibility-report.md +160 -0
  53. package/development/projects/proj_mkh4wfyd_u9w88/phase1/feasibility-report.md +160 -0
  54. package/development/projects/proj_mkh4wsbo_iahvf/development/projects/proj_mkh4xbpg_4na5w/phase1/feasibility-report.md +160 -0
  55. package/development/projects/proj_mkh4wsbo_iahvf/phase1/feasibility-report.md +160 -0
  56. package/development/projects/proj_mkh4xulg_1ka8x/phase1/feasibility-report.md +160 -0
  57. package/development/projects/proj_mkh4xwhj_gch8j/phase1/feasibility-report.md +160 -0
  58. package/development/projects/proj_mkh4y2qk_9lm8z/phase1/feasibility-report.md +160 -0
  59. package/development/projects/proj_mkh4y2qk_9lm8z/phase2/requirements.md +226 -0
  60. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/PRD.md +345 -0
  61. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/TASK_PLAN.md +284 -0
  62. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/prototype/README.md +14 -0
  63. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/DEVELOPMENT_LOG.md +35 -0
  64. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/TASKS.md +34 -0
  65. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/.env.example +5 -0
  66. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/README.md +60 -0
  67. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/package.json +25 -0
  68. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/index.js +70 -0
  69. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/routes/index.js +48 -0
  70. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/health.test.js +20 -0
  71. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/jest.config.js +21 -0
  72. package/development/projects/proj_mkh7veqg_3lypc/phase1/feasibility-report.md +160 -0
  73. package/development/projects/proj_mkh7veqg_3lypc/phase2/requirements.md +226 -0
  74. package/development/projects/proj_mkh7veqg_3lypc/phase3/PRD.md +345 -0
  75. package/development/projects/proj_mkh7veqg_3lypc/phase3/TASK_PLAN.md +284 -0
  76. package/development/projects/proj_mkh7veqg_3lypc/phase3/prototype/README.md +14 -0
  77. package/development/projects/proj_mkh8k8fo_rmqn5/phase1/feasibility-report.md +160 -0
  78. package/development/projects/proj_mkh8xyhy_1vshq/phase1/feasibility-report.md +178 -0
  79. package/development/projects/proj_mkh8zddd_dhamf/phase1/feasibility-report.md +377 -0
  80. package/development/projects/proj_mkh8zddd_dhamf/phase2/requirements.md +442 -0
  81. package/development/projects/proj_mkh8zddd_dhamf/phase3/api-design.md +800 -0
  82. package/development/projects/proj_mkh8zddd_dhamf/phase3/architecture.md +625 -0
  83. package/development/projects/proj_mkh8zddd_dhamf/phase3/data-model.md +830 -0
  84. package/development/projects/proj_mkh8zddd_dhamf/phase3/risks.md +957 -0
  85. package/development/projects/proj_mkh8zddd_dhamf/phase3/wbs.md +381 -0
  86. package/development/todos/.state.json +14 -1
  87. package/development/todos/INDEX.md +31 -73
  88. package/development/todos/completed/develop/local-knowledge-index.md +85 -0
  89. package/development/todos/{active → completed/develop}/todo-system.md +13 -3
  90. package/development/todos/completed/develop/web-search-integration.md +83 -0
  91. package/development/todos/completed/test/phase1-e2e-test.md +103 -0
  92. package/docs/DEVELOPMENT.md +329 -291
  93. package/lib/commands.js +388 -0
  94. package/package.json +3 -2
  95. package/tests/config-manager.test.js +677 -0
  96. package/tests/config-validator.test.js +436 -0
  97. package/tests/errors.test.js +477 -0
  98. package/tests/manual/phase1-e2e.sh +389 -0
  99. package/tests/manual/phase2-test-cases.md +311 -0
  100. package/tests/manual/phase3-test-cases.md +309 -0
  101. package/tests/manual/phase4-test-cases.md +414 -0
  102. package/tests/manual/test-cases.md +417 -0
  103. package/tests/quality-gate.test.js +679 -0
  104. package/tests/quality-rules.test.js +619 -0
  105. package/tests/version-check.test.js +75 -0
@@ -0,0 +1,1200 @@
1
+ /**
2
+ * Phase 3: Planning - PRD, Prototype, and Task Plan
3
+ *
4
+ * Input: Phase 2 Requirements Document
5
+ * Output: PRD.md, prototype/, TASK_PLAN.md
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ // ============================================================================
12
+ // Configuration
13
+ // ============================================================================
14
+
15
+ const PROJECTS_DIR = path.join(process.cwd(), 'development/projects');
16
+
17
+ // ============================================================================
18
+ // Planning Validator
19
+ // ============================================================================
20
+
21
+ class PlanningValidator {
22
+ /**
23
+ * Validate a PRD and task plan from markdown content
24
+ */
25
+ static validateFromMarkdown(content) {
26
+ const checks = [];
27
+ const blockers = [];
28
+ const warnings = [];
29
+
30
+ // Check 1: Has PRD overview
31
+ const hasPRDOverview =
32
+ content.includes('# Product Requirements Document') ||
33
+ content.includes('# PRD') ||
34
+ content.includes('## Product Overview') ||
35
+ content.includes('## 产品概述');
36
+
37
+ checks.push({
38
+ name: 'PRD Overview',
39
+ passed: hasPRDOverview,
40
+ message: hasPRDOverview
41
+ ? 'Product overview defined'
42
+ : 'Missing product overview section'
43
+ });
44
+
45
+ if (!hasPRDOverview) {
46
+ blockers.push('Add product overview with vision and goals');
47
+ }
48
+
49
+ // Check 2: Has architecture design
50
+ const hasArchitecture =
51
+ content.includes('## Architecture') ||
52
+ content.includes('## 系统架构') ||
53
+ content.includes('## System Design') ||
54
+ content.includes('## Technical Design') ||
55
+ content.includes('## 技术设计') ||
56
+ content.includes('架构');
57
+
58
+ checks.push({
59
+ name: 'Architecture Design',
60
+ passed: hasArchitecture,
61
+ message: hasArchitecture
62
+ ? 'Architecture design included'
63
+ : 'Missing architecture design'
64
+ });
65
+
66
+ if (!hasArchitecture) {
67
+ blockers.push('Add system architecture design with components and interactions');
68
+ }
69
+
70
+ // Check 3: Has data model
71
+ const hasDataModel =
72
+ content.includes('## Data Model') ||
73
+ content.includes('## 数据模型') ||
74
+ content.includes('## Database Schema') ||
75
+ content.includes('## Database') ||
76
+ content.includes('### Entities') ||
77
+ content.includes('数据结构') ||
78
+ content.includes('schema');
79
+
80
+ checks.push({
81
+ name: 'Data Model',
82
+ passed: hasDataModel,
83
+ message: hasDataModel
84
+ ? 'Data model defined'
85
+ : 'Missing data model/schema'
86
+ });
87
+
88
+ if (!hasDataModel) {
89
+ warnings.push('Add data model or database schema for key entities');
90
+ }
91
+
92
+ // Check 4: Has API design
93
+ const hasAPIDesign =
94
+ content.includes('## API Design') ||
95
+ content.includes('## API 设计') ||
96
+ content.includes('## Endpoints') ||
97
+ content.includes('## Routes') ||
98
+ content.includes('API:') ||
99
+ content.includes('POST') ||
100
+ content.includes('GET /');
101
+
102
+ checks.push({
103
+ name: 'API Design',
104
+ passed: hasAPIDesign,
105
+ message: hasAPIDesign
106
+ ? 'API design included'
107
+ : 'Missing API design'
108
+ });
109
+
110
+ if (!hasAPIDesign) {
111
+ warnings.push('Add API design with key endpoints and request/response formats');
112
+ }
113
+
114
+ // Check 5: Has task breakdown
115
+ const hasTaskBreakdown =
116
+ content.includes('## Task Breakdown') ||
117
+ content.includes('## 任务分解') ||
118
+ content.includes('## Implementation Tasks') ||
119
+ content.includes('## Development Tasks') ||
120
+ content.includes('TASK-') ||
121
+ content.includes('### Task');
122
+
123
+ checks.push({
124
+ name: 'Task Breakdown',
125
+ passed: hasTaskBreakdown,
126
+ message: hasTaskBreakdown
127
+ ? 'Implementation tasks defined'
128
+ : 'Missing task breakdown'
129
+ });
130
+
131
+ if (!hasTaskBreakdown) {
132
+ blockers.push('Add implementation task breakdown with dependencies');
133
+ }
134
+
135
+ // Check 6: Has milestones
136
+ const hasMilestones =
137
+ content.includes('## Milestones') ||
138
+ content.includes('## 里程碑') ||
139
+ content.includes('## Timeline') ||
140
+ content.includes('## Schedule') ||
141
+ content.includes('Sprint') ||
142
+ content.includes('里程碑');
143
+
144
+ checks.push({
145
+ name: 'Milestones',
146
+ passed: hasMilestones,
147
+ message: hasMilestones
148
+ ? 'Project milestones defined'
149
+ : 'Missing project milestones'
150
+ });
151
+
152
+ if (!hasMilestones) {
153
+ warnings.push('Add project milestones or sprint schedule');
154
+ }
155
+
156
+ // Calculate score
157
+ const passedChecks = checks.filter(c => c.passed).length;
158
+ const score = Math.round((passedChecks / checks.length) * 100);
159
+
160
+ // Determine if passed (need at least 80% and no blockers)
161
+ const passed = score >= 80 && blockers.length === 0;
162
+
163
+ return {
164
+ passed,
165
+ score,
166
+ checks,
167
+ blockers,
168
+ warnings
169
+ };
170
+ }
171
+
172
+ /**
173
+ * Validate a PRD file
174
+ */
175
+ static validateFile(filePath) {
176
+ if (!fs.existsSync(filePath)) {
177
+ return {
178
+ passed: false,
179
+ score: 0,
180
+ checks: [],
181
+ blockers: [`File not found: ${filePath}`],
182
+ warnings: []
183
+ };
184
+ }
185
+
186
+ try {
187
+ const content = fs.readFileSync(filePath, 'utf-8');
188
+ return this.validateFromMarkdown(content);
189
+ } catch (error) {
190
+ return {
191
+ passed: false,
192
+ score: 0,
193
+ checks: [],
194
+ blockers: [`Failed to read file: ${error.message}`],
195
+ warnings: []
196
+ };
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Generate a validation report for display
202
+ */
203
+ static generateReport(result) {
204
+ const lines = [];
205
+
206
+ lines.push('═══════════════════════════════════════════════════════');
207
+ lines.push(' PRD & Task Plan Validation');
208
+ lines.push('═══════════════════════════════════════════════════════');
209
+ lines.push('');
210
+
211
+ // Status
212
+ const status = result.passed ? '✅ PASSED' : '❌ FAILED';
213
+ const statusColor = result.passed ? '🟢' : '🔴';
214
+ lines.push(`Status: ${statusColor} ${status} (Score: ${result.score}/100)`);
215
+ lines.push('');
216
+
217
+ // Checks
218
+ lines.push('Quality Checks:');
219
+ lines.push('───────────────────────────────────────────────────────');
220
+
221
+ result.checks.forEach(check => {
222
+ const icon = check.passed ? '✅' : '❌';
223
+ lines.push(` ${icon} ${check.name}: ${check.message || 'Failed'}`);
224
+ });
225
+
226
+ lines.push('');
227
+
228
+ // Blockers
229
+ if (result.blockers.length > 0) {
230
+ lines.push('🚫 BLOCKERS (must fix before proceeding):');
231
+ lines.push('───────────────────────────────────────────────────────');
232
+ result.blockers.forEach((blocker, i) => {
233
+ lines.push(` ${i + 1}. ${blocker}`);
234
+ });
235
+ lines.push('');
236
+ }
237
+
238
+ // Warnings
239
+ if (result.warnings.length > 0) {
240
+ lines.push('⚠️ WARNINGS (recommended improvements):');
241
+ lines.push('───────────────────────────────────────────────────────');
242
+ result.warnings.forEach((warning, i) => {
243
+ lines.push(` ${i + 1}. ${warning}`);
244
+ });
245
+ lines.push('');
246
+ }
247
+
248
+ // Recommendation
249
+ if (result.passed) {
250
+ lines.push('🎉 PRD and task plan meet quality standards! Ready for Phase 4 (Development).');
251
+ } else {
252
+ lines.push('📝 Planning documents need improvements. Address blockers and re-validate.');
253
+ }
254
+
255
+ lines.push('');
256
+ lines.push('═══════════════════════════════════════════════════════');
257
+
258
+ return lines.join('\n');
259
+ }
260
+ }
261
+
262
+ // ============================================================================
263
+ // Phase 3 Planning Executor
264
+ // ============================================================================
265
+
266
+ class Phase3PlanningExecutor {
267
+ constructor(projectId) {
268
+ this.projectId = projectId;
269
+ this.projectDir = path.join(PROJECTS_DIR, projectId);
270
+ this.phaseDir = path.join(this.projectDir, 'phase3');
271
+ this.prdPath = path.join(this.phaseDir, 'PRD.md');
272
+ this.taskPlanPath = path.join(this.phaseDir, 'TASK_PLAN.md');
273
+ this.prototypeDir = path.join(this.phaseDir, 'prototype');
274
+ this.phase2RequirementsPath = path.join(this.projectDir, 'phase2', 'requirements.md');
275
+ }
276
+
277
+ /**
278
+ * Ensure project directories exist
279
+ */
280
+ ensureDirectories() {
281
+ if (!fs.existsSync(this.phaseDir)) {
282
+ fs.mkdirSync(this.phaseDir, { recursive: true });
283
+ }
284
+ if (!fs.existsSync(this.prototypeDir)) {
285
+ fs.mkdirSync(this.prototypeDir, { recursive: true });
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Read Phase 2 requirements document
291
+ */
292
+ readPhase2Requirements() {
293
+ if (!fs.existsSync(this.phase2RequirementsPath)) {
294
+ return null;
295
+ }
296
+ return fs.readFileSync(this.phase2RequirementsPath, 'utf-8');
297
+ }
298
+
299
+ /**
300
+ * Extract key information from Phase 2 requirements
301
+ */
302
+ extractRequirementsSummary(requirementsContent) {
303
+ const summary = {
304
+ idea: '',
305
+ functionalRequirements: [],
306
+ nonFunctionalRequirements: [],
307
+ techStack: [],
308
+ successMetrics: [],
309
+ constraints: []
310
+ };
311
+
312
+ if (!requirementsContent) return summary;
313
+
314
+ // Extract original idea from Phase 1 summary
315
+ const ideaMatch = requirementsContent.match(/### Original Idea\s+([\s\S]*?)(?=##|---)/);
316
+ if (ideaMatch) {
317
+ summary.idea = ideaMatch[1].trim();
318
+ }
319
+
320
+ // Extract functional requirements (FR-XXX format)
321
+ const frMatches = requirementsContent.matchAll(/### FR-(\d+):[^\n]+\n+\*\*Description\*\*:[\s\S]*?(?=###|\n##)/g);
322
+ for (const match of frMatches) {
323
+ const titleMatch = match[0].match(/### FR-\d+:\s+([^\n]+)/);
324
+ const descMatch = match[0].match(/\*\*Description\*\*:\s*([^\n]+)/);
325
+ if (titleMatch) {
326
+ summary.functionalRequirements.push({
327
+ id: match[0].match(/### FR-(\d+)/)[1],
328
+ title: titleMatch[1].trim(),
329
+ description: descMatch ? descMatch[1].trim() : ''
330
+ });
331
+ }
332
+ }
333
+
334
+ // Extract non-functional requirements
335
+ const nfrSection = requirementsContent.match(/## Non-Functional Requirements\s+([\s\S]*?)(?=##|$)/);
336
+ if (nfrSection) {
337
+ const categories = nfrSection[1].split(/###|\*\*/);
338
+ categories.forEach(cat => {
339
+ if (cat.includes('Performance') || cat.includes('Security') ||
340
+ cat.includes('Reliability') || cat.includes('Maintainability')) {
341
+ summary.nonFunctionalRequirements.push(cat.trim());
342
+ }
343
+ });
344
+ }
345
+
346
+ // Extract success metrics
347
+ const metricsSection = requirementsContent.match(/## Success Metrics\s+([\s\S]*?)(?=##|$)/);
348
+ if (metricsSection) {
349
+ const tableRows = metricsSection[1].match(/\|[^|\n]*\|[^|\n]*\|[^|\n]*/g);
350
+ if (tableRows) {
351
+ tableRows.forEach(row => {
352
+ summary.successMetrics.push(row);
353
+ });
354
+ }
355
+ }
356
+
357
+ return summary;
358
+ }
359
+
360
+ /**
361
+ * Generate PRD template
362
+ */
363
+ generatePRDTemplate(requirementsSummary) {
364
+ const date = new Date().toLocaleDateString();
365
+ const time = new Date().toLocaleTimeString();
366
+
367
+ const idea = requirementsSummary.idea || '[From Phase 2 Requirements]';
368
+ const functionalReqs = requirementsSummary.functionalRequirements || [];
369
+
370
+ return `# Product Requirements Document (PRD)
371
+
372
+ **Project**: ${this.projectId}
373
+ **Date**: ${date} ${time}
374
+ **Phase**: 3 - Planning
375
+ **Status**: 🚧 In Progress
376
+
377
+ ---
378
+
379
+ ## Document Control
380
+
381
+ | Version | Date | Author | Changes |
382
+ |---------|------|--------|---------|
383
+ | 0.1 | ${date} | Claude | Initial draft |
384
+
385
+ ---
386
+
387
+ ## Executive Summary
388
+
389
+ > Brief overview of the product vision and goals
390
+
391
+ ### Vision
392
+ [Describe the product vision - what problem are we solving and why does it matter?]
393
+
394
+ ### Goals
395
+ 1. [Goal 1]
396
+ 2. [Goal 2]
397
+ 3. [Goal 3]
398
+
399
+ ### Success Criteria
400
+ [How will we measure success?]
401
+
402
+ ---
403
+
404
+ ## Product Overview
405
+
406
+ ### Background
407
+ ${idea}
408
+
409
+ ### Target Audience
410
+ | Segment | Description | Pain Points |
411
+ |---------|-------------|-------------|
412
+ | [Segment A] | [Description] | [Pain points] |
413
+ | [Segment B] | [Description] | [Pain points] |
414
+
415
+ ### User Personas
416
+ **Persona 1: [Name]**
417
+ - Role: [User role]
418
+ - Goals: [What they want to achieve]
419
+ - Frustrations: [Current pain points]
420
+ - Scenarios: [Usage scenarios]
421
+
422
+ ---
423
+
424
+ ## Functional Requirements
425
+
426
+ ### Core Features
427
+
428
+ ${functionalReqs.length > 0 ? functionalReqs.map((fr, i) => `
429
+ **FR-${String(i + 1).padStart(3, '0')}: ${fr.title}**
430
+ - **Description**: ${fr.description}
431
+ - **Priority**: Must Have
432
+ - **Dependencies**: [List dependencies]
433
+ `).join('') : `
434
+ **FR-001: [Feature Name]**
435
+ - **Description**: [What the feature does]
436
+ - **Priority**: Must Have / Should Have / Could Have
437
+ - **User Story**: As a [user], I want [action], so that [benefit]
438
+ - **Acceptance Criteria**:
439
+ - [ ] Given [context], when [action], then [outcome]
440
+ - [ ] Given [context], when [action], then [outcome]
441
+ `}
442
+
443
+ ### Future Features (Out of Scope for MVP)
444
+ - [Feature 1]: [Brief description]
445
+ - [Feature 2]: [Brief description]
446
+
447
+ ---
448
+
449
+ ## System Architecture
450
+
451
+ ### High-Level Architecture
452
+
453
+ \`\`\`
454
+ [Insert architecture diagram or ASCII art]
455
+
456
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
457
+ │ Frontend │ │ Backend │ │ Database │
458
+ │ (User Interface)│◄──►│ (API Gateway) │◄──►│ (Data Store) │
459
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
460
+ \`\`\`
461
+
462
+ ### Components
463
+
464
+ | Component | Responsibility | Technology |
465
+ |-----------|---------------|------------|
466
+ | [Frontend] | User interface | [To be decided] |
467
+ | [Backend API] | Business logic | [To be decided] |
468
+ | [Database] | Data persistence | [To be decided] |
469
+ | [Cache] | Performance optimization | [To be decided] |
470
+
471
+ ### Data Flow
472
+
473
+ 1. **User Action**: [User does X]
474
+ 2. **Request**: [Frontend sends request to API]
475
+ 3. **Processing**: [Backend processes request]
476
+ 4. **Response**: [Data returned to frontend]
477
+ 5. **Display**: [UI updates]
478
+
479
+ ---
480
+
481
+ ## Data Model
482
+
483
+ ### Entity Relationship Diagram
484
+
485
+ \`\`\`
486
+ [Insert ERD or describe relationships]
487
+
488
+ [Entity A] 1──N [Entity B]
489
+ [Entity B] N──1 [Entity C]
490
+ \`\`\`
491
+
492
+ ### Key Entities
493
+
494
+ **Entity 1: [Name]**
495
+ | Attribute | Type | Required | Description |
496
+ |-----------|------|----------|-------------|
497
+ | id | UUID | Yes | Primary key |
498
+ | name | String | Yes | Display name |
499
+ | created_at | Timestamp | Yes | Creation time |
500
+ | updated_at | Timestamp | Yes | Last update |
501
+
502
+ **Entity 2: [Name]**
503
+ | Attribute | Type | Required | Description |
504
+ |-----------|------|----------|-------------|
505
+ | id | UUID | Yes | Primary key |
506
+ | [attribute] | [type] | [Yes/No] | [Description] |
507
+
508
+ ---
509
+
510
+ ## API Design
511
+
512
+ ### API Guidelines
513
+ - RESTful conventions
514
+ - JSON request/response format
515
+ - Standard HTTP status codes
516
+ - Authentication: [Type, e.g., JWT]
517
+ - Rate limiting: [Limits]
518
+
519
+ ### Core Endpoints
520
+
521
+ | Method | Endpoint | Description | Request | Response |
522
+ |--------|----------|-------------|---------|----------|
523
+ | GET | /api/v1/resource | List items | - | 200: Item array |
524
+ | POST | /api/v1/resource | Create item | Item data | 201: Created item |
525
+ | GET | /api/v1/resource/:id | Get item | - | 200: Item details |
526
+ | PUT | /api/v1/resource/:id | Update item | Item data | 200: Updated item |
527
+ | DELETE | /api/v1/resource/:id | Delete item | - | 204: No content |
528
+
529
+ ### Example API Call
530
+
531
+ \`\`\`bash
532
+ # Get all items
533
+ GET /api/v1/items
534
+ Authorization: Bearer <token>
535
+
536
+ Response:
537
+ {
538
+ "data": [...],
539
+ "pagination": {
540
+ "page": 1,
541
+ "limit": 20,
542
+ "total": 100
543
+ }
544
+ }
545
+ \`\`\`
546
+
547
+ ---
548
+
549
+ ## Non-Functional Requirements
550
+
551
+ ### Performance
552
+ - API response time: < 200ms (p95)
553
+ - Page load time: < 2s
554
+ - Support concurrent users: [Number]
555
+
556
+ ### Security
557
+ - Authentication: [Method, e.g., JWT with 24h expiry]
558
+ - Authorization: [Model, e.g., RBAC]
559
+ - Data encryption: TLS 1.3 in transit, AES-256 at rest
560
+ - Input validation: All user inputs sanitized
561
+
562
+ ### Reliability
563
+ - Uptime target: 99.9%
564
+ - Error handling: Graceful degradation
565
+ - Backup strategy: [Backup approach]
566
+
567
+ ### Scalability
568
+ - Horizontal scaling capability
569
+ - Database sharding strategy (if needed)
570
+ - CDN for static assets
571
+
572
+ ### Maintainability
573
+ - Code coverage target: > 80%
574
+ - API documentation: Auto-generated from code
575
+ - Logging: Structured logging with correlation IDs
576
+
577
+ ---
578
+
579
+ ## User Interface Design
580
+
581
+ ### Design Principles
582
+ 1. [Principle 1]: [Description]
583
+ 2. [Principle 2]: [Description]
584
+
585
+ ### Screen Flow
586
+
587
+ \`\`\`
588
+ [Screen A] → [Screen B] → [Screen C]
589
+ ↓ ↓
590
+ [Screen D] ← [Screen E]
591
+ \`\`\`
592
+
593
+ ### Key Screens
594
+
595
+ **Screen 1: [Name]**
596
+ - Purpose: [What user accomplishes]
597
+ - Elements: [List key UI elements]
598
+ - Interactions: [User actions and responses]
599
+
600
+ ---
601
+
602
+ ## Testing Strategy
603
+
604
+ ### Test Levels
605
+ - **Unit Tests**: Test individual components
606
+ - **Integration Tests**: Test component interactions
607
+ - **E2E Tests**: Test complete user flows
608
+ - **Performance Tests**: Load and stress testing
609
+
610
+ ### Test Coverage
611
+ - Target coverage: 80%+
612
+ - Critical path coverage: 100%
613
+
614
+ ### Test Automation
615
+ - Unit test framework: [To be decided]
616
+ - E2E test framework: [To be decided]
617
+ - CI/CD integration: [Approach]
618
+
619
+ ---
620
+
621
+ ## Deployment Plan
622
+
623
+ ### Environments
624
+ | Environment | Purpose | URL |
625
+ |-------------|---------|-----|
626
+ | Development | Local development | localhost |
627
+ | Staging | Pre-production testing | staging.example.com |
628
+ | Production | Live environment | app.example.com |
629
+
630
+ ### Deployment Strategy
631
+ - [ ] CI/CD pipeline setup
632
+ - [ ] Database migrations
633
+ - [ ] Feature flags
634
+ - [ ] Rollback plan
635
+
636
+ ### Monitoring
637
+ - Application metrics: [Tool, e.g., DataDog]
638
+ - Error tracking: [Tool, e.g., Sentry]
639
+ - Log aggregation: [Tool, e.g., ELK]
640
+
641
+ ---
642
+
643
+ ## Risk Mitigation
644
+
645
+ | Risk | Probability | Impact | Mitigation |
646
+ |------|-------------|--------|------------|
647
+ | [Risk 1] | High | High | [Strategy] |
648
+ | [Risk 2] | Medium | Low | [Strategy] |
649
+
650
+ ---
651
+
652
+ ## Dependencies
653
+
654
+ ### Internal Dependencies
655
+ - [Service A]: [Purpose and API]
656
+ - [Service B]: [Purpose and API]
657
+
658
+ ### External Dependencies
659
+ - [Third-party API]: [Purpose and fallback]
660
+ - [Library X]: [Purpose and version]
661
+
662
+ ---
663
+
664
+ ## Open Questions
665
+
666
+ | Question | Proposed Answer | Status |
667
+ |----------|-----------------|--------|
668
+ | [Question 1] | [Answer] | [Open/Resolved] |
669
+ | [Question 2] | [Answer] | [Open/Resolved] |
670
+
671
+ ---
672
+
673
+ ## Appendix
674
+
675
+ ### Glossary
676
+ | Term | Definition |
677
+ |------|------------|
678
+ | [Term 1] | [Definition] |
679
+ | [Term 2] | [Definition] |
680
+
681
+ ### References
682
+ - [Reference 1]: [Link]
683
+ - [Reference 2]: [Link]
684
+
685
+ ---
686
+
687
+ ## Approval Checklist
688
+
689
+ - [x] Product vision is clear
690
+ - [ ] Functional requirements are complete
691
+ - [ ] Architecture is designed
692
+ - [ ] Data model is defined
693
+ - [ ] API endpoints are specified
694
+ - [ ] Non-functional requirements are documented
695
+ - [ ] Test strategy is defined
696
+ - [ ] Deployment plan is outlined
697
+
698
+ ---
699
+
700
+ ## Next Steps (Phase 4: Development)
701
+
702
+ 1. [ ] Review and approve PRD
703
+ 2. [ ] Set up development environment
704
+ 3. [ ] Create initial project structure
705
+ 4. [ ] Begin implementation based on TASK_PLAN.md
706
+
707
+ ---
708
+
709
+ ## Metadata
710
+
711
+ - **Generated**: ${date} ${time}
712
+ - **Phase 2 Requirements**: \`../phase2/requirements.md\`
713
+ - **Task Plan**: \`TASK_PLAN.md\`
714
+
715
+ ---
716
+
717
+ *This PRD was generated by the Phase 3 Planning Executor.*
718
+ `;
719
+ }
720
+
721
+ /**
722
+ * Generate TASK_PLAN template
723
+ */
724
+ generateTaskPlanTemplate(requirementsSummary) {
725
+ const date = new Date().toLocaleDateString();
726
+
727
+ return `# Implementation Task Plan
728
+
729
+ **Project**: ${this.projectId}
730
+ **Created**: ${date}
731
+ **Phase**: 4 - Development
732
+
733
+ ---
734
+
735
+ ## Overview
736
+
737
+ This task plan breaks down the implementation into manageable tasks with clear dependencies and time estimates.
738
+
739
+ ---
740
+
741
+ ## Task Breakdown
742
+
743
+ ### Sprint 1: Foundation (Week 1)
744
+
745
+ #### TASK-001: Project Setup
746
+ - **Description**: Set up development environment and project structure
747
+ - **Priority**: P0 (Must Have)
748
+ - **Estimated**: 2 hours
749
+ - **Dependencies**: None
750
+ - **Owner**: [To be assigned]
751
+ - **Acceptance Criteria**:
752
+ - [ ] Repository initialized with proper structure
753
+ - [ ] Development environment configured
754
+ - [ ] CI/CD pipeline set up
755
+ - [ ] Code quality tools configured (linter, formatter)
756
+
757
+ #### TASK-002: Database Schema Implementation
758
+ - **Description**: Create database schema and migrations
759
+ - **Priority**: P0 (Must Have)
760
+ - **Estimated**: 3 hours
761
+ - **Dependencies**: TASK-001
762
+ - **Owner**: [To be assigned]
763
+ - **Acceptance Criteria**:
764
+ - [ ] All entities defined in PRD implemented
765
+ - [ ] Migration scripts created
766
+ - [ ] Seed data for development
767
+ - [ ] Indexes created for performance
768
+
769
+ #### TASK-003: Core API Infrastructure
770
+ - **Description**: Set up API framework and base controllers
771
+ - **Priority**: P0 (Must Have)
772
+ - **Estimated**: 4 hours
773
+ - **Dependencies**: TASK-001, TASK-002
774
+ - **Owner**: [To be assigned]
775
+ - **Acceptance Criteria**:
776
+ - [ ] API framework configured
777
+ - [ ] Authentication middleware
778
+ - [ ] Error handling middleware
779
+ - [ ] Request validation
780
+ - [ ] API documentation scaffold
781
+
782
+ ### Sprint 2: Core Features (Week 2)
783
+
784
+ #### TASK-004: [Feature A] Implementation
785
+ - **Description**: Implement [Feature A] as per FR-001
786
+ - **Priority**: P0 (Must Have)
787
+ - **Estimated**: 6 hours
788
+ - **Dependencies**: TASK-003
789
+ - **Owner**: [To be assigned]
790
+ - **Acceptance Criteria**:
791
+ - [ ] API endpoint implemented
792
+ - [ ] Business logic complete
793
+ - [ ] Unit tests written (>80% coverage)
794
+ - [ ] API documentation updated
795
+
796
+ #### TASK-005: [Feature B] Implementation
797
+ - **Description**: Implement [Feature B] as per FR-002
798
+ - **Priority**: P0 (Must Have)
799
+ - **Estimated**: 5 hours
800
+ - **Dependencies**: TASK-003
801
+ - **Owner**: [To be assigned]
802
+ - **Acceptance Criteria**:
803
+ - [ ] API endpoint implemented
804
+ - [ ] Business logic complete
805
+ - [ ] Unit tests written
806
+ - [ ] API documentation updated
807
+
808
+ #### TASK-006: Frontend Base Setup
809
+ - **Description**: Set up frontend framework and routing
810
+ - **Priority**: P0 (Must Have)
811
+ - **Estimated**: 3 hours
812
+ - **Dependencies**: TASK-001
813
+ - **Owner**: [To be assigned]
814
+ - **Acceptance Criteria**:
815
+ - [ ] Framework configured
816
+ - [ ] Base layout created
817
+ - [ ] Routing configured
818
+ - [ ] State management set up
819
+
820
+ ### Sprint 3: User Interface (Week 3)
821
+
822
+ #### TASK-007: [Screen A] Implementation
823
+ - **Description**: Build [Screen A] UI
824
+ - **Priority**: P1 (Should Have)
825
+ - **Estimated**: 4 hours
826
+ - **Dependencies**: TASK-006, TASK-004
827
+ - **Owner**: [To be assigned]
828
+ - **Acceptance Criteria**:
829
+ - [ ] UI matches design specification
830
+ - [ ] Responsive design (mobile, tablet, desktop)
831
+ - [ ] Loading states handled
832
+ - [ ] Error states handled
833
+ - [ ] Accessibility (WCAG 2.1 AA)
834
+
835
+ #### TASK-008: [Screen B] Implementation
836
+ - **Description**: Build [Screen B] UI
837
+ - **Priority**: P1 (Should Have)
838
+ - **Estimated**: 4 hours
839
+ - **Dependencies**: TASK-006, TASK-005
840
+ - **Owner**: [To be assigned]
841
+ - **Acceptance Criteria**:
842
+ - [ ] UI matches design specification
843
+ - [ ] Responsive design
844
+ - [ ] Loading/error states handled
845
+ - [ ] Accessibility compliance
846
+
847
+ ### Sprint 4: Integration & Testing (Week 4)
848
+
849
+ #### TASK-009: API Integration
850
+ - **Description**: Connect frontend to backend APIs
851
+ - **Priority**: P0 (Must Have)
852
+ - **Estimated**: 4 hours
853
+ - **Dependencies**: TASK-007, TASK-008, TASK-004, TASK-005
854
+ - **Owner**: [To be assigned]
855
+ - **Acceptance Criteria**:
856
+ - [ ] All screens connected to APIs
857
+ - [ ] Error handling complete
858
+ - [ ] Loading indicators working
859
+ - [ ] Data flow verified
860
+
861
+ #### TASK-010: End-to-End Testing
862
+ - **Description**: Write and execute E2E tests
863
+ - **Priority**: P0 (Must Have)
864
+ - **Estimated**: 3 hours
865
+ - **Dependencies**: TASK-009
866
+ - **Owner**: [To be assigned]
867
+ - **Acceptance Criteria**:
868
+ - [ ] Critical user paths covered
869
+ - [ ] Tests automated in CI/CD
870
+ - [ ] All tests passing
871
+ - [ ] Performance benchmarks met
872
+
873
+ #### TASK-011: Performance Optimization
874
+ - **Description**: Optimize application performance
875
+ - **Priority**: P1 (Should Have)
876
+ - **Estimated**: 3 hours
877
+ - **Dependencies**: TASK-010
878
+ - **Owner**: [To be assigned]
879
+ - **Acceptance Criteria**:
880
+ - [ ] API response time < 200ms (p95)
881
+ - [ ] Page load time < 2s
882
+ - [ ] Bundle size optimized
883
+ - [ ] Images/assets optimized
884
+
885
+ ### Sprint 5: Deployment (Week 5)
886
+
887
+ #### TASK-012: Production Setup
888
+ - **Description**: Prepare production environment
889
+ - **Priority**: P0 (Must Have)
890
+ - **Estimated**: 2 hours
891
+ - **Dependencies**: TASK-011
892
+ - **Owner**: [To be assigned]
893
+ - **Acceptance Criteria**:
894
+ - [ ] Production environment configured
895
+ - [ ] Database configured
896
+ - [ ] SSL certificate installed
897
+ - [ ] Monitoring configured
898
+ - [ ] Backup strategy in place
899
+
900
+ #### TASK-013: Deployment & Verification
901
+ - **Description**: Deploy to production and verify
902
+ - **Priority**: P0 (Must Have)
903
+ - **Estimated**: 2 hours
904
+ - **Dependencies**: TASK-012
905
+ - **Owner**: [To be assigned]
906
+ - **Acceptance Criteria**:
907
+ - [ ] Application deployed
908
+ - [ ] Smoke tests passing
909
+ - [ ] Monitoring data flowing
910
+ - [ ] Rollback plan documented
911
+
912
+ ---
913
+
914
+ ## Task Dependencies
915
+
916
+ \`\`\`
917
+ TASK-001 (Project Setup)
918
+
919
+ ├──→ TASK-002 (Database)
920
+ │ │
921
+ │ └──→ TASK-003 (API Infrastructure)
922
+ │ │
923
+ │ ├──→ TASK-004 (Feature A)
924
+ │ │ │
925
+ │ │ └──→ TASK-009 (Integration)
926
+ │ │ │
927
+ │ ├──→ TASK-005 (Feature B)────────┘
928
+ │ │
929
+ │ └──→ TASK-006 (Frontend Setup)
930
+ │ │
931
+ │ ├──→ TASK-007 (Screen A)──┐
932
+ │ │ │
933
+ │ └──→ TASK-008 (Screen B)──┴─→ TASK-009
934
+ │ │
935
+ └──────────────────────────────────────────────────────────→ TASK-010
936
+
937
+ └──→ TASK-011
938
+
939
+ └──→ TASK-012
940
+
941
+ └──→ TASK-013
942
+ \`\`\`
943
+
944
+ ---
945
+
946
+ ## Milestones
947
+
948
+ | Milestone | Tasks | Target Date | Status |
949
+ |-----------|-------|-------------|--------|
950
+ | M1: Foundation | TASK-001 to TASK-003 | Week 1 | 🔲 Pending |
951
+ | M2: Core Features | TASK-004 to TASK-006 | Week 2 | 🔲 Pending |
952
+ | M3: UI Complete | TASK-007 to TASK-008 | Week 3 | 🔲 Pending |
953
+ | M4: Test & Optimize | TASK-009 to TASK-011 | Week 4 | 🔲 Pending |
954
+ | M5: Production | TASK-012 to TASK-013 | Week 5 | 🔲 Pending |
955
+
956
+ ---
957
+
958
+ ## Time Estimates
959
+
960
+ | Phase | Tasks | Total Hours |
961
+ |-------|-------|-------------|
962
+ | Sprint 1 | TASK-001 to TASK-003 | 9h |
963
+ | Sprint 2 | TASK-004 to TASK-006 | 14h |
964
+ | Sprint 3 | TASK-007 to TASK-008 | 8h |
965
+ | Sprint 4 | TASK-009 to TASK-011 | 10h |
966
+ | Sprint 5 | TASK-012 to TASK-013 | 4h |
967
+ | **Total** | **All tasks** | **45h** |
968
+
969
+ ---
970
+
971
+ ## Risk & Mitigation
972
+
973
+ | Risk | Impact | Mitigation |
974
+ |------|--------|------------|
975
+ | Task estimation errors | Delayed delivery | Add 20% buffer to estimates |
976
+ | Technical blockers | Sprint delays | Identify and address early |
977
+ | Resource availability | Bottleneck | Cross-train team members |
978
+
979
+ ---
980
+
981
+ ## Definition of Done
982
+
983
+ A task is complete when:
984
+ - [ ] Code is written and follows style guidelines
985
+ - [ ] Unit tests written (coverage > 80%)
986
+ - [ ] Code reviewed by at least one person
987
+ - [ ] Documentation updated
988
+ - [ ] Tests passing in CI/CD
989
+ - [ ] No critical bugs
990
+
991
+ ---
992
+
993
+ ## Daily Standup Format
994
+
995
+ Each team member shares:
996
+ 1. **Yesterday**: What I completed
997
+ 2. **Today**: What I plan to work on
998
+ 3. **Blockers**: Anything blocking progress
999
+
1000
+ ---
1001
+
1002
+ ## Notes
1003
+
1004
+ - Update task status as work progresses
1005
+ - Add new tasks as scope changes
1006
+ - Archive completed tasks for reference
1007
+
1008
+ ---
1009
+
1010
+ *Generated by Phase 3 Planning Executor*
1011
+ `;
1012
+ }
1013
+
1014
+ /**
1015
+ * Execute Phase 3 planning workflow
1016
+ */
1017
+ async execute(progressCallback) {
1018
+ await progressCallback?.('Initializing Phase 3 planning...', 0, 6);
1019
+
1020
+ // Ensure directories exist
1021
+ this.ensureDirectories();
1022
+
1023
+ // Step 1: Read Phase 2 requirements
1024
+ await progressCallback?.('Reading Phase 2 requirements...', 1, 6);
1025
+ const requirementsContent = this.readPhase2Requirements();
1026
+
1027
+ if (!requirementsContent) {
1028
+ throw new Error(`Phase 2 requirements not found: ${this.phase2RequirementsPath}`);
1029
+ }
1030
+
1031
+ // Step 2: Extract requirements summary
1032
+ await progressCallback?.('Analyzing requirements...', 2, 6);
1033
+ const requirementsSummary = this.extractRequirementsSummary(requirementsContent);
1034
+
1035
+ // Step 3: Generate PRD
1036
+ await progressCallback?.('Generating PRD template...', 3, 6);
1037
+
1038
+ const prdTemplate = this.generatePRDTemplate(requirementsSummary);
1039
+ await fs.promises.writeFile(this.prdPath, prdTemplate, 'utf-8');
1040
+
1041
+ // Step 4: Generate Task Plan
1042
+ await progressCallback?.('Generating task plan...', 4, 6);
1043
+
1044
+ const taskPlanTemplate = this.generateTaskPlanTemplate(requirementsSummary);
1045
+ await fs.promises.writeFile(this.taskPlanPath, taskPlanTemplate, 'utf-8');
1046
+
1047
+ // Step 5: Create prototype structure
1048
+ await progressCallback?.('Creating prototype directory structure...', 5, 6);
1049
+
1050
+ // Create prototype placeholder files
1051
+ const prototypeReadme = path.join(this.prototypeDir, 'README.md');
1052
+ await fs.promises.writeFile(
1053
+ prototypeReadme,
1054
+ `# Prototype - ${this.projectId}
1055
+
1056
+ This directory contains prototype and proof-of-concept code.
1057
+
1058
+ ## Structure
1059
+
1060
+ - \`mocks/\` - Mock data and API responses
1061
+ - \`screens/\` - UI screen mockups
1062
+ - \`proof-of-concept/\` - Experimental code
1063
+
1064
+ ## Notes
1065
+
1066
+ This is a working directory for prototyping and experimentation.
1067
+ Code here may not follow production standards.
1068
+ `,
1069
+ 'utf-8'
1070
+ );
1071
+
1072
+ await progressCallback?.('Phase 3 planning complete. Ready for detailed design.', 6, 6);
1073
+
1074
+ return {
1075
+ projectId: this.projectId,
1076
+ prdPath: this.prdPath,
1077
+ taskPlanPath: this.taskPlanPath,
1078
+ prototypeDir: this.prototypeDir,
1079
+ requirementsSummary,
1080
+ nextSteps: [
1081
+ 'Review and complete the PRD',
1082
+ 'Review and adjust the task plan',
1083
+ 'Create prototypes/proofs-of-concept',
1084
+ 'Validate with: smc workflow validate',
1085
+ 'Proceed to Phase 4'
1086
+ ]
1087
+ };
1088
+ }
1089
+
1090
+ /**
1091
+ * Check if PRD exists
1092
+ */
1093
+ prdExists() {
1094
+ return fs.existsSync(this.prdPath);
1095
+ }
1096
+
1097
+ /**
1098
+ * Check if task plan exists
1099
+ */
1100
+ taskPlanExists() {
1101
+ return fs.existsSync(this.taskPlanPath);
1102
+ }
1103
+
1104
+ /**
1105
+ * Read the PRD
1106
+ */
1107
+ readPRD() {
1108
+ if (!this.prdExists()) return null;
1109
+ return fs.readFileSync(this.prdPath, 'utf-8');
1110
+ }
1111
+
1112
+ /**
1113
+ * Read the task plan
1114
+ */
1115
+ readTaskPlan() {
1116
+ if (!this.taskPlanExists()) return null;
1117
+ return fs.readFileSync(this.taskPlanPath, 'utf-8');
1118
+ }
1119
+
1120
+ /**
1121
+ * Validate the PRD
1122
+ */
1123
+ validatePRD() {
1124
+ return PlanningValidator.validateFile(this.prdPath);
1125
+ }
1126
+
1127
+ /**
1128
+ * Get phase info
1129
+ */
1130
+ getPhaseInfo() {
1131
+ return {
1132
+ phase: 3,
1133
+ name: 'Planning',
1134
+ description: 'PRD, prototype, and task plan',
1135
+ input: 'Phase 2 Requirements Document',
1136
+ output: 'PRD.md, TASK_PLAN.md, prototype/',
1137
+ status: this.prdExists() ? 'In Progress' : 'Not Started',
1138
+ files: {
1139
+ prd: this.prdPath,
1140
+ taskPlan: this.taskPlanPath,
1141
+ prototype: this.prototypeDir,
1142
+ phase2Requirements: this.phase2RequirementsPath
1143
+ }
1144
+ };
1145
+ }
1146
+ }
1147
+
1148
+ // ============================================================================
1149
+ // Project Management Helpers
1150
+ // ============================================================================
1151
+
1152
+ function getProjectsWithAllPhases() {
1153
+ if (!fs.existsSync(PROJECTS_DIR)) {
1154
+ return [];
1155
+ }
1156
+
1157
+ const projects = [];
1158
+ const entries = fs.readdirSync(PROJECTS_DIR, { withFileTypes: true });
1159
+
1160
+ for (const entry of entries) {
1161
+ if (entry.isDirectory() && entry.name.startsWith('proj_')) {
1162
+ const projectPath = path.join(PROJECTS_DIR, entry.name);
1163
+ const phase1Report = path.join(projectPath, 'phase1', 'feasibility-report.md');
1164
+ const phase2Requirements = path.join(projectPath, 'phase2', 'requirements.md');
1165
+ const phase3PRD = path.join(projectPath, 'phase3', 'PRD.md');
1166
+
1167
+ let currentPhase = 1;
1168
+ let status = 'draft';
1169
+
1170
+ if (fs.existsSync(phase3PRD)) {
1171
+ currentPhase = 3;
1172
+ status = 'planned';
1173
+ } else if (fs.existsSync(phase2Requirements)) {
1174
+ currentPhase = 2;
1175
+ status = 'in_progress';
1176
+ } else if (fs.existsSync(phase1Report)) {
1177
+ currentPhase = 1;
1178
+ status = 'review';
1179
+ }
1180
+
1181
+ projects.push({
1182
+ id: entry.name,
1183
+ path: projectPath,
1184
+ currentPhase,
1185
+ status,
1186
+ hasPhase1: fs.existsSync(phase1Report),
1187
+ hasPhase2: fs.existsSync(phase2Requirements),
1188
+ hasPhase3: fs.existsSync(phase3PRD)
1189
+ });
1190
+ }
1191
+ }
1192
+
1193
+ return projects.sort((a, b) => b.id.localeCompare(a.id));
1194
+ }
1195
+
1196
+ module.exports = {
1197
+ Phase3PlanningExecutor,
1198
+ PlanningValidator,
1199
+ getProjectsWithAllPhases
1200
+ };