speccrew 0.7.58 → 0.7.60

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 (WORKER-DISPATCH)
42
+ └── Dispatch worker per platform with index_only=true to generate INDEX.md
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 (generated by worker dispatched with `index_only: true` after all Feature×Platform workers complete)
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 generate INDEX.md directly — MUST dispatch worker with `index_only: true` in Phase 5.5 (WORKER-DISPATCH)
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 | WORKER-DISPATCH-INDEX | After all workers complete, dispatch ONE worker per platform with `index_only: true` to generate INDEX.md. Orchestrator MUST NOT generate INDEX.md directly |
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, dispatch ONE worker per platform with `index_only: true` to generate INDEX.md (WORKER-DISPATCH — 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`; INDEX.md is generated in Phase 5.5 by separate worker with `index_only: true`
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 generate INDEX.md directly — set `skip_index_generation: true` in Feature×Platform worker context; dispatch separate worker with `index_only: true` in Phase 5.5 (WORKER-DISPATCH)
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
 
@@ -30,10 +30,15 @@ tools: Read, Write, Glob, Grep
30
30
 
31
31
  ## Step 1: Read Inputs
32
32
 
33
+ > **Conditional Execution**: If `index_only` = `true`, **skip Steps 1-4** and jump directly to Step 5 to generate INDEX.md.
34
+
33
35
  **Input Parameters** (from agent context):
34
36
  - `feature_id` (optional): Feature identifier, e.g., `F-CRM-01`. If provided, use new naming format.
35
37
  - `feature_name`: Feature name, e.g., `customer-list`.
36
38
  - `platform_id`: Target platform, e.g., `backend-spring`, `backend-nestjs`.
39
+ - `skip_confirmation` (optional, boolean): When `true`, skip Checkpoint A user confirmation (used in batch dispatch mode)
40
+ - `skip_index_generation` (optional, boolean): When `true`, skip Step 5 INDEX.md generation (INDEX.md will be generated by orchestrator after all workers complete)
41
+ - `index_only` (optional, boolean): When `true`, skip Steps 1-4 and ONLY execute Step 5 (INDEX.md generation). Used after all platform workers complete.
37
42
 
38
43
  Read in order:
39
44
 
@@ -88,7 +93,11 @@ Mark each function as:
88
93
  | `[MODIFIED]` | Modify existing implementation |
89
94
  | `[NEW]` | Create brand new implementation |
90
95
 
91
- **Checkpoint A: Present function list with markers to user for confirmation before proceeding.**
96
+ **Checkpoint A**:
97
+ - If `skip_confirmation` = `true`: Log the function list with markers and **proceed automatically** without waiting for user confirmation.
98
+ - If `skip_confirmation` is not set or `false`: Present function list with markers to user and **wait for explicit confirmation** before proceeding.
99
+
100
+ > ⚠️ **FORBIDDEN**: Worker MUST NOT self-decide to skip confirmation. Only the `skip_confirmation` parameter from dispatch context controls this behavior.
92
101
 
93
102
  ## Step 4: Generate Module Design Documents
94
103
 
@@ -160,6 +169,10 @@ Verify the completed design document:
160
169
 
161
170
  ## Step 5: Generate Platform INDEX.md
162
171
 
172
+ > **Conditional Execution**:
173
+ > - If `skip_index_generation` = `true`, **skip this entire Step 5**.
174
+ > - If `index_only` = `true`, this step is the ONLY step to execute (Steps 1-4 are skipped).
175
+
163
176
  After all module designs are complete:
164
177
 
165
178
  ### 5.1 Read Index Template
@@ -311,7 +324,7 @@ When generating Mermaid diagrams, follow compatibility guidelines:
311
324
  - [ ] Feature Spec and API Contract read and understood
312
325
  - [ ] Existing codebase structure analyzed (Glob/Grep)
313
326
  - [ ] Function extraction completed with [EXISTING]/[MODIFIED]/[NEW] markers
314
- - [ ] Checkpoint A passed: function list confirmed with user
327
+ - [ ] Checkpoint A passed: function list confirmed (or skipped via skip_confirmation)
315
328
  - [ ] Every API in API Contract has a corresponding implementation design
316
329
  - [ ] Database entities cover all data requirements from Feature Spec
317
330
  - [ ] Transaction boundaries defined for multi-step operations
@@ -30,10 +30,15 @@ tools: Read, Write, Glob, Grep
30
30
 
31
31
  ## Step 1: Read Inputs
32
32
 
33
+ > **Conditional Execution**: If `index_only` = `true`, **skip Steps 1-4** and jump directly to Step 5 to generate INDEX.md.
34
+
33
35
  **Input Parameters** (from agent context):
34
36
  - `feature_id` (optional): Feature identifier, e.g., `F-CRM-01`. If provided, use new naming format.
35
37
  - `feature_name`: Feature name, e.g., `customer-list`.
36
38
  - `platform_id`: Target platform, e.g., `frontend-vue`, `frontend-react`.
39
+ - `skip_confirmation` (optional, boolean): When `true`, skip Checkpoint A user confirmation (used in batch dispatch mode)
40
+ - `skip_index_generation` (optional, boolean): When `true`, skip Step 5 INDEX.md generation (INDEX.md will be generated by orchestrator after all workers complete)
41
+ - `index_only` (optional, boolean): When `true`, skip Steps 1-4 and ONLY execute Step 5 (INDEX.md generation). Used after all platform workers complete.
37
42
 
38
43
  Read in order:
39
44
 
@@ -86,7 +91,11 @@ Mark each function's components as:
86
91
  | `[MODIFIED]` | Enhance/change existing | `[MODIFIED] OrderTable - add new column` |
87
92
  | `[NEW]` | Create brand new | `[NEW] ProductDetailDrawer` |
88
93
 
89
- **Checkpoint A: Present function extraction summary to user for confirmation.**
94
+ **Checkpoint A**:
95
+ - If `skip_confirmation` = `true`: Log the function extraction summary and **proceed automatically** without waiting for user confirmation.
96
+ - If `skip_confirmation` is not set or `false`: Present function extraction summary to user and **wait for explicit confirmation** before proceeding.
97
+
98
+ > ⚠️ **FORBIDDEN**: Worker MUST NOT self-decide to skip confirmation. Only the `skip_confirmation` parameter from dispatch context controls this behavior.
90
99
 
91
100
  ## Step 4: Generate Module Design Documents
92
101
 
@@ -143,6 +152,10 @@ Verify the completed design document:
143
152
 
144
153
  ## Step 5: Generate Platform INDEX.md
145
154
 
155
+ > **Conditional Execution**:
156
+ > - If `skip_index_generation` = `true`, **skip this entire Step 5**.
157
+ > - If `index_only` = `true`, this step is the ONLY step to execute (Steps 1-4 are skipped).
158
+
146
159
  After all module designs are complete:
147
160
 
148
161
  ### 5.1 Read Template
@@ -286,7 +299,7 @@ After completing all steps, output a structured completion report for the System
286
299
  - [ ] Directory structure follows conventions-design.md
287
300
  - [ ] INDEX.md generated with complete module list
288
301
  - [ ] All files written to correct paths under 03.system-design/{platform_id}/
289
- - [ ] Checkpoint A passed: function extraction confirmed with user
302
+ - [ ] Checkpoint A passed: function extraction confirmed (or skipped via skip_confirmation)
290
303
  - [ ] **No TODO/FIXME placeholders** — all components and methods have complete pseudocode
291
304
  - [ ] **API routes match API Contract exactly** — verified route-by-route
292
305
  - [ ] **Cross-Feature dependencies explicitly marked** — all `[DEPENDENCY: F-XXX-NNN]` tags present with degradation strategy
@@ -30,6 +30,16 @@ tools: Read, Write, Glob, Grep
30
30
 
31
31
  ## Step 1: Read Inputs
32
32
 
33
+ > **Conditional Execution**: If `index_only` = `true`, **skip Steps 1-4** and jump directly to Step 5 to generate INDEX.md.
34
+
35
+ **Input Parameters** (from agent context):
36
+ - `feature_id` (optional): Feature identifier, e.g., `F-CRM-01`.
37
+ - `feature_name`: Feature name, e.g., `customer-list`.
38
+ - `platform_id`: Target platform, e.g., `mobile-uniapp`, `mobile-flutter`.
39
+ - `skip_confirmation` (optional, boolean): When `true`, skip Checkpoint A user confirmation (used in batch dispatch mode)
40
+ - `skip_index_generation` (optional, boolean): When `true`, skip Step 5 INDEX.md generation (INDEX.md will be generated by orchestrator after all workers complete)
41
+ - `index_only` (optional, boolean): When `true`, skip Steps 1-4 and ONLY execute Step 5 (INDEX.md generation). Used after all platform workers complete.
42
+
33
43
  Read in order:
34
44
 
35
45
  1. **Feature Spec document(s)**: `speccrew-workspace/iterations/{number}-{type}-{name}/02.feature-design/[feature-name]-feature-spec.md`
@@ -80,7 +90,11 @@ Mark each function's screens/widgets as:
80
90
  | `[MODIFIED]` | Enhance/change existing | `[MODIFIED] OrderList - add pull-to-refresh` |
81
91
  | `[NEW]` | Create brand new | `[NEW] ProductDetailPage` |
82
92
 
83
- **Checkpoint A: Present function extraction summary to user for confirmation.**
93
+ **Checkpoint A**:
94
+ - If `skip_confirmation` = `true`: Log the function extraction summary and **proceed automatically** without waiting for user confirmation.
95
+ - If `skip_confirmation` is not set or `false`: Present function extraction summary 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.
84
98
 
85
99
  ## Step 4: Generate Module Design Documents
86
100
 
@@ -136,6 +150,10 @@ Verify the completed design document:
136
150
 
137
151
  ## Step 5: Generate Platform INDEX.md
138
152
 
153
+ > **Conditional Execution**:
154
+ > - If `skip_index_generation` = `true`, **skip this entire Step 5**.
155
+ > - If `index_only` = `true`, this step is the ONLY step to execute (Steps 1-4 are skipped).
156
+
139
157
  After all module designs are complete:
140
158
 
141
159
  ### 5.1 Read Template
@@ -279,7 +297,7 @@ After completing all steps, output a structured completion report for the System
279
297
  - [ ] App lifecycle handling documented
280
298
  - [ ] INDEX.md generated with complete module list
281
299
  - [ ] All files written to correct paths under 03.system-design/{platform_id}/
282
- - [ ] **Checkpoint A passed**: function extraction confirmed with user
300
+ - [ ] **Checkpoint A passed**: function extraction confirmed (or skipped via skip_confirmation)
283
301
  - [ ] **No TODO/FIXME placeholders** — all screens and methods have complete pseudocode
284
302
  - [ ] **API routes match API Contract exactly** — verified route-by-route
285
303
  - [ ] **Cross-Feature dependencies explicitly marked** — all `[DEPENDENCY: F-XXX-NNN]` tags present with degradation strategy
@@ -130,14 +130,38 @@ 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. Dispatch worker per platform with `index_only: true` to generate INDEX.md (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 (WORKER-DISPATCH)
147
+
148
+ After ALL Feature×Platform workers complete successfully, dispatch ONE worker per platform to generate INDEX.md. Each worker receives `index_only: true` and `skip_index_generation: false`, executing ONLY Step 5 of the platform skill.
149
+
150
+ **Dispatch parameters per platform**:
151
+ - `agent`: speccrew-task-worker
152
+ - `skill`: speccrew-sd-${platform.type}
153
+ - `skill_path`: ${ide_skills_dir}/speccrew-sd-${platform.type}/SKILL.md
154
+ - `context`:
155
+ - `index_only: true`
156
+ - `skip_index_generation: false`
157
+ - `platform_id`: ${platform.id}
158
+ - `output_dir`: ${iterations_dir}/${current_iteration}/03.system-design/${platform.id}
159
+ - `completed_documents`: ${platform.completed_documents}
160
+ - `techs_knowledge_dir`: ${techs_knowledge_dir}
161
+ - `workspace_path`: ${workspace_path}
162
+
163
+ **FORBIDDEN**: Orchestrator generating INDEX.md directly. INDEX.md MUST be generated by worker.
164
+
141
165
  **Example** (5 features × 3 platforms = 15 workers, 3 batches of 6/6/3):
142
166
  - Batch 1: Workers 1-6 (parallel)
143
167
  - Batch 2: Workers 7-12 (parallel, after batch 1 completes)
@@ -148,6 +172,7 @@ This skill MUST execute tasks continuously without unnecessary interruptions.
148
172
  This workflow has **mandatory HARD STOP** checkpoints at:
149
173
  - **Phase 3.5**: Framework evaluation confirmation (user MUST approve framework decisions)
150
174
  - **Phase 4.5**: Design overview confirmation (user MUST approve DESIGN-OVERVIEW.md before Phase 5 dispatch)
175
+ - **Phase 5.5**: (No HARD STOP — INDEX.md generation is automatic after all workers complete)
151
176
  - **Phase 6.1**: Joint design confirmation (user MUST approve all designs)
152
177
 
153
178
  DO NOT proceed past these checkpoints without explicit user confirmation.
@@ -168,6 +193,7 @@ DO NOT proceed past these checkpoints without explicit user confirmation.
168
193
  - **DO NOT generate framework-evaluation.md yourself** — Only workers generate it
169
194
  - **DO NOT create scripts for batch analysis** — Workers handle this via their own skill
170
195
  - **DO NOT fallback to inline execution if worker fails** — ABORT instead
196
+ - **DO NOT let individual workers generate INDEX.md in batch mode** — `skip_index_generation: true` must be set; INDEX.md is generated in Phase 5.5 by separate worker with `index_only: true`
171
197
  - **DO NOT skip reading workflow.agentflow.xml** — XML is the execution authority
172
198
  - **DO NOT generate DESIGN-OVERVIEW.md yourself** — Dispatch speccrew-task-worker with speccrew-sd-design-overview-generate skill
173
199
  - **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,37 @@
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 (WORKER-DISPATCH) -->
430
+ <block type="rule" id="P5-IDX-R1" level="mandatory" desc="INDEX.md Generation via Worker Dispatch">
431
+ <field name="text">
432
+ After ALL Feature×Platform workers complete, dispatch ONE worker per platform to generate INDEX.md.
433
+ - Each worker receives index_only=true, skip_index_generation=false
434
+ - Worker executes ONLY Step 5 of the platform skill
435
+ - FORBIDDEN: Orchestrator generating INDEX.md directly (must use worker)
436
+ </field>
437
+ </block>
438
+ <block type="loop" id="P5-IDX-L1" over="${platforms}" as="platform">
439
+ <block type="task" id="P5-IDX-DISPATCH" action="dispatch-to-worker" status="pending"
440
+ desc="Dispatch worker to generate INDEX.md for ${platform.id}">
441
+ <field name="agent">speccrew-task-worker</field>
442
+ <field name="skill">speccrew-sd-${platform.type}</field>
443
+ <field name="skill_path">${ide_skills_dir}/speccrew-sd-${platform.type}/SKILL.md</field>
444
+ <field name="context">
445
+ index_only: true
446
+ skip_index_generation: false
447
+ platform_id: ${platform.id}
448
+ output_dir: ${iterations_dir}/${current_iteration}/03.system-design/${platform.id}
449
+ completed_documents: ${platform.completed_documents}
450
+ techs_knowledge_dir: ${techs_knowledge_dir}
451
+ workspace_path: ${workspace_path}
452
+ </field>
453
+ </block>
454
+ </block>
455
+ <block type="gateway" id="P5-IDX-GW1" mode="wait" desc="Wait for all INDEX.md workers to complete"/>
456
+
424
457
  <!-- Step 5.5: Read final dispatch progress -->
425
458
  <block type="task" id="P5-B5" action="run-script" status="pending"
426
459
  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.60",
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;