aether-colony 1.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 (207) hide show
  1. package/.aether/CONTEXT.md +160 -0
  2. package/.aether/QUEEN.md +84 -0
  3. package/.aether/aether-utils.sh +7749 -0
  4. package/.aether/docs/QUEEN-SYSTEM.md +211 -0
  5. package/.aether/docs/README.md +68 -0
  6. package/.aether/docs/caste-system.md +48 -0
  7. package/.aether/docs/disciplines/DISCIPLINES.md +93 -0
  8. package/.aether/docs/disciplines/coding-standards.md +197 -0
  9. package/.aether/docs/disciplines/debugging.md +207 -0
  10. package/.aether/docs/disciplines/learning.md +254 -0
  11. package/.aether/docs/disciplines/tdd.md +257 -0
  12. package/.aether/docs/disciplines/verification-loop.md +167 -0
  13. package/.aether/docs/disciplines/verification.md +116 -0
  14. package/.aether/docs/error-codes.md +268 -0
  15. package/.aether/docs/known-issues.md +233 -0
  16. package/.aether/docs/pheromones.md +205 -0
  17. package/.aether/docs/queen-commands.md +97 -0
  18. package/.aether/exchange/colony-registry.xml +11 -0
  19. package/.aether/exchange/pheromone-xml.sh +575 -0
  20. package/.aether/exchange/pheromones.xml +87 -0
  21. package/.aether/exchange/queen-wisdom.xml +14 -0
  22. package/.aether/exchange/registry-xml.sh +273 -0
  23. package/.aether/exchange/wisdom-xml.sh +319 -0
  24. package/.aether/midden/approach-changes.md +5 -0
  25. package/.aether/midden/build-failures.md +5 -0
  26. package/.aether/midden/test-failures.md +5 -0
  27. package/.aether/model-profiles.yaml +100 -0
  28. package/.aether/rules/aether-colony.md +134 -0
  29. package/.aether/schemas/aether-types.xsd +255 -0
  30. package/.aether/schemas/colony-registry.xsd +309 -0
  31. package/.aether/schemas/example-prompt-builder.xml +234 -0
  32. package/.aether/schemas/pheromone.xsd +163 -0
  33. package/.aether/schemas/prompt.xsd +416 -0
  34. package/.aether/schemas/queen-wisdom.xsd +325 -0
  35. package/.aether/schemas/worker-priming.xsd +276 -0
  36. package/.aether/templates/QUEEN.md.template +79 -0
  37. package/.aether/templates/colony-state-reset.jq.template +22 -0
  38. package/.aether/templates/colony-state.template.json +35 -0
  39. package/.aether/templates/constraints.template.json +9 -0
  40. package/.aether/templates/crowned-anthill.template.md +36 -0
  41. package/.aether/templates/handoff-build-error.template.md +30 -0
  42. package/.aether/templates/handoff-build-success.template.md +39 -0
  43. package/.aether/templates/handoff.template.md +40 -0
  44. package/.aether/templates/learning-observations.template.json +6 -0
  45. package/.aether/templates/midden.template.json +7 -0
  46. package/.aether/templates/pheromones.template.json +6 -0
  47. package/.aether/templates/session.template.json +9 -0
  48. package/.aether/utils/atomic-write.sh +219 -0
  49. package/.aether/utils/chamber-compare.sh +193 -0
  50. package/.aether/utils/chamber-utils.sh +297 -0
  51. package/.aether/utils/colorize-log.sh +132 -0
  52. package/.aether/utils/error-handler.sh +212 -0
  53. package/.aether/utils/file-lock.sh +158 -0
  54. package/.aether/utils/queen-to-md.xsl +395 -0
  55. package/.aether/utils/semantic-cli.sh +413 -0
  56. package/.aether/utils/spawn-tree.sh +428 -0
  57. package/.aether/utils/spawn-with-model.sh +56 -0
  58. package/.aether/utils/state-loader.sh +215 -0
  59. package/.aether/utils/swarm-display.sh +268 -0
  60. package/.aether/utils/watch-spawn-tree.sh +253 -0
  61. package/.aether/utils/xml-compose.sh +253 -0
  62. package/.aether/utils/xml-convert.sh +273 -0
  63. package/.aether/utils/xml-core.sh +186 -0
  64. package/.aether/utils/xml-query.sh +201 -0
  65. package/.aether/utils/xml-utils.sh +110 -0
  66. package/.aether/workers.md +765 -0
  67. package/.claude/agents/ant/aether-ambassador.md +264 -0
  68. package/.claude/agents/ant/aether-archaeologist.md +322 -0
  69. package/.claude/agents/ant/aether-auditor.md +266 -0
  70. package/.claude/agents/ant/aether-builder.md +187 -0
  71. package/.claude/agents/ant/aether-chaos.md +268 -0
  72. package/.claude/agents/ant/aether-chronicler.md +304 -0
  73. package/.claude/agents/ant/aether-gatekeeper.md +325 -0
  74. package/.claude/agents/ant/aether-includer.md +373 -0
  75. package/.claude/agents/ant/aether-keeper.md +271 -0
  76. package/.claude/agents/ant/aether-measurer.md +317 -0
  77. package/.claude/agents/ant/aether-probe.md +210 -0
  78. package/.claude/agents/ant/aether-queen.md +325 -0
  79. package/.claude/agents/ant/aether-route-setter.md +173 -0
  80. package/.claude/agents/ant/aether-sage.md +353 -0
  81. package/.claude/agents/ant/aether-scout.md +142 -0
  82. package/.claude/agents/ant/aether-surveyor-disciplines.md +416 -0
  83. package/.claude/agents/ant/aether-surveyor-nest.md +354 -0
  84. package/.claude/agents/ant/aether-surveyor-pathogens.md +288 -0
  85. package/.claude/agents/ant/aether-surveyor-provisions.md +359 -0
  86. package/.claude/agents/ant/aether-tracker.md +265 -0
  87. package/.claude/agents/ant/aether-watcher.md +244 -0
  88. package/.claude/agents/ant/aether-weaver.md +247 -0
  89. package/.claude/commands/ant/archaeology.md +341 -0
  90. package/.claude/commands/ant/build.md +1160 -0
  91. package/.claude/commands/ant/chaos.md +349 -0
  92. package/.claude/commands/ant/colonize.md +270 -0
  93. package/.claude/commands/ant/continue.md +1070 -0
  94. package/.claude/commands/ant/council.md +309 -0
  95. package/.claude/commands/ant/dream.md +265 -0
  96. package/.claude/commands/ant/entomb.md +487 -0
  97. package/.claude/commands/ant/feedback.md +78 -0
  98. package/.claude/commands/ant/flag.md +139 -0
  99. package/.claude/commands/ant/flags.md +155 -0
  100. package/.claude/commands/ant/focus.md +58 -0
  101. package/.claude/commands/ant/help.md +122 -0
  102. package/.claude/commands/ant/history.md +137 -0
  103. package/.claude/commands/ant/init.md +409 -0
  104. package/.claude/commands/ant/interpret.md +267 -0
  105. package/.claude/commands/ant/lay-eggs.md +201 -0
  106. package/.claude/commands/ant/maturity.md +102 -0
  107. package/.claude/commands/ant/memory-details.md +77 -0
  108. package/.claude/commands/ant/migrate-state.md +165 -0
  109. package/.claude/commands/ant/oracle.md +387 -0
  110. package/.claude/commands/ant/organize.md +227 -0
  111. package/.claude/commands/ant/pause-colony.md +247 -0
  112. package/.claude/commands/ant/phase.md +126 -0
  113. package/.claude/commands/ant/plan.md +544 -0
  114. package/.claude/commands/ant/redirect.md +58 -0
  115. package/.claude/commands/ant/resume-colony.md +182 -0
  116. package/.claude/commands/ant/resume.md +363 -0
  117. package/.claude/commands/ant/seal.md +306 -0
  118. package/.claude/commands/ant/status.md +272 -0
  119. package/.claude/commands/ant/swarm.md +361 -0
  120. package/.claude/commands/ant/tunnels.md +425 -0
  121. package/.claude/commands/ant/update.md +209 -0
  122. package/.claude/commands/ant/verify-castes.md +95 -0
  123. package/.claude/commands/ant/watch.md +238 -0
  124. package/.opencode/agents/aether-ambassador.md +140 -0
  125. package/.opencode/agents/aether-archaeologist.md +108 -0
  126. package/.opencode/agents/aether-auditor.md +144 -0
  127. package/.opencode/agents/aether-builder.md +184 -0
  128. package/.opencode/agents/aether-chaos.md +115 -0
  129. package/.opencode/agents/aether-chronicler.md +122 -0
  130. package/.opencode/agents/aether-gatekeeper.md +116 -0
  131. package/.opencode/agents/aether-includer.md +117 -0
  132. package/.opencode/agents/aether-keeper.md +177 -0
  133. package/.opencode/agents/aether-measurer.md +128 -0
  134. package/.opencode/agents/aether-probe.md +133 -0
  135. package/.opencode/agents/aether-queen.md +286 -0
  136. package/.opencode/agents/aether-route-setter.md +130 -0
  137. package/.opencode/agents/aether-sage.md +106 -0
  138. package/.opencode/agents/aether-scout.md +101 -0
  139. package/.opencode/agents/aether-surveyor-disciplines.md +386 -0
  140. package/.opencode/agents/aether-surveyor-nest.md +324 -0
  141. package/.opencode/agents/aether-surveyor-pathogens.md +259 -0
  142. package/.opencode/agents/aether-surveyor-provisions.md +329 -0
  143. package/.opencode/agents/aether-tracker.md +137 -0
  144. package/.opencode/agents/aether-watcher.md +174 -0
  145. package/.opencode/agents/aether-weaver.md +130 -0
  146. package/.opencode/commands/ant/archaeology.md +338 -0
  147. package/.opencode/commands/ant/build.md +1200 -0
  148. package/.opencode/commands/ant/chaos.md +346 -0
  149. package/.opencode/commands/ant/colonize.md +202 -0
  150. package/.opencode/commands/ant/continue.md +938 -0
  151. package/.opencode/commands/ant/council.md +305 -0
  152. package/.opencode/commands/ant/dream.md +262 -0
  153. package/.opencode/commands/ant/entomb.md +367 -0
  154. package/.opencode/commands/ant/feedback.md +80 -0
  155. package/.opencode/commands/ant/flag.md +137 -0
  156. package/.opencode/commands/ant/flags.md +153 -0
  157. package/.opencode/commands/ant/focus.md +56 -0
  158. package/.opencode/commands/ant/help.md +124 -0
  159. package/.opencode/commands/ant/history.md +127 -0
  160. package/.opencode/commands/ant/init.md +337 -0
  161. package/.opencode/commands/ant/interpret.md +256 -0
  162. package/.opencode/commands/ant/lay-eggs.md +141 -0
  163. package/.opencode/commands/ant/maturity.md +92 -0
  164. package/.opencode/commands/ant/memory-details.md +77 -0
  165. package/.opencode/commands/ant/migrate-state.md +153 -0
  166. package/.opencode/commands/ant/oracle.md +338 -0
  167. package/.opencode/commands/ant/organize.md +224 -0
  168. package/.opencode/commands/ant/pause-colony.md +220 -0
  169. package/.opencode/commands/ant/phase.md +123 -0
  170. package/.opencode/commands/ant/plan.md +531 -0
  171. package/.opencode/commands/ant/redirect.md +67 -0
  172. package/.opencode/commands/ant/resume-colony.md +178 -0
  173. package/.opencode/commands/ant/resume.md +363 -0
  174. package/.opencode/commands/ant/seal.md +247 -0
  175. package/.opencode/commands/ant/status.md +272 -0
  176. package/.opencode/commands/ant/swarm.md +357 -0
  177. package/.opencode/commands/ant/tunnels.md +406 -0
  178. package/.opencode/commands/ant/update.md +191 -0
  179. package/.opencode/commands/ant/verify-castes.md +85 -0
  180. package/.opencode/commands/ant/watch.md +220 -0
  181. package/.opencode/opencode.json +3 -0
  182. package/CHANGELOG.md +325 -0
  183. package/DISCLAIMER.md +74 -0
  184. package/LICENSE +21 -0
  185. package/README.md +258 -0
  186. package/bin/cli.js +2436 -0
  187. package/bin/generate-commands.sh +291 -0
  188. package/bin/lib/caste-colors.js +57 -0
  189. package/bin/lib/colors.js +76 -0
  190. package/bin/lib/errors.js +255 -0
  191. package/bin/lib/event-types.js +190 -0
  192. package/bin/lib/file-lock.js +695 -0
  193. package/bin/lib/init.js +454 -0
  194. package/bin/lib/logger.js +242 -0
  195. package/bin/lib/model-profiles.js +445 -0
  196. package/bin/lib/model-verify.js +288 -0
  197. package/bin/lib/nestmate-loader.js +130 -0
  198. package/bin/lib/proxy-health.js +253 -0
  199. package/bin/lib/spawn-logger.js +266 -0
  200. package/bin/lib/state-guard.js +602 -0
  201. package/bin/lib/state-sync.js +516 -0
  202. package/bin/lib/telemetry.js +441 -0
  203. package/bin/lib/update-transaction.js +1454 -0
  204. package/bin/npx-install.js +178 -0
  205. package/bin/sync-to-runtime.sh +6 -0
  206. package/bin/validate-package.sh +88 -0
  207. package/package.json +70 -0
@@ -0,0 +1,938 @@
1
+ ---
2
+ name: ant:continue
3
+ description: "➡️🐜🚪🐜➡️ Detect build completion, reconcile state, and advance to next phase"
4
+ ---
5
+
6
+ You are the **Queen Ant Colony**. Reconcile completed work and advance to the next phase.
7
+
8
+ ## Instructions
9
+
10
+ ### Step -1: Normalize Arguments
11
+
12
+ Run: `normalized_args=$(bash .aether/aether-utils.sh normalize-args "$@")`
13
+
14
+ This ensures arguments work correctly in both Claude Code and OpenCode. Use `$normalized_args` throughout this command.
15
+
16
+ Parse `$normalized_args`:
17
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
18
+ - Otherwise: set `visual_mode = true`
19
+
20
+ ### Step 0: Initialize Visual Mode (if enabled)
21
+
22
+ If `visual_mode` is true:
23
+ ```bash
24
+ # Generate session ID
25
+ continue_id="continue-$(date +%s)"
26
+
27
+ # Initialize swarm display
28
+ bash .aether/aether-utils.sh swarm-display-init "$continue_id"
29
+ bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "excavating" "Phase continuation" "Colony" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "fungus_garden" 0
30
+ ```
31
+
32
+ ### Step 0.5: Version Check (Non-blocking)
33
+
34
+ Run using the Bash tool: `bash .aether/aether-utils.sh version-check 2>/dev/null || true`
35
+
36
+ If the command succeeds and the JSON result contains a non-empty string, display it as a one-line notice. Proceed regardless of outcome.
37
+
38
+ ### Step 1: Read State + Version Check
39
+
40
+ Read `.aether/data/COLONY_STATE.json`.
41
+
42
+ **Auto-upgrade old state:**
43
+ If `version` field is missing, "1.0", or "2.0":
44
+ 1. Preserve: `goal`, `state`, `current_phase`, `plan.phases`
45
+ 2. Write upgraded v3.0 state (same structure as /ant:init but preserving data)
46
+ 3. Output: `State auto-upgraded to v3.0`
47
+ 4. Continue with command.
48
+
49
+ Extract: `goal`, `state`, `current_phase`, `plan.phases`, `errors`, `memory`, `events`, `build_started_at`.
50
+
51
+ **Validation:**
52
+ - If `goal: null` -> output "No colony initialized. Run /ant:init first." and stop.
53
+ - If `plan.phases` is empty -> output "No project plan. Run /ant:plan first." and stop.
54
+
55
+ ### Step 1.5: Load State and Show Resumption Context
56
+
57
+ Run using Bash tool: `bash .aether/aether-utils.sh load-state`
58
+
59
+ If successful and goal is not null:
60
+ 1. Extract current_phase from state
61
+ 2. Get phase name from plan.phases[current_phase - 1].name (or "(unnamed)")
62
+ 3. Display brief resumption context:
63
+ ```
64
+ 🔄 Resuming: Phase X - Name
65
+ ```
66
+
67
+ If .aether/HANDOFF.md exists (detected in load-state output):
68
+ - Display "Resuming from paused session"
69
+ - Read .aether/HANDOFF.md for additional context
70
+ - Remove .aether/HANDOFF.md after display (cleanup)
71
+
72
+ Run: `bash .aether/aether-utils.sh unload-state` to release lock.
73
+
74
+ **Error handling:**
75
+ - If E_FILE_NOT_FOUND: "No colony initialized. Run /ant:init first." and stop
76
+ - If validation error: Display error details with recovery suggestion and stop
77
+ - For other errors: Display generic error and suggest /ant:status for diagnostics
78
+
79
+ **Completion Detection:**
80
+
81
+ If `state == "EXECUTING"`:
82
+ 1. Check if `build_started_at` exists
83
+ 2. Look for phase completion evidence:
84
+ - Activity log entries showing task completion
85
+ - Files created/modified matching phase tasks
86
+ 3. If no evidence and build started > 30 min ago:
87
+ - Display "Stale EXECUTING state. Build may have been interrupted."
88
+ - Offer: continue anyway or rollback to git checkpoint
89
+ - Rollback procedure: `git stash list | grep "aether-checkpoint"` to find ref, then `git stash pop <ref>` to restore
90
+
91
+ If `state != "EXECUTING"`:
92
+ - Normal continue flow (no build to reconcile)
93
+
94
+ ### Step 1.5: Verification Loop Gate (MANDATORY)
95
+
96
+ **The Iron Law:** No phase advancement without fresh verification evidence.
97
+
98
+ Before ANY phase can advance, execute the 6-phase verification loop. See `.aether/docs/disciplines/verification-loop.md` for full reference.
99
+
100
+ #### 1. Command Resolution (Priority Chain)
101
+
102
+ Resolve each command (build, test, types, lint) using this priority chain. Stop at the first source that provides a value for each command:
103
+
104
+ **Priority 1 — CLAUDE.md (System Context):**
105
+ Check the CLAUDE.md instructions already loaded in your system context for explicit build, test, type-check, or lint commands. These are authoritative and override all other sources.
106
+
107
+ **Priority 2 — codebase.md `## Commands`:**
108
+ Read `.aether/data/codebase.md` and look for the `## Commands` section. Use any commands listed there for slots not yet filled by Priority 1.
109
+
110
+ **Priority 3 — Fallback Heuristic Table:**
111
+ For any commands still unresolved, check for these files in order, use first match:
112
+
113
+ | File | Build | Test | Types | Lint |
114
+ |------|-------|------|-------|------|
115
+ | `package.json` | `npm run build` | `npm test` | `npx tsc --noEmit` | `npm run lint` |
116
+ | `Cargo.toml` | `cargo build` | `cargo test` | (built-in) | `cargo clippy` |
117
+ | `go.mod` | `go build ./...` | `go test ./...` | `go vet ./...` | `golangci-lint run` |
118
+ | `pyproject.toml` | `python -m build` | `pytest` | `pyright .` | `ruff check .` |
119
+ | `Makefile` | `make build` | `make test` | (check targets) | `make lint` |
120
+
121
+ If no build system detected, skip build/test/type/lint checks but still verify success criteria.
122
+
123
+ #### 2. Run 6-Phase Verification Loop
124
+
125
+ Execute all applicable phases and capture output:
126
+
127
+ ```
128
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
129
+ 👁️🐜 V E R I F I C A T I O N L O O P
130
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
131
+ Phase {id} — Checking colony work...
132
+ ```
133
+
134
+ **Phase 1: Build Check** (if command exists):
135
+ ```bash
136
+ {build_command} 2>&1 | tail -30
137
+ ```
138
+ Record: exit code, any errors. **STOP if fails.**
139
+
140
+ **Phase 2: Type Check** (if command exists):
141
+ ```bash
142
+ {type_command} 2>&1 | head -30
143
+ ```
144
+ Record: error count. Report all type errors.
145
+
146
+ **Phase 3: Lint Check** (if command exists):
147
+ ```bash
148
+ {lint_command} 2>&1 | head -30
149
+ ```
150
+ Record: warning count, error count.
151
+
152
+ **Phase 4: Test Check** (if command exists):
153
+ ```bash
154
+ {test_command} 2>&1 | tail -50
155
+ ```
156
+ Record: pass count, fail count, exit code. **STOP if fails.**
157
+
158
+ **Coverage Check** (if coverage command exists):
159
+ ```bash
160
+ {coverage_command} # e.g., npm run test:coverage
161
+ ```
162
+ Record: coverage percentage (target: 80%+ for new code)
163
+
164
+ **Phase 5: Security Scan**:
165
+ ```bash
166
+ # Check for exposed secrets
167
+ grep -rn "sk-\|api_key\|password\s*=" --include="*.ts" --include="*.js" --include="*.py" src/ 2>/dev/null | head -10
168
+
169
+ # Check for debug artifacts
170
+ grep -rn "console\.log\|debugger" --include="*.ts" --include="*.tsx" --include="*.js" src/ 2>/dev/null | head -10
171
+ ```
172
+ Record: potential secrets (critical), debug artifacts (warning).
173
+
174
+ **Phase 6: Diff Review**:
175
+ ```bash
176
+ git diff --stat
177
+ ```
178
+ Review changed files for unintended modifications.
179
+
180
+ **Success Criteria Check:**
181
+ Read phase success criteria from `plan.phases[current].success_criteria`.
182
+ For EACH criterion:
183
+ 1. Identify what proves it (file exists? test passes? output shows X?)
184
+ 2. Run the check
185
+ 3. Record evidence or gap
186
+
187
+ Display:
188
+ ```
189
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
190
+ 👁️🐜 V E R I F I C A T I O N R E P O R T
191
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
192
+
193
+ 🔨 Build [PASS/FAIL/SKIP]
194
+ 🔍 Types [PASS/FAIL/SKIP] (X errors)
195
+ 🧹 Lint [PASS/FAIL/SKIP] (X warnings)
196
+ 🧪 Tests [PASS/FAIL/SKIP] (X/Y passed)
197
+ Coverage {percent}% (target: 80%)
198
+ 🔒 Security [PASS/FAIL] (X issues)
199
+ 📋 Diff [X files changed]
200
+
201
+ ──────────────────────────────────────────────────
202
+ 🐜 Success Criteria
203
+ ──────────────────────────────────────────────────
204
+ ✅ {criterion 1}: {specific evidence}
205
+ ✅ {criterion 2}: {specific evidence}
206
+ ❌ {criterion 3}: {what's missing}
207
+
208
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
209
+ Overall: READY / NOT READY
210
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
211
+ ```
212
+
213
+ #### 3. Gate Decision
214
+
215
+ **If NOT READY (any of: build fails, tests fail, critical security issues, success criteria unmet):**
216
+
217
+ ```
218
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
219
+ ⛔🐜 V E R I F I C A T I O N F A I L E D
220
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
221
+
222
+ Phase {id} cannot advance until issues are resolved.
223
+
224
+ 🚨 Issues Found:
225
+ {list each failure with specific evidence}
226
+
227
+ 🔧 Required Actions:
228
+ 1. Fix the issues listed above
229
+ 2. Run /ant:continue again to re-verify
230
+
231
+ The phase will NOT advance until verification passes.
232
+ ```
233
+
234
+ **CRITICAL:** Do NOT proceed to Step 2. Do NOT advance the phase.
235
+ Do NOT offer workarounds. Verification is mandatory.
236
+
237
+ Use AskUserQuestion to confirm they understand what needs to be fixed:
238
+ - Show the specific failures
239
+ - Ask if they want to fix now or need help
240
+
241
+ **If READY (all checks pass with evidence):**
242
+
243
+ ```
244
+ ✅🐜 VERIFICATION PASSED
245
+
246
+ All checks completed with evidence:
247
+ {list each check and its evidence}
248
+
249
+ Proceeding to gate checks...
250
+ ```
251
+
252
+ Continue to Step 1.6.
253
+
254
+ ### Step 1.6: Spawn Enforcement Gate (MANDATORY)
255
+
256
+ **The Iron Law:** No phase advancement without worker spawning for non-trivial phases.
257
+
258
+ Read `.aether/data/spawn-tree.txt` to count spawns for this phase.
259
+
260
+ ```bash
261
+ grep -c "spawned" .aether/data/spawn-tree.txt 2>/dev/null || echo "0"
262
+ ```
263
+
264
+ Also check for Watcher spawns specifically:
265
+ ```bash
266
+ grep -c "watcher" .aether/data/spawn-tree.txt 2>/dev/null || echo "0"
267
+ ```
268
+
269
+ **HARD REJECTION - If spawn_count == 0 and phase had 3+ tasks:**
270
+
271
+ ```
272
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
273
+ ⛔🐜 S P A W N G A T E F A I L E D
274
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
275
+
276
+ This phase had {task_count} tasks but spawn_count: 0
277
+ The Prime Worker violated the spawn protocol.
278
+
279
+ 🐜 The colony requires actual parallelism:
280
+ - Prime Worker MUST spawn specialists for non-trivial work
281
+ - A single agent doing everything is NOT a colony
282
+ - "Justifications" for not spawning are not accepted
283
+
284
+ 🔧 Required Actions:
285
+ 1. Run /ant:build {phase} again
286
+ 2. Prime Worker MUST spawn at least 1 specialist
287
+ 3. Re-run /ant:continue after spawns complete
288
+
289
+ The phase will NOT advance until spawning occurs.
290
+ ```
291
+
292
+ **CRITICAL:** Do NOT proceed to Step 1.7. Do NOT advance the phase.
293
+ Log the violation:
294
+ ```bash
295
+ bash .aether/aether-utils.sh activity-log "BLOCKED" "colony" "Spawn gate failed: {task_count} tasks, 0 spawns"
296
+ bash .aether/aether-utils.sh error-flag-pattern "no-spawn-violation" "Prime Worker completed phase without spawning specialists" "critical"
297
+ ```
298
+
299
+ **HARD REJECTION - If watcher_count == 0 (no testing separation):**
300
+
301
+ ```
302
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
303
+ ⛔👁️🐜 W A T C H E R G A T E F A I L E D
304
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
305
+
306
+ No Watcher ant was spawned for testing/verification.
307
+ Testing MUST be performed by a separate agent, not the builder.
308
+
309
+ 🐜 Why this matters:
310
+ - Builders verify their own work = confirmation bias
311
+ - Independent Watchers catch bugs builders miss
312
+ - "Build passing" ≠ "App working"
313
+
314
+ 🔧 Required Actions:
315
+ 1. Run /ant:build {phase} again
316
+ 2. Prime Worker MUST spawn at least 1 Watcher
317
+ 3. Watcher must independently verify the work
318
+
319
+ The phase will NOT advance until a Watcher validates.
320
+ ```
321
+
322
+ **CRITICAL:** Do NOT proceed. Log the violation.
323
+
324
+ **If spawn_count >= 1 AND watcher_count >= 1:**
325
+
326
+ ```
327
+ ✅🐜 SPAWN GATE PASSED — {spawn_count} workers | {watcher_count} watchers
328
+ ```
329
+
330
+ Continue to Step 1.7.
331
+
332
+ ### Step 1.7: Anti-Pattern Gate
333
+
334
+ Scan all modified/created files for known anti-patterns. This catches recurring bugs before they reach production.
335
+
336
+ ```bash
337
+ bash .aether/aether-utils.sh check-antipattern "{file_path}"
338
+ ```
339
+
340
+ Run for each file in `files_created` and `files_modified` from Prime Worker output.
341
+
342
+ **Anti-Pattern Report:**
343
+
344
+ ```
345
+ 🔍🐜 Anti-Pattern Scan — {count} files scanned
346
+
347
+ {if critical issues:}
348
+ 🛑 CRITICAL (must fix):
349
+ {list each with file:line and description}
350
+
351
+ {if warnings:}
352
+ ⚠️ WARNINGS:
353
+ {list each with file:line and description}
354
+
355
+ {if clean:}
356
+ ✅🐜 No anti-patterns detected
357
+ ```
358
+
359
+ **CRITICAL issues block phase advancement:**
360
+ - Swift didSet infinite recursion
361
+ - Exposed secrets/credentials
362
+ - SQL injection patterns
363
+ - Known crash patterns
364
+
365
+ **WARNINGS are logged but don't block:**
366
+ - TypeScript `any` usage
367
+ - Console.log in production code
368
+ - TODO/FIXME comments
369
+
370
+ If CRITICAL issues found, display:
371
+
372
+ ```
373
+ ⛔🐜 ANTI-PATTERN GATE FAILED
374
+
375
+ Critical anti-patterns detected:
376
+ {list issues with file paths}
377
+
378
+ Run /ant:build {phase} again after fixing.
379
+ ```
380
+
381
+ Do NOT proceed to Step 2.
382
+
383
+ If no CRITICAL issues, continue to Step 1.8.
384
+
385
+ ### Step 1.8: TDD Evidence Gate (MANDATORY)
386
+
387
+ **The Iron Law:** No TDD claims without actual test files.
388
+
389
+ If Prime Worker reported TDD metrics (tests_added, tests_total, coverage_percent), verify test files exist:
390
+
391
+ ```bash
392
+ # Check for test files based on project type
393
+ find . -name "*.test.*" -o -name "*_test.*" -o -name "*Tests.swift" -o -name "test_*.py" 2>/dev/null | head -10
394
+ ```
395
+
396
+ **If Prime Worker claimed tests_added > 0 but no test files found:**
397
+
398
+ ```
399
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
400
+ ⛔🧪🐜 T D D G A T E F A I L E D
401
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
402
+
403
+ Prime Worker claimed:
404
+ tests_added: {claimed_count}
405
+ tests_total: {claimed_total}
406
+ coverage: {claimed_coverage}%
407
+
408
+ But no test files were found in the codebase.
409
+
410
+ 🚨 CRITICAL violation — fabricated TDD metrics.
411
+
412
+ 🔧 Required Actions:
413
+ 1. Run /ant:build {phase} again
414
+ 2. Actually write test files (not just claim them)
415
+ 3. Tests must exist and be runnable
416
+
417
+ The phase will NOT advance with fabricated metrics.
418
+ ```
419
+
420
+ **CRITICAL:** Do NOT proceed. Log the violation:
421
+ ```bash
422
+ bash .aether/aether-utils.sh error-flag-pattern "fabricated-tdd" "Prime Worker reported TDD metrics without creating test files" "critical"
423
+ ```
424
+
425
+ **If tests_added == 0 or test files exist matching claims:**
426
+
427
+ Continue to Step 1.9.
428
+
429
+ ### Step 1.9: Runtime Verification Gate (MANDATORY)
430
+
431
+ **The Iron Law:** Build passing ≠ App working.
432
+
433
+ Before advancing, the user must confirm the application actually runs.
434
+
435
+ Use AskUserQuestion:
436
+
437
+ ```
438
+ ──────────────────────────────────────────────────
439
+ 🐜 Runtime Verification Required
440
+ ──────────────────────────────────────────────────
441
+
442
+ Build checks passed — but does the app actually work?
443
+
444
+ Have you tested the application at runtime?
445
+ ```
446
+
447
+ Options:
448
+ 1. **Yes, tested and working** - App runs correctly, features work
449
+ 2. **Yes, tested but has issues** - App runs but has bugs (describe)
450
+ 3. **No, haven't tested yet** - Need to test before continuing
451
+ 4. **Skip (not applicable)** - No runnable app in this phase (e.g., library code)
452
+
453
+ **If "Yes, tested and working":**
454
+ ```
455
+ ✅🐜 RUNTIME VERIFIED — User confirmed app works.
456
+ ```
457
+ Continue to Step 2.
458
+
459
+ **If "Yes, tested but has issues":**
460
+ ```
461
+ ⛔🐜 RUNTIME GATE FAILED — User reported issues.
462
+
463
+ Please describe the issues so they can be addressed:
464
+ ```
465
+
466
+ Use AskUserQuestion to get issue details. Log to errors.records:
467
+ ```bash
468
+ bash .aether/aether-utils.sh error-add "runtime" "critical" "{user_description}" {phase}
469
+ ```
470
+
471
+ Do NOT proceed to Step 2.
472
+
473
+ **If "No, haven't tested yet":**
474
+ ```
475
+ ⏸️🐜 RUNTIME PENDING — Test the app, then run /ant:continue again.
476
+
477
+ - [ ] App launches without crashing
478
+ - [ ] Core features work as expected
479
+ - [ ] UI responds to user interaction
480
+ - [ ] No freezes or hangs
481
+ ```
482
+
483
+ Do NOT proceed to Step 2.
484
+
485
+ **If "Skip (not applicable)":**
486
+
487
+ Only valid for phases that don't produce runnable code (e.g., documentation, config files, library code with no entry point).
488
+
489
+ ```
490
+ ⏭️ RUNTIME CHECK SKIPPED
491
+
492
+ User indicated no runnable app for this phase.
493
+ Proceeding to phase advancement.
494
+ ```
495
+
496
+ Continue to Step 1.10.
497
+
498
+ ### Step 1.10: Flags Gate (MANDATORY)
499
+
500
+ **The Iron Law:** No phase advancement with unresolved blockers.
501
+
502
+ First, auto-resolve any flags eligible for resolution now that verification has passed:
503
+ ```bash
504
+ bash .aether/aether-utils.sh flag-auto-resolve "build_pass"
505
+ ```
506
+
507
+ Then check for remaining blocking flags:
508
+ ```bash
509
+ bash .aether/aether-utils.sh flag-check-blockers {current_phase}
510
+ ```
511
+
512
+ Parse result for `blockers`, `issues`, and `notes` counts.
513
+
514
+ **If blockers > 0:**
515
+
516
+ ```
517
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
518
+ ⛔🚩🐜 F L A G S G A T E F A I L E D
519
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
520
+
521
+ {blockers} blocker(s) must be resolved first.
522
+
523
+ 🚩 Active Blockers:
524
+ {list each blocker flag with ID, title, and description}
525
+
526
+ 🔧 Required Actions:
527
+ 1. Fix the issues described in each blocker
528
+ 2. Resolve flags: /ant:flags --resolve {flag_id} "resolution message"
529
+ 3. Run /ant:continue again after resolving all blockers
530
+ ```
531
+
532
+ **CRITICAL:** Do NOT proceed to Step 2. Do NOT advance the phase.
533
+
534
+ **If blockers == 0 but issues > 0:**
535
+
536
+ ```
537
+ ⚠️🐜 FLAGS: {issues} issue(s) noted (non-blocking)
538
+
539
+ {list each issue flag}
540
+
541
+ Use /ant:flags to review.
542
+ ```
543
+
544
+ Continue to Step 2.
545
+
546
+ **If all clear (no blockers or issues):**
547
+
548
+ ```
549
+ ✅🐜 FLAGS GATE PASSED — No blockers.
550
+ ```
551
+
552
+ Continue to Step 2.
553
+
554
+ ### Step 2: Update State
555
+
556
+ Find current phase in `plan.phases`.
557
+ Determine next phase (`current_phase + 1`).
558
+
559
+ **If no next phase (all complete):** Skip to Step 2.6 (commit suggestion), then Step 2.5 (completion).
560
+
561
+ Update COLONY_STATE.json:
562
+
563
+ 1. **Mark current phase completed:**
564
+ - Set `plan.phases[current].status` to `"completed"`
565
+ - Set all tasks in phase to `"completed"`
566
+
567
+ 2. **Extract learnings (with validation status):**
568
+
569
+ **CRITICAL: Learnings start as HYPOTHESES until verified.**
570
+
571
+ A learning is only "validated" if:
572
+ - The code was actually run and tested
573
+ - The feature works in practice, not just in theory
574
+ - User has confirmed the behavior
575
+
576
+ Append to `memory.phase_learnings`:
577
+ ```json
578
+ {
579
+ "id": "learning_<unix_timestamp>",
580
+ "phase": <phase_number>,
581
+ "phase_name": "<name>",
582
+ "learnings": [
583
+ {
584
+ "claim": "<specific actionable learning>",
585
+ "status": "hypothesis",
586
+ "tested": false,
587
+ "evidence": "<what observation led to this>",
588
+ "disproven_by": null
589
+ }
590
+ ],
591
+ "timestamp": "<ISO-8601>"
592
+ }
593
+ ```
594
+
595
+ **Status values:**
596
+ - `hypothesis` - Recorded but not verified (DEFAULT)
597
+ - `validated` - Tested and confirmed working
598
+ - `disproven` - Found to be incorrect
599
+
600
+ **Do NOT record a learning if:**
601
+ - It wasn't actually tested
602
+ - It's stating the obvious
603
+ - There's no evidence it works
604
+
605
+ 2.5. **Record learning observations for threshold tracking:**
606
+
607
+ For each learning extracted, record an observation to enable threshold-based wisdom promotion.
608
+
609
+ Run using the Bash tool with description "Recording learning observations...":
610
+ ```bash
611
+ colony_name=$(jq -r '.session_id | split("_")[1] // "unknown"' .aether/data/COLONY_STATE.json 2>/dev/null || echo "unknown")
612
+
613
+ # Get learnings from the current phase
614
+ current_phase_learnings=$(jq -r --argjson phase "$current_phase" '.memory.phase_learnings[] | select(.phase == $phase)' .aether/data/COLONY_STATE.json 2>/dev/null || echo "")
615
+
616
+ if [[ -n "$current_phase_learnings" ]]; then
617
+ echo "$current_phase_learnings" | jq -r '.learnings[]?.claim // empty' 2>/dev/null | while read -r claim; do
618
+ if [[ -n "$claim" ]]; then
619
+ # Default wisdom_type to "pattern" (threshold: 3 observations)
620
+ bash .aether/aether-utils.sh learning-observe "$claim" "pattern" "$colony_name" 2>/dev/null || true
621
+ fi
622
+ done
623
+ echo "Recorded observations for threshold tracking"
624
+ else
625
+ echo "No learnings to record"
626
+ fi
627
+ ```
628
+
629
+ This records each learning in `learning-observations.json` with:
630
+ - Content hash for deduplication (same claim across phases increments count)
631
+ - Observation count (increments if seen before)
632
+ - Colony name for cross-colony tracking
633
+
634
+ When observations reach threshold (default: 3 for "pattern" type), they become eligible for promotion in Step 2.1.5.
635
+
636
+ 3. **Extract instincts from patterns:**
637
+
638
+ Read activity.log for patterns from this phase's build.
639
+
640
+ For each pattern observed (success, error_resolution, user_feedback):
641
+
642
+ **If pattern matches existing instinct:**
643
+ - Update confidence: +0.1 for success outcome, -0.1 for failure
644
+ - Increment applications count
645
+ - Update last_applied timestamp
646
+
647
+ **If new pattern:**
648
+ - Create new instinct with initial confidence:
649
+ - success: 0.4
650
+ - error_resolution: 0.5
651
+ - user_feedback: 0.7
652
+
653
+ Append to `memory.instincts`:
654
+ ```json
655
+ {
656
+ "id": "instinct_<unix_timestamp>",
657
+ "trigger": "<when X>",
658
+ "action": "<do Y>",
659
+ "confidence": 0.5,
660
+ "status": "hypothesis",
661
+ "domain": "<testing|architecture|code-style|debugging|workflow>",
662
+ "source": "phase-<id>",
663
+ "evidence": ["<specific observation that led to this>"],
664
+ "tested": false,
665
+ "created_at": "<ISO-8601>",
666
+ "last_applied": null,
667
+ "applications": 0,
668
+ "successes": 0,
669
+ "failures": 0
670
+ }
671
+ ```
672
+
673
+ **Instinct confidence updates:**
674
+ - Success when applied: +0.1, increment `successes`
675
+ - Failure when applied: -0.15, increment `failures`
676
+ - If `failures` >= 2 and `successes` == 0: mark `status: "disproven"`
677
+ - If `successes` >= 2 and tested: mark `status: "validated"`
678
+
679
+ Cap: Keep max 30 instincts (remove lowest confidence when exceeded).
680
+
681
+ 4. **Advance state:**
682
+ - Set `current_phase` to next phase number
683
+ - Set `state` to `"READY"`
684
+ - Set `build_started_at` to null
685
+ - Append event: `"<timestamp>|phase_advanced|continue|Completed Phase <id>, advancing to Phase <next>"`
686
+
687
+ 5. **Cap enforcement:**
688
+ - Keep max 20 phase_learnings
689
+ - Keep max 30 decisions
690
+ - Keep max 30 instincts (remove lowest confidence)
691
+ - Keep max 100 events
692
+
693
+ Write COLONY_STATE.json.
694
+
695
+ ### Step 2.3: Update Handoff Document
696
+
697
+ After advancing the phase, update the handoff document with the new current state:
698
+
699
+ ```bash
700
+ # Determine if there's a next phase
701
+ next_phase_id=$((current_phase + 1))
702
+ has_next_phase=$(jq --arg next "$next_phase_id" '.plan.phases | map(select(.id == ($next | tonumber))) | length' .aether/data/COLONY_STATE.json)
703
+
704
+ # Write updated handoff
705
+ cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
706
+ # Colony Session — Phase Advanced
707
+
708
+ ## Quick Resume
709
+ Run `/ant:build {next_phase_id}` to start working on the current phase.
710
+
711
+ ## State at Advancement
712
+ - Goal: "$(jq -r '.goal' .aether/data/COLONY_STATE.json)"
713
+ - Completed Phase: {completed_phase_id} — {completed_phase_name}
714
+ - Current Phase: {next_phase_id} — {next_phase_name}
715
+ - State: READY
716
+ - Updated: $(date -u +%Y-%m-%dT%H:%M:%SZ)
717
+
718
+ ## What Was Completed
719
+ - Phase {completed_phase_id} marked as completed
720
+ - Learnings extracted: {learning_count}
721
+ - Instincts updated: {instinct_count}
722
+
723
+ ## Current Phase Tasks
724
+ $(jq -r '.plan.phases[] | select(.id == next_phase_id) | .tasks[] | "- [ ] \(.id): \(.description)"' .aether/data/COLONY_STATE.json)
725
+
726
+ ## Next Steps
727
+ - Build current phase: `/ant:build {next_phase_id}`
728
+ - Review phase details: `/ant:phase {next_phase_id}`
729
+ - Pause colony: `/ant:pause-colony`
730
+
731
+ ## Session Note
732
+ Phase advanced successfully. Colony is READY to build Phase {next_phase_id}.
733
+ HANDOFF_EOF
734
+ ```
735
+
736
+ This handoff reflects the post-advancement state, allowing seamless resumption even if the session is lost.
737
+
738
+ ### Step 2.4: Update Changelog
739
+
740
+ **Append a changelog entry for the completed phase.**
741
+
742
+ If `CHANGELOG.md` exists in the project root:
743
+
744
+ 1. Read the file
745
+ 2. Find the `## [Unreleased]` section
746
+ 3. Under the appropriate sub-heading (`### Added`, `### Changed`, or `### Fixed`), append a bullet for the completed phase:
747
+
748
+ ```
749
+ - **Phase {id}: {phase_name}** — {one-line summary of what was accomplished}. ({list of key files modified})
750
+ ```
751
+
752
+ **Determining the sub-heading:**
753
+ - If the phase created new features/commands → `### Added`
754
+ - If the phase modified existing behavior → `### Changed`
755
+ - If the phase fixed bugs → `### Fixed`
756
+ - If unclear, default to `### Changed`
757
+
758
+ **The one-line summary** should describe the user-visible outcome, not implementation details. Derive it from the phase description and task summaries.
759
+
760
+ **If no `## [Unreleased]` section exists**, create one at the top of the file (after the header).
761
+
762
+ **If no `CHANGELOG.md` exists**, skip this step silently.
763
+
764
+ ### Step 2.6: Commit Suggestion (Optional)
765
+
766
+ **This step is non-blocking. Skipping does not affect phase advancement or any subsequent steps. Failure to commit has zero consequences.**
767
+
768
+ After the phase is advanced and changelog updated, suggest a commit to preserve the milestone.
769
+
770
+ 1. **Generate the commit message:**
771
+ ```bash
772
+ bash .aether/aether-utils.sh generate-commit-message "milestone" {phase_id} "{phase_name}" "{one_line_summary}"
773
+ ```
774
+ Parse the returned JSON to extract `message` and `files_changed`.
775
+
776
+ 2. **Check files changed:**
777
+ ```bash
778
+ git diff --stat HEAD 2>/dev/null | tail -5
779
+ ```
780
+ If not in a git repo or no changes detected, skip this step silently.
781
+
782
+ 3. **Display the suggestion:**
783
+ ```
784
+ ──────────────────────────────────────────────────
785
+ Commit Suggestion
786
+ ──────────────────────────────────────────────────
787
+
788
+ Message: {generated_message}
789
+ Files: {files_changed} files changed
790
+ Preview: {first 5 lines of git diff --stat}
791
+
792
+ ──────────────────────────────────────────────────
793
+ ```
794
+
795
+ 4. **Use AskUserQuestion:**
796
+ ```
797
+ Commit this milestone?
798
+
799
+ 1. Yes, commit with this message
800
+ 2. Yes, but let me write the message
801
+ 3. No, I'll commit later
802
+ ```
803
+
804
+ 5. **If option 1 ("Yes, commit with this message"):**
805
+ ```bash
806
+ git add -A && git commit -m "{generated_message}"
807
+ ```
808
+ Display: `Committed: {generated_message} ({files_changed} files)`
809
+
810
+ 6. **If option 2 ("Yes, but let me write the message"):**
811
+ Use AskUserQuestion to get the user's custom commit message, then:
812
+ ```bash
813
+ git add -A && git commit -m "{custom_message}"
814
+ ```
815
+ Display: `Committed: {custom_message} ({files_changed} files)`
816
+
817
+ 7. **If option 3 ("No, I'll commit later"):**
818
+ Display: `Skipped. Your changes are saved on disk but not committed.`
819
+
820
+ 8. **Record the suggestion to prevent double-prompting:**
821
+ Set `last_commit_suggestion_phase` to `{phase_id}` in COLONY_STATE.json (add the field at the top level if it does not exist).
822
+
823
+ **Error handling:** If any git command fails (not a repo, merge conflict, pre-commit hook rejection), display the error output and continue to the next step. The commit suggestion is advisory only -- it never blocks the flow.
824
+
825
+ Continue to Step 2.7 (Context Clear Suggestion), then to Step 2.5 (Project Completion) or Step 3 (Display Result).
826
+
827
+ ### Step 2.7: Context Clear Suggestion (Optional)
828
+
829
+ **This step is non-blocking. Skipping does not affect phase advancement.**
830
+
831
+ After committing (or skipping commit), suggest clearing context to refresh before the next phase.
832
+
833
+ 1. **Display the suggestion:**
834
+ ```
835
+ ──────────────────────────────────────────────────
836
+ Context Refresh
837
+ ──────────────────────────────────────────────────
838
+
839
+ State is fully persisted and committed.
840
+ Phase {next_id} is ready to build.
841
+
842
+ ──────────────────────────────────────────────────
843
+ ```
844
+
845
+ 2. **Use AskUserQuestion:**
846
+ ```
847
+ Clear context now?
848
+
849
+ 1. Yes, clear context then run /ant:build {next_id}
850
+ 2. No, continue in current context
851
+ ```
852
+
853
+ 3. **If option 1 ("Yes, clear context"):**
854
+
855
+ **IMPORTANT:** Claude Code does not support programmatic /clear. Display instructions:
856
+ ```
857
+ Please type: /clear
858
+
859
+ Then run: /ant:build {next_id}
860
+ ```
861
+
862
+ Record the suggestion: Set `context_clear_suggested` to `true` in COLONY_STATE.json.
863
+
864
+ 4. **If option 2 ("No, continue in current context"):**
865
+ Display: `Continuing in current context. State is saved.`
866
+
867
+ Continue to Step 2.5 (Project Completion) or Step 3 (Display Result).
868
+
869
+ ### Step 2.5: Project Completion
870
+
871
+ Runs ONLY when all phases complete.
872
+
873
+ 1. Read activity.log and errors.records
874
+ 2. Display tech debt report:
875
+
876
+ ```
877
+ 🐜 ═══════════════════════════════════════════════════
878
+ 🎉 P R O J E C T C O M P L E T E 🎉
879
+ ═══════════════════════════════════════════════════ 🐜
880
+
881
+ 👑 Goal Achieved: {goal}
882
+ 📍 Phases Completed: {total}
883
+
884
+ {if flagged_patterns:}
885
+ ⚠️ Persistent Issues:
886
+ {list any flagged_patterns}
887
+ {end if}
888
+
889
+ 🧠 Colony Learnings:
890
+ {condensed learnings from memory.phase_learnings}
891
+
892
+ 🐜 The colony rests. Well done!
893
+ ```
894
+
895
+ 3. Write summary to `.aether/data/completion-report.md`
896
+ 4. Display next commands and stop.
897
+
898
+ ### Step 3: Display Result
899
+
900
+ **If visual_mode is true, render final swarm display:**
901
+ ```bash
902
+ bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "completed" "Phase advanced" "Colony" '{"read":5,"grep":2,"edit":3,"bash":2}' 100 "fungus_garden" 100
903
+ bash .aether/aether-utils.sh swarm-display-render "$continue_id"
904
+ ```
905
+
906
+ Output:
907
+
908
+ ```
909
+ 🐜 ═══════════════════════════════════════════════════
910
+ P H A S E A D V A N C E M E N T
911
+ ═══════════════════════════════════════════════════ 🐜
912
+
913
+ ✅ Phase {prev_id}: {prev_name} -- COMPLETED
914
+
915
+ 🧠 Learnings Extracted:
916
+ {list learnings added}
917
+
918
+ 🐜 Instincts Updated:
919
+ {for each instinct created or updated:}
920
+ [{confidence}] {domain}: {action}
921
+ {end for}
922
+
923
+ ─────────────────────────────────────────────────────
924
+
925
+ ➡️ Advancing to Phase {next_id}: {next_name}
926
+ {next_description}
927
+ 📋 Tasks: {task_count}
928
+ 📊 State: READY
929
+
930
+ 🐜 Next Steps:
931
+ /ant:build {next_id} 🔨 Start building Phase {next_id}: {next_name}
932
+ /ant:phase {next_id} 📋 Review phase details first
933
+ /ant:focus "<area>" 🎯 Guide colony attention
934
+
935
+ 💾 State persisted — context clear suggested above
936
+ ```
937
+
938
+ **IMPORTANT:** In the "Next Steps" section above, substitute the actual phase number for `{next_id}` (calculated in Step 2 as `current_phase + 1`). For example, if advancing to phase 4, output `/ant:build 4` not `/ant:build {next_id}`.