aether-colony 5.0.0 → 5.2.1

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