mindsystem-cc 3.17.1 → 3.18.0

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.
@@ -1,8 +1,6 @@
1
1
  <purpose>
2
2
 
3
- Mark a shipped version (v1.0, v1.1, v2.0) as complete. This creates a historical record in MILESTONES.md, performs full PROJECT.md evolution review, reorganizes ROADMAP.md with milestone groupings, and tags the release in git.
4
-
5
- This is the ritual that separates "development" from "shipped."
3
+ Mark a shipped version (v1.0, v1.1, v2.0) as complete. This creates a historical record in MILESTONES.md, performs full PROJECT.md evolution review, archives ROADMAP.md and REQUIREMENTS.md, and tags the release in git.
6
4
 
7
5
  </purpose>
8
6
 
@@ -22,25 +20,14 @@ This is the ritual that separates "development" from "shipped."
22
20
 
23
21
  When a milestone completes, this workflow:
24
22
 
25
- 1. Cleans up raw phase artifacts (CONTEXT, DESIGN, RESEARCH, SUMMARY, UAT, VERIFICATION, EXECUTION-ORDER deleted)
26
- 2. Creates `.planning/milestones/v[X.Y]/` directory for all archive files
27
- 3. Extracts full milestone details to `.planning/milestones/v[X.Y]/ROADMAP.md`
28
- 4. Archives requirements to `.planning/milestones/v[X.Y]/REQUIREMENTS.md`
29
- 5. Archives milestone context to `.planning/milestones/v[X.Y]/CONTEXT.md`
30
- 6. Archives research files to `.planning/milestones/v[X.Y]/research/` (if exists)
31
- 7. Updates ROADMAP.md to replace milestone details with one-line summary
32
- 8. Deletes REQUIREMENTS.md (fresh one created for next milestone)
33
- 9. Performs full PROJECT.md evolution review
34
- 10. Routes to `/ms:new-milestone` for next milestone
35
-
36
- Knowledge files in `.planning/knowledge/` persist across milestones (maintained by phase-level consolidation in execute-phase).
37
-
38
- **Context Efficiency:**
39
-
40
- - Completed milestones: One line each (~50 tokens)
41
- - Full details: In archive files (loaded only when needed)
42
- - Result: ROADMAP.md stays constant size forever
43
- - Result: REQUIREMENTS.md is always milestone-scoped (not cumulative)
23
+ 1. Creates `.planning/milestones/v[X.Y]/` directory for all archive files
24
+ 2. Extracts full milestone details to `.planning/milestones/v[X.Y]/ROADMAP.md`
25
+ 3. Archives requirements to `.planning/milestones/v[X.Y]/REQUIREMENTS.md`
26
+ 4. Archives milestone files via script (audit, context, research — whichever exist)
27
+ 5. Consolidates phase summaries, deletes artifacts, moves phase dirs via script
28
+ 6. Deletes REQUIREMENTS.md (fresh one created for next milestone)
29
+ 7. Performs full PROJECT.md evolution review
30
+ 8. Routes to `/ms:new-milestone` for next milestone
44
31
 
45
32
  **Archive Format:**
46
33
 
@@ -49,6 +36,10 @@ Knowledge files in `.planning/knowledge/` persist across milestones (maintained
49
36
  - Full phase details from roadmap
50
37
  - Milestone summary (decisions, issues, technical debt)
51
38
 
39
+ **PHASE-SUMMARIES** consolidates all `*-SUMMARY.md` files from phase directories, organized by phase and plan, before artifacts are deleted.
40
+
41
+ **phases/** contains the phase directories themselves (with remaining files like `.patch`, `mockups/`) moved from `.planning/phases/`.
42
+
52
43
  **REQUIREMENTS archive** contains:
53
44
  - All v1 requirements marked complete with outcomes
54
45
  - Traceability table with final status
@@ -60,32 +51,10 @@ Knowledge files in `.planning/knowledge/` persist across milestones (maintained
60
51
 
61
52
  <step name="verify_readiness">
62
53
 
63
- Check if milestone is truly complete:
54
+ Read roadmap to determine milestone phase range (`PHASE_START`, `PHASE_END`) for the stats script:
64
55
 
65
56
  ```bash
66
57
  cat .planning/ROADMAP.md
67
- ls .planning/phases/*/SUMMARY.md 2>/dev/null | wc -l
68
- ```
69
-
70
- **Questions to ask:**
71
-
72
- - Which phases belong to this milestone?
73
- - Are all those phases complete (all plans have summaries)?
74
- - Has the work been tested/validated?
75
- - Is this ready to ship/tag?
76
-
77
- Present:
78
-
79
- ```
80
- Milestone: [Name from user, e.g., "v1.0 MVP"]
81
-
82
- Appears to include:
83
- - Phase 1: Foundation (2/2 plans complete)
84
- - Phase 2: Authentication (2/2 plans complete)
85
- - Phase 3: Core Features (3/3 plans complete)
86
- - Phase 4: Polish (1/1 plan complete)
87
-
88
- Total: 4 phases, 8 plans, all complete
89
58
  ```
90
59
 
91
60
  <config-check>
@@ -96,74 +65,30 @@ cat .planning/config.json 2>/dev/null
96
65
 
97
66
  </config-check>
98
67
 
99
- ```
100
- ⚡ Auto-approved: Milestone scope verification
101
-
102
- [Show breakdown summary without prompting]
103
-
104
- Proceeding to stats gathering...
105
- ```
106
-
107
- Proceed directly to cleanup_artifacts step.
108
-
109
- </step>
110
-
111
- <step name="cleanup_artifacts">
112
-
113
- Delete remaining raw artifacts from phase directories. Knowledge files are already current from phase-level consolidation in execute-phase — no consolidation or learnings extraction needed.
68
+ Run the stats script to get readiness status and git statistics:
114
69
 
115
70
  ```bash
116
- ~/.claude/mindsystem/scripts/cleanup-phase-artifacts.sh $PHASE_START $PHASE_END
71
+ ~/.claude/mindsystem/scripts/gather-milestone-stats.sh $PHASE_START $PHASE_END
117
72
  ```
118
73
 
119
- Knowledge files in `.planning/knowledge/` persist (they ARE the milestone's knowledge output).
120
-
121
- **Present cleanup summary:**
122
-
123
- ```
124
- Raw artifacts cleaned from phase directories
125
- Knowledge files persist in .planning/knowledge/
126
- ```
127
-
128
- Continue to gather_stats step.
129
-
130
- </step>
74
+ The script outputs:
75
+ - **Readiness:** Phase/plan counts, completeness, list of incomplete plans
76
+ - **Git Stats:** Commit range, timeline, diff stats
131
77
 
132
- <step name="gather_stats">
78
+ If status is NOT READY, stop and report which plans are incomplete.
133
79
 
134
- Calculate milestone statistics:
80
+ If status is READY, present the combined output:
135
81
 
136
- ```bash
137
- # Count phases and plans in milestone
138
- # (user specified or detected from roadmap)
139
-
140
- # Find git range
141
- git log --oneline --grep="feat(" | head -20
142
-
143
- # Count files modified in range
144
- git diff --stat FIRST_COMMIT..LAST_COMMIT | tail -1
145
-
146
- # Count LOC (adapt to language)
147
- find . -name "*.swift" -o -name "*.ts" -o -name "*.py" | xargs wc -l 2>/dev/null
148
-
149
- # Calculate timeline
150
- git log --format="%ai" FIRST_COMMIT | tail -1 # Start date
151
- git log --format="%ai" LAST_COMMIT | head -1 # End date
152
82
  ```
83
+ ⚡ Auto-approved: Milestone scope verification
153
84
 
154
- Present summary:
155
-
156
- ```
157
- Milestone Stats:
158
- - Phases: [X-Y]
159
- - Plans: [Z] total
160
- - Tasks: [N] total (estimated from phase summaries)
161
- - Files modified: [M]
162
- - Lines of code: [LOC] [language]
163
- - Timeline: [Days] days ([Start] → [End])
164
- - Git range: feat(XX-XX) → feat(YY-YY)
85
+ Milestone: [Name from ROADMAP.md]
86
+ [Script readiness output — phases, plans, completeness]
87
+ [Script git stats — range, timeline, changes]
165
88
  ```
166
89
 
90
+ Proceed directly to extract_accomplishments step.
91
+
167
92
  </step>
168
93
 
169
94
  <step name="extract_accomplishments">
@@ -378,52 +303,6 @@ Initial user testing showed demand for shape tools.
378
303
 
379
304
  </step>
380
305
 
381
- <step name="reorganize_roadmap">
382
-
383
- Update `.planning/ROADMAP.md` to group completed milestone phases.
384
-
385
- Add milestone headers and collapse completed work:
386
-
387
- ```markdown
388
- # Roadmap: [Project Name]
389
-
390
- ## Milestones
391
-
392
- - ✅ **v1.0 MVP** — Phases 1-4 (shipped YYYY-MM-DD)
393
- - 🚧 **v1.1 Security** — Phases 5-6 (in progress)
394
- - 📋 **v2.0 Redesign** — Phases 7-10 (planned)
395
-
396
- ## Phases
397
-
398
- <details>
399
- <summary>✅ v1.0 MVP (Phases 1-4) — SHIPPED YYYY-MM-DD</summary>
400
-
401
- - [x] Phase 1: Foundation (2/2 plans) — completed YYYY-MM-DD
402
- - [x] Phase 2: Authentication (2/2 plans) — completed YYYY-MM-DD
403
- - [x] Phase 3: Core Features (3/3 plans) — completed YYYY-MM-DD
404
- - [x] Phase 4: Polish (1/1 plan) — completed YYYY-MM-DD
405
-
406
- </details>
407
-
408
- ### 🚧 v[Next] [Name] (In Progress / Planned)
409
-
410
- - [ ] Phase 5: [Name] ([N] plans)
411
- - [ ] Phase 6: [Name] ([N] plans)
412
-
413
- ## Progress
414
-
415
- | Phase | Milestone | Plans Complete | Status | Completed |
416
- | ----------------- | --------- | -------------- | ----------- | ---------- |
417
- | 1. Foundation | v1.0 | 2/2 | Complete | YYYY-MM-DD |
418
- | 2. Authentication | v1.0 | 2/2 | Complete | YYYY-MM-DD |
419
- | 3. Core Features | v1.0 | 3/3 | Complete | YYYY-MM-DD |
420
- | 4. Polish | v1.0 | 1/1 | Complete | YYYY-MM-DD |
421
- | 5. Security Audit | v1.1 | 0/1 | Not started | - |
422
- | 6. Hardening | v1.1 | 0/2 | Not started | - |
423
- ```
424
-
425
- </step>
426
-
427
306
  <step name="archive_milestone">
428
307
 
429
308
  Extract completed milestone details and create archive file.
@@ -478,7 +357,7 @@ Extract completed milestone details and create archive file.
478
357
  ✅ ROADMAP.md deleted (fresh one for next milestone)
479
358
  ```
480
359
 
481
- **Note:** Phase directories (`.planning/phases/`) are NOT deleted. They accumulate across milestones as the raw execution history. Phase numbering continues (v1.0 phases 1-4, v1.1 phases 5-8, etc.).
360
+ **Note:** Phase directories are moved to `milestones/v[X.Y]/phases/` by the archive_and_cleanup_phases step. After milestone completion, `.planning/phases/` contains only the next milestone's work. Phase numbering continues (v1.0 phases 1-4, v1.1 phases 5-8, etc.).
482
361
 
483
362
  </step>
484
363
 
@@ -545,55 +424,43 @@ Archive requirements and prepare for fresh requirements in next milestone.
545
424
 
546
425
  </step>
547
426
 
548
- <step name="archive_audit">
427
+ <step name="archive_milestone_files">
549
428
 
550
- Move the milestone audit file to the archive (if it exists):
429
+ Archive optional milestone files (audit, context, research) to the milestone directory:
551
430
 
552
431
  ```bash
553
- # Move audit to milestone folder (if exists)
554
- [ -f .planning/v[X.Y]-MILESTONE-AUDIT.md ] && mv .planning/v[X.Y]-MILESTONE-AUDIT.md .planning/milestones/v[X.Y]/MILESTONE-AUDIT.md
432
+ ~/.claude/mindsystem/scripts/archive-milestone-files.sh v[X.Y]
555
433
  ```
556
434
 
557
- Confirm:
558
- ```
559
- ✅ Audit archived to milestones/v[X.Y]/MILESTONE-AUDIT.md
560
- ```
561
-
562
- (Skip silently if no audit file exists — audit is optional)
435
+ The script moves whichever files exist and reports what was archived. Files that don't exist are skipped silently.
563
436
 
564
437
  </step>
565
438
 
566
- <step name="archive_context">
439
+ <step name="archive_and_cleanup_phases">
567
440
 
568
- Archive the milestone context file (if it exists):
441
+ Consolidate phase summaries, delete raw artifacts, and move phase directories to the milestone archive. This runs after all steps that read summaries (extract_accomplishments, evolve_project_full_review) and after archive_milestone creates the milestone directory.
569
442
 
570
443
  ```bash
571
- [ -f .planning/MILESTONE-CONTEXT.md ] && mv .planning/MILESTONE-CONTEXT.md .planning/milestones/v[X.Y]/CONTEXT.md
572
- ```
573
-
574
- If archived:
575
- ```
576
- ✅ Context archived to milestones/v[X.Y]/CONTEXT.md
444
+ ~/.claude/mindsystem/scripts/archive-milestone-phases.sh $PHASE_START $PHASE_END v[X.Y]
577
445
  ```
578
446
 
579
- (Skip silently if no context file exists)
580
-
581
- </step>
582
-
583
- <step name="archive_research">
584
-
585
- Archive research files to milestone (if research directory exists):
447
+ Verify archive:
586
448
 
587
449
  ```bash
588
- [ -d .planning/research ] && mv .planning/research .planning/milestones/v[X.Y]/research
450
+ ls .planning/milestones/v[X.Y]/PHASE-SUMMARIES.md
451
+ ls .planning/milestones/v[X.Y]/phases/
589
452
  ```
590
453
 
591
- If archived:
454
+ Present:
455
+
592
456
  ```
593
- Research archived to milestones/v[X.Y]/research/
457
+ Phase summaries consolidated to milestones/v[X.Y]/PHASE-SUMMARIES.md
458
+ ✅ Raw artifacts deleted from phase directories
459
+ ✅ Phase directories moved to milestones/v[X.Y]/phases/
460
+ ✅ .planning/phases/ clean for next milestone
594
461
  ```
595
462
 
596
- (Skip silently if no research directory exists)
463
+ Knowledge files in `.planning/knowledge/` persist (they ARE the milestone's knowledge output).
597
464
 
598
465
  </step>
599
466
 
@@ -686,12 +553,15 @@ chore: complete v[X.Y] milestone
686
553
  Archived to milestones/v[X.Y]/:
687
554
  - ROADMAP.md
688
555
  - REQUIREMENTS.md
556
+ - PHASE-SUMMARIES.md (consolidated from phase directories)
557
+ - phases/ (phase directories moved from .planning/phases/)
689
558
  - MILESTONE-AUDIT.md (if audit was run)
690
559
  - CONTEXT.md (if milestone context existed)
691
560
  - research/ (if research existed)
692
561
 
693
562
  Cleaned:
694
- - Raw phase artifacts (CONTEXT, DESIGN, RESEARCH, SUMMARY, UAT, VERIFICATION, EXECUTION-ORDER)
563
+ - Raw phase artifacts deleted (CONTEXT, DESIGN, RESEARCH, SUMMARY, UAT, VERIFICATION, EXECUTION-ORDER)
564
+ - Phase directories moved to milestone archive
695
565
  - Knowledge files persist in .planning/knowledge/
696
566
 
697
567
  Deleted (fresh for next milestone):
@@ -752,62 +622,17 @@ Tag: v[X.Y]
752
622
 
753
623
  </process>
754
624
 
755
- <milestone_naming>
756
-
757
- **Version conventions:**
758
- - **v1.0** — Initial MVP
759
- - **v1.1, v1.2, v1.3** — Minor updates, new features, fixes
760
- - **v2.0, v3.0** — Major rewrites, breaking changes, significant new direction
761
-
762
- **Name conventions:**
763
- - v1.0 MVP
764
- - v1.1 Security
765
- - v1.2 Performance
766
- - v2.0 Redesign
767
- - v2.0 iOS Launch
768
-
769
- Keep names short (1-2 words describing the focus).
770
-
771
- </milestone_naming>
772
-
773
- <what_qualifies>
774
-
775
- **Create milestones for:**
776
- - Initial release (v1.0)
777
- - Public releases
778
- - Major feature sets shipped
779
- - Before archiving planning
780
-
781
- **Don't create milestones for:**
782
- - Every phase completion (too granular)
783
- - Work in progress (wait until shipped)
784
- - Internal dev iterations (unless truly shipped internally)
785
-
786
- If uncertain, ask: "Is this deployed/usable/shipped in some form?"
787
- If yes → milestone. If no → keep working.
788
-
789
- </what_qualifies>
790
-
791
625
  <success_criteria>
792
626
 
793
- Milestone completion is successful when:
627
+ Milestone completion is successful when (ordered by skip risk):
794
628
 
795
- - [ ] Raw artifacts cleaned from phase directories (CONTEXT, DESIGN, RESEARCH, SUMMARY, UAT, VERIFICATION, EXECUTION-ORDER)
796
- - [ ] Knowledge files persist in .planning/knowledge/
797
- - [ ] MILESTONES.md entry created with stats and accomplishments
798
- - [ ] PROJECT.md full evolution review completed
629
+ - [ ] PROJECT.md full evolution review completed (What This Is, Core Value, Requirements, Key Decisions, Context)
799
630
  - [ ] All shipped requirements moved to Validated in PROJECT.md
800
631
  - [ ] Key Decisions updated with outcomes
801
- - [ ] ROADMAP.md reorganized with milestone grouping
802
- - [ ] Milestone directory created (milestones/v[X.Y]/)
632
+ - [ ] MILESTONES.md entry created with stats and accomplishments
803
633
  - [ ] Roadmap archive created (milestones/v[X.Y]/ROADMAP.md)
804
634
  - [ ] Requirements archive created (milestones/v[X.Y]/REQUIREMENTS.md)
805
- - [ ] Research archived to milestone (milestones/v[X.Y]/research/) if .planning/research/ existed
806
635
  - [ ] REQUIREMENTS.md deleted (fresh for next milestone)
807
636
  - [ ] STATE.md updated with fresh project reference
808
- - [ ] Git tag created (v[X.Y])
809
- - [ ] Milestone commit made (includes archive files and deletion)
810
- - [ ] Context archive created if MILESTONE-CONTEXT.md existed
811
- - [ ] User knows next steps (starting with /ms:new-milestone)
812
637
 
813
638
  </success_criteria>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindsystem-cc",
3
- "version": "3.17.1",
3
+ "version": "3.18.0",
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,68 @@
1
+ #!/bin/bash
2
+ #
3
+ # archive-milestone-files.sh
4
+ # Moves optional milestone files (audit, context, research) to the
5
+ # milestone archive directory. Skips silently if files don't exist.
6
+ #
7
+ # Usage: ./scripts/archive-milestone-files.sh <version>
8
+ # Example: ./scripts/archive-milestone-files.sh v1.0
9
+
10
+ set -e
11
+
12
+ # --- Validation ---
13
+ if [ -z "$1" ]; then
14
+ echo "Error: Version argument required"
15
+ echo "Usage: $0 <version>"
16
+ exit 1
17
+ fi
18
+
19
+ VERSION="$1"
20
+
21
+ # --- Find .planning from git root ---
22
+ GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
23
+ if [ -z "$GIT_ROOT" ]; then
24
+ echo "Error: Not in a git repository"
25
+ exit 1
26
+ fi
27
+
28
+ PLANNING_DIR="$GIT_ROOT/.planning"
29
+ MILESTONE_DIR="$PLANNING_DIR/milestones/$VERSION"
30
+
31
+ if [ ! -d "$MILESTONE_DIR" ]; then
32
+ echo "Error: Milestone directory not found at $MILESTONE_DIR"
33
+ echo "Run archive_milestone step first to create it"
34
+ exit 1
35
+ fi
36
+
37
+ # --- Move files ---
38
+ ARCHIVED=0
39
+
40
+ # Milestone audit
41
+ if [ -f "$PLANNING_DIR/${VERSION}-MILESTONE-AUDIT.md" ]; then
42
+ mv "$PLANNING_DIR/${VERSION}-MILESTONE-AUDIT.md" "$MILESTONE_DIR/MILESTONE-AUDIT.md"
43
+ echo "Archived: ${VERSION}-MILESTONE-AUDIT.md → MILESTONE-AUDIT.md"
44
+ ARCHIVED=$((ARCHIVED + 1))
45
+ fi
46
+
47
+ # Milestone context
48
+ if [ -f "$PLANNING_DIR/MILESTONE-CONTEXT.md" ]; then
49
+ mv "$PLANNING_DIR/MILESTONE-CONTEXT.md" "$MILESTONE_DIR/CONTEXT.md"
50
+ echo "Archived: MILESTONE-CONTEXT.md → CONTEXT.md"
51
+ ARCHIVED=$((ARCHIVED + 1))
52
+ fi
53
+
54
+ # Research directory
55
+ if [ -d "$PLANNING_DIR/research" ]; then
56
+ mv "$PLANNING_DIR/research" "$MILESTONE_DIR/research"
57
+ echo "Archived: research/ → research/"
58
+ ARCHIVED=$((ARCHIVED + 1))
59
+ fi
60
+
61
+ if [ "$ARCHIVED" -eq 0 ]; then
62
+ echo "No optional files to archive (audit, context, research all absent)"
63
+ else
64
+ echo ""
65
+ echo "Archived $ARCHIVED item(s) to milestones/$VERSION/"
66
+ fi
67
+
68
+ exit 0
@@ -0,0 +1,138 @@
1
+ #!/bin/bash
2
+ #
3
+ # archive-milestone-phases.sh
4
+ # Consolidates phase summaries, deletes raw artifacts, and moves phase
5
+ # directories to the milestone archive.
6
+ #
7
+ # Usage: ./scripts/archive-milestone-phases.sh <start_phase> <end_phase> <version>
8
+ # Example: ./scripts/archive-milestone-phases.sh 1 6 v1.0
9
+
10
+ set -e
11
+
12
+ # --- Validation ---
13
+ if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
14
+ echo "Error: Three arguments required"
15
+ echo "Usage: $0 <start_phase> <end_phase> <version>"
16
+ exit 1
17
+ fi
18
+
19
+ START="$1"
20
+ END="$2"
21
+ VERSION="$3"
22
+
23
+ if ! [[ "$START" =~ ^[0-9]+$ ]] || ! [[ "$END" =~ ^[0-9]+$ ]]; then
24
+ echo "Error: start_phase and end_phase must be numeric"
25
+ echo "Usage: $0 <start_phase> <end_phase> <version>"
26
+ exit 1
27
+ fi
28
+
29
+ if [ "$START" -gt "$END" ]; then
30
+ echo "Error: Start phase ($START) cannot exceed end phase ($END)"
31
+ exit 1
32
+ fi
33
+
34
+ # --- Find .planning from git root ---
35
+ GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
36
+ if [ -z "$GIT_ROOT" ]; then
37
+ echo "Error: Not in a git repository"
38
+ exit 1
39
+ fi
40
+
41
+ PHASES_DIR="$GIT_ROOT/.planning/phases"
42
+ if [ ! -d "$PHASES_DIR" ]; then
43
+ echo "Error: Phases directory not found at $PHASES_DIR"
44
+ exit 1
45
+ fi
46
+
47
+ MILESTONE_DIR="$GIT_ROOT/.planning/milestones/$VERSION"
48
+ if [ ! -d "$MILESTONE_DIR" ]; then
49
+ echo "Error: Milestone directory not found at $MILESTONE_DIR"
50
+ echo "Run archive_milestone step first to create it"
51
+ exit 1
52
+ fi
53
+
54
+ # --- Helper: check if phase number is in range (supports decimals like 02.1) ---
55
+ in_range() {
56
+ local phase_num="$1"
57
+ echo "$phase_num" | awk -v s="$START" -v e="$END" '{
58
+ # Strip leading zeros for comparison
59
+ val = $1 + 0
60
+ if (val >= s && val <= e + 0.999) exit 0
61
+ else exit 1
62
+ }'
63
+ }
64
+
65
+ # --- Stage 1: Consolidate summaries ---
66
+ SUMMARIES_FILE="$MILESTONE_DIR/PHASE-SUMMARIES.md"
67
+ SUMMARY_COUNT=0
68
+
69
+ echo "# Phase Summaries: $VERSION" > "$SUMMARIES_FILE"
70
+ echo "" >> "$SUMMARIES_FILE"
71
+
72
+ for dir in "$PHASES_DIR"/*/; do
73
+ [ -d "$dir" ] || continue
74
+ dirname=$(basename "$dir")
75
+ phase_num="${dirname%%-*}"
76
+ phase_name="${dirname#*-}"
77
+
78
+ if in_range "$phase_num"; then
79
+ has_summaries=false
80
+ for f in "$dir"/*-SUMMARY.md; do
81
+ [ -f "$f" ] || continue
82
+ if [ "$has_summaries" = false ]; then
83
+ echo "## Phase $phase_num: $phase_name" >> "$SUMMARIES_FILE"
84
+ echo "" >> "$SUMMARIES_FILE"
85
+ has_summaries=true
86
+ fi
87
+ plan_file=$(basename "$f")
88
+ plan_id="${plan_file%-SUMMARY.md}"
89
+ echo "### $plan_id" >> "$SUMMARIES_FILE"
90
+ echo "" >> "$SUMMARIES_FILE"
91
+ cat "$f" >> "$SUMMARIES_FILE"
92
+ echo "" >> "$SUMMARIES_FILE"
93
+ SUMMARY_COUNT=$((SUMMARY_COUNT + 1))
94
+ done
95
+ fi
96
+ done
97
+
98
+ echo "Stage 1: Consolidated $SUMMARY_COUNT summaries to PHASE-SUMMARIES.md"
99
+
100
+ # --- Stage 2: Delete artifacts ---
101
+ DELETED=0
102
+ for dir in "$PHASES_DIR"/*/; do
103
+ [ -d "$dir" ] || continue
104
+ dirname=$(basename "$dir")
105
+ phase_num="${dirname%%-*}"
106
+
107
+ if in_range "$phase_num"; then
108
+ for f in "$dir"/*-CONTEXT.md "$dir"/*-DESIGN.md "$dir"/*-RESEARCH.md \
109
+ "$dir"/*-SUMMARY.md "$dir"/*-UAT.md "$dir"/*-VERIFICATION.md \
110
+ "$dir"/*-EXECUTION-ORDER.md; do
111
+ if [ -f "$f" ]; then
112
+ rm -f "$f"
113
+ DELETED=$((DELETED + 1))
114
+ fi
115
+ done
116
+ fi
117
+ done
118
+
119
+ echo "Stage 2: Deleted $DELETED artifact files"
120
+
121
+ # --- Stage 3: Move phase directories ---
122
+ mkdir -p "$MILESTONE_DIR/phases"
123
+ MOVED=0
124
+ for dir in "$PHASES_DIR"/*/; do
125
+ [ -d "$dir" ] || continue
126
+ dirname=$(basename "$dir")
127
+ phase_num="${dirname%%-*}"
128
+
129
+ if in_range "$phase_num"; then
130
+ mv "$dir" "$MILESTONE_DIR/phases/$dirname"
131
+ MOVED=$((MOVED + 1))
132
+ fi
133
+ done
134
+
135
+ echo "Stage 3: Moved $MOVED phase directories to milestones/$VERSION/phases/"
136
+ echo ""
137
+ echo "Archive complete: $SUMMARY_COUNT summaries, $DELETED artifacts deleted, $MOVED dirs moved"
138
+ exit 0