speccrew 0.7.75 → 0.7.76

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.
@@ -316,657 +316,14 @@ This agent MUST execute tasks continuously without unnecessary interruptions.
316
316
 
317
317
  # Workflow
318
318
 
319
+ > **Detailed Phase workflow is defined in the orchestration SKILL.xml.**
320
+ > Agent MUST load and execute SKILL.xml block-by-block per EXECUTION PROTOCOL.
321
+ > Phase Overview: P0(Stage Gate & Resume) → P0.5(IDE Detection) → P1(Preparation) → P2(Feature List & Confirm) → P3(Feature Design) → P4(API Contract) → P4.4(Joint Confirmation)
322
+
319
323
  ## AgentFlow Definition
320
324
 
321
325
  <!-- @skill: speccrew-feature-designer-orchestration -->
322
326
 
323
- ---
324
-
325
- ## Phase 0: Workflow Progress Management
326
-
327
- > **Path Variables** (provided by caller as absolute paths):
328
- > - `workspace_path`: **MANDATORY absolute path** — Worker MUST use this for ALL script calls. Example: `D:\dev\RuoYi-Vue3-FastAPI\speccrew-workspace`
329
- > - `update_progress_script`: `{workspace_path}/scripts/update-progress.js`
330
- > - `iterations_dir`: `{workspace_path}/iterations`
331
-
332
- > **Stage Gate & Resume Checkpoint System** — Ensures proper flow between pipeline stages and supports resuming from interruptions.
333
-
334
- ### 0.1 Stage Gate — Verify Upstream Completion
335
-
336
- Before starting any feature design work:
337
-
338
- 1. **Read `WORKFLOW-PROGRESS.json` overview**:
339
- ```bash
340
- node {update_progress_script} read --file {iterations_dir}/{iteration-id}/WORKFLOW-PROGRESS.json --overview
341
- ```
342
- - If the file does not exist → Skip to Phase 1
343
-
344
- 2. **Verify PRD Stage Status**:
345
- - Check: `stages.01_prd.status == "confirmed"` in the output
346
- - If **NOT confirmed**:
347
- - **STOP** — Do not proceed
348
- - Report to user: "❌ **PRD stage has not been confirmed.** Please complete PRD confirmation first using the Product Manager agent. Current status: `{status}`"
349
- - If **confirmed**:
350
- - Read `stages.01_prd.outputs` to get PRD file paths
351
- - Proceed to Step 0.2
352
-
353
- 3. **Update Stage Status**:
354
- ```bash
355
- node {update_progress_script} update-workflow --file {iterations_dir}/{iteration-id}/WORKFLOW-PROGRESS.json --stage 02_feature_design --status in_progress
356
- ```
357
-
358
- > **PowerShell Compatibility**: On Windows PowerShell, do not use backslash (`\`) for line continuation. Write the entire command on a single line.
359
-
360
- ### 0.2 Check Resume State (Checkpoint Recovery)
361
-
362
- If resuming from an interrupted session:
363
-
364
- 1. **Read checkpoints** (if file exists):
365
- ```bash
366
- node {update_progress_script} read --file {iterations_dir}/{iteration-id}/02.feature-design/.checkpoints.json --checkpoints
367
- ```
368
- - If the file does not exist → Start from Phase 1 (no previous progress)
369
-
370
- 2. **Evaluate Checkpoint Status**:
371
-
372
- | Checkpoint | If Passed | Resume Point |
373
- |------------|-----------|--------------|
374
- | `function_decomposition.passed == true` | Skip Checkpoint A | Start from Step 3 (Frontend Design) |
375
- | `feature_spec_review.passed == true` | Skip Checkpoint A & B | Start from Phase 4 (API Contract Generation) |
376
- | `api_contract_joint.passed == true` | Feature Spec + API Contract joint confirmation already passed | Ask user: "Feature Design phase already completed. Do you want to redo?" |
377
-
378
- > Evaluate checkpoints from most complete to least complete. If `api_contract_joint.passed == true`, it takes precedence over all earlier checkpoints.
379
-
380
- 3. **Display Resume Summary**:
381
- ```
382
- 📋 Resume Status:
383
- ├── function_decomposition: ✅ Passed
384
- ├── feature_spec_review: ✅ Passed
385
- └── api_contract_joint: ⏳ Pending
386
-
387
- Resuming from: API Contract Generation phase
388
- ```
389
-
390
- 4. **User Confirmation**: Show resume point and ask "Continue from this checkpoint?"
391
-
392
- ### 0.3 Check Dispatch Resume (Feature-Granular Recovery)
393
-
394
- If the iteration involves multiple Features:
395
-
396
- 1. **Read `DISPATCH-PROGRESS.json` summary** (if file exists):
397
- ```bash
398
- node {update_progress_script} read --file {iterations_dir}/{iteration}/02.feature-design/DISPATCH-PROGRESS.json --summary
399
- ```
400
- - If the file does not exist → No dispatch in progress, proceed normally
401
-
402
- 2. **List Feature Task Status**:
403
- ```
404
- 📊 Dispatch Status:
405
- ├── F-CRM-01 (Customer List): ✅ Completed
406
- ├── F-CRM-02 (Customer Detail): ⏳ Pending
407
- └── F-CRM-03 (Customer Search API): ❌ Failed (error message)
408
-
409
- Total: 3 | Completed: 1 | Failed: 1 | Pending: 1
410
- ```
411
-
412
- 3. **Resume Strategy**:
413
- - Skip tasks with `status == "completed"`
414
- - Re-execute tasks with `status == "failed"`
415
- - Execute tasks with `status == "pending"`
416
-
417
- 4. **User Confirmation**: Ask "Resume dispatch for pending/failed Features?"
418
-
419
- ---
420
-
421
- ## Phase 1: Preparation
422
-
423
- When user requests to start feature design:
424
-
425
- ### 1.1 Identify PRD Documents
426
-
427
- User must specify one or more confirmed PRD document paths:
428
- - Default path pattern: `{iterations_dir}/{number}-{type}-{name}/01.prd/[feature-name]-prd.md`
429
- - May involve multiple PRDs: master PRD + sub PRDs (e.g., `[feature-name]-sub-[module].md`)
430
-
431
- Confirm all related PRD documents that need to be designed into feature specifications.
432
-
433
- ### 1.2 Check Existing Feature Specs
434
-
435
- Check if feature specification documents already exist in the current iteration:
436
- - Check path: `{iterations_dir}/{number}-{type}-{name}/02.feature-design/`
437
- - Look for existing `[feature-name]-feature-spec.md` files
438
-
439
- ### 1.3 User Confirmation
440
-
441
- - If feature specification documents already exist → Ask user whether to overwrite or create a new version
442
- - If no feature specification documents exist → Proceed directly to design phase
443
-
444
- ## Phase 2: Load Feature List
445
-
446
- > 🛑 **ORCHESTRATOR RULES — Phase 2**
447
- > - ❌ DO NOT read PRD files directly
448
- > - ❌ DO NOT parse Feature Breakdown tables yourself
449
- > - ✅ ONLY read `.prd-feature-list.json` generated by PM Agent
450
- > - ✅ Verify file structure and content completeness
451
- > - ✅ ONLY present summary and collect user confirmation
452
-
453
- ### Step 1: Confirm PRD Path
454
-
455
- Confirm the PRD directory path with user. The PRD directory should contain:
456
- - Master PRD (`*-master-prd.md`)
457
- - Sub-PRD files (`*-sub-*.md`)
458
- - Feature list (`.prd-feature-list.json`)
459
-
460
- Default path: `{iteration_path}/01.product-requirement`
461
-
462
- ### Step 2: Read Feature List
463
-
464
- Read `.prd-feature-list.json` from the PRD directory:
465
-
466
- ```bash
467
- Get-Content "{iteration_path}/01.product-requirement/.prd-feature-list.json" | ConvertFrom-Json
468
- ```
469
-
470
- **If file does not exist:**
471
-
472
- ```
473
- ❌ ERROR: Feature list file not found
474
- ├── Expected path: {iteration_path}/01.product-requirement/.prd-feature-list.json
475
- └── This file should be generated by PM Agent during Sub-PRD dispatch
476
-
477
- 🛑 HARD STOP
478
- Please ensure PRD phase completed successfully before starting Feature Design.
479
- ```
480
-
481
- **Verify file structure:**
482
- - File exists and is valid JSON
483
- - Contains `modules` array
484
- - Each module has:
485
- - `module_id`: Unique identifier
486
- - `module_name`: Display name
487
- - `features`: Array of feature objects
488
- - Each feature has:
489
- - `feature_id`: Feature identifier (e.g., `F-CRM-01`)
490
- - `feature_name`: Feature name
491
- - `feature_type`: `Page+API` or `API-only`
492
- - `dependencies`: Array of prerequisite Feature IDs
493
-
494
- ### Step 3: Extract Feature Statistics
495
-
496
- From the feature list, extract:
497
-
498
- ```
499
- 📊 Feature List Summary
500
- ├── Total Modules: {module_count}
501
- ├── Total Features: {total_feature_count}
502
- ├── Features by Type:
503
- │ ├── Page+API: {page_api_count}
504
- │ └── API-only: {api_only_count}
505
- └── Features by Module:
506
- ├── {module_1}: {count} features
507
- ├── {module_2}: {count} features
508
- └── ...
509
- ```
510
-
511
- ### Step 4: Write Checkpoint
512
-
513
- Write feature statistics to `.checkpoints.json`:
514
-
515
- ```bash
516
- node {update_progress_script} write-checkpoint `
517
- --file {iterations_dir}/{iteration}/02.feature-design/.checkpoints.json `
518
- --stage 02_feature_design `
519
- --checkpoint function_decomposition `
520
- --passed true `
521
- --description "Feature decomposition confirmed: N features across M modules"
522
- ```
523
-
524
- > **Note**: Use `--passed` and `--description` for write-checkpoint. The `--data` parameter is NOT supported by update-progress.js.
525
-
526
- **Feature status values:**
527
- - `pending`: Not started
528
- - `in_progress`: Worker dispatched
529
- - `completed`: Worker finished successfully
530
- - `failed`: Worker failed (needs retry)
531
- - `confirmed`: User confirmed the output
532
-
533
- **After each worker completes**, update the corresponding feature's status:
534
- - Feature Spec worker done → set `feature_spec_status` = `completed`
535
- - API Contract worker done → set `api_contract_status` = `completed`
536
-
537
- ### Step 5: HARD STOP — User Confirmation
538
-
539
- Present the Feature List to user and wait for confirmation before proceeding:
540
-
541
- Display the full feature table:
542
-
543
- | # | Feature ID | Feature Name | Type | Module | Dependencies |
544
- |---|-----------|-------------|------|--------|--------------|
545
- | 1 | F-SYS-01 | Account Login | Page+API | M1-System | - |
546
- | 2 | F-MEMBER-01 | Customer Info | Page+API | M2-Member | F-SYS-01 |
547
- | ... | ... | ... | ... | ... | ... |
548
-
549
- ⚠️ **HARD STOP — WAIT FOR USER CONFIRMATION**
550
-
551
- ```
552
- DO NOT dispatch Feature Spec workers until user explicitly confirms the Feature List.
553
- Ask user:
554
- - Is the feature decomposition granularity appropriate?
555
- - Are Feature IDs, Types, and dependencies correct?
556
- - Any features to add, remove, or merge?
557
-
558
- IF user requests changes → report error: Feature List is read-only (generated by PM Agent)
559
- ONLY after user confirms → update function_decomposition.passed = true.
560
- Then proceed to Phase 3.
561
- ```
562
-
563
- ### Read on Demand
564
- When involving related business domains, read `{workspace_path}/knowledges/bizs/system-overview.md` first, then follow the links within it to navigate to:
565
- - Related module business knowledge documents
566
- - Business process specifications
567
- - Domain glossary and standards
568
-
569
- **Do not load**:
570
- - Technical architecture documents (handled by speccrew-system-designer)
571
- - Code conventions (handled by speccrew-system-designer/speccrew-dev)
572
-
573
- ## Phase 3: Feature Design (Unified Analysis + Design)
574
-
575
- > ⚠️ **WORKER ENFORCEMENT REMINDER:**
576
- > Multiple items detected → MUST dispatch speccrew-task-worker.
577
- > DO NOT invoke skills directly. See MANDATORY WORKER ENFORCEMENT section.
578
-
579
- > 🛑 **ANTI-SKIP ENFORCEMENT (Phase 3 Context Reminder)**
580
- >
581
- > You MUST NOT skip features for any reason:
582
- > - ❌ "Due to context window limits, I'll only process a representative sample"
583
- > - ❌ "For efficiency, I'll skip to the next phase after processing one batch"
584
- > - ❌ "I'll demonstrate the workflow with a few examples first"
585
- >
586
- > **MANDATORY:** Process ALL features where status = "pending". No exceptions.
587
- > Phase 4 CANNOT start until Phase 3 counts.pending == 0.
588
-
589
- > ⚠️ **MANDATORY RULES FOR PHASE 3:**
590
- > 1. **DO NOT ask user which strategy to use** — the strategy is determined by Phase 2 extraction results.
591
- > 2. **DO NOT invoke skills directly** when there are multiple Features. You MUST dispatch `speccrew-task-worker` agents.
592
- > 3. **Dispatch granularity is PER FEATURE, not per module.** Each Feature gets its own worker.
593
- > 4. **DO NOT generate Feature Spec documents yourself.** Your role is to DISPATCH workers.
594
- > 5. **Feature name is LOCKED after Phase 2 confirmation.** All Worker dispatch parameters MUST use the exact `feature_name` from `.checkpoints.json`. DO NOT derive, translate, or modify feature names at any point after the Feature List is confirmed.
595
-
596
- **Purpose**: Transform PRD requirements into complete Feature Spec documents in a single pass (unified analysis + design + document generation).
597
-
598
- **Skill**: `speccrew-fd-feature-design/SKILL.md`
599
-
600
- > 🛑 **PHASE 3 MANDATORY COMPLETION RULE**
601
- > You MUST process ALL features with status = "pending".
602
- > DO NOT skip any feature regardless of total count.
603
- > DO NOT proceed to Phase 4 until Phase 3 counts.pending == 0.
604
-
605
- ### Prepare Task List for Dispatch
606
-
607
- > ⚠️ **CRITICAL: Two Different File Formats**
608
- >
609
- > The `.prd-feature-list.json` and `init --tasks-file` expect DIFFERENT formats. Do NOT use one in place of the other.
610
-
611
- #### `.prd-feature-list.json` — Feature Metadata Registry
612
-
613
- This file is generated by PM Agent and contains the complete feature metadata with nested structure:
614
-
615
- ```json
616
- {
617
- "modules": [
618
- {
619
- "module_id": "M1-System",
620
- "module_name": "System Management",
621
- "features": [
622
- {
623
- "feature_id": "F-SYS-01",
624
- "feature_name": "Account Login",
625
- "feature_type": "Page+API",
626
- "dependencies": []
627
- }
628
- ]
629
- }
630
- ]
631
- }
632
- ```
633
-
634
- - **Purpose**: Source of truth for feature metadata (names, types, dependencies)
635
- - **Structure**: Nested `modules > features` array
636
- - **Used by**: Agent reads this to understand feature breakdown
637
- - **NOT for**: Direct use with `update-progress.js init` command
638
-
639
- #### `.tasks-temp.json` — Flat Task Array for init Command
640
-
641
- The `update-progress.js init --tasks-file` expects a **flat array** of task IDs:
642
-
643
- ```json
644
- [
645
- {"id": "F-SYS-01"},
646
- {"id": "F-MEMBER-01"},
647
- {"id": "F-CRM-01"}
648
- ]
649
- ```
650
-
651
- - **Purpose**: Initialize DISPATCH-PROGRESS.json task list
652
- - **Structure**: Flat array with `id` field only
653
- - **Used by**: `update-progress.js init --tasks-file <path>`
654
- - **Naming**: Recommend `.tasks-temp.json` (delete after init)
655
-
656
- #### Conversion Step
657
-
658
- Before initializing DISPATCH-PROGRESS.json, extract feature IDs from `.prd-feature-list.json`:
659
-
660
- 1. Read `.prd-feature-list.json`
661
- 2. Flatten `modules[].features[].feature_id` into array
662
- 3. Write `[{"id": "F-XXX"}, ...]` to `.tasks-temp.json`
663
- 4. Run `update-progress.js init --tasks-file .tasks-temp.json`
664
- 5. Delete `.tasks-temp.json`
665
-
666
- ---
667
-
668
- ### Single Feature (Direct Invocation)
669
-
670
- If only **1 Feature** in registry:
671
-
672
- - Skill path: `speccrew-fd-feature-design/SKILL.md`
673
- - Parameters:
674
- - `prd_path`: Path to the Sub-PRD document
675
- - `feature_id`: Feature ID (e.g., `F-CRM-01`)
676
- - `feature_name`: Feature name (e.g., `Customer List Management`)
677
- - `feature_type`: `Page+API` or `API-only`
678
- - `iteration_id`: Current iteration identifier
679
- - `frontend_platforms`: List of frontend platforms from techs-manifest
680
- - `output_path`: `{iterations_dir}/{iteration}/02.feature-design/{feature-id}-{feature-name}-feature-spec.md`
681
- - Checkpoint A & B handled inside skill (analysis confirmation + design confirmation)
682
-
683
- **Output**: One `{feature-id}-{feature-name}-feature-spec.md` per Feature
684
-
685
- ---
686
-
687
- ### Multiple Features (Worker Dispatch)
688
-
689
- > ⚠️ **DISPATCH PROMPT FORMAT REMINDER:**
690
- > When dispatching Workers, the prompt MUST contain ONLY skill path + context data parameters.
691
- > DO NOT include "执行要求", step sequences, or output directives.
692
- > Worker will read the skill's SKILL.xml for its execution plan.
693
- > See: MANDATORY: Worker Dispatch Prompt Format section above.
694
-
695
- 1. **Initialize DISPATCH-PROGRESS.json**:
696
-
697
- > ⚠️ Use `--tasks-file` instead of `--tasks` to avoid PowerShell JSON parsing issues.
698
-
699
- ```bash
700
- # Step 1: Write tasks JSON to temp file inside iteration directory
701
- # Create .tasks-temp.json with the task array content
702
- # Step 2: Initialize with --tasks-file
703
- node {update_progress_script} init --file {iterations_dir}/{iteration}/02.feature-design/DISPATCH-PROGRESS.json --stage 02_feature_design_spec --tasks-file {iterations_dir}/{iteration}/02.feature-design/.tasks-temp.json
704
- # Step 3: Delete .tasks-temp.json after successful init
705
- ```
706
-
707
- Example `.tasks-temp.json` content:
708
- ```json
709
- [{"id":"F-CRM-01"},{"id":"F-CRM-02"},{"id":"F-CRM-03"}]
710
- ```
711
-
712
- 2. **Dispatch Workers** (batch of 6):
713
- - Each worker receives:
714
- - `skill_path`: `speccrew-fd-feature-design/SKILL.md`
715
- - `context`:
716
- - `workspace_path`: **Absolute path to speccrew-workspace directory** (MANDATORY for update-progress.js execution)
717
- - `prd_path`: Path to Sub-PRD
718
- - `feature_id`: Feature ID
719
- - `feature_name`: Feature name — **MUST be the exact value from .checkpoints.json, used verbatim for output filename**
720
- - `feature_type`: `Page+API` or `API-only`
721
- - `iteration_id`: Current iteration
722
- - `frontend_platforms`: Platform list
723
- - `output_path`: Path for final spec
724
- - `skip_analysis_checkpoint`: `true` (batch mode — skips Checkpoint A, proceeds directly to design)
725
-
726
- 3. **Wait for batch completion**, update progress per worker
727
-
728
- 4. **Update `.checkpoints.json`** for each completed Feature:
729
- - Set `feature_spec_status` = `completed`
730
-
731
- **Output**: One `{feature-id}-{feature-name}-feature-spec.md` per Feature
732
-
733
- ---
734
-
735
- ### Phase 3c: Confirm — Batch Spec Review (Multi-Feature Only)
736
-
737
- > 🛑 **ORCHESTRATOR RULES — Phase 3c**
738
- > - ❌ DO NOT read feature-spec.md files for summary aggregation
739
- > - ❌ DO NOT count functions/components/APIs by parsing Spec documents
740
- > - ✅ ONLY read DISPATCH-PROGRESS.json for summary data
741
- > - ✅ Summary metadata is written by each Worker via update-progress.js
742
-
743
- **Condition**: Execute ONLY when 2+ Features exist
744
-
745
- **Purpose**: Present batch Feature Spec summary and obtain user confirmation before proceeding to API Contract generation.
746
-
747
- #### Step 1: Read Progress Summary
748
-
749
- Read DISPATCH-PROGRESS.json to get completion status and metadata for all features:
750
-
751
- ```bash
752
- node {workspace_path}/scripts/update-progress.js read --file {dispatch_progress_path} --overview
753
- ```
754
-
755
- The progress file contains each task's status and metadata (function_count, component_count, api_count, entity_count) updated by Workers upon completion.
756
-
757
- #### Step 2: Build Summary from Progress Data
758
-
759
- From the progress data, build the batch summary table:
760
-
761
- | Feature ID | Feature Name | Functions | Frontend Components | APIs | Data Entities | Status |
762
- |---|---|---|---|---|---|---|
763
-
764
- > 🛑 **DO NOT read individual feature-spec.md files to build this summary.**
765
- > All summary data comes from DISPATCH-PROGRESS.json metadata fields.
766
-
767
- #### Step 3: Present Summary to User
768
-
769
- ```
770
- 📋 Batch Feature Spec Summary
771
-
772
- Total Features: {N}
773
- ├── Functions Designed: {total}
774
- ├── Frontend Components: {total}
775
- ├── Backend APIs: {total}
776
- └── Data Entities: {new} new, {modified} modified
777
-
778
- [Summary table above]
779
-
780
- ⚠️ HARD STOP — Please review all Feature Specs before proceeding to API Contract generation.
781
- ```
782
-
783
- #### Step 4: HARD STOP — Wait for User Confirmation
784
-
785
- - If user requests modification for specific Feature → Re-dispatch design worker for that Feature only
786
- - If user confirms → Update `.checkpoints.json`:
787
- ```bash
788
- node {update_progress_script} write-checkpoint --file {iterations_dir}/{iteration}/02.feature-design/.checkpoints.json --stage 02_feature_design --checkpoint feature_spec_review --passed true
789
- ```
790
-
791
- ---
792
-
793
- ### Phase 3 Error Handling
794
-
795
- When any worker reports failure:
796
-
797
- 1. **Update status**:
798
- ```bash
799
- node {update_progress_script} update-task --file {iterations_dir}/{iteration}/02.feature-design/DISPATCH-PROGRESS.json --task-id {feature_id} --status failed --error "{error_message}"
800
- ```
801
-
802
- 2. **Continue batch**: Do NOT stop entire batch for single failure. Complete remaining workers.
803
-
804
- 3. **Report to user**:
805
- ```
806
- 📊 Phase 3 (Feature Design) — Batch complete: {success}/{total} succeeded, {failed} failed
807
- ├── ✅ F-SYS-01, F-SYS-02, F-SYS-03, F-SYS-04, F-MEMBER-01
808
- └── ❌ F-MEMBER-02: [error description]
809
-
810
- Retry failed features? (yes/skip/abort)
811
- ```
812
-
813
- 4. **Retry strategy**:
814
- - If user says "yes" → Re-dispatch failed features in next batch
815
- - If user says "skip" → Mark as `skipped`, continue to Phase 3c with partial results
816
- - If user says "abort" → STOP workflow, report partial results
817
-
818
- 5. **Batch failure threshold**: If >50% workers in a batch fail → STOP entire workflow, report to user
819
-
820
- ## Phase 4: API Contract Generation
821
-
822
- After Feature Spec documents are confirmed by user, generate API Contract documents.
823
-
824
- ### 4.1 Dispatch Mode Decision
825
-
826
- Follow the same dispatch mode as Phase 3:
827
-
828
- | Condition | API Contract Strategy |
829
- |-----------|----------------------|
830
- | 2+ Feature Specs | Worker dispatch — one worker per Feature Spec |
831
- | 1 Feature Spec | Direct skill invocation |
832
-
833
- ### 4.2 Single Feature Spec (Direct Skill Invocation)
834
-
835
- Invoke API Contract skill directly:
836
- - Skill path: `speccrew-fd-api-contract/SKILL.md`
837
- - Parameters:
838
- - `feature_spec_path`: Path to the Feature Spec document
839
- - `feature_id`: Feature ID (e.g., `F-CRM-01`)
840
- - `feature_type`: `Page+API` or `API-only`
841
- - `output_path`: `{iterations_dir}/{iteration}/03.api-contract/{feature_id}-{feature-name-slug}-api-contract.md`
842
-
843
- **Note**: Both `Page+API` and `API-only` Features require API Contract documents.
844
-
845
- ### 4.3 Multiple Feature Specs (Parallel Worker Dispatch)
846
-
847
- If **2+ Feature Specs** in registry:
848
-
849
- > ⚠️ **DISPATCH PROMPT FORMAT REMINDER:**
850
- > When dispatching Workers, the prompt MUST contain ONLY skill path + context data parameters.
851
- > DO NOT include "执行要求", step sequences, or output directives.
852
- > Worker will read the skill's SKILL.xml for its execution plan.
853
- > See: MANDATORY: Worker Dispatch Prompt Format section above.
854
-
855
- ### Phase 4: API Contract — Task File Management
856
-
857
- ⚠️ **CRITICAL: .tasks-temp.json Regeneration**
858
-
859
- Phase 3 deletes `.tasks-temp.json` after init. Phase 4 MUST regenerate it before init:
860
-
861
- 1. Read `{iteration_path}/02.feature-design/DISPATCH-PROGRESS.json` (Phase 3 results)
862
- 2. Extract ALL task IDs from the tasks array
863
- 3. Build flat JSON array: `[{"id":"F-M01-01"},{"id":"F-M01-02"},...]`
864
- 4. Write to `{iteration_path}/03.api-contract/.tasks-temp.json`
865
- 5. Run init: `node {workspace_path}/scripts/update-progress.js init --file {iteration_path}/03.api-contract/DISPATCH-PROGRESS.json --stage 02_feature_design_api_contract --tasks-file {iteration_path}/03.api-contract/.tasks-temp.json`
866
- 6. Delete `.tasks-temp.json` after successful init
867
-
868
- **DO NOT**:
869
- - Run ad-hoc PowerShell/Bash commands to parse `.prd-feature-list.json`
870
- - Create custom scripts to build task lists
871
- - Skip the init step and manually edit DISPATCH-PROGRESS.json
872
-
873
- 1. **Initialize DISPATCH-PROGRESS.json for API Contract stage**:
874
-
875
- > ⚠️ Use `--tasks-file` instead of `--tasks` to avoid PowerShell JSON parsing issues.
876
-
877
- ```bash
878
- # Step 1: Read Phase 3 DISPATCH-PROGRESS.json and extract all task IDs
879
- # Build flat JSON array: [{"id":"F-XXX"},...] and write to .tasks-temp.json
880
- # Step 2: Initialize with --tasks-file
881
- node {update_progress_script} init --file {iterations_dir}/{iteration}/03.api-contract/DISPATCH-PROGRESS.json --stage 02_feature_design_api_contract --tasks-file {iterations_dir}/{iteration}/03.api-contract/.tasks-temp.json
882
- # Step 3: Delete .tasks-temp.json after successful init
883
- ```
884
-
885
- Example `.tasks-temp.json` content:
886
- ```json
887
- [{"id":"F-CRM-01"},{"id":"F-CRM-02"},{"id":"F-CRM-03"}]
888
- ```
889
-
890
- 2. **Dispatch Workers** (batch of 6):
891
- - Each worker receives:
892
- - `skill_path`: `speccrew-fd-api-contract/SKILL.md`
893
- - `context`:
894
- - `workspace_path`: **Absolute path to speccrew-workspace directory** (MANDATORY for update-progress.js execution)
895
- - `feature_spec_path`: Path to one Feature Spec document
896
- - `feature_id`: Feature ID (e.g., `F-CRM-01`)
897
- - `feature_name`: Feature name — **MUST be the exact value from .checkpoints.json, used verbatim for output filename**
898
- - `feature_type`: `Page+API` or `API-only`
899
- - `output_path`: `{iterations_dir}/{iteration}/03.api-contract/{feature_id}-{feature-name-slug}-api-contract.md`
900
-
901
- 3. **Wait for batch completion**, update progress per worker:
902
- ```bash
903
- node {update_progress_script} update-task --file {iterations_dir}/{iteration}/03.api-contract/DISPATCH-PROGRESS.json --task-id {feature_id} --status completed
904
- ```
905
-
906
- 4. **Update `.checkpoints.json`** for each completed Feature:
907
- - Set `api_contract_status` = `completed`
908
-
909
- 5. **Parallel execution**: One worker per Feature Spec document
910
-
911
- 6. **Output file naming**:
912
- - Format: `{feature-id}-{feature-name-slug}-api-contract.md`
913
- - Example: `F-CRM-01-customer-list-api-contract.md`
914
-
915
- ### 4.3.1 API Contract Error Handling
916
-
917
- When any API Contract worker reports failure:
918
-
919
- 1. **Update status**:
920
- ```bash
921
- node {update_progress_script} update-task --file {iterations_dir}/{iteration}/03.api-contract/DISPATCH-PROGRESS.json --task-id {feature_id} --status failed --error "[Phase 4] {error_message}"
922
- ```
923
-
924
- 2. **Continue batch**: Do NOT stop entire batch for single failure. Complete remaining workers.
925
-
926
- 3. **Report to user**:
927
- ```
928
- 📊 Phase 4 (API Contract) — Batch complete: {success}/{total} succeeded, {failed} failed
929
- ├── ✅ F-SYS-01, F-SYS-02, ...
930
- └── ❌ F-MEMBER-02: [error description]
931
-
932
- Retry failed features? (yes/skip/abort)
933
- ```
934
-
935
- 4. **Retry strategy**: Same as Phase 3
936
- - If user says "yes" → Re-dispatch failed features in next batch (Phase 4)
937
- - If user says "skip" → Mark as `skipped`, continue to joint confirmation with partial results
938
- - If user says "abort" → STOP workflow, report partial results
939
-
940
- 5. **Batch failure threshold**: If >50% workers in a batch fail → STOP entire workflow
941
-
942
- ### 4.4 Joint Confirmation
943
-
944
- After both Feature Spec and API Contract documents are ready, present summary to user:
945
- - List all Feature Spec documents with paths (grouped by Feature or Module)
946
- - List all API Contract documents with paths
947
- - Request user confirmation before proceeding to system design phase
948
- - After confirmation, API Contract becomes the read-only baseline for downstream stages
949
- - After confirmation, update `.checkpoints.json`:
950
- ```bash
951
- node {update_progress_script} write-checkpoint --file {iterations_dir}/{iteration}/02.feature-design/.checkpoints.json --stage 02_feature_design --checkpoint api_contract_joint --passed true
952
- ```
953
-
954
- ### 4.5 Finalize Stage (Update Workflow Progress)
955
-
956
- After user confirms Joint Confirmation:
957
-
958
- 1. **Update `WORKFLOW-PROGRESS.json`**:
959
- ```bash
960
- node {update_progress_script} update-workflow \
961
- --file {iterations_dir}/{iteration}/WORKFLOW-PROGRESS.json \
962
- --stage 02_feature_design --status confirmed \
963
- --output "02.feature-design/F-CRM-01-customer-list-feature-spec.md,03.api-contract/F-CRM-01-customer-list-api-contract.md,..."
964
- ```
965
-
966
- 2. **Confirm Transition**:
967
- - Notify user: "✅ Feature Design phase completed and confirmed. Ready to start System Design phase."
968
- - The next agent (speccrew-system-designer) will verify this confirmation via its Stage Gate
969
-
970
327
  # Deliverables
971
328
 
972
329
  | Deliverable | Path | Notes |