aether-colony 3.1.17 → 5.0.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.
Files changed (183) hide show
  1. package/{runtime → .aether}/CONTEXT.md +1 -1
  2. package/{runtime → .aether}/aether-utils.sh +1772 -98
  3. package/.aether/docs/QUEEN-SYSTEM.md +211 -0
  4. package/.aether/docs/QUEEN.md +84 -0
  5. package/.aether/docs/README.md +68 -0
  6. package/.aether/docs/caste-system.md +48 -0
  7. package/{runtime → .aether/docs/disciplines}/DISCIPLINES.md +8 -8
  8. package/.aether/docs/error-codes.md +268 -0
  9. package/{runtime → .aether}/docs/known-issues.md +42 -26
  10. package/.aether/docs/queen-commands.md +97 -0
  11. package/.aether/exchange/colony-registry.xml +11 -0
  12. package/{runtime → .aether}/exchange/pheromone-xml.sh +2 -1
  13. package/.aether/exchange/pheromones.xml +87 -0
  14. package/.aether/exchange/queen-wisdom.xml +14 -0
  15. package/{runtime → .aether}/exchange/registry-xml.sh +7 -3
  16. package/{runtime → .aether}/exchange/wisdom-xml.sh +11 -4
  17. package/.aether/rules/aether-colony.md +134 -0
  18. package/.aether/schemas/example-prompt-builder.xml +234 -0
  19. package/.aether/templates/colony-state-reset.jq.template +22 -0
  20. package/.aether/templates/colony-state.template.json +35 -0
  21. package/.aether/templates/constraints.template.json +9 -0
  22. package/.aether/templates/crowned-anthill.template.md +36 -0
  23. package/.aether/templates/handoff-build-error.template.md +30 -0
  24. package/.aether/templates/handoff-build-success.template.md +39 -0
  25. package/.aether/templates/handoff.template.md +40 -0
  26. package/{runtime → .aether}/utils/atomic-write.sh +5 -5
  27. package/{runtime → .aether}/utils/chamber-compare.sh +23 -10
  28. package/{runtime → .aether}/utils/chamber-utils.sh +32 -20
  29. package/{runtime → .aether}/utils/error-handler.sh +13 -1
  30. package/{runtime → .aether}/utils/file-lock.sh +49 -13
  31. package/.aether/utils/semantic-cli.sh +413 -0
  32. package/{runtime → .aether}/utils/xml-compose.sh +7 -1
  33. package/.aether/utils/xml-convert.sh +273 -0
  34. package/.aether/utils/xml-query.sh +201 -0
  35. package/.aether/utils/xml-utils.sh +110 -0
  36. package/{runtime → .aether}/workers.md +14 -17
  37. package/.claude/agents/ant/aether-ambassador.md +264 -0
  38. package/.claude/agents/ant/aether-archaeologist.md +322 -0
  39. package/.claude/agents/ant/aether-auditor.md +266 -0
  40. package/.claude/agents/ant/aether-builder.md +187 -0
  41. package/.claude/agents/ant/aether-chaos.md +268 -0
  42. package/.claude/agents/ant/aether-chronicler.md +304 -0
  43. package/.claude/agents/ant/aether-gatekeeper.md +325 -0
  44. package/.claude/agents/ant/aether-includer.md +373 -0
  45. package/.claude/agents/ant/aether-keeper.md +271 -0
  46. package/.claude/agents/ant/aether-measurer.md +317 -0
  47. package/.claude/agents/ant/aether-probe.md +210 -0
  48. package/.claude/agents/ant/aether-queen.md +325 -0
  49. package/.claude/agents/ant/aether-route-setter.md +173 -0
  50. package/.claude/agents/ant/aether-sage.md +353 -0
  51. package/.claude/agents/ant/aether-scout.md +142 -0
  52. package/.claude/agents/ant/aether-surveyor-disciplines.md +416 -0
  53. package/.claude/agents/ant/aether-surveyor-nest.md +354 -0
  54. package/.claude/agents/ant/aether-surveyor-pathogens.md +288 -0
  55. package/.claude/agents/ant/aether-surveyor-provisions.md +359 -0
  56. package/.claude/agents/ant/aether-tracker.md +265 -0
  57. package/.claude/agents/ant/aether-watcher.md +244 -0
  58. package/.claude/agents/ant/aether-weaver.md +247 -0
  59. package/.claude/commands/ant/archaeology.md +16 -7
  60. package/.claude/commands/ant/build.md +415 -284
  61. package/.claude/commands/ant/chaos.md +19 -10
  62. package/.claude/commands/ant/colonize.md +58 -24
  63. package/.claude/commands/ant/continue.md +155 -145
  64. package/.claude/commands/ant/council.md +15 -5
  65. package/.claude/commands/ant/dream.md +16 -7
  66. package/.claude/commands/ant/entomb.md +274 -157
  67. package/.claude/commands/ant/feedback.md +33 -29
  68. package/.claude/commands/ant/flag.md +18 -10
  69. package/.claude/commands/ant/flags.md +14 -6
  70. package/.claude/commands/ant/focus.md +29 -21
  71. package/.claude/commands/ant/help.md +11 -1
  72. package/.claude/commands/ant/history.md +10 -0
  73. package/.claude/commands/ant/init.md +91 -65
  74. package/.claude/commands/ant/interpret.md +15 -4
  75. package/.claude/commands/ant/lay-eggs.md +55 -7
  76. package/.claude/commands/ant/maturity.md +11 -1
  77. package/.claude/commands/ant/migrate-state.md +14 -2
  78. package/.claude/commands/ant/oracle.md +23 -15
  79. package/.claude/commands/ant/organize.md +29 -20
  80. package/.claude/commands/ant/pause-colony.md +17 -7
  81. package/.claude/commands/ant/phase.md +17 -8
  82. package/.claude/commands/ant/plan.md +20 -9
  83. package/.claude/commands/ant/redirect.md +29 -32
  84. package/.claude/commands/ant/resume-colony.md +19 -9
  85. package/.claude/commands/ant/resume.md +272 -96
  86. package/.claude/commands/ant/seal.md +201 -191
  87. package/.claude/commands/ant/status.md +71 -32
  88. package/.claude/commands/ant/swarm.md +26 -44
  89. package/.claude/commands/ant/tunnels.md +279 -105
  90. package/.claude/commands/ant/update.md +81 -20
  91. package/.claude/commands/ant/verify-castes.md +14 -4
  92. package/.claude/commands/ant/watch.md +13 -12
  93. package/.opencode/agents/aether-ambassador.md +63 -20
  94. package/.opencode/agents/aether-archaeologist.md +29 -12
  95. package/.opencode/agents/aether-auditor.md +51 -18
  96. package/.opencode/agents/aether-builder.md +69 -19
  97. package/.opencode/agents/aether-chaos.md +29 -12
  98. package/.opencode/agents/aether-chronicler.md +60 -18
  99. package/.opencode/agents/aether-gatekeeper.md +27 -18
  100. package/.opencode/agents/aether-includer.md +27 -18
  101. package/.opencode/agents/aether-keeper.md +89 -18
  102. package/.opencode/agents/aether-measurer.md +27 -18
  103. package/.opencode/agents/aether-probe.md +60 -18
  104. package/.opencode/agents/aether-queen.md +172 -24
  105. package/.opencode/agents/aether-route-setter.md +57 -12
  106. package/.opencode/agents/aether-sage.md +26 -18
  107. package/.opencode/agents/aether-scout.md +27 -19
  108. package/.opencode/agents/aether-surveyor-disciplines.md +53 -1
  109. package/.opencode/agents/aether-surveyor-nest.md +53 -1
  110. package/.opencode/agents/aether-surveyor-pathogens.md +51 -1
  111. package/.opencode/agents/aether-surveyor-provisions.md +53 -1
  112. package/.opencode/agents/aether-tracker.md +64 -18
  113. package/.opencode/agents/aether-watcher.md +66 -19
  114. package/.opencode/agents/aether-weaver.md +61 -18
  115. package/.opencode/commands/ant/build.md +406 -192
  116. package/.opencode/commands/ant/continue.md +66 -76
  117. package/.opencode/commands/ant/entomb.md +106 -45
  118. package/.opencode/commands/ant/init.md +46 -48
  119. package/.opencode/commands/ant/organize.md +5 -5
  120. package/.opencode/commands/ant/resume.md +334 -0
  121. package/.opencode/commands/ant/seal.md +33 -24
  122. package/.opencode/commands/ant/status.md +11 -0
  123. package/.opencode/commands/ant/tunnels.md +149 -0
  124. package/.opencode/commands/ant/update.md +59 -16
  125. package/CHANGELOG.md +79 -0
  126. package/README.md +135 -353
  127. package/bin/cli.js +243 -122
  128. package/bin/generate-commands.sh +2 -2
  129. package/bin/lib/init.js +13 -3
  130. package/bin/lib/update-transaction.js +119 -117
  131. package/bin/sync-to-runtime.sh +5 -137
  132. package/bin/validate-package.sh +84 -0
  133. package/package.json +9 -6
  134. package/.opencode/agents/aether-architect.md +0 -66
  135. package/.opencode/agents/aether-guardian.md +0 -107
  136. package/.opencode/agents/workers.md +0 -1034
  137. package/runtime/QUEEN_ANT_ARCHITECTURE.md +0 -402
  138. package/runtime/data/signatures.json +0 -41
  139. package/runtime/docs/AETHER-2.0-IMPLEMENTATION-PLAN.md +0 -1343
  140. package/runtime/docs/AETHER-PHEROMONE-SYSTEM-MASTER-SPEC.md +0 -2642
  141. package/runtime/docs/PHEROMONE-INJECTION.md +0 -240
  142. package/runtime/docs/PHEROMONE-INTEGRATION.md +0 -192
  143. package/runtime/docs/PHEROMONE-SYSTEM-DESIGN.md +0 -426
  144. package/runtime/docs/README.md +0 -94
  145. package/runtime/docs/VISUAL-OUTPUT-SPEC.md +0 -219
  146. package/runtime/docs/biological-reference.md +0 -272
  147. package/runtime/docs/codebase-review.md +0 -399
  148. package/runtime/docs/command-sync.md +0 -164
  149. package/runtime/docs/constraints.md +0 -116
  150. package/runtime/docs/implementation-learnings.md +0 -89
  151. package/runtime/docs/namespace.md +0 -148
  152. package/runtime/docs/pathogen-schema-example.json +0 -36
  153. package/runtime/docs/pathogen-schema.md +0 -111
  154. package/runtime/docs/planning-discipline.md +0 -159
  155. package/runtime/docs/progressive-disclosure.md +0 -184
  156. package/runtime/lib/queen-utils.sh +0 -729
  157. package/runtime/planning.md +0 -159
  158. package/runtime/recover.sh +0 -136
  159. package/runtime/utils/xml-utils.sh +0 -2196
  160. package/runtime/workers-new-castes.md +0 -516
  161. /package/{runtime → .aether/docs/disciplines}/coding-standards.md +0 -0
  162. /package/{runtime → .aether/docs/disciplines}/debugging.md +0 -0
  163. /package/{runtime → .aether/docs/disciplines}/learning.md +0 -0
  164. /package/{runtime → .aether/docs/disciplines}/tdd.md +0 -0
  165. /package/{runtime → .aether/docs/disciplines}/verification-loop.md +0 -0
  166. /package/{runtime → .aether/docs/disciplines}/verification.md +0 -0
  167. /package/{runtime → .aether}/docs/pheromones.md +0 -0
  168. /package/{runtime → .aether}/model-profiles.yaml +0 -0
  169. /package/{runtime → .aether}/schemas/aether-types.xsd +0 -0
  170. /package/{runtime → .aether}/schemas/colony-registry.xsd +0 -0
  171. /package/{runtime → .aether}/schemas/pheromone.xsd +0 -0
  172. /package/{runtime → .aether}/schemas/prompt.xsd +0 -0
  173. /package/{runtime → .aether}/schemas/queen-wisdom.xsd +0 -0
  174. /package/{runtime → .aether}/schemas/worker-priming.xsd +0 -0
  175. /package/{runtime → .aether}/templates/QUEEN.md.template +0 -0
  176. /package/{runtime → .aether}/utils/colorize-log.sh +0 -0
  177. /package/{runtime → .aether}/utils/queen-to-md.xsl +0 -0
  178. /package/{runtime → .aether}/utils/spawn-tree.sh +0 -0
  179. /package/{runtime → .aether}/utils/spawn-with-model.sh +0 -0
  180. /package/{runtime → .aether}/utils/state-loader.sh +0 -0
  181. /package/{runtime → .aether}/utils/swarm-display.sh +0 -0
  182. /package/{runtime → .aether}/utils/watch-spawn-tree.sh +0 -0
  183. /package/{runtime → .aether}/utils/xml-core.sh +0 -0
@@ -3,7 +3,7 @@ name: ant:seal
3
3
  description: "🏺🐜🏺 Seal the colony with Crowned Anthill milestone"
4
4
  ---
5
5
 
6
- You are the **Queen**. Seal the colony when all work is complete.
6
+ You are the **Queen**. Seal the colony with a ceremony no archiving.
7
7
 
8
8
  ## Instructions
9
9
 
@@ -11,6 +11,37 @@ Parse `$ARGUMENTS`:
11
11
  - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
12
12
  - Otherwise: set `visual_mode = true`
13
13
 
14
+ <failure_modes>
15
+ ### Crowned Anthill Write Failure
16
+ If writing the Crowned Anthill milestone document fails:
17
+ - Do not mark the colony as sealed in state
18
+ - Report the error -- sealing is incomplete
19
+ - Recovery: user can re-run /ant:seal after fixing the issue
20
+
21
+ ### State Update Failure After Seal
22
+ If COLONY_STATE.json update fails after seal document is written:
23
+ - The seal document exists but state doesn't reflect it
24
+ - Report the inconsistency
25
+ - Options: (1) Retry state update only, (2) Manual state fix, (3) Re-run /ant:seal
26
+ </failure_modes>
27
+
28
+ <success_criteria>
29
+ Command is complete when:
30
+ - Crowned Anthill milestone document is written
31
+ - COLONY_STATE.json reflects sealed status
32
+ - All phase evidence is summarized in the seal document
33
+ - User sees confirmation of successful seal
34
+ </success_criteria>
35
+
36
+ <read_only>
37
+ Do not touch during seal:
38
+ - .aether/dreams/ (user notes)
39
+ - .aether/chambers/ (archived colonies -- seal does NOT archive)
40
+ - Source code files
41
+ - .env* files
42
+ - .claude/settings.json
43
+ </read_only>
44
+
14
45
  ### Step 0: Initialize Visual Mode (if enabled)
15
46
 
16
47
  If `visual_mode` is true:
@@ -18,9 +49,8 @@ If `visual_mode` is true:
18
49
  # Generate session ID
19
50
  seal_id="seal-$(date +%s)"
20
51
 
21
- # Initialize swarm display
22
- bash .aether/aether-utils.sh swarm-display-init "$seal_id"
23
- bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "excavating" "Sealing colony" "Colony" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "fungus_garden" 0
52
+ # Initialize swarm display (consolidated)
53
+ bash .aether/aether-utils.sh swarm-display-init "$seal_id" && bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "excavating" "Sealing colony" "Colony" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "fungus_garden" 0
24
54
  ```
25
55
 
26
56
  ### Step 1: Read State
@@ -33,102 +63,64 @@ No colony initialized. Run /ant:init first.
33
63
  ```
34
64
  Stop here.
35
65
 
36
- #### Step 1.5: Check for Concurrent Seal Operations
37
-
38
- Capture session start time:
39
- ```bash
40
- SEAL_START=$(date +%s)
41
- ```
42
-
43
- Check for existing seal operations (in-progress archives):
44
- ```bash
45
- # Check for incomplete archive directories (no manifest.json)
46
- incomplete_archives=$(find .aether/data/archive -type d -name "session_*_archive" 2>/dev/null | while read dir; do
47
- if [[ ! -f "$dir/manifest.json" ]]; then
48
- echo "$dir"
49
- fi
50
- done)
51
-
52
- if [[ -n "$incomplete_archives" ]]; then
53
- echo "Warning: Incomplete archive operations detected:"
54
- echo "$incomplete_archives"
55
- echo ""
56
- echo "These may be from interrupted seal operations."
57
- echo "Proceeding will create a new archive."
58
- fi
59
- ```
60
-
61
- ### Step 2: Validate Colony Is Complete
66
+ Extract: `goal`, `state`, `current_phase`, `plan.phases`, `milestone`, `version`, `initialized_at`.
62
67
 
63
- Extract: `goal`, `current_phase`, `plan.phases`, `milestone`, `state`.
68
+ ### Step 2: Maturity Gate
64
69
 
65
- **Precondition 1: All phases must be completed**
70
+ Run `bash .aether/aether-utils.sh milestone-detect` to get `milestone`, `phases_completed`, `total_phases`.
66
71
 
67
- Check if all phases in `plan.phases` have `status: "completed"`:
68
- ```
69
- all_completed = all(phase.status == "completed" for phase in plan.phases)
72
+ **If milestone is already "Crowned Anthill":**
70
73
  ```
71
-
72
- If NOT all completed:
73
- ```
74
- Cannot archive colony with incomplete phases.
75
-
76
- Completed phases: X of Y
77
- Remaining: {list of incomplete phase names}
78
-
79
- Run /ant:continue to complete remaining phases first.
74
+ Colony already sealed at Crowned Anthill.
75
+ Run /ant:entomb to archive this colony to chambers.
80
76
  ```
81
77
  Stop here.
82
78
 
83
- **Precondition 2: State must not be EXECUTING**
84
-
85
- If `state == "EXECUTING"`:
79
+ **If state is "EXECUTING":**
86
80
  ```
87
- Colony is still executing. Run /ant:continue to reconcile first.
81
+ Colony is still executing. Run /ant:continue first.
88
82
  ```
89
83
  Stop here.
90
84
 
91
- ### Step 3: Check Milestone Eligibility
85
+ **If all phases complete** (phases_completed == total_phases, or milestone is "Sealed Chambers"):
86
+ - Set `incomplete_warning = ""` (no warning needed)
87
+ - Proceed to Step 3.
92
88
 
93
- The full milestone progression is:
94
- - **First Mound** Phase 1 complete (first runnable)
95
- - **Open Chambers** Feature work underway (2+ phases complete)
96
- - **Brood Stable** — Tests consistently green
97
- - **Ventilated Nest** — Perf/latency acceptable (build + lint clean)
98
- - **Sealed Chambers** — All phases complete (interfaces frozen)
99
- - **Crowned Anthill** — Release-ready (user confirms via /ant:seal)
89
+ **If phases are incomplete** (any other milestone First Mound, Open Chambers, Brood Stable, Ventilated Nest, etc.):
90
+ - Set `incomplete_warning = "WARNING: {phases_completed} of {total_phases} phases complete. Sealing now will mark incomplete work as the final state."`
91
+ - Proceed to Step 3 (warn but DO NOT block).
100
92
 
101
- **If current milestone is "Crowned Anthill":**
102
- ```
103
- Colony is already at Crowned Anthill milestone.
104
- No further archiving needed.
93
+ ### Step 3: Confirmation
105
94
 
106
- Use /ant:status to view colony state.
95
+ Display what will be sealed:
107
96
  ```
108
- Stop here.
97
+ SEAL COLONY
109
98
 
110
- **If current milestone is "Sealed Chambers":**
111
- - Proceed to Step 4 (will upgrade to Crowned Anthill)
99
+ Goal: {goal}
100
+ Phases: {phases_completed} of {total_phases} completed
101
+ Current Milestone: {milestone}
112
102
 
113
- **If current milestone is "First Mound", "Open Chambers", "Brood Stable", "Ventilated Nest", or any intermediate milestone:**
114
- - Since all phases are complete, the colony qualifies for both Sealed Chambers and Crowned Anthill
115
- - The current logic allows proceeding to Step 4 (seal as Crowned Anthill)
116
- - If user wants to explicitly achieve Sealed Chambers first, they can manually update milestone via COLONY_STATE.json
103
+ {If incomplete_warning is not empty, display it here}
117
104
 
118
- **If milestone is unrecognized (not in the 6 known stages):**
105
+ This will:
106
+ - Award the Crowned Anthill milestone
107
+ - Write CROWNED-ANTHILL.md ceremony record
108
+ - Promote colony wisdom to QUEEN.md
109
+
110
+ Seal this colony? (yes/no)
119
111
  ```
120
- Unknown milestone: {milestone}
121
112
 
122
- The milestone "{milestone}" is not recognized.
123
- Known milestones: First Mound, Open Chambers, Brood Stable, Ventilated Nest, Sealed Chambers, Crowned Anthill
113
+ Use `AskUserQuestion with yes/no options`.
124
114
 
125
- Run /ant:status to check colony state.
115
+ If not "yes":
116
+ ```
117
+ Sealing cancelled. Colony remains active.
126
118
  ```
127
119
  Stop here.
128
120
 
129
121
  ### Step 4: Promote Colony Wisdom to QUEEN.md
130
122
 
131
- Before archiving, extract and promote significant patterns and decisions from the colony:
123
+ Extract and promote significant patterns, decisions, and instincts from the colony:
132
124
 
133
125
  ```bash
134
126
  # Ensure QUEEN.md exists
@@ -144,7 +136,7 @@ colony_name=$(jq -r '.session_id // empty' .aether/data/COLONY_STATE.json | sed
144
136
  promotions_made=0
145
137
  promotion_details=""
146
138
 
147
- # Extract and promote phase learnings (validated learnings with high confidence)
139
+ # Extract and promote phase learnings (validated learnings)
148
140
  while IFS= read -r learning; do
149
141
  claim=$(echo "$learning" | jq -r '.claim // empty')
150
142
  status=$(echo "$learning" | jq -r '.status // empty')
@@ -183,154 +175,172 @@ while IFS= read -r decision; do
183
175
  fi
184
176
  done < <(jq -c '.memory.decisions[]? // empty' .aether/data/COLONY_STATE.json 2>/dev/null)
185
177
 
178
+ # Promote high-confidence instincts
179
+ instinct_result=$(bash .aether/aether-utils.sh instinct-read --min-confidence 0.7 2>/dev/null || echo '{"ok":false}')
180
+ if echo "$instinct_result" | jq -e '.ok' >/dev/null 2>&1; then
181
+ while IFS= read -r instinct_action; do
182
+ if [[ -n "$instinct_action" && "$instinct_action" != "null" ]]; then
183
+ result=$(bash .aether/aether-utils.sh queen-promote "pattern" "$instinct_action" "$colony_name" 2>/dev/null)
184
+ if echo "$result" | jq -e '.ok' >/dev/null 2>&1; then
185
+ promotions_made=$((promotions_made + 1))
186
+ fi
187
+ fi
188
+ done < <(echo "$instinct_result" | jq -r '.result[]?.action // empty' 2>/dev/null)
189
+ fi
190
+
186
191
  # Log promotion results to activity log
187
- bash .aether/aether-utils.sh activity-log "MODIFIED" "Queen" "Promoted ${promotions_made} learnings/decisions to QUEEN.md from colony ${colony_name}"
192
+ bash .aether/aether-utils.sh activity-log "MODIFIED" "Queen" "Promoted ${promotions_made} learnings/decisions/instincts to QUEEN.md from colony ${colony_name}"
188
193
 
189
194
  # Store promotion summary for display
190
195
  promotion_summary="${promotions_made} wisdom entries promoted"
191
196
  ```
192
197
 
193
- ### Step 5: Archive Colony State
198
+ ### Step 5: Update Milestone to Crowned Anthill
194
199
 
195
- Create archive directory:
196
- ```
197
- archive_dir=".aether/data/archive/session_$(date -u +%s)_archive"
198
- mkdir -p "$archive_dir"
199
- ```
200
+ Update COLONY_STATE.json:
201
+ 1. Set `milestone` to `"Crowned Anthill"`
202
+ 2. Set `milestone_updated_at` to current ISO-8601 timestamp
203
+ 3. Append event: `"<timestamp>|milestone_reached|seal|Achieved Crowned Anthill milestone"`
200
204
 
201
- Copy the following files to the archive directory:
202
- 1. `.aether/data/COLONY_STATE.json` → `$archive_dir/COLONY_STATE.json`
203
- 2. `.aether/data/activity.log` → `$archive_dir/activity.log`
204
- 3. `.aether/data/spawn-tree.txt` → `$archive_dir/spawn-tree.txt`
205
- 4. `.aether/data/flags.json` → `$archive_dir/flags.json` (if exists)
206
- 5. `.aether/data/constraints.json` → `$archive_dir/constraints.json` (if exists)
207
-
208
- Create archive manifest file `$archive_dir/manifest.json`:
209
- ```json
210
- {
211
- "archived_at": "<ISO-8601 timestamp>",
212
- "goal": "<colony goal>",
213
- "total_phases": <number>,
214
- "milestone": "Crowned Anthill",
215
- "files": [
216
- "COLONY_STATE.json",
217
- "activity.log",
218
- "spawn-tree.txt",
219
- "flags.json",
220
- "constraints.json"
221
- ]
222
- }
223
- ```
205
+ Run `bash .aether/aether-utils.sh validate-state colony` after write.
224
206
 
225
- #### Step 5.5: Verify Archive Integrity
207
+ ### Step 6: Write CROWNED-ANTHILL.md
226
208
 
227
- Verify the archive was created successfully:
209
+ Calculate colony age:
228
210
  ```bash
229
- if [[ -f "$archive_dir/manifest.json" ]]; then
230
- echo "Archive verified: $archive_dir"
211
+ initialized_at=$(jq -r '.initialized_at // empty' .aether/data/COLONY_STATE.json)
212
+ if [[ -n "$initialized_at" ]]; then
213
+ init_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$initialized_at" +%s 2>/dev/null || echo 0)
214
+ now_epoch=$(date +%s)
215
+ if [[ "$init_epoch" -gt 0 ]]; then
216
+ colony_age_days=$(( (now_epoch - init_epoch) / 86400 ))
217
+ else
218
+ colony_age_days=0
219
+ fi
231
220
  else
232
- echo "Error: Archive creation incomplete"
233
- # Don't proceed with milestone update
234
- exit 1
221
+ colony_age_days=0
235
222
  fi
236
223
  ```
237
224
 
238
- ### Step 6: Update Milestone to Crowned Anthill
239
-
240
- Update COLONY_STATE.json:
241
- 1. Set `milestone` to `"Crowned Anthill"`
242
- 2. Set `milestone_updated_at` to current ISO-8601 timestamp
243
- 3. Append event: `"<timestamp>|milestone_reached|archive|Achieved Crowned Anthill milestone - colony archived"`
244
-
245
- ### Step 7: Write Final Handoff
246
-
247
- After archiving and promoting wisdom, write the final handoff documenting the completed colony:
248
-
225
+ Extract phase recap:
249
226
  ```bash
250
- cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
251
- # Colony Session SEALED (Crowned Anthill)
252
-
253
- ## 🏆 Colony Complete
254
- **Status:** Crowned Anthill — All phases completed and archived
255
-
256
- ## Archive Location
257
- {archive_dir}
258
-
259
- ## Colony Summary
260
- - Goal: "{goal}"
261
- - Total Phases: {total_phases}
262
- - Milestone: Crowned Anthill
263
- - Sealed At: {timestamp}
264
- - Wisdom Promoted: {promotion_summary}
265
-
266
- ## Files Archived
267
- - COLONY_STATE.json
268
- - activity.log
269
- - spawn-tree.txt
270
- - flags.json (if existed)
271
- - constraints.json (if existed)
272
-
273
- ## Session Note
274
- This colony has been sealed and archived. The anthill stands crowned.
275
- To start anew, run: /ant:lay-eggs "<new goal>"
276
- HANDOFF_EOF
227
+ phase_recap=""
228
+ while IFS= read -r phase_line; do
229
+ phase_name=$(echo "$phase_line" | jq -r '.name')
230
+ phase_status=$(echo "$phase_line" | jq -r '.status')
231
+ phase_recap="${phase_recap} - ${phase_name}: ${phase_status}\n"
232
+ done < <(jq -c '.plan.phases[]' .aether/data/COLONY_STATE.json 2>/dev/null)
277
233
  ```
278
234
 
279
- This handoff serves as the final record of the completed colony.
280
-
281
- ### Step 8: Display Result
282
-
283
- **If visual_mode is true, render final swarm display:**
235
+ Write the seal document:
284
236
  ```bash
285
- bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "completed" "Colony sealed" "Colony" '{"read":3,"grep":0,"edit":2,"bash":3}' 100 "fungus_garden" 100
286
- bash .aether/aether-utils.sh swarm-display-inline "$seal_id"
237
+ version=$(jq -r '.version // "3.0"' .aether/data/COLONY_STATE.json)
238
+ seal_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
287
239
  ```
288
240
 
289
- Output:
290
- ```
291
- 🏺 ════════════════════════════════════════════════════
292
- C R O W N E D A N T H I L L
293
- ══════════════════════════════════════════════════ 🏺
241
+ Resolve the crowned-anthill template path:
242
+ Check ~/.aether/system/templates/crowned-anthill.template.md first,
243
+ then .aether/templates/crowned-anthill.template.md.
244
+
245
+ If no template found: output "Template missing: crowned-anthill.template.md. Run aether update to fix." and stop.
294
246
 
295
- Colony archived successfully!
247
+ Read the template file. Fill all {{PLACEHOLDER}} values:
248
+ - {{GOAL}} → goal (from colony state)
249
+ - {{SEAL_DATE}} → seal_date (ISO-8601 UTC timestamp)
250
+ - {{VERSION}} → version (from colony state)
251
+ - {{TOTAL_PHASES}} → total_phases
252
+ - {{PHASES_COMPLETED}} → phases_completed
253
+ - {{COLONY_AGE_DAYS}} → colony_age_days
254
+ - {{PROMOTIONS_MADE}} → promotions_made
255
+ - {{PHASE_RECAP}} → phase recap list (one entry per line, formatted from the bash loop above)
296
256
 
297
- 👑 Goal: {goal (truncated to 60 chars)}
298
- 📍 Phases: {total_phases} completed
299
- 🏆 Milestone: Crowned Anthill
300
- 📚 Wisdom Promoted: {promotion_summary}
257
+ Remove the HTML comment lines at the top of the template (lines starting with <!--).
258
+ Write the result to .aether/CROWNED-ANTHILL.md using the Write tool.
301
259
 
302
- 📦 Archive Location: {archive_dir}
303
- - COLONY_STATE.json
304
- - activity.log
305
- - spawn-tree.txt
306
- - flags.json (if existed)
307
- - constraints.json (if existed)
260
+ ### Step 6.5: Export XML Archive (best-effort)
308
261
 
309
- 🐜 The colony has reached its final form.
310
- The anthill stands crowned and sealed.
311
- History is preserved. The colony rests.
262
+ Export colony data as a combined XML archive. This is best-effort — seal proceeds even if XML export fails.
312
263
 
313
- 💾 State persisted — safe to /clear
264
+ ```bash
265
+ # Check if xmllint is available
266
+ if command -v xmllint >/dev/null 2>&1; then
267
+ xml_result=$(bash .aether/aether-utils.sh colony-archive-xml ".aether/exchange/colony-archive.xml" 2>&1)
268
+ xml_ok=$(echo "$xml_result" | jq -r '.ok // false' 2>/dev/null)
269
+ if [[ "$xml_ok" == "true" ]]; then
270
+ xml_pheromone_count=$(echo "$xml_result" | jq -r '.result.pheromone_count // 0' 2>/dev/null)
271
+ xml_export_line="XML Archive: colony-archive.xml (${xml_pheromone_count} active signals)"
272
+ else
273
+ xml_export_line="XML Archive: export failed (non-blocking)"
274
+ fi
275
+ else
276
+ xml_export_line="XML Archive: skipped (xmllint not available)"
277
+ fi
278
+ ```
279
+
280
+ ### Step 7: Display Ceremony
314
281
 
315
- 🐜 What would you like to do next?
316
- 1. /ant:lay-eggs "<new goal>" — Start a new colony
317
- 2. /ant:tunnels — Browse archived colonies
318
- 3. /clear — Clear context and continue
282
+ **If visual_mode is true, render swarm display BEFORE the ASCII art (consolidated):**
283
+ ```bash
284
+ bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "completed" "Colony sealed" "Colony" '{"read":3,"grep":0,"edit":2,"bash":3}' 100 "fungus_garden" 100 && bash .aether/aether-utils.sh swarm-display-inline "$seal_id"
285
+ ```
319
286
 
320
- Use AskUserQuestion with these three options.
287
+ Display the ASCII art ceremony:
288
+ ```
289
+ . .
290
+ /|\ /|\
291
+ / | \ / | \
292
+ / | X | \
293
+ / | / \ | \
294
+ / |/ \| \
295
+ / / \ \
296
+ /____ / ___ \ ____\
297
+ / / \ \
298
+ / / \ \
299
+ /_/ \_\
300
+ | CROWNED |
301
+ | ANTHILL |
302
+ |__________|
303
+ ```
321
304
 
322
- If option 1 selected: proceed to run /ant:lay-eggs flow
323
- If option 2 selected: run /ant:tunnels
324
- If option 3 selected: display "Run /ant:lay-eggs to begin anew after clearing"
305
+ Below the ASCII art, display:
306
+ ```
307
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
308
+ C R O W N E D A N T H I L L
309
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
310
+
311
+ Goal: {goal}
312
+ Phases: {phases_completed} of {total_phases} completed
313
+ {If incomplete_warning is not empty: display it}
314
+ Wisdom Promoted: {promotion_summary}
315
+
316
+ Seal Document: .aether/CROWNED-ANTHILL.md
317
+ {xml_export_line}
318
+
319
+ The colony stands crowned and sealed.
320
+ Its wisdom lives on in QUEEN.md.
321
+ The anthill has reached its final form.
322
+
323
+ ──────────────────────────────────────────────────
324
+ 🐜 Next Up
325
+ ──────────────────────────────────────────────────
326
+ /ant:entomb 🏺 Archive colony to chambers
327
+ /ant:lay-eggs 🥚 Start a new colony
328
+ /ant:tunnels 🗄️ Browse archived chambers
325
329
  ```
326
330
 
327
331
  ### Edge Cases
328
332
 
329
- **If milestone is already "Sealed Chambers" but phases are complete:**
330
- - Proceed with archiving and upgrade to Crowned Anthill
333
+ **Colony already at Crowned Anthill:**
334
+ - Display message and guide to /ant:entomb. Do NOT re-seal.
335
+
336
+ **Phases incomplete:**
337
+ - Warn but allow. The seal proceeds after confirmation.
338
+
339
+ **Missing QUEEN.md:**
340
+ - queen-init creates it. If that fails, skip promotion (non-fatal).
331
341
 
332
- **If any archive files are missing:**
333
- - Archive what exists, note in manifest which files were missing
342
+ **Missing initialized_at:**
343
+ - Colony age defaults to 0 days.
334
344
 
335
- **If archive directory already exists:**
336
- - Append timestamp to make unique: `session_<ts>_archive_<random>`
345
+ **Empty phases array:**
346
+ - Can seal a colony with 0 phases (rare but valid). phases_completed = 0, total_phases = 0.