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,1313 @@
1
+ name: "ant:plan"
2
+ description: "📊🐜🗺️🐜📊 Show project plan or generate project-specific phases"
3
+ body_claude: |
4
+ You are the **Queen**. Orchestrate research and planning until the selected confidence target is reached within the selected iteration budget.
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
+ ### Step 1: Read State
13
+
14
+ Read `.aether/data/COLONY_STATE.json`.
15
+
16
+ **Auto-upgrade old state:**
17
+ If `version` field is missing, "1.0", or "2.0":
18
+ 1. Preserve: `goal`, `state`, `current_phase`, `plan.phases`
19
+ 2. Write upgraded v3.0 state (same structure as /ant:init but preserving data)
20
+ 3. Output: `State auto-upgraded to v3.0`
21
+ 4. Continue with command.
22
+
23
+ Extract: `goal`, `plan.phases`
24
+
25
+ **Validate:** If `goal: null`:
26
+ ```
27
+ No colony initialized. Run /ant:init "<goal>" first.
28
+ ```
29
+ Stop here.
30
+
31
+ ### Step 1.5: Load State and Show Resumption Context
32
+
33
+ Run using Bash tool: `bash .aether/aether-utils.sh load-state`
34
+
35
+ If successful and goal is not null:
36
+ 1. Extract current_phase from state
37
+ 2. Get phase name from plan.phases[current_phase - 1].name (or "(unnamed)")
38
+ 3. Display brief resumption context:
39
+ ```
40
+ 🔄 Resuming: Phase X - Name
41
+ ```
42
+
43
+ If .aether/HANDOFF.md exists (detected in load-state output):
44
+ - Display "Resuming from paused session"
45
+ - Read .aether/HANDOFF.md for additional context
46
+ - Remove .aether/HANDOFF.md after display (cleanup)
47
+
48
+ Run: `bash .aether/aether-utils.sh unload-state` to release lock.
49
+
50
+ **Error handling:**
51
+ - If E_FILE_NOT_FOUND: "No colony initialized. Run /ant:init first." and stop
52
+ - If validation error: Display error details with recovery suggestion and stop
53
+ - For other errors: Display generic error and suggest /ant:status for diagnostics
54
+
55
+ ### Step 2: Check Existing Plan
56
+
57
+ If `plan.phases` has entries (non-empty array), skip to **Step 6** (Display Plan).
58
+
59
+ Parse `$ARGUMENTS`:
60
+ - If contains `--accept`: Set `force_accept = true` (accept current plan regardless of confidence)
61
+ - Otherwise: `force_accept = false`
62
+
63
+ Select planning depth (prompt user if not explicitly provided):
64
+ - Presets:
65
+ - `fast`: `target_confidence = 80`, `max_iterations = 4`
66
+ - `balanced`: `target_confidence = 90`, `max_iterations = 6`
67
+ - `deep`: `target_confidence = 95`, `max_iterations = 8`
68
+ - `exhaustive`: `target_confidence = 99`, `max_iterations = 12`
69
+ - Preset selectors:
70
+ - `--fast`, `--balanced`, `--deep`, `--exhaustive`
71
+ - `--quality fast|balanced|deep|exhaustive`
72
+ - CLI overrides:
73
+ - `--target <70-99>` to set `target_confidence`
74
+ - `--max-iterations <2-12>` to set `max_iterations`
75
+ - If no preset/overrides are provided, ask:
76
+ `Planning depth? 1) Fast 2) Balanced 3) Deep (recommended) 4) Exhaustive`
77
+ - Map user choice to a preset, default to `deep` on unclear input.
78
+ - If overrides are out of range, clamp to valid ranges and continue.
79
+
80
+ ### Step 2.5: Load Compact Context Capsule
81
+
82
+ Run using the Bash tool with description "Loading compact planning context...":
83
+ ```bash
84
+ bash .aether/aether-utils.sh context-capsule --compact --json 2>/dev/null
85
+ ```
86
+
87
+ If JSON is valid and `.ok == true`, extract `.result.prompt_section` into `context_capsule_prompt`.
88
+ If command fails or returns invalid JSON, set `context_capsule_prompt = ""` and continue.
89
+
90
+ ### Step 3: Initialize Planning State
91
+
92
+ Update watch files for tmux visibility:
93
+
94
+ Write `.aether/data/watch-status.txt`:
95
+ ```
96
+ AETHER COLONY :: PLANNING
97
+ ==========================
98
+
99
+ State: PLANNING
100
+ Phase: 0/0 (generating plan)
101
+ Confidence: 0%
102
+ Iteration: 0/{max_iterations}
103
+
104
+ Active Workers:
105
+ [Research] Starting...
106
+ [Planning] Waiting...
107
+
108
+ Last Activity:
109
+ Planning loop initiated
110
+ ```
111
+
112
+ Write `.aether/data/watch-progress.txt`:
113
+ ```
114
+ Progress
115
+ ========
116
+
117
+ [ ] 0%
118
+
119
+ Target: {target_confidence}% confidence
120
+
121
+ Iteration: 0/{max_iterations}
122
+ Gaps: (analyzing...)
123
+ ```
124
+
125
+ ### Step 3.5: Load Territory Survey
126
+
127
+ Check if territory survey exists before research:
128
+
129
+ ```bash
130
+ ls .aether/data/survey/*.md 2>/dev/null
131
+ ```
132
+
133
+ **If survey exists:**
134
+ 1. **Always read PATHOGENS.md first** — understand known concerns before planning
135
+ 2. Read other relevant docs based on goal keywords:
136
+
137
+ | Goal Contains | Additional Documents |
138
+ |---------------|---------------------|
139
+ | UI, frontend, component, page | DISCIPLINES.md, CHAMBERS.md |
140
+ | API, backend, endpoint | BLUEPRINT.md, DISCIPLINES.md |
141
+ | database, schema, model | BLUEPRINT.md, PROVISIONS.md |
142
+ | test, spec | SENTINEL-PROTOCOLS.md, DISCIPLINES.md |
143
+ | integration, external | TRAILS.md, PROVISIONS.md |
144
+ | refactor, cleanup | PATHOGENS.md, BLUEPRINT.md |
145
+
146
+ **Inject survey context into scout and planner prompts:**
147
+ - Include key patterns from DISCIPLINES.md
148
+ - Reference architecture from BLUEPRINT.md
149
+ - Note tech stack from PROVISIONS.md
150
+ - Flag concerns from PATHOGENS.md
151
+
152
+ **Display:**
153
+ ```
154
+ 🗺️ Territory survey loaded — incorporating context into planning
155
+ ```
156
+
157
+ **If no survey:** Continue without survey context (scouts will do fresh exploration)
158
+
159
+ ### Step 3.6: Phase Domain Research
160
+
161
+ Investigate domain knowledge for each phase before the planning loop begins. This runs every time `/ant:plan` generates a new plan -- no skip flag.
162
+
163
+ **1. Retrieve hive wisdom for research priming:**
164
+
165
+ ```bash
166
+ hive_context=$(bash .aether/aether-utils.sh hive-read --limit 5 --format text 2>/dev/null)
167
+ ```
168
+
169
+ Parse the JSON result to extract `.result.text` as `hive_text`. If command fails or returns empty, set `hive_text = ""`.
170
+
171
+ **2. Clean any previous research for this phase:**
172
+
173
+ ```bash
174
+ research_dir=".aether/data/phase-research"
175
+ mkdir -p "$research_dir"
176
+ rm -f "$research_dir/phase-{phase_number}-research.md"
177
+ ```
178
+
179
+ Re-running /ant:plan always re-researches from scratch.
180
+
181
+ **3. Spawn Research Scout** via Task tool with `subagent_type="aether-scout"`:
182
+
183
+ FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are a Scout Ant performing Phase Domain Research."
184
+
185
+ ```
186
+ You are a Scout Ant performing Phase Domain Research.
187
+
188
+ --- MISSION ---
189
+ Investigate the domain knowledge needed for Phase {phase_number}: {phase_name}
190
+ Goal: "{goal}"
191
+ Phase description: "{phase_description}"
192
+
193
+ {context_capsule_prompt}
194
+
195
+ --- PRE-EXISTING COLONY WISDOM ---
196
+ {hive_text}
197
+
198
+ --- RESEARCH AREAS ---
199
+ 1. Key patterns in the existing codebase relevant to this phase
200
+ 2. External library/API documentation if the phase involves external tools
201
+ 3. Common gotchas and pitfalls in this domain
202
+ 4. Recommended implementation approach based on findings
203
+
204
+ --- SCOPE CONSTRAINTS ---
205
+ - Maximum 5 key patterns
206
+ - Maximum 3 gotchas
207
+ - Maximum 1 recommended approach paragraph
208
+ - Total output under 3000 words
209
+ - Prioritize actionable guidance over exhaustive documentation
210
+ - Check hive wisdom above first -- do not re-discover known patterns
211
+
212
+ --- TOOLS ---
213
+ Use: Glob, Grep, Read, WebSearch, WebFetch
214
+ Do NOT use: Task, Write, Edit
215
+
216
+ --- OUTPUT FORMAT ---
217
+ Return JSON:
218
+ {
219
+ "hive_wisdom_used": ["list of hive entries that were relevant"],
220
+ "key_patterns": [
221
+ {"pattern": "description", "source": "file path or URL", "relevance": "why it matters for this phase"}
222
+ ],
223
+ "external_context": [
224
+ {"topic": "what", "finding": "description", "source": "URL or doc reference"}
225
+ ],
226
+ "gotchas": [
227
+ {"issue": "what can go wrong", "prevention": "how to avoid it", "source": "evidence"}
228
+ ],
229
+ "recommended_approach": "synthesis paragraph",
230
+ "files_to_study": ["path1", "path2"]
231
+ }
232
+ ```
233
+
234
+ **4. Wait for scout to complete** (blocking -- direct Task return).
235
+
236
+ **5. Parse scout JSON output and write RESEARCH.md to disk.** The Queen (plan.md orchestrator) writes the file -- scout is read-only. Write to: `.aether/data/phase-research/phase-{phase_number}-research.md`
237
+
238
+ RESEARCH.md format (6 fixed sections):
239
+
240
+ ```markdown
241
+ # Phase {N} Research: {Phase Name}
242
+
243
+ **Generated:** {ISO-8601 timestamp}
244
+ **Phase:** {N} - {Phase Name}
245
+ **Research scope:** {brief summary of what was investigated}
246
+
247
+ ## Hive Wisdom (Pre-existing Knowledge)
248
+ {Format hive_wisdom_used entries, or "No relevant hive wisdom found" if empty}
249
+
250
+ ## Key Patterns
251
+ {Format each key_patterns entry as: **{pattern}:** {relevance} (Source: {source})}
252
+
253
+ ## External Context
254
+ {Format each external_context entry as: **{topic}:** {finding} (Source: {source})}
255
+ {If empty: "No external research needed for this phase"}
256
+
257
+ ## Gotchas
258
+ {Format each gotchas entry as: **{issue}:** {prevention} (Source: {source})}
259
+
260
+ ## Recommended Approach
261
+ {recommended_approach text}
262
+
263
+ ## Files to Study
264
+ {Format as bullet list of file paths}
265
+ ```
266
+
267
+ **6. Store research findings** in a variable `research_findings_summary` for injection into the Route-Setter prompt in Step 4. This is a compact summary (not the full RESEARCH.md):
268
+
269
+ ```
270
+ Key Patterns: {bullet list of pattern names}
271
+ Gotchas: {bullet list of gotcha titles}
272
+ Recommended: {recommended_approach, first sentence only}
273
+ Files: {comma-separated file paths}
274
+ ```
275
+
276
+ **7. Display completion:**
277
+
278
+ ```
279
+ Research complete: phase-{phase_number}-research.md ({word_count} words)
280
+ ```
281
+
282
+ ### Step 4: Research and Planning Loop
283
+
284
+ Initialize tracking:
285
+ - `iteration = 0`
286
+ - `confidence = 0`
287
+ - `gaps = []` (list of knowledge gaps)
288
+ - `plan_draft = null`
289
+ - `last_confidence = 0`
290
+ - `stall_count = 0` (consecutive iterations with < 5% improvement)
291
+
292
+ **Loop (max {max_iterations} iterations, 2 agents per iteration: 1 scout + 1 planner):**
293
+
294
+ ```
295
+ while iteration < max_iterations AND confidence < target_confidence:
296
+ iteration += 1
297
+
298
+ # === AUTO-BREAK CHECKS (no user prompt needed) ===
299
+ if iteration > 1:
300
+ if confidence >= target_confidence:
301
+ Log: "Confidence threshold reached ({confidence}%), finalizing plan"
302
+ break
303
+ if stall_count >= 2:
304
+ Log: "Planning stalled at {confidence}%, finalizing current plan"
305
+ break
306
+
307
+ # === RESEARCH PHASE (always runs — 1 scout per iteration) ===
308
+
309
+ if iteration == 1:
310
+
311
+ # Broad exploration on first pass
312
+ Spawn Research Scout via Task tool with subagent_type="aether-scout":
313
+
314
+ """
315
+ You are a Scout Ant in the Aether Colony.
316
+
317
+ --- MISSION ---
318
+ Research the codebase to understand what exists and how it works.
319
+
320
+ Goal: "{goal}"
321
+ Iteration: {iteration}/{max_iterations}
322
+
323
+ {context_capsule_prompt}
324
+
325
+ --- EXPLORATION AREAS ---
326
+ Cover ALL of these in a single pass:
327
+ 1. Core architecture, entry points, and main modules
328
+ 2. Business logic and domain models
329
+ 3. Testing patterns and quality practices
330
+ 4. Configuration, dependencies, and infrastructure
331
+ 5. Edge cases, error handling, and validation
332
+
333
+ --- TOOLS ---
334
+ Use: Glob, Grep, Read, WebSearch, WebFetch
335
+ Do NOT use: Task, Write, Edit
336
+
337
+ --- OUTPUT CONSTRAINTS ---
338
+ Maximum 5 findings (prioritize by impact on the goal).
339
+ Maximum 2 sentences per finding.
340
+ Maximum 3 knowledge gaps identified.
341
+
342
+ --- OUTPUT FORMAT ---
343
+ Return JSON:
344
+ {
345
+ "findings": [
346
+ {"area": "...", "discovery": "...", "source": "file or search"}
347
+ ],
348
+ "gaps_remaining": [
349
+ {"id": "gap_N", "description": "..."}
350
+ ],
351
+ "overall_knowledge_confidence": 0-100
352
+ }
353
+ """
354
+
355
+ else:
356
+
357
+ # Gap-focused research on subsequent passes
358
+ Spawn Gap-Focused Scout via Task tool with subagent_type="aether-scout":
359
+
360
+ """
361
+ You are a Scout Ant in the Aether Colony (gap-focused research).
362
+
363
+ --- MISSION ---
364
+ Investigate ONLY these specific knowledge gaps. Do not explore broadly.
365
+
366
+ Goal: "{goal}"
367
+ Iteration: {iteration}/{max_iterations}
368
+
369
+ {context_capsule_prompt}
370
+
371
+ --- GAPS TO INVESTIGATE ---
372
+ {for each gap in gaps:}
373
+ - {gap.id}: {gap.description}
374
+ {end for}
375
+
376
+ --- TOOLS ---
377
+ Use: Glob, Grep, Read, WebSearch, WebFetch
378
+ Do NOT use: Task, Write, Edit
379
+
380
+ --- OUTPUT CONSTRAINTS ---
381
+ Maximum 3 findings (one per gap investigated).
382
+ Maximum 2 sentences per finding.
383
+ Only report gaps that are STILL unresolved after your research.
384
+
385
+ --- OUTPUT FORMAT ---
386
+ Return JSON:
387
+ {
388
+ "findings": [
389
+ {"area": "...", "discovery": "...", "source": "file or search"}
390
+ ],
391
+ "gaps_remaining": [
392
+ {"id": "gap_N", "description": "..."}
393
+ ],
394
+ "gaps_resolved": ["gap_1", "gap_2"],
395
+ "overall_knowledge_confidence": 0-100
396
+ }
397
+ """
398
+
399
+ # Wait for scout to complete.
400
+ # Update gaps list from scout results.
401
+
402
+ # === PLANNING PHASE (always runs — 1 planner per iteration) ===
403
+
404
+ Spawn Planning Ant (Route-Setter) via Task tool with subagent_type="aether-route-setter":
405
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are a Route-Setter Ant - creates structured phase plans and analyzes dependencies."
406
+
407
+ """
408
+ You are a Route-Setter Ant in the Aether Colony.
409
+
410
+ --- MISSION ---
411
+ Create or refine a project plan based on research findings.
412
+
413
+ Goal: "{goal}"
414
+ Iteration: {iteration}/{max_iterations}
415
+
416
+ {context_capsule_prompt}
417
+
418
+ --- PLANNING DISCIPLINE ---
419
+
420
+ Key rules:
421
+ - Bite-sized tasks (2-5 minutes each) - one action per task
422
+ - Goal-oriented - describe WHAT to achieve, not HOW
423
+ - Constraints define boundaries, not implementation
424
+ - Hints point toward patterns, not solutions
425
+ - Success criteria are testable outcomes
426
+
427
+ Task format (GOAL-ORIENTED):
428
+ ```
429
+ Task N.1: {goal description}
430
+ Goal: What to achieve (not how)
431
+ Constraints:
432
+ - Boundaries and requirements
433
+ - Integration points
434
+ Hints:
435
+ - Pointer to existing patterns (optional)
436
+ - Relevant files to reference (optional)
437
+ Success Criteria:
438
+ - Testable outcome 1
439
+ - Testable outcome 2
440
+ ```
441
+
442
+ DO NOT include:
443
+ - Exact code to write
444
+ - Specific function names (unless critical API)
445
+ - Implementation details
446
+ - Line-by-line instructions
447
+
448
+ Workers discover implementations by reading existing code and patterns.
449
+ This enables TRUE EMERGENCE - different approaches based on context.
450
+
451
+ --- RESEARCH FINDINGS ---
452
+ {scout.findings formatted — compact, max 5 items}
453
+
454
+ --- PHASE DOMAIN RESEARCH (from Step 3.6) ---
455
+ {research_findings_summary if available, otherwise omit this section}
456
+
457
+ Remaining Gaps:
458
+ {gaps formatted — compact, max 3 items}
459
+
460
+ --- CURRENT PLAN DRAFT ---
461
+ {if plan_draft:}
462
+ {plan_draft}
463
+ {else:}
464
+ No plan yet. Create initial draft.
465
+ {end if}
466
+
467
+ --- INSTRUCTIONS ---
468
+ 1. If no plan exists, create 3-6 phases with concrete tasks
469
+ 2. If plan exists, refine based on NEW information only
470
+ 3. Rate confidence across 5 dimensions
471
+ 4. Keep response concise — no verbose explanations
472
+
473
+ Do NOT assign castes to tasks - describe the work only.
474
+
475
+ --- OUTPUT CONSTRAINTS ---
476
+ Maximum 6 phases. Maximum 4 tasks per phase.
477
+ Maximum 2 sentence description per task.
478
+ Confidence dimensions as single numbers, not paragraphs.
479
+
480
+ --- OUTPUT FORMAT ---
481
+ Return JSON:
482
+ {
483
+ "plan": {
484
+ "phases": [
485
+ {
486
+ "id": 1,
487
+ "name": "...",
488
+ "description": "...",
489
+ "tasks": [
490
+ {
491
+ "id": "1.1",
492
+ "goal": "What to achieve (not how)",
493
+ "constraints": ["boundary 1", "boundary 2"],
494
+ "hints": ["optional pointer to pattern"],
495
+ "success_criteria": ["testable outcome 1", "testable outcome 2"],
496
+ "depends_on": []
497
+ }
498
+ ],
499
+ "success_criteria": ["...", "..."]
500
+ }
501
+ ]
502
+ },
503
+ "confidence": {
504
+ "knowledge": 0-100,
505
+ "requirements": 0-100,
506
+ "risks": 0-100,
507
+ "dependencies": 0-100,
508
+ "effort": 0-100,
509
+ "overall": 0-100
510
+ },
511
+ "delta_reasoning": "One sentence: what changed from last iteration",
512
+ "unresolved_gaps": ["...", "..."]
513
+ }
514
+ """
515
+
516
+ Parse planning results. Update plan_draft and confidence.
517
+
518
+ # === UPDATE WATCH FILES ===
519
+
520
+ Update `.aether/data/watch-status.txt` with current state.
521
+ Update `.aether/data/watch-progress.txt` with progress bar.
522
+
523
+ # === STALL TRACKING ===
524
+
525
+ delta = confidence - last_confidence
526
+ if delta < 5:
527
+ stall_count += 1
528
+ else:
529
+ stall_count = 0
530
+
531
+ last_confidence = confidence
532
+ ```
533
+
534
+ **After loop exits (auto-finalize, no user prompt needed):**
535
+
536
+ ```
537
+ Planning complete after {iteration} iteration(s).
538
+
539
+ Confidence: {confidence}%
540
+ {if gaps remain:}
541
+ Note: {gaps.length} knowledge gap(s) deferred — these can be resolved during builds.
542
+ {end if}
543
+ ```
544
+
545
+ Proceed directly to Step 5. No user confirmation needed — the plan auto-finalizes.
546
+
547
+ ### Step 5: Finalize Plan
548
+
549
+ Once loop exits (confidence >= {target_confidence}, max iterations reached, or stall detected):
550
+
551
+ Read current COLONY_STATE.json, then update:
552
+ - Set `plan.phases` to the final phases array
553
+ - Set `plan.generated_at` to ISO-8601 timestamp
554
+ - Set `state` to `"READY"`
555
+ - Append event: `"<timestamp>|plan_generated|plan|Generated {N} phases with {confidence}% confidence"`
556
+
557
+ Write COLONY_STATE.json.
558
+
559
+ Log: `bash .aether/aether-utils.sh activity-log "PLAN_COMPLETE" "queen" "Plan finalized with {confidence}% confidence"`
560
+
561
+ Update watch-status.txt:
562
+ ```
563
+ AETHER COLONY :: READY
564
+ =======================
565
+
566
+ State: READY
567
+ Plan: {N} phases generated
568
+ Confidence: {confidence}%
569
+
570
+ Ready to build.
571
+ ```
572
+
573
+ ### Step 6: Update Session
574
+
575
+ Update the session tracking file to enable `/ant:resume` after context clear:
576
+
577
+ ```bash
578
+ bash .aether/aether-utils.sh session-update "/ant:plan" "/ant:build 1" "Plan generated with {confidence}% confidence, {N} phases"
579
+ ```
580
+
581
+ ### Step 7: Display Plan
582
+
583
+ Read `plan.phases` from COLONY_STATE.json and display:
584
+
585
+ ```
586
+ 📊🐜🗺️🐜📊 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
587
+ C O L O N Y P L A N
588
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📊🐜🗺️🐜📊
589
+
590
+ 👑 Goal: {goal}
591
+
592
+ {if plan was just generated:}
593
+ 📊 Confidence: {confidence}%
594
+ 🔄 Iterations: {iteration}
595
+ {end if}
596
+
597
+ ─────────────────────────────────────────────────────
598
+
599
+ 📍 Phase {id}: {name} [{STATUS}]
600
+ {description}
601
+
602
+ 🐜 Tasks:
603
+ {status_icon} {id}: {description}
604
+
605
+ ✅ Success Criteria:
606
+ • {criterion}
607
+
608
+ ─────────────────────────────────────────────────────
609
+ (repeat for each phase)
610
+
611
+ 🐜 Next Steps:
612
+ {Calculate first_incomplete_phase: iterate through phases, find first where status != 'completed'. Default to 1 if all complete or no phases. Look up its name from plan.phases[id].name.}
613
+ /ant:build {first_incomplete_phase} 🔨 Phase {first_incomplete_phase}: {phase_name}
614
+ /ant:focus "<area>" 🎯 Focus colony attention
615
+ /ant:status 📊 View colony status
616
+
617
+ 💾 Plan persisted — safe to /clear before building
618
+ ```
619
+
620
+ Status icons: pending = `[ ]`, in_progress = `[~]`, completed = `[✓]`
621
+
622
+ After displaying the plan, generate the state-based Next Up block:
623
+ ```bash
624
+ state=$(jq -r '.state // "IDLE"' .aether/data/COLONY_STATE.json)
625
+ current_phase=$(jq -r '.current_phase // 0' .aether/data/COLONY_STATE.json)
626
+ total_phases=$(jq -r '.plan.phases | length' .aether/data/COLONY_STATE.json)
627
+ bash .aether/aether-utils.sh print-next-up "$state" "$current_phase" "$total_phases"
628
+ ```
629
+
630
+ ---
631
+
632
+ ## Confidence Scoring Reference
633
+
634
+ Each dimension rated 0-100%:
635
+
636
+ | Dimension | What It Measures |
637
+ |-----------|------------------|
638
+ | Knowledge | Understanding of codebase structure, patterns, tech stack |
639
+ | Requirements | Clarity of success criteria and acceptance conditions |
640
+ | Risks | Identification of potential blockers and failure modes |
641
+ | Dependencies | Understanding of what affects what, ordering constraints |
642
+ | Effort | Ability to estimate relative complexity of tasks |
643
+
644
+ **Overall** = weighted average (knowledge 25%, requirements 25%, risks 20%, dependencies 15%, effort 15%)
645
+
646
+ **Target:** Use the selected planning depth target. Higher targets trade latency for stronger up-front plan quality.
647
+
648
+ ---
649
+
650
+ ## Auto-Termination Safeguards
651
+
652
+ The planning loop terminates automatically without requiring user input:
653
+
654
+ 1. **Confidence Threshold**: Loop exits when overall confidence reaches `{target_confidence}%`
655
+
656
+ 2. **Hard Iteration Cap**: Maximum `{max_iterations}` iterations (2 subagents per iteration: 1 scout + 1 planner)
657
+
658
+ 3. **Stall Detection**: If confidence improves < 5% for 2 consecutive iterations, auto-finalize current plan
659
+
660
+ 4. **Single Scout Research**: One researcher per iteration (broad on iteration 1, gap-focused on 2+) — no parallel Alpha/Beta or synthesis agent
661
+
662
+ 5. **Compressed Output**: Subagents limited to 5 findings max, 2-sentence summaries, compact JSON
663
+
664
+ 6. **Escape Hatch**: `/ant:plan --accept` accepts current plan regardless of confidence
665
+ body_opencode: |
666
+
667
+ You are the **Queen**. Orchestrate research and planning until the selected confidence target is reached within the selected iteration budget.
668
+
669
+ ## Instructions
670
+
671
+ Parse `$normalized_args`:
672
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
673
+ - Otherwise: set `visual_mode = true`
674
+
675
+ ### Step 1: Read State
676
+
677
+ Read `.aether/data/COLONY_STATE.json`.
678
+
679
+ **Auto-upgrade old state:**
680
+ If `version` field is missing, "1.0", or "2.0":
681
+ 1. Preserve: `goal`, `state`, `current_phase`, `plan.phases`
682
+ 2. Write upgraded v3.0 state (same structure as /ant:init but preserving data)
683
+ 3. Output: `State auto-upgraded to v3.0`
684
+ 4. Continue with command.
685
+
686
+ Extract: `goal`, `plan.phases`
687
+
688
+ **Validate:** If `goal: null`:
689
+ ```
690
+ No colony initialized. Run /ant:init "<goal>" first.
691
+ ```
692
+ Stop here.
693
+
694
+ ### Step 1.5: Load State and Show Resumption Context
695
+
696
+ Run using Bash tool: `bash .aether/aether-utils.sh load-state`
697
+
698
+ If successful and goal is not null:
699
+ 1. Extract current_phase from state
700
+ 2. Get phase name from plan.phases[current_phase - 1].name (or "(unnamed)")
701
+ 3. Display brief resumption context:
702
+ ```
703
+ 🔄 Resuming: Phase X - Name
704
+ ```
705
+
706
+ If .aether/HANDOFF.md exists (detected in load-state output):
707
+ - Display "Resuming from paused session"
708
+ - Read .aether/HANDOFF.md for additional context
709
+ - Remove .aether/HANDOFF.md after display (cleanup)
710
+
711
+ Run: `bash .aether/aether-utils.sh unload-state` to release lock.
712
+
713
+ **Error handling:**
714
+ - If E_FILE_NOT_FOUND: "No colony initialized. Run /ant:init first." and stop
715
+ - If validation error: Display error details with recovery suggestion and stop
716
+ - For other errors: Display generic error and suggest /ant:status for diagnostics
717
+
718
+ ### Step 2: Check Existing Plan
719
+
720
+ If `plan.phases` has entries (non-empty array), skip to **Step 6** (Display Plan).
721
+
722
+ Parse `$normalized_args`:
723
+ - If contains `--accept`: Set `force_accept = true` (accept current plan regardless of confidence)
724
+ - Otherwise: `force_accept = false`
725
+
726
+ Select planning depth (prompt user if not explicitly provided):
727
+ - Presets:
728
+ - `fast`: `target_confidence = 80`, `max_iterations = 4`
729
+ - `balanced`: `target_confidence = 90`, `max_iterations = 6`
730
+ - `deep`: `target_confidence = 95`, `max_iterations = 8`
731
+ - `exhaustive`: `target_confidence = 99`, `max_iterations = 12`
732
+ - Preset selectors:
733
+ - `--fast`, `--balanced`, `--deep`, `--exhaustive`
734
+ - `--quality fast|balanced|deep|exhaustive`
735
+ - CLI overrides:
736
+ - `--target <70-99>` to set `target_confidence`
737
+ - `--max-iterations <2-12>` to set `max_iterations`
738
+ - If no preset/overrides are provided, ask:
739
+ `Planning depth? 1) Fast 2) Balanced 3) Deep (recommended) 4) Exhaustive`
740
+ - Map user choice to a preset, default to `deep` on unclear input.
741
+ - If overrides are out of range, clamp to valid ranges and continue.
742
+
743
+ ### Step 2.5: Load Compact Context Capsule
744
+
745
+ Run using the Bash tool with description "Loading compact planning context...":
746
+ ```bash
747
+ bash .aether/aether-utils.sh context-capsule --compact --json 2>/dev/null
748
+ ```
749
+
750
+ If JSON is valid and `.ok == true`, extract `.result.prompt_section` into `context_capsule_prompt`.
751
+ If command fails or returns invalid JSON, set `context_capsule_prompt = ""` and continue.
752
+
753
+ ### Step 3: Initialize Planning State
754
+
755
+ Update watch files for tmux visibility:
756
+
757
+ Write `.aether/data/watch-status.txt`:
758
+ ```
759
+ AETHER COLONY :: PLANNING
760
+ ==========================
761
+
762
+ State: PLANNING
763
+ Phase: 0/0 (generating plan)
764
+ Confidence: 0%
765
+ Iteration: 0/{max_iterations}
766
+
767
+ Active Workers:
768
+ [Research] Starting...
769
+ [Planning] Waiting...
770
+
771
+ Last Activity:
772
+ Planning loop initiated
773
+ ```
774
+
775
+ Write `.aether/data/watch-progress.txt`:
776
+ ```
777
+ Progress
778
+ ========
779
+
780
+ [ ] 0%
781
+
782
+ Target: {target_confidence}% confidence
783
+
784
+ Iteration: 0/{max_iterations}
785
+ Gaps: (analyzing...)
786
+ ```
787
+
788
+ ### Step 3.5: Load Territory Survey
789
+
790
+ Check if territory survey exists before research:
791
+
792
+ ```bash
793
+ ls .aether/data/survey/*.md 2>/dev/null
794
+ ```
795
+
796
+ **If survey exists:**
797
+ 1. **Always read PATHOGENS.md first** — understand known concerns before planning
798
+ 2. Read other relevant docs based on goal keywords:
799
+
800
+ | Goal Contains | Additional Documents |
801
+ |---------------|---------------------|
802
+ | UI, frontend, component, page | DISCIPLINES.md, CHAMBERS.md |
803
+ | API, backend, endpoint | BLUEPRINT.md, DISCIPLINES.md |
804
+ | database, schema, model | BLUEPRINT.md, PROVISIONS.md |
805
+ | test, spec | SENTINEL-PROTOCOLS.md, DISCIPLINES.md |
806
+ | integration, external | TRAILS.md, PROVISIONS.md |
807
+ | refactor, cleanup | PATHOGENS.md, BLUEPRINT.md |
808
+
809
+ **Inject survey context into scout and planner prompts:**
810
+ - Include key patterns from DISCIPLINES.md
811
+ - Reference architecture from BLUEPRINT.md
812
+ - Note tech stack from PROVISIONS.md
813
+ - Flag concerns from PATHOGENS.md
814
+
815
+ **Display:**
816
+ ```
817
+ 🗺️ Territory survey loaded — incorporating context into planning
818
+ ```
819
+
820
+ **If no survey:** Continue without survey context (scouts will do fresh exploration)
821
+
822
+ ### Step 3.6: Phase Domain Research
823
+
824
+ Investigate domain knowledge for each phase before the planning loop begins. This runs every time `/ant:plan` generates a new plan -- no skip flag.
825
+
826
+ **1. Retrieve hive wisdom for research priming:**
827
+
828
+ ```bash
829
+ hive_context=$(bash .aether/aether-utils.sh hive-read --limit 5 --format text 2>/dev/null)
830
+ ```
831
+
832
+ Parse the JSON result to extract `.result.text` as `hive_text`. If command fails or returns empty, set `hive_text = ""`.
833
+
834
+ **2. Clean any previous research for this phase:**
835
+
836
+ ```bash
837
+ research_dir=".aether/data/phase-research"
838
+ mkdir -p "$research_dir"
839
+ rm -f "$research_dir/phase-{phase_number}-research.md"
840
+ ```
841
+
842
+ Re-running /ant:plan always re-researches from scratch.
843
+
844
+ **3. Spawn Research Scout** via Task tool with `subagent_type="aether-scout"`:
845
+
846
+ FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are a Scout Ant performing Phase Domain Research."
847
+
848
+ ```
849
+ You are a Scout Ant performing Phase Domain Research.
850
+
851
+ --- MISSION ---
852
+ Investigate the domain knowledge needed for Phase {phase_number}: {phase_name}
853
+ Goal: "{goal}"
854
+ Phase description: "{phase_description}"
855
+
856
+ {context_capsule_prompt}
857
+
858
+ --- PRE-EXISTING COLONY WISDOM ---
859
+ {hive_text}
860
+
861
+ --- RESEARCH AREAS ---
862
+ 1. Key patterns in the existing codebase relevant to this phase
863
+ 2. External library/API documentation if the phase involves external tools
864
+ 3. Common gotchas and pitfalls in this domain
865
+ 4. Recommended implementation approach based on findings
866
+
867
+ --- SCOPE CONSTRAINTS ---
868
+ - Maximum 5 key patterns
869
+ - Maximum 3 gotchas
870
+ - Maximum 1 recommended approach paragraph
871
+ - Total output under 3000 words
872
+ - Prioritize actionable guidance over exhaustive documentation
873
+ - Check hive wisdom above first -- do not re-discover known patterns
874
+
875
+ --- TOOLS ---
876
+ Use: Glob, Grep, Read, WebSearch, WebFetch
877
+ Do NOT use: Task, Write, Edit
878
+
879
+ --- OUTPUT FORMAT ---
880
+ Return JSON:
881
+ {
882
+ "hive_wisdom_used": ["list of hive entries that were relevant"],
883
+ "key_patterns": [
884
+ {"pattern": "description", "source": "file path or URL", "relevance": "why it matters for this phase"}
885
+ ],
886
+ "external_context": [
887
+ {"topic": "what", "finding": "description", "source": "URL or doc reference"}
888
+ ],
889
+ "gotchas": [
890
+ {"issue": "what can go wrong", "prevention": "how to avoid it", "source": "evidence"}
891
+ ],
892
+ "recommended_approach": "synthesis paragraph",
893
+ "files_to_study": ["path1", "path2"]
894
+ }
895
+ ```
896
+
897
+ **4. Wait for scout to complete** (blocking -- direct Task return).
898
+
899
+ **5. Parse scout JSON output and write RESEARCH.md to disk.** The Queen (plan.md orchestrator) writes the file -- scout is read-only. Write to: `.aether/data/phase-research/phase-{phase_number}-research.md`
900
+
901
+ RESEARCH.md format (6 fixed sections):
902
+
903
+ ```markdown
904
+ # Phase {N} Research: {Phase Name}
905
+
906
+ **Generated:** {ISO-8601 timestamp}
907
+ **Phase:** {N} - {Phase Name}
908
+ **Research scope:** {brief summary of what was investigated}
909
+
910
+ ## Hive Wisdom (Pre-existing Knowledge)
911
+ {Format hive_wisdom_used entries, or "No relevant hive wisdom found" if empty}
912
+
913
+ ## Key Patterns
914
+ {Format each key_patterns entry as: **{pattern}:** {relevance} (Source: {source})}
915
+
916
+ ## External Context
917
+ {Format each external_context entry as: **{topic}:** {finding} (Source: {source})}
918
+ {If empty: "No external research needed for this phase"}
919
+
920
+ ## Gotchas
921
+ {Format each gotchas entry as: **{issue}:** {prevention} (Source: {source})}
922
+
923
+ ## Recommended Approach
924
+ {recommended_approach text}
925
+
926
+ ## Files to Study
927
+ {Format as bullet list of file paths}
928
+ ```
929
+
930
+ **6. Store research findings** in a variable `research_findings_summary` for injection into the Route-Setter prompt in Step 4. This is a compact summary (not the full RESEARCH.md):
931
+
932
+ ```
933
+ Key Patterns: {bullet list of pattern names}
934
+ Gotchas: {bullet list of gotcha titles}
935
+ Recommended: {recommended_approach, first sentence only}
936
+ Files: {comma-separated file paths}
937
+ ```
938
+
939
+ **7. Display completion:**
940
+
941
+ ```
942
+ Research complete: phase-{phase_number}-research.md ({word_count} words)
943
+ ```
944
+
945
+ ### Step 4: Research and Planning Loop
946
+
947
+ Initialize tracking:
948
+ - `iteration = 0`
949
+ - `confidence = 0`
950
+ - `gaps = []` (list of knowledge gaps)
951
+ - `plan_draft = null`
952
+ - `last_confidence = 0`
953
+ - `stall_count = 0` (consecutive iterations with < 5% improvement)
954
+
955
+ **Loop (max {max_iterations} iterations, 2 agents per iteration: 1 scout + 1 planner):**
956
+
957
+ ```
958
+ while iteration < max_iterations AND confidence < target_confidence:
959
+ iteration += 1
960
+
961
+ # === AUTO-BREAK CHECKS (no user prompt needed) ===
962
+ if iteration > 1:
963
+ if confidence >= target_confidence:
964
+ Log: "Confidence threshold reached ({confidence}%), finalizing plan"
965
+ break
966
+ if stall_count >= 2:
967
+ Log: "Planning stalled at {confidence}%, finalizing current plan"
968
+ break
969
+
970
+ # === RESEARCH PHASE (always runs — 1 scout per iteration) ===
971
+
972
+ if iteration == 1:
973
+
974
+ # Broad exploration on first pass
975
+ Spawn Research Scout via Task tool with subagent_type="aether-scout":
976
+
977
+ """
978
+ You are a Scout Ant in the Aether Colony.
979
+
980
+ --- MISSION ---
981
+ Research the codebase to understand what exists and how it works.
982
+
983
+ Goal: "{goal}"
984
+ Iteration: {iteration}/{max_iterations}
985
+
986
+ {context_capsule_prompt}
987
+
988
+ --- EXPLORATION AREAS ---
989
+ Cover ALL of these in a single pass:
990
+ 1. Core architecture, entry points, and main modules
991
+ 2. Business logic and domain models
992
+ 3. Testing patterns and quality practices
993
+ 4. Configuration, dependencies, and infrastructure
994
+ 5. Edge cases, error handling, and validation
995
+
996
+ --- TOOLS ---
997
+ Use: Glob, Grep, Read, WebSearch, WebFetch
998
+ Do NOT use: Task, Write, Edit
999
+
1000
+ --- OUTPUT CONSTRAINTS ---
1001
+ Maximum 5 findings (prioritize by impact on the goal).
1002
+ Maximum 2 sentences per finding.
1003
+ Maximum 3 knowledge gaps identified.
1004
+
1005
+ --- OUTPUT FORMAT ---
1006
+ Return JSON:
1007
+ {
1008
+ "findings": [
1009
+ {"area": "...", "discovery": "...", "source": "file or search"}
1010
+ ],
1011
+ "gaps_remaining": [
1012
+ {"id": "gap_N", "description": "..."}
1013
+ ],
1014
+ "overall_knowledge_confidence": 0-100
1015
+ }
1016
+ """
1017
+
1018
+ else:
1019
+
1020
+ # Gap-focused research on subsequent passes
1021
+ Spawn Gap-Focused Scout via Task tool with subagent_type="aether-scout":
1022
+
1023
+ """
1024
+ You are a Scout Ant in the Aether Colony (gap-focused research).
1025
+
1026
+ --- MISSION ---
1027
+ Investigate ONLY these specific knowledge gaps. Do not explore broadly.
1028
+
1029
+ Goal: "{goal}"
1030
+ Iteration: {iteration}/{max_iterations}
1031
+
1032
+ {context_capsule_prompt}
1033
+
1034
+ --- GAPS TO INVESTIGATE ---
1035
+ {for each gap in gaps:}
1036
+ - {gap.id}: {gap.description}
1037
+ {end for}
1038
+
1039
+ --- TOOLS ---
1040
+ Use: Glob, Grep, Read, WebSearch, WebFetch
1041
+ Do NOT use: Task, Write, Edit
1042
+
1043
+ --- OUTPUT CONSTRAINTS ---
1044
+ Maximum 3 findings (one per gap investigated).
1045
+ Maximum 2 sentences per finding.
1046
+ Only report gaps that are STILL unresolved after your research.
1047
+
1048
+ --- OUTPUT FORMAT ---
1049
+ Return JSON:
1050
+ {
1051
+ "findings": [
1052
+ {"area": "...", "discovery": "...", "source": "file or search"}
1053
+ ],
1054
+ "gaps_remaining": [
1055
+ {"id": "gap_N", "description": "..."}
1056
+ ],
1057
+ "gaps_resolved": ["gap_1", "gap_2"],
1058
+ "overall_knowledge_confidence": 0-100
1059
+ }
1060
+ """
1061
+
1062
+ # Wait for scout to complete.
1063
+ # Update gaps list from scout results.
1064
+
1065
+ # === PLANNING PHASE (always runs — 1 planner per iteration) ===
1066
+
1067
+ Spawn Planning Ant (Route-Setter) via Task tool with subagent_type="aether-route-setter":
1068
+ # NOTE: Claude Code uses aether-route-setter; OpenCode now uses same specialist agent
1069
+
1070
+ """
1071
+ You are a Route-Setter Ant in the Aether Colony.
1072
+
1073
+ --- MISSION ---
1074
+ Create or refine a project plan based on research findings.
1075
+
1076
+ Goal: "{goal}"
1077
+ Iteration: {iteration}/{max_iterations}
1078
+
1079
+ {context_capsule_prompt}
1080
+
1081
+ --- PLANNING DISCIPLINE ---
1082
+ Read .aether/planning.md for full reference.
1083
+
1084
+ Key rules:
1085
+ - Bite-sized tasks (2-5 minutes each) - one action per task
1086
+ - Goal-oriented - describe WHAT to achieve, not HOW
1087
+ - Constraints define boundaries, not implementation
1088
+ - Hints point toward patterns, not solutions
1089
+ - Success criteria are testable outcomes
1090
+
1091
+ Task format (GOAL-ORIENTED):
1092
+ ```
1093
+ Task N.1: {goal description}
1094
+ Goal: What to achieve (not how)
1095
+ Constraints:
1096
+ - Boundaries and requirements
1097
+ - Integration points
1098
+ Hints:
1099
+ - Pointer to existing patterns (optional)
1100
+ - Relevant files to reference (optional)
1101
+ Success Criteria:
1102
+ - Testable outcome 1
1103
+ - Testable outcome 2
1104
+ ```
1105
+
1106
+ DO NOT include:
1107
+ - Exact code to write
1108
+ - Specific function names (unless critical API)
1109
+ - Implementation details
1110
+ - Line-by-line instructions
1111
+
1112
+ Workers discover implementations by reading existing code and patterns.
1113
+ This enables TRUE EMERGENCE - different approaches based on context.
1114
+
1115
+ --- RESEARCH FINDINGS ---
1116
+ {scout.findings formatted — compact, max 5 items}
1117
+
1118
+ --- PHASE DOMAIN RESEARCH (from Step 3.6) ---
1119
+ {research_findings_summary if available, otherwise omit this section}
1120
+
1121
+ Remaining Gaps:
1122
+ {gaps formatted — compact, max 3 items}
1123
+
1124
+ --- CURRENT PLAN DRAFT ---
1125
+ {if plan_draft:}
1126
+ {plan_draft}
1127
+ {else:}
1128
+ No plan yet. Create initial draft.
1129
+ {end if}
1130
+
1131
+ --- INSTRUCTIONS ---
1132
+ 1. If no plan exists, create 3-6 phases with concrete tasks
1133
+ 2. If plan exists, refine based on NEW information only
1134
+ 3. Rate confidence across 5 dimensions
1135
+ 4. Keep response concise — no verbose explanations
1136
+
1137
+ Do NOT assign castes to tasks - describe the work only.
1138
+
1139
+ --- OUTPUT CONSTRAINTS ---
1140
+ Maximum 6 phases. Maximum 4 tasks per phase.
1141
+ Maximum 2 sentence description per task.
1142
+ Confidence dimensions as single numbers, not paragraphs.
1143
+
1144
+ --- OUTPUT FORMAT ---
1145
+ Return JSON:
1146
+ {
1147
+ "plan": {
1148
+ "phases": [
1149
+ {
1150
+ "id": 1,
1151
+ "name": "...",
1152
+ "description": "...",
1153
+ "tasks": [
1154
+ {
1155
+ "id": "1.1",
1156
+ "goal": "What to achieve (not how)",
1157
+ "constraints": ["boundary 1", "boundary 2"],
1158
+ "hints": ["optional pointer to pattern"],
1159
+ "success_criteria": ["testable outcome 1", "testable outcome 2"],
1160
+ "depends_on": []
1161
+ }
1162
+ ],
1163
+ "success_criteria": ["...", "..."]
1164
+ }
1165
+ ]
1166
+ },
1167
+ "confidence": {
1168
+ "knowledge": 0-100,
1169
+ "requirements": 0-100,
1170
+ "risks": 0-100,
1171
+ "dependencies": 0-100,
1172
+ "effort": 0-100,
1173
+ "overall": 0-100
1174
+ },
1175
+ "delta_reasoning": "One sentence: what changed from last iteration",
1176
+ "unresolved_gaps": ["...", "..."]
1177
+ }
1178
+ """
1179
+
1180
+ Parse planning results. Update plan_draft and confidence.
1181
+
1182
+ # === UPDATE WATCH FILES ===
1183
+
1184
+ Update `.aether/data/watch-status.txt` with current state.
1185
+ Update `.aether/data/watch-progress.txt` with progress bar.
1186
+
1187
+ # === STALL TRACKING ===
1188
+
1189
+ delta = confidence - last_confidence
1190
+ if delta < 5:
1191
+ stall_count += 1
1192
+ else:
1193
+ stall_count = 0
1194
+
1195
+ last_confidence = confidence
1196
+ ```
1197
+
1198
+ **After loop exits (auto-finalize, no user prompt needed):**
1199
+
1200
+ ```
1201
+ Planning complete after {iteration} iteration(s).
1202
+
1203
+ Confidence: {confidence}%
1204
+ {if gaps remain:}
1205
+ Note: {gaps.length} knowledge gap(s) deferred — these can be resolved during builds.
1206
+ {end if}
1207
+ ```
1208
+
1209
+ Proceed directly to Step 5. No user confirmation needed — the plan auto-finalizes.
1210
+
1211
+ ### Step 5: Finalize Plan
1212
+
1213
+ Once loop exits (confidence >= {target_confidence}, max iterations reached, or stall detected):
1214
+
1215
+ Read current COLONY_STATE.json, then update:
1216
+ - Set `plan.phases` to the final phases array
1217
+ - Set `plan.generated_at` to ISO-8601 timestamp
1218
+ - Set `state` to `"READY"`
1219
+ - Append event: `"<timestamp>|plan_generated|plan|Generated {N} phases with {confidence}% confidence"`
1220
+
1221
+ Write COLONY_STATE.json.
1222
+
1223
+ Log plan completion: `bash .aether/aether-utils.sh activity-log "PLAN_COMPLETE" "queen" "Plan finalized with {confidence}% confidence"`
1224
+
1225
+ Update watch-status.txt:
1226
+ ```
1227
+ AETHER COLONY :: READY
1228
+ =======================
1229
+
1230
+ State: READY
1231
+ Plan: {N} phases generated
1232
+ Confidence: {confidence}%
1233
+
1234
+ Ready to build.
1235
+ ```
1236
+
1237
+ ### Step 6: Display Plan
1238
+
1239
+ Read `plan.phases` from COLONY_STATE.json and display:
1240
+
1241
+ ```
1242
+ 📊🐜🗺️🐜📊 ═══════════════════════════════════════════════════
1243
+ C O L O N Y P L A N
1244
+ ═══════════════════════════════════════════════════ 📊🐜🗺️🐜📊
1245
+
1246
+ 👑 Goal: {goal}
1247
+
1248
+ {if plan was just generated:}
1249
+ 📊 Confidence: {confidence}%
1250
+ 🔄 Iterations: {iteration}
1251
+ {end if}
1252
+
1253
+ ─────────────────────────────────────────────────────
1254
+
1255
+ 📍 Phase {id}: {name} [{STATUS}]
1256
+ {description}
1257
+
1258
+ 🐜 Tasks:
1259
+ {status_icon} {id}: {description}
1260
+
1261
+ ✅ Success Criteria:
1262
+ • {criterion}
1263
+
1264
+ ─────────────────────────────────────────────────────
1265
+ (repeat for each phase)
1266
+
1267
+ 🐜 Next Steps:
1268
+ {Calculate first_incomplete_phase: iterate through phases, find first where status != 'completed'. Default to 1 if all complete or no phases. Look up its name from plan.phases[id].name.}
1269
+ /ant:build {first_incomplete_phase} 🔨 Phase {first_incomplete_phase}: {phase_name}
1270
+ /ant:focus "<area>" 🎯 Focus colony attention
1271
+ /ant:status 📊 View colony status
1272
+
1273
+ 💾 Plan persisted — safe to /clear before building
1274
+ ```
1275
+
1276
+ Status icons: pending = `[ ]`, in_progress = `[~]`, completed = `[✓]`
1277
+
1278
+ ---
1279
+
1280
+ ## Confidence Scoring Reference
1281
+
1282
+ Each dimension rated 0-100%:
1283
+
1284
+ | Dimension | What It Measures |
1285
+ |-----------|------------------|
1286
+ | Knowledge | Understanding of codebase structure, patterns, tech stack |
1287
+ | Requirements | Clarity of success criteria and acceptance conditions |
1288
+ | Risks | Identification of potential blockers and failure modes |
1289
+ | Dependencies | Understanding of what affects what, ordering constraints |
1290
+ | Effort | Ability to estimate relative complexity of tasks |
1291
+
1292
+ **Overall** = weighted average (knowledge 25%, requirements 25%, risks 20%, dependencies 15%, effort 15%)
1293
+
1294
+ **Target:** Use the selected planning depth target. Higher targets trade latency for stronger up-front plan quality.
1295
+
1296
+ ---
1297
+
1298
+ ## Auto-Termination Safeguards
1299
+
1300
+ The planning loop terminates automatically without requiring user input:
1301
+
1302
+ 1. **Confidence Threshold**: Loop exits when overall confidence reaches `{target_confidence}%`
1303
+
1304
+ 2. **Hard Iteration Cap**: Maximum `{max_iterations}` iterations (2 subagents per iteration: 1 scout + 1 planner)
1305
+
1306
+ 3. **Stall Detection**: If confidence improves < 5% for 2 consecutive iterations, auto-finalize current plan
1307
+
1308
+ 4. **Single Scout Research**: One researcher per iteration (broad on iteration 1, gap-focused on 2+) — no parallel Alpha/Beta or synthesis agent
1309
+
1310
+ 5. **Compressed Output**: Subagents limited to 5 findings max, 2-sentence summaries, compact JSON
1311
+
1312
+ 6. **Escape Hatch**: `/ant:plan --accept` accepts current plan regardless of confidence
1313
+