@girardmedia/bootspring 2.1.3 → 2.2.1
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.
- package/bin/bootspring.js +157 -83
- package/claude-commands/agent.md +34 -0
- package/claude-commands/bs.md +31 -0
- package/claude-commands/build.md +25 -0
- package/claude-commands/skill.md +31 -0
- package/claude-commands/todo.md +25 -0
- package/dist/core/index.d.ts +5814 -0
- package/dist/core.js +5779 -0
- package/dist/index.js +93883 -0
- package/dist/mcp/index.d.ts +1 -0
- package/dist/mcp-server.js +2298 -0
- package/generators/api-docs.js +3 -3
- package/generators/decisions.js +14 -14
- package/generators/health.js +6 -6
- package/generators/sprint.js +4 -4
- package/generators/templates/build-planning.template.js +2 -2
- package/generators/visual-doc-generator.js +1 -1
- package/package.json +22 -68
- package/cli/agent.js +0 -799
- package/cli/auth.js +0 -896
- package/cli/billing.js +0 -320
- package/cli/build.js +0 -1442
- package/cli/dashboard.js +0 -123
- package/cli/init.js +0 -669
- package/cli/mcp.js +0 -240
- package/cli/orchestrator.js +0 -240
- package/cli/project.js +0 -825
- package/cli/quality.js +0 -281
- package/cli/skill.js +0 -503
- package/cli/switch.js +0 -453
- package/cli/todo.js +0 -629
- package/cli/update.js +0 -132
- package/core/api-client.d.ts +0 -69
- package/core/api-client.js +0 -1482
- package/core/auth.d.ts +0 -98
- package/core/auth.js +0 -737
- package/core/build-orchestrator.js +0 -508
- package/core/build-state.js +0 -612
- package/core/config.d.ts +0 -106
- package/core/config.js +0 -1328
- package/core/context-loader.js +0 -580
- package/core/context.d.ts +0 -61
- package/core/context.js +0 -327
- package/core/entitlements.d.ts +0 -70
- package/core/entitlements.js +0 -322
- package/core/index.d.ts +0 -53
- package/core/index.js +0 -62
- package/core/mcp-config.js +0 -115
- package/core/policies.d.ts +0 -43
- package/core/policies.js +0 -113
- package/core/policy-matrix.js +0 -303
- package/core/project-activity.js +0 -175
- package/core/redaction.d.ts +0 -5
- package/core/redaction.js +0 -63
- package/core/self-update.js +0 -259
- package/core/session.js +0 -353
- package/core/task-extractor.js +0 -1098
- package/core/telemetry.d.ts +0 -55
- package/core/telemetry.js +0 -617
- package/core/tier-enforcement.js +0 -928
- package/core/utils.d.ts +0 -90
- package/core/utils.js +0 -455
- package/core/validation.js +0 -572
- package/mcp/server.d.ts +0 -57
- package/mcp/server.js +0 -264
package/cli/build.js
DELETED
|
@@ -1,1442 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bootspring Build Command
|
|
3
|
-
*
|
|
4
|
-
* Dedicated build management commands:
|
|
5
|
-
* - status: Check build progress
|
|
6
|
-
* - pause: Pause the build loop
|
|
7
|
-
* - resume: Resume the build loop
|
|
8
|
-
* - task: Show current task
|
|
9
|
-
* - skip: Skip current task
|
|
10
|
-
* - plan: View full plan
|
|
11
|
-
* - reset: Reset build state
|
|
12
|
-
*
|
|
13
|
-
* @package bootspring
|
|
14
|
-
* @command build
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const path = require('path');
|
|
18
|
-
const fs = require('fs');
|
|
19
|
-
const config = require('../core/config');
|
|
20
|
-
const utils = require('../core/utils');
|
|
21
|
-
const buildState = require('../core/build-state');
|
|
22
|
-
const { BuildOrchestrator } = require('../core/build-orchestrator');
|
|
23
|
-
|
|
24
|
-
// Colors
|
|
25
|
-
const c = {
|
|
26
|
-
reset: '\x1b[0m',
|
|
27
|
-
bold: '\x1b[1m',
|
|
28
|
-
dim: '\x1b[2m',
|
|
29
|
-
green: '\x1b[32m',
|
|
30
|
-
blue: '\x1b[34m',
|
|
31
|
-
yellow: '\x1b[33m',
|
|
32
|
-
cyan: '\x1b[36m',
|
|
33
|
-
red: '\x1b[31m',
|
|
34
|
-
magenta: '\x1b[35m'
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const PRESEED_DOC_FILES = [
|
|
38
|
-
'VISION.md',
|
|
39
|
-
'AUDIENCE.md',
|
|
40
|
-
'MARKET.md',
|
|
41
|
-
'COMPETITORS.md',
|
|
42
|
-
'BUSINESS_MODEL.md',
|
|
43
|
-
'PRD.md',
|
|
44
|
-
'TECHNICAL_SPEC.md',
|
|
45
|
-
'ROADMAP.md'
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Detect if the project root contains an existing codebase
|
|
50
|
-
*/
|
|
51
|
-
function isExistingCodebase(projectRoot) {
|
|
52
|
-
const indicators = [
|
|
53
|
-
'package.json', 'Cargo.toml', 'go.mod', 'requirements.txt',
|
|
54
|
-
'pyproject.toml', 'Gemfile', 'pom.xml', 'build.gradle', 'composer.json', '.git'
|
|
55
|
-
];
|
|
56
|
-
const srcDirs = ['src', 'lib', 'app', 'pages', 'components'];
|
|
57
|
-
|
|
58
|
-
for (const indicator of indicators) {
|
|
59
|
-
if (fs.existsSync(path.join(projectRoot, indicator))) return true;
|
|
60
|
-
}
|
|
61
|
-
for (const dir of srcDirs) {
|
|
62
|
-
const dirPath = path.join(projectRoot, dir);
|
|
63
|
-
if (fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory()) return true;
|
|
64
|
-
}
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Get the appropriate preseed command suggestion
|
|
70
|
-
*/
|
|
71
|
-
function getPreseedSuggestion(projectRoot) {
|
|
72
|
-
return isExistingCodebase(projectRoot) ? 'bootspring preseed codebase' : 'bootspring preseed start';
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function resolveBooleanFlag(value, defaultValue) {
|
|
76
|
-
if (typeof value === 'boolean') return value;
|
|
77
|
-
if (typeof value === 'string') {
|
|
78
|
-
const normalized = value.trim().toLowerCase();
|
|
79
|
-
if (['true', '1', 'yes', 'on'].includes(normalized)) return true;
|
|
80
|
-
if (['false', '0', 'no', 'off'].includes(normalized)) return false;
|
|
81
|
-
}
|
|
82
|
-
return defaultValue;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function countPreseedDocsInDir(dirPath) {
|
|
86
|
-
return PRESEED_DOC_FILES.filter(file => fs.existsSync(path.join(dirPath, file))).length;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function copyPlanningPreseedDocs(projectRoot, options = {}) {
|
|
90
|
-
const planningDir = path.join(projectRoot, 'planning');
|
|
91
|
-
const preseedDir = path.join(projectRoot, '.bootspring', 'preseed');
|
|
92
|
-
|
|
93
|
-
if (!fs.existsSync(planningDir)) return 0;
|
|
94
|
-
|
|
95
|
-
if (!fs.existsSync(preseedDir)) {
|
|
96
|
-
fs.mkdirSync(preseedDir, { recursive: true });
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const overwrite = options.overwrite === true;
|
|
100
|
-
let copied = 0;
|
|
101
|
-
|
|
102
|
-
for (const file of PRESEED_DOC_FILES) {
|
|
103
|
-
const source = path.join(planningDir, file);
|
|
104
|
-
const target = path.join(preseedDir, file);
|
|
105
|
-
if (!fs.existsSync(source)) continue;
|
|
106
|
-
if (!overwrite && fs.existsSync(target)) continue;
|
|
107
|
-
fs.copyFileSync(source, target);
|
|
108
|
-
copied++;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return copied;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Main run function - Interactive by default
|
|
116
|
-
* @param {array} args - Command arguments
|
|
117
|
-
*/
|
|
118
|
-
async function run(args) {
|
|
119
|
-
const parsedArgs = utils.parseArgs(args);
|
|
120
|
-
const subcommand = parsedArgs._[0];
|
|
121
|
-
|
|
122
|
-
const cfg = config.load();
|
|
123
|
-
const projectRoot = cfg._projectRoot;
|
|
124
|
-
|
|
125
|
-
// If no subcommand, run interactive mode
|
|
126
|
-
if (!subcommand) {
|
|
127
|
-
return interactiveBuild(projectRoot, parsedArgs);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Advanced users can use subcommands directly
|
|
131
|
-
switch (subcommand) {
|
|
132
|
-
case 'status':
|
|
133
|
-
return showBuildStatus(projectRoot, parsedArgs);
|
|
134
|
-
|
|
135
|
-
case 'pause':
|
|
136
|
-
return pauseBuildLoop(projectRoot);
|
|
137
|
-
|
|
138
|
-
case 'stop':
|
|
139
|
-
return gracefulStop(projectRoot);
|
|
140
|
-
|
|
141
|
-
case 'resume':
|
|
142
|
-
case 'continue':
|
|
143
|
-
return resumeBuildLoop(projectRoot);
|
|
144
|
-
|
|
145
|
-
case 'task':
|
|
146
|
-
return showCurrentTask(projectRoot, parsedArgs);
|
|
147
|
-
|
|
148
|
-
case 'skip':
|
|
149
|
-
return skipCurrentTask(projectRoot, parsedArgs);
|
|
150
|
-
|
|
151
|
-
case 'plan':
|
|
152
|
-
return showPlan(projectRoot);
|
|
153
|
-
|
|
154
|
-
case 'reset':
|
|
155
|
-
return resetBuild(projectRoot, parsedArgs);
|
|
156
|
-
|
|
157
|
-
case 'next':
|
|
158
|
-
return buildNextTask(projectRoot, parsedArgs);
|
|
159
|
-
|
|
160
|
-
case 'done':
|
|
161
|
-
case 'complete':
|
|
162
|
-
return markTaskDone(projectRoot, parsedArgs);
|
|
163
|
-
|
|
164
|
-
case 'loop':
|
|
165
|
-
case 'all':
|
|
166
|
-
return buildLoop(projectRoot, parsedArgs);
|
|
167
|
-
|
|
168
|
-
case 'migrate-todo':
|
|
169
|
-
case 'migrate':
|
|
170
|
-
return migrateTodoFormat(projectRoot, parsedArgs);
|
|
171
|
-
|
|
172
|
-
case 'backfill':
|
|
173
|
-
case 'recover':
|
|
174
|
-
case 'hydrate':
|
|
175
|
-
case 'bootstrap':
|
|
176
|
-
return backfillBuildArtifacts(projectRoot, parsedArgs);
|
|
177
|
-
|
|
178
|
-
case 'help':
|
|
179
|
-
case '-h':
|
|
180
|
-
case '--help':
|
|
181
|
-
return showHelp();
|
|
182
|
-
|
|
183
|
-
default:
|
|
184
|
-
console.log(`${c.red}Unknown subcommand: ${subcommand}${c.reset}`);
|
|
185
|
-
showHelp();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Interactive build mode - guides user through options
|
|
191
|
-
*/
|
|
192
|
-
async function interactiveBuild(projectRoot, args = {}) {
|
|
193
|
-
const state = buildState.load(projectRoot);
|
|
194
|
-
|
|
195
|
-
console.log(`
|
|
196
|
-
${c.cyan}${c.bold}Bootspring Build${c.reset}
|
|
197
|
-
`);
|
|
198
|
-
|
|
199
|
-
// No build state - offer to initialize
|
|
200
|
-
if (!state) {
|
|
201
|
-
console.log(`${c.yellow}No build found.${c.reset}
|
|
202
|
-
|
|
203
|
-
This will:
|
|
204
|
-
1. Extract tasks from your seed documents
|
|
205
|
-
2. Create a build plan in /planning
|
|
206
|
-
3. Guide you through building your MVP
|
|
207
|
-
|
|
208
|
-
`);
|
|
209
|
-
|
|
210
|
-
const answer = await askQuestion('Initialize build from seed docs? [Y/n] ');
|
|
211
|
-
|
|
212
|
-
if (answer.toLowerCase() === 'n') {
|
|
213
|
-
console.log(`\n${c.dim}Run '${getPreseedSuggestion(projectRoot)}' first if you haven't set up seed docs.${c.reset}\n`);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Initialize build
|
|
218
|
-
const { BuildOrchestrator } = require('../core/build-orchestrator');
|
|
219
|
-
const orchestrator = new BuildOrchestrator(projectRoot);
|
|
220
|
-
const spinner = utils.createSpinner('Analyzing seed documents...').start();
|
|
221
|
-
|
|
222
|
-
const result = await orchestrator.initialize();
|
|
223
|
-
|
|
224
|
-
if (!result.success) {
|
|
225
|
-
spinner.fail(result.error);
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
spinner.succeed(`Found ${result.taskCount} tasks to build`);
|
|
230
|
-
console.log('');
|
|
231
|
-
|
|
232
|
-
// Continue to show options
|
|
233
|
-
return interactiveBuild(projectRoot, args);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Show current progress
|
|
237
|
-
const stats = buildState.getStats(projectRoot);
|
|
238
|
-
const nextTask = buildState.getNextTask(projectRoot);
|
|
239
|
-
|
|
240
|
-
// Progress bar
|
|
241
|
-
const barWidth = 30;
|
|
242
|
-
const filled = Math.round((stats.progress / 100) * barWidth);
|
|
243
|
-
const bar = '█'.repeat(filled) + '░'.repeat(barWidth - filled);
|
|
244
|
-
const progressColor = stats.progress === 100 ? c.green : stats.progress > 50 ? c.cyan : c.yellow;
|
|
245
|
-
|
|
246
|
-
console.log(`${c.bold}${state.projectName}${c.reset}
|
|
247
|
-
|
|
248
|
-
Progress: [${progressColor}${bar}${c.reset}] ${stats.progress}%
|
|
249
|
-
Tasks: ${c.green}${stats.completed}${c.reset} done, ${stats.pending} remaining
|
|
250
|
-
Phase: ${formatPhaseName(state.currentPhase)}
|
|
251
|
-
`);
|
|
252
|
-
|
|
253
|
-
// All done!
|
|
254
|
-
if (!nextTask) {
|
|
255
|
-
if (stats.completed === stats.total) {
|
|
256
|
-
console.log(`${c.green}${c.bold}All tasks complete! Your MVP is ready.${c.reset}
|
|
257
|
-
|
|
258
|
-
Next steps:
|
|
259
|
-
${c.cyan}npm run dev${c.reset} Start development server
|
|
260
|
-
${c.cyan}npm run build${c.reset} Build for production
|
|
261
|
-
${c.cyan}bootspring deploy${c.reset} Deploy to production
|
|
262
|
-
`);
|
|
263
|
-
} else {
|
|
264
|
-
console.log(`${c.yellow}No pending tasks available.${c.reset}
|
|
265
|
-
Some tasks may be blocked. Run ${c.cyan}bootspring build status${c.reset} for details.
|
|
266
|
-
`);
|
|
267
|
-
}
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Show next task
|
|
272
|
-
console.log(`${c.bold}Next Task:${c.reset}
|
|
273
|
-
${nextTask.title}
|
|
274
|
-
${c.dim}${nextTask.source || ''}${c.reset}
|
|
275
|
-
`);
|
|
276
|
-
|
|
277
|
-
// Show options
|
|
278
|
-
console.log(`${c.bold}What would you like to do?${c.reset}
|
|
279
|
-
|
|
280
|
-
${c.cyan}1${c.reset} Start this task (shows prompt for Claude Code)
|
|
281
|
-
${c.cyan}2${c.reset} Loop all tasks (autonomous - runs Claude until complete)
|
|
282
|
-
${c.cyan}3${c.reset} View task details
|
|
283
|
-
${c.cyan}4${c.reset} Skip this task
|
|
284
|
-
${c.cyan}5${c.reset} View full plan
|
|
285
|
-
${c.cyan}q${c.reset} Quit
|
|
286
|
-
`);
|
|
287
|
-
|
|
288
|
-
const choice = await askQuestion('Choose [1-5, q]: ');
|
|
289
|
-
|
|
290
|
-
switch (choice.trim()) {
|
|
291
|
-
case '1':
|
|
292
|
-
case '':
|
|
293
|
-
return buildNextTask(projectRoot, args);
|
|
294
|
-
|
|
295
|
-
case '2':
|
|
296
|
-
return buildLoop(projectRoot, args);
|
|
297
|
-
|
|
298
|
-
case '3':
|
|
299
|
-
showCurrentTask(projectRoot, { prompt: true });
|
|
300
|
-
console.log('');
|
|
301
|
-
return interactiveBuild(projectRoot, args);
|
|
302
|
-
|
|
303
|
-
case '4': {
|
|
304
|
-
const reason = await askQuestion('Skip reason (optional): ');
|
|
305
|
-
skipCurrentTask(projectRoot, { reason: reason || 'Skipped by user' });
|
|
306
|
-
return interactiveBuild(projectRoot, args);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
case '5':
|
|
310
|
-
showPlan(projectRoot);
|
|
311
|
-
return interactiveBuild(projectRoot, args);
|
|
312
|
-
|
|
313
|
-
case 'q':
|
|
314
|
-
case 'Q':
|
|
315
|
-
console.log(`\n${c.dim}Run 'bootspring build' anytime to continue.${c.reset}\n`);
|
|
316
|
-
return;
|
|
317
|
-
|
|
318
|
-
default:
|
|
319
|
-
console.log(`${c.yellow}Invalid choice. Please try again.${c.reset}\n`);
|
|
320
|
-
return interactiveBuild(projectRoot, args);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Build the next task - writes to CURRENT_TASK.md for Claude Code
|
|
326
|
-
*/
|
|
327
|
-
async function buildNextTask(projectRoot, _args = {}) {
|
|
328
|
-
const state = buildState.load(projectRoot);
|
|
329
|
-
|
|
330
|
-
if (!state) {
|
|
331
|
-
console.log(`${c.yellow}No build state found. Run 'bootspring build' to start.${c.reset}`);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
const nextTask = buildState.getNextTask(projectRoot);
|
|
336
|
-
|
|
337
|
-
if (!nextTask) {
|
|
338
|
-
console.log(`${c.green}All tasks complete!${c.reset}`);
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// Mark task as in progress
|
|
343
|
-
const startedTask = buildState.updateProgress(projectRoot, nextTask.id, 'in_progress');
|
|
344
|
-
if (!startedTask) {
|
|
345
|
-
console.log(`${c.red}Failed to update build state. Could not mark ${nextTask.id} as in progress.${c.reset}`);
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
console.log(`
|
|
350
|
-
${c.green}${c.bold}✓ Task ${nextTask.id} now in progress${c.reset}
|
|
351
|
-
|
|
352
|
-
${c.bold}Task:${c.reset} ${nextTask.title}
|
|
353
|
-
${c.bold}Phase:${c.reset} ${nextTask.phase || 'MVP'}
|
|
354
|
-
${c.bold}Source:${c.reset} ${nextTask.source || 'PRD.md'}
|
|
355
|
-
|
|
356
|
-
${c.cyan}${c.bold}Tell Claude Code:${c.reset}
|
|
357
|
-
"Read planning/TODO.md, find ${nextTask.id}, and implement it"
|
|
358
|
-
|
|
359
|
-
${c.dim}When done, run: bootspring build done${c.reset}
|
|
360
|
-
`);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Generate a prompt for Claude Code to execute
|
|
366
|
-
*/
|
|
367
|
-
function _generateTaskPrompt(task, _projectRoot) {
|
|
368
|
-
const lines = [];
|
|
369
|
-
|
|
370
|
-
lines.push(`**Objective:** ${task.title}`);
|
|
371
|
-
lines.push('');
|
|
372
|
-
|
|
373
|
-
if (task.description) {
|
|
374
|
-
lines.push('**Description:**');
|
|
375
|
-
lines.push(task.description);
|
|
376
|
-
lines.push('');
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (task.acceptanceCriteria && task.acceptanceCriteria.length > 0) {
|
|
380
|
-
lines.push('**Acceptance Criteria:**');
|
|
381
|
-
task.acceptanceCriteria.forEach(ac => {
|
|
382
|
-
lines.push(`- [ ] ${ac}`);
|
|
383
|
-
});
|
|
384
|
-
lines.push('');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (task.sourceSection) {
|
|
388
|
-
lines.push(`**Source:** ${task.source} - ${task.sourceSection}`);
|
|
389
|
-
lines.push('');
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
lines.push('**Instructions:**');
|
|
393
|
-
lines.push('1. Implement the task as described above');
|
|
394
|
-
lines.push('2. Ensure all acceptance criteria are met');
|
|
395
|
-
lines.push('3. Test your implementation');
|
|
396
|
-
lines.push('4. When done, run: bootspring build done');
|
|
397
|
-
|
|
398
|
-
return lines.join('\n');
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Mark current task as done and auto-queue next
|
|
403
|
-
*/
|
|
404
|
-
async function markTaskDone(projectRoot, _args = {}) {
|
|
405
|
-
const state = buildState.load(projectRoot);
|
|
406
|
-
|
|
407
|
-
if (!state) {
|
|
408
|
-
console.log(`${c.yellow}No build state found.${c.reset}`);
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Find in-progress task
|
|
413
|
-
const inProgressTask = state.implementationQueue.find(t => t.status === 'in_progress');
|
|
414
|
-
|
|
415
|
-
if (!inProgressTask) {
|
|
416
|
-
console.log(`${c.yellow}No task currently in progress.${c.reset}`);
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// Mark as complete
|
|
421
|
-
const completedTask = buildState.updateProgress(projectRoot, inProgressTask.id, 'completed');
|
|
422
|
-
if (!completedTask) {
|
|
423
|
-
console.log(`${c.red}Failed to update build state. Could not mark ${inProgressTask.id} as completed.${c.reset}`);
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
console.log(`${c.green}✓${c.reset} Completed: ${c.bold}${inProgressTask.title}${c.reset}`);
|
|
428
|
-
|
|
429
|
-
// Check if loop mode is active - if so, commit and push
|
|
430
|
-
const loopState = loadLoopState(projectRoot);
|
|
431
|
-
if (loopState && loopState.active) {
|
|
432
|
-
await commitAndPush(projectRoot, inProgressTask, {
|
|
433
|
-
noCommit: loopState.noCommit,
|
|
434
|
-
noPush: loopState.noPush
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// Get stats
|
|
439
|
-
const stats = buildState.getStats(projectRoot);
|
|
440
|
-
if (!stats) {
|
|
441
|
-
console.log(`${c.red}Failed to load build stats after updating task status.${c.reset}`);
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
console.log(`${c.dim}Progress: ${stats.completed}/${stats.total} tasks (${Math.round(stats.completedPercent)}%)${c.reset}`);
|
|
445
|
-
|
|
446
|
-
// Auto-queue next task
|
|
447
|
-
const nextTask = buildState.getNextTask(projectRoot);
|
|
448
|
-
|
|
449
|
-
if (nextTask) {
|
|
450
|
-
// Mark as in progress
|
|
451
|
-
const queuedTask = buildState.updateProgress(projectRoot, nextTask.id, 'in_progress');
|
|
452
|
-
if (!queuedTask) {
|
|
453
|
-
console.log(`${c.red}Failed to update build state. Could not queue ${nextTask.id} as in progress.${c.reset}`);
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
// Update loop state with new task
|
|
458
|
-
if (loopState && loopState.active) {
|
|
459
|
-
saveLoopState(projectRoot, {
|
|
460
|
-
...loopState,
|
|
461
|
-
currentTaskId: nextTask.id,
|
|
462
|
-
lastTaskCompletedAt: new Date().toISOString()
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
console.log(`
|
|
467
|
-
${c.cyan}${c.bold}▶ Next: ${nextTask.title}${c.reset} (${nextTask.id})
|
|
468
|
-
|
|
469
|
-
${c.bold}Continue building:${c.reset} Read planning/TODO.md, implement ${nextTask.id}
|
|
470
|
-
${c.dim}Then run: bootspring build done${c.reset}
|
|
471
|
-
`);
|
|
472
|
-
} else {
|
|
473
|
-
// Clear loop state - build complete
|
|
474
|
-
if (loopState && loopState.active) {
|
|
475
|
-
saveLoopState(projectRoot, {
|
|
476
|
-
...loopState,
|
|
477
|
-
active: false,
|
|
478
|
-
completedAt: new Date().toISOString()
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
console.log(`
|
|
483
|
-
${c.green}${c.bold}🎉 MVP BUILD COMPLETE!${c.reset}
|
|
484
|
-
|
|
485
|
-
All ${stats.total} tasks finished. Your MVP is ready.
|
|
486
|
-
|
|
487
|
-
${c.bold}Next steps:${c.reset}
|
|
488
|
-
1. Review the generated code
|
|
489
|
-
2. Run tests: ${c.cyan}npm test${c.reset}
|
|
490
|
-
3. Deploy: ${c.cyan}bootspring deploy${c.reset}
|
|
491
|
-
`);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Build loop - autonomous task execution with commit/push after each task
|
|
497
|
-
*
|
|
498
|
-
* Usage:
|
|
499
|
-
* bootspring build loop # Start/resume the loop
|
|
500
|
-
* bootspring build loop --no-push # Commit but don't push
|
|
501
|
-
* bootspring build loop --no-commit # No git operations
|
|
502
|
-
*/
|
|
503
|
-
async function buildLoop(projectRoot, args = {}) {
|
|
504
|
-
const state = buildState.load(projectRoot);
|
|
505
|
-
|
|
506
|
-
if (!state) {
|
|
507
|
-
console.log(`${c.yellow}No build state found. Run 'bootspring seed synthesize' first.${c.reset}`);
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
const stats = buildState.getStats(projectRoot);
|
|
512
|
-
const noCommit = args['no-commit'] || args.noCommit;
|
|
513
|
-
const noPush = args['no-push'] || args.noPush || noCommit;
|
|
514
|
-
|
|
515
|
-
// Check for in-progress task (crash recovery)
|
|
516
|
-
const inProgress = state.implementationQueue.find(t => t.status === 'in_progress');
|
|
517
|
-
|
|
518
|
-
if (inProgress) {
|
|
519
|
-
console.log(`
|
|
520
|
-
${c.yellow}${c.bold}⚠ Resuming from crash${c.reset}
|
|
521
|
-
|
|
522
|
-
Found in-progress task: ${c.cyan}${inProgress.title}${c.reset} (${inProgress.id})
|
|
523
|
-
|
|
524
|
-
${c.dim}This task was in progress when the loop stopped.
|
|
525
|
-
Continue implementing it, then run 'bootspring build done'.${c.reset}
|
|
526
|
-
`);
|
|
527
|
-
} else {
|
|
528
|
-
// Queue next task
|
|
529
|
-
const nextTask = buildState.getNextTask(projectRoot);
|
|
530
|
-
if (!nextTask) {
|
|
531
|
-
console.log(`${c.green}${c.bold}🎉 All tasks complete!${c.reset}`);
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
const queuedTask = buildState.updateProgress(projectRoot, nextTask.id, 'in_progress');
|
|
535
|
-
if (!queuedTask) {
|
|
536
|
-
console.log(`${c.red}Failed to update build state. Could not queue ${nextTask.id} as in progress.${c.reset}`);
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
const currentTask = state.implementationQueue.find(t => t.status === 'in_progress')
|
|
542
|
-
|| buildState.getNextTask(projectRoot);
|
|
543
|
-
|
|
544
|
-
console.log(`
|
|
545
|
-
${c.cyan}${c.bold}⚡ Bootspring Build Loop${c.reset}
|
|
546
|
-
|
|
547
|
-
${c.bold}Current Task:${c.reset} ${currentTask?.title || 'None'} (${currentTask?.id || '-'})
|
|
548
|
-
${c.bold}Progress:${c.reset} ${stats.completed}/${stats.total} tasks (${Math.round(stats.completedPercent)}%)
|
|
549
|
-
${c.bold}Git Mode:${c.reset} ${noCommit ? 'Disabled' : noPush ? 'Commit only' : 'Commit + Push'}
|
|
550
|
-
|
|
551
|
-
${c.bold}Workflow:${c.reset}
|
|
552
|
-
1. Read planning/TODO.md, find ${currentTask?.id || 'current task'}
|
|
553
|
-
2. Implement the task
|
|
554
|
-
3. Run: ${c.cyan}bootspring build done${c.reset}${!noCommit ? `
|
|
555
|
-
(Auto-commits: "feat(${currentTask?.id}): ${currentTask?.title?.slice(0, 40) || 'task'}...")${!noPush ? `
|
|
556
|
-
(Auto-pushes to origin)` : ''}` : ''}
|
|
557
|
-
4. Continue to next task...
|
|
558
|
-
|
|
559
|
-
${c.dim}Press Ctrl+C to stop. Run 'bootspring build loop' to resume.${c.reset}
|
|
560
|
-
`);
|
|
561
|
-
|
|
562
|
-
// Save loop state for crash recovery
|
|
563
|
-
saveLoopState(projectRoot, {
|
|
564
|
-
active: true,
|
|
565
|
-
startedAt: new Date().toISOString(),
|
|
566
|
-
noCommit,
|
|
567
|
-
noPush
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Save loop state for crash recovery
|
|
573
|
-
*/
|
|
574
|
-
function saveLoopState(projectRoot, state) {
|
|
575
|
-
const loopFile = path.join(projectRoot, '.bootspring', 'loop-state.json');
|
|
576
|
-
const dir = path.dirname(loopFile);
|
|
577
|
-
if (!fs.existsSync(dir)) {
|
|
578
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
579
|
-
}
|
|
580
|
-
fs.writeFileSync(loopFile, JSON.stringify(state, null, 2));
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
/**
|
|
584
|
-
* Load loop state
|
|
585
|
-
*/
|
|
586
|
-
function loadLoopState(projectRoot) {
|
|
587
|
-
const loopFile = path.join(projectRoot, '.bootspring', 'loop-state.json');
|
|
588
|
-
if (fs.existsSync(loopFile)) {
|
|
589
|
-
try {
|
|
590
|
-
return JSON.parse(fs.readFileSync(loopFile, 'utf-8'));
|
|
591
|
-
} catch {
|
|
592
|
-
return null;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
return null;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Clear loop state (used when stopping or completing)
|
|
600
|
-
*/
|
|
601
|
-
function _clearLoopState(projectRoot) {
|
|
602
|
-
const loopFile = path.join(projectRoot, '.bootspring', 'loop-state.json');
|
|
603
|
-
if (fs.existsSync(loopFile)) {
|
|
604
|
-
fs.unlinkSync(loopFile);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* Commit and push changes for a completed task
|
|
610
|
-
*/
|
|
611
|
-
async function commitAndPush(projectRoot, task, options = {}) {
|
|
612
|
-
const { noCommit, noPush } = options;
|
|
613
|
-
|
|
614
|
-
if (noCommit) return { committed: false, pushed: false };
|
|
615
|
-
|
|
616
|
-
const { execSync } = require('child_process');
|
|
617
|
-
|
|
618
|
-
try {
|
|
619
|
-
// Check if there are changes to commit
|
|
620
|
-
const status = execSync('git status --porcelain', { cwd: projectRoot, encoding: 'utf-8' });
|
|
621
|
-
if (!status.trim()) {
|
|
622
|
-
console.log(`${c.dim}No changes to commit${c.reset}`);
|
|
623
|
-
return { committed: false, pushed: false };
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// Stage all changes
|
|
627
|
-
execSync('git add -A', { cwd: projectRoot });
|
|
628
|
-
|
|
629
|
-
// Create commit message
|
|
630
|
-
const shortTitle = task.title.length > 50 ? task.title.slice(0, 47) + '...' : task.title;
|
|
631
|
-
const commitMsg = `feat(${task.id}): ${shortTitle}
|
|
632
|
-
|
|
633
|
-
Task: ${task.title}
|
|
634
|
-
Phase: ${task.phase || 'MVP'}
|
|
635
|
-
Source: ${task.source || 'planning'}
|
|
636
|
-
|
|
637
|
-
Acceptance Criteria:
|
|
638
|
-
${(task.acceptanceCriteria || []).map(ac => `- [x] ${ac}`).join('\n')}
|
|
639
|
-
|
|
640
|
-
Built with Bootspring autonomous loop.`;
|
|
641
|
-
|
|
642
|
-
// Commit
|
|
643
|
-
execSync(`git commit -m "${commitMsg.replace(/"/g, '\\"')}"`, { cwd: projectRoot });
|
|
644
|
-
console.log(`${c.green}✓${c.reset} Committed: ${c.bold}${task.id}${c.reset}`);
|
|
645
|
-
|
|
646
|
-
if (noPush) {
|
|
647
|
-
return { committed: true, pushed: false };
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
// Push
|
|
651
|
-
try {
|
|
652
|
-
execSync('git push', { cwd: projectRoot, stdio: 'pipe' });
|
|
653
|
-
console.log(`${c.green}✓${c.reset} Pushed to origin`);
|
|
654
|
-
return { committed: true, pushed: true };
|
|
655
|
-
} catch (pushError) {
|
|
656
|
-
console.log(`${c.yellow}⚠${c.reset} Push failed (commit saved locally): ${pushError.message}`);
|
|
657
|
-
return { committed: true, pushed: false };
|
|
658
|
-
}
|
|
659
|
-
} catch (error) {
|
|
660
|
-
console.log(`${c.yellow}⚠${c.reset} Git operation failed: ${error.message}`);
|
|
661
|
-
return { committed: false, pushed: false };
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* Ask a question and get user input
|
|
667
|
-
*/
|
|
668
|
-
function askQuestion(question) {
|
|
669
|
-
const readline = require('readline');
|
|
670
|
-
const rl = readline.createInterface({
|
|
671
|
-
input: process.stdin,
|
|
672
|
-
output: process.stdout
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
return new Promise(resolve => {
|
|
676
|
-
rl.question(question, answer => {
|
|
677
|
-
rl.close();
|
|
678
|
-
resolve(answer);
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
function loadLoopUsageSummary(projectRoot) {
|
|
684
|
-
const loopDir = path.join(projectRoot, '.bootspring', 'loop');
|
|
685
|
-
const metricsPath = path.join(loopDir, 'metrics.json');
|
|
686
|
-
const sessionPath = path.join(loopDir, 'session-state.json');
|
|
687
|
-
|
|
688
|
-
if (!fs.existsSync(metricsPath) && !fs.existsSync(sessionPath)) {
|
|
689
|
-
return null;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
let metrics = {};
|
|
693
|
-
let sessionState = {};
|
|
694
|
-
|
|
695
|
-
try {
|
|
696
|
-
if (fs.existsSync(metricsPath)) {
|
|
697
|
-
metrics = JSON.parse(fs.readFileSync(metricsPath, 'utf-8'));
|
|
698
|
-
}
|
|
699
|
-
if (fs.existsSync(sessionPath)) {
|
|
700
|
-
sessionState = JSON.parse(fs.readFileSync(sessionPath, 'utf-8'));
|
|
701
|
-
}
|
|
702
|
-
} catch {
|
|
703
|
-
return null;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
const apiCalls = Number(metrics.totalApiCalls ?? sessionState.usage?.apiCalls ?? 0);
|
|
707
|
-
const promptTokens = Number(metrics.totalPromptTokens ?? sessionState.usage?.promptTokens ?? 0);
|
|
708
|
-
const completionTokens = Number(metrics.totalCompletionTokens ?? sessionState.usage?.completionTokens ?? 0);
|
|
709
|
-
const totalTokens = Number(metrics.totalTokens ?? sessionState.usage?.totalTokens ?? 0);
|
|
710
|
-
const estimatedCostUsd = Number(metrics.estimatedCostUsd ?? sessionState.usage?.estimatedCostUsd ?? 0);
|
|
711
|
-
|
|
712
|
-
return {
|
|
713
|
-
apiCalls: Number.isFinite(apiCalls) ? apiCalls : 0,
|
|
714
|
-
promptTokens: Number.isFinite(promptTokens) ? promptTokens : 0,
|
|
715
|
-
completionTokens: Number.isFinite(completionTokens) ? completionTokens : 0,
|
|
716
|
-
totalTokens: Number.isFinite(totalTokens) ? totalTokens : 0,
|
|
717
|
-
estimatedCostUsd: Number.isFinite(estimatedCostUsd) ? estimatedCostUsd : 0,
|
|
718
|
-
budgetConfig: sessionState.budgetConfig || null
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
function formatUsd(amount) {
|
|
723
|
-
return `$${(Number(amount) || 0).toFixed(4)}`;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/**
|
|
727
|
-
* Show build status
|
|
728
|
-
*/
|
|
729
|
-
function showBuildStatus(projectRoot, _args = {}) {
|
|
730
|
-
const state = buildState.load(projectRoot);
|
|
731
|
-
|
|
732
|
-
if (!state) {
|
|
733
|
-
console.log(`
|
|
734
|
-
${c.cyan}${c.bold}Build Status${c.reset}
|
|
735
|
-
|
|
736
|
-
${c.yellow}No build state found.${c.reset}
|
|
737
|
-
Run ${c.cyan}bootspring seed build${c.reset} to initialize the build system.
|
|
738
|
-
`);
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
const stats = buildState.getStats(projectRoot);
|
|
743
|
-
const loopUsage = loadLoopUsageSummary(projectRoot);
|
|
744
|
-
|
|
745
|
-
// Status icon
|
|
746
|
-
const statusIcon = {
|
|
747
|
-
pending: `${c.dim}○${c.reset}`,
|
|
748
|
-
in_progress: `${c.green}●${c.reset}`,
|
|
749
|
-
paused: `${c.yellow}◐${c.reset}`,
|
|
750
|
-
completed: `${c.green}✓${c.reset}`,
|
|
751
|
-
failed: `${c.red}✗${c.reset}`
|
|
752
|
-
}[state.status] || '?';
|
|
753
|
-
|
|
754
|
-
// Progress bar
|
|
755
|
-
const barWidth = 40;
|
|
756
|
-
const filled = Math.round((stats.progress / 100) * barWidth);
|
|
757
|
-
const bar = '█'.repeat(filled) + '░'.repeat(barWidth - filled);
|
|
758
|
-
const progressColor = stats.progress === 100 ? c.green :
|
|
759
|
-
stats.progress > 50 ? c.cyan : c.yellow;
|
|
760
|
-
|
|
761
|
-
console.log(`
|
|
762
|
-
${c.cyan}${c.bold}Build Status${c.reset}
|
|
763
|
-
|
|
764
|
-
${c.bold}Project:${c.reset} ${state.projectName}
|
|
765
|
-
${c.bold}Status:${c.reset} ${statusIcon} ${state.status}
|
|
766
|
-
${c.bold}Phase:${c.reset} ${formatPhaseName(state.currentPhase)}
|
|
767
|
-
|
|
768
|
-
${c.bold}Progress${c.reset}
|
|
769
|
-
[${progressColor}${bar}${c.reset}] ${stats.progress}%
|
|
770
|
-
|
|
771
|
-
${c.bold}Tasks${c.reset}
|
|
772
|
-
Total: ${stats.total}
|
|
773
|
-
Completed: ${c.green}${stats.completed}${c.reset}
|
|
774
|
-
In Progress: ${c.cyan}${stats.inProgress}${c.reset}
|
|
775
|
-
Pending: ${stats.pending}
|
|
776
|
-
Blocked: ${c.red}${stats.blocked}${c.reset}
|
|
777
|
-
Skipped: ${c.dim}${stats.skipped}${c.reset}
|
|
778
|
-
|
|
779
|
-
${c.bold}MVP Progress${c.reset}
|
|
780
|
-
${stats.mvpProgress}% complete ${stats.mvpComplete ? `${c.green}✓ MVP Complete${c.reset}` : ''}
|
|
781
|
-
|
|
782
|
-
${c.bold}Loop Session${c.reset}
|
|
783
|
-
Iteration: ${stats.iteration}/${stats.maxIterations}
|
|
784
|
-
Session ID: ${c.dim}${state.loopSession?.sessionId || 'N/A'}${c.reset}
|
|
785
|
-
`);
|
|
786
|
-
|
|
787
|
-
if (loopUsage) {
|
|
788
|
-
console.log(`${c.bold}Loop Usage${c.reset}
|
|
789
|
-
API calls: ${loopUsage.apiCalls}
|
|
790
|
-
Tokens: ${loopUsage.totalTokens} (${loopUsage.promptTokens} in / ${loopUsage.completionTokens} out)
|
|
791
|
-
Est. cost: ${formatUsd(loopUsage.estimatedCostUsd)}
|
|
792
|
-
Budget stop (USD): ${loopUsage.budgetConfig?.maxUsd ? formatUsd(loopUsage.budgetConfig.maxUsd) : 'off'}
|
|
793
|
-
Budget stop (tokens): ${loopUsage.budgetConfig?.maxTokens || 'off'}
|
|
794
|
-
`);
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
// Show next actions
|
|
798
|
-
showNextActions(state, stats);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Show suggested next actions
|
|
803
|
-
*/
|
|
804
|
-
function showNextActions(state, _stats) {
|
|
805
|
-
console.log(`${c.bold}Next Actions:${c.reset}`);
|
|
806
|
-
|
|
807
|
-
if (state.status === 'paused') {
|
|
808
|
-
console.log(` ${c.cyan}1.${c.reset} Resume building → ${c.dim}bootspring build resume${c.reset}`);
|
|
809
|
-
console.log(` ${c.cyan}2.${c.reset} View current task → ${c.dim}bootspring build task${c.reset}`);
|
|
810
|
-
console.log(` ${c.cyan}3.${c.reset} View full plan → ${c.dim}bootspring build plan${c.reset}`);
|
|
811
|
-
} else if (state.status === 'completed') {
|
|
812
|
-
console.log(` ${c.green}Build complete!${c.reset} All tasks have been finished.`);
|
|
813
|
-
console.log(` ${c.cyan}1.${c.reset} View summary → ${c.dim}bootspring build plan${c.reset}`);
|
|
814
|
-
console.log(` ${c.cyan}2.${c.reset} Deploy → ${c.dim}bootspring deploy${c.reset}`);
|
|
815
|
-
} else if (state.status === 'failed') {
|
|
816
|
-
console.log(` ${c.red}Build failed.${c.reset} Review errors and resume.`);
|
|
817
|
-
console.log(` ${c.cyan}1.${c.reset} View current task → ${c.dim}bootspring build task${c.reset}`);
|
|
818
|
-
console.log(` ${c.cyan}2.${c.reset} Skip blocked task → ${c.dim}bootspring build skip${c.reset}`);
|
|
819
|
-
console.log(` ${c.cyan}3.${c.reset} Reset build → ${c.dim}bootspring build reset${c.reset}`);
|
|
820
|
-
} else if (state.status === 'in_progress') {
|
|
821
|
-
console.log(` ${c.cyan}Build in progress...${c.reset}`);
|
|
822
|
-
console.log(` ${c.cyan}1.${c.reset} Pause building → ${c.dim}bootspring build pause${c.reset}`);
|
|
823
|
-
console.log(` ${c.cyan}2.${c.reset} View current task → ${c.dim}bootspring build task${c.reset}`);
|
|
824
|
-
} else {
|
|
825
|
-
console.log(` ${c.cyan}1.${c.reset} Start building → ${c.dim}bootspring seed build --loop${c.reset}`);
|
|
826
|
-
console.log(` ${c.cyan}2.${c.reset} View current task → ${c.dim}bootspring build task${c.reset}`);
|
|
827
|
-
console.log(` ${c.cyan}3.${c.reset} View full plan → ${c.dim}bootspring build plan${c.reset}`);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
console.log('');
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
/**
|
|
834
|
-
* Pause the build loop
|
|
835
|
-
*/
|
|
836
|
-
function pauseBuildLoop(projectRoot) {
|
|
837
|
-
const state = buildState.load(projectRoot);
|
|
838
|
-
|
|
839
|
-
if (!state) {
|
|
840
|
-
console.log(`${c.yellow}No build state found.${c.reset}`);
|
|
841
|
-
return;
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
if (state.status !== 'in_progress') {
|
|
845
|
-
console.log(`${c.yellow}Build is not running (status: ${state.status})${c.reset}`);
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
buildState.pause(projectRoot);
|
|
850
|
-
|
|
851
|
-
// Update loop state to inactive
|
|
852
|
-
const loopState = loadLoopState(projectRoot);
|
|
853
|
-
if (loopState) {
|
|
854
|
-
saveLoopState(projectRoot, {
|
|
855
|
-
...loopState,
|
|
856
|
-
active: false,
|
|
857
|
-
pausedAt: new Date().toISOString()
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
console.log(`
|
|
862
|
-
${c.green}Build paused.${c.reset}
|
|
863
|
-
|
|
864
|
-
Resume with: ${c.cyan}bootspring build resume${c.reset}
|
|
865
|
-
`);
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* Resume the build loop
|
|
870
|
-
*/
|
|
871
|
-
function resumeBuildLoop(projectRoot) {
|
|
872
|
-
const state = buildState.load(projectRoot);
|
|
873
|
-
|
|
874
|
-
if (!state) {
|
|
875
|
-
console.log(`${c.yellow}No build state found.${c.reset}`);
|
|
876
|
-
console.log(`Initialize with: ${c.cyan}bootspring seed build${c.reset}`);
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
if (state.status === 'completed') {
|
|
881
|
-
console.log(`${c.green}Build is already complete!${c.reset}`);
|
|
882
|
-
return;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
if (state.status !== 'paused' && state.status !== 'pending') {
|
|
886
|
-
console.log(`${c.yellow}Build status: ${state.status}${c.reset}`);
|
|
887
|
-
console.log('Cannot resume from this state.');
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
buildState.resume(projectRoot);
|
|
892
|
-
|
|
893
|
-
// Restore loop state if it exists
|
|
894
|
-
const loopState = loadLoopState(projectRoot);
|
|
895
|
-
if (loopState) {
|
|
896
|
-
saveLoopState(projectRoot, {
|
|
897
|
-
...loopState,
|
|
898
|
-
active: true,
|
|
899
|
-
resumedAt: new Date().toISOString()
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
console.log(`
|
|
904
|
-
${c.green}Build resumed.${c.reset}
|
|
905
|
-
|
|
906
|
-
Continue with: ${c.cyan}bootspring build next${c.reset}
|
|
907
|
-
Or run loop: ${c.cyan}bootspring build loop${c.reset}
|
|
908
|
-
`);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
/**
|
|
912
|
-
* Graceful stop - finish current task then pause
|
|
913
|
-
*/
|
|
914
|
-
function gracefulStop(projectRoot) {
|
|
915
|
-
console.log(`
|
|
916
|
-
${c.yellow}${c.bold}Graceful stop requested${c.reset}
|
|
917
|
-
|
|
918
|
-
The loop will pause after the current task completes.
|
|
919
|
-
This ensures no work is interrupted mid-task.
|
|
920
|
-
|
|
921
|
-
${c.dim}Waiting for current task to finish...${c.reset}
|
|
922
|
-
`);
|
|
923
|
-
|
|
924
|
-
const bootspringDir = path.join(projectRoot, '.bootspring');
|
|
925
|
-
if (!fs.existsSync(bootspringDir)) {
|
|
926
|
-
fs.mkdirSync(bootspringDir, { recursive: true });
|
|
927
|
-
}
|
|
928
|
-
const stopFile = path.join(bootspringDir, 'STOP_AFTER_TASK');
|
|
929
|
-
fs.writeFileSync(stopFile, new Date().toISOString());
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
/**
|
|
933
|
-
* Show current task
|
|
934
|
-
*/
|
|
935
|
-
function showCurrentTask(projectRoot, args = {}) {
|
|
936
|
-
const state = buildState.load(projectRoot);
|
|
937
|
-
|
|
938
|
-
if (!state) {
|
|
939
|
-
console.log(`${c.yellow}No build state found.${c.reset}`);
|
|
940
|
-
return;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
const nextTask = buildState.getNextTask(projectRoot);
|
|
944
|
-
|
|
945
|
-
if (!nextTask) {
|
|
946
|
-
const stats = buildState.getStats(projectRoot);
|
|
947
|
-
|
|
948
|
-
if (stats.completed === stats.total) {
|
|
949
|
-
console.log(`
|
|
950
|
-
${c.green}${c.bold}All tasks complete!${c.reset}
|
|
951
|
-
|
|
952
|
-
${stats.completed} tasks have been completed.
|
|
953
|
-
`);
|
|
954
|
-
} else {
|
|
955
|
-
console.log(`
|
|
956
|
-
${c.yellow}No pending tasks available.${c.reset}
|
|
957
|
-
|
|
958
|
-
${c.bold}Summary:${c.reset}
|
|
959
|
-
Completed: ${stats.completed}
|
|
960
|
-
Blocked: ${stats.blocked}
|
|
961
|
-
Skipped: ${stats.skipped}
|
|
962
|
-
`);
|
|
963
|
-
}
|
|
964
|
-
return;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
console.log(`
|
|
968
|
-
${c.cyan}${c.bold}Current Task${c.reset}
|
|
969
|
-
|
|
970
|
-
${c.bold}ID:${c.reset} ${nextTask.id}
|
|
971
|
-
${c.bold}Title:${c.reset} ${nextTask.title}
|
|
972
|
-
${c.bold}Phase:${c.reset} ${formatPhaseName(nextTask.phase)}
|
|
973
|
-
${c.bold}Complexity:${c.reset} ${nextTask.estimatedComplexity || 'medium'}
|
|
974
|
-
${c.bold}Source:${c.reset} ${nextTask.source || 'Manual'} ${nextTask.sourceSection ? `(${nextTask.sourceSection})` : ''}
|
|
975
|
-
${c.bold}Status:${c.reset} ${nextTask.status}
|
|
976
|
-
`);
|
|
977
|
-
|
|
978
|
-
if (nextTask.description) {
|
|
979
|
-
console.log(`${c.bold}Description:${c.reset}
|
|
980
|
-
${nextTask.description}
|
|
981
|
-
`);
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
if (nextTask.acceptanceCriteria && nextTask.acceptanceCriteria.length > 0) {
|
|
985
|
-
console.log(`${c.bold}Acceptance Criteria:${c.reset}`);
|
|
986
|
-
nextTask.acceptanceCriteria.forEach((criteria, i) => {
|
|
987
|
-
console.log(` ${c.dim}${i + 1}.${c.reset} ${criteria}`);
|
|
988
|
-
});
|
|
989
|
-
console.log('');
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
if (nextTask.dependencies && nextTask.dependencies.length > 0) {
|
|
993
|
-
console.log(`${c.bold}Dependencies:${c.reset} ${nextTask.dependencies.join(', ')}`);
|
|
994
|
-
console.log('');
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
// Show prompt generation option
|
|
998
|
-
if (args.prompt) {
|
|
999
|
-
const orchestrator = new BuildOrchestrator(projectRoot);
|
|
1000
|
-
const prompt = orchestrator.generateTaskPrompt(nextTask);
|
|
1001
|
-
console.log(`${c.bold}Generated Prompt:${c.reset}`);
|
|
1002
|
-
console.log(c.dim + '─'.repeat(60) + c.reset);
|
|
1003
|
-
console.log(prompt);
|
|
1004
|
-
console.log(c.dim + '─'.repeat(60) + c.reset);
|
|
1005
|
-
} else {
|
|
1006
|
-
console.log(`${c.dim}Use --prompt to generate AI prompt for this task${c.reset}`);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
/**
|
|
1011
|
-
* Skip current task
|
|
1012
|
-
*/
|
|
1013
|
-
function skipCurrentTask(projectRoot, args = {}) {
|
|
1014
|
-
const state = buildState.load(projectRoot);
|
|
1015
|
-
|
|
1016
|
-
if (!state) {
|
|
1017
|
-
console.log(`${c.yellow}No build state found.${c.reset}`);
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
const nextTask = buildState.getNextTask(projectRoot);
|
|
1022
|
-
|
|
1023
|
-
if (!nextTask) {
|
|
1024
|
-
console.log(`${c.yellow}No pending tasks to skip.${c.reset}`);
|
|
1025
|
-
return;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
const reason = args.reason || args._[1] || 'Manually skipped';
|
|
1029
|
-
|
|
1030
|
-
const skippedTask = buildState.updateProgress(projectRoot, nextTask.id, 'skipped', {
|
|
1031
|
-
error: reason
|
|
1032
|
-
});
|
|
1033
|
-
if (!skippedTask) {
|
|
1034
|
-
console.log(`${c.red}Failed to update build state. Could not skip ${nextTask.id}.${c.reset}`);
|
|
1035
|
-
return;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
console.log(`
|
|
1039
|
-
${c.yellow}Skipped task: ${nextTask.title}${c.reset}
|
|
1040
|
-
Reason: ${reason}
|
|
1041
|
-
|
|
1042
|
-
Next task: ${buildState.getNextTask(projectRoot)?.title || 'None remaining'}
|
|
1043
|
-
`);
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
/**
|
|
1047
|
-
* Show full plan
|
|
1048
|
-
*/
|
|
1049
|
-
function showPlan(projectRoot) {
|
|
1050
|
-
const planPath = path.join(projectRoot, 'planning', 'MASTER_PLAN.md');
|
|
1051
|
-
|
|
1052
|
-
if (!fs.existsSync(planPath)) {
|
|
1053
|
-
console.log(`${c.yellow}No plan found.${c.reset}`);
|
|
1054
|
-
console.log(`Initialize with: ${c.cyan}bootspring seed build${c.reset}`);
|
|
1055
|
-
return;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
const content = fs.readFileSync(planPath, 'utf-8');
|
|
1059
|
-
|
|
1060
|
-
// Print with formatting
|
|
1061
|
-
console.log(`
|
|
1062
|
-
${c.cyan}${c.bold}Master Plan${c.reset}
|
|
1063
|
-
${c.dim}${planPath}${c.reset}
|
|
1064
|
-
|
|
1065
|
-
${content}
|
|
1066
|
-
`);
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
/**
|
|
1070
|
-
* Reset build state
|
|
1071
|
-
*/
|
|
1072
|
-
function resetBuild(projectRoot, args = {}) {
|
|
1073
|
-
const force = args.force || args.f;
|
|
1074
|
-
|
|
1075
|
-
const state = buildState.load(projectRoot);
|
|
1076
|
-
|
|
1077
|
-
if (!state) {
|
|
1078
|
-
console.log(`${c.yellow}No build state found.${c.reset}`);
|
|
1079
|
-
return;
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
if (!force && state.status === 'in_progress') {
|
|
1083
|
-
console.log(`${c.yellow}Build is in progress. Use --force to reset.${c.reset}`);
|
|
1084
|
-
return;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
buildState.reset(projectRoot);
|
|
1088
|
-
|
|
1089
|
-
console.log(`
|
|
1090
|
-
${c.green}Build state reset.${c.reset}
|
|
1091
|
-
|
|
1092
|
-
Re-initialize with: ${c.cyan}bootspring seed build${c.reset}
|
|
1093
|
-
`);
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
* Format phase name for display
|
|
1098
|
-
*/
|
|
1099
|
-
function formatPhaseName(phase) {
|
|
1100
|
-
if (!phase) return 'Unknown';
|
|
1101
|
-
|
|
1102
|
-
const names = {
|
|
1103
|
-
foundation: 'Foundation',
|
|
1104
|
-
mvp: 'MVP',
|
|
1105
|
-
launch: 'Launch',
|
|
1106
|
-
other: 'Other'
|
|
1107
|
-
};
|
|
1108
|
-
|
|
1109
|
-
return names[phase] || phase.charAt(0).toUpperCase() + phase.slice(1);
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
/**
|
|
1113
|
-
* Backfill preseed docs and planning queue artifacts for existing projects.
|
|
1114
|
-
*/
|
|
1115
|
-
async function backfillBuildArtifacts(projectRoot, args = {}) {
|
|
1116
|
-
const force = resolveBooleanFlag(args.force, false) || resolveBooleanFlag(args.f, false);
|
|
1117
|
-
const deep = resolveBooleanFlag(args.deep, !(resolveBooleanFlag(args.quick, false) || resolveBooleanFlag(args.q, false)));
|
|
1118
|
-
const auto = resolveBooleanFlag(args.auto, !(resolveBooleanFlag(args.interactive, false) || resolveBooleanFlag(args.i, false)));
|
|
1119
|
-
const withOnboard = resolveBooleanFlag(args['with-onboard'], !(resolveBooleanFlag(args['no-onboard'], false) || resolveBooleanFlag(args.noOnboard, false)));
|
|
1120
|
-
|
|
1121
|
-
const preseedDir = path.join(projectRoot, '.bootspring', 'preseed');
|
|
1122
|
-
const planningDir = path.join(projectRoot, 'planning');
|
|
1123
|
-
const seedPath = path.join(projectRoot, 'SEED.md');
|
|
1124
|
-
const queuePath = path.join(planningDir, 'TASK_QUEUE.md');
|
|
1125
|
-
|
|
1126
|
-
console.log(`
|
|
1127
|
-
${c.cyan}${c.bold}Backfilling Build Artifacts${c.reset}
|
|
1128
|
-
`);
|
|
1129
|
-
|
|
1130
|
-
let preseedCount = countPreseedDocsInDir(preseedDir);
|
|
1131
|
-
const needsPreseed = force || preseedCount < PRESEED_DOC_FILES.length;
|
|
1132
|
-
let generatedFromCodebase = false;
|
|
1133
|
-
|
|
1134
|
-
if (needsPreseed) {
|
|
1135
|
-
const copied = copyPlanningPreseedDocs(projectRoot, { overwrite: force });
|
|
1136
|
-
if (copied > 0) {
|
|
1137
|
-
console.log(`${c.green}✓${c.reset} Imported ${copied} preseed documents from planning/`);
|
|
1138
|
-
}
|
|
1139
|
-
|
|
1140
|
-
preseedCount = countPreseedDocsInDir(preseedDir);
|
|
1141
|
-
|
|
1142
|
-
if (force || preseedCount < PRESEED_DOC_FILES.length) {
|
|
1143
|
-
let preseedRunner = null;
|
|
1144
|
-
try {
|
|
1145
|
-
preseedRunner = require('./preseed-from-codebase');
|
|
1146
|
-
} catch {
|
|
1147
|
-
console.log(`${c.yellow}Preseed backfill is not available in the public thin client.${c.reset}`);
|
|
1148
|
-
console.log(`${c.dim}Restore preseed artifacts manually or use a full Bootspring setup to regenerate them.${c.reset}`);
|
|
1149
|
-
return;
|
|
1150
|
-
}
|
|
1151
|
-
const beforeCount = preseedCount;
|
|
1152
|
-
await preseedRunner.run({
|
|
1153
|
-
_: [],
|
|
1154
|
-
deep,
|
|
1155
|
-
d: deep,
|
|
1156
|
-
auto,
|
|
1157
|
-
a: auto,
|
|
1158
|
-
'with-onboard': withOnboard,
|
|
1159
|
-
onboard: withOnboard
|
|
1160
|
-
});
|
|
1161
|
-
|
|
1162
|
-
preseedCount = countPreseedDocsInDir(preseedDir);
|
|
1163
|
-
generatedFromCodebase = preseedCount > beforeCount;
|
|
1164
|
-
}
|
|
1165
|
-
} else {
|
|
1166
|
-
console.log(`${c.dim}Preseed already available (${preseedCount}/${PRESEED_DOC_FILES.length}).${c.reset}`);
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
const shouldSynthesizeSeed = force || generatedFromCodebase || !fs.existsSync(seedPath);
|
|
1170
|
-
if (shouldSynthesizeSeed) {
|
|
1171
|
-
let seedRunner = null;
|
|
1172
|
-
try {
|
|
1173
|
-
seedRunner = require('./seed');
|
|
1174
|
-
} catch {
|
|
1175
|
-
console.log(`${c.yellow}Seed synthesis is not available in the public thin client.${c.reset}`);
|
|
1176
|
-
console.log(`${c.dim}Add SEED.md manually or use a full Bootspring setup to synthesize it.${c.reset}`);
|
|
1177
|
-
return;
|
|
1178
|
-
}
|
|
1179
|
-
const synthArgs = ['synthesize'];
|
|
1180
|
-
if (fs.existsSync(seedPath)) synthArgs.push('--force');
|
|
1181
|
-
|
|
1182
|
-
try {
|
|
1183
|
-
await seedRunner.run(synthArgs);
|
|
1184
|
-
} catch (error) {
|
|
1185
|
-
if (!fs.existsSync(seedPath)) {
|
|
1186
|
-
console.log(`${c.red}Failed to synthesize SEED.md: ${error.message}${c.reset}`);
|
|
1187
|
-
return;
|
|
1188
|
-
}
|
|
1189
|
-
console.log(`${c.yellow}⚠ Could not refresh SEED.md, continuing with existing file.${c.reset}`);
|
|
1190
|
-
}
|
|
1191
|
-
} else {
|
|
1192
|
-
console.log(`${c.dim}SEED.md already exists; skipping synthesis.${c.reset}`);
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
let state = buildState.load(projectRoot);
|
|
1196
|
-
if (state) {
|
|
1197
|
-
const orchestrator = new BuildOrchestrator(projectRoot);
|
|
1198
|
-
orchestrator.updatePlanningFiles();
|
|
1199
|
-
console.log(`${c.green}✓${c.reset} Regenerated planning/TASK_QUEUE.md from current build state`);
|
|
1200
|
-
} else {
|
|
1201
|
-
const orchestrator = new BuildOrchestrator(projectRoot);
|
|
1202
|
-
const spinner = utils.createSpinner('Initializing build from recovered docs...').start();
|
|
1203
|
-
const result = await orchestrator.initialize();
|
|
1204
|
-
if (!result.success) {
|
|
1205
|
-
spinner.fail(result.error || 'Build initialization failed');
|
|
1206
|
-
return;
|
|
1207
|
-
}
|
|
1208
|
-
spinner.succeed(`Initialized build with ${result.taskCount} tasks`);
|
|
1209
|
-
state = buildState.load(projectRoot);
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
const hasSeed = fs.existsSync(seedPath);
|
|
1213
|
-
const hasQueue = fs.existsSync(queuePath);
|
|
1214
|
-
const finalPreseedCount = countPreseedDocsInDir(preseedDir);
|
|
1215
|
-
const queueTasks = state?.implementationQueue?.length || 0;
|
|
1216
|
-
|
|
1217
|
-
console.log(`
|
|
1218
|
-
${c.green}${c.bold}Backfill complete${c.reset}
|
|
1219
|
-
|
|
1220
|
-
${c.bold}Recovered artifacts:${c.reset}
|
|
1221
|
-
Preseed docs: ${finalPreseedCount}/${PRESEED_DOC_FILES.length}
|
|
1222
|
-
SEED.md: ${hasSeed ? `${c.green}yes${c.reset}` : `${c.red}no${c.reset}`}
|
|
1223
|
-
TASK_QUEUE.md: ${hasQueue ? `${c.green}yes${c.reset}` : `${c.red}no${c.reset}`}
|
|
1224
|
-
Build tasks in state: ${queueTasks}
|
|
1225
|
-
|
|
1226
|
-
${c.bold}Next steps:${c.reset}
|
|
1227
|
-
Run ${c.cyan}bootspring build status${c.reset} to verify progress
|
|
1228
|
-
Run ${c.cyan}bootspring build next${c.reset} to continue implementation
|
|
1229
|
-
`);
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
/**
|
|
1233
|
-
* Extract non-task supplementary content from TASK_QUEUE.md.
|
|
1234
|
-
* Captures context notes, architecture diagrams, integration guidelines,
|
|
1235
|
-
* and any section that isn't the task table or per-task detail blocks.
|
|
1236
|
-
*/
|
|
1237
|
-
function extractSupplementaryContent(queueContent) {
|
|
1238
|
-
const lines = queueContent.split('\n');
|
|
1239
|
-
const sections = [];
|
|
1240
|
-
let currentSection = null;
|
|
1241
|
-
let inTaskTable = false;
|
|
1242
|
-
let inTaskDetail = false;
|
|
1243
|
-
|
|
1244
|
-
for (let i = 0; i < lines.length; i++) {
|
|
1245
|
-
const line = lines[i];
|
|
1246
|
-
|
|
1247
|
-
// Detect task table (starts with | Position | or | # |)
|
|
1248
|
-
if (/^\|\s*(Position|#)\s*\|/.test(line)) {
|
|
1249
|
-
inTaskTable = true;
|
|
1250
|
-
continue;
|
|
1251
|
-
}
|
|
1252
|
-
// Still in task table (rows starting with |)
|
|
1253
|
-
if (inTaskTable && /^\|/.test(line)) {
|
|
1254
|
-
continue;
|
|
1255
|
-
}
|
|
1256
|
-
if (inTaskTable && !/^\|/.test(line)) {
|
|
1257
|
-
inTaskTable = false;
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
// Detect per-task detail blocks (### task-XXX: or ### bs-XXX:)
|
|
1261
|
-
if (/^###\s+(task-\d+|bs-\d+)\s*:/.test(line)) {
|
|
1262
|
-
inTaskDetail = true;
|
|
1263
|
-
continue;
|
|
1264
|
-
}
|
|
1265
|
-
// End task detail at next ### or ## heading
|
|
1266
|
-
if (inTaskDetail && /^#{2,3}\s+/.test(line) && !/^###\s+(task-\d+|bs-\d+)\s*:/.test(line)) {
|
|
1267
|
-
inTaskDetail = false;
|
|
1268
|
-
}
|
|
1269
|
-
if (inTaskDetail) continue;
|
|
1270
|
-
|
|
1271
|
-
// Skip the header, queue status heading, and generated boilerplate
|
|
1272
|
-
if (/^#\s+.*Implementation Queue/.test(line)) continue;
|
|
1273
|
-
if (/^>\s*(Ordered task queue|Last Updated|Current Version)/.test(line)) continue;
|
|
1274
|
-
if (/^## Queue Status/.test(line)) { inTaskTable = true; continue; }
|
|
1275
|
-
if (/^## Task Details/.test(line)) { inTaskDetail = true; continue; }
|
|
1276
|
-
if (/^\*Generated by/.test(line)) continue;
|
|
1277
|
-
if (/^---$/.test(line.trim())) continue;
|
|
1278
|
-
|
|
1279
|
-
// Detect section headings for supplementary content
|
|
1280
|
-
if (/^##\s+/.test(line) && !/^## (Queue Status|Task Details|Execution Guidelines)/.test(line)) {
|
|
1281
|
-
if (currentSection) sections.push(currentSection);
|
|
1282
|
-
currentSection = { heading: line, lines: [] };
|
|
1283
|
-
continue;
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
// Execution Guidelines is useful — keep it
|
|
1287
|
-
if (/^## Execution Guidelines/.test(line)) {
|
|
1288
|
-
if (currentSection) sections.push(currentSection);
|
|
1289
|
-
currentSection = { heading: line, lines: [] };
|
|
1290
|
-
continue;
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
if (currentSection) {
|
|
1294
|
-
currentSection.lines.push(line);
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
if (currentSection) sections.push(currentSection);
|
|
1299
|
-
|
|
1300
|
-
// Filter out empty sections and build output
|
|
1301
|
-
const output = sections
|
|
1302
|
-
.filter(s => s.lines.some(l => l.trim().length > 0))
|
|
1303
|
-
.map(s => `${s.heading}\n\n${s.lines.join('\n').trim()}`)
|
|
1304
|
-
.join('\n\n---\n\n');
|
|
1305
|
-
|
|
1306
|
-
return output.trim();
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
/**
|
|
1310
|
-
* Migrate from TASK_QUEUE.md to TODO.md as single source of truth.
|
|
1311
|
-
*/
|
|
1312
|
-
async function migrateTodoFormat(projectRoot, args = {}) {
|
|
1313
|
-
const planningDir = path.join(projectRoot, 'planning');
|
|
1314
|
-
const queuePath = path.join(planningDir, 'TASK_QUEUE.md');
|
|
1315
|
-
const todoPath = path.join(planningDir, 'TODO.md');
|
|
1316
|
-
const keepQueue = Boolean(args['keep-queue'] || args.keepQueue);
|
|
1317
|
-
|
|
1318
|
-
console.log(`
|
|
1319
|
-
${c.cyan}${c.bold}Migrating to TODO.md as Single Source of Truth${c.reset}
|
|
1320
|
-
`);
|
|
1321
|
-
|
|
1322
|
-
// Step 1: Ensure we have build state with tasks
|
|
1323
|
-
let state = buildState.load(projectRoot);
|
|
1324
|
-
|
|
1325
|
-
if (!state || !state.implementationQueue || state.implementationQueue.length === 0) {
|
|
1326
|
-
if (fs.existsSync(queuePath)) {
|
|
1327
|
-
console.log(`${c.dim}No build state — syncing tasks from TASK_QUEUE.md first...${c.reset}`);
|
|
1328
|
-
try {
|
|
1329
|
-
const taskExtractor = require('../core/task-extractor');
|
|
1330
|
-
const result = taskExtractor.syncFromTaskQueue(projectRoot);
|
|
1331
|
-
if (result.total > 0) {
|
|
1332
|
-
console.log(`${c.green}✓${c.reset} Synced ${result.total} tasks from TASK_QUEUE.md`);
|
|
1333
|
-
state = buildState.load(projectRoot);
|
|
1334
|
-
}
|
|
1335
|
-
} catch {
|
|
1336
|
-
// Fall through
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
if (!state || !state.implementationQueue || state.implementationQueue.length === 0) {
|
|
1341
|
-
console.log(`${c.red}No tasks found. Run 'bootspring seed build' first or ensure TASK_QUEUE.md exists.${c.reset}`);
|
|
1342
|
-
return;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
// Step 2: Extract non-task content from TASK_QUEUE.md (context notes, diagrams, guidelines)
|
|
1347
|
-
let supplementaryContent = '';
|
|
1348
|
-
if (fs.existsSync(queuePath)) {
|
|
1349
|
-
const queueContent = fs.readFileSync(queuePath, 'utf-8');
|
|
1350
|
-
supplementaryContent = extractSupplementaryContent(queueContent);
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
// Step 3: Generate enriched TODO.md with full task metadata
|
|
1354
|
-
const planningTemplate = require('../generators/templates/build-planning.template');
|
|
1355
|
-
let todo = planningTemplate.generateTodo(state.implementationQueue, {
|
|
1356
|
-
projectName: state.projectName
|
|
1357
|
-
});
|
|
1358
|
-
|
|
1359
|
-
// Append supplementary content if any was extracted
|
|
1360
|
-
if (supplementaryContent) {
|
|
1361
|
-
todo += `\n---\n\n## Reference (from TASK_QUEUE.md)\n\n${supplementaryContent}\n`;
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
fs.writeFileSync(todoPath, todo);
|
|
1365
|
-
|
|
1366
|
-
const stats = buildState.getStats(projectRoot);
|
|
1367
|
-
console.log(`${c.green}✓${c.reset} Generated TODO.md with ${state.implementationQueue.length} tasks (${stats?.completed || 0} completed)`);
|
|
1368
|
-
if (supplementaryContent) {
|
|
1369
|
-
console.log(`${c.green}✓${c.reset} Preserved supplementary content (context notes, diagrams, guidelines)`);
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// Step 4: Archive TASK_QUEUE.md unless --keep-queue
|
|
1373
|
-
if (fs.existsSync(queuePath) && !keepQueue) {
|
|
1374
|
-
const archivePath = path.join(planningDir, 'TASK_QUEUE.md.bak');
|
|
1375
|
-
fs.renameSync(queuePath, archivePath);
|
|
1376
|
-
console.log(`${c.green}✓${c.reset} Archived TASK_QUEUE.md → TASK_QUEUE.md.bak`);
|
|
1377
|
-
} else if (fs.existsSync(queuePath) && keepQueue) {
|
|
1378
|
-
console.log(`${c.dim}Kept TASK_QUEUE.md (--keep-queue)${c.reset}`);
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
console.log(`
|
|
1382
|
-
${c.green}${c.bold}Migration complete${c.reset}
|
|
1383
|
-
|
|
1384
|
-
${c.bold}What changed:${c.reset}
|
|
1385
|
-
- ${c.cyan}planning/TODO.md${c.reset} is now the single source of truth
|
|
1386
|
-
- Task IDs, source, description, acceptance criteria, and status are all inline
|
|
1387
|
-
- Non-task content (context notes, diagrams, guidelines) preserved in Reference section
|
|
1388
|
-
- Build loop reads TODO.md instead of TASK_QUEUE.md
|
|
1389
|
-
${!keepQueue && fs.existsSync(path.join(planningDir, 'TASK_QUEUE.md.bak')) ? ` - Old TASK_QUEUE.md archived as TASK_QUEUE.md.bak
|
|
1390
|
-
` : ''}
|
|
1391
|
-
${c.bold}Next steps:${c.reset}
|
|
1392
|
-
Run ${c.cyan}bootspring build status${c.reset} to verify
|
|
1393
|
-
Run ${c.cyan}bootspring build next${c.reset} to continue building
|
|
1394
|
-
`);
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
/**
|
|
1398
|
-
* Show help
|
|
1399
|
-
*/
|
|
1400
|
-
function showHelp() {
|
|
1401
|
-
console.log(`
|
|
1402
|
-
${c.cyan}${c.bold}Bootspring Build${c.reset}
|
|
1403
|
-
${c.dim}Task-driven build system for Claude Code${c.reset}
|
|
1404
|
-
|
|
1405
|
-
${c.bold}Quick Start:${c.reset}
|
|
1406
|
-
${c.cyan}bootspring build next${c.reset} Get next task and start building
|
|
1407
|
-
|
|
1408
|
-
${c.bold}Workflow:${c.reset}
|
|
1409
|
-
1. Run ${c.cyan}bootspring build next${c.reset} to get the next task
|
|
1410
|
-
2. Implement the task in your codebase
|
|
1411
|
-
3. Run ${c.cyan}bootspring build done${c.reset} when complete
|
|
1412
|
-
4. Repeat until MVP is complete
|
|
1413
|
-
|
|
1414
|
-
${c.bold}Commands:${c.reset}
|
|
1415
|
-
${c.cyan}bootspring build${c.reset} Start interactive build
|
|
1416
|
-
${c.cyan}bootspring build next${c.reset} Get next task (start here!)
|
|
1417
|
-
${c.cyan}bootspring build done${c.reset} Mark current task complete
|
|
1418
|
-
${c.cyan}bootspring build loop${c.reset} Start autonomous loop (commit+push each task)
|
|
1419
|
-
${c.cyan}bootspring build skip${c.reset} Skip current task
|
|
1420
|
-
${c.cyan}bootspring build stop${c.reset} Graceful stop (finish current task, then pause)
|
|
1421
|
-
${c.cyan}bootspring build status${c.reset} View detailed progress
|
|
1422
|
-
${c.cyan}bootspring build task${c.reset} View current task details
|
|
1423
|
-
${c.cyan}bootspring build plan${c.reset} View the full master plan
|
|
1424
|
-
${c.cyan}bootspring build migrate-todo${c.reset} Migrate TASK_QUEUE.md → TODO.md (single source of truth)
|
|
1425
|
-
${c.cyan}bootspring build backfill${c.reset} Recover preseed + SEED + TASK_QUEUE artifacts
|
|
1426
|
-
${c.cyan}bootspring build reset${c.reset} Start over
|
|
1427
|
-
|
|
1428
|
-
${c.bold}Loop Options:${c.reset}
|
|
1429
|
-
${c.cyan}bootspring build loop${c.reset} Commit + push after each task
|
|
1430
|
-
${c.cyan}bootspring build loop --no-push${c.reset} Commit only (no push)
|
|
1431
|
-
${c.cyan}bootspring build loop --no-commit${c.reset} No git operations
|
|
1432
|
-
|
|
1433
|
-
${c.bold}Other Options:${c.reset}
|
|
1434
|
-
--prompt Show AI prompt for current task
|
|
1435
|
-
--force Force reset even if in progress
|
|
1436
|
-
--quick With backfill: skip deep codebase analysis
|
|
1437
|
-
--interactive With backfill: allow follow-up prompts
|
|
1438
|
-
--no-onboard With backfill: skip onboard-assisted detection
|
|
1439
|
-
`);
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
module.exports = { run };
|