speccrew 0.6.21 → 0.6.23

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.
@@ -562,6 +562,24 @@ No knowledge base exists. A lightweight feature inventory scan is triggered to d
562
562
  > **Path B Step 5: Update Features Status**
563
563
  > After all analyze Workers complete, update each analyzed feature's `analyzed` field to `true` in the corresponding features-*.json file.
564
564
  >
565
+ > **Path B Step 6: Generate System Overview**
566
+ > Dispatch a Worker to generate system-overview.md from all module-overview files:
567
+ >
568
+ > ```
569
+ > Use the Agent tool to invoke speccrew-task-worker:
570
+ > - agent: speccrew-task-worker
571
+ > - task: Execute speccrew-knowledge-system-summarize skill
572
+ > - context:
573
+ > skill: speccrew-knowledge-system-summarize
574
+ > modules_path: {workspace_path}/knowledges/bizs
575
+ > output_path: {workspace_path}/knowledges/bizs
576
+ > language: {language}
577
+ > ```
578
+ >
579
+ > This step aggregates all module-overview.md files into a single system-overview.md, which PM Agent uses as the primary knowledge context when processing new requirements.
580
+ >
581
+ > ⚠️ This step MUST complete before Phase 1 exits. system-overview.md is required for subsequent requirement analysis.
582
+ >
565
583
  > Only after ALL Steps complete, proceed to Phase 2 (Requirement Clarification).
566
584
  >
567
585
  > 🛑 **Path B Completion Check**:
@@ -571,6 +589,7 @@ No knowledge base exists. A lightweight feature inventory scan is triggered to d
571
589
  > - [ ] Step 3 completed: analyze Workers dispatched and completed for ALL pending features
572
590
  > - [ ] Step 4 completed: module-summarize Workers completed for ALL matched modules
573
591
  > - [ ] Step 5 completed: features-*.json updated with analyzed=true
592
+ > - [ ] Step 6 completed: system-overview.md generated
574
593
  >
575
594
  > If ANY step is incomplete, DO NOT proceed. Execute the missing steps first.
576
595
 
@@ -1091,65 +1110,117 @@ This agent MUST execute tasks continuously without unnecessary interruptions.
1091
1110
  > Multiple items detected → MUST dispatch speccrew-task-worker.
1092
1111
  > DO NOT invoke skills directly. See MANDATORY WORKER ENFORCEMENT section.
1093
1112
 
1113
+ > 🛑 **ORCHESTRATOR PRINCIPLE — PM Agent is DISPATCHER, NOT WORKER:**
1114
+ > The PM Agent MUST dispatch ONE Worker per Sub-PRD module.
1115
+ > Each Worker generates ONE Sub-PRD file.
1116
+ > PM Agent tracks progress and sends batches — PM Agent NEVER generates Sub-PRD content.
1117
+
1094
1118
  **IF the Skill output includes a Sub-PRD Dispatch Plan (from Step 12c), execute this phase.**
1095
1119
  **IF Single PRD structure, skip to Phase 6.**
1096
1120
 
1097
- After the Skill generates the Master PRD and outputs the dispatch plan, the PM Agent takes over to generate Sub-PRDs in parallel using worker agents.
1121
+ After the Skill generates the Master PRD and outputs the dispatch plan, the PM Agent takes over to dispatch Sub-PRD generation to worker agents.
1098
1122
 
1099
- > **Phase 5 Execution Flow:**
1123
+ > **CORRECT Phase 5 Execution Flow (Dispatch-Tracked):**
1100
1124
  > ```
1101
1125
  > Generate Skill outputs Dispatch Plan
1102
1126
  > ↓
1103
1127
  > PM reads Dispatch Plan (module list + contexts)
1104
1128
  > ↓
1105
- > PM initializes DISPATCH-PROGRESS.json (via script)
1129
+ > PM initializes DISPATCH-PROGRESS.json (via script) ← Step 5.2
1106
1130
  > ↓
1107
- > PM invokes speccrew-task-worker × N (one per module)
1108
- > └─ Each worker internally calls speccrew-pm-sub-prd-generate
1131
+ > PM dispatches Workers IN BATCHES Step 5.3
1132
+ > ├─ Batch 1: Workers 1-5 (parallel dispatch)
1133
+ > ├─ Wait for Batch 1 completion
1134
+ > ├─ Update DISPATCH-PROGRESS.json per completed worker
1135
+ > ├─ Batch 2: Workers 6-10 (parallel dispatch)
1136
+ > ├─ Wait for Batch 2 completion
1137
+ > └─ ... until all modules done
1138
+ > ↓
1139
+ > ALL workers done → PM verifies in Step 5.5
1140
+ > ↓
1141
+ > ALL verified → Phase 6
1142
+ > ```
1143
+ >
1144
+ > **WRONG flow (VIOLATION):**
1145
+ > ```
1146
+ > PM reads Dispatch Plan
1109
1147
  > ↓
1110
- > Workers complete PM updates progress (via script)
1148
+ > PM dispatches ONE Worker for ALL modules ← VIOLATION
1149
+ > └─ Worker internally loops to generate all Sub-PRDs
1111
1150
  > ↓
1112
- > ALL workers done Phase 6
1151
+ > This is serial generation, NOT parallel dispatch
1113
1152
  > ```
1114
1153
  >
1115
- > **NOT this flow:**
1154
+ > **ALSO WRONG:**
1116
1155
  > ```
1117
1156
  > PM reads Dispatch Plan → PM generates Sub-PRDs directly ← VIOLATION
1118
1157
  > ```
1119
1158
 
1159
+ ---
1160
+
1120
1161
  ### 5.1 Read Dispatch Plan
1121
1162
 
1122
1163
  From the Skill's Step 12c output, collect:
1123
1164
  - `feature_name`: System-level feature name
1124
1165
  - `template_path`: Path to PRD-TEMPLATE.md
1125
1166
  - `master_prd_path`: Path to the generated Master PRD
1167
+ - `clarification_file`: Path to `.clarification-summary.md`
1168
+ - `module_design_file`: Path to `.module-design.md`
1126
1169
  - `output_dir`: Directory for Sub-PRD files (same as Master PRD directory)
1127
1170
  - Module list with context for each module:
1128
1171
  - `module_name`, `module_key`, `module_scope`, `module_entities`
1129
1172
  - `module_user_stories`, `module_requirements`, `module_features`
1130
1173
  - `module_dependencies`
1131
1174
 
1132
- ### 5.1b Initialize Dispatch Progress Tracking
1175
+ **Store these values as workflow context variables for use in Worker dispatches.**
1176
+
1177
+ ---
1178
+
1179
+ ### 5.2 Initialize Dispatch Progress Tracking
1133
1180
 
1134
- **MANDATORY: Initialize dispatch tracking with script:**
1181
+ > 🛑 **HARD STOP: This step MUST complete before ANY Worker dispatch.**
1182
+
1183
+ **Step 5.2.1: Prepare tasks array**
1184
+
1185
+ Create a temporary file with task definitions for each module:
1186
+
1187
+ ```json
1188
+ [
1189
+ {
1190
+ "id": "{module_key_1}",
1191
+ "name": "{module_name_1}",
1192
+ "status": "pending",
1193
+ "output_file": "{output_dir}/{feature_name}-sub-{module_key_1}.md"
1194
+ },
1195
+ {
1196
+ "id": "{module_key_2}",
1197
+ "name": "{module_name_2}",
1198
+ "status": "pending",
1199
+ "output_file": "{output_dir}/{feature_name}-sub-{module_key_2}.md"
1200
+ }
1201
+ ]
1202
+ ```
1203
+
1204
+ **Step 5.2.2: Initialize DISPATCH-PROGRESS.json**
1135
1205
 
1136
1206
  > ⚠️ Use --tasks-file instead of --tasks to avoid PowerShell JSON parsing issues.
1137
1207
 
1138
1208
  ```bash
1139
- # Write tasks to temp file inside iteration directory
1140
- # Create .tasks-temp.json with task array content
1141
- node "{update_progress_script}" init \
1142
- --file {iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json \
1143
- --stage sub_prd_dispatch \
1144
- --tasks-file {iterations_dir}/{iteration}/01.product-requirement/.tasks-temp.json
1145
- # Delete .tasks-temp.json after successful init
1209
+ # PowerShell compatible command
1210
+ node "{update_progress_script}" init `
1211
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json" `
1212
+ --stage sub_prd_dispatch `
1213
+ --tasks-file "{iterations_dir}/{iteration}/01.product-requirement/.tasks-temp.json"
1214
+
1215
+ # Clean up temp file after successful init
1216
+ Remove-Item "{iterations_dir}/{iteration}/01.product-requirement/.tasks-temp.json"
1146
1217
  ```
1147
1218
 
1148
1219
  > **PowerShell Compatibility Note:**
1149
1220
  > PowerShell cannot properly parse JSON in command-line arguments. Use file-based approach:
1150
- > 1. Write tasks JSON to a temporary file (e.g., `tasks-temp.json`)
1151
- > 2. Read file content in the command: `node "{update_progress_script}" init --stage sub_prd_dispatch --tasks (Get-Content tasks-temp.json -Raw)`
1152
- > 3. Or use: `Get-Content tasks-temp.json | node "{update_progress_script}" init --stage sub_prd_dispatch --tasks -`
1221
+ > 1. Write tasks JSON to a temporary file (e.g., `.tasks-temp.json`)
1222
+ > 2. Run the init command with `--tasks-file` pointing to the temp file
1223
+ > 3. Delete temp file after successful init
1153
1224
 
1154
1225
  > 🛑 **HARD STOP: DISPATCH-PROGRESS.json MUST be created by script ONLY**
1155
1226
  > - MUST use: `node "{update_progress_script}" init --stage sub_prd_dispatch --tasks-file <TASKS_FILE>`
@@ -1157,116 +1228,281 @@ node "{update_progress_script}" init \
1157
1228
  > - IF script fails → STOP workflow immediately, report error to user, ask "Retry or Abort?"
1158
1229
  > - DO NOT proceed to Worker dispatch without successful script execution
1159
1230
 
1160
- After each worker completes:
1161
- ```bash
1162
- node "{update_progress_script}" update-task \
1163
- --file {iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json \
1164
- --task-id {module_key} --status completed
1165
- ```
1231
+ **Step 5.2.3: Verify initialization**
1166
1232
 
1167
- If a worker fails:
1168
1233
  ```bash
1169
- node "{update_progress_script}" update-task \
1170
- --file {iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json \
1171
- --task-id {module_key} --status failed --error "{error_message}"
1234
+ node "{update_progress_script}" read `
1235
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json" `
1236
+ --summary
1172
1237
  ```
1173
1238
 
1174
- ### 5.3 Dispatch Workers
1239
+ Expected output: `Total: N tasks | Pending: N | Completed: 0 | Failed: 0`
1240
+
1241
+ ---
1242
+
1243
+ ### 5.3 Dispatch Workers (Batch Parallel)
1244
+
1245
+ > 🛑 **CRITICAL: ONE Worker per Module — NO EXCEPTIONS**
1246
+ >
1247
+ > | Module Count | Dispatch Strategy |
1248
+ > |--------------|-------------------|
1249
+ > | 1-5 modules | Single batch, all parallel |
1250
+ > | 6-10 modules | 2 batches of 5 |
1251
+ > | 11-15 modules | 3 batches of 5 |
1252
+ > | 16+ modules | Batches of 5, final batch may be smaller |
1253
+ >
1254
+ > **BATCH SIZE = 5 (maximum parallel Workers per batch)**
1175
1255
 
1176
1256
  **PM Agent Role: ORCHESTRATOR ONLY — Phase 5 EXPLICIT RULES**
1177
1257
 
1178
1258
  **MANDATORY — PM MUST:**
1179
1259
  1. Read the Dispatch Plan from generate skill output
1180
- 2. Initialize DISPATCH-PROGRESS.json via update-progress.js script
1181
- 3. For EACH module in dispatch plan: invoke `speccrew-task-worker` with `skill_path: speccrew-pm-sub-prd-generate/SKILL.md`
1260
+ 2. Initialize DISPATCH-PROGRESS.json via update-progress.js script (Step 5.2)
1261
+ 3. For EACH module in dispatch plan: invoke ONE `speccrew-task-worker`
1182
1262
  4. Pass ALL required context parameters to each worker
1183
- 5. Wait for ALL workers to complete
1184
- 6. Update DISPATCH-PROGRESS.json via script after each worker completes
1263
+ 5. Dispatch in batches of 5, wait for each batch to complete
1264
+ 6. After each Worker completes, update DISPATCH-PROGRESS.json via script
1185
1265
 
1186
1266
  🛑 **FORBIDDEN — PM MUST NOT:**
1187
1267
  - Generate Sub-PRD files directly (via create_file, write, or any file creation)
1188
1268
  - Invoke speccrew-pm-sub-prd-generate skill directly (ONLY speccrew-task-worker invokes it)
1269
+ - Dispatch ONE Worker to handle MULTIPLE modules (each module = one Worker)
1189
1270
  - Create or edit any Sub-PRD content as fallback if worker fails
1190
1271
  - Skip worker dispatch and generate Sub-PRDs inline
1191
1272
  - IF PM attempts ANY of above → WORKFLOW VIOLATION → STOP immediately
1192
1273
 
1193
- **Implementation:**
1194
-
1195
- For EACH module in the dispatch plan, invoke a new `speccrew-task-worker` agent:
1196
- - **skill_path**: Search with glob `**/speccrew-pm-sub-prd-generate/SKILL.md`
1197
- - **context**:
1198
- - `module_name`: from dispatch plan
1199
- - `module_key`: from dispatch plan
1200
- - `master_prd_path`: path to Master PRD
1201
- - `template_path`: PRD template path (from Step 7 glob search result)
1202
- - `output_dir`: `{iterations_dir}/{iteration}/01.product-requirement/` (absolute path from Phase 0.6)
1203
-
1204
- Each worker receives:
1205
- - `skill_path`: `speccrew-pm-sub-prd-generate/SKILL.md`
1206
- - `context`:
1207
- - `module_name`: Module name (e.g., "Customer Management")
1208
- - `module_key`: Module identifier for file naming (e.g., "customer")
1209
- - `module_scope`: What this module covers
1210
- - `module_entities`: Core business entities
1211
- - `module_user_stories`: Module-specific user stories
1212
- - `module_requirements`: Module-specific functional requirements (P0/P1/P2)
1213
- - `module_features`: Feature Breakdown entries for this module
1214
- - `module_dependencies`: Dependencies on other modules
1215
- - `master_prd_path`: Path to the Master PRD
1216
- - `feature_name`: System-level feature name
1217
- - `template_path`: Path to PRD-TEMPLATE.md
1218
- - `output_path`: `{output_dir}/{feature_name}-sub-{module_key}.md`
1219
-
1220
- **Batch Strategy:**
1221
- - If modules ≤ 6: dispatch ALL in parallel
1222
- - If modules > 6: dispatch in batches of 6, wait for batch completion before next batch
1223
-
1224
- **Parallel execution pattern:**
1274
+ ---
1275
+
1276
+ #### Step 5.3.1: Determine Batch Plan
1277
+
1278
+ <arg_value>Read DISPATCH-PROGRESS.json to get pending tasks:
1279
+
1280
+ ```bash
1281
+ node "{update_progress_script}" read `
1282
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json"
1283
+ ```
1284
+
1285
+ Group tasks into batches:
1225
1286
  ```
1226
- Worker 1: Module "customer" → crm-system-sub-customer.md
1227
- Worker 2: Module "contact" → crm-system-sub-contact.md
1228
- Worker 3: Module "opportunity" → crm-system-sub-opportunity.md
1229
- ...
1230
- Worker N: Module "{module-N}" → crm-system-sub-{module-N}.md
1287
+ 📊 Sub-PRD Dispatch Plan
1288
+ ├── Total Modules: 14
1289
+ ├── Batch Size: 5
1290
+ ├── Batches Required: 3
1291
+ │ ├── Batch 1: modules 1-5 (customer, contact, opportunity, lead, activity)
1292
+ │ ├── Batch 2: modules 6-10 (report, dashboard, workflow, notification, integration)
1293
+ │ └── Batch 3: modules 11-14 (security, audit, config, help)
1294
+ └── Strategy: Parallel dispatch within batch, sequential between batches
1231
1295
  ```
1232
1296
 
1233
- **All workers execute simultaneously (or in batches).** Wait for all workers to complete before proceeding.
1297
+ ---
1234
1298
 
1235
- **Before proceeding to Phase 6, verify:**
1236
- - [ ] All workers were dispatched via speccrew-task-worker
1237
- - [ ] No Sub-PRD was generated by PM Agent directly
1238
- - [ ] All workers completed (check DISPATCH-PROGRESS.json)
1299
+ #### Step 5.3.2: Dispatch Batch N
1239
1300
 
1240
- ### 5.4 Collect Results
1301
+ For EACH module in current batch, dispatch ONE `speccrew-task-worker`:
1241
1302
 
1242
- After all workers complete:
1303
+ **Agent Tool Invocation Format (REPEAT for each module):**
1243
1304
 
1244
- 1. **Check worker results**: Verify each worker reported success
1245
- 2. **List generated files**:
1246
- ```
1247
- 📊 Sub-PRD Generation Results:
1248
- ├── Worker 1: {module-1} → ✅ Generated ({file_size})
1249
- ├── Worker 2: {module-2} → ✅ Generated ({file_size})
1250
- ├── Worker N: {module-N} → ✅ Generated ({file_size})
1251
-
1252
- Total: N workers | Completed: X | Failed: Y
1253
- ```
1305
+ ```
1306
+ Use the Agent tool to invoke speccrew-task-worker:
1307
+ - agent: speccrew-task-worker
1308
+ - task: Generate Sub-PRD for module "{module_name}"
1309
+ - context:
1310
+ skill: speccrew-pm-sub-prd-generate
1311
+ module_name: {module_name}
1312
+ module_key: {module_key}
1313
+ module_scope: {module_scope}
1314
+ module_entities: {module_entities}
1315
+ module_user_stories: {module_user_stories}
1316
+ module_requirements: {module_requirements}
1317
+ module_features: {module_features}
1318
+ module_dependencies: {module_dependencies}
1319
+ master_prd_path: {master_prd_path}
1320
+ clarification_file: {clarification_file}
1321
+ module_design_file: {module_design_file}
1322
+ feature_name: {feature_name}
1323
+ template_path: {template_path}
1324
+ output_path: {output_dir}/{feature_name}-sub-{module_key}.md
1325
+ language: {language}
1326
+ ```
1254
1327
 
1255
- 3. **Handle failures**: If any worker failed:
1256
- - Report which modules failed and why
1257
- - Re-dispatch failed modules (retry once)
1258
- - If retry fails, report to user for manual intervention
1328
+ **Worker Context Parameters:**
1329
+
1330
+ | Parameter | Source | Description |
1331
+ |-----------|--------|-------------|
1332
+ | `skill` | Fixed | `speccrew-pm-sub-prd-generate` |
1333
+ | `module_name` | Dispatch Plan | Display name (e.g., "Customer Management") |
1334
+ | `module_key` | Dispatch Plan | Identifier for file naming (e.g., "customer") |
1335
+ | `module_scope` | Dispatch Plan | What this module covers |
1336
+ | `module_entities` | Dispatch Plan | Core business entities |
1337
+ | `module_user_stories` | Dispatch Plan | Module-specific user stories |
1338
+ | `module_requirements` | Dispatch Plan | Module-specific functional requirements (P0/P1/P2) |
1339
+ | `module_features` | Dispatch Plan | Feature Breakdown entries for this module |
1340
+ | `module_dependencies` | Dispatch Plan | Dependencies on other modules |
1341
+ | `master_prd_path` | Dispatch Plan | Path to the Master PRD |
1342
+ | `clarification_file` | Step 5.1 | Path to `.clarification-summary.md` |
1343
+ | `module_design_file` | Step 5.1 | Path to `.module-design.md` |
1344
+ | `feature_name` | Dispatch Plan | System-level feature name |
1345
+ | `template_path` | Dispatch Plan | Path to PRD-TEMPLATE.md |
1346
+ | `output_path` | Computed | `{output_dir}/{feature_name}-sub-{module_key}.md` |
1347
+ | `language` | Detected | User's language |
1348
+
1349
+ **Dispatch Example (Batch 1 with 5 modules):**
1350
+
1351
+ ```
1352
+ 📊 Dispatching Batch 1 (5 modules in parallel)
1353
+ ├── Worker 1: module="customer" → output: crm-system-sub-customer.md
1354
+ ├── Worker 2: module="contact" → output: crm-system-sub-contact.md
1355
+ ├── Worker 3: module="opportunity" → output: crm-system-sub-opportunity.md
1356
+ ├── Worker 4: module="lead" → output: crm-system-sub-lead.md
1357
+ └── Worker 5: module="activity" → output: crm-system-sub-activity.md
1358
+
1359
+ Waiting for all 5 Workers to complete...
1360
+ ```
1361
+
1362
+ ---
1363
+
1364
+ #### Step 5.3.3: Update Progress After Each Worker
1365
+
1366
+ **When a Worker completes successfully:**
1367
+
1368
+ ```bash
1369
+ node "{update_progress_script}" update-task `
1370
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json" `
1371
+ --task-id "{module_key}" `
1372
+ --status completed
1373
+ ```
1374
+
1375
+ **When a Worker fails:**
1376
+
1377
+ ```bash
1378
+ node "{update_progress_script}" update-task `
1379
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json" `
1380
+ --task-id "{module_key}" `
1381
+ --status failed `
1382
+ --error "{error_message}"
1383
+ ```
1384
+
1385
+ **After each batch completes, show progress:**
1386
+
1387
+ ```
1388
+ 📊 Batch 1 Complete
1389
+ ├── ✅ customer: completed
1390
+ ├── ✅ contact: completed
1391
+ ├── ✅ opportunity: completed
1392
+ ├── ❌ lead: failed (timeout)
1393
+ └── ✅ activity: completed
1394
+
1395
+ Progress: 4/14 completed, 1 failed, 9 pending
1396
+ Proceeding to Batch 2...
1397
+ ```
1398
+
1399
+ ---
1400
+
1401
+ #### Step 5.3.4: Continue to Next Batch
1402
+
1403
+ After current batch completes:
1404
+ 1. Check DISPATCH-PROGRESS.json for remaining pending tasks
1405
+ 2. If pending tasks remain → dispatch next batch (Step 5.3.2)
1406
+ 3. If all tasks done → proceed to Step 5.4
1407
+
1408
+ ```bash
1409
+ node "{update_progress_script}" read `
1410
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json" `
1411
+ --summary
1412
+ ```
1413
+
1414
+ Continue dispatching batches until `counts.pending == 0`.
1415
+
1416
+ ---
1417
+
1418
+ ### 5.4 Handle Failures & Retry
1419
+
1420
+ After all batches complete, check for failed tasks:
1421
+
1422
+ ```bash
1423
+ node "{update_progress_script}" read `
1424
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json"
1425
+ ```
1426
+
1427
+ **If any tasks have `status: "failed"`:**
1428
+
1429
+ 1. List failed modules
1430
+ 2. Re-dispatch ONE Worker per failed module (single retry)
1431
+ 3. Update status after retry
1432
+ 4. If retry fails again, report to user for manual intervention
1433
+
1434
+ ```
1435
+ 📊 Retry Summary
1436
+ ├── Retrying 2 failed modules...
1437
+ │ ├── Worker: module="lead" → retry
1438
+ │ └── Worker: module="report" → retry
1439
+ ├── Retry Results:
1440
+ │ ├── ✅ lead: completed (retry successful)
1441
+ │ └── ❌ report: failed (retry failed)
1442
+ └── Final Status: 13/14 completed, 1 failed
1443
+
1444
+ Module "report" failed after retry. Manual intervention required.
1445
+ Options:
1446
+ - Skip and continue with 13/14 Sub-PRDs
1447
+ - Abort and investigate
1448
+ ```
1449
+
1450
+ ---
1451
+
1452
+ ### 5.5 Collect Results & Verify
1453
+
1454
+ > 🛑 **Verification before proceeding to Phase 6**
1455
+
1456
+ **Step 5.5.1: Read Final Progress**
1457
+
1458
+ ```bash
1459
+ node "{update_progress_script}" read `
1460
+ --file "{iterations_dir}/{iteration}/01.product-requirement/DISPATCH-PROGRESS.json" `
1461
+ --summary
1462
+ ```
1463
+
1464
+ Expected: `Total: N | Pending: 0 | Completed: N | Failed: 0`
1465
+
1466
+ **Step 5.5.2: Verify All Sub-PRD Files Exist**
1467
+
1468
+ ```bash
1469
+ # List all Sub-PRD files
1470
+ Get-ChildItem "{iterations_dir}/{iteration}/01.product-requirement/" -Filter "*-sub-*.md"
1471
+ ```
1472
+
1473
+ Verify:
1474
+ - File count matches DISPATCH-PROGRESS.json completed count
1475
+ - Each file has size > 3KB
1476
+
1477
+ **Step 5.5.3: Report Final Summary**
1259
1478
 
1260
- After all workers complete, report dispatch summary:
1261
1479
  ```
1262
1480
  📊 Sub-PRD Generation Complete:
1263
- ├── Total: 11 modules
1264
- ├── ✅ Completed: 10
1265
- ├── ❌ Failed: 1 (member — error description)
1266
- └── Retry failed modules? (yes/skip)
1481
+ ├── Total Modules: {count}
1482
+ ├── ✅ Completed: {count}
1483
+ ├── ❌ Failed: {count}
1484
+ ├── Generated Files:
1485
+ │ ├── {feature_name}-sub-{module_1}.md ({size} KB)
1486
+ │ ├── {feature_name}-sub-{module_2}.md ({size} KB)
1487
+ │ └── ...
1488
+ └── All Sub-PRDs ready for Phase 6 Verification
1267
1489
  ```
1268
1490
 
1269
- Update `.checkpoints.json` → `sub_prd_dispatch.passed = true` (only if all succeeded or user skips failures).
1491
+ **Step 5.5.4: Update Checkpoint**
1492
+
1493
+ ```bash
1494
+ node "{update_progress_script}" write-checkpoint `
1495
+ --file "{iterations_dir}/{iteration}/01.product-requirement/.checkpoints.json" `
1496
+ --checkpoint sub_prd_dispatch `
1497
+ --status passed
1498
+ ```
1499
+
1500
+ **Before proceeding to Phase 6, verify:**
1501
+ - [ ] All workers were dispatched via speccrew-task-worker (one Worker per module)
1502
+ - [ ] No Sub-PRD was generated by PM Agent directly
1503
+ - [ ] All workers completed (DISPATCH-PROGRESS.json counts.pending == 0)
1504
+ - [ ] All Sub-PRD files exist and have valid size
1505
+ - [ ] Checkpoint updated
1270
1506
 
1271
1507
  > 🛑 **MANDATORY**: After all Sub-PRDs are generated and checkpoint is recorded, you MUST immediately proceed to Phase 6 (Verification & User Review). DO NOT skip Phase 6. DO NOT directly ask the user if they want to continue to Feature Design. Phase 6 handles the formal verification, user review, and status update.
1272
1508
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: speccrew-system-developer
3
3
  description: SpecCrew System Developer. Reads system design blueprints and coordinates cross-platform development task dispatch. Loads techs knowledge, verifies environment readiness, dispatches per-platform dev skills, performs integration checks, and delivers development completion reports. Supports web, mobile, desktop, and backend platforms.
4
- tools: Read, Write, Glob, Grep, Bash, Agent
4
+ tools: Read, Write, Glob, Grep, Bash
5
5
  ---
6
6
 
7
7
  # Quick Reference — Execution Flow
@@ -364,6 +364,45 @@ Log: "✅ Checkpoint B (feature_design_review) passed and recorded"
364
364
 
365
365
  ## Step 5: Determine Output Path & Copy Template
366
366
 
367
+ > **⚠️ CRITICAL: Two-Phase Strategy (Skeleton-First, Content-After)**
368
+ >
369
+ > Steps 5 and 6 MUST be executed in two phases to ensure consistent document structure.
370
+
371
+ ### Phase A: Skeleton Construction (BEFORE any content filling)
372
+
373
+ 1. Read FEATURE-SPEC-TEMPLATE.md to identify the complete section structure
374
+ 2. Count the number of functions from `.feature-analysis.md` input
375
+ 3. For Section 2 Function Details, replicate the template's Function block structure for EACH function:
376
+ - Copy the EXACT template structure (all 4 sub-sections) from FEATURE-SPEC-TEMPLATE.md
377
+ - Create `### 2.1 Function: {function_name}` through `### 2.N Function: {function_name}`
378
+ - Each function block MUST contain these 4 sub-section headers (copied from template):
379
+ ```
380
+ #### 2.N.1 Frontend Prototype
381
+ [TO BE FILLED]
382
+
383
+ #### 2.N.2 Interaction Flow
384
+ [TO BE FILLED]
385
+
386
+ #### 2.N.3 Backend Interface
387
+ [TO BE FILLED]
388
+
389
+ #### 2.N.4 Data Definition
390
+ [TO BE FILLED]
391
+ ```
392
+ 4. Verify skeleton: confirm ALL functions have ALL 4 sub-section headers before proceeding
393
+
394
+ > ⚠️ DO NOT start filling content until the complete skeleton is verified.
395
+
396
+ ### Phase B: Content Filling (AFTER skeleton is complete)
397
+
398
+ Fill each `[TO BE FILLED]` placeholder with actual content:
399
+ - **Frontend Prototype** → ASCII wireframes (Pattern A/B/C/M-A/M-B/M-C) + Interface Element Description table
400
+ - **Interaction Flow** → Mermaid `sequenceDiagram` + Interaction Rules table
401
+ - **Backend Interface** → Interface List table + Mermaid `flowchart TD` for Processing Logic + Data Access table
402
+ - **Data Definition** → Fields table + Data Source table
403
+
404
+ ---
405
+
367
406
  ### 5.1 Determine Output Path
368
407
 
369
408
  **Single Feature Mode** (when `feature_id` provided):
@@ -399,6 +438,13 @@ Log: "✅ Checkpoint B (feature_design_review) passed and recorded"
399
438
 
400
439
  ## Step 6: Fill Sections Using search_replace
401
440
 
441
+ > **⚠️ CRITICAL: Section 2 Function Details Skeleton Verification**
442
+ >
443
+ > Before proceeding with content filling, verify the two-phase strategy was correctly applied:
444
+ > 1. Confirm ALL functions in Section 2 have complete 4 sub-section skeletons (Frontend Prototype, Interaction Flow, Backend Interface, Data Definition)
445
+ > 2. Confirm no `[TO BE FILLED]` placeholders remain unfilled after content filling
446
+ > 3. Confirm each function follows the exact template structure from FEATURE-SPEC-TEMPLATE.md
447
+
402
448
  ### Section Mapping Table
403
449
 
404
450
  | Template Section | Data Source |
@@ -504,6 +550,7 @@ Log: "✅ Feature Spec generation completed. Checkpoint feature_spec_review pass
504
550
  - [ ] Output path determined
505
551
  - [ ] Template copied using `create_file`
506
552
  - [ ] All sections filled using `search_replace`
553
+ - [ ] **[CRITICAL]** Section 2 Function Details skeleton verified (all functions have 4 sub-sections)
507
554
  - [ ] **[CRITICAL]** Interaction Flow uses Mermaid sequenceDiagram (NOT ASCII)
508
555
  - [ ] **[CRITICAL]** Processing Logic uses Mermaid flowchart TD (NOT ASCII)
509
556
  - [ ] All Mermaid diagrams follow mermaid-rule.md compliance rules
@@ -126,6 +126,52 @@ Collect all business rules from feature details:
126
126
 
127
127
  ### Step 5: Generate Complete MODULE-OVERVIEW.md
128
128
 
129
+ > **⚠️ CRITICAL: Two-Phase Strategy (Skeleton-First, Content-After)**
130
+ >
131
+ > This step MUST be executed in two phases to ensure consistent document structure.
132
+
133
+ ### Phase A: Skeleton Construction (BEFORE any content filling)
134
+
135
+ 1. Read MODULE-OVERVIEW-TEMPLATE.md to identify the complete section structure
136
+ 2. Count data items from extracted information:
137
+ - Section 3: Count unique **Entities** (deduplicated by entity name)
138
+ - Section 4: Count unique **Dependencies** (internal + external)
139
+ - Section 5: Count unique **Core Business Flows**
140
+ - Section 6: Count unique **Business Rules**
141
+ 3. For each section with repeating data items, create complete skeleton structure:
142
+ - **Section 3 (Entities)**: For each entity, create table row with ALL column placeholders:
143
+ ```
144
+ | [Entity Name] | [TO BE FILLED] | [TO BE FILLED] | [TO BE FILLED] |
145
+ ```
146
+ - **Section 4 (Dependencies)**: For each dependency, create table row with ALL column placeholders:
147
+ ```
148
+ | [Direction] | [Target] | [Content] | [Method] |
149
+ ```
150
+ - **Section 5 (Core Business Flows)**: For each flow, create flow item with placeholders:
151
+ ```
152
+ **[Flow Name]**: [TO BE FILLED]
153
+ ```
154
+ - **Section 6 (Business Rules)**: For each rule, create table row with ALL column placeholders:
155
+ ```
156
+ | [Rule ID] | [Rule Name] | [Description] | [Related Features] |
157
+ ```
158
+ 4. Verify skeleton: confirm ALL data items have ALL required column/field placeholders before proceeding
159
+
160
+ > ⚠️ DO NOT start filling content until the complete skeleton is verified.
161
+
162
+ ### Phase B: Content Filling (AFTER skeleton is complete)
163
+
164
+ Fill each `[TO BE FILLED]` placeholder with actual content:
165
+ - Entity Description → Business description of the entity
166
+ - Entity Key Attributes → Field names with types (deduplicated from all features)
167
+ - Entity Business Rules → Constraints and validation rules aggregated from features
168
+ - Dependency Content → What is provided/consumed
169
+ - Dependency Method → How the dependency is realized (API call, import, injection)
170
+ - Core Business Flow → Step sequence with actors and outcomes
171
+ - Business Rule Description → Rule logic and enforcement point
172
+
173
+ ---
174
+
129
175
  **⚠️ CRITICAL CONSTRAINTS (apply to this step):**
130
176
  > 1. **FORBIDDEN: `create_file` for overview document** — If skeleton exists, use `search_replace`; if not, copy template first then fill with `search_replace`
131
177
  > 2. **FORBIDDEN: Full-file rewrite** — Always use targeted `search_replace` on specific sections
@@ -208,6 +208,48 @@ Create flow-module mapping matrix:
208
208
 
209
209
  ### Step 7: Generate system-overview.md
210
210
 
211
+ > **⚠️ CRITICAL: Two-Phase Strategy (Skeleton-First, Content-After)**
212
+ >
213
+ > This step MUST be executed in two phases to ensure consistent document structure.
214
+
215
+ ### Phase A: Skeleton Construction (BEFORE any content filling)
216
+
217
+ 1. Read SYSTEM-OVERVIEW-TEMPLATE.md to identify the complete section structure
218
+ 2. Count aggregated data items from discovered modules:
219
+ - Section 2: Count unique **Modules** (including platform_type annotation for duplicates)
220
+ - Section 3: Count unique **End-to-End Business Flows**
221
+ - Section 4: Count unique **External Integrations**
222
+ 3. For each section with repeating data items, create complete skeleton structure:
223
+ - **Section 2 (Module Topology)**: For each module, create index table row with ALL column placeholders:
224
+ ```
225
+ | [Module Name] | [Domain] | [Purpose] | [Entities] | [APIs] | [Detail Doc] |
226
+ ```
227
+ - **Section 3 (Business Flows)**: For each flow, create mapping matrix row:
228
+ ```
229
+ | [Flow Name] | [Module 1] | [Module 2] | ... | [Module N] |
230
+ ```
231
+ - **Section 4 (External Integrations)**: For each integration, create table row:
232
+ ```
233
+ | [System Name] | [Integration Type] | [Data Exchanged] | [Protocol] |
234
+ ```
235
+ 4. Verify skeleton: confirm ALL data items have ALL required column placeholders before proceeding
236
+
237
+ > ⚠️ DO NOT start filling content until the complete skeleton is verified.
238
+
239
+ ### Phase B: Content Filling (AFTER skeleton is complete)
240
+
241
+ Fill each `[TO BE FILLED]` placeholder with actual content:
242
+ - Module Domain → Business domain classification from module overview
243
+ - Module Purpose → Business purpose extracted from module overview
244
+ - Module Entities → Entity count and key entity names
245
+ - Module APIs → API/Interface count from module overview
246
+ - Module Detail Doc → Relative link to module-overview.md
247
+ - Flow Module Mapping → ✓ for involved modules, - for not involved
248
+ - Integration Data Exchanged → Data structures and formats exchanged
249
+ - Integration Protocol → HTTP/REST, gRPC, WebSocket, etc.
250
+
251
+ ---
252
+
211
253
  **⚠️ CRITICAL CONSTRAINTS (apply to Step 7a and 7b):**
212
254
  > 1. **FORBIDDEN: `create_file` for documents** — Document MUST be created by copying template (Step 7a) then filling with `search_replace` (Step 7b)
213
255
  > 2. **FORBIDDEN: Full-file rewrite** — Always use targeted `search_replace` on specific sections
@@ -179,7 +179,56 @@ ELSE:
179
179
  | One list page with filters | Entire reporting subsystem |
180
180
  | One form with validation | Multi-step wizard with 10+ steps |
181
181
 
182
- ### 4.2 Marking Existing vs New Features
182
+ ### 4.2 Section 3.5 Feature Details — Two-Phase Strategy
183
+
184
+ > **⚠️ CRITICAL: Two-Phase Strategy (Skeleton-First, Content-After)**
185
+ >
186
+ > This step MUST be executed in two phases to ensure consistent document structure.
187
+
188
+ #### Phase A: Skeleton Construction (BEFORE any content filling)
189
+
190
+ 1. Read PRD-TEMPLATE.md to identify the complete Feature Details structure
191
+ 2. Count the number of features from `{module_features}` input
192
+ 3. For Section 3.5 Feature Details, replicate the template's Feature block structure for EACH feature:
193
+ - Copy the EXACT template structure (all 6 sub-sections) from PRD-TEMPLATE.md
194
+ - Create `#### Feature 1: {feature_name}` through `#### Feature N: {feature_name}`
195
+ - Each feature block MUST contain these 6 sub-section headers (copied from template):
196
+ ```
197
+ **Requirement Description:**
198
+ [TO BE FILLED]
199
+
200
+ **Interaction Flow:**
201
+ [TO BE FILLED]
202
+
203
+ **Boundary Conditions:**
204
+ [TO BE FILLED]
205
+
206
+ **Exception Scenarios:**
207
+ [TO BE FILLED]
208
+
209
+ **Operation Flow Diagram:**
210
+ [TO BE FILLED]
211
+
212
+ **Operation Steps Detail:**
213
+ [TO BE FILLED]
214
+ ```
215
+ 4. Verify skeleton: confirm ALL features have ALL 6 sub-section headers before proceeding
216
+
217
+ > ⚠️ DO NOT start filling content until the complete skeleton is verified.
218
+
219
+ #### Phase B: Content Filling (AFTER skeleton is complete)
220
+
221
+ Fill each `[TO BE FILLED]` placeholder with actual content:
222
+ - **Requirement Description** → Business requirements in business language
223
+ - **Interaction Flow** → User interaction steps (numbered list)
224
+ - **Boundary Conditions** → Table with Condition Type | Scenario | Handling Rule
225
+ - **Exception Scenarios** → Bullet list of exception handling
226
+ - **Operation Flow Diagram** → Mermaid `graph LR` diagram showing operation flow
227
+ - **Operation Steps Detail** → Table: Step | Action | Expected Outcome | Exception Handling
228
+
229
+ ---
230
+
231
+ ### 4.3 Marking Existing vs New Features
183
232
 
184
233
  | Marker | Meaning |
185
234
  |--------|---------|
@@ -189,6 +238,13 @@ ELSE:
189
238
 
190
239
  ## Step 5: Task Granularity Check
191
240
 
241
+ > **⚠️ CRITICAL: Section 3.5 Feature Details Skeleton Verification**
242
+ >
243
+ > Before proceeding, verify the two-phase strategy was correctly applied:
244
+ > 1. Confirm ALL features in Section 3.5 have complete 6 sub-section skeletons
245
+ > 2. Confirm no `[TO BE FILLED]` placeholders remain unfilled
246
+ > 3. Confirm each feature has: Requirement Description, Interaction Flow, Boundary Conditions, Exception Scenarios, Operation Flow Diagram, Operation Steps Detail
247
+
192
248
  **After PRD completion, verify user story granularity:**
193
249
 
194
250
  **Appropriate Granularity (completable in one iteration):**
@@ -68,6 +68,53 @@ tools: Read, Write, Glob, Grep
68
68
 
69
69
  ## Step 3: Fill Module-Specific Content
70
70
 
71
+ > **⚠️ CRITICAL: Two-Phase Strategy (Skeleton-First, Content-After)**
72
+ >
73
+ > This step MUST be executed in two phases to ensure consistent document structure.
74
+
75
+ ### Phase A: Skeleton Construction (BEFORE any content filling)
76
+
77
+ 1. Read PRD-TEMPLATE.md to identify the complete section structure
78
+ 2. Count the number of features from `{module_features}` input
79
+ 3. For Section 3.5 Feature Details, replicate the template's Feature block structure for EACH feature:
80
+ - Copy the EXACT template structure (all 6 sub-sections) from PRD-TEMPLATE.md
81
+ - Create `#### Feature 1: {feature_name}` through `#### Feature N: {feature_name}`
82
+ - Each feature block MUST contain these 6 sub-section headers (copied from template):
83
+ ```
84
+ **Requirement Description:**
85
+ [TO BE FILLED]
86
+
87
+ **Interaction Flow:**
88
+ [TO BE FILLED]
89
+
90
+ **Boundary Conditions:**
91
+ [TO BE FILLED]
92
+
93
+ **Exception Scenarios:**
94
+ [TO BE FILLED]
95
+
96
+ **Operation Flow Diagram:**
97
+ [TO BE FILLED]
98
+
99
+ **Operation Steps Detail:**
100
+ [TO BE FILLED]
101
+ ```
102
+ 4. Verify skeleton: confirm ALL features have ALL 6 sub-section headers before proceeding
103
+
104
+ > ⚠️ DO NOT start filling content until the complete skeleton is verified.
105
+
106
+ ### Phase B: Content Filling (AFTER skeleton is complete)
107
+
108
+ Fill each `[TO BE FILLED]` placeholder with actual content:
109
+ - Requirement Description → Business requirements in business language
110
+ - Interaction Flow → User interaction steps (numbered list)
111
+ - Boundary Conditions → Table with Condition Type | Scenario | Handling Rule
112
+ - Exception Scenarios → Bullet list of exception handling
113
+ - Operation Flow Diagram → Mermaid `graph LR` diagram showing operation flow
114
+ - Operation Steps Detail → Table with Step | Action | Expected Outcome | Exception Handling
115
+
116
+ ---
117
+
71
118
  Fill each section using `search_replace`:
72
119
 
73
120
  ### 3.1 Section 1: Background & Goals
@@ -85,11 +132,17 @@ Fill each section using `search_replace`:
85
132
  - 3.4 Feature Breakdown: **REQUIRED** — Fill with `{module_features}` data:
86
133
  - Feature ID, Feature Name, Type (User Interaction / Backend Process), Scope, Description
87
134
  - Feature Dependencies table
88
- - 3.5 Feature Details: Detailed descriptions for each feature including:
135
+ - 3.5 Feature Details: **FOR EACH feature in module_features, fill ALL 6 sub-sections below:**
136
+
137
+ **Complete structure (MUST repeat for every Feature 1, 2, ... N):**
89
138
  - Requirement Description — **Business requirements in business language**
90
139
  - Interaction Flow — **User interaction steps in business terms**
91
140
  - Boundary Conditions table — **Business scenarios and business handling rules**
92
141
  - Exception Scenarios — **Business exception handling in business language**
142
+ - Operation Flow Diagram — **Mermaid `graph LR` showing business operation steps (REQUIRED for EVERY feature)**
143
+ - Operation Steps Detail — **Table: Step | Action | Expected Outcome | Business Exception Handling (REQUIRED for EVERY feature)**
144
+
145
+ > ⚠️ **CRITICAL**: ALL features MUST have the SAME 6-section structure. DO NOT skip Operation Flow Diagram or Operation Steps Detail for ANY feature. Check the PRD-TEMPLATE.md for the exact format.
93
146
 
94
147
  ### 3.4 Section 4: Non-functional Requirements
95
148
  - Module-specific performance, security, compatibility requirements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speccrew",
3
- "version": "0.6.21",
3
+ "version": "0.6.23",
4
4
  "description": "Spec-Driven Development toolkit for AI-powered IDEs",
5
5
  "author": "charlesmu99",
6
6
  "repository": {