@girardmedia/bootspring 1.2.0 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +107 -14
  2. package/bin/bootspring.js +166 -27
  3. package/cli/agent.js +189 -17
  4. package/cli/analyze.js +499 -0
  5. package/cli/audit.js +557 -0
  6. package/cli/auth.js +495 -38
  7. package/cli/billing.js +302 -0
  8. package/cli/build.js +695 -0
  9. package/cli/business.js +109 -26
  10. package/cli/checkpoint-utils.js +168 -0
  11. package/cli/checkpoint.js +639 -0
  12. package/cli/cloud-sync.js +447 -0
  13. package/cli/content.js +198 -0
  14. package/cli/context.js +1 -1
  15. package/cli/deploy.js +543 -0
  16. package/cli/fundraise.js +112 -50
  17. package/cli/github-cmd.js +435 -0
  18. package/cli/health.js +477 -0
  19. package/cli/init.js +84 -13
  20. package/cli/legal.js +107 -95
  21. package/cli/log.js +2 -2
  22. package/cli/loop.js +976 -73
  23. package/cli/manager.js +711 -0
  24. package/cli/metrics.js +480 -0
  25. package/cli/monitor.js +812 -0
  26. package/cli/onboard.js +521 -0
  27. package/cli/orchestrator.js +12 -24
  28. package/cli/prd.js +594 -0
  29. package/cli/preseed-start.js +1483 -0
  30. package/cli/preseed.js +2302 -0
  31. package/cli/project.js +436 -0
  32. package/cli/quality.js +233 -0
  33. package/cli/security.js +913 -0
  34. package/cli/seed.js +1441 -5
  35. package/cli/skill.js +273 -211
  36. package/cli/suggest.js +989 -0
  37. package/cli/switch.js +453 -0
  38. package/cli/visualize.js +527 -0
  39. package/cli/watch.js +769 -0
  40. package/cli/workspace.js +607 -0
  41. package/core/analyze-workflow.js +1134 -0
  42. package/core/api-client.js +535 -22
  43. package/core/audit-workflow.js +1350 -0
  44. package/core/build-orchestrator.js +480 -0
  45. package/core/build-state.js +577 -0
  46. package/core/checkpoint-engine.js +408 -0
  47. package/core/config.js +1109 -26
  48. package/core/context-loader.js +21 -1
  49. package/core/deploy-workflow.js +836 -0
  50. package/core/entitlements.js +93 -22
  51. package/core/github-sync.js +610 -0
  52. package/core/index.js +8 -1
  53. package/core/ingest.js +1111 -0
  54. package/core/metrics-engine.js +768 -0
  55. package/core/onboard-workflow.js +1007 -0
  56. package/core/preseed-workflow.js +934 -0
  57. package/core/preseed.js +1617 -0
  58. package/core/project-context.js +325 -0
  59. package/core/project-state.js +694 -0
  60. package/core/r2-sync.js +583 -0
  61. package/core/scaffold.js +525 -7
  62. package/core/session.js +258 -0
  63. package/core/task-extractor.js +758 -0
  64. package/core/telemetry.js +28 -6
  65. package/core/tier-enforcement.js +737 -0
  66. package/core/utils.js +38 -14
  67. package/generators/questionnaire.js +15 -12
  68. package/generators/sections/ai.js +7 -7
  69. package/generators/sections/content.js +300 -0
  70. package/generators/sections/index.js +3 -0
  71. package/generators/sections/plugins.js +7 -6
  72. package/generators/templates/build-planning.template.js +596 -0
  73. package/generators/templates/content.template.js +819 -0
  74. package/generators/templates/index.js +2 -1
  75. package/hooks/git-autopilot.js +1250 -0
  76. package/hooks/index.js +9 -0
  77. package/intelligence/agent-collab.js +2057 -0
  78. package/intelligence/auto-suggest.js +634 -0
  79. package/intelligence/content-gen.js +1589 -0
  80. package/intelligence/cross-project.js +1647 -0
  81. package/intelligence/index.js +184 -0
  82. package/intelligence/learning/insights.json +517 -7
  83. package/intelligence/learning/pattern-learner.js +1008 -14
  84. package/intelligence/memory/decision-tracker.js +1431 -31
  85. package/intelligence/memory/decisions.jsonl +0 -0
  86. package/intelligence/orchestrator.js +2896 -1
  87. package/intelligence/prd.js +92 -1
  88. package/intelligence/recommendation-weights.json +14 -2
  89. package/intelligence/recommendations.js +463 -9
  90. package/intelligence/workflow-composer.js +1451 -0
  91. package/marketplace/index.d.ts +324 -0
  92. package/marketplace/index.js +1921 -0
  93. package/mcp/contracts/mcp-contract.v1.json +342 -4
  94. package/mcp/registry.js +680 -3
  95. package/mcp/response-formatter.js +23 -0
  96. package/mcp/tools/assist-tool.js +78 -4
  97. package/mcp/tools/autopilot-tool.js +408 -0
  98. package/mcp/tools/content-tool.js +571 -0
  99. package/mcp/tools/dashboard-tool.js +251 -5
  100. package/mcp/tools/mvp-tool.js +344 -0
  101. package/mcp/tools/plugin-tool.js +23 -1
  102. package/mcp/tools/prd-tool.js +579 -0
  103. package/mcp/tools/seed-tool.js +447 -0
  104. package/mcp/tools/skill-tool.js +43 -14
  105. package/mcp/tools/suggest-tool.js +147 -0
  106. package/package.json +15 -6
  107. package/agents/README.md +0 -93
  108. package/agents/ai-integration-expert/context.md +0 -386
  109. package/agents/api-expert/context.md +0 -416
  110. package/agents/architecture-expert/context.md +0 -454
  111. package/agents/auth-expert/context.md +0 -399
  112. package/agents/backend-expert/context.md +0 -483
  113. package/agents/business-strategy-expert/context.md +0 -180
  114. package/agents/code-review-expert/context.md +0 -365
  115. package/agents/competitive-analysis-expert/context.md +0 -239
  116. package/agents/data-modeling-expert/context.md +0 -352
  117. package/agents/database-expert/context.md +0 -250
  118. package/agents/devops-expert/context.md +0 -446
  119. package/agents/email-expert/context.md +0 -379
  120. package/agents/financial-expert/context.md +0 -213
  121. package/agents/frontend-expert/context.md +0 -364
  122. package/agents/fundraising-expert/context.md +0 -257
  123. package/agents/growth-expert/context.md +0 -249
  124. package/agents/index.js +0 -140
  125. package/agents/investor-relations-expert/context.md +0 -266
  126. package/agents/legal-expert/context.md +0 -284
  127. package/agents/marketing-expert/context.md +0 -236
  128. package/agents/monitoring-expert/context.md +0 -362
  129. package/agents/operations-expert/context.md +0 -279
  130. package/agents/partnerships-expert/context.md +0 -286
  131. package/agents/payment-expert/context.md +0 -340
  132. package/agents/performance-expert/context.md +0 -377
  133. package/agents/private-equity-expert/context.md +0 -246
  134. package/agents/railway-expert/context.md +0 -284
  135. package/agents/research-expert/context.md +0 -245
  136. package/agents/sales-expert/context.md +0 -241
  137. package/agents/security-expert/context.md +0 -343
  138. package/agents/testing-expert/context.md +0 -414
  139. package/agents/ui-ux-expert/context.md +0 -448
  140. package/agents/vercel-expert/context.md +0 -426
  141. package/skills/index.js +0 -787
  142. package/skills/patterns/README.md +0 -163
  143. package/skills/patterns/ai/agents.md +0 -281
  144. package/skills/patterns/ai/claude.md +0 -138
  145. package/skills/patterns/ai/embeddings.md +0 -150
  146. package/skills/patterns/ai/rag.md +0 -266
  147. package/skills/patterns/ai/streaming.md +0 -170
  148. package/skills/patterns/ai/structured-output.md +0 -162
  149. package/skills/patterns/ai/tools.md +0 -154
  150. package/skills/patterns/analytics/tracking.md +0 -220
  151. package/skills/patterns/api/errors.md +0 -296
  152. package/skills/patterns/api/graphql.md +0 -440
  153. package/skills/patterns/api/middleware.md +0 -279
  154. package/skills/patterns/api/openapi.md +0 -285
  155. package/skills/patterns/api/rate-limiting.md +0 -231
  156. package/skills/patterns/api/route-handler.md +0 -217
  157. package/skills/patterns/api/server-action.md +0 -249
  158. package/skills/patterns/api/versioning.md +0 -443
  159. package/skills/patterns/api/webhooks.md +0 -247
  160. package/skills/patterns/auth/clerk.md +0 -132
  161. package/skills/patterns/auth/mfa.md +0 -313
  162. package/skills/patterns/auth/nextauth.md +0 -140
  163. package/skills/patterns/auth/oauth.md +0 -237
  164. package/skills/patterns/auth/rbac.md +0 -152
  165. package/skills/patterns/auth/session-management.md +0 -367
  166. package/skills/patterns/auth/session.md +0 -120
  167. package/skills/patterns/database/audit.md +0 -177
  168. package/skills/patterns/database/migrations.md +0 -177
  169. package/skills/patterns/database/pagination.md +0 -230
  170. package/skills/patterns/database/pooling.md +0 -357
  171. package/skills/patterns/database/prisma.md +0 -180
  172. package/skills/patterns/database/relations.md +0 -187
  173. package/skills/patterns/database/seeding.md +0 -246
  174. package/skills/patterns/database/soft-delete.md +0 -153
  175. package/skills/patterns/database/transactions.md +0 -162
  176. package/skills/patterns/deployment/ci-cd.md +0 -231
  177. package/skills/patterns/deployment/docker.md +0 -188
  178. package/skills/patterns/deployment/monitoring.md +0 -387
  179. package/skills/patterns/deployment/vercel.md +0 -160
  180. package/skills/patterns/email/resend.md +0 -143
  181. package/skills/patterns/email/templates.md +0 -245
  182. package/skills/patterns/email/transactional.md +0 -503
  183. package/skills/patterns/email/verification.md +0 -176
  184. package/skills/patterns/files/download.md +0 -243
  185. package/skills/patterns/files/upload.md +0 -239
  186. package/skills/patterns/i18n/nextintl.md +0 -188
  187. package/skills/patterns/logging/structured.md +0 -292
  188. package/skills/patterns/notifications/email-queue.md +0 -248
  189. package/skills/patterns/notifications/push.md +0 -279
  190. package/skills/patterns/payments/checkout.md +0 -303
  191. package/skills/patterns/payments/invoices.md +0 -287
  192. package/skills/patterns/payments/portal.md +0 -245
  193. package/skills/patterns/payments/stripe.md +0 -272
  194. package/skills/patterns/payments/subscriptions.md +0 -300
  195. package/skills/patterns/payments/usage.md +0 -279
  196. package/skills/patterns/performance/caching.md +0 -276
  197. package/skills/patterns/performance/code-splitting.md +0 -233
  198. package/skills/patterns/performance/edge.md +0 -254
  199. package/skills/patterns/performance/isr.md +0 -266
  200. package/skills/patterns/performance/lazy-loading.md +0 -281
  201. package/skills/patterns/realtime/sse.md +0 -327
  202. package/skills/patterns/realtime/websockets.md +0 -336
  203. package/skills/patterns/search/filtering.md +0 -329
  204. package/skills/patterns/search/fulltext.md +0 -260
  205. package/skills/patterns/security/audit-logging.md +0 -444
  206. package/skills/patterns/security/csrf.md +0 -234
  207. package/skills/patterns/security/headers.md +0 -252
  208. package/skills/patterns/security/sanitization.md +0 -258
  209. package/skills/patterns/security/secrets.md +0 -261
  210. package/skills/patterns/security/validation.md +0 -268
  211. package/skills/patterns/security/xss.md +0 -229
  212. package/skills/patterns/seo/metadata.md +0 -252
  213. package/skills/patterns/state/context.md +0 -349
  214. package/skills/patterns/state/react-query.md +0 -313
  215. package/skills/patterns/state/url-state.md +0 -482
  216. package/skills/patterns/state/zustand.md +0 -262
  217. package/skills/patterns/testing/api.md +0 -259
  218. package/skills/patterns/testing/component.md +0 -233
  219. package/skills/patterns/testing/coverage.md +0 -207
  220. package/skills/patterns/testing/fixtures.md +0 -225
  221. package/skills/patterns/testing/integration.md +0 -436
  222. package/skills/patterns/testing/mocking.md +0 -177
  223. package/skills/patterns/testing/playwright.md +0 -162
  224. package/skills/patterns/testing/snapshot.md +0 -175
  225. package/skills/patterns/testing/vitest.md +0 -307
  226. package/skills/patterns/ui/accordions.md +0 -395
  227. package/skills/patterns/ui/cards.md +0 -299
  228. package/skills/patterns/ui/dropdowns.md +0 -476
  229. package/skills/patterns/ui/empty-states.md +0 -320
  230. package/skills/patterns/ui/forms.md +0 -405
  231. package/skills/patterns/ui/inputs.md +0 -319
  232. package/skills/patterns/ui/layouts.md +0 -282
  233. package/skills/patterns/ui/loading.md +0 -291
  234. package/skills/patterns/ui/modals.md +0 -338
  235. package/skills/patterns/ui/navigation.md +0 -374
  236. package/skills/patterns/ui/tables.md +0 -407
  237. package/skills/patterns/ui/toasts.md +0 -300
  238. package/skills/patterns/ui/tooltips.md +0 -396
  239. package/skills/patterns/utils/dates.md +0 -435
  240. package/skills/patterns/utils/errors.md +0 -451
  241. package/skills/patterns/utils/formatting.md +0 -345
  242. package/skills/patterns/utils/validation.md +0 -434
  243. package/templates/bootspring.config.js +0 -83
  244. package/templates/business/business-model-canvas.md +0 -246
  245. package/templates/business/business-plan.md +0 -266
  246. package/templates/business/competitive-analysis.md +0 -312
  247. package/templates/fundraising/data-room-checklist.md +0 -300
  248. package/templates/fundraising/investor-research.md +0 -243
  249. package/templates/fundraising/pitch-deck-outline.md +0 -253
  250. package/templates/legal/gdpr-checklist.md +0 -339
  251. package/templates/legal/privacy-policy.md +0 -285
  252. package/templates/legal/terms-of-service.md +0 -222
  253. package/templates/mcp.json +0 -9
package/cli/prd.js ADDED
@@ -0,0 +1,594 @@
1
+ /**
2
+ * Bootspring PRD Command
3
+ * Product Requirements Document management
4
+ *
5
+ * Commands:
6
+ * create Create a new PRD
7
+ * list List all PRDs
8
+ * show Show a specific PRD
9
+ * import Import PRDs from .bootspring/inputs/prd
10
+ * to-tasks Convert PRD to todo items
11
+ * status Show PRD system status
12
+ *
13
+ * @package bootspring
14
+ * @command prd
15
+ */
16
+
17
+ const fs = require('fs');
18
+ const path = require('path');
19
+ const utils = require('../core/utils');
20
+ const config = require('../core/config');
21
+
22
+ // Lazy load ingest module
23
+ let ingest = null;
24
+ function getIngest() {
25
+ if (!ingest) {
26
+ ingest = require('../core/ingest');
27
+ }
28
+ return ingest;
29
+ }
30
+
31
+ /**
32
+ * Run PRD command
33
+ * @param {string[]} args - Command arguments
34
+ */
35
+ async function run(args) {
36
+ const parsedArgs = utils.parseArgs(args);
37
+ const subcommand = parsedArgs._[0] || 'status';
38
+
39
+ switch (subcommand) {
40
+ case 'create':
41
+ return prdCreate(parsedArgs);
42
+ case 'list':
43
+ return prdList(parsedArgs);
44
+ case 'show':
45
+ return prdShow(parsedArgs);
46
+ case 'import':
47
+ return prdImport(parsedArgs);
48
+ case 'to-tasks':
49
+ return prdToTasks(parsedArgs);
50
+ case 'status':
51
+ return prdStatus(parsedArgs);
52
+ case 'help':
53
+ case '-h':
54
+ case '--help':
55
+ return showHelp();
56
+ default:
57
+ utils.print.error(`Unknown subcommand: ${subcommand}`);
58
+ showHelp();
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Create a new PRD
64
+ */
65
+ function prdCreate(args) {
66
+ const projectRoot = config.findProjectRoot();
67
+ const name = args._[1] || args.name;
68
+ const title = args.title;
69
+ const description = args.description;
70
+
71
+ console.log(`
72
+ ${utils.COLORS.cyan}${utils.COLORS.bold}Bootspring PRD Create${utils.COLORS.reset}
73
+ ${utils.COLORS.dim}Create a new Product Requirements Document${utils.COLORS.reset}
74
+ `);
75
+
76
+ if (!name) {
77
+ utils.print.error('PRD name required');
78
+ utils.print.dim('Usage: bootspring prd create <name> [--title="..."] [--description="..."]');
79
+ return;
80
+ }
81
+
82
+ const prdDir = path.join(projectRoot, '.bootspring', 'generated', 'prd');
83
+ if (!fs.existsSync(prdDir)) {
84
+ fs.mkdirSync(prdDir, { recursive: true });
85
+ }
86
+
87
+ const fileName = `${name.toLowerCase().replace(/\s+/g, '-')}.md`;
88
+ const filePath = path.join(prdDir, fileName);
89
+
90
+ if (fs.existsSync(filePath) && !args.force) {
91
+ utils.print.warning(`PRD already exists: ${fileName}`);
92
+ utils.print.dim('Use --force to overwrite');
93
+ return;
94
+ }
95
+
96
+ const date = new Date().toISOString().split('T')[0];
97
+ const content = `# ${title || name}
98
+
99
+ **Status:** Draft
100
+ **Created:** ${date}
101
+ **Author:** ${process.env.USER || 'Bootspring'}
102
+
103
+ ## Overview
104
+
105
+ ${description || 'Add description here.'}
106
+
107
+ ## Problem Statement
108
+
109
+ Describe the problem being solved and why it matters.
110
+
111
+ ## Goals
112
+
113
+ 1. Primary goal
114
+ 2. Secondary goal
115
+ 3. Success criteria
116
+
117
+ ## User Stories
118
+
119
+ ### As a user, I want to...
120
+
121
+ - [ ] User story 1
122
+ - [ ] User story 2
123
+ - [ ] User story 3
124
+
125
+ ## Requirements
126
+
127
+ ### Must Have (P0)
128
+ - Requirement 1
129
+ - Requirement 2
130
+
131
+ ### Should Have (P1)
132
+ - Requirement 3
133
+ - Requirement 4
134
+
135
+ ### Nice to Have (P2)
136
+ - Requirement 5
137
+
138
+ ## Technical Considerations
139
+
140
+ - Architecture notes
141
+ - Dependencies
142
+ - Performance requirements
143
+
144
+ ## Success Metrics
145
+
146
+ | Metric | Target | Current |
147
+ |--------|--------|---------|
148
+ | Metric 1 | X | - |
149
+ | Metric 2 | Y | - |
150
+
151
+ ## Timeline
152
+
153
+ | Phase | Duration | Status |
154
+ |-------|----------|--------|
155
+ | Research | 1 week | Not started |
156
+ | Design | 1 week | Not started |
157
+ | Implementation | 2 weeks | Not started |
158
+ | Testing | 1 week | Not started |
159
+
160
+ ## Open Questions
161
+
162
+ 1. Question 1?
163
+ 2. Question 2?
164
+
165
+ ## References
166
+
167
+ - Link 1
168
+ - Link 2
169
+
170
+ ---
171
+ *Generated by Bootspring PRD System*
172
+ `;
173
+
174
+ fs.writeFileSync(filePath, content);
175
+ utils.print.success(`Created PRD: ${fileName}`);
176
+
177
+ console.log(`
178
+ ${utils.COLORS.bold}Next steps:${utils.COLORS.reset}
179
+ 1. Edit ${utils.COLORS.cyan}.bootspring/generated/prd/${fileName}${utils.COLORS.reset}
180
+ 2. Run ${utils.COLORS.cyan}bootspring prd to-tasks ${name}${utils.COLORS.reset} to create todos
181
+ `);
182
+ }
183
+
184
+ /**
185
+ * List all PRDs
186
+ */
187
+ function prdList(_args) {
188
+ const projectRoot = config.findProjectRoot();
189
+ const prdDir = path.join(projectRoot, '.bootspring', 'generated', 'prd');
190
+ const inputPrdDir = path.join(projectRoot, '.bootspring', 'inputs', 'prd');
191
+
192
+ console.log(`
193
+ ${utils.COLORS.cyan}${utils.COLORS.bold}Bootspring PRD List${utils.COLORS.reset}
194
+ `);
195
+
196
+ const prds = [];
197
+
198
+ // Check generated PRDs
199
+ if (fs.existsSync(prdDir)) {
200
+ const files = fs.readdirSync(prdDir).filter(f => f.endsWith('.md'));
201
+ for (const file of files) {
202
+ const filePath = path.join(prdDir, file);
203
+ const stats = fs.statSync(filePath);
204
+ const content = fs.readFileSync(filePath, 'utf-8');
205
+ const titleMatch = content.match(/^#\s+(.+)/m);
206
+ const statusMatch = content.match(/\*\*Status:\*\*\s*(.+)/i);
207
+
208
+ prds.push({
209
+ name: file.replace('.md', ''),
210
+ title: titleMatch ? titleMatch[1] : file,
211
+ source: 'generated',
212
+ status: statusMatch ? statusMatch[1].trim() : 'Unknown',
213
+ modified: stats.mtime
214
+ });
215
+ }
216
+ }
217
+
218
+ // Check input PRDs
219
+ if (fs.existsSync(inputPrdDir)) {
220
+ const files = fs.readdirSync(inputPrdDir).filter(f =>
221
+ f.endsWith('.md') || f.endsWith('.txt')
222
+ );
223
+ for (const file of files) {
224
+ if (file === 'README.md') continue;
225
+ const filePath = path.join(inputPrdDir, file);
226
+ const stats = fs.statSync(filePath);
227
+
228
+ prds.push({
229
+ name: file.replace(/\.(md|txt)$/, ''),
230
+ title: file,
231
+ source: 'input',
232
+ status: 'Imported',
233
+ modified: stats.mtime
234
+ });
235
+ }
236
+ }
237
+
238
+ if (prds.length === 0) {
239
+ utils.print.dim('No PRDs found');
240
+ console.log(`
241
+ ${utils.COLORS.bold}To create a PRD:${utils.COLORS.reset}
242
+ bootspring prd create <name> --title="My Feature"
243
+
244
+ ${utils.COLORS.bold}To import PRDs:${utils.COLORS.reset}
245
+ 1. Drop files in ${utils.COLORS.cyan}.bootspring/inputs/prd/${utils.COLORS.reset}
246
+ 2. Run ${utils.COLORS.cyan}bootspring prd import${utils.COLORS.reset}
247
+ `);
248
+ return;
249
+ }
250
+
251
+ console.log(`${utils.COLORS.bold}PRDs:${utils.COLORS.reset}
252
+ `);
253
+
254
+ for (const prd of prds) {
255
+ const modified = utils.formatRelativeTime(prd.modified);
256
+ const sourceIcon = prd.source === 'generated' ? utils.COLORS.green + '+' : utils.COLORS.cyan + '>';
257
+ console.log(` ${sourceIcon}${utils.COLORS.reset} ${utils.COLORS.bold}${prd.name}${utils.COLORS.reset}`);
258
+ console.log(` ${utils.COLORS.dim}${prd.title.slice(0, 50)}${utils.COLORS.reset}`);
259
+ console.log(` ${utils.COLORS.dim}Status: ${prd.status} | Modified: ${modified}${utils.COLORS.reset}`);
260
+ console.log();
261
+ }
262
+
263
+ console.log(`${utils.COLORS.dim}Total: ${prds.length} PRDs (${prds.filter(p => p.source === 'generated').length} generated, ${prds.filter(p => p.source === 'input').length} imported)${utils.COLORS.reset}`);
264
+ }
265
+
266
+ /**
267
+ * Show a specific PRD
268
+ */
269
+ function prdShow(args) {
270
+ const projectRoot = config.findProjectRoot();
271
+ const name = args._[1] || args.name;
272
+
273
+ console.log(`
274
+ ${utils.COLORS.cyan}${utils.COLORS.bold}Bootspring PRD Show${utils.COLORS.reset}
275
+ `);
276
+
277
+ if (!name) {
278
+ utils.print.error('PRD name required');
279
+ utils.print.dim('Usage: bootspring prd show <name>');
280
+ return;
281
+ }
282
+
283
+ // Try generated first, then input
284
+ const paths = [
285
+ path.join(projectRoot, '.bootspring', 'generated', 'prd', `${name}.md`),
286
+ path.join(projectRoot, '.bootspring', 'inputs', 'prd', `${name}.md`),
287
+ path.join(projectRoot, '.bootspring', 'inputs', 'prd', name)
288
+ ];
289
+
290
+ let content = null;
291
+ let foundPath = null;
292
+
293
+ for (const p of paths) {
294
+ if (fs.existsSync(p)) {
295
+ content = fs.readFileSync(p, 'utf-8');
296
+ foundPath = p;
297
+ break;
298
+ }
299
+ }
300
+
301
+ if (!content) {
302
+ utils.print.error(`PRD not found: ${name}`);
303
+ utils.print.dim('Run "bootspring prd list" to see available PRDs');
304
+ return;
305
+ }
306
+
307
+ console.log(`${utils.COLORS.dim}File: ${foundPath}${utils.COLORS.reset}
308
+ `);
309
+ console.log(content);
310
+ }
311
+
312
+ /**
313
+ * Import PRDs from inputs folder
314
+ */
315
+ async function prdImport(_args) {
316
+ const projectRoot = config.findProjectRoot();
317
+ const inputPrdDir = path.join(projectRoot, '.bootspring', 'inputs', 'prd');
318
+
319
+ console.log(`
320
+ ${utils.COLORS.cyan}${utils.COLORS.bold}Bootspring PRD Import${utils.COLORS.reset}
321
+ ${utils.COLORS.dim}Importing PRDs from .bootspring/inputs/prd${utils.COLORS.reset}
322
+ `);
323
+
324
+ if (!fs.existsSync(inputPrdDir)) {
325
+ utils.print.warning('No .bootspring/inputs/prd folder found');
326
+ utils.print.dim('Run "bootspring seed setup" to create the folder structure');
327
+ return;
328
+ }
329
+
330
+ const spinner = utils.createSpinner('Analyzing PRD files...').start();
331
+
332
+ try {
333
+ const Ingest = getIngest();
334
+ const ingested = await Ingest.ingestPRD(projectRoot);
335
+
336
+ spinner.succeed('Analyzed PRD files');
337
+
338
+ if (!ingested || ingested.length === 0) {
339
+ utils.print.dim('No PRD files found in .bootspring/inputs/prd/');
340
+ return;
341
+ }
342
+
343
+ console.log(`
344
+ ${utils.COLORS.bold}Imported ${ingested.length} PRD files:${utils.COLORS.reset}
345
+ `);
346
+
347
+ for (const prd of ingested) {
348
+ console.log(` ${utils.COLORS.green}+${utils.COLORS.reset} ${prd.file}`);
349
+ if (prd.userStories?.length > 0) {
350
+ console.log(` ${utils.COLORS.dim}User Stories: ${prd.userStories.length}${utils.COLORS.reset}`);
351
+ }
352
+ if (prd.features?.length > 0) {
353
+ console.log(` ${utils.COLORS.dim}Features: ${prd.features.length}${utils.COLORS.reset}`);
354
+ }
355
+ if (prd.requirements?.mustHave?.length > 0) {
356
+ console.log(` ${utils.COLORS.dim}Requirements: ${prd.requirements.mustHave.length} must-have${utils.COLORS.reset}`);
357
+ }
358
+ }
359
+
360
+ console.log(`
361
+ ${utils.COLORS.bold}Next steps:${utils.COLORS.reset}
362
+ 1. Run ${utils.COLORS.cyan}bootspring prd to-tasks${utils.COLORS.reset} to create todos
363
+ 2. Run ${utils.COLORS.cyan}bootspring seed generate${utils.COLORS.reset} to update context
364
+ `);
365
+ } catch (error) {
366
+ spinner.fail(`Import failed: ${error.message}`);
367
+ }
368
+ }
369
+
370
+ /**
371
+ * Convert PRD to tasks
372
+ */
373
+ async function prdToTasks(args) {
374
+ const projectRoot = config.findProjectRoot();
375
+ const name = args._[1] || args.name;
376
+
377
+ console.log(`
378
+ ${utils.COLORS.cyan}${utils.COLORS.bold}Bootspring PRD to Tasks${utils.COLORS.reset}
379
+ ${utils.COLORS.dim}Converting PRD requirements to todos${utils.COLORS.reset}
380
+ `);
381
+
382
+ let content = null;
383
+
384
+ if (name) {
385
+ // Load specific PRD
386
+ const paths = [
387
+ path.join(projectRoot, '.bootspring', 'generated', 'prd', `${name}.md`),
388
+ path.join(projectRoot, '.bootspring', 'inputs', 'prd', `${name}.md`)
389
+ ];
390
+
391
+ for (const p of paths) {
392
+ if (fs.existsSync(p)) {
393
+ content = fs.readFileSync(p, 'utf-8');
394
+ break;
395
+ }
396
+ }
397
+
398
+ if (!content) {
399
+ utils.print.error(`PRD not found: ${name}`);
400
+ utils.print.dim('Run "bootspring prd list" to see available PRDs');
401
+ return;
402
+ }
403
+ } else {
404
+ // Load all PRDs
405
+ const prdDir = path.join(projectRoot, '.bootspring', 'generated', 'prd');
406
+ if (fs.existsSync(prdDir)) {
407
+ const files = fs.readdirSync(prdDir).filter(f => f.endsWith('.md'));
408
+ content = files.map(f => fs.readFileSync(path.join(prdDir, f), 'utf-8')).join('\n\n');
409
+ }
410
+ }
411
+
412
+ if (!content) {
413
+ utils.print.warning('No PRDs to process');
414
+ return;
415
+ }
416
+
417
+ // Extract tasks from content
418
+ const tasks = [];
419
+
420
+ // Extract user stories (lines with - [ ])
421
+ const storyMatches = content.matchAll(/^\s*-\s*\[\s*\]\s*(.+)$/gm);
422
+ for (const match of storyMatches) {
423
+ const text = match[1].trim();
424
+ if (text.length > 5) {
425
+ tasks.push({ text, type: 'story', priority: 2 });
426
+ }
427
+ }
428
+
429
+ // Extract requirements from Must Have section
430
+ const mustHaveSection = content.match(/### Must Have.*?\n([\s\S]*?)(?=###|##|$)/i);
431
+ if (mustHaveSection) {
432
+ const reqMatches = mustHaveSection[1].matchAll(/^\s*-\s*(.+)$/gm);
433
+ for (const match of reqMatches) {
434
+ const text = match[1].trim();
435
+ if (text.length > 5 && !text.startsWith('[')) {
436
+ tasks.push({ text, type: 'requirement', priority: 1 });
437
+ }
438
+ }
439
+ }
440
+
441
+ // Extract requirements from Should Have section
442
+ const shouldHaveSection = content.match(/### Should Have.*?\n([\s\S]*?)(?=###|##|$)/i);
443
+ if (shouldHaveSection) {
444
+ const reqMatches = shouldHaveSection[1].matchAll(/^\s*-\s*(.+)$/gm);
445
+ for (const match of reqMatches) {
446
+ const text = match[1].trim();
447
+ if (text.length > 5 && !text.startsWith('[')) {
448
+ tasks.push({ text, type: 'requirement', priority: 2 });
449
+ }
450
+ }
451
+ }
452
+
453
+ if (tasks.length === 0) {
454
+ utils.print.warning('No actionable items found in PRD');
455
+ utils.print.dim('Add user stories with "- [ ] ..." or requirements with "- ..."');
456
+ return;
457
+ }
458
+
459
+ console.log(`
460
+ ${utils.COLORS.bold}Found ${tasks.length} tasks:${utils.COLORS.reset}
461
+ `);
462
+
463
+ // Load todo module
464
+ const todoModule = require('./todo');
465
+
466
+ let added = 0;
467
+ for (const task of tasks.slice(0, 20)) {
468
+ const prefix = task.type === 'story' ? '[Story]' : '[Req]';
469
+ const priority = task.priority === 1 ? 'P0' : 'P1';
470
+ const todoText = `${prefix} ${priority}: ${task.text.slice(0, 80)}`;
471
+
472
+ console.log(` ${utils.COLORS.green}+${utils.COLORS.reset} ${todoText}`);
473
+
474
+ try {
475
+ todoModule.add({ text: todoText, priority: task.priority });
476
+ added++;
477
+ } catch {
478
+ // Skip if todo fails
479
+ }
480
+ }
481
+
482
+ if (tasks.length > 20) {
483
+ console.log(` ${utils.COLORS.dim}... and ${tasks.length - 20} more (run with --all to add all)${utils.COLORS.reset}`);
484
+ }
485
+
486
+ console.log(`
487
+ ${utils.COLORS.green}${utils.COLORS.bold}Added ${added} tasks${utils.COLORS.reset}
488
+
489
+ Run ${utils.COLORS.cyan}bootspring todo list${utils.COLORS.reset} to see all tasks
490
+ `);
491
+ }
492
+
493
+ /**
494
+ * Show PRD status
495
+ */
496
+ function prdStatus(_args) {
497
+ const projectRoot = config.findProjectRoot();
498
+ const prdDir = path.join(projectRoot, '.bootspring', 'generated', 'prd');
499
+ const inputPrdDir = path.join(projectRoot, '.bootspring', 'inputs', 'prd');
500
+
501
+ console.log(`
502
+ ${utils.COLORS.cyan}${utils.COLORS.bold}Bootspring PRD Status${utils.COLORS.reset}
503
+ `);
504
+
505
+ const stats = {
506
+ generated: 0,
507
+ input: 0,
508
+ draft: 0,
509
+ approved: 0,
510
+ totalFeatures: 0,
511
+ totalStories: 0
512
+ };
513
+
514
+ // Count generated PRDs
515
+ if (fs.existsSync(prdDir)) {
516
+ const files = fs.readdirSync(prdDir).filter(f => f.endsWith('.md'));
517
+ stats.generated = files.length;
518
+
519
+ for (const file of files) {
520
+ const content = fs.readFileSync(path.join(prdDir, file), 'utf-8');
521
+ if (content.includes('Status:** Draft')) stats.draft++;
522
+ if (content.includes('Status:** Approved')) stats.approved++;
523
+
524
+ // Count user stories
525
+ const storyCount = (content.match(/-\s*\[\s*\]/g) || []).length;
526
+ stats.totalStories += storyCount;
527
+ }
528
+ }
529
+
530
+ // Count input PRDs
531
+ if (fs.existsSync(inputPrdDir)) {
532
+ const files = fs.readdirSync(inputPrdDir).filter(f =>
533
+ (f.endsWith('.md') || f.endsWith('.txt')) && f !== 'README.md'
534
+ );
535
+ stats.input = files.length;
536
+ }
537
+
538
+ console.log(`${utils.COLORS.bold}Summary:${utils.COLORS.reset}`);
539
+ console.log(` Generated PRDs: ${utils.COLORS.cyan}${stats.generated}${utils.COLORS.reset}`);
540
+ console.log(` Input PRDs: ${utils.COLORS.cyan}${stats.input}${utils.COLORS.reset}`);
541
+ console.log(` Draft: ${stats.draft}`);
542
+ console.log(` Approved: ${stats.approved}`);
543
+ console.log(` Total User Stories: ${stats.totalStories}`);
544
+
545
+ const hasStructure = fs.existsSync(path.join(projectRoot, '.bootspring', 'inputs', 'prd'));
546
+
547
+ console.log(`
548
+ ${utils.COLORS.bold}Status:${utils.COLORS.reset}`);
549
+ console.log(` ${hasStructure ? utils.COLORS.green + '✓' : utils.COLORS.yellow + '○'}${utils.COLORS.reset} Input folder exists`);
550
+ console.log(` ${stats.generated > 0 ? utils.COLORS.green + '✓' : utils.COLORS.yellow + '○'}${utils.COLORS.reset} PRDs created`);
551
+
552
+ console.log(`
553
+ ${utils.COLORS.bold}Commands:${utils.COLORS.reset}
554
+ bootspring prd create <name> ${utils.COLORS.dim}# Create new PRD${utils.COLORS.reset}
555
+ bootspring prd list ${utils.COLORS.dim}# List all PRDs${utils.COLORS.reset}
556
+ bootspring prd show <name> ${utils.COLORS.dim}# View a PRD${utils.COLORS.reset}
557
+ bootspring prd import ${utils.COLORS.dim}# Import from inputs${utils.COLORS.reset}
558
+ bootspring prd to-tasks ${utils.COLORS.dim}# Convert to todos${utils.COLORS.reset}
559
+ `);
560
+ }
561
+
562
+ /**
563
+ * Show help
564
+ */
565
+ function showHelp() {
566
+ console.log(`
567
+ ${utils.COLORS.cyan}${utils.COLORS.bold}Bootspring PRD${utils.COLORS.reset}
568
+ ${utils.COLORS.dim}Product Requirements Document management${utils.COLORS.reset}
569
+
570
+ ${utils.COLORS.bold}Usage:${utils.COLORS.reset}
571
+ bootspring prd <command> [options]
572
+
573
+ ${utils.COLORS.bold}Commands:${utils.COLORS.reset}
574
+ ${utils.COLORS.cyan}create${utils.COLORS.reset} Create a new PRD
575
+ ${utils.COLORS.cyan}list${utils.COLORS.reset} List all PRDs
576
+ ${utils.COLORS.cyan}show${utils.COLORS.reset} Show a specific PRD
577
+ ${utils.COLORS.cyan}import${utils.COLORS.reset} Import PRDs from .bootspring/inputs/prd
578
+ ${utils.COLORS.cyan}to-tasks${utils.COLORS.reset} Convert PRD to todo items
579
+ ${utils.COLORS.cyan}status${utils.COLORS.reset} Show PRD system status (default)
580
+
581
+ ${utils.COLORS.bold}Create Options:${utils.COLORS.reset}
582
+ --title="..." PRD title
583
+ --description="..." PRD description
584
+ --force Overwrite existing PRD
585
+
586
+ ${utils.COLORS.bold}Examples:${utils.COLORS.reset}
587
+ bootspring prd create auth --title="User Authentication"
588
+ bootspring prd list
589
+ bootspring prd show auth
590
+ bootspring prd to-tasks auth
591
+ `);
592
+ }
593
+
594
+ module.exports = { run };