mindsystem-cc 3.12.0 → 3.13.1

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.
Files changed (33) hide show
  1. package/agents/ms-consolidator.md +4 -4
  2. package/agents/ms-executor.md +19 -351
  3. package/agents/ms-flutter-code-quality.md +7 -6
  4. package/agents/ms-mock-generator.md +51 -138
  5. package/agents/ms-plan-checker.md +170 -175
  6. package/agents/ms-plan-writer.md +120 -115
  7. package/agents/ms-verifier.md +22 -18
  8. package/commands/ms/check-phase.md +3 -3
  9. package/commands/ms/execute-phase.md +8 -6
  10. package/commands/ms/plan-phase.md +4 -3
  11. package/commands/ms/verify-work.md +7 -7
  12. package/mindsystem/references/goal-backward.md +10 -25
  13. package/mindsystem/references/mock-patterns.md +149 -240
  14. package/mindsystem/references/plan-format.md +326 -247
  15. package/mindsystem/references/scope-estimation.md +29 -24
  16. package/mindsystem/references/tdd-execution.md +70 -0
  17. package/mindsystem/references/tdd.md +53 -194
  18. package/mindsystem/templates/UAT.md +16 -16
  19. package/mindsystem/templates/phase-prompt.md +51 -367
  20. package/mindsystem/templates/roadmap.md +1 -1
  21. package/mindsystem/templates/verification-report.md +2 -2
  22. package/mindsystem/workflows/adhoc.md +16 -21
  23. package/mindsystem/workflows/execute-phase.md +71 -49
  24. package/mindsystem/workflows/execute-plan.md +183 -1054
  25. package/mindsystem/workflows/plan-phase.md +47 -38
  26. package/mindsystem/workflows/verify-phase.md +16 -20
  27. package/mindsystem/workflows/verify-work.md +54 -67
  28. package/package.json +1 -1
  29. package/scripts/update-state.sh +59 -0
  30. package/scripts/validate-execution-order.sh +102 -0
  31. package/skills/flutter-code-quality/SKILL.md +4 -3
  32. package/mindsystem/templates/summary.md +0 -293
  33. package/mindsystem/workflows/generate-mocks.md +0 -261
@@ -36,7 +36,7 @@ PLAN.md IS the prompt that Claude executes. Plans are grouped into execution wav
36
36
 
37
37
  **Vertical slices over horizontal layers:** Group by feature (User: model + API + UI) not by type (all models → all APIs → all UIs).
38
38
 
39
- **Explicit dependencies:** Every plan declares what it needs (`depends_on`) and what it touches (`files_modified`). Empty dependencies = parallel candidate.
39
+ **Explicit dependencies:** EXECUTION-ORDER.md centralizes dependency and parallelism tracking. Plans with no dependencies = parallel candidates.
40
40
 
41
41
  **Secure by design:** Assume hostile input on every boundary. Validate, parameterize, authenticate, fail closed.
42
42
 
@@ -120,7 +120,7 @@ grep -l "status: diagnosed" "$PHASE_DIR"/*-UAT.md 2>/dev/null
120
120
 
121
121
  **2. Parse gaps:**
122
122
 
123
- **From VERIFICATION.md** (if exists): Parse `gaps:` from YAML frontmatter.
123
+ **From VERIFICATION.md** (if exists): Parse gaps from `## Gaps Summary` section (markdown format with `### Critical Gaps` and `### Non-Critical Gaps` subsections).
124
124
 
125
125
  **From UAT.md** (if exists with status: diagnosed): Parse gaps from `## Gaps` section (YAML format).
126
126
 
@@ -154,40 +154,49 @@ Cluster related gaps by:
154
154
  - Same concern (fetch + render → one "wire frontend" plan)
155
155
  - Dependency order (can't wire if artifact is stub → fix stub first)
156
156
 
157
- **6. Create gap closure tasks:**
157
+ **6. Create gap closure changes:**
158
158
 
159
- For each gap:
160
- ```xml
161
- <task name="{fix_description}" type="auto">
162
- <files>{artifact.path}</files>
163
- <action>
164
- {For each item in gap.missing:}
165
- - {missing item}
166
-
167
- Reference existing code: {from SUMMARYs}
168
- Gap reason: {gap.reason}
169
- </action>
170
- <verify>{How to confirm gap is closed}</verify>
171
- <done>{Observable truth now achievable}</done>
172
- </task>
159
+ For each gap, create a markdown change subsection:
160
+
161
+ ```markdown
162
+ ### N. {Fix description}
163
+ **Files:** `{artifact.path}`
164
+
165
+ {For each item in gap.missing:}
166
+ - {missing item}
167
+
168
+ Reference existing code: {from SUMMARYs}
169
+ Gap reason: {gap.reason}
173
170
  ```
174
171
 
175
172
  **7. Write PLAN.md files:**
176
173
 
177
- Use standard template but note gap closure context:
174
+ Use pure markdown plan format with gap closure context:
178
175
 
179
- ```yaml
180
- ---
181
- phase: XX-name
182
- plan: NN # Sequential after existing
183
- type: execute
184
- wave: 1 # Gap closures typically single wave
185
- depends_on: [] # Usually independent of each other
186
- files_modified: [...]
187
- gap_closure: true # Flag for tracking
188
- ---
176
+ ```markdown
177
+ # Plan NN: {Gap closure description}
178
+
179
+ **Subsystem:** {subsystem} | **Type:** execute
180
+
181
+ ## Context
182
+ Gap closure for phase XX. Addresses gaps identified by verification.
183
+
184
+ ## Changes
185
+
186
+ ### 1. {Fix description}
187
+ **Files:** `{artifact.path}`
188
+
189
+ {Implementation details from gap.missing items}
190
+
191
+ ## Verification
192
+ - {How to confirm gap is closed}
193
+
194
+ ## Must-Haves
195
+ - [ ] {Observable truth now achievable}
189
196
  ```
190
197
 
198
+ Also create or update EXECUTION-ORDER.md to include gap closure plans (typically single wave, independent of each other).
199
+
191
200
  **9. Present gap closure summary:**
192
201
 
193
202
  ```markdown
@@ -432,7 +441,7 @@ cat .planning/phases/XX-name/${PHASE}-DESIGN.md 2>/dev/null
432
441
  **If DESIGN.md exists:**
433
442
  - Tasks reference specific screens/components from design
434
443
  - Verification criteria include design verification items
435
- - must_haves include design-specified observable behaviors
444
+ - Must-Haves include design-specified observable behaviors
436
445
  - Task actions specify exact values (colors, spacing) from design
437
446
 
438
447
  **If none exist:** Suggest /ms:research-phase for niche domains, /ms:discuss-phase for simpler domains, or proceed with roadmap only.
@@ -573,10 +582,10 @@ Task(
573
582
  The subagent handles:
574
583
  - Building dependency graph from needs/creates
575
584
  - Assigning wave numbers
576
- - Grouping tasks into plans (2-3 per plan)
577
- - Deriving must_haves (goal-backward)
585
+ - Grouping tasks into plans (2-3 changes per plan)
586
+ - Deriving Must-Haves (goal-backward)
578
587
  - Estimating scope, splitting if needed
579
- - Writing PLAN.md files
588
+ - Writing PLAN.md files + EXECUTION-ORDER.md
580
589
  - Git commit
581
590
  - Calculating risk score
582
591
  </step>
@@ -744,10 +753,10 @@ Tasks are instructions for Claude, not Jira tickets.
744
753
  - [ ] Prior decisions, issues, concerns synthesized
745
754
  - [ ] Tasks identified with needs/creates dependencies
746
755
  - [ ] Task list handed off to ms-plan-writer
747
- - [ ] PLAN file(s) created by subagent with XML structure
748
- - [ ] Each plan: depends_on, files_modified in frontmatter
749
- - [ ] Each plan: must_haves derived (truths, artifacts, key_links)
750
- - [ ] Each plan: 2-3 tasks (~50% context)
756
+ - [ ] PLAN file(s) created with pure markdown format
757
+ - [ ] EXECUTION-ORDER.md created with wave groups
758
+ - [ ] Each plan: Must-Haves section with observable truths
759
+ - [ ] Each plan: 2-3 changes (~50% context)
751
760
  - [ ] Wave structure maximizes parallelism
752
761
  - [ ] PLAN file(s) committed to git
753
762
  - [ ] Risk assessment presented (score + top factors)
@@ -759,8 +768,8 @@ Tasks are instructions for Claude, not Jira tickets.
759
768
  - [ ] Existing SUMMARYs read for context
760
769
  - [ ] Gaps clustered into focused plans
761
770
  - [ ] Plan numbers sequential after existing (04, 05...)
762
- - [ ] PLAN file(s) exist with gap_closure: true
763
- - [ ] Each plan: tasks derived from gap.missing items
771
+ - [ ] PLAN file(s) created with pure markdown format
772
+ - [ ] EXECUTION-ORDER.md updated with gap closure plans
764
773
  - [ ] PLAN file(s) committed to git
765
774
  - [ ] User knows to run `/ms:execute-phase {X}` next
766
775
  </success_criteria>
@@ -42,7 +42,7 @@ grep -E "^| ${PHASE_NUM}" .planning/REQUIREMENTS.md 2>/dev/null
42
42
  # All SUMMARY files (claims to verify)
43
43
  ls "$PHASE_DIR"/*-SUMMARY.md 2>/dev/null
44
44
 
45
- # All PLAN files (for must_haves in frontmatter)
45
+ # All PLAN files (for Must-Haves in plan markdown)
46
46
  ls "$PHASE_DIR"/*-PLAN.md 2>/dev/null
47
47
  ```
48
48
 
@@ -54,32 +54,28 @@ ls "$PHASE_DIR"/*-PLAN.md 2>/dev/null
54
54
  <step name="establish_must_haves">
55
55
  **Determine what must be verified.**
56
56
 
57
- **Option A: Must-haves in PLAN frontmatter**
57
+ **Option A: Must-haves in plan markdown**
58
58
 
59
- Check if any PLAN.md has `must_haves` in frontmatter:
59
+ Check if any PLAN.md has a `## Must-Haves` section:
60
60
 
61
61
  ```bash
62
- grep -l "must_haves:" "$PHASE_DIR"/*-PLAN.md 2>/dev/null
62
+ grep -l "## Must-Haves" "$PHASE_DIR"/*-PLAN.md 2>/dev/null
63
63
  ```
64
64
 
65
- If found, extract and use:
66
- ```yaml
67
- must_haves:
68
- truths:
69
- - "User can see existing messages"
70
- - "User can send a message"
71
- artifacts:
72
- - path: "src/components/Chat.tsx"
73
- provides: "Message list rendering"
74
- key_links:
75
- - from: "Chat.tsx"
76
- to: "api/chat"
77
- via: "fetch in useEffect"
65
+ If found, extract checklist items. Must-haves are markdown checklist entries:
66
+
67
+ ```markdown
68
+ ## Must-Haves
69
+ - [ ] User can see existing messages
70
+ - [ ] User can send a message
71
+ - [ ] Messages persist after refresh
78
72
  ```
79
73
 
74
+ Each `- [ ]` item is an observable truth to verify. Derive artifacts from `**Files:**` lines in `## Changes` sections and key links from the implementation details.
75
+
80
76
  **Option B: Derive from phase goal**
81
77
 
82
- If no must_haves in frontmatter, derive using goal-backward process:
78
+ If no `## Must-Haves` section found in plans, derive using goal-backward process:
83
79
 
84
80
  1. **State the goal:** Take phase goal from ROADMAP.md
85
81
 
@@ -370,7 +366,7 @@ verify_state_render_link() {
370
366
 
371
367
  ### Aggregate key link results
372
368
 
373
- For each key link in must_haves:
369
+ For each key link derived from plan `## Changes` and `## Must-Haves` sections:
374
370
  - Run appropriate verification function
375
371
  - Record status and evidence
376
372
  - WIRED / PARTIAL / STUB / NOT_WIRED
@@ -615,7 +611,7 @@ The orchestrator will:
615
611
  </process>
616
612
 
617
613
  <success_criteria>
618
- - [ ] Must-haves established (from frontmatter or derived)
614
+ - [ ] Must-haves established (from plan ## Must-Haves section or derived)
619
615
  - [ ] All truths verified with status and evidence
620
616
  - [ ] All artifacts checked at all three levels
621
617
  - [ ] All key links verified
@@ -5,7 +5,7 @@ Complete verify-and-fix session: by session end, everything verified, issues fix
5
5
  </purpose>
6
6
 
7
7
  <execution_context>
8
- <!-- mock-patterns.md and generate-mocks.md loaded on demand when mocks are needed (see classify_tests step) -->
8
+ <!-- mock-patterns.md loaded on demand for transient_state mocks (see generate_mocks step) -->
9
9
  </execution_context>
10
10
 
11
11
  <template>
@@ -232,7 +232,7 @@ tests:
232
232
  <step name="create_batches">
233
233
  **Group tests into batches:**
234
234
 
235
- **If any tests have mock_required=true:** Read `~/.claude/mindsystem/references/mock-patterns.md` and `~/.claude/mindsystem/workflows/generate-mocks.md` now for mock generation guidance.
235
+ **If any tests have mock_required=true AND batch includes `transient_state` mocks:** Read `~/.claude/mindsystem/references/mock-patterns.md` for delay/never-resolve strategies.
236
236
 
237
237
  **Rules:**
238
238
  1. Group by mock_type (tests needing same mock state go together)
@@ -311,7 +311,7 @@ source: [list of SUMMARY.md files]
311
311
  started: [ISO timestamp]
312
312
  updated: [ISO timestamp]
313
313
  current_batch: 1
314
- mock_stash: null
314
+ mocked_files: []
315
315
  pre_work_stash: [from dirty tree handling, or null]
316
316
  ---
317
317
 
@@ -378,11 +378,11 @@ Read current batch from UAT.md.
378
378
  **1. Handle mock generation (if needed):**
379
379
 
380
380
  If `mock_type` is not null AND different from previous batch:
381
- - Discard old mocks if any (use stash name from `mock_stash` in UAT.md frontmatter):
381
+ - Revert old mocks if any (from `mocked_files` in UAT.md frontmatter):
382
382
  ```bash
383
- MOCK_STASH=$(git stash list | grep "mocks-batch" | head -1 | cut -d: -f1)
384
- [ -n "$MOCK_STASH" ] && git stash drop "$MOCK_STASH"
383
+ git checkout -- <mocked_files>
385
384
  ```
385
+ - Clear `mocked_files` in frontmatter
386
386
  - Go to `generate_mocks`
387
387
 
388
388
  If `mock_type` is null or same as previous:
@@ -394,72 +394,61 @@ Go to `present_tests`
394
394
  </step>
395
395
 
396
396
  <step name="generate_mocks">
397
- **Generate mocks for current batch:**
397
+ **Generate mocks for current batch using inline approach:**
398
398
 
399
- Present mock generation options:
400
- ```
401
- ## Batch [N]: [Name]
399
+ Count mock-requiring tests in this batch.
402
400
 
403
- **Mock required:** [mock_type description]
401
+ **Decision logic:**
404
402
 
405
- This batch tests states that require mock data. Options:
403
+ | Count | Approach |
404
+ |-------|----------|
405
+ | 1-4 | Inline: edit service methods directly in main context |
406
+ | 5+ | Subagent: spawn ms-mock-generator for batch editing |
406
407
 
407
- 1. Generate mocks (Recommended) — I'll create the override files
408
- 2. I'll set up mocks manually — Skip generation, you handle it
409
- 3. Skip this batch — Log all tests as assumptions
410
- ```
408
+ **Inline approach (1-4 mocks):**
411
409
 
412
- **If "Generate mocks":**
410
+ For each test in the batch:
411
+ 1. Identify the service/repository method that provides the data
412
+ 2. Read the method
413
+ 3. Edit to hardcode desired return value BEFORE the real implementation:
414
+ ```
415
+ // MOCK: {description} — revert after UAT
416
+ {hardcoded return/throw}
417
+ ```
418
+ 4. For transient_state mocks: Read `~/.claude/mindsystem/references/mock-patterns.md` for delay/never-resolve strategies
419
+
420
+ **Subagent approach (5+ mocks):**
413
421
 
414
- Spawn mock generator:
415
422
  ```
416
423
  Task(
417
424
  prompt="""
418
- Generate mocks for manual UAT testing.
425
+ Generate inline mocks for manual UAT testing.
419
426
 
420
- Project: {from PROJECT.md}
421
427
  Phase: {phase_name}
422
- Mock type: {mock_type}
423
428
 
424
- Tests requiring this mock:
425
- {test list with expected behaviors}
429
+ Tests requiring mocks:
430
+ {test list with mock_type and expected behaviors}
426
431
 
427
- Follow patterns from @~/.claude/mindsystem/workflows/generate-mocks.md
432
+ Mocked files from previous batches (avoid conflicts):
433
+ {mocked_files from UAT.md frontmatter}
428
434
  """,
429
435
  subagent_type="ms-mock-generator",
430
436
  description="Generate {mock_type} mocks"
431
437
  )
432
438
  ```
433
439
 
434
- After mock generator returns:
440
+ **After mocks applied (both approaches):**
435
441
 
436
- 1. Update UAT.md: `mock_stash: null` (mocks are uncommitted, not stashed yet)
437
- 2. Present toggle instructions from mock generator
438
- 3. Ask user to confirm mocks are active:
442
+ 1. Record mocked files in UAT.md frontmatter: `mocked_files: [file1.dart, file2.dart, ...]`
443
+ 2. Tell user: "Mocks applied. Hot reload to test."
444
+ 3. Proceed directly to `present_tests` no user confirmation needed
439
445
 
440
- ```
441
- questions:
442
- - question: "I've created the mock files. Have you enabled the mocks and verified they're working?"
443
- header: "Mocks ready"
444
- options:
445
- - label: "Yes, mocks are active"
446
- description: "I've toggled the flags and hot reloaded"
447
- - label: "Having trouble"
448
- description: "Something isn't working with the mocks"
449
- multiSelect: false
450
- ```
451
-
452
- **If "I'll set up manually":**
453
- - Present what mock state is needed
454
- - Wait for user to confirm ready
446
+ **Skip option:**
455
447
 
456
- **If "Skip this batch":**
457
- - Prompt for reason: "Why are you skipping this batch?"
458
- - Mark all tests in batch as `skipped` with user's reason
448
+ If user has previously indicated they want to skip mock batches, or if mock generation fails:
449
+ - Mark all tests in batch as `skipped`
459
450
  - Append to Assumptions section
460
451
  - Proceed to next batch
461
-
462
- Proceed to `present_tests`.
463
452
  </step>
464
453
 
465
454
  <step name="present_tests">
@@ -574,9 +563,9 @@ For each question:
574
563
 
575
564
  **1. Stash mocks (if active):**
576
565
  ```bash
577
- git stash push -m "mocks-batch-{N}"
566
+ git stash push -m "mocks-batch-{N}" -- <mocked_files>
578
567
  ```
579
- Update UAT.md: `mock_stash: "mocks-batch-{N}"`
568
+ Use `mocked_files` list from UAT.md frontmatter.
580
569
 
581
570
  **2. Make the fix:**
582
571
  - Edit the file(s)
@@ -605,11 +594,11 @@ git stash pop
605
594
 
606
595
  **Handle stash conflict:**
607
596
  ```bash
608
- # If conflict, take fix version
597
+ # Conflict means fix touched a mocked file — take the fix version
609
598
  git checkout --theirs <conflicted-file>
610
599
  git add <conflicted-file>
611
600
  ```
612
- Log that mock was discarded for that file.
601
+ Remove conflicted file from `mocked_files` list in UAT.md (mock no longer needed for that file).
613
602
 
614
603
  **6. Request re-test:**
615
604
  ```
@@ -626,7 +615,7 @@ Go to `handle_retest`.
626
615
 
627
616
  **1. Stash mocks (if active):**
628
617
  ```bash
629
- git stash push -m "mocks-batch-{N}"
618
+ git stash push -m "mocks-batch-{N}" -- <mocked_files>
630
619
  ```
631
620
 
632
621
  **2. Spawn ms-verify-fixer:**
@@ -738,13 +727,12 @@ questions:
738
727
 
739
728
  Read full UAT file.
740
729
 
741
- Check `mock_stash` — if exists, offer to restore:
742
- ```
743
- Found stashed mocks: {mock_stash}
744
-
745
- 1. Restore mocks — Continue where we left off
746
- 2. Discard mocks — Start batch fresh
730
+ Check `mocked_files` — if non-empty, verify mocks are still present:
731
+ ```bash
732
+ git diff --name-only
747
733
  ```
734
+ If mocked files have uncommitted changes, mocks are still active — continue.
735
+ If mocked files are clean, mocks were lost — regenerate for current batch.
748
736
 
749
737
  Find current position:
750
738
  - current_batch
@@ -796,12 +784,11 @@ issues: {count}
796
784
  <step name="complete_session">
797
785
  **Complete UAT session:**
798
786
 
799
- **1. Discard mocks:**
787
+ **1. Revert mocks:**
800
788
  ```bash
801
- # Find and drop the specific mock stash (not just the top one)
802
- MOCK_STASH=$(git stash list | grep "mocks-batch" | head -1 | cut -d: -f1)
803
- [ -n "$MOCK_STASH" ] && git stash drop "$MOCK_STASH"
789
+ git checkout -- <mocked_files>
804
790
  ```
791
+ Use `mocked_files` list from UAT.md frontmatter. Clear the list after reverting.
805
792
 
806
793
  **2. Generate UAT fixes patch (if fixes were made):**
807
794
  ```bash
@@ -818,7 +805,7 @@ PRE_WORK_STASH=$(git stash list | grep "pre-verify-work" | head -1 | cut -d: -f1
818
805
 
819
806
  **4. Update UAT.md:**
820
807
  - status: complete
821
- - Clear current_batch, mock_stash
808
+ - Clear current_batch, mocked_files
822
809
  - Final Progress counts
823
810
 
824
811
  **5. Commit UAT.md:**
@@ -863,7 +850,7 @@ Check if more phases remain in ROADMAP.md:
863
850
  |---------|------|------|
864
851
  | Frontmatter.status | OVERWRITE | Phase transitions |
865
852
  | Frontmatter.current_batch | OVERWRITE | Batch transitions |
866
- | Frontmatter.mock_stash | OVERWRITE | Stash operations |
853
+ | Frontmatter.mocked_files | OVERWRITE | Mock generation/cleanup |
867
854
  | Frontmatter.updated | OVERWRITE | Every write |
868
855
  | Progress | OVERWRITE | After each test result |
869
856
  | Current Batch | OVERWRITE | Batch transitions |
@@ -895,7 +882,7 @@ Default: **major** (safe default)
895
882
  - [ ] Dirty tree handled at start
896
883
  - [ ] Tests classified by mock requirements
897
884
  - [ ] Batches created respecting dependencies and mock types
898
- - [ ] Mocks generated when needed with toggle instructions
885
+ - [ ] Mocks applied inline when needed (1-4 direct, 5+ via subagent)
899
886
  - [ ] Tests presented in batches of 4
900
887
  - [ ] Issues investigated with lightweight check (2-3 calls)
901
888
  - [ ] Simple issues fixed inline with proper commit
@@ -903,7 +890,7 @@ Default: **major** (safe default)
903
890
  - [ ] Re-test retries (2 max, tracked via retry_count) before offering options
904
891
  - [ ] Blocked tests re-presented after blocking issues resolved
905
892
  - [ ] Stash conflicts auto-resolved to fix version
906
- - [ ] Mocks discarded on completion
893
+ - [ ] Mocks reverted on completion (git checkout)
907
894
  - [ ] UAT fixes patch generated
908
895
  - [ ] User's pre-existing work restored
909
896
  - [ ] UAT.md committed with final summary
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindsystem-cc",
3
- "version": "3.12.0",
3
+ "version": "3.13.1",
4
4
  "description": "A meta-prompting, context engineering and spec-driven development system for Claude Code by TÂCHES.",
5
5
  "bin": {
6
6
  "mindsystem-cc": "bin/install.js"
@@ -0,0 +1,59 @@
1
+ #!/bin/bash
2
+ #
3
+ # update-state.sh
4
+ # Updates .planning/STATE.md Plan and Status lines based on plan progress.
5
+ # Idempotent — same arguments produce the same result.
6
+ #
7
+ # Usage: ./scripts/update-state.sh <completed_plan_count> <total_plans>
8
+ # Example: ./scripts/update-state.sh 2 4
9
+ # (2 of 4 plans complete)
10
+ #
11
+
12
+ set -e
13
+
14
+ # --- Validation ---
15
+ if [ -z "$1" ] || [ -z "$2" ]; then
16
+ echo "Error: Two arguments required"
17
+ echo "Usage: $0 <completed_plan_count> <total_plans>"
18
+ exit 1
19
+ fi
20
+
21
+ COMPLETED="$1"
22
+ TOTAL="$2"
23
+
24
+ if ! [[ "$COMPLETED" =~ ^[0-9]+$ ]] || ! [[ "$TOTAL" =~ ^[0-9]+$ ]]; then
25
+ echo "Error: Both arguments must be numeric"
26
+ echo "Usage: $0 <completed_plan_count> <total_plans>"
27
+ exit 1
28
+ fi
29
+
30
+ if [ "$COMPLETED" -gt "$TOTAL" ]; then
31
+ echo "Error: Completed ($COMPLETED) cannot exceed total ($TOTAL)"
32
+ exit 1
33
+ fi
34
+
35
+ # --- Find STATE.md from git root ---
36
+ GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
37
+ if [ -z "$GIT_ROOT" ]; then
38
+ echo "Error: Not in a git repository"
39
+ exit 1
40
+ fi
41
+
42
+ STATE_FILE="$GIT_ROOT/.planning/STATE.md"
43
+ if [ ! -f "$STATE_FILE" ]; then
44
+ echo "Error: STATE.md not found at $STATE_FILE"
45
+ exit 1
46
+ fi
47
+
48
+ # --- Update Plan line ---
49
+ sed -i '' "s/^Plan:.*/Plan: $COMPLETED of $TOTAL complete in current phase/" "$STATE_FILE"
50
+
51
+ # --- Update Status line ---
52
+ if [ "$COMPLETED" -eq "$TOTAL" ]; then
53
+ sed -i '' "s/^Status:.*/Status: All plans executed, pending verification/" "$STATE_FILE"
54
+ else
55
+ sed -i '' "s/^Status:.*/Status: In progress — plan $COMPLETED of $TOTAL complete/" "$STATE_FILE"
56
+ fi
57
+
58
+ echo "STATE.md updated: $COMPLETED of $TOTAL plans complete"
59
+ exit 0
@@ -0,0 +1,102 @@
1
+ #!/bin/bash
2
+ #
3
+ # validate-execution-order.sh
4
+ # Validates EXECUTION-ORDER.md against plan files in a phase directory.
5
+ # Checks bidirectional consistency and warns about file conflicts within waves.
6
+ #
7
+ # Usage: ./scripts/validate-execution-order.sh <phase_directory>
8
+ # Example: ./scripts/validate-execution-order.sh .planning/phases/03-auth
9
+ #
10
+
11
+ set -e
12
+
13
+ # --- Validation ---
14
+ if [ -z "$1" ]; then
15
+ echo "Error: Phase directory required"
16
+ echo "Usage: $0 <phase_directory>"
17
+ exit 1
18
+ fi
19
+
20
+ PHASE_DIR="$1"
21
+
22
+ if [ ! -d "$PHASE_DIR" ]; then
23
+ echo "FAIL: Directory does not exist: $PHASE_DIR"
24
+ exit 1
25
+ fi
26
+
27
+ EXEC_ORDER="$PHASE_DIR/EXECUTION-ORDER.md"
28
+ if [ ! -f "$EXEC_ORDER" ]; then
29
+ echo "FAIL: EXECUTION-ORDER.md not found in $PHASE_DIR"
30
+ exit 1
31
+ fi
32
+
33
+ # --- Collect plan files on disk ---
34
+ DISK_PLANS=$(ls -1 "$PHASE_DIR"/*-PLAN.md 2>/dev/null | xargs -I{} basename {} | sort)
35
+ DISK_COUNT=$(echo "$DISK_PLANS" | grep -c . 2>/dev/null || echo 0)
36
+
37
+ if [ "$DISK_COUNT" -eq 0 ]; then
38
+ echo "FAIL: No *-PLAN.md files found in $PHASE_DIR"
39
+ exit 1
40
+ fi
41
+
42
+ # --- Parse EXECUTION-ORDER.md for plan filenames ---
43
+ ORDER_PLANS=$(grep -oE '[0-9]+-PLAN\.md' "$EXEC_ORDER" | sort -u)
44
+ ORDER_COUNT=$(echo "$ORDER_PLANS" | grep -c . 2>/dev/null || echo 0)
45
+
46
+ # --- Check 1: Every disk plan is listed in EXECUTION-ORDER.md ---
47
+ ERRORS=""
48
+ while IFS= read -r plan; do
49
+ if ! echo "$ORDER_PLANS" | grep -qx "$plan"; then
50
+ ERRORS="${ERRORS} Missing from EXECUTION-ORDER.md: $plan\n"
51
+ fi
52
+ done <<< "$DISK_PLANS"
53
+
54
+ # --- Check 2: Every plan in EXECUTION-ORDER.md exists on disk ---
55
+ while IFS= read -r plan; do
56
+ if ! echo "$DISK_PLANS" | grep -qx "$plan"; then
57
+ ERRORS="${ERRORS} Listed in EXECUTION-ORDER.md but file missing: $plan\n"
58
+ fi
59
+ done <<< "$ORDER_PLANS"
60
+
61
+ if [ -n "$ERRORS" ]; then
62
+ echo "FAIL: Plan/execution-order mismatch"
63
+ printf "%b" "$ERRORS"
64
+ exit 1
65
+ fi
66
+
67
+ # --- Check 3 (warning): File conflicts within waves ---
68
+ CURRENT_WAVE=""
69
+ WAVE_COUNT=0
70
+ declare -A WAVE_FILES
71
+
72
+ while IFS= read -r line; do
73
+ if echo "$line" | grep -qE '^## Wave [0-9]+'; then
74
+ CURRENT_WAVE=$(echo "$line" | grep -oE '[0-9]+')
75
+ WAVE_COUNT=$((WAVE_COUNT + 1))
76
+ WAVE_FILES[$CURRENT_WAVE]=""
77
+ elif [ -n "$CURRENT_WAVE" ]; then
78
+ PLAN_FILE=$(echo "$line" | grep -oE '[0-9]+-PLAN\.md' || true)
79
+ if [ -n "$PLAN_FILE" ] && [ -f "$PHASE_DIR/$PLAN_FILE" ]; then
80
+ # Extract **Files:** lines from plan
81
+ FILE_PATHS=$(grep -E '^\*\*Files:\*\*' "$PHASE_DIR/$PLAN_FILE" | sed 's/\*\*Files:\*\*//g' | tr ',' '\n' | sed 's/`//g; s/^[[:space:]]*//; s/[[:space:]]*$//' | grep -v '^$' || true)
82
+ while IFS= read -r fpath; do
83
+ [ -z "$fpath" ] && continue
84
+ EXISTING="${WAVE_FILES[$CURRENT_WAVE]}"
85
+ if echo "$EXISTING" | grep -qF "|$fpath|"; then
86
+ echo "WARNING: File '$fpath' appears in multiple plans within Wave $CURRENT_WAVE"
87
+ else
88
+ WAVE_FILES[$CURRENT_WAVE]="${EXISTING}|$fpath|"
89
+ fi
90
+ done <<< "$FILE_PATHS"
91
+ fi
92
+ fi
93
+ done < "$EXEC_ORDER"
94
+
95
+ # --- Handle edge case: no waves parsed ---
96
+ if [ "$WAVE_COUNT" -eq 0 ]; then
97
+ echo "FAIL: No '## Wave N' headers found in EXECUTION-ORDER.md"
98
+ exit 1
99
+ fi
100
+
101
+ echo "PASS: $DISK_COUNT plans across $WAVE_COUNT waves"
102
+ exit 0
@@ -24,11 +24,12 @@ Comprehensive guidelines for Flutter/Dart code quality, widget organization, and
24
24
 
25
25
  Fetch fresh guidelines before each review:
26
26
 
27
- ```
28
- https://gist.githubusercontent.com/rolandtolnay/edf9ea7d5adf218f45accb3411f0627c/raw/flutter-code-quality-guidelines.md
27
+ ```bash
28
+ gh api /gists/edf9ea7d5adf218f45accb3411f0627c \
29
+ --jq '.files["flutter-code-quality-guidelines.md"].content'
29
30
  ```
30
31
 
31
- Use WebFetch to retrieve. Contains: anti-patterns, widget patterns, state management, collections, hooks, theme/styling, etc.
32
+ Never use WebFetch for gist content — it summarizes instead of returning raw text. Contains: anti-patterns, widget patterns, state management, collections, hooks, theme/styling, etc.
32
33
 
33
34
  ## Widget Organization Guidelines (Embedded)
34
35