aether-colony 5.0.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/.aether/aether-utils.sh +3226 -3345
  2. package/.aether/agents-claude/aether-ambassador.md +265 -0
  3. package/.aether/agents-claude/aether-archaeologist.md +327 -0
  4. package/.aether/agents-claude/aether-architect.md +236 -0
  5. package/.aether/agents-claude/aether-auditor.md +271 -0
  6. package/.aether/agents-claude/aether-builder.md +224 -0
  7. package/.aether/agents-claude/aether-chaos.md +269 -0
  8. package/.aether/agents-claude/aether-chronicler.md +305 -0
  9. package/.aether/agents-claude/aether-gatekeeper.md +330 -0
  10. package/.aether/agents-claude/aether-includer.md +374 -0
  11. package/.aether/agents-claude/aether-keeper.md +272 -0
  12. package/.aether/agents-claude/aether-measurer.md +322 -0
  13. package/.aether/agents-claude/aether-oracle.md +237 -0
  14. package/.aether/agents-claude/aether-probe.md +211 -0
  15. package/.aether/agents-claude/aether-queen.md +330 -0
  16. package/.aether/agents-claude/aether-route-setter.md +178 -0
  17. package/.aether/agents-claude/aether-sage.md +418 -0
  18. package/.aether/agents-claude/aether-scout.md +179 -0
  19. package/.aether/agents-claude/aether-surveyor-disciplines.md +417 -0
  20. package/.aether/agents-claude/aether-surveyor-nest.md +355 -0
  21. package/.aether/agents-claude/aether-surveyor-pathogens.md +289 -0
  22. package/.aether/agents-claude/aether-surveyor-provisions.md +360 -0
  23. package/.aether/agents-claude/aether-tracker.md +270 -0
  24. package/.aether/agents-claude/aether-watcher.md +280 -0
  25. package/.aether/agents-claude/aether-weaver.md +248 -0
  26. package/.aether/commands/archaeology.yaml +653 -0
  27. package/.aether/commands/build.yaml +1221 -0
  28. package/.aether/commands/chaos.yaml +653 -0
  29. package/.aether/commands/colonize.yaml +442 -0
  30. package/.aether/commands/continue.yaml +1484 -0
  31. package/.aether/commands/council.yaml +509 -0
  32. package/.aether/commands/data-clean.yaml +80 -0
  33. package/.aether/commands/dream.yaml +275 -0
  34. package/.aether/commands/entomb.yaml +863 -0
  35. package/.aether/commands/export-signals.yaml +64 -0
  36. package/.aether/commands/feedback.yaml +158 -0
  37. package/.aether/commands/flag.yaml +160 -0
  38. package/.aether/commands/flags.yaml +177 -0
  39. package/.aether/commands/focus.yaml +112 -0
  40. package/.aether/commands/help.yaml +167 -0
  41. package/.aether/commands/history.yaml +137 -0
  42. package/.aether/commands/import-signals.yaml +79 -0
  43. package/.aether/commands/init.yaml +502 -0
  44. package/.aether/commands/insert-phase.yaml +102 -0
  45. package/.aether/commands/interpret.yaml +285 -0
  46. package/.aether/commands/lay-eggs.yaml +224 -0
  47. package/.aether/commands/maturity.yaml +122 -0
  48. package/.aether/commands/memory-details.yaml +74 -0
  49. package/.aether/commands/migrate-state.yaml +174 -0
  50. package/.aether/commands/oracle.yaml +1224 -0
  51. package/.aether/commands/organize.yaml +446 -0
  52. package/.aether/commands/patrol.yaml +621 -0
  53. package/.aether/commands/pause-colony.yaml +424 -0
  54. package/.aether/commands/phase.yaml +124 -0
  55. package/.aether/commands/pheromones.yaml +153 -0
  56. package/.aether/commands/plan.yaml +1364 -0
  57. package/.aether/commands/preferences.yaml +63 -0
  58. package/.aether/commands/quick.yaml +104 -0
  59. package/.aether/commands/redirect.yaml +123 -0
  60. package/.aether/commands/resume-colony.yaml +375 -0
  61. package/.aether/commands/resume.yaml +407 -0
  62. package/.aether/commands/run.yaml +229 -0
  63. package/.aether/commands/seal.yaml +1214 -0
  64. package/.aether/commands/skill-create.yaml +337 -0
  65. package/.aether/commands/status.yaml +408 -0
  66. package/.aether/commands/swarm.yaml +352 -0
  67. package/.aether/commands/tunnels.yaml +814 -0
  68. package/.aether/commands/update.yaml +131 -0
  69. package/.aether/commands/verify-castes.yaml +159 -0
  70. package/.aether/commands/watch.yaml +454 -0
  71. package/.aether/docs/INCIDENT_TEMPLATE.md +32 -0
  72. package/.aether/docs/QUEEN-SYSTEM.md +11 -11
  73. package/.aether/docs/README.md +32 -2
  74. package/.aether/docs/command-playbooks/README.md +23 -0
  75. package/.aether/docs/command-playbooks/build-complete.md +349 -0
  76. package/.aether/docs/command-playbooks/build-context.md +282 -0
  77. package/.aether/docs/command-playbooks/build-full.md +1683 -0
  78. package/.aether/docs/command-playbooks/build-prep.md +284 -0
  79. package/.aether/docs/command-playbooks/build-verify.md +405 -0
  80. package/.aether/docs/command-playbooks/build-wave.md +749 -0
  81. package/.aether/docs/command-playbooks/continue-advance.md +524 -0
  82. package/.aether/docs/command-playbooks/continue-finalize.md +447 -0
  83. package/.aether/docs/command-playbooks/continue-full.md +1725 -0
  84. package/.aether/docs/command-playbooks/continue-gates.md +686 -0
  85. package/.aether/docs/command-playbooks/continue-verify.md +407 -0
  86. package/.aether/docs/context-continuity.md +84 -0
  87. package/.aether/docs/disciplines/DISCIPLINES.md +9 -7
  88. package/.aether/docs/error-codes.md +1 -1
  89. package/.aether/docs/known-issues.md +34 -173
  90. package/.aether/docs/pheromones.md +86 -6
  91. package/.aether/docs/plans/pheromone-display-plan.md +257 -0
  92. package/.aether/docs/queen-commands.md +10 -9
  93. package/.aether/docs/source-of-truth-map.md +132 -0
  94. package/.aether/docs/xml-utilities.md +47 -0
  95. package/.aether/rules/aether-colony.md +23 -13
  96. package/.aether/scripts/incident-test-add.sh +47 -0
  97. package/.aether/scripts/weekly-audit.sh +79 -0
  98. package/.aether/skills/.index.json +649 -0
  99. package/.aether/skills/colony/.manifest.json +16 -0
  100. package/.aether/skills/colony/build-discipline/SKILL.md +78 -0
  101. package/.aether/skills/colony/colony-interaction/SKILL.md +56 -0
  102. package/.aether/skills/colony/colony-lifecycle/SKILL.md +77 -0
  103. package/.aether/skills/colony/colony-visuals/SKILL.md +112 -0
  104. package/.aether/skills/colony/context-management/SKILL.md +80 -0
  105. package/.aether/skills/colony/error-presentation/SKILL.md +99 -0
  106. package/.aether/skills/colony/pheromone-protocol/SKILL.md +79 -0
  107. package/.aether/skills/colony/pheromone-visibility/SKILL.md +81 -0
  108. package/.aether/skills/colony/state-safety/SKILL.md +84 -0
  109. package/.aether/skills/colony/worker-priming/SKILL.md +82 -0
  110. package/.aether/skills/domain/.manifest.json +24 -0
  111. package/.aether/skills/domain/README.md +33 -0
  112. package/.aether/skills/domain/django/SKILL.md +49 -0
  113. package/.aether/skills/domain/docker/SKILL.md +52 -0
  114. package/.aether/skills/domain/golang/SKILL.md +52 -0
  115. package/.aether/skills/domain/graphql/SKILL.md +51 -0
  116. package/.aether/skills/domain/html-css/SKILL.md +48 -0
  117. package/.aether/skills/domain/nextjs/SKILL.md +45 -0
  118. package/.aether/skills/domain/nodejs/SKILL.md +53 -0
  119. package/.aether/skills/domain/postgresql/SKILL.md +53 -0
  120. package/.aether/skills/domain/prisma/SKILL.md +59 -0
  121. package/.aether/skills/domain/python/SKILL.md +50 -0
  122. package/.aether/skills/domain/rails/SKILL.md +52 -0
  123. package/.aether/skills/domain/react/SKILL.md +45 -0
  124. package/.aether/skills/domain/rest-api/SKILL.md +58 -0
  125. package/.aether/skills/domain/svelte/SKILL.md +47 -0
  126. package/.aether/skills/domain/tailwind/SKILL.md +45 -0
  127. package/.aether/skills/domain/testing/SKILL.md +53 -0
  128. package/.aether/skills/domain/typescript/SKILL.md +58 -0
  129. package/.aether/skills/domain/vue/SKILL.md +49 -0
  130. package/.aether/templates/QUEEN.md.template +23 -41
  131. package/.aether/templates/colony-state-reset.jq.template +1 -0
  132. package/.aether/templates/colony-state.template.json +4 -0
  133. package/.aether/templates/learning-observations.template.json +6 -0
  134. package/.aether/templates/midden.template.json +13 -0
  135. package/.aether/templates/pheromones.template.json +6 -0
  136. package/.aether/templates/session.template.json +9 -0
  137. package/.aether/utils/atomic-write.sh +63 -17
  138. package/.aether/utils/chamber-utils.sh +145 -2
  139. package/.aether/utils/council.sh +425 -0
  140. package/.aether/utils/emoji-audit.sh +166 -0
  141. package/.aether/utils/error-handler.sh +21 -7
  142. package/.aether/utils/file-lock.sh +182 -27
  143. package/.aether/utils/flag.sh +278 -0
  144. package/.aether/utils/hive.sh +572 -0
  145. package/.aether/utils/immune.sh +508 -0
  146. package/.aether/utils/learning.sh +1928 -0
  147. package/.aether/utils/midden.sh +520 -0
  148. package/.aether/utils/oracle/oracle.md +168 -0
  149. package/.aether/utils/oracle/oracle.sh +1023 -0
  150. package/.aether/utils/pheromone.sh +2029 -0
  151. package/.aether/utils/queen.sh +1710 -0
  152. package/.aether/utils/scan.sh +860 -0
  153. package/.aether/utils/semantic-cli.sh +10 -8
  154. package/.aether/utils/session.sh +816 -0
  155. package/.aether/utils/skills.sh +509 -0
  156. package/.aether/utils/spawn-tree.sh +103 -271
  157. package/.aether/utils/spawn.sh +260 -0
  158. package/.aether/utils/state-api.sh +389 -0
  159. package/.aether/utils/state-loader.sh +8 -6
  160. package/.aether/utils/suggest.sh +611 -0
  161. package/.aether/utils/swarm-display.sh +10 -1
  162. package/.aether/utils/swarm.sh +1004 -0
  163. package/.aether/utils/watch-spawn-tree.sh +11 -2
  164. package/.aether/utils/xml-compose.sh +2 -2
  165. package/.aether/utils/xml-convert.sh +9 -5
  166. package/.aether/utils/xml-core.sh +5 -9
  167. package/.aether/utils/xml-query.sh +4 -4
  168. package/.aether/workers.md +86 -67
  169. package/.claude/agents/ant/aether-ambassador.md +2 -1
  170. package/.claude/agents/ant/aether-archaeologist.md +6 -1
  171. package/.claude/agents/ant/aether-architect.md +236 -0
  172. package/.claude/agents/ant/aether-auditor.md +6 -1
  173. package/.claude/agents/ant/aether-builder.md +38 -1
  174. package/.claude/agents/ant/aether-chaos.md +2 -1
  175. package/.claude/agents/ant/aether-chronicler.md +1 -0
  176. package/.claude/agents/ant/aether-gatekeeper.md +6 -1
  177. package/.claude/agents/ant/aether-includer.md +1 -0
  178. package/.claude/agents/ant/aether-keeper.md +1 -0
  179. package/.claude/agents/ant/aether-measurer.md +6 -1
  180. package/.claude/agents/ant/aether-oracle.md +237 -0
  181. package/.claude/agents/ant/aether-probe.md +2 -1
  182. package/.claude/agents/ant/aether-queen.md +6 -1
  183. package/.claude/agents/ant/aether-route-setter.md +6 -1
  184. package/.claude/agents/ant/aether-sage.md +68 -3
  185. package/.claude/agents/ant/aether-scout.md +38 -1
  186. package/.claude/agents/ant/aether-surveyor-disciplines.md +2 -1
  187. package/.claude/agents/ant/aether-surveyor-nest.md +2 -1
  188. package/.claude/agents/ant/aether-surveyor-pathogens.md +2 -1
  189. package/.claude/agents/ant/aether-surveyor-provisions.md +2 -1
  190. package/.claude/agents/ant/aether-tracker.md +6 -1
  191. package/.claude/agents/ant/aether-watcher.md +37 -1
  192. package/.claude/agents/ant/aether-weaver.md +2 -1
  193. package/.claude/commands/ant/archaeology.md +1 -8
  194. package/.claude/commands/ant/build.md +43 -1159
  195. package/.claude/commands/ant/chaos.md +1 -14
  196. package/.claude/commands/ant/colonize.md +3 -14
  197. package/.claude/commands/ant/continue.md +40 -1026
  198. package/.claude/commands/ant/council.md +213 -15
  199. package/.claude/commands/ant/data-clean.md +81 -0
  200. package/.claude/commands/ant/dream.md +12 -9
  201. package/.claude/commands/ant/entomb.md +62 -87
  202. package/.claude/commands/ant/export-signals.md +57 -0
  203. package/.claude/commands/ant/feedback.md +18 -0
  204. package/.claude/commands/ant/flag.md +12 -0
  205. package/.claude/commands/ant/flags.md +22 -8
  206. package/.claude/commands/ant/focus.md +18 -0
  207. package/.claude/commands/ant/help.md +40 -8
  208. package/.claude/commands/ant/history.md +3 -0
  209. package/.claude/commands/ant/import-signals.md +71 -0
  210. package/.claude/commands/ant/init.md +349 -191
  211. package/.claude/commands/ant/insert-phase.md +105 -0
  212. package/.claude/commands/ant/interpret.md +11 -0
  213. package/.claude/commands/ant/lay-eggs.md +167 -158
  214. package/.claude/commands/ant/maturity.md +22 -11
  215. package/.claude/commands/ant/memory-details.md +77 -0
  216. package/.claude/commands/ant/migrate-state.md +6 -0
  217. package/.claude/commands/ant/oracle.md +317 -62
  218. package/.claude/commands/ant/organize.md +10 -5
  219. package/.claude/commands/ant/patrol.md +620 -0
  220. package/.claude/commands/ant/pause-colony.md +8 -22
  221. package/.claude/commands/ant/phase.md +26 -37
  222. package/.claude/commands/ant/pheromones.md +156 -0
  223. package/.claude/commands/ant/plan.md +199 -50
  224. package/.claude/commands/ant/preferences.md +65 -0
  225. package/.claude/commands/ant/quick.md +100 -0
  226. package/.claude/commands/ant/redirect.md +18 -0
  227. package/.claude/commands/ant/resume-colony.md +37 -22
  228. package/.claude/commands/ant/resume.md +60 -7
  229. package/.claude/commands/ant/run.md +231 -0
  230. package/.claude/commands/ant/seal.md +506 -78
  231. package/.claude/commands/ant/skill-create.md +286 -0
  232. package/.claude/commands/ant/status.md +171 -1
  233. package/.claude/commands/ant/swarm.md +11 -23
  234. package/.claude/commands/ant/tunnels.md +1 -0
  235. package/.claude/commands/ant/update.md +58 -135
  236. package/.claude/commands/ant/verify-castes.md +90 -42
  237. package/.claude/commands/ant/watch.md +1 -0
  238. package/.opencode/agents/aether-ambassador.md +1 -1
  239. package/.opencode/agents/aether-architect.md +133 -0
  240. package/.opencode/agents/aether-builder.md +3 -3
  241. package/.opencode/agents/aether-oracle.md +137 -0
  242. package/.opencode/agents/aether-queen.md +1 -1
  243. package/.opencode/agents/aether-route-setter.md +1 -1
  244. package/.opencode/agents/aether-scout.md +1 -1
  245. package/.opencode/agents/aether-surveyor-disciplines.md +6 -1
  246. package/.opencode/agents/aether-surveyor-nest.md +6 -1
  247. package/.opencode/agents/aether-surveyor-pathogens.md +6 -1
  248. package/.opencode/agents/aether-surveyor-provisions.md +6 -1
  249. package/.opencode/agents/aether-tracker.md +1 -1
  250. package/.opencode/agents/aether-watcher.md +1 -1
  251. package/.opencode/agents/aether-weaver.md +1 -1
  252. package/.opencode/commands/ant/archaeology.md +7 -14
  253. package/.opencode/commands/ant/build.md +54 -88
  254. package/.opencode/commands/ant/chaos.md +7 -24
  255. package/.opencode/commands/ant/colonize.md +10 -17
  256. package/.opencode/commands/ant/continue.md +595 -66
  257. package/.opencode/commands/ant/council.md +150 -18
  258. package/.opencode/commands/ant/data-clean.md +77 -0
  259. package/.opencode/commands/ant/dream.md +15 -17
  260. package/.opencode/commands/ant/entomb.md +28 -18
  261. package/.opencode/commands/ant/export-signals.md +54 -0
  262. package/.opencode/commands/ant/feedback.md +24 -5
  263. package/.opencode/commands/ant/flag.md +16 -4
  264. package/.opencode/commands/ant/flags.md +24 -10
  265. package/.opencode/commands/ant/focus.md +22 -5
  266. package/.opencode/commands/ant/help.md +41 -8
  267. package/.opencode/commands/ant/history.md +9 -0
  268. package/.opencode/commands/ant/import-signals.md +68 -0
  269. package/.opencode/commands/ant/init.md +396 -154
  270. package/.opencode/commands/ant/insert-phase.md +111 -0
  271. package/.opencode/commands/ant/interpret.md +16 -0
  272. package/.opencode/commands/ant/lay-eggs.md +184 -112
  273. package/.opencode/commands/ant/maturity.md +18 -2
  274. package/.opencode/commands/ant/memory-details.md +83 -0
  275. package/.opencode/commands/ant/migrate-state.md +12 -0
  276. package/.opencode/commands/ant/oracle.md +322 -67
  277. package/.opencode/commands/ant/organize.md +14 -12
  278. package/.opencode/commands/ant/patrol.md +626 -0
  279. package/.opencode/commands/ant/pause-colony.md +12 -29
  280. package/.opencode/commands/ant/phase.md +30 -40
  281. package/.opencode/commands/ant/pheromones.md +162 -0
  282. package/.opencode/commands/ant/plan.md +210 -57
  283. package/.opencode/commands/ant/preferences.md +71 -0
  284. package/.opencode/commands/ant/quick.md +91 -0
  285. package/.opencode/commands/ant/redirect.md +22 -5
  286. package/.opencode/commands/ant/resume-colony.md +41 -29
  287. package/.opencode/commands/ant/resume.md +80 -20
  288. package/.opencode/commands/ant/run.md +237 -0
  289. package/.opencode/commands/ant/seal.md +230 -25
  290. package/.opencode/commands/ant/skill-create.md +63 -0
  291. package/.opencode/commands/ant/status.md +125 -30
  292. package/.opencode/commands/ant/swarm.md +3 -345
  293. package/.opencode/commands/ant/tunnels.md +3 -9
  294. package/.opencode/commands/ant/update.md +63 -127
  295. package/.opencode/commands/ant/verify-castes.md +96 -42
  296. package/.opencode/commands/ant/watch.md +7 -0
  297. package/CHANGELOG.md +368 -1
  298. package/README.md +195 -324
  299. package/bin/cli.js +236 -429
  300. package/bin/generate-commands.js +186 -0
  301. package/bin/generate-commands.sh +128 -89
  302. package/bin/lib/spawn-logger.js +0 -15
  303. package/bin/lib/update-transaction.js +285 -35
  304. package/bin/npx-install.js +178 -0
  305. package/bin/validate-package.sh +85 -3
  306. package/package.json +16 -4
  307. package/.aether/CONTEXT.md +0 -160
  308. package/.aether/docs/QUEEN.md +0 -84
  309. package/.aether/exchange/colony-registry.xml +0 -11
  310. package/.aether/exchange/pheromones.xml +0 -87
  311. package/.aether/exchange/queen-wisdom.xml +0 -14
  312. package/.aether/model-profiles.yaml +0 -100
  313. package/.aether/utils/spawn-with-model.sh +0 -56
  314. package/bin/lib/model-profiles.js +0 -445
  315. package/bin/lib/model-verify.js +0 -288
  316. package/bin/lib/proxy-health.js +0 -253
  317. package/bin/lib/telemetry.js +0 -441
@@ -0,0 +1,1214 @@
1
+ name: "ant:seal"
2
+ description: "🏺🐜🏺 Seal the colony with Crowned Anthill milestone"
3
+ body_claude: |
4
+ You are the **Queen**. Seal the colony with a ceremony — no archiving.
5
+
6
+ ## Instructions
7
+
8
+ Parse `$ARGUMENTS`:
9
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
10
+ - Otherwise: set `visual_mode = true`
11
+
12
+ <failure_modes>
13
+ ### Crowned Anthill Write Failure
14
+ If writing the Crowned Anthill milestone document fails:
15
+ - Do not mark the colony as sealed in state
16
+ - Report the error -- sealing is incomplete
17
+ - Recovery: user can re-run /ant:seal after fixing the issue
18
+
19
+ ### State Update Failure After Seal
20
+ If COLONY_STATE.json update fails after seal document is written:
21
+ - The seal document exists but state doesn't reflect it
22
+ - Report the inconsistency
23
+ - Options: (1) Retry state update only, (2) Manual state fix, (3) Re-run /ant:seal
24
+ </failure_modes>
25
+
26
+ <success_criteria>
27
+ Command is complete when:
28
+ - Crowned Anthill milestone document is written
29
+ - COLONY_STATE.json reflects sealed status
30
+ - All phase evidence is summarized in the seal document
31
+ - User sees confirmation of successful seal
32
+ </success_criteria>
33
+
34
+ <read_only>
35
+ Do not touch during seal:
36
+ - .aether/dreams/ (user notes)
37
+ - .aether/chambers/ (archived colonies -- seal does NOT archive)
38
+ - Source code files
39
+ - .env* files
40
+ - .claude/settings.json
41
+ </read_only>
42
+
43
+ ### Step 0: Initialize Visual Mode (if enabled)
44
+
45
+ If `visual_mode` is true:
46
+ ### Step 1: Read State
47
+
48
+ Read `.aether/data/COLONY_STATE.json`.
49
+
50
+ If file missing or `goal: null`:
51
+ ```
52
+ No colony initialized. Run /ant:init first.
53
+ ```
54
+ Stop here.
55
+
56
+ Extract: `goal`, `state`, `current_phase`, `plan.phases`, `milestone`, `version`, `initialized_at`.
57
+
58
+ ### Step 2: Maturity Gate
59
+
60
+ Run `bash .aether/aether-utils.sh milestone-detect` to get `milestone`, `phases_completed`, `total_phases`.
61
+
62
+ **If milestone is already "Crowned Anthill":**
63
+ ```
64
+ Colony already sealed at Crowned Anthill.
65
+ Run /ant:entomb to archive this colony to chambers.
66
+ ```
67
+ Stop here.
68
+
69
+ **If state is "EXECUTING":**
70
+ ```
71
+ Colony is still executing. Run /ant:continue first.
72
+ ```
73
+ Stop here.
74
+
75
+ **If all phases complete** (phases_completed == total_phases, or milestone is "Sealed Chambers"):
76
+ - Set `incomplete_warning = ""` (no warning needed)
77
+ - Proceed to Step 3.
78
+
79
+ **If phases are incomplete** (any other milestone — First Mound, Open Chambers, Brood Stable, Ventilated Nest, etc.):
80
+ - Set `incomplete_warning = "WARNING: {phases_completed} of {total_phases} phases complete. Sealing now will mark incomplete work as the final state."`
81
+ - Proceed to Step 3 (warn but DO NOT block).
82
+
83
+ ### Step 3: Confirmation
84
+
85
+ Display what will be sealed:
86
+ ```
87
+ SEAL COLONY
88
+
89
+ Goal: {goal}
90
+ Phases: {phases_completed} of {total_phases} completed
91
+ Current Milestone: {milestone}
92
+
93
+ {If incomplete_warning is not empty, display it here}
94
+
95
+ This will:
96
+ - Award the Crowned Anthill milestone
97
+ - Write CROWNED-ANTHILL.md ceremony record
98
+ - Promote colony wisdom to QUEEN.md
99
+
100
+ Seal this colony? (yes/no)
101
+ ```
102
+
103
+ Use `AskUserQuestion with yes/no options`.
104
+
105
+ If not "yes":
106
+ ```
107
+ Sealing cancelled. Colony remains active.
108
+ ```
109
+ Stop here.
110
+
111
+ ### Step 3.5: Analytics Review
112
+
113
+ Before wisdom approval, spawn Sage to analyze colony trends and provide data-driven insights.
114
+
115
+ **Check phase threshold and spawn Sage:**
116
+ ```bash
117
+ # Check if colony has enough history for meaningful analytics
118
+ phases_completed=$(jq '[.plan.phases[] | select(.status == "completed")] | length' .aether/data/COLONY_STATE.json 2>/dev/null || echo "0")
119
+
120
+ if [[ "$phases_completed" -ge 3 ]]; then
121
+ # Generate Sage name and dispatch
122
+ sage_name=$(bash .aether/aether-utils.sh generate-ant-name "sage")
123
+ bash .aether/aether-utils.sh spawn-log "Queen" "sage" "$sage_name" "Colony analytics review"
124
+
125
+ # Display spawn notification
126
+ echo ""
127
+ echo "━━━ 📜🐜 S A G E ━━━"
128
+ echo "──── 📜🐜 Spawning $sage_name — Colony analytics review ────"
129
+ fi
130
+ ```
131
+
132
+ **Spawn Sage using Task tool when threshold is met:**
133
+ If phases_completed >= 3, spawn the Sage agent using Task tool with `subagent_type="aether-sage"`:
134
+
135
+ ```xml
136
+ <task>
137
+ <description>📜 Sage {sage_name}: Colony analytics review</description>
138
+ <prompt>
139
+ You are {sage_name}, a 📜 Sage Ant.
140
+
141
+ Mission: Analyze colony history and provide data-driven insights for wisdom promotion
142
+
143
+ Data Sources:
144
+ - COLONY_STATE.json: Colony configuration, phases, learnings, instincts
145
+ - activity.log: Activity history with timestamps
146
+ - midden.json: Failure patterns and flagged issues
147
+
148
+ Analysis Areas:
149
+ 1. Velocity Trends: Phase completion rate over time
150
+ 2. Bug Density: Error frequency and patterns from midden
151
+ 3. Review Turnaround: Time from build to continue
152
+
153
+ Work:
154
+ 1. Read COLONY_STATE.json for phase history and learnings
155
+ 2. Read activity.log for velocity patterns
156
+ 3. Read midden.json for bug density analysis
157
+ 4. Calculate metrics and identify trends
158
+ 5. Provide recommendations for wisdom promotion
159
+
160
+ **IMPORTANT:** You are strictly read-only. Do not modify any files.
161
+
162
+ Log activity: bash .aether/aether-utils.sh activity-log "ANALYZING" "{sage_name}" "description"
163
+
164
+ Return ONLY this JSON (no other text):
165
+ {{
166
+ "ant_name": "{sage_name}",
167
+ "caste": "sage",
168
+ "status": "completed" | "failed" | "blocked",
169
+ "summary": "What you analyzed and found",
170
+ "key_findings": [],
171
+ "trends": {{
172
+ "velocity": "increasing|stable|decreasing",
173
+ "bug_density": "high|medium|low",
174
+ "review_turnaround": "fast|moderate|slow"
175
+ }},
176
+ "metrics_analyzed": [],
177
+ "predictions": [],
178
+ "recommendations": [
179
+ {{"priority": 1, "action": "", "expected_impact": ""}}
180
+ ],
181
+ "next_steps": [],
182
+ "blockers": []
183
+ }}
184
+ </prompt>
185
+ </task>
186
+ ```
187
+
188
+ **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."
189
+
190
+ **Parse Sage JSON output:**
191
+ After spawn, extract from response: `key_findings`, `trends`, `recommendations`
192
+
193
+ Log completion and update swarm display:
194
+ ```bash
195
+ bash .aether/aether-utils.sh spawn-complete "$sage_name" "completed" "Analytics review complete"
196
+ ```
197
+
198
+ **Display Sage completion line:**
199
+ ```
200
+ 📜 {sage_name}: Colony analytics review complete ✓
201
+ Velocity: {trend} | Bug density: {level} | Review turnaround: {speed}
202
+ ```
203
+
204
+ **Log high-priority recommendations to midden (non-blocking):**
205
+ For each recommendation with priority <= 2:
206
+ ```bash
207
+ bash .aether/aether-utils.sh midden-write "analytics" "Sage recommendation (P{priority}): {action}" "sage"
208
+ ```
209
+
210
+ **Display insights summary:**
211
+ ```
212
+ 📜 Sage Insights:
213
+ Key Findings: {count}
214
+ Top Recommendation: {first recommendation action}
215
+ ```
216
+
217
+ **Continue to Step 3.6 (non-blocking):**
218
+ Proceed to Step 3.6 regardless of Sage findings — Sage is strictly non-blocking.
219
+
220
+ **If phases_completed < 3:**
221
+ Skip silently (no output) — proceed directly to Step 3.6.
222
+
223
+ ### Step 3.6: Wisdom Approval
224
+
225
+ Before sealing, review wisdom proposals accumulated during this colony's lifecycle.
226
+
227
+ ```bash
228
+ # --- Batch auto-promotion for auto-threshold observations (QUEEN-02) ---
229
+ # Auto-promote observations meeting higher recurrence thresholds
230
+ # before presenting the interactive review for lower-threshold proposals.
231
+
232
+ obs_file=".aether/data/learning-observations.json"
233
+ auto_promoted_count=0
234
+
235
+ if [[ -f "$obs_file" ]]; then
236
+ for encoded in $(jq -r '.observations[] | @base64' "$obs_file" 2>/dev/null); do
237
+ content=$(echo "$encoded" | base64 -d | jq -r '.content // empty')
238
+ wisdom_type=$(echo "$encoded" | base64 -d | jq -r '.wisdom_type // "pattern"')
239
+ colony=$(echo "$encoded" | base64 -d | jq -r '.colonies[0] // "unknown"')
240
+ [[ -z "$content" ]] && continue
241
+
242
+ result=$(bash .aether/aether-utils.sh learning-promote-auto "$wisdom_type" "$content" "$colony" "learning" 2>/dev/null || echo '{}')
243
+ was_promoted=$(echo "$result" | jq -r '.result.promoted // false' 2>/dev/null || echo "false")
244
+ if [[ "$was_promoted" == "true" ]]; then
245
+ auto_promoted_count=$((auto_promoted_count + 1))
246
+ fi
247
+ done
248
+ fi
249
+
250
+ if [[ "$auto_promoted_count" -gt 0 ]]; then
251
+ echo "Auto-promoted $auto_promoted_count observation(s) to QUEEN.md (met recurrence thresholds)"
252
+ echo ""
253
+ fi
254
+ # --- END Batch auto-promotion ---
255
+
256
+ # Check for pending proposals
257
+ proposals=$(bash .aether/aether-utils.sh learning-check-promotion 2>/dev/null || echo '{"proposals":[]}')
258
+ proposal_count=$(echo "$proposals" | jq '.proposals | length')
259
+
260
+ if [[ "$proposal_count" -gt 0 ]]; then
261
+ echo ""
262
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
263
+ echo " 🧠 WISDOM REVIEW"
264
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
265
+ echo ""
266
+ echo "Review wisdom proposals before sealing this colony."
267
+ echo "Approved proposals will be promoted to QUEEN.md."
268
+ echo ""
269
+
270
+ # Run approval workflow (blocking)
271
+ bash .aether/aether-utils.sh learning-approve-proposals
272
+
273
+ echo ""
274
+ echo "Wisdom review complete. Proceeding with sealing ceremony..."
275
+ echo ""
276
+ else
277
+ echo "No wisdom proposals to review."
278
+ fi
279
+ ```
280
+
281
+ ### Step 3.7: Hive Promotion (NON-BLOCKING)
282
+
283
+ After QUEEN.md promotion, promote abstracted instincts to the cross-colony hive.
284
+
285
+ **Extract high-confidence instincts for hive promotion:**
286
+ ```bash
287
+ # Get instincts with confidence >= 0.8
288
+ high_conf_instincts=$(jq -r '.memory.instincts[] | select(.confidence >= 0.8) | @base64' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
289
+
290
+ # Derive source repo name from current directory
291
+ source_repo="$(pwd)"
292
+
293
+ # Read domain tags from registry (NOT from instinct.domain which is a category, not a repo domain)
294
+ repo_domain_tags=$(jq -r --arg repo "$(pwd)" \
295
+ '[.repos[] | select(.path == $repo) | .domain_tags // []] | .[0] // [] | join(",")' \
296
+ "$HOME/.aether/registry.json" 2>/dev/null || echo "")
297
+
298
+ hive_promoted_count=0
299
+ hive_errors=0
300
+ for encoded in $high_conf_instincts; do
301
+ [[ -z "$encoded" ]] && continue
302
+
303
+ # Extract trigger and action fields from the instinct object
304
+ trigger=$(echo "$encoded" | base64 -d | jq -r '.trigger // empty')
305
+ action=$(echo "$encoded" | base64 -d | jq -r '.action // empty')
306
+ confidence=$(echo "$encoded" | base64 -d | jq -r '.confidence // 0.7')
307
+
308
+ [[ -z "$trigger" || -z "$action" ]] && continue
309
+
310
+ # Strip leading "When " or "when " from trigger to avoid "When When..." stutter
311
+ trigger_clean=$(echo "$trigger" | sed 's/^[Ww]hen //')
312
+
313
+ # Build the promotion text in "When {trigger}: {action}" format
314
+ promote_text="When ${trigger_clean}: ${action}"
315
+
316
+ # Build hive-promote args with --text and --source-repo (required)
317
+ promote_args=(hive-promote --text "$promote_text" --source-repo "$source_repo" --confidence "$confidence")
318
+ [[ -n "$repo_domain_tags" ]] && promote_args+=(--domain "$repo_domain_tags")
319
+
320
+ # Call hive-promote which orchestrates abstract + store
321
+ result=$(bash .aether/aether-utils.sh "${promote_args[@]}" 2>/dev/null || echo '{}')
322
+ was_promoted=$(echo "$result" | jq -r '.result.action // "skipped"' 2>/dev/null || echo "skipped")
323
+
324
+ if [[ "$was_promoted" == "promoted" || "$was_promoted" == "merged" ]]; then
325
+ hive_promoted_count=$((hive_promoted_count + 1))
326
+ fi
327
+ done
328
+
329
+ if [[ "$hive_promoted_count" -gt 0 ]]; then
330
+ echo "Hive promotion: $hive_promoted_count instinct(s) promoted to cross-colony hive"
331
+ fi
332
+ ```
333
+
334
+ **Continue to Step 4 (non-blocking):**
335
+ Proceed to Step 4 regardless of hive promotion results — hive promotion is strictly non-blocking.
336
+
337
+ ### Step 4: Log Seal Activity
338
+
339
+ Log the seal ceremony to activity log:
340
+ ```bash
341
+ bash .aether/aether-utils.sh activity-log "MODIFIED" "Queen" "Colony sealed - wisdom review completed"
342
+ ```
343
+
344
+ ### Step 4.4: Checkpoint State
345
+
346
+ Before modifying colony state, create a rolling backup:
347
+
348
+ Run using the Bash tool with description "Checkpointing colony state before seal...":
349
+ ```bash
350
+ bash .aether/aether-utils.sh state-checkpoint "pre-seal" 2>/dev/null || echo "Warning: State checkpoint failed -- continuing without backup" >&2
351
+ ```
352
+
353
+ ### Step 4.5: Increment Colony Version
354
+
355
+ Before writing the Crowned Anthill milestone, increment `colony_version` in COLONY_STATE.json.
356
+
357
+ ```bash
358
+ # Read current colony_version (default to 0 for backward compat with older colonies)
359
+ current_colony_version=$(jq -r '.colony_version // 0' .aether/data/COLONY_STATE.json 2>/dev/null || echo 0)
360
+ # Guard against non-integer values (floats, strings)
361
+ [[ "$current_colony_version" =~ ^[0-9]+$ ]] || current_colony_version=0
362
+ new_colony_version=$(( current_colony_version + 1 ))
363
+
364
+ # Write incremented value back — guard against empty output destroying the file
365
+ updated=$(jq --argjson v "$new_colony_version" '.colony_version = $v' .aether/data/COLONY_STATE.json 2>/dev/null)
366
+ if [[ -n "$updated" && ${#updated} -gt 10 ]]; then
367
+ echo "$updated" > .aether/data/COLONY_STATE.json
368
+ else
369
+ echo "Warning: jq update failed — colony_version defaults to 1, state file unchanged"
370
+ new_colony_version=1
371
+ fi
372
+ ```
373
+
374
+ Use `new_colony_version` as `{colony_version}` throughout the rest of the seal ceremony (e.g., display as "Crowned Anthill v{colony_version}").
375
+
376
+ **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.
377
+
378
+ ### Step 5: Update Milestone to Crowned Anthill
379
+
380
+ Update COLONY_STATE.json:
381
+ 1. Set `milestone` to `"Crowned Anthill"`
382
+ 2. Set `milestone_updated_at` to current ISO-8601 timestamp
383
+ 3. Append event: `"<timestamp>|milestone_reached|seal|Achieved Crowned Anthill milestone"`
384
+
385
+ Run `bash .aether/aether-utils.sh validate-state colony` after write.
386
+
387
+ ### Step 5.1: Update Changelog
388
+
389
+ **MANDATORY: Record the seal in the project changelog. This step is never skipped.**
390
+
391
+ If no `CHANGELOG.md` exists, `changelog-append` creates one automatically.
392
+
393
+ Build a summary of what the colony accomplished across all phases:
394
+ - Collect completed phase names from COLONY_STATE.json
395
+ - Summarize the goal and key outcomes in one line
396
+
397
+ ```bash
398
+ bash .aether/aether-utils.sh changelog-append \
399
+ "$(date +%Y-%m-%d)" \
400
+ "seal-crowned-anthill" \
401
+ "00" \
402
+ "{key_files_csv}" \
403
+ "Colony sealed at Crowned Anthill;{goal}" \
404
+ "{phases_completed} phases completed;Colony wisdom promoted to QUEEN.md" \
405
+ ""
406
+ ```
407
+
408
+ - `{key_files_csv}` — list the most significant files created or modified across the colony's lifetime (derive from phase plans or git log)
409
+ - `{goal}` — the colony goal from COLONY_STATE.json
410
+
411
+ **Error handling:** If `changelog-append` fails, log to midden and continue — changelog failure never blocks sealing.
412
+
413
+ ### Step 5.2: Update Registry (Silent)
414
+
415
+ Mark the colony as inactive in the global registry. This is silent on failure — registry is not required for the colony to work.
416
+
417
+ Run using the Bash tool (ignore errors):
418
+ ```bash
419
+ 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
420
+ ```
421
+
422
+ If the command fails, proceed silently. This is optional bookkeeping.
423
+
424
+ ### Step 5.5: Documentation Coverage Audit
425
+
426
+ Before writing the seal document, spawn a Chronicler to survey documentation coverage.
427
+
428
+ **Generate Chronicler name and dispatch:**
429
+ ```bash
430
+ # Generate unique chronicler name
431
+ chronicler_name=$(bash .aether/aether-utils.sh generate-ant-name "chronicler")
432
+
433
+ # Log spawn and update swarm display
434
+ bash .aether/aether-utils.sh spawn-log "Queen" "chronicler" "$chronicler_name" "Documentation coverage audit"
435
+ ```
436
+
437
+ **Display:**
438
+ ```
439
+ ━━━ 📝🐜 C H R O N I C L E R ━━━
440
+ ──── 📝🐜 Spawning {chronicler_name} — documentation coverage audit ────
441
+ ```
442
+
443
+ **Spawn Chronicler using Task tool:**
444
+ Spawn the Chronicler using Task tool with `subagent_type="aether-chronicler"`:
445
+
446
+ ```xml
447
+ <task>
448
+ <description>📝 Chronicler {chronicler_name}: Documentation coverage audit</description>
449
+ <prompt>
450
+ You are {chronicler_name}, a 📝 Chronicler Ant.
451
+
452
+ Mission: Documentation coverage audit before seal ceremony
453
+
454
+ Survey the following documentation types:
455
+ - README.md (project overview, quick start)
456
+ - API documentation (endpoints, parameters, responses)
457
+ - Guides (tutorials, how-tos, best practices)
458
+ - Changelogs (version history, release notes)
459
+ - Code comments (JSDoc, TSDoc inline documentation)
460
+ - Architecture docs (system design, decisions)
461
+
462
+ Work:
463
+ 1. Check if README.md exists and covers: installation, usage, examples
464
+ 2. Look for docs/ directory and survey guide coverage
465
+ 3. Check for API documentation (OpenAPI, README sections, etc.)
466
+ 4. Verify CHANGELOG.md exists and has recent entries
467
+ 5. Sample source files for inline documentation coverage
468
+ 6. Identify documentation gaps (missing, outdated, incomplete)
469
+
470
+ **IMPORTANT:** You are strictly read-only. Do not modify any files.
471
+
472
+ Log activity: bash .aether/aether-utils.sh activity-log "SURVEYING" "{chronicler_name}" "description"
473
+
474
+ Return ONLY this JSON (no other text):
475
+ {
476
+ "ant_name": "{chronicler_name}",
477
+ "caste": "chronicler",
478
+ "status": "completed" | "failed" | "blocked",
479
+ "summary": "What you surveyed and found",
480
+ "documentation_created": [],
481
+ "documentation_updated": [],
482
+ "pages_documented": 0,
483
+ "code_examples_verified": [],
484
+ "coverage_percent": 0,
485
+ "gaps_identified": [
486
+ {"type": "README|API|Guide|Changelog|Comments|Architecture", "severity": "high|medium|low", "description": "...", "location": "..."}
487
+ ],
488
+ "blockers": []
489
+ }
490
+ </prompt>
491
+ </task>
492
+ ```
493
+
494
+ **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."
495
+
496
+ **Parse Chronicler JSON output:**
497
+ Extract from response: `coverage_percent`, `gaps_identified`, `pages_documented`
498
+
499
+ Log completion and update swarm display:
500
+ ```bash
501
+ bash .aether/aether-utils.sh spawn-complete "$chronicler_name" "completed" "Documentation audit complete"
502
+ ```
503
+
504
+ **Display Chronicler completion line:**
505
+ ```
506
+ 📝 {chronicler_name}: Documentation coverage audit ({pages_documented} pages, {coverage_percent}% coverage) ✓
507
+ ```
508
+
509
+ **Log gaps to midden (non-blocking):**
510
+ For each gap in `gaps_identified` with severity "high" or "medium":
511
+ ```bash
512
+ bash .aether/aether-utils.sh midden-write "documentation" "Gap ({severity}): {description} at {location}" "chronicler"
513
+ ```
514
+
515
+ **Display summary:**
516
+ ```
517
+ 📝 Chronicler complete — {coverage_percent}% coverage, {gap_count} gaps logged to midden
518
+ ```
519
+
520
+ **Continue to Step 6 (non-blocking):**
521
+ Proceed to Step 6 regardless of Chronicler findings — Chronicler is strictly non-blocking.
522
+
523
+ ### Step 6: Write CROWNED-ANTHILL.md
524
+
525
+ Calculate colony age:
526
+ ```bash
527
+ initialized_at=$(jq -r '.initialized_at // empty' .aether/data/COLONY_STATE.json)
528
+ if [[ -n "$initialized_at" ]]; then
529
+ init_epoch=$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$initialized_at" +%s 2>/dev/null || echo 0)
530
+ now_epoch=$(date +%s)
531
+ if [[ "$init_epoch" -gt 0 ]]; then
532
+ colony_age_days=$(( (now_epoch - init_epoch) / 86400 ))
533
+ else
534
+ colony_age_days=0
535
+ fi
536
+ else
537
+ colony_age_days=0
538
+ fi
539
+ ```
540
+
541
+ Extract phase recap:
542
+ ```bash
543
+ phase_recap=""
544
+ while IFS= read -r phase_line; do
545
+ phase_name=$(echo "$phase_line" | jq -r '.name')
546
+ phase_status=$(echo "$phase_line" | jq -r '.status')
547
+ phase_recap="${phase_recap} - ${phase_name}: ${phase_status}\n"
548
+ done < <(jq -c '.plan.phases[]' .aether/data/COLONY_STATE.json 2>/dev/null)
549
+ ```
550
+
551
+ Write the seal document:
552
+ ```bash
553
+ version=$(jq -r '.version // "3.0"' .aether/data/COLONY_STATE.json)
554
+ seal_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
555
+ ```
556
+
557
+ Resolve the crowned-anthill template path:
558
+ Check ~/.aether/system/templates/crowned-anthill.template.md first,
559
+ then .aether/templates/crowned-anthill.template.md.
560
+
561
+ If no template found: output "Template missing: crowned-anthill.template.md. Run aether update to fix." and stop.
562
+
563
+ Read the template file. Fill all {{PLACEHOLDER}} values:
564
+ - {{GOAL}} → goal (from colony state)
565
+ - {{SEAL_DATE}} → seal_date (ISO-8601 UTC timestamp)
566
+ - {{VERSION}} → version (from colony state)
567
+ - {{TOTAL_PHASES}} → total_phases
568
+ - {{PHASES_COMPLETED}} → phases_completed
569
+ - {{COLONY_AGE_DAYS}} → colony_age_days
570
+ - {{PROMOTIONS_MADE}} → promotions_made
571
+ - {{PHASE_RECAP}} → phase recap list (one entry per line, formatted from the bash loop above)
572
+
573
+ Remove the HTML comment lines at the top of the template (lines starting with <!--).
574
+ Write the result to .aether/CROWNED-ANTHILL.md using the Write tool.
575
+
576
+ ### Step 6.5: Export XML Archive (best-effort)
577
+
578
+ Export colony data as a combined XML archive and a standalone pheromones.xml. Both are best-effort — seal proceeds even if XML export fails.
579
+
580
+ ```bash
581
+ # Check if xmllint is available
582
+ if command -v xmllint >/dev/null 2>&1; then
583
+ xml_result=$(bash .aether/aether-utils.sh colony-archive-xml ".aether/exchange/colony-archive.xml" 2>&1)
584
+ xml_ok=$(echo "$xml_result" | jq -r '.ok // false' 2>/dev/null)
585
+ if [[ "$xml_ok" == "true" ]]; then
586
+ xml_pheromone_count=$(echo "$xml_result" | jq -r '.result.pheromone_count // 0' 2>/dev/null)
587
+ xml_export_line="XML Archive: colony-archive.xml (${xml_pheromone_count} active signals)"
588
+ else
589
+ xml_export_line="XML Archive: export failed (non-blocking)"
590
+ fi
591
+
592
+ # Also export standalone pheromones.xml for cross-colony sharing
593
+ pher_result=$(bash .aether/aether-utils.sh pheromone-export-xml ".aether/exchange/pheromones.xml" 2>&1)
594
+ pher_ok=$(echo "$pher_result" | jq -r '.ok // false' 2>/dev/null)
595
+ if [[ "$pher_ok" == "true" ]]; then
596
+ pher_signal_count=$(jq '[.signals[] | select(.active != false)] | length' .aether/data/pheromones.json 2>/dev/null || echo "0")
597
+ pher_export_line="Signal Export: pheromones.xml (${pher_signal_count} signals, importable by other colonies)"
598
+ else
599
+ pher_export_line="Signal Export: failed (non-blocking)"
600
+ fi
601
+
602
+ # Export standalone queen-wisdom.xml for cross-colony wisdom sharing
603
+ wisdom_result=$(bash .aether/aether-utils.sh wisdom-export-xml ".aether/exchange/queen-wisdom.xml" 2>&1)
604
+ wisdom_ok=$(echo "$wisdom_result" | jq -r '.ok // false' 2>/dev/null)
605
+ if [[ "$wisdom_ok" == "true" ]]; then
606
+ wisdom_count=$(echo "$wisdom_result" | jq -r '.result.entries // 0' 2>/dev/null)
607
+ wisdom_export_line="Wisdom Export: queen-wisdom.xml (${wisdom_count} entries)"
608
+ else
609
+ wisdom_export_line="Wisdom Export: failed (non-blocking)"
610
+ fi
611
+
612
+ # Export standalone colony-registry.xml for lineage tracking
613
+ registry_result=$(bash .aether/aether-utils.sh registry-export-xml ".aether/exchange/colony-registry.xml" 2>&1)
614
+ registry_ok=$(echo "$registry_result" | jq -r '.ok // false' 2>/dev/null)
615
+ if [[ "$registry_ok" == "true" ]]; then
616
+ registry_count=$(echo "$registry_result" | jq -r '.result.colonies // 0' 2>/dev/null)
617
+ registry_export_line="Registry Export: colony-registry.xml (${registry_count} colonies)"
618
+ else
619
+ registry_export_line="Registry Export: failed (non-blocking)"
620
+ fi
621
+ else
622
+ xml_export_line="XML Archive: skipped (xmllint not available)"
623
+ pher_export_line="Signal Export: skipped (xmllint not available)"
624
+ wisdom_export_line="Wisdom Export: skipped (xmllint not available)"
625
+ registry_export_line="Registry Export: skipped (xmllint not available)"
626
+ fi
627
+ ```
628
+
629
+ ### Step 7: Display Ceremony
630
+
631
+
632
+ Display the ASCII art ceremony:
633
+ ```
634
+ . .
635
+ /|\ /|\
636
+ / | \ / | \
637
+ / | X | \
638
+ / | / \ | \
639
+ / |/ \| \
640
+ / / \ \
641
+ /____ / ___ \ ____\
642
+ / / \ \
643
+ / / \ \
644
+ /_/ \_\
645
+ | CROWNED |
646
+ | ANTHILL |
647
+ |__________|
648
+ ```
649
+
650
+ Below the ASCII art, display:
651
+ ```
652
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
653
+ C R O W N E D A N T H I L L v{colony_version}
654
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
655
+
656
+ Goal: {goal}
657
+ Phases: {phases_completed} of {total_phases} completed
658
+ Milestone: Crowned Anthill v{colony_version}
659
+ {If incomplete_warning is not empty: display it}
660
+ Wisdom Promoted: {promotion_summary}
661
+
662
+ Seal Document: .aether/CROWNED-ANTHILL.md
663
+ {xml_export_line}
664
+ {pher_export_line}
665
+ {wisdom_export_line}
666
+ {registry_export_line}
667
+
668
+ The colony stands crowned and sealed.
669
+ Its wisdom lives on in QUEEN.md.
670
+ The anthill has reached its final form.
671
+
672
+ ──────────────────────────────────────────────────
673
+ 🐜 Next Up
674
+ ──────────────────────────────────────────────────
675
+ /ant:entomb 🏺 Archive colony to chambers
676
+ /ant:lay-eggs 🥚 Start a new colony
677
+ /ant:tunnels 🗄️ Browse archived chambers
678
+ ```
679
+
680
+ ### Step 7.5: Commit Suggestion (Non-blocking)
681
+
682
+ After the ceremony, offer to commit all colony work.
683
+
684
+ **Gate check — skip silently if any fail:**
685
+ 1. Not a git repo: `git rev-parse --git-dir 2>/dev/null` fails → skip
686
+ 2. Clean working tree: `git status --porcelain 2>/dev/null` is empty → skip to Step 7.6 (may still want to push)
687
+
688
+ **If uncommitted changes exist:**
689
+
690
+ Generate a seal commit message:
691
+ ```bash
692
+ seal_commit=$(bash .aether/aether-utils.sh generate-commit-message seal "$phases_completed" "$goal" "$colony_age_days" 2>/dev/null)
693
+ seal_message=$(echo "$seal_commit" | jq -r '.result.message // "aether-seal: colony sealed"')
694
+ seal_body=$(echo "$seal_commit" | jq -r '.result.body // ""')
695
+ ```
696
+
697
+ Display the suggestion:
698
+ ```
699
+ ──────────────────────────────────────────────────
700
+ Commit suggestion:
701
+
702
+ $seal_message
703
+
704
+ $seal_body
705
+ ──────────────────────────────────────────────────
706
+ ```
707
+
708
+ Prompt with AskUserQuestion (3 options):
709
+ 1. **Commit with this message** — Run `git add -A && git commit -m "$seal_message" -m "$seal_body"`
710
+ 2. **Edit message** — Ask user for their preferred message, then commit with that
711
+ 3. **Skip** — Do not commit
712
+
713
+ If the user chooses option 1 or 2 and the commit succeeds, set `seal_committed = true`.
714
+ If the commit fails or user skips, set `seal_committed = false`.
715
+
716
+ **Error handling:** If `generate-commit-message` fails, fall back to message `"aether-seal: colony sealed"`. Never let commit suggestion failures stop the seal flow.
717
+
718
+ ### Step 7.6: Push Suggestion (Non-blocking)
719
+
720
+ Only show if a commit was just made in Step 7.5 (`seal_committed == true`) OR if there are unpushed commits.
721
+
722
+ **Gate check — skip silently if any fail:**
723
+ 1. Not a git repo → skip
724
+ 2. No remote configured: `git remote -v 2>/dev/null` is empty → skip
725
+
726
+ **Check for unpushed commits:**
727
+ ```bash
728
+ unpushed=$(git log --oneline @{u}..HEAD 2>/dev/null | wc -l | tr -d ' ')
729
+ ```
730
+ If `unpushed == 0` and `seal_committed == false` → skip (nothing to push)
731
+
732
+ **If there are commits to push:**
733
+
734
+ Detect current branch and upstream status:
735
+ ```bash
736
+ current_branch=$(git branch --show-current)
737
+ has_upstream=$(git rev-parse --abbrev-ref @{u} 2>/dev/null && echo "yes" || echo "no")
738
+ ```
739
+
740
+ Display:
741
+ ```
742
+ Push {unpushed} commit(s) to remote?
743
+ Branch: {current_branch}
744
+ ```
745
+
746
+ Prompt with AskUserQuestion (2 options):
747
+ 1. **Push now** — If upstream exists: `git push`. If no upstream: `git push -u origin $current_branch`
748
+ 2. **I'll push later** — Skip
749
+
750
+ Display result: `Pushed to origin/{current_branch}` on success, or `Push skipped` if declined.
751
+
752
+ **Error handling:** If push fails, display the error message but do not stop the seal flow. Suggest: "You can push manually with `git push`."
753
+
754
+ **Safety:** Never auto-push. Always require explicit user approval via AskUserQuestion.
755
+
756
+ ### Edge Cases
757
+
758
+ **Colony already at Crowned Anthill:**
759
+ - Display message and guide to /ant:entomb. Do NOT re-seal.
760
+
761
+ **Phases incomplete:**
762
+ - Warn but allow. The seal proceeds after confirmation.
763
+
764
+ **Missing QUEEN.md:**
765
+ - queen-init creates it. If that fails, skip promotion (non-fatal).
766
+
767
+ **Missing initialized_at:**
768
+ - Colony age defaults to 0 days.
769
+
770
+ **Empty phases array:**
771
+ - Can seal a colony with 0 phases (rare but valid). phases_completed = 0, total_phases = 0.
772
+
773
+ body_opencode: |
774
+ You are the **Queen**. Seal the colony when all work is complete.
775
+
776
+ ## Instructions
777
+
778
+ Parse `$normalized_args`:
779
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
780
+ - Otherwise: set `visual_mode = true`
781
+
782
+ ### Step 1: Read State
783
+
784
+ Read `.aether/data/COLONY_STATE.json`.
785
+
786
+ If file missing or `goal: null`:
787
+ ```
788
+ No colony initialized. Run /ant:init first.
789
+ ```
790
+ Stop here.
791
+
792
+ ### Step 2: Validate Colony Is Complete
793
+
794
+ Extract: `goal`, `current_phase`, `plan.phases`, `milestone`, `state`.
795
+
796
+ **Precondition 1: All phases must be completed**
797
+
798
+ Check if all phases in `plan.phases` have `status: "completed"`:
799
+ ```
800
+ all_completed = all(phase.status == "completed" for phase in plan.phases)
801
+ ```
802
+
803
+ If NOT all completed:
804
+ ```
805
+ Cannot archive colony with incomplete phases.
806
+
807
+ Completed phases: X of Y
808
+ Remaining: {list of incomplete phase names}
809
+
810
+ Run /ant:continue to complete remaining phases first.
811
+ ```
812
+ Stop here.
813
+
814
+ **Precondition 2: State must not be EXECUTING**
815
+
816
+ If `state == "EXECUTING"`:
817
+ ```
818
+ Colony is still executing. Run /ant:continue to reconcile first.
819
+ ```
820
+ Stop here.
821
+
822
+ ### Step 3: Check Milestone Eligibility
823
+
824
+ The full milestone progression is:
825
+ - **First Mound** — Phase 1 complete (first runnable)
826
+ - **Open Chambers** — Feature work underway (2+ phases complete)
827
+ - **Brood Stable** — Tests consistently green
828
+ - **Ventilated Nest** — Perf/latency acceptable (build + lint clean)
829
+ - **Sealed Chambers** — All phases complete (interfaces frozen)
830
+ - **Crowned Anthill** — Release-ready (user confirms via /ant:seal)
831
+
832
+ **If current milestone is "Crowned Anthill":**
833
+ ```
834
+ Colony is already at Crowned Anthill milestone.
835
+ No further archiving needed.
836
+
837
+ Use /ant:status to view colony state.
838
+ ```
839
+ Stop here.
840
+
841
+ **If current milestone is "Sealed Chambers":**
842
+ - Proceed to Step 4 (will upgrade to Crowned Anthill)
843
+
844
+ **If current milestone is "First Mound", "Open Chambers", "Brood Stable", "Ventilated Nest", or any intermediate milestone:**
845
+ - Since all phases are complete, the colony qualifies for both Sealed Chambers and Crowned Anthill
846
+ - The current logic allows proceeding to Step 4 (seal as Crowned Anthill)
847
+ - If user wants to explicitly achieve Sealed Chambers first, they can manually update milestone via COLONY_STATE.json
848
+
849
+ **If milestone is unrecognized (not in the 6 known stages):**
850
+ ```
851
+ Unknown milestone: {milestone}
852
+
853
+ The milestone "{milestone}" is not recognized.
854
+ Known milestones: First Mound, Open Chambers, Brood Stable, Ventilated Nest, Sealed Chambers, Crowned Anthill
855
+
856
+ Run /ant:status to check colony state.
857
+ ```
858
+ Stop here.
859
+
860
+ ### Step 4: Archive Colony State
861
+
862
+ Create archive directory:
863
+ ```
864
+ archive_dir=".aether/data/archive/session_$(date -u +%s)_archive"
865
+ mkdir -p "$archive_dir"
866
+ ```
867
+
868
+ Copy the following files to the archive directory:
869
+ 1. `.aether/data/COLONY_STATE.json` → `$archive_dir/COLONY_STATE.json`
870
+ 2. `.aether/data/activity.log` → `$archive_dir/activity.log`
871
+ 3. `.aether/data/spawn-tree.txt` → `$archive_dir/spawn-tree.txt`
872
+ 4. `.aether/data/flags.json` → `$archive_dir/flags.json` (if exists)
873
+ 5. `.aether/data/constraints.json` → `$archive_dir/constraints.json` (if exists)
874
+
875
+ Create archive manifest file `$archive_dir/manifest.json`:
876
+ ```json
877
+ {
878
+ "archived_at": "<ISO-8601 timestamp>",
879
+ "goal": "<colony goal>",
880
+ "total_phases": <number>,
881
+ "milestone": "Crowned Anthill",
882
+ "files": [
883
+ "COLONY_STATE.json",
884
+ "activity.log",
885
+ "spawn-tree.txt",
886
+ "flags.json",
887
+ "constraints.json"
888
+ ]
889
+ }
890
+ ```
891
+
892
+ ### Step 4.5: Increment Colony Version
893
+
894
+ Before writing the Crowned Anthill milestone, increment `colony_version` in COLONY_STATE.json.
895
+
896
+ ```bash
897
+ # Read current colony_version (default to 0 for backward compat with older colonies)
898
+ current_colony_version=$(jq -r '.colony_version // 0' .aether/data/COLONY_STATE.json 2>/dev/null || echo 0)
899
+ # Guard against non-integer values (floats, strings)
900
+ [[ "$current_colony_version" =~ ^[0-9]+$ ]] || current_colony_version=0
901
+ new_colony_version=$(( current_colony_version + 1 ))
902
+
903
+ # Write incremented value back — guard against empty output destroying the file
904
+ updated=$(jq --argjson v "$new_colony_version" '.colony_version = $v' .aether/data/COLONY_STATE.json 2>/dev/null)
905
+ if [[ -n "$updated" && ${#updated} -gt 10 ]]; then
906
+ echo "$updated" > .aether/data/COLONY_STATE.json
907
+ else
908
+ echo "Warning: jq update failed — colony_version defaults to 1, state file unchanged"
909
+ new_colony_version=1
910
+ fi
911
+ ```
912
+
913
+ Use `new_colony_version` as `{colony_version}` throughout the rest of the seal ceremony (e.g., display as "Crowned Anthill v{colony_version}").
914
+
915
+ **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.
916
+
917
+ ### Step 5: Update Milestone to Crowned Anthill
918
+
919
+ Update COLONY_STATE.json:
920
+ 1. Set `milestone` to `"Crowned Anthill"`
921
+ 2. Set `milestone_updated_at` to current ISO-8601 timestamp
922
+ 3. Append event: `"<timestamp>|milestone_reached|archive|Achieved Crowned Anthill milestone - colony archived"`
923
+
924
+ ### Step 5.1: Update Changelog
925
+
926
+ **MANDATORY: Record the seal in the project changelog. This step is never skipped.**
927
+
928
+ If no `CHANGELOG.md` exists, `changelog-append` creates one automatically.
929
+
930
+ Build a summary of what the colony accomplished across all phases:
931
+ - Collect completed phase names from COLONY_STATE.json
932
+ - Summarize the goal and key outcomes in one line
933
+
934
+ ```bash
935
+ bash .aether/aether-utils.sh changelog-append \
936
+ "$(date +%Y-%m-%d)" \
937
+ "seal-crowned-anthill" \
938
+ "00" \
939
+ "{key_files_csv}" \
940
+ "Colony sealed at Crowned Anthill;{goal}" \
941
+ "{phases_completed} phases completed;Colony wisdom promoted to QUEEN.md" \
942
+ ""
943
+ ```
944
+
945
+ - `{key_files_csv}` — list the most significant files created or modified across the colony's lifetime (derive from phase plans or git log)
946
+ - `{goal}` — the colony goal from COLONY_STATE.json
947
+
948
+ **Error handling:** If `changelog-append` fails, log to midden and continue — changelog failure never blocks sealing.
949
+
950
+ ### Step 5.2: Update Registry (Silent)
951
+
952
+ Mark the colony as inactive in the global registry. This is silent on failure — registry is not required for the colony to work.
953
+
954
+ Run using the Bash tool (ignore errors):
955
+ ```bash
956
+ 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
957
+ ```
958
+
959
+ If the command fails, proceed silently. This is optional bookkeeping.
960
+
961
+ ### Step 5.25: Hive Promotion (NON-BLOCKING)
962
+
963
+ After wisdom promotion, promote abstracted instincts to the cross-colony hive.
964
+
965
+ **Extract high-confidence instincts for hive promotion:**
966
+ ```bash
967
+ # Get instincts with confidence >= 0.8
968
+ high_conf_instincts=$(jq -r '.memory.instincts[] | select(.confidence >= 0.8) | @base64' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
969
+
970
+ # Derive source repo name from current directory
971
+ source_repo="$(pwd)"
972
+
973
+ # Read domain tags from registry (NOT from instinct.domain which is a category, not a repo domain)
974
+ repo_domain_tags=$(jq -r --arg repo "$(pwd)" \
975
+ '[.repos[] | select(.path == $repo) | .domain_tags // []] | .[0] // [] | join(",")' \
976
+ "$HOME/.aether/registry.json" 2>/dev/null || echo "")
977
+
978
+ hive_promoted_count=0
979
+ hive_errors=0
980
+ for encoded in $high_conf_instincts; do
981
+ [[ -z "$encoded" ]] && continue
982
+
983
+ # Extract trigger and action fields from the instinct object
984
+ trigger=$(echo "$encoded" | base64 -d | jq -r '.trigger // empty')
985
+ action=$(echo "$encoded" | base64 -d | jq -r '.action // empty')
986
+ confidence=$(echo "$encoded" | base64 -d | jq -r '.confidence // 0.7')
987
+
988
+ [[ -z "$trigger" || -z "$action" ]] && continue
989
+
990
+ # Strip leading "When " or "when " from trigger to avoid "When When..." stutter
991
+ trigger_clean=$(echo "$trigger" | sed 's/^[Ww]hen //')
992
+
993
+ # Build the promotion text in "When {trigger}: {action}" format
994
+ promote_text="When ${trigger_clean}: ${action}"
995
+
996
+ # Build hive-promote args with --text and --source-repo (required)
997
+ promote_args=(hive-promote --text "$promote_text" --source-repo "$source_repo" --confidence "$confidence")
998
+ [[ -n "$repo_domain_tags" ]] && promote_args+=(--domain "$repo_domain_tags")
999
+
1000
+ # Call hive-promote which orchestrates abstract + store
1001
+ result=$(bash .aether/aether-utils.sh "${promote_args[@]}" 2>/dev/null || echo '{}')
1002
+ was_promoted=$(echo "$result" | jq -r '.result.action // "skipped"' 2>/dev/null || echo "skipped")
1003
+
1004
+ if [[ "$was_promoted" == "promoted" || "$was_promoted" == "merged" ]]; then
1005
+ hive_promoted_count=$((hive_promoted_count + 1))
1006
+ fi
1007
+ done
1008
+
1009
+ if [[ "$hive_promoted_count" -gt 0 ]]; then
1010
+ echo "Hive promotion: $hive_promoted_count instinct(s) promoted to cross-colony hive"
1011
+ fi
1012
+ ```
1013
+
1014
+ **Continue to Step 5.5 (non-blocking):**
1015
+ Proceed to Step 5.5 regardless of hive promotion results — hive promotion is strictly non-blocking.
1016
+
1017
+ ### Step 5.5: Write Final Handoff
1018
+
1019
+ After archiving, write the final handoff documenting the completed colony:
1020
+
1021
+ Resolve the handoff template path:
1022
+ Check ~/.aether/system/templates/handoff.template.md first,
1023
+ then .aether/templates/handoff.template.md.
1024
+
1025
+ If no template found: output "Template missing: handoff.template.md. Run aether update to fix." and stop.
1026
+
1027
+ Read the template file. Fill all {{PLACEHOLDER}} values:
1028
+ - {{CHAMBER_NAME}} → archive directory name
1029
+ - {{GOAL}} → goal
1030
+ - {{PHASES_COMPLETED}} → total_phases (OpenCode seal archives completed colonies)
1031
+ - {{TOTAL_PHASES}} → total_phases
1032
+ - {{MILESTONE}} → "Crowned Anthill"
1033
+ - {{ENTOMB_TIMESTAMP}} → seal timestamp
1034
+
1035
+ Remove the HTML comment lines at the top of the template.
1036
+ Write the result to .aether/HANDOFF.md using the Write tool.
1037
+
1038
+ This handoff serves as the final record of the completed colony.
1039
+
1040
+ ### Step 5.75: Export XML Archive (best-effort)
1041
+
1042
+ Export colony data as a combined XML archive and a standalone pheromones.xml. Both are best-effort — seal proceeds even if XML export fails.
1043
+
1044
+ ```bash
1045
+ # Check if xmllint is available
1046
+ if command -v xmllint >/dev/null 2>&1; then
1047
+ xml_result=$(bash .aether/aether-utils.sh colony-archive-xml ".aether/exchange/colony-archive.xml" 2>&1)
1048
+ xml_ok=$(echo "$xml_result" | jq -r '.ok // false' 2>/dev/null)
1049
+ if [[ "$xml_ok" == "true" ]]; then
1050
+ xml_pheromone_count=$(echo "$xml_result" | jq -r '.result.pheromone_count // 0' 2>/dev/null)
1051
+ xml_export_line="XML Archive: colony-archive.xml (${xml_pheromone_count} active signals)"
1052
+ else
1053
+ xml_export_line="XML Archive: export failed (non-blocking)"
1054
+ fi
1055
+
1056
+ # Also export standalone pheromones.xml for cross-colony sharing
1057
+ pher_result=$(bash .aether/aether-utils.sh pheromone-export-xml ".aether/exchange/pheromones.xml" 2>&1)
1058
+ pher_ok=$(echo "$pher_result" | jq -r '.ok // false' 2>/dev/null)
1059
+ if [[ "$pher_ok" == "true" ]]; then
1060
+ pher_signal_count=$(jq '[.signals[] | select(.active != false)] | length' .aether/data/pheromones.json 2>/dev/null || echo "0")
1061
+ pher_export_line="Signal Export: pheromones.xml (${pher_signal_count} signals, importable by other colonies)"
1062
+ else
1063
+ pher_export_line="Signal Export: failed (non-blocking)"
1064
+ fi
1065
+
1066
+ # Export standalone queen-wisdom.xml for cross-colony wisdom sharing
1067
+ wisdom_result=$(bash .aether/aether-utils.sh wisdom-export-xml ".aether/exchange/queen-wisdom.xml" 2>&1)
1068
+ wisdom_ok=$(echo "$wisdom_result" | jq -r '.ok // false' 2>/dev/null)
1069
+ if [[ "$wisdom_ok" == "true" ]]; then
1070
+ wisdom_count=$(echo "$wisdom_result" | jq -r '.result.entries // 0' 2>/dev/null)
1071
+ wisdom_export_line="Wisdom Export: queen-wisdom.xml (${wisdom_count} entries)"
1072
+ else
1073
+ wisdom_export_line="Wisdom Export: failed (non-blocking)"
1074
+ fi
1075
+
1076
+ # Export standalone colony-registry.xml for lineage tracking
1077
+ registry_result=$(bash .aether/aether-utils.sh registry-export-xml ".aether/exchange/colony-registry.xml" 2>&1)
1078
+ registry_ok=$(echo "$registry_result" | jq -r '.ok // false' 2>/dev/null)
1079
+ if [[ "$registry_ok" == "true" ]]; then
1080
+ registry_count=$(echo "$registry_result" | jq -r '.result.colonies // 0' 2>/dev/null)
1081
+ registry_export_line="Registry Export: colony-registry.xml (${registry_count} colonies)"
1082
+ else
1083
+ registry_export_line="Registry Export: failed (non-blocking)"
1084
+ fi
1085
+ else
1086
+ xml_export_line="XML Archive: skipped (xmllint not available)"
1087
+ pher_export_line="Signal Export: skipped (xmllint not available)"
1088
+ wisdom_export_line="Wisdom Export: skipped (xmllint not available)"
1089
+ registry_export_line="Registry Export: skipped (xmllint not available)"
1090
+ fi
1091
+ ```
1092
+
1093
+ ### Step 6: Display Result
1094
+
1095
+ Output:
1096
+ ```
1097
+ 🏺 ════════════════════════════════════════════════════
1098
+ C R O W N E D A N T H I L L v{colony_version}
1099
+ ══════════════════════════════════════════════════ 🏺
1100
+
1101
+ ✅ Colony archived successfully!
1102
+
1103
+ 👑 Goal: {goal (truncated to 60 chars)}
1104
+ 📍 Phases: {total_phases} completed
1105
+ 🏆 Milestone: Crowned Anthill v{colony_version}
1106
+
1107
+ 📦 Archive Location: {archive_dir}
1108
+ - COLONY_STATE.json
1109
+ - activity.log
1110
+ - spawn-tree.txt
1111
+ - flags.json (if existed)
1112
+ - constraints.json (if existed)
1113
+ {xml_export_line}
1114
+ {pher_export_line}
1115
+ {wisdom_export_line}
1116
+ {registry_export_line}
1117
+
1118
+ 🐜 The colony has reached its final form.
1119
+ The anthill stands crowned and sealed.
1120
+ History is preserved. The colony rests.
1121
+
1122
+ 💾 State persisted — safe to /clear
1123
+
1124
+ 🐜 What would you like to do next?
1125
+ 1. /ant:lay-eggs "<new goal>" — Start a new colony
1126
+ 2. /ant:tunnels — Browse archived colonies
1127
+ 3. /clear — Clear context and continue
1128
+
1129
+ Use AskUserQuestion with these three options.
1130
+
1131
+ If option 1 selected: proceed to run /ant:lay-eggs flow
1132
+ If option 2 selected: run /ant:tunnels
1133
+ If option 3 selected: display "Run /ant:lay-eggs to begin anew after clearing"
1134
+ ```
1135
+
1136
+ ### Step 6.5: Commit Suggestion (Non-blocking)
1137
+
1138
+ After the ceremony, offer to commit all colony work.
1139
+
1140
+ **Gate check — skip silently if any fail:**
1141
+ 1. Not a git repo: `git rev-parse --git-dir 2>/dev/null` fails -> skip
1142
+ 2. Clean working tree: `git status --porcelain 2>/dev/null` is empty -> skip to Step 6.6
1143
+
1144
+ **If uncommitted changes exist:**
1145
+
1146
+ Generate a seal commit message:
1147
+ ```bash
1148
+ seal_commit=$(bash .aether/aether-utils.sh generate-commit-message seal "$phases_completed" "$goal" "$colony_age_days" 2>/dev/null)
1149
+ seal_message=$(echo "$seal_commit" | jq -r '.result.message // "aether-seal: colony sealed"')
1150
+ seal_body=$(echo "$seal_commit" | jq -r '.result.body // ""')
1151
+ ```
1152
+
1153
+ Display the suggestion:
1154
+ ```
1155
+ Commit suggestion:
1156
+ $seal_message
1157
+ $seal_body
1158
+ ```
1159
+
1160
+ Prompt with AskUserQuestion (3 options):
1161
+ 1. **Commit with this message** — Run `git add -A && git commit -m "$seal_message" -m "$seal_body"`
1162
+ 2. **Edit message** — Ask user for their preferred message, then commit with that
1163
+ 3. **Skip** — Do not commit
1164
+
1165
+ If the user chooses option 1 or 2 and the commit succeeds, set `seal_committed = true`.
1166
+ If the commit fails or user skips, set `seal_committed = false`.
1167
+
1168
+ **Error handling:** If `generate-commit-message` fails, fall back to message `"aether-seal: colony sealed"`. Never let commit suggestion failures stop the seal flow.
1169
+
1170
+ ### Step 6.6: Push Suggestion (Non-blocking)
1171
+
1172
+ Only show if a commit was just made in Step 6.5 (`seal_committed == true`) OR if there are unpushed commits.
1173
+
1174
+ **Gate check — skip silently if any fail:**
1175
+ 1. Not a git repo -> skip
1176
+ 2. No remote configured: `git remote -v 2>/dev/null` is empty -> skip
1177
+
1178
+ **Check for unpushed commits:**
1179
+ ```bash
1180
+ unpushed=$(git log --oneline @{u}..HEAD 2>/dev/null | wc -l | tr -d ' ')
1181
+ ```
1182
+ If `unpushed == 0` and `seal_committed == false` -> skip
1183
+
1184
+ **If there are commits to push:**
1185
+
1186
+ Detect current branch and upstream status:
1187
+ ```bash
1188
+ current_branch=$(git branch --show-current)
1189
+ has_upstream=$(git rev-parse --abbrev-ref @{u} 2>/dev/null && echo "yes" || echo "no")
1190
+ ```
1191
+
1192
+ Display: `Push {unpushed} commit(s) to remote? Branch: {current_branch}`
1193
+
1194
+ Prompt with AskUserQuestion (2 options):
1195
+ 1. **Push now** — If upstream exists: `git push`. If no upstream: `git push -u origin $current_branch`
1196
+ 2. **I'll push later** — Skip
1197
+
1198
+ Display result on success or skip.
1199
+
1200
+ **Error handling:** If push fails, display the error but do not stop the seal flow.
1201
+
1202
+ **Safety:** Never auto-push. Always require explicit user approval.
1203
+
1204
+ ### Edge Cases
1205
+
1206
+ **If milestone is already "Sealed Chambers" but phases are complete:**
1207
+ - Proceed with archiving and upgrade to Crowned Anthill
1208
+
1209
+ **If any archive files are missing:**
1210
+ - Archive what exists, note in manifest which files were missing
1211
+
1212
+ **If archive directory already exists:**
1213
+ - Append timestamp to make unique: `session_<ts>_archive_<random>`
1214
+