speccrew 0.7.58 → 0.7.59

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.
@@ -36,7 +36,10 @@ Phase 4: Generate DESIGN-OVERVIEW.md (WORKER-DISPATCH + HARD STOP)
36
36
 
37
37
  Phase 5: Dispatch Per-Platform Skills
38
38
  ├── Single Feature + Single Platform → Direct skill invocation
39
- └── Multi-Feature or Multi-Platform → Worker dispatch (batch of 6)
39
+ └── Multi-Feature or Multi-Platform → Worker dispatch (batch of 6, skip_confirmation + skip_index_generation)
40
+
41
+ Phase 5.5: Generate Platform INDEX.md (AGENT-OWNED)
42
+ └── Orchestrator generates INDEX.md per platform after all workers complete
40
43
 
41
44
  Phase 6: Joint Confirmation (HARD STOP)
42
45
  └── Present all designs → User confirms → Finalize stage
@@ -59,6 +62,7 @@ This agent is an **orchestrator/dispatcher**. For system design execution (Phase
59
62
  This agent MAY directly create/modify ONLY the following files:
60
63
  - ✅ `DISPATCH-PROGRESS.json` (via update-progress.js script only)
61
64
  - ✅ `.checkpoints.json` (via update-progress.js script only)
65
+ - ✅ `INDEX.md` per platform directory (AGENT-OWNED — generated by orchestrator after all workers complete, NOT by workers in batch mode)
62
66
  - ✅ Progress summary messages to user
63
67
 
64
68
  > Note: `framework-evaluation.md` is generated **ONLY** by the `speccrew-sd-framework-evaluate` skill.
@@ -74,7 +78,7 @@ This agent MAY directly create/modify ONLY the following files:
74
78
  3. ❌ DO NOT invoke `speccrew-sd-mobile` skill directly
75
79
  4. ❌ DO NOT invoke `speccrew-sd-desktop` skill directly
76
80
  5. ❌ DO NOT generate `*-design.md` files yourself
77
- 6. ❌ DO NOT generate platform `INDEX.md` files yourself
81
+ 6. ❌ DO NOT let individual workers generate platform `INDEX.md` in batch mode — orchestrator generates INDEX.md in Phase 5.5 (AGENT-OWNED)
78
82
  7. ❌ DO NOT create design document content as fallback if worker fails
79
83
 
80
84
  ### Violation Recovery
@@ -128,6 +132,8 @@ This agent MUST execute tasks continuously without unnecessary interruptions.
128
132
  | Phase 3 | HARD STOP | User must confirm framework decisions before proceeding to Phase 4 |
129
133
  | Phase 4 | WORKER-DISPATCH + HARD STOP | DESIGN-OVERVIEW.md generation MUST be dispatched to speccrew-task-worker via **Agent tool**. After worker completes, present summary to user and WAIT for confirmation before Phase 5. |
130
134
  | Phase 5 | SKILL-ONLY | Platform design workers MUST use platform-specific design skills. Agent MUST NOT write design documents itself |
135
+ | Phase 5 | SKIP-CONFIRMATION | Batch dispatch MUST include `skip_confirmation: true` and `skip_index_generation: true` in worker context. Workers skip Checkpoint A and Step 5 in batch mode |
136
+ | Phase 5.5 | AGENT-OWNED-INDEX | After all workers complete, orchestrator generates INDEX.md per platform. Workers MUST NOT generate INDEX.md in batch mode |
131
137
  | Phase 6 | HARD STOP | User must confirm all designs before finalizing |
132
138
  | ALL | ABORT ON FAILURE | If any skill invocation fails → STOP and report. Do NOT generate content manually as fallback |
133
139
  | ALL | SCRIPT ENFORCEMENT | All .checkpoints.json and WORKFLOW-PROGRESS.json updates via update-progress.js script. Manual JSON creation FORBIDDEN |
@@ -790,15 +796,17 @@ All workers execute simultaneously to maximize efficiency.
790
796
  > 1. **ONE Worker per Feature×Platform combination** — DO NOT group
791
797
  > 2. Use **Agent tool** to create `speccrew-task-worker` for each task
792
798
  > 3. Pass `skill_path`: `${ide_skills_dir}/${skill_name}/SKILL.md` (platform-specific skill)
793
- > 4. Pass context: task_id, feature_id, feature_name, platform_id, feature_spec_path, api_contract_path, techs_knowledge_paths, framework_decisions, output_base_path
799
+ > 4. Pass context: task_id, feature_id, feature_name, platform_id, feature_spec_path, api_contract_path, techs_knowledge_paths, framework_decisions, output_base_path, **skip_confirmation: true**, **skip_index_generation: true**
794
800
  > 5. Dispatch ALL Workers in the same batch **SIMULTANEOUSLY** in a single turn
795
801
  > 6. **Wait** for ALL Workers in the batch to complete before dispatching next batch
796
802
  > 7. Update DISPATCH-PROGRESS.json after each Worker completes
803
+ > 8. After ALL workers complete, generate INDEX.md for each platform directory (AGENT-OWNED task — see Phase 5.5 in orchestration SKILL.md)
797
804
  > **FORBIDDEN**:
798
805
  > - ❌ DO NOT group multiple features into one Worker
799
806
  > - ❌ DO NOT use Skill tool to invoke platform skills (when Features ≥ 2 OR Platforms ≥ 2)
800
807
  > - ❌ DO NOT dispatch Workers sequentially — ALL in same batch must be simultaneous
801
808
  > - ❌ DO NOT generate *-design.md files yourself as fallback
809
+ > - ❌ DO NOT let individual workers generate INDEX.md in batch mode — set `skip_index_generation: true`; orchestrator generates INDEX.md after all workers complete
802
810
 
803
811
  ### 5.5 Update DISPATCH-PROGRESS.json
804
812
 
@@ -1088,6 +1096,7 @@ Otherwise
1088
1096
  - DO NOT create or manually edit DISPATCH-PROGRESS.json, .checkpoints.json, or WORKFLOW-PROGRESS.json — use update-progress.js script only
1089
1097
  - DO NOT update WORKFLOW-PROGRESS.json status to "confirmed" before joint user confirmation in Phase 6
1090
1098
  - DO NOT proceed to the next batch or Phase 6 if any Phase 5 batch worker failure rate > 50% — follow the Batch Failure recovery flow in Phase 5.6
1099
+ - DO NOT let individual workers generate INDEX.md in batch mode — set `skip_index_generation: true` in worker context; orchestrator generates INDEX.md in Phase 5.5 (AGENT-OWNED)
1091
1100
  - DO NOT skip backward compatibility checks for old format Feature Specs
1092
1101
  - DO NOT automatically transition to or invoke the next stage agent — user starts next stage in a new conversation
1093
1102
 
@@ -34,6 +34,8 @@ tools: Read, Write, Glob, Grep
34
34
  - `feature_id` (optional): Feature identifier, e.g., `F-CRM-01`. If provided, use new naming format.
35
35
  - `feature_name`: Feature name, e.g., `customer-list`.
36
36
  - `platform_id`: Target platform, e.g., `backend-spring`, `backend-nestjs`.
37
+ - `skip_confirmation` (optional, boolean): When `true`, skip Checkpoint A user confirmation (used in batch dispatch mode)
38
+ - `skip_index_generation` (optional, boolean): When `true`, skip Step 5 INDEX.md generation (INDEX.md will be generated by orchestrator after all workers complete)
37
39
 
38
40
  Read in order:
39
41
 
@@ -88,7 +90,11 @@ Mark each function as:
88
90
  | `[MODIFIED]` | Modify existing implementation |
89
91
  | `[NEW]` | Create brand new implementation |
90
92
 
91
- **Checkpoint A: Present function list with markers to user for confirmation before proceeding.**
93
+ **Checkpoint A**:
94
+ - If `skip_confirmation` = `true`: Log the function list with markers and **proceed automatically** without waiting for user confirmation.
95
+ - If `skip_confirmation` is not set or `false`: Present function list with markers to user and **wait for explicit confirmation** before proceeding.
96
+
97
+ > ⚠️ **FORBIDDEN**: Worker MUST NOT self-decide to skip confirmation. Only the `skip_confirmation` parameter from dispatch context controls this behavior.
92
98
 
93
99
  ## Step 4: Generate Module Design Documents
94
100
 
@@ -160,6 +166,8 @@ Verify the completed design document:
160
166
 
161
167
  ## Step 5: Generate Platform INDEX.md
162
168
 
169
+ > **Conditional Execution**: If `skip_index_generation` = `true`, **skip this entire Step 5** and proceed to completion. INDEX.md will be generated by the orchestrator after all platform workers complete.
170
+
163
171
  After all module designs are complete:
164
172
 
165
173
  ### 5.1 Read Index Template
@@ -311,7 +319,7 @@ When generating Mermaid diagrams, follow compatibility guidelines:
311
319
  - [ ] Feature Spec and API Contract read and understood
312
320
  - [ ] Existing codebase structure analyzed (Glob/Grep)
313
321
  - [ ] Function extraction completed with [EXISTING]/[MODIFIED]/[NEW] markers
314
- - [ ] Checkpoint A passed: function list confirmed with user
322
+ - [ ] Checkpoint A passed: function list confirmed (or skipped via skip_confirmation)
315
323
  - [ ] Every API in API Contract has a corresponding implementation design
316
324
  - [ ] Database entities cover all data requirements from Feature Spec
317
325
  - [ ] Transaction boundaries defined for multi-step operations
@@ -34,6 +34,8 @@ tools: Read, Write, Glob, Grep
34
34
  - `feature_id` (optional): Feature identifier, e.g., `F-CRM-01`. If provided, use new naming format.
35
35
  - `feature_name`: Feature name, e.g., `customer-list`.
36
36
  - `platform_id`: Target platform, e.g., `frontend-vue`, `frontend-react`.
37
+ - `skip_confirmation` (optional, boolean): When `true`, skip Checkpoint A user confirmation (used in batch dispatch mode)
38
+ - `skip_index_generation` (optional, boolean): When `true`, skip Step 5 INDEX.md generation (INDEX.md will be generated by orchestrator after all workers complete)
37
39
 
38
40
  Read in order:
39
41
 
@@ -86,7 +88,11 @@ Mark each function's components as:
86
88
  | `[MODIFIED]` | Enhance/change existing | `[MODIFIED] OrderTable - add new column` |
87
89
  | `[NEW]` | Create brand new | `[NEW] ProductDetailDrawer` |
88
90
 
89
- **Checkpoint A: Present function extraction summary to user for confirmation.**
91
+ **Checkpoint A**:
92
+ - If `skip_confirmation` = `true`: Log the function extraction summary and **proceed automatically** without waiting for user confirmation.
93
+ - If `skip_confirmation` is not set or `false`: Present function extraction summary to user and **wait for explicit confirmation** before proceeding.
94
+
95
+ > ⚠️ **FORBIDDEN**: Worker MUST NOT self-decide to skip confirmation. Only the `skip_confirmation` parameter from dispatch context controls this behavior.
90
96
 
91
97
  ## Step 4: Generate Module Design Documents
92
98
 
@@ -143,6 +149,8 @@ Verify the completed design document:
143
149
 
144
150
  ## Step 5: Generate Platform INDEX.md
145
151
 
152
+ > **Conditional Execution**: If `skip_index_generation` = `true`, **skip this entire Step 5** and proceed to completion. INDEX.md will be generated by the orchestrator after all platform workers complete.
153
+
146
154
  After all module designs are complete:
147
155
 
148
156
  ### 5.1 Read Template
@@ -286,7 +294,7 @@ After completing all steps, output a structured completion report for the System
286
294
  - [ ] Directory structure follows conventions-design.md
287
295
  - [ ] INDEX.md generated with complete module list
288
296
  - [ ] All files written to correct paths under 03.system-design/{platform_id}/
289
- - [ ] Checkpoint A passed: function extraction confirmed with user
297
+ - [ ] Checkpoint A passed: function extraction confirmed (or skipped via skip_confirmation)
290
298
  - [ ] **No TODO/FIXME placeholders** — all components and methods have complete pseudocode
291
299
  - [ ] **API routes match API Contract exactly** — verified route-by-route
292
300
  - [ ] **Cross-Feature dependencies explicitly marked** — all `[DEPENDENCY: F-XXX-NNN]` tags present with degradation strategy
@@ -30,6 +30,13 @@ tools: Read, Write, Glob, Grep
30
30
 
31
31
  ## Step 1: Read Inputs
32
32
 
33
+ **Input Parameters** (from agent context):
34
+ - `feature_id` (optional): Feature identifier, e.g., `F-CRM-01`.
35
+ - `feature_name`: Feature name, e.g., `customer-list`.
36
+ - `platform_id`: Target platform, e.g., `mobile-uniapp`, `mobile-flutter`.
37
+ - `skip_confirmation` (optional, boolean): When `true`, skip Checkpoint A user confirmation (used in batch dispatch mode)
38
+ - `skip_index_generation` (optional, boolean): When `true`, skip Step 5 INDEX.md generation (INDEX.md will be generated by orchestrator after all workers complete)
39
+
33
40
  Read in order:
34
41
 
35
42
  1. **Feature Spec document(s)**: `speccrew-workspace/iterations/{number}-{type}-{name}/02.feature-design/[feature-name]-feature-spec.md`
@@ -80,7 +87,11 @@ Mark each function's screens/widgets as:
80
87
  | `[MODIFIED]` | Enhance/change existing | `[MODIFIED] OrderList - add pull-to-refresh` |
81
88
  | `[NEW]` | Create brand new | `[NEW] ProductDetailPage` |
82
89
 
83
- **Checkpoint A: Present function extraction summary to user for confirmation.**
90
+ **Checkpoint A**:
91
+ - If `skip_confirmation` = `true`: Log the function extraction summary and **proceed automatically** without waiting for user confirmation.
92
+ - If `skip_confirmation` is not set or `false`: Present function extraction summary to user and **wait for explicit confirmation** before proceeding.
93
+
94
+ > ⚠️ **FORBIDDEN**: Worker MUST NOT self-decide to skip confirmation. Only the `skip_confirmation` parameter from dispatch context controls this behavior.
84
95
 
85
96
  ## Step 4: Generate Module Design Documents
86
97
 
@@ -136,6 +147,8 @@ Verify the completed design document:
136
147
 
137
148
  ## Step 5: Generate Platform INDEX.md
138
149
 
150
+ > **Conditional Execution**: If `skip_index_generation` = `true`, **skip this entire Step 5** and proceed to completion. INDEX.md will be generated by the orchestrator after all platform workers complete.
151
+
139
152
  After all module designs are complete:
140
153
 
141
154
  ### 5.1 Read Template
@@ -279,7 +292,7 @@ After completing all steps, output a structured completion report for the System
279
292
  - [ ] App lifecycle handling documented
280
293
  - [ ] INDEX.md generated with complete module list
281
294
  - [ ] All files written to correct paths under 03.system-design/{platform_id}/
282
- - [ ] **Checkpoint A passed**: function extraction confirmed with user
295
+ - [ ] **Checkpoint A passed**: function extraction confirmed (or skipped via skip_confirmation)
283
296
  - [ ] **No TODO/FIXME placeholders** — all screens and methods have complete pseudocode
284
297
  - [ ] **API routes match API Contract exactly** — verified route-by-route
285
298
  - [ ] **Cross-Feature dependencies explicitly marked** — all `[DEPENDENCY: F-XXX-NNN]` tags present with degradation strategy
@@ -130,14 +130,34 @@ This skill MUST execute tasks continuously without unnecessary interruptions.
130
130
  4. Compute batch plan (batch size = 6)
131
131
  5. For each batch:
132
132
  a. Use **Agent tool** to create `speccrew-task-worker` agents for ALL tasks in the batch **SIMULTANEOUSLY**
133
- b. Each Worker receives: `skill_path` (platform-specific skill), `task_id`, `feature_id`, `feature_name`, `platform_id`, `feature_spec_path`, `api_contract_path`, `techs_knowledge_paths`, `framework_decisions`, `output_base_path`
133
+ b. Each Worker receives: `skill_path` (platform-specific skill), `task_id`, `feature_id`, `feature_name`, `platform_id`, `feature_spec_path`, `api_contract_path`, `techs_knowledge_paths`, `framework_decisions`, `output_base_path`, `skip_confirmation: true`, `skip_index_generation: true`
134
134
  c. **Wait** for ALL Workers in the batch to complete
135
135
  d. Update DISPATCH-PROGRESS.json for each completed Worker
136
136
  e. Log batch progress
137
137
  6. After all batches complete, read final progress summary
138
+ 7. Generate INDEX.md for each platform (AGENT-OWNED, see Phase 5.5)
138
139
 
139
140
  **CRITICAL**: Each Worker handles exactly ONE feature on ONE platform. DO NOT group multiple features or platforms into a single Worker.
140
141
 
142
+ **Batch Dispatch Context Parameters**: When dispatching Workers in batch mode, the following parameters MUST be included in each Worker's context:
143
+ - `skip_confirmation: true` — Workers skip Checkpoint A user confirmation (not feasible in batch mode)
144
+ - `skip_index_generation: true` — Workers skip Step 5 INDEX.md generation (INDEX.md will be generated by orchestrator after all workers complete)
145
+
146
+ ### Phase 5.5: INDEX.md Generation (AGENT-OWNED)
147
+
148
+ After ALL Feature×Platform workers complete successfully, the orchestrator generates INDEX.md for each platform directory. This is an AGENT-OWNED task — the orchestrator generates INDEX.md directly, NOT by dispatching a worker.
149
+
150
+ **Steps per platform**:
151
+ 1. Read INDEX-TEMPLATE.md from techs knowledge templates
152
+ 2. Copy template to `{output_dir}/{platform_id}/INDEX.md`
153
+ 3. Fill sections using `search_replace` with actual content from:
154
+ - Tech stack summary from techs knowledge
155
+ - Module list table from completed design documents
156
+ - Shared design decisions from architecture knowledge
157
+ 4. Verify all placeholders are replaced
158
+
159
+ **FORBIDDEN**: Dispatching a worker for INDEX.md generation. INDEX.md is a summary/aggregation file that the orchestrator creates by reading completed worker outputs.
160
+
141
161
  **Example** (5 features × 3 platforms = 15 workers, 3 batches of 6/6/3):
142
162
  - Batch 1: Workers 1-6 (parallel)
143
163
  - Batch 2: Workers 7-12 (parallel, after batch 1 completes)
@@ -148,6 +168,7 @@ This skill MUST execute tasks continuously without unnecessary interruptions.
148
168
  This workflow has **mandatory HARD STOP** checkpoints at:
149
169
  - **Phase 3.5**: Framework evaluation confirmation (user MUST approve framework decisions)
150
170
  - **Phase 4.5**: Design overview confirmation (user MUST approve DESIGN-OVERVIEW.md before Phase 5 dispatch)
171
+ - **Phase 5.5**: (No HARD STOP — INDEX.md generation is automatic after all workers complete)
151
172
  - **Phase 6.1**: Joint design confirmation (user MUST approve all designs)
152
173
 
153
174
  DO NOT proceed past these checkpoints without explicit user confirmation.
@@ -168,6 +189,7 @@ DO NOT proceed past these checkpoints without explicit user confirmation.
168
189
  - **DO NOT generate framework-evaluation.md yourself** — Only workers generate it
169
190
  - **DO NOT create scripts for batch analysis** — Workers handle this via their own skill
170
191
  - **DO NOT fallback to inline execution if worker fails** — ABORT instead
192
+ - **DO NOT let individual workers generate INDEX.md in batch mode** — `skip_index_generation: true` must be set; orchestrator generates INDEX.md after all workers complete
171
193
  - **DO NOT skip reading workflow.agentflow.xml** — XML is the execution authority
172
194
  - **DO NOT generate DESIGN-OVERVIEW.md yourself** — Dispatch speccrew-task-worker with speccrew-sd-design-overview-generate skill
173
195
  - **DO NOT use Skill tool for Phase 4 design overview generation** — Skill tool executes inline, Agent tool creates a worker
@@ -389,7 +389,9 @@
389
389
  api_contract_path: ${task.api_contract_path},
390
390
  techs_knowledge_paths: ${task.techs_knowledge_paths},
391
391
  framework_decisions: ${framework_result.decisions},
392
- output_base_path: ${iterations_dir}/${current_iteration}/03.system-design
392
+ output_base_path: ${iterations_dir}/${current_iteration}/03.system-design,
393
+ skip_confirmation: true,
394
+ skip_index_generation: true
393
395
  </field>
394
396
  <field name="output" var="worker_result_${task.id}"/>
395
397
  </block>
@@ -421,6 +423,34 @@
421
423
  </branch>
422
424
  </block>
423
425
 
426
+ <!-- batch-update is available via: node update-progress.js batch-update --file <progress.json> --tasks-file <tasks.json> -->
427
+ <!-- Use when orchestrator needs to batch-update multiple task statuses at once -->
428
+
429
+ <!-- Phase 5.5: Generate Platform INDEX.md (AGENT-OWNED) -->
430
+ <block type="rule" id="P5-IDX-R1" level="mandatory" desc="INDEX.md Generation - Agent Owned">
431
+ <field name="text">
432
+ After all workers complete, the orchestrator generates INDEX.md for each platform.
433
+ Steps per platform:
434
+ 1. Read INDEX-TEMPLATE.md from techs knowledge templates
435
+ 2. Copy template to {output_dir}/{platform_id}/INDEX.md
436
+ 3. Fill sections using search_replace with actual content from:
437
+ - Tech stack summary from techs knowledge
438
+ - Module list table from completed design documents
439
+ - Shared design decisions from architecture knowledge
440
+ 4. Verify all placeholders are replaced
441
+ FORBIDDEN: Dispatching a worker for INDEX.md generation.
442
+ </field>
443
+ </block>
444
+ <block type="loop" id="P5-IDX-L1" over="${platforms}" as="platform">
445
+ <block type="task" id="P5-IDX-B1" action="write-file" status="pending"
446
+ desc="Generate INDEX.md for ${platform.id}">
447
+ <field name="template_source">${techs_knowledge_dir}/${platform.id}/templates/INDEX-TEMPLATE.md</field>
448
+ <field name="output">${iterations_dir}/${current_iteration}/03.system-design/${platform.id}/INDEX.md</field>
449
+ <field name="fill_method">search_replace per section</field>
450
+ <field name="module_list_source">${platform.completed_documents}</field>
451
+ </block>
452
+ </block>
453
+
424
454
  <!-- Step 5.5: Read final dispatch progress -->
425
455
  <block type="task" id="P5-B5" action="run-script" status="pending"
426
456
  desc="Read final dispatch progress summary">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speccrew",
3
- "version": "0.7.58",
3
+ "version": "0.7.59",
4
4
  "description": "Spec-Driven Development toolkit for AI-powered IDEs",
5
5
  "author": "charlesmu99",
6
6
  "repository": {
@@ -65,7 +65,14 @@
65
65
  * --features-dir <dir> Directory containing features-*.json files (required)
66
66
  * --force Overwrite existing file
67
67
  *
68
- * 8. sync - Sync task status with actual output files
68
+ * 8. batch-update - Batch update multiple task statuses from a JSON file
69
+ * node update-progress.js batch-update --file <path> --tasks-file <path>
70
+ * Options:
71
+ * --file <path> Progress file path (required)
72
+ * --tasks-file <path> JSON file with task updates (required)
73
+ * Format: [{"id": "task-id", "status": "completed", ...}]
74
+ *
75
+ * 9. sync - Sync task status with actual output files
69
76
  * node update-progress.js sync --file <path> --dir <dir> --suffix <suffix> [--strict]
70
77
  * Options:
71
78
  * --file <path> Progress file path (required)
@@ -1146,6 +1153,152 @@ function cmdInitKnowledgeTasks(args) {
1146
1153
  }
1147
1154
  }
1148
1155
 
1156
+ /**
1157
+ * Command: batch-update - Batch update multiple task statuses from a JSON file
1158
+ *
1159
+ * Reads a list of task updates from a JSON file and applies them to the progress file.
1160
+ * This avoids long command lines that can crash PSReadLine.
1161
+ *
1162
+ * Tasks file format:
1163
+ * [
1164
+ * {"id": "task-1", "status": "completed"},
1165
+ * {"id": "task-2", "status": "failed", "error": "error message"},
1166
+ * {"id": "task-3", "status": "completed", "output": "result info"}
1167
+ * ]
1168
+ */
1169
+ function cmdBatchUpdate(args) {
1170
+ if (!args.file || !args.tasksFile) {
1171
+ outputError('Usage: batch-update --file <path> --tasks-file <path>');
1172
+ }
1173
+
1174
+ const filePath = path.resolve(args.file);
1175
+ const tasksFilePath = path.resolve(args.tasksFile);
1176
+
1177
+ // Read tasks file
1178
+ let updates;
1179
+ try {
1180
+ updates = readJsonFile(tasksFilePath);
1181
+ } catch (e) {
1182
+ outputError(`Failed to read tasks file: ${e.message}`);
1183
+ }
1184
+
1185
+ // Validate updates is an array
1186
+ if (!Array.isArray(updates)) {
1187
+ outputError('Tasks file must contain a JSON array of task updates');
1188
+ }
1189
+
1190
+ if (updates.length === 0) {
1191
+ outputError('Tasks file is empty — no updates to apply');
1192
+ }
1193
+
1194
+ // Validate each update entry
1195
+ const validStatuses = ['pending', 'in_progress', 'partial', 'completed', 'failed', 'confirmed'];
1196
+ for (let i = 0; i < updates.length; i++) {
1197
+ if (!updates[i].id) {
1198
+ outputError(`Update entry at index ${i} is missing required "id" field`);
1199
+ }
1200
+ if (!updates[i].status) {
1201
+ outputError(`Update entry at index ${i} (id: ${updates[i].id}) is missing required "status" field`);
1202
+ }
1203
+ if (!validStatuses.includes(updates[i].status)) {
1204
+ outputError(`Invalid status "${updates[i].status}" for task ${updates[i].id}. Must be one of: ${validStatuses.join(', ')}`);
1205
+ }
1206
+ }
1207
+
1208
+ let lockPath = null;
1209
+ try {
1210
+ lockPath = acquireLock(filePath);
1211
+ const data = readJsonFile(filePath);
1212
+
1213
+ const now = getTimestamp();
1214
+ let updated = 0;
1215
+ let notFound = 0;
1216
+ let skipped = 0;
1217
+ const notFoundIds = [];
1218
+
1219
+ // Build a lookup map for tasks (support both flat and nested structures)
1220
+ // Flat structure: data.tasks array
1221
+ if (data.tasks && Array.isArray(data.tasks)) {
1222
+ for (const update of updates) {
1223
+ const taskIndex = data.tasks.findIndex(t => t.id === update.id);
1224
+ if (taskIndex === -1) {
1225
+ notFound++;
1226
+ notFoundIds.push(update.id);
1227
+ continue;
1228
+ }
1229
+
1230
+ const task = data.tasks[taskIndex];
1231
+
1232
+ // Skip if already in target status
1233
+ if (task.status === update.status) {
1234
+ skipped++;
1235
+ continue;
1236
+ }
1237
+
1238
+ // Apply status update
1239
+ task.status = update.status;
1240
+ task.updated_at = now;
1241
+
1242
+ // Set timestamps based on status
1243
+ if (update.status === 'in_progress') {
1244
+ task.started_at = now;
1245
+ } else if (update.status === 'completed') {
1246
+ task.completed_at = now;
1247
+ if (update.output) {
1248
+ task.output = update.output;
1249
+ }
1250
+ } else if (update.status === 'confirmed') {
1251
+ task.confirmed_at = now;
1252
+ } else if (update.status === 'failed') {
1253
+ task.completed_at = now;
1254
+ if (update.error) {
1255
+ task.error = update.error;
1256
+ }
1257
+ if (update.error_category) {
1258
+ task.error_category = update.error_category;
1259
+ }
1260
+ } else if (update.status === 'partial') {
1261
+ if (!task.started_at) {
1262
+ task.started_at = now;
1263
+ }
1264
+ if (update.output) {
1265
+ task.output = update.output;
1266
+ }
1267
+ }
1268
+
1269
+ updated++;
1270
+ }
1271
+
1272
+ // Recalculate counts
1273
+ data.counts = calculateCounts(data.tasks);
1274
+ } else {
1275
+ // No flat tasks array — cannot batch update
1276
+ outputError('Progress file does not contain a tasks array — batch-update only supports flat task structure');
1277
+ }
1278
+
1279
+ data.updated_at = now;
1280
+
1281
+ // Atomic write
1282
+ atomicWriteJson(filePath, data);
1283
+
1284
+ const result = {
1285
+ total_updates_requested: updates.length,
1286
+ updated: updated,
1287
+ skipped_already_current: skipped,
1288
+ not_found: notFound,
1289
+ counts: data.counts
1290
+ };
1291
+
1292
+ if (notFoundIds.length > 0) {
1293
+ result.not_found_ids = notFoundIds;
1294
+ }
1295
+
1296
+ outputSuccess(`Batch update completed: ${updated} tasks updated, ${skipped} skipped, ${notFound} not found`, result);
1297
+ } finally {
1298
+ if (lockPath) releaseLock(lockPath);
1299
+ }
1300
+ }
1301
+
1149
1302
  /**
1150
1303
  * Command: sync - Sync task status with actual output files
1151
1304
  * Scans directory for files matching suffix, extracts task IDs from filenames,
@@ -1494,6 +1647,7 @@ function main() {
1494
1647
  console.error(' update-workflow Update a workflow stage status');
1495
1648
  console.error(' init-tasks Generate tasks from feature-spec files');
1496
1649
  console.error(' init-knowledge-tasks Generate knowledge initialization tasks from matcher results');
1650
+ console.error(' batch-update Batch update multiple task statuses from a JSON file');
1497
1651
  console.error(' sync Sync task status with actual output files');
1498
1652
  console.error('');
1499
1653
  console.error('Run "node update-progress.js <command> --help" for more information.');
@@ -1527,6 +1681,9 @@ function main() {
1527
1681
  case 'init-knowledge-tasks':
1528
1682
  cmdInitKnowledgeTasks(args);
1529
1683
  break;
1684
+ case 'batch-update':
1685
+ cmdBatchUpdate(args);
1686
+ break;
1530
1687
  case 'sync':
1531
1688
  cmdSync(args);
1532
1689
  break;