sumulige-claude 1.1.2 → 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 (102) 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 +16 -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 +176 -0
  34. package/CHANGELOG.md +7 -14
  35. package/cli.js +20 -0
  36. package/config/quality-gate.json +9 -3
  37. package/development/cache/web-search/search_1193d605f8eb364651fc2f2041b58a31.json +36 -0
  38. package/development/cache/web-search/search_3798bf06960edc125f744a1abb5b72c5.json +36 -0
  39. package/development/cache/web-search/search_37c7d4843a53f0d83f1122a6f908a2a3.json +36 -0
  40. package/development/cache/web-search/search_44166fa0153709ee168485a22aa0ab40.json +36 -0
  41. package/development/cache/web-search/search_4deaebb1f77e86a8ca066dc5a49c59fd.json +36 -0
  42. package/development/cache/web-search/search_94da91789466070a7f545612e73c7372.json +36 -0
  43. package/development/cache/web-search/search_dd5de8491b8b803a3cb01339cd210fb0.json +36 -0
  44. package/development/knowledge-base/.index.clean.json +0 -0
  45. package/development/knowledge-base/.index.json +486 -0
  46. package/development/knowledge-base/test-best-practices.md +29 -0
  47. package/development/projects/proj_mkh1pazz_ixmt1/phase1/feasibility-report.md +160 -0
  48. package/development/projects/proj_mkh4jvnb_z7rwf/phase1/feasibility-report.md +160 -0
  49. package/development/projects/proj_mkh4jxkd_ewz5a/phase1/feasibility-report.md +160 -0
  50. package/development/projects/proj_mkh4k84n_ni73k/phase1/feasibility-report.md +160 -0
  51. package/development/projects/proj_mkh4wfyd_u9w88/phase1/feasibility-report.md +160 -0
  52. package/development/projects/proj_mkh4wsbo_iahvf/development/projects/proj_mkh4xbpg_4na5w/phase1/feasibility-report.md +160 -0
  53. package/development/projects/proj_mkh4wsbo_iahvf/phase1/feasibility-report.md +160 -0
  54. package/development/projects/proj_mkh4xulg_1ka8x/phase1/feasibility-report.md +160 -0
  55. package/development/projects/proj_mkh4xwhj_gch8j/phase1/feasibility-report.md +160 -0
  56. package/development/projects/proj_mkh4y2qk_9lm8z/phase1/feasibility-report.md +160 -0
  57. package/development/projects/proj_mkh4y2qk_9lm8z/phase2/requirements.md +226 -0
  58. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/PRD.md +345 -0
  59. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/TASK_PLAN.md +284 -0
  60. package/development/projects/proj_mkh4y2qk_9lm8z/phase3/prototype/README.md +14 -0
  61. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/DEVELOPMENT_LOG.md +35 -0
  62. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/TASKS.md +34 -0
  63. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/.env.example +5 -0
  64. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/README.md +60 -0
  65. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/package.json +25 -0
  66. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/index.js +70 -0
  67. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/src/routes/index.js +48 -0
  68. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/health.test.js +20 -0
  69. package/development/projects/proj_mkh4y2qk_9lm8z/phase4/source/tests/jest.config.js +21 -0
  70. package/development/projects/proj_mkh7veqg_3lypc/phase1/feasibility-report.md +160 -0
  71. package/development/projects/proj_mkh7veqg_3lypc/phase2/requirements.md +226 -0
  72. package/development/projects/proj_mkh7veqg_3lypc/phase3/PRD.md +345 -0
  73. package/development/projects/proj_mkh7veqg_3lypc/phase3/TASK_PLAN.md +284 -0
  74. package/development/projects/proj_mkh7veqg_3lypc/phase3/prototype/README.md +14 -0
  75. package/development/projects/proj_mkh8k8fo_rmqn5/phase1/feasibility-report.md +160 -0
  76. package/development/projects/proj_mkh8xyhy_1vshq/phase1/feasibility-report.md +178 -0
  77. package/development/projects/proj_mkh8zddd_dhamf/phase1/feasibility-report.md +377 -0
  78. package/development/projects/proj_mkh8zddd_dhamf/phase2/requirements.md +442 -0
  79. package/development/projects/proj_mkh8zddd_dhamf/phase3/api-design.md +800 -0
  80. package/development/projects/proj_mkh8zddd_dhamf/phase3/architecture.md +625 -0
  81. package/development/projects/proj_mkh8zddd_dhamf/phase3/data-model.md +830 -0
  82. package/development/projects/proj_mkh8zddd_dhamf/phase3/risks.md +957 -0
  83. package/development/projects/proj_mkh8zddd_dhamf/phase3/wbs.md +381 -0
  84. package/development/todos/.state.json +14 -1
  85. package/development/todos/INDEX.md +31 -73
  86. package/development/todos/completed/develop/local-knowledge-index.md +85 -0
  87. package/development/todos/{active → completed/develop}/todo-system.md +13 -3
  88. package/development/todos/completed/develop/web-search-integration.md +83 -0
  89. package/development/todos/completed/test/phase1-e2e-test.md +103 -0
  90. package/lib/commands.js +388 -0
  91. package/package.json +3 -2
  92. package/tests/config-manager.test.js +677 -0
  93. package/tests/config-validator.test.js +436 -0
  94. package/tests/errors.test.js +477 -0
  95. package/tests/manual/phase1-e2e.sh +389 -0
  96. package/tests/manual/phase2-test-cases.md +311 -0
  97. package/tests/manual/phase3-test-cases.md +309 -0
  98. package/tests/manual/phase4-test-cases.md +414 -0
  99. package/tests/manual/test-cases.md +417 -0
  100. package/tests/quality-gate.test.js +679 -0
  101. package/tests/quality-rules.test.js +619 -0
  102. package/tests/version-check.test.js +75 -0
@@ -0,0 +1,578 @@
1
+ /**
2
+ * Phase 1: Research - NotebookLM Feasibility Analysis (JavaScript version)
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ // ============================================================================
9
+ // Configuration
10
+ // ============================================================================
11
+
12
+ const PROJECTS_DIR = path.join(process.cwd(), 'development/projects');
13
+
14
+ // ============================================================================
15
+ // Feasibility Validator
16
+ // ============================================================================
17
+
18
+ class FeasibilityValidator {
19
+ /**
20
+ * Validate a feasibility report from markdown content
21
+ */
22
+ static validateFromMarkdown(content) {
23
+ const checks = [];
24
+ const blockers = [];
25
+ const warnings = [];
26
+
27
+ // Check 1: Has requirement summary
28
+ const hasRequirementSummary =
29
+ content.includes('## Requirements Summary') ||
30
+ content.includes('## 需求概述') ||
31
+ content.includes('# 需求') ||
32
+ content.match(/需求|问题|目标|用户/);
33
+
34
+ checks.push({
35
+ name: 'Requirement Summary',
36
+ passed: hasRequirementSummary,
37
+ message: hasRequirementSummary
38
+ ? 'Requirement summary found'
39
+ : 'Missing requirement summary section'
40
+ });
41
+
42
+ if (!hasRequirementSummary) {
43
+ blockers.push('Add a requirements summary section describing what we are building');
44
+ }
45
+
46
+ // Check 2: Has correlation analysis
47
+ const hasCorrelationAnalysis =
48
+ content.includes('## Correlation Analysis') ||
49
+ content.includes('## 关联分析') ||
50
+ content.includes('## 关联发现') ||
51
+ content.includes('Related Projects') ||
52
+ content.includes('相关项目') ||
53
+ content.includes('reusable');
54
+
55
+ checks.push({
56
+ name: 'Correlation Analysis',
57
+ passed: hasCorrelationAnalysis,
58
+ message: hasCorrelationAnalysis
59
+ ? 'Correlation analysis found'
60
+ : 'Missing correlation analysis - connect the dots with related work'
61
+ });
62
+
63
+ if (!hasCorrelationAnalysis) {
64
+ warnings.push('Add correlation analysis to find related work and reusable components');
65
+ }
66
+
67
+ // Check 3: Has best practices
68
+ const hasBestPractices =
69
+ content.includes('## Best Practices') ||
70
+ content.includes('## 业界最佳实践') ||
71
+ content.includes('## 最佳实践') ||
72
+ content.includes('Industry') ||
73
+ content.includes('sources') ||
74
+ content.includes('参考');
75
+
76
+ checks.push({
77
+ name: 'Best Practices Research',
78
+ passed: hasBestPractices,
79
+ message: hasBestPractices
80
+ ? 'Best practices research found'
81
+ : 'Missing industry best practices research'
82
+ });
83
+
84
+ if (!hasBestPractices) {
85
+ blockers.push('Add best practices research with cited sources');
86
+ }
87
+
88
+ // Check 4: Has feasibility conclusion
89
+ const hasFeasibilityConclusion =
90
+ content.includes('## Feasibility Assessment') ||
91
+ content.includes('## 可行性评估') ||
92
+ content.includes('feasibility') ||
93
+ content.includes('可行性') ||
94
+ content.match(/⭐\s*\d|难度|复杂度|Technical/);
95
+
96
+ checks.push({
97
+ name: 'Feasibility Conclusion',
98
+ passed: hasFeasibilityConclusion,
99
+ message: hasFeasibilityConclusion
100
+ ? 'Feasibility assessment found'
101
+ : 'Missing feasibility assessment with concrete ratings'
102
+ });
103
+
104
+ if (!hasFeasibilityConclusion) {
105
+ blockers.push('Add feasibility assessment with technical complexity rating (⭐ 1-5)');
106
+ }
107
+
108
+ // Check 5: Has time estimate
109
+ const hasTimeEstimate =
110
+ content.includes('Time Estimate') ||
111
+ content.includes('时间预估') ||
112
+ content.includes('estimated') ||
113
+ content.match(/\d+\s*(hour|h|小时|day|天)/);
114
+
115
+ checks.push({
116
+ name: 'Time Estimate',
117
+ passed: hasTimeEstimate,
118
+ message: hasTimeEstimate
119
+ ? 'Time estimate found'
120
+ : 'Missing time estimate for implementation'
121
+ });
122
+
123
+ if (!hasTimeEstimate) {
124
+ warnings.push('Add concrete time estimate (e.g., "4 hours")');
125
+ }
126
+
127
+ // Check 6: Has risk assessment
128
+ const hasRiskAssessment =
129
+ content.includes('## Risk') ||
130
+ content.includes('## 风险') ||
131
+ content.includes('risk') ||
132
+ content.includes('mitigation') ||
133
+ content.includes('缓解') ||
134
+ content.match(/挑战|问题|Risk/);
135
+
136
+ checks.push({
137
+ name: 'Risk Assessment',
138
+ passed: hasRiskAssessment,
139
+ message: hasRiskAssessment
140
+ ? 'Risk assessment found'
141
+ : 'Missing risk assessment with mitigation strategies'
142
+ });
143
+
144
+ if (!hasRiskAssessment) {
145
+ blockers.push('Add risk assessment with identified risks and mitigation strategies');
146
+ }
147
+
148
+ // Calculate score
149
+ const passedChecks = checks.filter(c => c.passed).length;
150
+ const score = Math.round((passedChecks / checks.length) * 100);
151
+
152
+ // Determine if passed (need at least 80% and no blockers)
153
+ const passed = score >= 80 && blockers.length === 0;
154
+
155
+ return {
156
+ passed,
157
+ score,
158
+ checks,
159
+ blockers,
160
+ warnings
161
+ };
162
+ }
163
+
164
+ /**
165
+ * Validate a feasibility report file
166
+ */
167
+ static validateFile(filePath) {
168
+ if (!fs.existsSync(filePath)) {
169
+ return {
170
+ passed: false,
171
+ score: 0,
172
+ checks: [],
173
+ blockers: [`File not found: ${filePath}`],
174
+ warnings: []
175
+ };
176
+ }
177
+
178
+ try {
179
+ const content = fs.readFileSync(filePath, 'utf-8');
180
+ return this.validateFromMarkdown(content);
181
+ } catch (error) {
182
+ return {
183
+ passed: false,
184
+ score: 0,
185
+ checks: [],
186
+ blockers: [`Failed to read file: ${error.message}`],
187
+ warnings: []
188
+ };
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Generate a validation report for display
194
+ */
195
+ static generateReport(result) {
196
+ const lines = [];
197
+
198
+ lines.push('═══════════════════════════════════════════════════════');
199
+ lines.push(' Feasibility Report Validation');
200
+ lines.push('═══════════════════════════════════════════════════════');
201
+ lines.push('');
202
+
203
+ // Status
204
+ const status = result.passed ? '✅ PASSED' : '❌ FAILED';
205
+ const statusColor = result.passed ? '🟢' : '🔴';
206
+ lines.push(`Status: ${statusColor} ${status} (Score: ${result.score}/100)`);
207
+ lines.push('');
208
+
209
+ // Checks
210
+ lines.push('Quality Checks:');
211
+ lines.push('───────────────────────────────────────────────────────');
212
+
213
+ result.checks.forEach(check => {
214
+ const icon = check.passed ? '✅' : '❌';
215
+ lines.push(` ${icon} ${check.name}: ${check.message || 'Failed'}`);
216
+ });
217
+
218
+ lines.push('');
219
+
220
+ // Blockers
221
+ if (result.blockers.length > 0) {
222
+ lines.push('🚫 BLOCKERS (must fix before proceeding):');
223
+ lines.push('───────────────────────────────────────────────────────');
224
+ result.blockers.forEach((blocker, i) => {
225
+ lines.push(` ${i + 1}. ${blocker}`);
226
+ });
227
+ lines.push('');
228
+ }
229
+
230
+ // Warnings
231
+ if (result.warnings.length > 0) {
232
+ lines.push('⚠️ WARNINGS (recommended improvements):');
233
+ lines.push('───────────────────────────────────────────────────────');
234
+ result.warnings.forEach((warning, i) => {
235
+ lines.push(` ${i + 1}. ${warning}`);
236
+ });
237
+ lines.push('');
238
+ }
239
+
240
+ // Recommendation
241
+ if (result.passed) {
242
+ lines.push('🎉 Report meets quality standards! Ready for Phase 2 (Approval).');
243
+ } else {
244
+ lines.push('📝 Report needs improvements. Address blockers and re-validate.');
245
+ }
246
+
247
+ lines.push('');
248
+ lines.push('═══════════════════════════════════════════════════════');
249
+
250
+ return lines.join('\n');
251
+ }
252
+ }
253
+
254
+ // ============================================================================
255
+ // Phase 1 Research Executor
256
+ // ============================================================================
257
+
258
+ class Phase1ResearchExecutor {
259
+ constructor(projectId) {
260
+ this.projectId = projectId;
261
+ this.projectDir = path.join(PROJECTS_DIR, projectId);
262
+ this.phaseDir = path.join(this.projectDir, 'phase1');
263
+ this.reportPath = path.join(this.phaseDir, 'feasibility-report.md');
264
+ }
265
+
266
+ /**
267
+ * Ensure project directories exist
268
+ */
269
+ ensureDirectories() {
270
+ if (!fs.existsSync(this.projectDir)) {
271
+ fs.mkdirSync(this.projectDir, { recursive: true });
272
+ }
273
+ if (!fs.existsSync(this.phaseDir)) {
274
+ fs.mkdirSync(this.phaseDir, { recursive: true });
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Generate report template
280
+ */
281
+ generateReportTemplate(idea, context) {
282
+ const date = new Date().toLocaleDateString();
283
+ const time = new Date().toLocaleTimeString();
284
+
285
+ return `# Feasibility Analysis Report
286
+
287
+ **Project**: ${this.projectId}
288
+ **Date**: ${date} ${time}
289
+ **Phase**: 1 - Research
290
+ **Status**: 🚧 In Progress
291
+
292
+ ---
293
+
294
+ ## Executive Summary
295
+
296
+ > Brief overview of the project and feasibility assessment
297
+
298
+ ---
299
+
300
+ ## Requirements Summary
301
+
302
+ ### Problem Statement
303
+ [What problem are we solving?]
304
+
305
+ ### Target Users
306
+ [Who will use this? What are their pain points?]
307
+
308
+ ### Key Features
309
+ 1. [Feature 1]
310
+ 2. [Feature 2]
311
+ 3. [Feature 3]
312
+
313
+ ### Constraints
314
+ - [Constraint 1]
315
+ - [Constraint 2]
316
+
317
+ ### Assumptions
318
+ - [Assumption 1]
319
+ - [Assumption 2]
320
+
321
+ ---
322
+
323
+ ## Original Idea
324
+
325
+ ${idea}
326
+
327
+ ${context ? `### Additional Context\n${context}` : ''}
328
+
329
+ ---
330
+
331
+ ## Correlation Analysis (Connect The Dots)
332
+
333
+ ### Research Plan (研究计划)
334
+
335
+ **Key Objectives (关键目标)**:
336
+ - [每个选项要回答的核心问题是什么?]
337
+ - [评估需要哪些数据/信息?]
338
+
339
+ **Research Methods (研究方法)**:
340
+ - [如何收集和分析数据?]
341
+ - [使用的工具或方法论是什么?]
342
+
343
+ **Evaluation Criteria (评估标准)**:
344
+ - [比较选项的指标/基准是什么?]
345
+ - [可行性/成功的判断标准是什么?]
346
+
347
+ **Expected Outcomes (预期成果)**:
348
+ - [可能的研究发现或结果是什么?]
349
+ - [研究后的下一步行动是什么?]
350
+
351
+ ### Related Projects
352
+ | Project | Similarity | Reusable Components |
353
+ |---------|------------|---------------------|
354
+ | [Project A] | 85% | [Component list] |
355
+ | [Project B] | 60% | [Component list] |
356
+
357
+ ### Overlapping Technology
358
+ - [Tech stack overlap]
359
+ - [Shared libraries]
360
+ - [Common patterns]
361
+
362
+ ### Lessons from History
363
+ - [Lesson 1]: [Context and outcome]
364
+ - [Lesson 2]: [Context and outcome]
365
+
366
+ ---
367
+
368
+ ## Industry Best Practices
369
+
370
+ ### Architecture
371
+ **Practice**: [Specific practice]
372
+ **Rationale**: [Why this is recommended]
373
+ **Sources**: [Citations]
374
+
375
+ ### Security
376
+ **Practice**: [Security best practice]
377
+ **Rationale**: [Why this matters]
378
+
379
+ ---
380
+
381
+ ## Feasibility Assessment
382
+
383
+ ### Technical Feasibility: ⭐⭐⭐☆☆ (3/5)
384
+
385
+ **Strengths**:
386
+ - [Strength 1]
387
+ - [Strength 2]
388
+
389
+ **Challenges**:
390
+ - [Challenge 1]: [Mitigation strategy]
391
+
392
+ ### Time Estimate: X hours
393
+
394
+ **Breakdown**:
395
+ - Research & Planning: Xh
396
+ - Design: Xh
397
+ - Implementation: Xh
398
+ - Testing: Xh
399
+
400
+ **Total**: X hours
401
+
402
+ ### Complexity: Medium
403
+
404
+ **Reasoning**: [Explain complexity assessment]
405
+
406
+ ### Risk Assessment
407
+
408
+ | Risk | Severity | Probability | Mitigation |
409
+ |------|----------|-------------|------------|
410
+ | [Risk 1] | High | Medium | [Mitigation strategy] |
411
+ | [Risk 2] | Medium | Low | [Mitigation strategy] |
412
+
413
+ ---
414
+
415
+ ## Recommendations
416
+
417
+ ### Recommended Tech Stack
418
+
419
+ **Frontend**:
420
+ - [Choice 1] - [Rationale]
421
+
422
+ **Backend**:
423
+ - [Choice 1] - [Rationale]
424
+
425
+ ### Suggested Architecture
426
+
427
+ [High-level architecture description]
428
+
429
+ ### Potential Issues to Watch
430
+
431
+ 1. **[Issue 1]**: [Monitoring approach]
432
+ 2. **[Issue 2]**: [Monitoring approach]
433
+
434
+ ### Next Steps (Phase 2: Approval)
435
+
436
+ 1. [ ] Review this report and ensure all sections are complete
437
+ 2. [ ] Run quality gate: \`smc workflow validate ${this.reportPath}\`
438
+ 3. [ ] Address any blockers identified
439
+ 4. [ ] Proceed to Phase 2 for Claude review and consensus
440
+
441
+ ---
442
+
443
+ ## Quality Checklist
444
+
445
+ - [x] Requirement summary is clear and complete
446
+ - [ ] Correlation analysis found related work/patterns
447
+ - [ ] Best practices are cited with sources
448
+ - [ ] Feasibility has concrete ratings (not vague)
449
+ - [ ] Time estimate is justified
450
+ - [ ] Risks have mitigation strategies
451
+ - [ ] Recommendations are actionable
452
+
453
+ ---
454
+
455
+ ## Metadata
456
+
457
+ - **Generated**: ${date} ${time}
458
+ - **Confidence Level**: [To be filled by AI]
459
+
460
+ ---
461
+
462
+ *This report was generated by the Phase 1 Research Executor.*
463
+ `;
464
+ }
465
+
466
+ /**
467
+ * Execute Phase 1 research workflow
468
+ */
469
+ async execute(idea, context = '', progressCallback) {
470
+ await progressCallback?.('Initializing Phase 1 research...', 0, 5);
471
+
472
+ // Ensure directories exist
473
+ this.ensureDirectories();
474
+
475
+ // Step 1: Create directories
476
+ await progressCallback?.('Setting up project structure...', 1, 5);
477
+
478
+ // Step 2: Generate report template
479
+ await progressCallback?.('Generating feasibility report template...', 2, 5);
480
+
481
+ const reportTemplate = this.generateReportTemplate(idea, context);
482
+ await fs.promises.writeFile(this.reportPath, reportTemplate, 'utf-8');
483
+
484
+ await progressCallback?.('Phase 1 research context prepared. Ready for AI analysis.', 3, 5);
485
+
486
+ return {
487
+ projectId: this.projectId,
488
+ reportPath: this.reportPath,
489
+ nextSteps: [
490
+ 'Complete the feasibility report',
491
+ 'Validate with: smc workflow validate',
492
+ 'Proceed to Phase 2'
493
+ ]
494
+ };
495
+ }
496
+
497
+ /**
498
+ * Check if report exists
499
+ */
500
+ reportExists() {
501
+ return fs.existsSync(this.reportPath);
502
+ }
503
+
504
+ /**
505
+ * Read the existing report
506
+ */
507
+ readReport() {
508
+ if (!this.reportExists()) return null;
509
+ return fs.readFileSync(this.reportPath, 'utf-8');
510
+ }
511
+
512
+ /**
513
+ * Validate the report
514
+ */
515
+ validateReport() {
516
+ return FeasibilityValidator.validateFile(this.reportPath);
517
+ }
518
+
519
+ /**
520
+ * Get the report path
521
+ */
522
+ getReportPath() {
523
+ return this.reportPath;
524
+ }
525
+ }
526
+
527
+ // ============================================================================
528
+ // Project Management Helpers
529
+ // ============================================================================
530
+
531
+ function generateProjectId() {
532
+ const timestamp = Date.now().toString(36);
533
+ const random = Math.random().toString(36).substr(2, 5);
534
+ return `proj_${timestamp}_${random}`;
535
+ }
536
+
537
+ async function createProject(idea, context = '') {
538
+ const projectId = generateProjectId();
539
+ const executor = new Phase1ResearchExecutor(projectId);
540
+
541
+ await executor.execute(idea, context, (msg, current, total) => {
542
+ const progress = Math.round((current / total) * 100);
543
+ console.log(`[${progress}%] ${msg}`);
544
+ });
545
+
546
+ return projectId;
547
+ }
548
+
549
+ function listProjects() {
550
+ if (!fs.existsSync(PROJECTS_DIR)) {
551
+ return [];
552
+ }
553
+
554
+ const projects = [];
555
+ const entries = fs.readdirSync(PROJECTS_DIR, { withFileTypes: true });
556
+
557
+ for (const entry of entries) {
558
+ if (entry.isDirectory() && entry.name.startsWith('proj_')) {
559
+ const projectPath = path.join(PROJECTS_DIR, entry.name);
560
+ const reportPath = path.join(projectPath, 'phase1', 'feasibility-report.md');
561
+ projects.push({
562
+ id: entry.name,
563
+ path: projectPath,
564
+ hasReport: fs.existsSync(reportPath)
565
+ });
566
+ }
567
+ }
568
+
569
+ return projects.sort((a, b) => b.id.localeCompare(a.id));
570
+ }
571
+
572
+ module.exports = {
573
+ Phase1ResearchExecutor,
574
+ FeasibilityValidator,
575
+ generateProjectId,
576
+ createProject,
577
+ listProjects
578
+ };