aether-colony 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/.aether/aether-utils.sh +3150 -3349
  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 +438 -0
  30. package/.aether/commands/continue.yaml +1484 -0
  31. package/.aether/commands/council.yaml +304 -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 +469 -0
  44. package/.aether/commands/insert-phase.yaml +98 -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 +1313 -0
  57. package/.aether/commands/preferences.yaml +63 -0
  58. package/.aether/commands/redirect.yaml +123 -0
  59. package/.aether/commands/resume-colony.yaml +373 -0
  60. package/.aether/commands/resume.yaml +398 -0
  61. package/.aether/commands/run.yaml +193 -0
  62. package/.aether/commands/seal.yaml +1205 -0
  63. package/.aether/commands/skill-create.yaml +337 -0
  64. package/.aether/commands/status.yaml +364 -0
  65. package/.aether/commands/swarm.yaml +352 -0
  66. package/.aether/commands/tunnels.yaml +814 -0
  67. package/.aether/commands/update.yaml +131 -0
  68. package/.aether/commands/verify-castes.yaml +159 -0
  69. package/.aether/commands/watch.yaml +454 -0
  70. package/.aether/docs/INCIDENT_TEMPLATE.md +32 -0
  71. package/.aether/docs/QUEEN-SYSTEM.md +11 -11
  72. package/.aether/docs/README.md +32 -2
  73. package/.aether/docs/command-playbooks/README.md +23 -0
  74. package/.aether/docs/command-playbooks/build-complete.md +349 -0
  75. package/.aether/docs/command-playbooks/build-context.md +282 -0
  76. package/.aether/docs/command-playbooks/build-full.md +1682 -0
  77. package/.aether/docs/command-playbooks/build-prep.md +283 -0
  78. package/.aether/docs/command-playbooks/build-verify.md +405 -0
  79. package/.aether/docs/command-playbooks/build-wave.md +749 -0
  80. package/.aether/docs/command-playbooks/continue-advance.md +524 -0
  81. package/.aether/docs/command-playbooks/continue-finalize.md +447 -0
  82. package/.aether/docs/command-playbooks/continue-full.md +1724 -0
  83. package/.aether/docs/command-playbooks/continue-gates.md +686 -0
  84. package/.aether/docs/command-playbooks/continue-verify.md +406 -0
  85. package/.aether/docs/context-continuity.md +84 -0
  86. package/.aether/docs/disciplines/DISCIPLINES.md +9 -7
  87. package/.aether/docs/error-codes.md +1 -1
  88. package/.aether/docs/known-issues.md +34 -173
  89. package/.aether/docs/pheromones.md +86 -6
  90. package/.aether/docs/plans/pheromone-display-plan.md +257 -0
  91. package/.aether/docs/queen-commands.md +10 -9
  92. package/.aether/docs/source-of-truth-map.md +132 -0
  93. package/.aether/docs/xml-utilities.md +47 -0
  94. package/.aether/rules/aether-colony.md +23 -13
  95. package/.aether/scripts/incident-test-add.sh +47 -0
  96. package/.aether/scripts/weekly-audit.sh +79 -0
  97. package/.aether/skills/.index.json +649 -0
  98. package/.aether/skills/colony/.manifest.json +16 -0
  99. package/.aether/skills/colony/build-discipline/SKILL.md +78 -0
  100. package/.aether/skills/colony/colony-interaction/SKILL.md +56 -0
  101. package/.aether/skills/colony/colony-lifecycle/SKILL.md +77 -0
  102. package/.aether/skills/colony/colony-visuals/SKILL.md +112 -0
  103. package/.aether/skills/colony/context-management/SKILL.md +80 -0
  104. package/.aether/skills/colony/error-presentation/SKILL.md +99 -0
  105. package/.aether/skills/colony/pheromone-protocol/SKILL.md +79 -0
  106. package/.aether/skills/colony/pheromone-visibility/SKILL.md +81 -0
  107. package/.aether/skills/colony/state-safety/SKILL.md +84 -0
  108. package/.aether/skills/colony/worker-priming/SKILL.md +82 -0
  109. package/.aether/skills/domain/.manifest.json +24 -0
  110. package/.aether/skills/domain/README.md +33 -0
  111. package/.aether/skills/domain/django/SKILL.md +49 -0
  112. package/.aether/skills/domain/docker/SKILL.md +52 -0
  113. package/.aether/skills/domain/golang/SKILL.md +52 -0
  114. package/.aether/skills/domain/graphql/SKILL.md +51 -0
  115. package/.aether/skills/domain/html-css/SKILL.md +48 -0
  116. package/.aether/skills/domain/nextjs/SKILL.md +45 -0
  117. package/.aether/skills/domain/nodejs/SKILL.md +53 -0
  118. package/.aether/skills/domain/postgresql/SKILL.md +53 -0
  119. package/.aether/skills/domain/prisma/SKILL.md +59 -0
  120. package/.aether/skills/domain/python/SKILL.md +50 -0
  121. package/.aether/skills/domain/rails/SKILL.md +52 -0
  122. package/.aether/skills/domain/react/SKILL.md +45 -0
  123. package/.aether/skills/domain/rest-api/SKILL.md +58 -0
  124. package/.aether/skills/domain/svelte/SKILL.md +47 -0
  125. package/.aether/skills/domain/tailwind/SKILL.md +45 -0
  126. package/.aether/skills/domain/testing/SKILL.md +53 -0
  127. package/.aether/skills/domain/typescript/SKILL.md +58 -0
  128. package/.aether/skills/domain/vue/SKILL.md +49 -0
  129. package/.aether/templates/QUEEN.md.template +23 -41
  130. package/.aether/templates/colony-state-reset.jq.template +1 -0
  131. package/.aether/templates/colony-state.template.json +4 -0
  132. package/.aether/templates/learning-observations.template.json +6 -0
  133. package/.aether/templates/midden.template.json +13 -0
  134. package/.aether/templates/pheromones.template.json +6 -0
  135. package/.aether/templates/session.template.json +9 -0
  136. package/.aether/utils/atomic-write.sh +63 -17
  137. package/.aether/utils/chamber-utils.sh +145 -2
  138. package/.aether/utils/emoji-audit.sh +166 -0
  139. package/.aether/utils/error-handler.sh +21 -7
  140. package/.aether/utils/file-lock.sh +182 -27
  141. package/.aether/utils/flag.sh +267 -0
  142. package/.aether/utils/hive.sh +572 -0
  143. package/.aether/utils/learning.sh +1928 -0
  144. package/.aether/utils/midden.sh +342 -0
  145. package/.aether/utils/oracle/oracle.md +168 -0
  146. package/.aether/utils/oracle/oracle.sh +1023 -0
  147. package/.aether/utils/pheromone.sh +2029 -0
  148. package/.aether/utils/queen.sh +1698 -0
  149. package/.aether/utils/scan.sh +860 -0
  150. package/.aether/utils/semantic-cli.sh +10 -8
  151. package/.aether/utils/session.sh +552 -0
  152. package/.aether/utils/skills.sh +509 -0
  153. package/.aether/utils/spawn-tree.sh +103 -271
  154. package/.aether/utils/spawn.sh +260 -0
  155. package/.aether/utils/state-api.sh +199 -0
  156. package/.aether/utils/state-loader.sh +8 -6
  157. package/.aether/utils/suggest.sh +611 -0
  158. package/.aether/utils/swarm-display.sh +10 -1
  159. package/.aether/utils/swarm.sh +1004 -0
  160. package/.aether/utils/watch-spawn-tree.sh +11 -2
  161. package/.aether/utils/xml-compose.sh +2 -2
  162. package/.aether/utils/xml-convert.sh +9 -5
  163. package/.aether/utils/xml-core.sh +5 -9
  164. package/.aether/utils/xml-query.sh +4 -4
  165. package/.aether/workers.md +86 -67
  166. package/.claude/agents/ant/aether-ambassador.md +2 -1
  167. package/.claude/agents/ant/aether-archaeologist.md +6 -1
  168. package/.claude/agents/ant/aether-architect.md +236 -0
  169. package/.claude/agents/ant/aether-auditor.md +6 -1
  170. package/.claude/agents/ant/aether-builder.md +38 -1
  171. package/.claude/agents/ant/aether-chaos.md +2 -1
  172. package/.claude/agents/ant/aether-chronicler.md +1 -0
  173. package/.claude/agents/ant/aether-gatekeeper.md +6 -1
  174. package/.claude/agents/ant/aether-includer.md +1 -0
  175. package/.claude/agents/ant/aether-keeper.md +1 -0
  176. package/.claude/agents/ant/aether-measurer.md +6 -1
  177. package/.claude/agents/ant/aether-oracle.md +237 -0
  178. package/.claude/agents/ant/aether-probe.md +2 -1
  179. package/.claude/agents/ant/aether-queen.md +6 -1
  180. package/.claude/agents/ant/aether-route-setter.md +6 -1
  181. package/.claude/agents/ant/aether-sage.md +68 -3
  182. package/.claude/agents/ant/aether-scout.md +38 -1
  183. package/.claude/agents/ant/aether-surveyor-disciplines.md +2 -1
  184. package/.claude/agents/ant/aether-surveyor-nest.md +2 -1
  185. package/.claude/agents/ant/aether-surveyor-pathogens.md +2 -1
  186. package/.claude/agents/ant/aether-surveyor-provisions.md +2 -1
  187. package/.claude/agents/ant/aether-tracker.md +6 -1
  188. package/.claude/agents/ant/aether-watcher.md +37 -1
  189. package/.claude/agents/ant/aether-weaver.md +2 -1
  190. package/.claude/commands/ant/archaeology.md +1 -8
  191. package/.claude/commands/ant/build.md +43 -1159
  192. package/.claude/commands/ant/chaos.md +1 -14
  193. package/.claude/commands/ant/colonize.md +1 -14
  194. package/.claude/commands/ant/continue.md +40 -1026
  195. package/.claude/commands/ant/council.md +9 -16
  196. package/.claude/commands/ant/data-clean.md +81 -0
  197. package/.claude/commands/ant/dream.md +12 -9
  198. package/.claude/commands/ant/entomb.md +62 -87
  199. package/.claude/commands/ant/export-signals.md +57 -0
  200. package/.claude/commands/ant/feedback.md +18 -0
  201. package/.claude/commands/ant/flag.md +12 -0
  202. package/.claude/commands/ant/flags.md +22 -8
  203. package/.claude/commands/ant/focus.md +18 -0
  204. package/.claude/commands/ant/help.md +40 -8
  205. package/.claude/commands/ant/history.md +3 -0
  206. package/.claude/commands/ant/import-signals.md +71 -0
  207. package/.claude/commands/ant/init.md +316 -191
  208. package/.claude/commands/ant/insert-phase.md +101 -0
  209. package/.claude/commands/ant/interpret.md +11 -0
  210. package/.claude/commands/ant/lay-eggs.md +167 -158
  211. package/.claude/commands/ant/maturity.md +22 -11
  212. package/.claude/commands/ant/memory-details.md +77 -0
  213. package/.claude/commands/ant/migrate-state.md +6 -0
  214. package/.claude/commands/ant/oracle.md +317 -62
  215. package/.claude/commands/ant/organize.md +10 -5
  216. package/.claude/commands/ant/patrol.md +620 -0
  217. package/.claude/commands/ant/pause-colony.md +8 -22
  218. package/.claude/commands/ant/phase.md +26 -37
  219. package/.claude/commands/ant/pheromones.md +156 -0
  220. package/.claude/commands/ant/plan.md +175 -52
  221. package/.claude/commands/ant/preferences.md +65 -0
  222. package/.claude/commands/ant/redirect.md +18 -0
  223. package/.claude/commands/ant/resume-colony.md +34 -20
  224. package/.claude/commands/ant/resume.md +51 -7
  225. package/.claude/commands/ant/run.md +195 -0
  226. package/.claude/commands/ant/seal.md +497 -78
  227. package/.claude/commands/ant/skill-create.md +286 -0
  228. package/.claude/commands/ant/status.md +127 -1
  229. package/.claude/commands/ant/swarm.md +11 -23
  230. package/.claude/commands/ant/tunnels.md +1 -0
  231. package/.claude/commands/ant/update.md +58 -135
  232. package/.claude/commands/ant/verify-castes.md +90 -42
  233. package/.claude/commands/ant/watch.md +1 -0
  234. package/.opencode/agents/aether-ambassador.md +1 -1
  235. package/.opencode/agents/aether-architect.md +133 -0
  236. package/.opencode/agents/aether-builder.md +3 -3
  237. package/.opencode/agents/aether-oracle.md +137 -0
  238. package/.opencode/agents/aether-queen.md +1 -1
  239. package/.opencode/agents/aether-route-setter.md +1 -1
  240. package/.opencode/agents/aether-scout.md +1 -1
  241. package/.opencode/agents/aether-surveyor-disciplines.md +6 -1
  242. package/.opencode/agents/aether-surveyor-nest.md +6 -1
  243. package/.opencode/agents/aether-surveyor-pathogens.md +6 -1
  244. package/.opencode/agents/aether-surveyor-provisions.md +6 -1
  245. package/.opencode/agents/aether-tracker.md +1 -1
  246. package/.opencode/agents/aether-watcher.md +1 -1
  247. package/.opencode/agents/aether-weaver.md +1 -1
  248. package/.opencode/commands/ant/archaeology.md +7 -14
  249. package/.opencode/commands/ant/build.md +54 -88
  250. package/.opencode/commands/ant/chaos.md +7 -24
  251. package/.opencode/commands/ant/colonize.md +8 -17
  252. package/.opencode/commands/ant/continue.md +595 -66
  253. package/.opencode/commands/ant/council.md +11 -22
  254. package/.opencode/commands/ant/data-clean.md +77 -0
  255. package/.opencode/commands/ant/dream.md +15 -17
  256. package/.opencode/commands/ant/entomb.md +28 -18
  257. package/.opencode/commands/ant/export-signals.md +54 -0
  258. package/.opencode/commands/ant/feedback.md +24 -5
  259. package/.opencode/commands/ant/flag.md +16 -4
  260. package/.opencode/commands/ant/flags.md +24 -10
  261. package/.opencode/commands/ant/focus.md +22 -5
  262. package/.opencode/commands/ant/help.md +41 -8
  263. package/.opencode/commands/ant/history.md +9 -0
  264. package/.opencode/commands/ant/import-signals.md +68 -0
  265. package/.opencode/commands/ant/init.md +365 -156
  266. package/.opencode/commands/ant/insert-phase.md +107 -0
  267. package/.opencode/commands/ant/interpret.md +16 -0
  268. package/.opencode/commands/ant/lay-eggs.md +184 -112
  269. package/.opencode/commands/ant/maturity.md +18 -2
  270. package/.opencode/commands/ant/memory-details.md +83 -0
  271. package/.opencode/commands/ant/migrate-state.md +12 -0
  272. package/.opencode/commands/ant/oracle.md +322 -67
  273. package/.opencode/commands/ant/organize.md +14 -12
  274. package/.opencode/commands/ant/patrol.md +626 -0
  275. package/.opencode/commands/ant/pause-colony.md +12 -29
  276. package/.opencode/commands/ant/phase.md +30 -40
  277. package/.opencode/commands/ant/pheromones.md +162 -0
  278. package/.opencode/commands/ant/plan.md +184 -56
  279. package/.opencode/commands/ant/preferences.md +71 -0
  280. package/.opencode/commands/ant/redirect.md +22 -5
  281. package/.opencode/commands/ant/resume-colony.md +38 -27
  282. package/.opencode/commands/ant/resume.md +71 -20
  283. package/.opencode/commands/ant/run.md +201 -0
  284. package/.opencode/commands/ant/seal.md +230 -25
  285. package/.opencode/commands/ant/skill-create.md +63 -0
  286. package/.opencode/commands/ant/status.md +124 -31
  287. package/.opencode/commands/ant/swarm.md +3 -345
  288. package/.opencode/commands/ant/tunnels.md +3 -9
  289. package/.opencode/commands/ant/update.md +63 -127
  290. package/.opencode/commands/ant/verify-castes.md +96 -42
  291. package/.opencode/commands/ant/watch.md +7 -0
  292. package/CHANGELOG.md +278 -1
  293. package/README.md +188 -340
  294. package/bin/cli.js +236 -429
  295. package/bin/generate-commands.js +186 -0
  296. package/bin/generate-commands.sh +128 -89
  297. package/bin/lib/spawn-logger.js +0 -15
  298. package/bin/lib/update-transaction.js +285 -35
  299. package/bin/npx-install.js +178 -0
  300. package/bin/validate-package.sh +85 -3
  301. package/package.json +7 -3
  302. package/.aether/CONTEXT.md +0 -160
  303. package/.aether/docs/QUEEN.md +0 -84
  304. package/.aether/exchange/colony-registry.xml +0 -11
  305. package/.aether/exchange/pheromones.xml +0 -87
  306. package/.aether/exchange/queen-wisdom.xml +0 -14
  307. package/.aether/model-profiles.yaml +0 -100
  308. package/.aether/utils/spawn-with-model.sh +0 -56
  309. package/bin/lib/model-profiles.js +0 -445
  310. package/bin/lib/model-verify.js +0 -288
  311. package/bin/lib/proxy-health.js +0 -253
  312. package/bin/lib/telemetry.js +0 -441
@@ -0,0 +1,447 @@
1
+ ### Step 2.1.6: Batch Wisdom Auto-Promotion (QUEEN-01)
2
+
3
+ After learnings extraction and auto-emission, sweep all recorded observations and auto-promote any that meet the higher recurrence thresholds (pattern=2, philosophy=3, etc.) to QUEEN.md. The learning-promote-auto subcommand has an internal grep guard that skips content already in QUEEN.md, so this is safe to run even after memory-capture in Step 2.5 already attempted promotion.
4
+
5
+ ```bash
6
+ # === Batch Wisdom Auto-Promotion (QUEEN-01) ===
7
+ # Sweep all observations and auto-promote any that crossed auto thresholds.
8
+ # The grep guard inside learning-promote-auto prevents double-promotion
9
+ # for observations already promoted by memory-capture in Step 2.5.
10
+
11
+ obs_file=".aether/data/learning-observations.json"
12
+ if [[ -f "$obs_file" ]]; then
13
+ obs_count=$(jq '.observations | length' "$obs_file" 2>/dev/null || echo "0")
14
+ promoted_count=0
15
+
16
+ if [[ "$obs_count" -gt 0 ]]; then
17
+ for encoded in $(jq -r '.observations[] | @base64' "$obs_file" 2>/dev/null); do
18
+ content=$(echo "$encoded" | base64 -d | jq -r '.content // empty')
19
+ wisdom_type=$(echo "$encoded" | base64 -d | jq -r '.wisdom_type // "pattern"')
20
+ colony=$(echo "$encoded" | base64 -d | jq -r '.colonies[0] // "unknown"')
21
+ [[ -z "$content" ]] && continue
22
+
23
+ result=$(bash .aether/aether-utils.sh learning-promote-auto "$wisdom_type" "$content" "$colony" "learning" 2>/dev/null || echo '{}')
24
+ was_promoted=$(echo "$result" | jq -r '.result.promoted // false' 2>/dev/null || echo "false")
25
+ if [[ "$was_promoted" == "true" ]]; then
26
+ promoted_count=$((promoted_count + 1))
27
+ fi
28
+ done
29
+ fi
30
+ fi
31
+ # === END Batch Wisdom Auto-Promotion ===
32
+ ```
33
+
34
+ ### Step 2.1.7: Write Build Learnings to QUEEN.md (QUEEN-01)
35
+
36
+ After learning extraction and auto-promotion, write the current phase's learnings directly
37
+ to the QUEEN.md Build Learnings section. This captures both successes and failures from every
38
+ build, regardless of recurrence thresholds.
39
+
40
+ **This step uses queen-write-learnings, which bypasses observation thresholds.**
41
+ Every build writes learnings -- this is the user's explicit decision.
42
+
43
+ Run using the Bash tool with description "Writing build learnings to QUEEN.md...":
44
+ ```bash
45
+ # Get phase info
46
+ current_phase=$(jq -r '.current_phase' .aether/data/COLONY_STATE.json 2>/dev/null || echo "0")
47
+ phase_name=$(jq -r --argjson p "$current_phase" '.plan.phases[] | select(.id == $p) | .name // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
48
+
49
+ # Extract learnings from the just-completed phase
50
+ learnings_json=$(jq -r --argjson p "$((current_phase - 1))" '
51
+ [.memory.phase_learnings[]
52
+ | select(.phase == $p)
53
+ | .learnings[]
54
+ | {
55
+ claim: .claim,
56
+ tag: (if (.claim | test("this (codebase|repo|project)"; "i")) then "repo" else "general" end),
57
+ evidence: (.evidence // "")
58
+ }
59
+ ]' .aether/data/COLONY_STATE.json 2>/dev/null || echo '[]')
60
+
61
+ learnings_count=$(echo "$learnings_json" | jq 'length' 2>/dev/null || echo "0")
62
+
63
+ if [[ "$learnings_count" -gt 0 ]] && [[ "$learnings_json" != "[]" ]]; then
64
+ prev_phase=$((current_phase - 1))
65
+ queen_error="false"
66
+ result=$(bash .aether/aether-utils.sh queen-write-learnings \
67
+ "$prev_phase" "$phase_name" "$learnings_json" 2>/dev/null || echo '{"ok":false}')
68
+ [[ "$result" == '{"ok":false}' ]] && queen_error="true"
69
+
70
+ written=$(echo "$result" | jq -r '.result.written // 0' 2>/dev/null || echo "0")
71
+ fi
72
+ ```
73
+
74
+ **Tag heuristic:**
75
+ - Default tag is "general" (most learnings are broadly applicable)
76
+ - Tag as "repo" if the claim mentions "this codebase", "this repo", "this project", or contains repo-specific names
77
+ - The jq query uses a regex test for common repo-specific indicators
78
+
79
+ **Brief notice:** The consolidated wisdom summary (below) serves as the brief notice.
80
+ It only appears when entries are actually written or instincts are promoted. No notice for zero writes.
81
+
82
+ This step is NON-BLOCKING -- QUEEN.md write failures never block phase advancement.
83
+ The dedup check inside queen-write-learnings prevents duplicate entries.
84
+
85
+ ### Wisdom Summary (PIPE-04)
86
+
87
+ After both queen-write-learnings and hive promotion complete, output a single consolidated wisdom line. This replaces the individual "Written N learning(s)" echo from Step 2.1.7 above.
88
+
89
+ ```bash
90
+ # === Consolidated Wisdom Summary ===
91
+ # Build summary from both queen-write-learnings (Step 2.1.7) and hive promotion (Step 3d)
92
+ # Capture the hive_promoted_count passed from continue-advance.md
93
+ hive_promoted_count="${hive_promoted_count:-0}" # Default to 0 if Step 3d didn't run
94
+
95
+ wisdom_parts=""
96
+ [[ "$written" -gt 0 ]] && wisdom_parts="$written learning(s) recorded"
97
+ # Capture fallback_count from continue-advance.md Step 2.4
98
+ fallback_count="${fallback_count:-0}"
99
+ if [[ "$fallback_count" -gt 0 ]]; then
100
+ wisdom_parts="${wisdom_parts} ($fallback_count from fallback)"
101
+ fi
102
+ if [[ "$hive_promoted_count" -gt 0 ]]; then
103
+ [[ -n "$wisdom_parts" ]] && wisdom_parts="$wisdom_parts, "
104
+ wisdom_parts="$wisdom_parts$hive_promoted_count instinct(s) promoted to hive"
105
+ fi
106
+
107
+ if [[ -n "$wisdom_parts" ]]; then
108
+ echo "$wisdom_parts"
109
+ fi
110
+
111
+ # Warning for failures (non-blocking)
112
+ wisdom_failures=0
113
+ [[ "$queen_error" == "true" ]] && wisdom_failures=$((wisdom_failures + 1))
114
+ [[ "$hive_error" == "true" ]] && wisdom_failures=$((wisdom_failures + 1))
115
+ if [[ "$wisdom_failures" -gt 0 ]]; then
116
+ echo "Warning: $wisdom_failures wisdom write(s) failed"
117
+ fi
118
+ ```
119
+
120
+ ### Step 2.2: Update Handoff Document
121
+
122
+ After advancing the phase, update the handoff document with the new current state:
123
+
124
+ ```bash
125
+ # Determine if there's a next phase
126
+ next_phase_id=$((current_phase + 1))
127
+ has_next_phase=$(jq --arg next "$next_phase_id" '.plan.phases | map(select(.id == ($next | tonumber))) | length' .aether/data/COLONY_STATE.json)
128
+
129
+ # Write updated handoff
130
+ cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
131
+ # Colony Session — Phase Advanced
132
+
133
+ ## Quick Resume
134
+ Run `/ant:build {next_phase_id}` to start working on the current phase.
135
+
136
+ ## State at Advancement
137
+ - Goal: "$(jq -r '.goal' .aether/data/COLONY_STATE.json)"
138
+ - Completed Phase: {completed_phase_id} — {completed_phase_name}
139
+ - Current Phase: {next_phase_id} — {next_phase_name}
140
+ - State: READY
141
+ - Updated: $(date -u +%Y-%m-%dT%H:%M:%SZ)
142
+
143
+ ## What Was Completed
144
+ - Phase {completed_phase_id} marked as completed
145
+ - Learnings extracted: {learning_count}
146
+ - Instincts updated: {instinct_count}
147
+ - Wisdom promoted to QUEEN.md: {promoted_count}
148
+
149
+ ## Current Phase Tasks
150
+ $(jq -r '.plan.phases[] | select(.id == next_phase_id) | .tasks[] | "- [ ] \(.id): \(.description)"' .aether/data/COLONY_STATE.json)
151
+
152
+ ## Next Steps
153
+ - Build current phase: `/ant:build {next_phase_id}`
154
+ - Review phase details: `/ant:phase {next_phase_id}`
155
+ - Pause colony: `/ant:pause-colony`
156
+
157
+ ## Session Note
158
+ Phase advanced successfully. Colony is READY to build Phase {next_phase_id}.
159
+ HANDOFF_EOF
160
+ ```
161
+
162
+ This handoff reflects the post-advancement state, allowing seamless resumption even if the session is lost.
163
+
164
+ ### Step 2.3: Update Changelog
165
+
166
+ **MANDATORY: Append a changelog entry for the completed phase. This step is never skipped.**
167
+
168
+ If no `CHANGELOG.md` exists, `changelog-append` creates one automatically.
169
+
170
+ **Step 2.3.1: Collect plan data**
171
+
172
+ ```bash
173
+ bash .aether/aether-utils.sh changelog-collect-plan-data "{phase_identifier}" "{plan_number}"
174
+ ```
175
+
176
+ Parse the returned JSON to extract `files`, `decisions`, `worked`, and `requirements` arrays.
177
+
178
+ - `{phase_identifier}` is the full phase name (e.g., `36-memory-capture`)
179
+ - `{plan_number}` is the plan number (e.g., `01`)
180
+
181
+ If the command fails (e.g., no plan file found), fall back to collecting data manually:
182
+ - Files: from `git diff --stat` of the completed phase
183
+ - Decisions: from COLONY_STATE.json `memory.decisions` (last 5)
184
+ - Worked/requirements: leave empty
185
+
186
+ **Step 2.3.2: Append changelog entry**
187
+
188
+ ```bash
189
+ bash .aether/aether-utils.sh changelog-append \
190
+ "$(date +%Y-%m-%d)" \
191
+ "{phase_identifier}" \
192
+ "{plan_number}" \
193
+ "{files_csv}" \
194
+ "{decisions_semicolon_separated}" \
195
+ "{worked_semicolon_separated}" \
196
+ "{requirements_csv}"
197
+ ```
198
+
199
+ This atomically writes the entry. If the project already has a Keep a Changelog format, it adds a "Colony Work Log" separator section to keep both formats clean.
200
+
201
+ **Error handling:** If `changelog-append` fails, log to midden and continue — changelog failure never blocks phase advancement.
202
+
203
+ ### Step 2.4: Commit Suggestion (Optional)
204
+
205
+ **This step is non-blocking. Skipping does not affect phase advancement or any subsequent steps. Failure to commit has zero consequences.**
206
+
207
+ After the phase is advanced and changelog updated, suggest a commit to preserve the milestone.
208
+
209
+ #### Step 2.4.1: Capture AI Description
210
+
211
+ **As the AI, briefly describe what was accomplished in this phase.**
212
+
213
+ Look at:
214
+ 1. The phase PLAN.md `<objective>` section (what we set out to do)
215
+ 2. Tasks that were marked complete
216
+ 3. Files that were modified (from git diff --stat)
217
+ 4. Any patterns or decisions recorded
218
+
219
+ **Provide a brief, memorable description** (10-15 words, imperative mood):
220
+ - Good: "Implement task-based model routing with keyword detection and precedence chain"
221
+ - Good: "Fix build timing by removing background execution from worker spawns"
222
+ - Bad: "Phase complete" (too vague)
223
+ - Bad: "Modified files in bin/lib" (too mechanical)
224
+
225
+ Store this as `ai_description` for the commit message.
226
+
227
+ #### Step 2.4.2: Generate Enhanced Commit Message
228
+
229
+ ```bash
230
+ bash .aether/aether-utils.sh generate-commit-message "contextual" {phase_id} "{phase_name}" "{ai_description}" {plan_number}
231
+ ```
232
+
233
+ Parse the returned JSON to extract:
234
+ - `message` - the commit subject line
235
+ - `body` - structured metadata (Scope, Files)
236
+ - `files_changed` - file count
237
+ - `subsystem` - derived subsystem name
238
+ - `scope` - phase.plan format
239
+
240
+ **Check files changed:**
241
+ ```bash
242
+ git diff --stat HEAD 2>/dev/null | tail -5
243
+ ```
244
+ If not in a git repo or no changes detected, skip this step silently.
245
+
246
+ **Display the enhanced suggestion:**
247
+ ```
248
+ ──────────────────────────────────────────────────
249
+ Commit Suggestion
250
+ ──────────────────────────────────────────────────
251
+
252
+ AI Description: {ai_description}
253
+
254
+ Formatted Message:
255
+ {message}
256
+
257
+ Metadata:
258
+ Scope: {scope}
259
+ Files: {files_changed} files changed
260
+ Preview: {first 5 lines of git diff --stat}
261
+
262
+ ──────────────────────────────────────────────────
263
+ ```
264
+
265
+ **Use AskUserQuestion:**
266
+ ```
267
+ Commit this milestone?
268
+
269
+ 1. Yes, commit with this message
270
+ 2. Yes, but let me edit the description
271
+ 3. No, I'll commit later
272
+ ```
273
+
274
+ **If option 1 ("Yes, commit with this message"):**
275
+ ```bash
276
+ git add -A && git commit -m "{message}" -m "{body}"
277
+ ```
278
+ Display: `Committed: {message} ({files_changed} files)`
279
+
280
+ **If option 2 ("Yes, but let me edit"):**
281
+ Use AskUserQuestion to get the user's custom description:
282
+ ```
283
+ Enter your description (or press Enter to keep: '{ai_description}'):
284
+ ```
285
+ Then regenerate the commit message with the new description and commit.
286
+
287
+ **If option 3 ("No, I'll commit later"):**
288
+ Display: `Skipped. Your changes are saved on disk but not committed.`
289
+
290
+ **Record the suggestion to prevent double-prompting:**
291
+ Set `last_commit_suggestion_phase` to `{phase_id}` in COLONY_STATE.json (add the field at the top level if it does not exist).
292
+
293
+ **Error handling:** If any git command fails (not a repo, merge conflict, pre-commit hook rejection), display the error output and continue to the next step. The commit suggestion is advisory only -- it never blocks the flow.
294
+
295
+ Continue to Step 2.5 (Context Clear Suggestion), then to Step 2.7 (Project Completion) or Step 3 (Display Result).
296
+
297
+ ### Step 2.5: Context Clear Suggestion (Optional)
298
+
299
+ **This step is non-blocking. Skipping does not affect phase advancement.**
300
+
301
+ After committing (or skipping commit), suggest clearing context to refresh before the next phase.
302
+
303
+ 1. **Display the suggestion:**
304
+ ```
305
+ ──────────────────────────────────────────────────
306
+ Context Refresh
307
+ ──────────────────────────────────────────────────
308
+
309
+ State is fully persisted and committed.
310
+ Phase {next_id} is ready to build.
311
+
312
+ ──────────────────────────────────────────────────
313
+ ```
314
+
315
+ 2. **Use AskUserQuestion:**
316
+ ```
317
+ Clear context now?
318
+
319
+ 1. Yes, clear context then run /ant:build {next_id}
320
+ 2. No, continue in current context
321
+ ```
322
+
323
+ 3. **If option 1 ("Yes, clear context"):**
324
+
325
+ **IMPORTANT:** Claude Code does not support programmatic /clear. Display instructions:
326
+ ```
327
+ Please type: /clear
328
+
329
+ Then run: /ant:build {next_id}
330
+ ```
331
+
332
+ Record the suggestion: Set `context_clear_suggested` to `true` in COLONY_STATE.json.
333
+
334
+ 4. **If option 2 ("No, continue in current context"):**
335
+ Display: `Continuing in current context. State is saved.`
336
+
337
+ Continue to Step 2.7 (Project Completion) or Step 3 (Display Result).
338
+
339
+ ### Step 2.6: Update Context Document
340
+
341
+ After phase advancement is complete, update `.aether/CONTEXT.md`:
342
+
343
+ **Log the activity:**
344
+ ```bash
345
+ bash .aether/aether-utils.sh context-update activity "continue" "Phase {prev_id} completed, advanced to {next_id}" "—"
346
+ ```
347
+
348
+ **Update the phase:**
349
+ ```bash
350
+ bash .aether/aether-utils.sh context-update update-phase {next_id} "{next_phase_name}" "YES" "Phase advanced, ready to build"
351
+ ```
352
+
353
+ **Log any decisions from this session:**
354
+ If any architectural decisions were made during verification, also run:
355
+ ```bash
356
+ bash .aether/aether-utils.sh context-update decision "{decision_description}" "{rationale}" "Queen"
357
+ ```
358
+
359
+ ### Step 2.7: Project Completion
360
+
361
+ Runs ONLY when all phases complete.
362
+
363
+ 1. Read activity.log and errors.records
364
+ 2. Display tech debt report:
365
+
366
+ ```
367
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
368
+ 🎉 P R O J E C T C O M P L E T E 🎉
369
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
370
+
371
+ 👑 Goal Achieved: {goal}
372
+ 📍 Phases Completed: {total}
373
+
374
+ {if flagged_patterns:}
375
+ ⚠️ Persistent Issues:
376
+ {list any flagged_patterns}
377
+ {end if}
378
+
379
+ 🧠 Colony Learnings:
380
+ {condensed learnings from memory.phase_learnings}
381
+
382
+ 👑 Wisdom Added to QUEEN.md:
383
+ {count} patterns/redirects/philosophies promoted across all phases
384
+
385
+ 🐜 The colony rests. Well done!
386
+ ```
387
+
388
+ 3. Write summary to `.aether/data/completion-report.md`
389
+ 4. Display next commands and stop.
390
+
391
+ ### Step 3: Display Result
392
+
393
+ Output:
394
+
395
+ ```
396
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
397
+ P H A S E A D V A N C E M E N T
398
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
399
+
400
+ ✅ Phase {prev_id}: {prev_name} -- COMPLETED
401
+
402
+ 🧠 Learnings Extracted:
403
+ {list learnings added}
404
+
405
+ 👑 Wisdom Promoted to QUEEN.md:
406
+ {for each promoted learning:}
407
+ [{type}] {brief claim}
408
+ {end for}
409
+
410
+ 🐜 Instincts Updated:
411
+ {for each instinct created or updated:}
412
+ [{confidence}] {domain}: {action}
413
+ {end for}
414
+
415
+ 📝 QUEEN.md Updated:
416
+ Build learnings: {written_count} entries
417
+ Instincts promoted: {promoted_instinct_count} entries
418
+
419
+ ─────────────────────────────────────────────────────
420
+
421
+ ➡️ Advancing to Phase {next_id}: {next_name}
422
+ {next_description}
423
+ 📋 Tasks: {task_count}
424
+ 📊 State: READY
425
+
426
+ ──────────────────────────────────────────────────
427
+ 🐜 Next Up
428
+ ──────────────────────────────────────────────────
429
+ /ant:build {next_id} 🔨 Build next phase
430
+ /ant:status 📊 Check progress
431
+
432
+ 💾 State persisted — context clear suggested above
433
+
434
+ 📋 Context document updated at `.aether/CONTEXT.md`
435
+ ```
436
+
437
+ **IMPORTANT:** In the "Next Steps" section above, substitute the actual phase number for `{next_id}` (calculated in Step 2 as `current_phase + 1`). For example, if advancing to phase 4, output `/ant:build 4` not `/ant:build {next_id}`.
438
+
439
+ ### Step 4: Update Session
440
+
441
+ Update the session tracking file to enable `/ant:resume` after context clear:
442
+
443
+ ```bash
444
+ bash .aether/aether-utils.sh session-update "/ant:continue" "/ant:build {next_id}" "Phase {prev_id} completed, advanced to Phase {next_id}"
445
+ ```
446
+
447
+ Run using the Bash tool with description "Saving session state...": `bash .aether/aether-utils.sh session-update "/ant:continue" "/ant:build {next_id}" "Phase {prev_id} completed, advanced to Phase {next_id}"`