aether-colony 5.3.1 → 5.3.3

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 (165) hide show
  1. package/.aether/aether-utils.sh +181 -5
  2. package/.aether/commands/build.yaml +35 -0
  3. package/.aether/commands/entomb.yaml +1 -1
  4. package/.aether/commands/init.yaml +29 -12
  5. package/.aether/commands/oracle.yaml +70 -0
  6. package/.aether/commands/patrol.yaml +2 -2
  7. package/.aether/commands/run.yaml +3 -3
  8. package/.aether/commands/swarm.yaml +1 -1
  9. package/.aether/docs/command-playbooks/build-complete.md +41 -8
  10. package/.aether/docs/command-playbooks/build-full.md +7 -7
  11. package/.aether/docs/command-playbooks/build-prep.md +1 -1
  12. package/.aether/docs/command-playbooks/continue-advance.md +33 -0
  13. package/.aether/docs/command-playbooks/continue-finalize.md +15 -1
  14. package/.aether/docs/command-playbooks/continue-full.md +15 -1
  15. package/.aether/docs/source-of-truth-map.md +10 -10
  16. package/.aether/docs/structural-learning-stack.md +283 -0
  17. package/.aether/utils/consolidation-seal.sh +196 -0
  18. package/.aether/utils/consolidation.sh +127 -0
  19. package/.aether/utils/curation-ants/archivist.sh +97 -0
  20. package/.aether/utils/curation-ants/critic.sh +214 -0
  21. package/.aether/utils/curation-ants/herald.sh +102 -0
  22. package/.aether/utils/curation-ants/janitor.sh +121 -0
  23. package/.aether/utils/curation-ants/librarian.sh +99 -0
  24. package/.aether/utils/curation-ants/nurse.sh +153 -0
  25. package/.aether/utils/curation-ants/orchestrator.sh +181 -0
  26. package/.aether/utils/curation-ants/scribe.sh +164 -0
  27. package/.aether/utils/curation-ants/sentinel.sh +119 -0
  28. package/.aether/utils/event-bus.sh +301 -0
  29. package/.aether/utils/graph.sh +559 -0
  30. package/.aether/utils/instinct-store.sh +401 -0
  31. package/.aether/utils/learning.sh +79 -7
  32. package/.aether/utils/session.sh +13 -0
  33. package/.aether/utils/state-api.sh +1 -1
  34. package/.aether/utils/trust-scoring.sh +347 -0
  35. package/.aether/utils/worktree.sh +97 -0
  36. package/.claude/commands/ant/entomb.md +1 -1
  37. package/.claude/commands/ant/init.md +29 -12
  38. package/.claude/commands/ant/oracle.md +35 -0
  39. package/.claude/commands/ant/patrol.md +2 -2
  40. package/.claude/commands/ant/run.md +3 -3
  41. package/.claude/commands/ant/swarm.md +1 -1
  42. package/.opencode/commands/ant/build.md +35 -0
  43. package/.opencode/commands/ant/init.md +29 -12
  44. package/.opencode/commands/ant/oracle.md +35 -0
  45. package/.opencode/commands/ant/patrol.md +2 -2
  46. package/.opencode/commands/ant/run.md +3 -3
  47. package/CHANGELOG.md +83 -0
  48. package/README.md +34 -37
  49. package/bin/lib/update-transaction.js +8 -3
  50. package/bin/npx-entry.js +0 -0
  51. package/package.json +1 -1
  52. package/.aether/agents/aether-ambassador.md +0 -140
  53. package/.aether/agents/aether-archaeologist.md +0 -108
  54. package/.aether/agents/aether-architect.md +0 -133
  55. package/.aether/agents/aether-auditor.md +0 -144
  56. package/.aether/agents/aether-builder.md +0 -184
  57. package/.aether/agents/aether-chaos.md +0 -115
  58. package/.aether/agents/aether-chronicler.md +0 -122
  59. package/.aether/agents/aether-gatekeeper.md +0 -116
  60. package/.aether/agents/aether-includer.md +0 -117
  61. package/.aether/agents/aether-keeper.md +0 -177
  62. package/.aether/agents/aether-measurer.md +0 -128
  63. package/.aether/agents/aether-oracle.md +0 -137
  64. package/.aether/agents/aether-probe.md +0 -133
  65. package/.aether/agents/aether-queen.md +0 -286
  66. package/.aether/agents/aether-route-setter.md +0 -130
  67. package/.aether/agents/aether-sage.md +0 -106
  68. package/.aether/agents/aether-scout.md +0 -101
  69. package/.aether/agents/aether-surveyor-disciplines.md +0 -391
  70. package/.aether/agents/aether-surveyor-nest.md +0 -329
  71. package/.aether/agents/aether-surveyor-pathogens.md +0 -264
  72. package/.aether/agents/aether-surveyor-provisions.md +0 -334
  73. package/.aether/agents/aether-tracker.md +0 -137
  74. package/.aether/agents/aether-watcher.md +0 -174
  75. package/.aether/agents/aether-weaver.md +0 -130
  76. package/.aether/commands/claude/archaeology.md +0 -334
  77. package/.aether/commands/claude/build.md +0 -65
  78. package/.aether/commands/claude/chaos.md +0 -336
  79. package/.aether/commands/claude/colonize.md +0 -259
  80. package/.aether/commands/claude/continue.md +0 -60
  81. package/.aether/commands/claude/council.md +0 -507
  82. package/.aether/commands/claude/data-clean.md +0 -81
  83. package/.aether/commands/claude/dream.md +0 -268
  84. package/.aether/commands/claude/entomb.md +0 -498
  85. package/.aether/commands/claude/export-signals.md +0 -57
  86. package/.aether/commands/claude/feedback.md +0 -96
  87. package/.aether/commands/claude/flag.md +0 -151
  88. package/.aether/commands/claude/flags.md +0 -169
  89. package/.aether/commands/claude/focus.md +0 -76
  90. package/.aether/commands/claude/help.md +0 -154
  91. package/.aether/commands/claude/history.md +0 -140
  92. package/.aether/commands/claude/import-signals.md +0 -71
  93. package/.aether/commands/claude/init.md +0 -505
  94. package/.aether/commands/claude/insert-phase.md +0 -105
  95. package/.aether/commands/claude/interpret.md +0 -278
  96. package/.aether/commands/claude/lay-eggs.md +0 -210
  97. package/.aether/commands/claude/maturity.md +0 -113
  98. package/.aether/commands/claude/memory-details.md +0 -77
  99. package/.aether/commands/claude/migrate-state.md +0 -171
  100. package/.aether/commands/claude/oracle.md +0 -642
  101. package/.aether/commands/claude/organize.md +0 -232
  102. package/.aether/commands/claude/patrol.md +0 -620
  103. package/.aether/commands/claude/pause-colony.md +0 -233
  104. package/.aether/commands/claude/phase.md +0 -115
  105. package/.aether/commands/claude/pheromones.md +0 -156
  106. package/.aether/commands/claude/plan.md +0 -693
  107. package/.aether/commands/claude/preferences.md +0 -65
  108. package/.aether/commands/claude/quick.md +0 -100
  109. package/.aether/commands/claude/redirect.md +0 -76
  110. package/.aether/commands/claude/resume-colony.md +0 -197
  111. package/.aether/commands/claude/resume.md +0 -388
  112. package/.aether/commands/claude/run.md +0 -231
  113. package/.aether/commands/claude/seal.md +0 -774
  114. package/.aether/commands/claude/skill-create.md +0 -286
  115. package/.aether/commands/claude/status.md +0 -410
  116. package/.aether/commands/claude/swarm.md +0 -349
  117. package/.aether/commands/claude/tunnels.md +0 -426
  118. package/.aether/commands/claude/update.md +0 -132
  119. package/.aether/commands/claude/verify-castes.md +0 -143
  120. package/.aether/commands/claude/watch.md +0 -239
  121. package/.aether/commands/opencode/archaeology.md +0 -331
  122. package/.aether/commands/opencode/build.md +0 -1168
  123. package/.aether/commands/opencode/chaos.md +0 -329
  124. package/.aether/commands/opencode/colonize.md +0 -195
  125. package/.aether/commands/opencode/continue.md +0 -1436
  126. package/.aether/commands/opencode/council.md +0 -437
  127. package/.aether/commands/opencode/data-clean.md +0 -77
  128. package/.aether/commands/opencode/dream.md +0 -260
  129. package/.aether/commands/opencode/entomb.md +0 -377
  130. package/.aether/commands/opencode/export-signals.md +0 -54
  131. package/.aether/commands/opencode/feedback.md +0 -99
  132. package/.aether/commands/opencode/flag.md +0 -149
  133. package/.aether/commands/opencode/flags.md +0 -167
  134. package/.aether/commands/opencode/focus.md +0 -73
  135. package/.aether/commands/opencode/help.md +0 -157
  136. package/.aether/commands/opencode/history.md +0 -136
  137. package/.aether/commands/opencode/import-signals.md +0 -68
  138. package/.aether/commands/opencode/init.md +0 -518
  139. package/.aether/commands/opencode/insert-phase.md +0 -111
  140. package/.aether/commands/opencode/interpret.md +0 -272
  141. package/.aether/commands/opencode/lay-eggs.md +0 -213
  142. package/.aether/commands/opencode/maturity.md +0 -108
  143. package/.aether/commands/opencode/memory-details.md +0 -83
  144. package/.aether/commands/opencode/migrate-state.md +0 -165
  145. package/.aether/commands/opencode/oracle.md +0 -593
  146. package/.aether/commands/opencode/organize.md +0 -226
  147. package/.aether/commands/opencode/patrol.md +0 -626
  148. package/.aether/commands/opencode/pause-colony.md +0 -203
  149. package/.aether/commands/opencode/phase.md +0 -113
  150. package/.aether/commands/opencode/pheromones.md +0 -162
  151. package/.aether/commands/opencode/plan.md +0 -684
  152. package/.aether/commands/opencode/preferences.md +0 -71
  153. package/.aether/commands/opencode/quick.md +0 -91
  154. package/.aether/commands/opencode/redirect.md +0 -84
  155. package/.aether/commands/opencode/resume-colony.md +0 -190
  156. package/.aether/commands/opencode/resume.md +0 -394
  157. package/.aether/commands/opencode/run.md +0 -237
  158. package/.aether/commands/opencode/seal.md +0 -452
  159. package/.aether/commands/opencode/skill-create.md +0 -63
  160. package/.aether/commands/opencode/status.md +0 -307
  161. package/.aether/commands/opencode/swarm.md +0 -15
  162. package/.aether/commands/opencode/tunnels.md +0 -400
  163. package/.aether/commands/opencode/update.md +0 -127
  164. package/.aether/commands/opencode/verify-castes.md +0 -139
  165. package/.aether/commands/opencode/watch.md +0 -227
@@ -1,774 +0,0 @@
1
- <!-- Generated from .aether/commands/seal.yaml - DO NOT EDIT DIRECTLY -->
2
- ---
3
- name: ant:seal
4
- description: "🏺🐜🏺 Seal the colony with Crowned Anthill milestone"
5
- ---
6
-
7
- You are the **Queen**. Seal the colony with a ceremony — no archiving.
8
-
9
- ## Instructions
10
-
11
- Parse `$ARGUMENTS`:
12
- - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
13
- - Otherwise: set `visual_mode = true`
14
-
15
- <failure_modes>
16
- ### Crowned Anthill Write Failure
17
- If writing the Crowned Anthill milestone document fails:
18
- - Do not mark the colony as sealed in state
19
- - Report the error -- sealing is incomplete
20
- - Recovery: user can re-run /ant:seal after fixing the issue
21
-
22
- ### State Update Failure After Seal
23
- If COLONY_STATE.json update fails after seal document is written:
24
- - The seal document exists but state doesn't reflect it
25
- - Report the inconsistency
26
- - Options: (1) Retry state update only, (2) Manual state fix, (3) Re-run /ant:seal
27
- </failure_modes>
28
-
29
- <success_criteria>
30
- Command is complete when:
31
- - Crowned Anthill milestone document is written
32
- - COLONY_STATE.json reflects sealed status
33
- - All phase evidence is summarized in the seal document
34
- - User sees confirmation of successful seal
35
- </success_criteria>
36
-
37
- <read_only>
38
- Do not touch during seal:
39
- - .aether/dreams/ (user notes)
40
- - .aether/chambers/ (archived colonies -- seal does NOT archive)
41
- - Source code files
42
- - .env* files
43
- - .claude/settings.json
44
- </read_only>
45
-
46
- ### Step 0: Initialize Visual Mode (if enabled)
47
-
48
- If `visual_mode` is true:
49
- ### Step 1: Read State
50
-
51
- Read `.aether/data/COLONY_STATE.json`.
52
-
53
- If file missing or `goal: null`:
54
- ```
55
- No colony initialized. Run /ant:init first.
56
- ```
57
- Stop here.
58
-
59
- Extract: `goal`, `state`, `current_phase`, `plan.phases`, `milestone`, `version`, `initialized_at`.
60
-
61
- ### Step 2: Maturity Gate
62
-
63
- Run `bash .aether/aether-utils.sh milestone-detect` to get `milestone`, `phases_completed`, `total_phases`.
64
-
65
- **If milestone is already "Crowned Anthill":**
66
- ```
67
- Colony already sealed at Crowned Anthill.
68
- Run /ant:entomb to archive this colony to chambers.
69
- ```
70
- Stop here.
71
-
72
- **If state is "EXECUTING":**
73
- ```
74
- Colony is still executing. Run /ant:continue first.
75
- ```
76
- Stop here.
77
-
78
- **If all phases complete** (phases_completed == total_phases, or milestone is "Sealed Chambers"):
79
- - Set `incomplete_warning = ""` (no warning needed)
80
- - Proceed to Step 3.
81
-
82
- **If phases are incomplete** (any other milestone — First Mound, Open Chambers, Brood Stable, Ventilated Nest, etc.):
83
- - Set `incomplete_warning = "WARNING: {phases_completed} of {total_phases} phases complete. Sealing now will mark incomplete work as the final state."`
84
- - Proceed to Step 3 (warn but DO NOT block).
85
-
86
- ### Step 3: Confirmation
87
-
88
- Display what will be sealed:
89
- ```
90
- SEAL COLONY
91
-
92
- Goal: {goal}
93
- Phases: {phases_completed} of {total_phases} completed
94
- Current Milestone: {milestone}
95
-
96
- {If incomplete_warning is not empty, display it here}
97
-
98
- This will:
99
- - Award the Crowned Anthill milestone
100
- - Write CROWNED-ANTHILL.md ceremony record
101
- - Promote colony wisdom to QUEEN.md
102
-
103
- Seal this colony? (yes/no)
104
- ```
105
-
106
- Use `AskUserQuestion with yes/no options`.
107
-
108
- If not "yes":
109
- ```
110
- Sealing cancelled. Colony remains active.
111
- ```
112
- Stop here.
113
-
114
- ### Step 3.5: Analytics Review
115
-
116
- Before wisdom approval, spawn Sage to analyze colony trends and provide data-driven insights.
117
-
118
- **Check phase threshold and spawn Sage:**
119
- ```bash
120
- # Check if colony has enough history for meaningful analytics
121
- phases_completed=$(jq '[.plan.phases[] | select(.status == "completed")] | length' .aether/data/COLONY_STATE.json 2>/dev/null || echo "0")
122
-
123
- if [[ "$phases_completed" -ge 3 ]]; then
124
- # Generate Sage name and dispatch
125
- sage_name=$(bash .aether/aether-utils.sh generate-ant-name "sage")
126
- bash .aether/aether-utils.sh spawn-log "Queen" "sage" "$sage_name" "Colony analytics review"
127
-
128
- # Display spawn notification
129
- echo ""
130
- echo "━━━ 📜🐜 S A G E ━━━"
131
- echo "──── 📜🐜 Spawning $sage_name — Colony analytics review ────"
132
- fi
133
- ```
134
-
135
- **Spawn Sage using Task tool when threshold is met:**
136
- If phases_completed >= 3, spawn the Sage agent using Task tool with `subagent_type="aether-sage"`:
137
-
138
- ```xml
139
- <task>
140
- <description>📜 Sage {sage_name}: Colony analytics review</description>
141
- <prompt>
142
- You are {sage_name}, a 📜 Sage Ant.
143
-
144
- Mission: Analyze colony history and provide data-driven insights for wisdom promotion
145
-
146
- Data Sources:
147
- - COLONY_STATE.json: Colony configuration, phases, learnings, instincts
148
- - activity.log: Activity history with timestamps
149
- - midden.json: Failure patterns and flagged issues
150
-
151
- Analysis Areas:
152
- 1. Velocity Trends: Phase completion rate over time
153
- 2. Bug Density: Error frequency and patterns from midden
154
- 3. Review Turnaround: Time from build to continue
155
-
156
- Work:
157
- 1. Read COLONY_STATE.json for phase history and learnings
158
- 2. Read activity.log for velocity patterns
159
- 3. Read midden.json for bug density analysis
160
- 4. Calculate metrics and identify trends
161
- 5. Provide recommendations for wisdom promotion
162
-
163
- **IMPORTANT:** You are strictly read-only. Do not modify any files.
164
-
165
- Log activity: bash .aether/aether-utils.sh activity-log "ANALYZING" "{sage_name}" "description"
166
-
167
- Return ONLY this JSON (no other text):
168
- {{
169
- "ant_name": "{sage_name}",
170
- "caste": "sage",
171
- "status": "completed" | "failed" | "blocked",
172
- "summary": "What you analyzed and found",
173
- "key_findings": [],
174
- "trends": {{
175
- "velocity": "increasing|stable|decreasing",
176
- "bug_density": "high|medium|low",
177
- "review_turnaround": "fast|moderate|slow"
178
- }},
179
- "metrics_analyzed": [],
180
- "predictions": [],
181
- "recommendations": [
182
- {{"priority": 1, "action": "", "expected_impact": ""}}
183
- ],
184
- "next_steps": [],
185
- "blockers": []
186
- }}
187
- </prompt>
188
- </task>
189
- ```
190
-
191
- **FALLBACK:** If "Agent type not found", use general-purpose agent and inject role: "You are a Sage Ant - analytics specialist that extracts trends from history to guide decisions."
192
-
193
- **Parse Sage JSON output:**
194
- After spawn, extract from response: `key_findings`, `trends`, `recommendations`
195
-
196
- Log completion and update swarm display:
197
- ```bash
198
- bash .aether/aether-utils.sh spawn-complete "$sage_name" "completed" "Analytics review complete"
199
- ```
200
-
201
- **Display Sage completion line:**
202
- ```
203
- 📜 {sage_name}: Colony analytics review complete ✓
204
- Velocity: {trend} | Bug density: {level} | Review turnaround: {speed}
205
- ```
206
-
207
- **Log high-priority recommendations to midden (non-blocking):**
208
- For each recommendation with priority <= 2:
209
- ```bash
210
- bash .aether/aether-utils.sh midden-write "analytics" "Sage recommendation (P{priority}): {action}" "sage"
211
- ```
212
-
213
- **Display insights summary:**
214
- ```
215
- 📜 Sage Insights:
216
- Key Findings: {count}
217
- Top Recommendation: {first recommendation action}
218
- ```
219
-
220
- **Continue to Step 3.6 (non-blocking):**
221
- Proceed to Step 3.6 regardless of Sage findings — Sage is strictly non-blocking.
222
-
223
- **If phases_completed < 3:**
224
- Skip silently (no output) — proceed directly to Step 3.6.
225
-
226
- ### Step 3.6: Wisdom Approval
227
-
228
- Before sealing, review wisdom proposals accumulated during this colony's lifecycle.
229
-
230
- ```bash
231
- # --- Batch auto-promotion for auto-threshold observations (QUEEN-02) ---
232
- # Auto-promote observations meeting higher recurrence thresholds
233
- # before presenting the interactive review for lower-threshold proposals.
234
-
235
- obs_file=".aether/data/learning-observations.json"
236
- auto_promoted_count=0
237
-
238
- if [[ -f "$obs_file" ]]; then
239
- for encoded in $(jq -r '.observations[] | @base64' "$obs_file" 2>/dev/null); do
240
- content=$(echo "$encoded" | base64 -d | jq -r '.content // empty')
241
- wisdom_type=$(echo "$encoded" | base64 -d | jq -r '.wisdom_type // "pattern"')
242
- colony=$(echo "$encoded" | base64 -d | jq -r '.colonies[0] // "unknown"')
243
- [[ -z "$content" ]] && continue
244
-
245
- result=$(bash .aether/aether-utils.sh learning-promote-auto "$wisdom_type" "$content" "$colony" "learning" 2>/dev/null || echo '{}')
246
- was_promoted=$(echo "$result" | jq -r '.result.promoted // false' 2>/dev/null || echo "false")
247
- if [[ "$was_promoted" == "true" ]]; then
248
- auto_promoted_count=$((auto_promoted_count + 1))
249
- fi
250
- done
251
- fi
252
-
253
- if [[ "$auto_promoted_count" -gt 0 ]]; then
254
- echo "Auto-promoted $auto_promoted_count observation(s) to QUEEN.md (met recurrence thresholds)"
255
- echo ""
256
- fi
257
- # --- END Batch auto-promotion ---
258
-
259
- # Check for pending proposals
260
- proposals=$(bash .aether/aether-utils.sh learning-check-promotion 2>/dev/null || echo '{"proposals":[]}')
261
- proposal_count=$(echo "$proposals" | jq '.proposals | length')
262
-
263
- if [[ "$proposal_count" -gt 0 ]]; then
264
- echo ""
265
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
266
- echo " 🧠 WISDOM REVIEW"
267
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
268
- echo ""
269
- echo "Review wisdom proposals before sealing this colony."
270
- echo "Approved proposals will be promoted to QUEEN.md."
271
- echo ""
272
-
273
- # Run approval workflow (blocking)
274
- bash .aether/aether-utils.sh learning-approve-proposals
275
-
276
- echo ""
277
- echo "Wisdom review complete. Proceeding with sealing ceremony..."
278
- echo ""
279
- else
280
- echo "No wisdom proposals to review."
281
- fi
282
- ```
283
-
284
- ### Step 3.7: Hive Promotion (NON-BLOCKING)
285
-
286
- After QUEEN.md promotion, promote abstracted instincts to the cross-colony hive.
287
-
288
- **Extract high-confidence instincts for hive promotion:**
289
- ```bash
290
- # Get instincts with confidence >= 0.8
291
- high_conf_instincts=$(jq -r '.memory.instincts[] | select(.confidence >= 0.8) | @base64' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
292
-
293
- # Derive source repo name from current directory
294
- source_repo="$(pwd)"
295
-
296
- # Read domain tags from registry (NOT from instinct.domain which is a category, not a repo domain)
297
- repo_domain_tags=$(jq -r --arg repo "$(pwd)" \
298
- '[.repos[] | select(.path == $repo) | .domain_tags // []] | .[0] // [] | join(",")' \
299
- "$HOME/.aether/registry.json" 2>/dev/null || echo "")
300
-
301
- hive_promoted_count=0
302
- hive_errors=0
303
- for encoded in $high_conf_instincts; do
304
- [[ -z "$encoded" ]] && continue
305
-
306
- # Extract trigger and action fields from the instinct object
307
- trigger=$(echo "$encoded" | base64 -d | jq -r '.trigger // empty')
308
- action=$(echo "$encoded" | base64 -d | jq -r '.action // empty')
309
- confidence=$(echo "$encoded" | base64 -d | jq -r '.confidence // 0.7')
310
-
311
- [[ -z "$trigger" || -z "$action" ]] && continue
312
-
313
- # Strip leading "When " or "when " from trigger to avoid "When When..." stutter
314
- trigger_clean=$(echo "$trigger" | sed 's/^[Ww]hen //')
315
-
316
- # Build the promotion text in "When {trigger}: {action}" format
317
- promote_text="When ${trigger_clean}: ${action}"
318
-
319
- # Build hive-promote args with --text and --source-repo (required)
320
- promote_args=(hive-promote --text "$promote_text" --source-repo "$source_repo" --confidence "$confidence")
321
- [[ -n "$repo_domain_tags" ]] && promote_args+=(--domain "$repo_domain_tags")
322
-
323
- # Call hive-promote which orchestrates abstract + store
324
- result=$(bash .aether/aether-utils.sh "${promote_args[@]}" 2>/dev/null || echo '{}')
325
- was_promoted=$(echo "$result" | jq -r '.result.action // "skipped"' 2>/dev/null || echo "skipped")
326
-
327
- if [[ "$was_promoted" == "promoted" || "$was_promoted" == "merged" ]]; then
328
- hive_promoted_count=$((hive_promoted_count + 1))
329
- fi
330
- done
331
-
332
- if [[ "$hive_promoted_count" -gt 0 ]]; then
333
- echo "Hive promotion: $hive_promoted_count instinct(s) promoted to cross-colony hive"
334
- fi
335
- ```
336
-
337
- **Continue to Step 4 (non-blocking):**
338
- Proceed to Step 4 regardless of hive promotion results — hive promotion is strictly non-blocking.
339
-
340
- ### Step 4: Log Seal Activity
341
-
342
- Log the seal ceremony to activity log:
343
- ```bash
344
- bash .aether/aether-utils.sh activity-log "MODIFIED" "Queen" "Colony sealed - wisdom review completed"
345
- ```
346
-
347
- ### Step 4.4: Checkpoint State
348
-
349
- Before modifying colony state, create a rolling backup:
350
-
351
- Run using the Bash tool with description "Checkpointing colony state before seal...":
352
- ```bash
353
- bash .aether/aether-utils.sh state-checkpoint "pre-seal" 2>/dev/null || echo "Warning: State checkpoint failed -- continuing without backup" >&2
354
- ```
355
-
356
- ### Step 4.5: Increment Colony Version
357
-
358
- Before writing the Crowned Anthill milestone, increment `colony_version` in COLONY_STATE.json.
359
-
360
- ```bash
361
- # Read current colony_version (default to 0 for backward compat with older colonies)
362
- current_colony_version=$(jq -r '.colony_version // 0' .aether/data/COLONY_STATE.json 2>/dev/null || echo 0)
363
- # Guard against non-integer values (floats, strings)
364
- [[ "$current_colony_version" =~ ^[0-9]+$ ]] || current_colony_version=0
365
- new_colony_version=$(( current_colony_version + 1 ))
366
-
367
- # Write incremented value back — guard against empty output destroying the file
368
- updated=$(jq --argjson v "$new_colony_version" '.colony_version = $v' .aether/data/COLONY_STATE.json 2>/dev/null)
369
- if [[ -n "$updated" && ${#updated} -gt 10 ]]; then
370
- echo "$updated" > .aether/data/COLONY_STATE.json
371
- else
372
- echo "Warning: jq update failed — colony_version defaults to 1, state file unchanged"
373
- new_colony_version=1
374
- fi
375
- ```
376
-
377
- Use `new_colony_version` as `{colony_version}` throughout the rest of the seal ceremony (e.g., display as "Crowned Anthill v{colony_version}").
378
-
379
- **Error handling:** If jq fails or produces empty/short output, COLONY_STATE.json is NOT overwritten and `new_colony_version` defaults to 1. Never let version increment failures block the seal.
380
-
381
- ### Step 5: Update Milestone to Crowned Anthill
382
-
383
- Update COLONY_STATE.json:
384
- 1. Set `milestone` to `"Crowned Anthill"`
385
- 2. Set `milestone_updated_at` to current ISO-8601 timestamp
386
- 3. Append event: `"<timestamp>|milestone_reached|seal|Achieved Crowned Anthill milestone"`
387
-
388
- Run `bash .aether/aether-utils.sh validate-state colony` after write.
389
-
390
- ### Step 5.1: Update Changelog
391
-
392
- **MANDATORY: Record the seal in the project changelog. This step is never skipped.**
393
-
394
- If no `CHANGELOG.md` exists, `changelog-append` creates one automatically.
395
-
396
- Build a summary of what the colony accomplished across all phases:
397
- - Collect completed phase names from COLONY_STATE.json
398
- - Summarize the goal and key outcomes in one line
399
-
400
- ```bash
401
- bash .aether/aether-utils.sh changelog-append \
402
- "$(date +%Y-%m-%d)" \
403
- "seal-crowned-anthill" \
404
- "00" \
405
- "{key_files_csv}" \
406
- "Colony sealed at Crowned Anthill;{goal}" \
407
- "{phases_completed} phases completed;Colony wisdom promoted to QUEEN.md" \
408
- ""
409
- ```
410
-
411
- - `{key_files_csv}` — list the most significant files created or modified across the colony's lifetime (derive from phase plans or git log)
412
- - `{goal}` — the colony goal from COLONY_STATE.json
413
-
414
- **Error handling:** If `changelog-append` fails, log to midden and continue — changelog failure never blocks sealing.
415
-
416
- ### Step 5.2: Update Registry (Silent)
417
-
418
- Mark the colony as inactive in the global registry. This is silent on failure — registry is not required for the colony to work.
419
-
420
- Run using the Bash tool (ignore errors):
421
- ```bash
422
- bash .aether/aether-utils.sh registry-add "$(pwd)" "$(jq -r '.version // "unknown"' ~/.aether/version.json 2>/dev/null || echo 'unknown')" --active false 2>/dev/null || true
423
- ```
424
-
425
- If the command fails, proceed silently. This is optional bookkeeping.
426
-
427
- ### Step 5.5: Documentation Coverage Audit
428
-
429
- Before writing the seal document, spawn a Chronicler to survey documentation coverage.
430
-
431
- **Generate Chronicler name and dispatch:**
432
- ```bash
433
- # Generate unique chronicler name
434
- chronicler_name=$(bash .aether/aether-utils.sh generate-ant-name "chronicler")
435
-
436
- # Log spawn and update swarm display
437
- bash .aether/aether-utils.sh spawn-log "Queen" "chronicler" "$chronicler_name" "Documentation coverage audit"
438
- ```
439
-
440
- **Display:**
441
- ```
442
- ━━━ 📝🐜 C H R O N I C L E R ━━━
443
- ──── 📝🐜 Spawning {chronicler_name} — documentation coverage audit ────
444
- ```
445
-
446
- **Spawn Chronicler using Task tool:**
447
- Spawn the Chronicler using Task tool with `subagent_type="aether-chronicler"`:
448
-
449
- ```xml
450
- <task>
451
- <description>📝 Chronicler {chronicler_name}: Documentation coverage audit</description>
452
- <prompt>
453
- You are {chronicler_name}, a 📝 Chronicler Ant.
454
-
455
- Mission: Documentation coverage audit before seal ceremony
456
-
457
- Survey the following documentation types:
458
- - README.md (project overview, quick start)
459
- - API documentation (endpoints, parameters, responses)
460
- - Guides (tutorials, how-tos, best practices)
461
- - Changelogs (version history, release notes)
462
- - Code comments (JSDoc, TSDoc inline documentation)
463
- - Architecture docs (system design, decisions)
464
-
465
- Work:
466
- 1. Check if README.md exists and covers: installation, usage, examples
467
- 2. Look for docs/ directory and survey guide coverage
468
- 3. Check for API documentation (OpenAPI, README sections, etc.)
469
- 4. Verify CHANGELOG.md exists and has recent entries
470
- 5. Sample source files for inline documentation coverage
471
- 6. Identify documentation gaps (missing, outdated, incomplete)
472
-
473
- **IMPORTANT:** You are strictly read-only. Do not modify any files.
474
-
475
- Log activity: bash .aether/aether-utils.sh activity-log "SURVEYING" "{chronicler_name}" "description"
476
-
477
- Return ONLY this JSON (no other text):
478
- {
479
- "ant_name": "{chronicler_name}",
480
- "caste": "chronicler",
481
- "status": "completed" | "failed" | "blocked",
482
- "summary": "What you surveyed and found",
483
- "documentation_created": [],
484
- "documentation_updated": [],
485
- "pages_documented": 0,
486
- "code_examples_verified": [],
487
- "coverage_percent": 0,
488
- "gaps_identified": [
489
- {"type": "README|API|Guide|Changelog|Comments|Architecture", "severity": "high|medium|low", "description": "...", "location": "..."}
490
- ],
491
- "blockers": []
492
- }
493
- </prompt>
494
- </task>
495
- ```
496
-
497
- **FALLBACK:** If "Agent type not found", use general-purpose agent and inject role: "You are a Chronicler Ant - documentation specialist that surveys and identifies documentation gaps."
498
-
499
- **Parse Chronicler JSON output:**
500
- Extract from response: `coverage_percent`, `gaps_identified`, `pages_documented`
501
-
502
- Log completion and update swarm display:
503
- ```bash
504
- bash .aether/aether-utils.sh spawn-complete "$chronicler_name" "completed" "Documentation audit complete"
505
- ```
506
-
507
- **Display Chronicler completion line:**
508
- ```
509
- 📝 {chronicler_name}: Documentation coverage audit ({pages_documented} pages, {coverage_percent}% coverage) ✓
510
- ```
511
-
512
- **Log gaps to midden (non-blocking):**
513
- For each gap in `gaps_identified` with severity "high" or "medium":
514
- ```bash
515
- bash .aether/aether-utils.sh midden-write "documentation" "Gap ({severity}): {description} at {location}" "chronicler"
516
- ```
517
-
518
- **Display summary:**
519
- ```
520
- 📝 Chronicler complete — {coverage_percent}% coverage, {gap_count} gaps logged to midden
521
- ```
522
-
523
- **Continue to Step 6 (non-blocking):**
524
- Proceed to Step 6 regardless of Chronicler findings — Chronicler is strictly non-blocking.
525
-
526
- ### Step 6: Write CROWNED-ANTHILL.md
527
-
528
- Calculate colony age:
529
- ```bash
530
- initialized_at=$(jq -r '.initialized_at // empty' .aether/data/COLONY_STATE.json)
531
- if [[ -n "$initialized_at" ]]; then
532
- init_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$initialized_at" +%s 2>/dev/null || echo 0)
533
- now_epoch=$(date +%s)
534
- if [[ "$init_epoch" -gt 0 ]]; then
535
- colony_age_days=$(( (now_epoch - init_epoch) / 86400 ))
536
- else
537
- colony_age_days=0
538
- fi
539
- else
540
- colony_age_days=0
541
- fi
542
- ```
543
-
544
- Extract phase recap:
545
- ```bash
546
- phase_recap=""
547
- while IFS= read -r phase_line; do
548
- phase_name=$(echo "$phase_line" | jq -r '.name')
549
- phase_status=$(echo "$phase_line" | jq -r '.status')
550
- phase_recap="${phase_recap} - ${phase_name}: ${phase_status}\n"
551
- done < <(jq -c '.plan.phases[]' .aether/data/COLONY_STATE.json 2>/dev/null)
552
- ```
553
-
554
- Write the seal document:
555
- ```bash
556
- version=$(jq -r '.version // "3.0"' .aether/data/COLONY_STATE.json)
557
- seal_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
558
- ```
559
-
560
- Resolve the crowned-anthill template path:
561
- Check ~/.aether/system/templates/crowned-anthill.template.md first,
562
- then .aether/templates/crowned-anthill.template.md.
563
-
564
- If no template found: output "Template missing: crowned-anthill.template.md. Run aether update to fix." and stop.
565
-
566
- Read the template file. Fill all {{PLACEHOLDER}} values:
567
- - {{GOAL}} → goal (from colony state)
568
- - {{SEAL_DATE}} → seal_date (ISO-8601 UTC timestamp)
569
- - {{VERSION}} → version (from colony state)
570
- - {{TOTAL_PHASES}} → total_phases
571
- - {{PHASES_COMPLETED}} → phases_completed
572
- - {{COLONY_AGE_DAYS}} → colony_age_days
573
- - {{PROMOTIONS_MADE}} → promotions_made
574
- - {{PHASE_RECAP}} → phase recap list (one entry per line, formatted from the bash loop above)
575
-
576
- Remove the HTML comment lines at the top of the template (lines starting with <!--).
577
- Write the result to .aether/CROWNED-ANTHILL.md using the Write tool.
578
-
579
- ### Step 6.5: Export XML Archive (best-effort)
580
-
581
- Export colony data as a combined XML archive and a standalone pheromones.xml. Both are best-effort — seal proceeds even if XML export fails.
582
-
583
- ```bash
584
- # Check if xmllint is available
585
- if command -v xmllint >/dev/null 2>&1; then
586
- xml_result=$(bash .aether/aether-utils.sh colony-archive-xml ".aether/exchange/colony-archive.xml" 2>&1)
587
- xml_ok=$(echo "$xml_result" | jq -r '.ok // false' 2>/dev/null)
588
- if [[ "$xml_ok" == "true" ]]; then
589
- xml_pheromone_count=$(echo "$xml_result" | jq -r '.result.pheromone_count // 0' 2>/dev/null)
590
- xml_export_line="XML Archive: colony-archive.xml (${xml_pheromone_count} active signals)"
591
- else
592
- xml_export_line="XML Archive: export failed (non-blocking)"
593
- fi
594
-
595
- # Also export standalone pheromones.xml for cross-colony sharing
596
- pher_result=$(bash .aether/aether-utils.sh pheromone-export-xml ".aether/exchange/pheromones.xml" 2>&1)
597
- pher_ok=$(echo "$pher_result" | jq -r '.ok // false' 2>/dev/null)
598
- if [[ "$pher_ok" == "true" ]]; then
599
- pher_signal_count=$(jq '[.signals[] | select(.active != false)] | length' .aether/data/pheromones.json 2>/dev/null || echo "0")
600
- pher_export_line="Signal Export: pheromones.xml (${pher_signal_count} signals, importable by other colonies)"
601
- else
602
- pher_export_line="Signal Export: failed (non-blocking)"
603
- fi
604
-
605
- # Export standalone queen-wisdom.xml for cross-colony wisdom sharing
606
- wisdom_result=$(bash .aether/aether-utils.sh wisdom-export-xml ".aether/exchange/queen-wisdom.xml" 2>&1)
607
- wisdom_ok=$(echo "$wisdom_result" | jq -r '.ok // false' 2>/dev/null)
608
- if [[ "$wisdom_ok" == "true" ]]; then
609
- wisdom_count=$(echo "$wisdom_result" | jq -r '.result.entries // 0' 2>/dev/null)
610
- wisdom_export_line="Wisdom Export: queen-wisdom.xml (${wisdom_count} entries)"
611
- else
612
- wisdom_export_line="Wisdom Export: failed (non-blocking)"
613
- fi
614
-
615
- # Export standalone colony-registry.xml for lineage tracking
616
- registry_result=$(bash .aether/aether-utils.sh registry-export-xml ".aether/exchange/colony-registry.xml" 2>&1)
617
- registry_ok=$(echo "$registry_result" | jq -r '.ok // false' 2>/dev/null)
618
- if [[ "$registry_ok" == "true" ]]; then
619
- registry_count=$(echo "$registry_result" | jq -r '.result.colonies // 0' 2>/dev/null)
620
- registry_export_line="Registry Export: colony-registry.xml (${registry_count} colonies)"
621
- else
622
- registry_export_line="Registry Export: failed (non-blocking)"
623
- fi
624
- else
625
- xml_export_line="XML Archive: skipped (xmllint not available)"
626
- pher_export_line="Signal Export: skipped (xmllint not available)"
627
- wisdom_export_line="Wisdom Export: skipped (xmllint not available)"
628
- registry_export_line="Registry Export: skipped (xmllint not available)"
629
- fi
630
- ```
631
-
632
- ### Step 7: Display Ceremony
633
-
634
-
635
- Display the ASCII art ceremony:
636
- ```
637
- . .
638
- /|\ /|\
639
- / | \ / | \
640
- / | X | \
641
- / | / \ | \
642
- / |/ \| \
643
- / / \ \
644
- /____ / ___ \ ____\
645
- / / \ \
646
- / / \ \
647
- /_/ \_\
648
- | CROWNED |
649
- | ANTHILL |
650
- |__________|
651
- ```
652
-
653
- Below the ASCII art, display:
654
- ```
655
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
656
- C R O W N E D A N T H I L L v{colony_version}
657
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
658
-
659
- Goal: {goal}
660
- Phases: {phases_completed} of {total_phases} completed
661
- Milestone: Crowned Anthill v{colony_version}
662
- {If incomplete_warning is not empty: display it}
663
- Wisdom Promoted: {promotion_summary}
664
-
665
- Seal Document: .aether/CROWNED-ANTHILL.md
666
- {xml_export_line}
667
- {pher_export_line}
668
- {wisdom_export_line}
669
- {registry_export_line}
670
-
671
- The colony stands crowned and sealed.
672
- Its wisdom lives on in QUEEN.md.
673
- The anthill has reached its final form.
674
-
675
- ──────────────────────────────────────────────────
676
- 🐜 Next Up
677
- ──────────────────────────────────────────────────
678
- /ant:entomb 🏺 Archive colony to chambers
679
- /ant:lay-eggs 🥚 Start a new colony
680
- /ant:tunnels 🗄️ Browse archived chambers
681
- ```
682
-
683
- ### Step 7.5: Commit Suggestion (Non-blocking)
684
-
685
- After the ceremony, offer to commit all colony work.
686
-
687
- **Gate check — skip silently if any fail:**
688
- 1. Not a git repo: `git rev-parse --git-dir 2>/dev/null` fails → skip
689
- 2. Clean working tree: `git status --porcelain 2>/dev/null` is empty → skip to Step 7.6 (may still want to push)
690
-
691
- **If uncommitted changes exist:**
692
-
693
- Generate a seal commit message:
694
- ```bash
695
- seal_commit=$(bash .aether/aether-utils.sh generate-commit-message seal "$phases_completed" "$goal" "$colony_age_days" 2>/dev/null)
696
- seal_message=$(echo "$seal_commit" | jq -r '.result.message // "aether-seal: colony sealed"')
697
- seal_body=$(echo "$seal_commit" | jq -r '.result.body // ""')
698
- ```
699
-
700
- Display the suggestion:
701
- ```
702
- ──────────────────────────────────────────────────
703
- Commit suggestion:
704
-
705
- $seal_message
706
-
707
- $seal_body
708
- ──────────────────────────────────────────────────
709
- ```
710
-
711
- Prompt with AskUserQuestion (3 options):
712
- 1. **Commit with this message** — Run `git add -A && git commit -m "$seal_message" -m "$seal_body"`
713
- 2. **Edit message** — Ask user for their preferred message, then commit with that
714
- 3. **Skip** — Do not commit
715
-
716
- If the user chooses option 1 or 2 and the commit succeeds, set `seal_committed = true`.
717
- If the commit fails or user skips, set `seal_committed = false`.
718
-
719
- **Error handling:** If `generate-commit-message` fails, fall back to message `"aether-seal: colony sealed"`. Never let commit suggestion failures stop the seal flow.
720
-
721
- ### Step 7.6: Push Suggestion (Non-blocking)
722
-
723
- Only show if a commit was just made in Step 7.5 (`seal_committed == true`) OR if there are unpushed commits.
724
-
725
- **Gate check — skip silently if any fail:**
726
- 1. Not a git repo → skip
727
- 2. No remote configured: `git remote -v 2>/dev/null` is empty → skip
728
-
729
- **Check for unpushed commits:**
730
- ```bash
731
- unpushed=$(git log --oneline @{u}..HEAD 2>/dev/null | wc -l | tr -d ' ')
732
- ```
733
- If `unpushed == 0` and `seal_committed == false` → skip (nothing to push)
734
-
735
- **If there are commits to push:**
736
-
737
- Detect current branch and upstream status:
738
- ```bash
739
- current_branch=$(git branch --show-current)
740
- has_upstream=$(git rev-parse --abbrev-ref @{u} 2>/dev/null && echo "yes" || echo "no")
741
- ```
742
-
743
- Display:
744
- ```
745
- Push {unpushed} commit(s) to remote?
746
- Branch: {current_branch}
747
- ```
748
-
749
- Prompt with AskUserQuestion (2 options):
750
- 1. **Push now** — If upstream exists: `git push`. If no upstream: `git push -u origin $current_branch`
751
- 2. **I'll push later** — Skip
752
-
753
- Display result: `Pushed to origin/{current_branch}` on success, or `Push skipped` if declined.
754
-
755
- **Error handling:** If push fails, display the error message but do not stop the seal flow. Suggest: "You can push manually with `git push`."
756
-
757
- **Safety:** Never auto-push. Always require explicit user approval via AskUserQuestion.
758
-
759
- ### Edge Cases
760
-
761
- **Colony already at Crowned Anthill:**
762
- - Display message and guide to /ant:entomb. Do NOT re-seal.
763
-
764
- **Phases incomplete:**
765
- - Warn but allow. The seal proceeds after confirmation.
766
-
767
- **Missing QUEEN.md:**
768
- - queen-init creates it. If that fails, skip promotion (non-fatal).
769
-
770
- **Missing initialized_at:**
771
- - Colony age defaults to 0 days.
772
-
773
- **Empty phases array:**
774
- - Can seal a colony with 0 phases (rare but valid). phases_completed = 0, total_phases = 0.