* Auto-generate task commands for all existing specs
()
| 283 | * Auto-generate task commands for all existing specs |
| 284 | */ |
| 285 | async autoGenerateTaskCommands(): Promise<void> { |
| 286 | try { |
| 287 | // Check if specs directory exists |
| 288 | await fs.access(this.specsDir); |
| 289 | } catch { |
| 290 | // No specs directory, nothing to generate |
| 291 | return; |
| 292 | } |
| 293 | |
| 294 | try { |
| 295 | const specsEntries = await fs.readdir(this.specsDir, { withFileTypes: true }); |
| 296 | const specDirs = specsEntries |
| 297 | .filter(entry => entry.isDirectory()) |
| 298 | .map(entry => entry.name); |
| 299 | |
| 300 | if (specDirs.length === 0) { |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | console.log(`Auto-generating task commands for ${specDirs.length} existing spec(s)...`); |
| 305 | |
| 306 | for (const specName of specDirs) { |
| 307 | const tasksFile = join(this.specsDir, specName, 'tasks.md'); |
| 308 | const commandsSpecDir = join(this.commandsDir, specName); |
| 309 | |
| 310 | try { |
| 311 | // Check if tasks.md exists |
| 312 | await fs.access(tasksFile); |
| 313 | |
| 314 | // Read tasks.md |
| 315 | const tasksContent = await fs.readFile(tasksFile, 'utf8'); |
| 316 | |
| 317 | // Parse tasks and generate commands |
| 318 | const tasks = parseTasksFromMarkdown(tasksContent); |
| 319 | |
| 320 | if (tasks.length === 0) { |
| 321 | continue; |
| 322 | } |
| 323 | |
| 324 | // Delete existing task commands for this spec |
| 325 | try { |
| 326 | await fs.rm(commandsSpecDir, { recursive: true }); |
| 327 | } catch { |
| 328 | // Directory might not exist |
| 329 | } |
| 330 | |
| 331 | // Create spec commands directory |
| 332 | await fs.mkdir(commandsSpecDir, { recursive: true }); |
| 333 | |
| 334 | // Generate commands |
| 335 | for (const task of tasks) { |
| 336 | await generateTaskCommand(commandsSpecDir, specName, task); |
| 337 | } |
| 338 | |
| 339 | console.log(` Generated ${tasks.length} task commands for spec: ${specName}`); |
| 340 | |
| 341 | } catch { |
| 342 | // tasks.md doesn't exist for this spec, skip |
no test coverage detected