aether-colony 3.1.4 → 3.1.15

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 (124) hide show
  1. package/.claude/commands/ant/archaeology.md +12 -0
  2. package/.claude/commands/ant/build.md +382 -319
  3. package/.claude/commands/ant/chaos.md +23 -1
  4. package/.claude/commands/ant/colonize.md +147 -87
  5. package/.claude/commands/ant/continue.md +213 -23
  6. package/.claude/commands/ant/council.md +22 -0
  7. package/.claude/commands/ant/dream.md +18 -0
  8. package/.claude/commands/ant/entomb.md +178 -6
  9. package/.claude/commands/ant/init.md +87 -13
  10. package/.claude/commands/ant/lay-eggs.md +45 -5
  11. package/.claude/commands/ant/oracle.md +82 -9
  12. package/.claude/commands/ant/organize.md +2 -2
  13. package/.claude/commands/ant/pause-colony.md +86 -28
  14. package/.claude/commands/ant/phase.md +26 -0
  15. package/.claude/commands/ant/plan.md +204 -111
  16. package/.claude/commands/ant/resume-colony.md +23 -1
  17. package/.claude/commands/ant/resume.md +159 -0
  18. package/.claude/commands/ant/seal.md +177 -3
  19. package/.claude/commands/ant/swarm.md +78 -97
  20. package/.claude/commands/ant/verify-castes.md +7 -7
  21. package/.claude/commands/ant/watch.md +17 -0
  22. package/.opencode/agents/aether-ambassador.md +97 -0
  23. package/.opencode/agents/aether-archaeologist.md +91 -0
  24. package/.opencode/agents/aether-architect.md +66 -0
  25. package/.opencode/agents/aether-auditor.md +111 -0
  26. package/.opencode/agents/aether-builder.md +28 -10
  27. package/.opencode/agents/aether-chaos.md +98 -0
  28. package/.opencode/agents/aether-chronicler.md +80 -0
  29. package/.opencode/agents/aether-gatekeeper.md +107 -0
  30. package/.opencode/agents/aether-guardian.md +107 -0
  31. package/.opencode/agents/aether-includer.md +108 -0
  32. package/.opencode/agents/aether-keeper.md +106 -0
  33. package/.opencode/agents/aether-measurer.md +119 -0
  34. package/.opencode/agents/aether-probe.md +91 -0
  35. package/.opencode/agents/aether-queen.md +72 -19
  36. package/.opencode/agents/aether-route-setter.md +85 -0
  37. package/.opencode/agents/aether-sage.md +98 -0
  38. package/.opencode/agents/aether-scout.md +33 -15
  39. package/.opencode/agents/aether-surveyor-disciplines.md +334 -0
  40. package/.opencode/agents/aether-surveyor-nest.md +272 -0
  41. package/.opencode/agents/aether-surveyor-pathogens.md +209 -0
  42. package/.opencode/agents/aether-surveyor-provisions.md +277 -0
  43. package/.opencode/agents/aether-tracker.md +91 -0
  44. package/.opencode/agents/aether-watcher.md +30 -12
  45. package/.opencode/agents/aether-weaver.md +87 -0
  46. package/.opencode/agents/workers.md +1034 -0
  47. package/.opencode/commands/ant/archaeology.md +44 -26
  48. package/.opencode/commands/ant/build.md +327 -295
  49. package/.opencode/commands/ant/chaos.md +32 -4
  50. package/.opencode/commands/ant/colonize.md +119 -93
  51. package/.opencode/commands/ant/continue.md +98 -10
  52. package/.opencode/commands/ant/council.md +28 -0
  53. package/.opencode/commands/ant/dream.md +24 -0
  54. package/.opencode/commands/ant/entomb.md +73 -1
  55. package/.opencode/commands/ant/feedback.md +8 -2
  56. package/.opencode/commands/ant/flag.md +9 -3
  57. package/.opencode/commands/ant/flags.md +8 -2
  58. package/.opencode/commands/ant/focus.md +8 -2
  59. package/.opencode/commands/ant/help.md +12 -0
  60. package/.opencode/commands/ant/init.md +49 -4
  61. package/.opencode/commands/ant/lay-eggs.md +30 -2
  62. package/.opencode/commands/ant/oracle.md +39 -7
  63. package/.opencode/commands/ant/organize.md +9 -3
  64. package/.opencode/commands/ant/pause-colony.md +54 -1
  65. package/.opencode/commands/ant/phase.md +36 -4
  66. package/.opencode/commands/ant/plan.md +225 -117
  67. package/.opencode/commands/ant/redirect.md +8 -2
  68. package/.opencode/commands/ant/resume-colony.md +51 -26
  69. package/.opencode/commands/ant/seal.md +76 -0
  70. package/.opencode/commands/ant/status.md +50 -20
  71. package/.opencode/commands/ant/swarm.md +108 -104
  72. package/.opencode/commands/ant/tunnels.md +107 -2
  73. package/CHANGELOG.md +21 -0
  74. package/README.md +199 -86
  75. package/bin/cli.js +142 -25
  76. package/bin/generate-commands.sh +100 -16
  77. package/bin/lib/caste-colors.js +5 -5
  78. package/bin/lib/errors.js +16 -0
  79. package/bin/lib/file-lock.js +279 -44
  80. package/bin/lib/state-sync.js +206 -23
  81. package/bin/lib/update-transaction.js +206 -24
  82. package/bin/sync-to-runtime.sh +129 -0
  83. package/package.json +2 -2
  84. package/runtime/CONTEXT.md +160 -0
  85. package/runtime/aether-utils.sh +1421 -55
  86. package/runtime/docs/AETHER-2.0-IMPLEMENTATION-PLAN.md +1343 -0
  87. package/runtime/docs/AETHER-PHEROMONE-SYSTEM-MASTER-SPEC.md +2642 -0
  88. package/runtime/docs/PHEROMONE-INJECTION.md +240 -0
  89. package/runtime/docs/PHEROMONE-INTEGRATION.md +192 -0
  90. package/runtime/docs/PHEROMONE-SYSTEM-DESIGN.md +426 -0
  91. package/runtime/docs/README.md +94 -0
  92. package/runtime/docs/VISUAL-OUTPUT-SPEC.md +219 -0
  93. package/runtime/docs/biological-reference.md +272 -0
  94. package/runtime/docs/codebase-review.md +399 -0
  95. package/runtime/docs/command-sync.md +164 -0
  96. package/runtime/docs/implementation-learnings.md +89 -0
  97. package/runtime/docs/known-issues.md +217 -0
  98. package/runtime/docs/namespace.md +148 -0
  99. package/runtime/docs/planning-discipline.md +159 -0
  100. package/runtime/lib/queen-utils.sh +729 -0
  101. package/runtime/model-profiles.yaml +100 -0
  102. package/runtime/recover.sh +136 -0
  103. package/runtime/templates/QUEEN.md.template +79 -0
  104. package/runtime/utils/atomic-write.sh +5 -5
  105. package/runtime/utils/chamber-utils.sh +6 -3
  106. package/runtime/utils/error-handler.sh +200 -0
  107. package/runtime/utils/queen-to-md.xsl +395 -0
  108. package/runtime/utils/spawn-tree.sh +428 -0
  109. package/runtime/utils/spawn-with-model.sh +56 -0
  110. package/runtime/utils/state-loader.sh +215 -0
  111. package/runtime/utils/swarm-display.sh +5 -5
  112. package/runtime/utils/watch-spawn-tree.sh +90 -22
  113. package/runtime/utils/xml-compose.sh +247 -0
  114. package/runtime/utils/xml-core.sh +186 -0
  115. package/runtime/utils/xml-utils.sh +2161 -0
  116. package/runtime/verification-loop.md +1 -1
  117. package/runtime/workers-new-castes.md +516 -0
  118. package/runtime/workers.md +20 -8
  119. package/.aether/visualizations/anthill-stages/brood-stable.txt +0 -26
  120. package/.aether/visualizations/anthill-stages/crowned-anthill.txt +0 -30
  121. package/.aether/visualizations/anthill-stages/first-mound.txt +0 -18
  122. package/.aether/visualizations/anthill-stages/open-chambers.txt +0 -24
  123. package/.aether/visualizations/anthill-stages/sealed-chambers.txt +0 -28
  124. package/.aether/visualizations/anthill-stages/ventilated-nest.txt +0 -27
@@ -53,22 +53,24 @@ After displaying context, run: `bash .aether/aether-utils.sh unload-state` to re
53
53
  1. Extract the phase number (first argument)
54
54
  2. Check remaining arguments for flags:
55
55
  - If contains `--verbose` or `-v`: set `verbose_mode = true`
56
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
56
57
  - If contains `--model <name>` or `-m <name>`: set `cli_model_override = <name>`
57
- - Otherwise: set defaults
58
+ - Otherwise: set `visual_mode = true` (visual is default)
58
59
 
59
60
  If the phase number is empty or not a number:
60
61
 
61
62
  ```
62
- Usage: /ant:build <phase_number> [--verbose|-v] [--model <model>|-m <model>]
63
+ Usage: /ant:build <phase_number> [--verbose|-v] [--no-visual] [--model <model>|-m <model>]
63
64
 
64
65
  Options:
65
66
  --verbose, -v Show full completion details (spawn tree, TDD, patterns)
67
+ --no-visual Disable real-time visual display (visual is on by default)
66
68
  --model, -m <name> Override model for this build (one-time)
67
69
 
68
70
  Examples:
69
- /ant:build 1 Build Phase 1 (compact output)
70
- /ant:build 1 --verbose Build Phase 1 (full details)
71
- /ant:build 3 -v Build Phase 3 (full details)
71
+ /ant:build 1 Build Phase 1 (with visual display)
72
+ /ant:build 1 --verbose Build Phase 1 (full details + visual)
73
+ /ant:build 1 --no-visual Build Phase 1 without visual display
72
74
  /ant:build 1 --model glm-5 Build Phase 1 with glm-5 for all workers
73
75
  ```
74
76
 
@@ -189,7 +191,90 @@ If file doesn't exist or is empty:
189
191
  CONSTRAINTS: (none)
190
192
  ```
191
193
 
192
- ### Step 4.5: Archaeologist Pre-Build Scan
194
+ ### Step 4.0: Load Territory Survey
195
+
196
+ Check if territory survey exists and load relevant documents:
197
+
198
+ ```bash
199
+ bash .aether/aether-utils.sh survey-load "{phase_name}" 2>/dev/null
200
+ ```
201
+
202
+ **Parse the JSON response:**
203
+ - If `.ok` is false: Set `survey_docs = null` and skip survey loading
204
+ - If successful: Extract `.docs` (comma-separated list) and `.dir`
205
+
206
+ **Determine phase type from phase name:**
207
+ | Phase Contains | Documents to Load |
208
+ |----------------|-------------------|
209
+ | UI, frontend, component, button, page | DISCIPLINES.md, CHAMBERS.md |
210
+ | API, endpoint, backend, route | BLUEPRINT.md, DISCIPLINES.md |
211
+ | database, schema, model, migration | BLUEPRINT.md, PROVISIONS.md |
212
+ | test, spec, coverage | SENTINEL-PROTOCOLS.md, DISCIPLINES.md |
213
+ | integration, external, client | TRAILS.md, PROVISIONS.md |
214
+ | refactor, cleanup, debt | PATHOGENS.md, BLUEPRINT.md |
215
+ | setup, config, initialize | PROVISIONS.md, CHAMBERS.md |
216
+ | *default* | PROVISIONS.md, BLUEPRINT.md |
217
+
218
+ **Read the relevant survey documents** from `.aether/data/survey/`:
219
+ - Extract key patterns to follow
220
+ - Note file locations for new code
221
+ - Identify known concerns to avoid
222
+
223
+ **Display summary:**
224
+ ```
225
+ 🗺️ SURVEY LOADED
226
+ ================
227
+ {for each doc loaded}
228
+ {emoji} {filename} — {brief description}
229
+ {/for}
230
+
231
+ {if no survey}
232
+ (No territory survey — run /ant:colonize for deeper context)
233
+ {/if}
234
+ ```
235
+
236
+ **Store for builder injection:**
237
+ - `survey_patterns` — patterns to follow
238
+ - `survey_locations` — where to place files
239
+ - `survey_concerns` — concerns to avoid
240
+
241
+ ### Step 4.1: Load QUEEN.md Wisdom
242
+
243
+ Call `queen-read` to extract eternal wisdom for worker priming:
244
+
245
+ ```bash
246
+ bash .aether/aether-utils.sh queen-read 2>/dev/null
247
+ ```
248
+
249
+ **Parse the JSON response:**
250
+ - If `.ok` is false or command fails: Set `queen_wisdom = null` and skip wisdom injection
251
+ - If successful: Extract wisdom sections from `.result.wisdom`
252
+
253
+ **Store wisdom variables:**
254
+ ```
255
+ queen_philosophies = .result.wisdom.philosophies (if .result.priming.has_philosophies)
256
+ queen_patterns = .result.wisdom.patterns (if .result.priming.has_patterns)
257
+ queen_redirects = .result.wisdom.redirects (if .result.priming.has_redirects)
258
+ queen_stack_wisdom = .result.wisdom.stack_wisdom (if .result.priming.has_stack_wisdom)
259
+ queen_decrees = .result.wisdom.decrees (if .result.priming.has_decrees)
260
+ ```
261
+
262
+ **Display summary (if any wisdom exists):**
263
+ ```
264
+ 📜 QUEEN WISDOM LOADED
265
+ =====================
266
+ {if queen_philosophies:} 📜 Philosophies: yes{/if}
267
+ {if queen_patterns:} 🧭 Patterns: yes{/if}
268
+ {if queen_redirects:} ⚠️ Redirects: yes{/if}
269
+ {if queen_stack_wisdom:} 🔧 Stack Wisdom: yes{/if}
270
+ {if queen_decrees:} 🏛️ Decrees: yes{/if}
271
+
272
+ {if none exist:} (no eternal wisdom recorded yet){/if}
273
+ ```
274
+
275
+ **Graceful handling:** If QUEEN.md doesn't exist or `queen-read` fails, continue without wisdom injection. Workers will receive standard prompts.
276
+
277
+ ### Step 4.2: Archaeologist Pre-Build Scan
193
278
 
194
279
  **Conditional step — only fires when the phase modifies existing files.**
195
280
 
@@ -214,46 +299,35 @@ CONSTRAINTS: (none)
214
299
 
215
300
  Display:
216
301
  ```
217
- 🏺 Spawning Archaeologist: {archaeologist_name}
218
- Scanning history of files to be modified...
302
+ 🏺🐜 Archaeologist {archaeologist_name} spawning
303
+ Scanning history of files to be modified...
219
304
  ```
220
305
 
221
- Spawn a Scout (using Task tool with `subagent_type="general"`) with this prompt:
306
+ Spawn a Scout (using Task tool with `subagent_type="aether-archaeologist"`) with this prompt:
307
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are an Archaeologist Ant - git historian that excavates why code exists."
222
308
 
223
309
  ```
224
- You are {Archaeologist-Name}, a 🏺 Archaeologist Ant (Scout) in the Aether Colony.
225
-
226
- --- YOUR MISSION ---
227
- Perform a pre-build archaeology scan on files that are about to be modified.
228
-
229
- --- FILES TO INVESTIGATE ---
230
- {list of existing files that will be modified by this phase's tasks}
231
-
232
- --- INSTRUCTIONS ---
233
- For each file:
234
- 1. Read the file to understand its current state
235
- 2. Run: git log --oneline -15 -- "{file_path}" to see recent history
236
- 3. Run: git log --all --grep="fix\|bug\|workaround\|hack\|revert" --oneline -- "{file_path}" to find incident history
237
- 4. Run: git blame "{file_path}" | head -40 to see authorship of key sections
238
- 5. Note any TODO/FIXME/HACK markers in the current code
239
-
240
- --- MODEL CONTEXT ---
241
- Assigned model: {model} (from caste: archaeologist)
242
- This ant is running as: {Ant-Name} (archaeologist caste)
243
-
244
- --- OUTPUT ---
245
- For each file, report:
246
- - WHY key code sections exist (from commit messages)
247
- - Known workarounds or hacks that must not be broken
248
- - Key architectural decisions visible in history
249
- - Areas of caution (high churn, reverted changes, emergency fixes)
250
- - Sections that are stable bedrock vs volatile sand
251
-
252
- Include in your header:
253
- Model: {model} | Caste: archaeologist | Ant: {Ant-Name}
254
-
255
- Keep the report concise and actionable — builders need quick context, not a thesis.
256
- Format as plain text with file headers. No JSON output needed.
310
+ You are {Archaeologist-Name}, a 🏺🐜 Archaeologist Ant.
311
+
312
+ Mission: Pre-build archaeology scan
313
+
314
+ Files: {list of existing files that will be modified}
315
+
316
+ Work:
317
+ 1. Read each file to understand current state
318
+ 2. Run: git log --oneline -15 -- "{file_path}" for history
319
+ 3. Run: git log --all --grep="fix\|bug\|workaround\|hack\|revert" --oneline -- "{file_path}" for incident history
320
+ 4. Run: git blame "{file_path}" | head -40 for authorship
321
+ 5. Note TODO/FIXME/HACK markers
322
+
323
+ Log activity: bash .aether/aether-utils.sh activity-log "READ" "{Ant-Name}" "description"
324
+
325
+ Report (plain text):
326
+ - WHY key code sections exist (from commits)
327
+ - Known workarounds/hacks to preserve
328
+ - Key architectural decisions
329
+ - Areas of caution (high churn, reverts, emergencies)
330
+ - Stable bedrock vs volatile sand sections
257
331
  ```
258
332
 
259
333
  **Wait for results** (blocking — use TaskOutput with `block: true`).
@@ -279,6 +353,8 @@ CONSTRAINTS: (none)
279
353
  The `archaeology_context` will be injected into builder prompts in Step 5.1 (see below).
280
354
  If this step was skipped (no existing files modified), the archaeology section is omitted from builder prompts.
281
355
 
356
+ ---
357
+
282
358
  ### Step 5: Initialize Swarm Display and Analyze Tasks
283
359
 
284
360
  **YOU (the Queen) will spawn workers directly. Do NOT delegate to a single Prime Worker.**
@@ -300,12 +376,12 @@ bash .aether/aether-utils.sh swarm-display-update "Queen" "prime" "excavating" "
300
376
 
301
377
  **Show real-time display header:**
302
378
  ```
303
- 🔨🐜 COLONY BUILD INITIATED 🐜🔨
379
+ 🔨 COLONY BUILD INITIATED
304
380
  ═══════════════════════════════════════════════════
305
381
  Phase {id}: {name}
306
382
  Build ID: {build_id}
307
383
 
308
- Launching swarm display... (visual tracking enabled)
384
+ Launching swarm display...
309
385
  ```
310
386
 
311
387
  Analyze the phase tasks:
@@ -318,10 +394,10 @@ Analyze the phase tasks:
318
394
  - **Wave 3+:** Continue until all tasks assigned
319
395
 
320
396
  2. **Assign castes:**
321
- - Implementation tasks → 🔨 Builder
322
- - Research/docs tasks → 🔍 Scout
323
- - Testing/validation → 👁️ Watcher (ALWAYS spawn at least one)
324
- - Resilience testing → 🎲 Chaos (ALWAYS spawn one after Watcher)
397
+ - Implementation tasks → 🔨🐜 Builder
398
+ - Research/docs tasks → 🔍🐜 Scout
399
+ - Testing/validation → 👁️🐜 Watcher (ALWAYS spawn at least one)
400
+ - Resilience testing → 🎲🐜 Chaos (ALWAYS spawn one after Watcher)
325
401
 
326
402
  3. **Generate ant names for each worker:**
327
403
  ```bash
@@ -330,154 +406,130 @@ bash .aether/aether-utils.sh generate-ant-name "watcher"
330
406
  bash .aether/aether-utils.sh generate-ant-name "chaos"
331
407
  ```
332
408
 
333
- Display spawn plan:
409
+ Display spawn plan with caste emojis:
334
410
  ```
335
- 🐜 SPAWN PLAN
336
- =============
337
- Wave 1 (parallel):
338
- 🔨{Builder-Name}: Task {id} - {description}
339
- 🔨{Builder-Name}: Task {id} - {description}
411
+ 🐜 SPAWN PLAN
340
412
 
341
- Wave 2 (after Wave 1):
342
- 🔨{Builder-Name}: Task {id} - {description}
413
+ Wave 1 — Parallel
414
+ 🔨🐜 {Builder-Name} Task {id} {description}
415
+ 🔨🐜 {Builder-Name} Task {id} {description}
343
416
 
344
- Verification:
345
- 👁️{Watcher-Name}: Verify all work independently
346
- 🎲{Chaos-Name}: Resilience testing (after Watcher)
417
+ Wave 2 — After Wave 1
418
+ 🔨🐜 {Builder-Name} Task {id} {description}
419
+
420
+ Verification
421
+ 👁️🐜 {Watcher-Name} Verify all work independently
422
+ 🎲🐜 {Chaos-Name} Resilience testing (after Watcher)
347
423
 
348
424
  Total: {N} Builders + 1 Watcher + 1 Chaos = {N+2} spawns
349
425
  ```
350
426
 
427
+ **Caste Emoji Legend:**
428
+ - 🔨🐜 Builder (cyan if color enabled)
429
+ - 👁️🐜 Watcher (green if color enabled)
430
+ - 🎲🐜 Chaos (red if color enabled)
431
+ - 🔍🐜 Scout (yellow if color enabled)
432
+ - 🏺🐜 Archaeologist (magenta if color enabled)
433
+ - 🥚 Queen/Prime
434
+
435
+ **Every spawn must show its caste emoji.**
436
+
351
437
  ### Step 5.1: Spawn Wave 1 Workers (Parallel)
352
438
 
353
439
  **CRITICAL: Spawn ALL Wave 1 workers in a SINGLE message using multiple Task tool calls.**
354
440
 
355
- For each Wave 1 task, use Task tool with `subagent_type="general"` and `run_in_background: true`:
441
+ **First, mark build start in context:**
442
+ ```bash
443
+ bash .aether/aether-utils.sh context-update build-start {phase_id} {wave_1_worker_count} {wave_1_task_count}
444
+ ```
445
+
446
+ For each Wave 1 task, use Task tool with `subagent_type="aether-builder"` (DO NOT use run_in_background - multiple Task calls in a single message run in parallel and block until complete):
356
447
 
357
448
  Log each spawn and update swarm display:
358
449
  ```bash
359
450
  bash .aether/aether-utils.sh spawn-log "Queen" "builder" "{ant_name}" "{task_description}"
360
451
  bash .aether/aether-utils.sh swarm-display-update "{ant_name}" "builder" "excavating" "{task_description}" "Queen" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "fungus_garden" 10
452
+ bash .aether/aether-utils.sh context-update worker-spawn "{ant_name}" "builder" "{task_description}"
361
453
  ```
362
454
 
363
- **Builder Worker Prompt Template:**
455
+ **Builder Worker Prompt (CLEAN OUTPUT):**
364
456
  ```
365
- You are {Ant-Name}, a 🔨 Builder Ant in the Aether Colony at depth {depth}.
457
+ You are {Ant-Name}, a 🔨🐜 Builder Ant.
366
458
 
367
- --- YOUR TASK ---
368
459
  Task {id}: {description}
369
460
 
370
- --- CONTEXT ---
371
461
  Goal: "{colony_goal}"
372
- Phase: {phase_name}
373
-
374
- --- CONSTRAINTS ---
375
- {constraints from Step 4}
376
-
377
- --- COLONY KNOWLEDGE ---
378
- {Include this section ONLY if memory.instincts or memory.phase_learnings exist in COLONY_STATE.json.}
379
-
380
- Top Instincts (proven patterns — follow these):
381
- {For each instinct in memory.instincts where confidence >= 0.5, sorted by confidence descending, max 5:}
382
- [{confidence}] {trigger} → {action}
383
- {If none qualify: omit this sub-section}
384
462
 
385
- Recent Learnings:
386
- {For each learning in memory.phase_learnings (last 3 phases only) where status == "validated":}
387
- - {claim}
388
- {If none qualify: omit this sub-section}
463
+ { archaeology_context if exists }
389
464
 
390
- Error Patterns to Avoid:
391
- {For each pattern in errors.flagged_patterns:}
392
- ⚠️ {description}
393
- {If none: omit this sub-section}
465
+ { queen_wisdom_section if any wisdom exists }
394
466
 
395
- {If archaeology_context exists (Step 4.5 produced findings):}
396
- --- ARCHAEOLOGY CONTEXT ---
397
- The following historical insights were discovered about files you will modify:
398
- {archaeology_context findings}
399
- {End if — omit this entire section if Step 4.5 was skipped}
400
-
401
- --- INSTRUCTIONS ---
467
+ Work:
402
468
  1. Read .aether/workers.md for Builder discipline
403
- 2. Implement the task completely
404
- 3. Write actual test files (not just claims)
405
- 4. Log your work: bash .aether/aether-utils.sh activity-log "CREATED" "{ant_name} (Builder)" "{file_path}"
406
- 5. Before modifying any file, check for grave markers:
407
- bash .aether/aether-utils.sh grave-check "{file_path}"
408
- If caution_level is "high": read the failure_summary, add extra test coverage for that area, mention the graveyard in your summary
409
- If caution_level is "low": note it and proceed carefully
410
- If caution_level is "none": proceed normally
411
-
412
- --- SPAWN CAPABILITY ---
413
- You are at depth {depth}. You MAY spawn sub-workers if you encounter genuine surprise (3x expected complexity).
414
-
415
- Spawn limits by depth:
416
- - Depth 1: max 4 spawns
417
- - Depth 2: max 2 spawns
418
- - Depth 3: NO spawns (complete inline)
419
-
420
- When to spawn:
421
- - Task is 3x larger than expected
422
- - Discovered sub-domain requiring different expertise
423
- - Found blocking dependency needing parallel investigation
424
-
425
- DO NOT spawn for work you can complete in < 10 tool calls.
426
-
427
- Before spawning:
428
- 1. Check: bash .aether/aether-utils.sh spawn-can-spawn {depth}
429
- 2. Generate name: bash .aether/aether-utils.sh generate-ant-name "{caste}"
430
- 3. Log spawn: bash .aether/aether-utils.sh spawn-log "{your_name}" "{caste}" "{child_name}" "{task}"
431
- 4. Update swarm display: bash .aether/aether-utils.sh swarm-display-update "{child_name}" "{caste}" "excavating" "{task}" "{your_name}" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "fungus_garden" 10
432
- 5. Use Task tool with subagent_type="general"
433
- 6. After completion:
434
- - Log completion: bash .aether/aether-utils.sh spawn-complete "{child_name}" "{status}" "{summary}"
435
- - Update swarm display: bash .aether/aether-utils.sh swarm-display-update "{child_name}" "{caste}" "completed" "{task}" "{your_name}" '{"read":5,"grep":3,"edit":2,"bash":1}' 100 "fungus_garden" 100
436
-
437
- Full spawn format: .aether/workers.md section "Spawning Sub-Workers"
438
-
439
- --- OUTPUT ---
440
- Return JSON:
441
- {
442
- "ant_name": "{your name}",
443
- "task_id": "{task_id}",
444
- "status": "completed" | "failed" | "blocked",
445
- "summary": "What you accomplished",
446
- "files_created": [],
447
- "files_modified": [],
448
- "tests_written": [],
449
- "blockers": [],
450
- "spawns": [],
451
- "model_context": {
452
- "assigned": "{model}",
453
- "caste": "builder",
454
- "source": "caste-default",
455
- "reported_at": "ISO-8601 timestamp"
456
- }
457
- }
469
+ 2. Implement task, write tests
470
+ 3. Log activity: bash .aether/aether-utils.sh activity-log "ACTION" "{Ant-Name}" "description"
471
+ 4. Update display: bash .aether/aether-utils.sh swarm-display-update "{Ant-Name}" "builder" "excavating" "current task" "Queen" '{"read":0,"grep":0,"edit":0,"bash":0}' {progress} "fungus_garden" 50
472
+
473
+ Spawn sub-workers ONLY if 3x complexity:
474
+ - Check: bash .aether/aether-utils.sh spawn-can-spawn {depth}
475
+ - Generate name: bash .aether/aether-utils.sh generate-ant-name "builder"
476
+ - Announce: "🐜 Spawning {child_name} for {reason}"
477
+ - Log: bash .aether/aether-utils.sh spawn-log "{Ant-Name}" "builder" "{child_name}" "{task}"
478
+
479
+ Return ONLY this JSON (no other text):
480
+ {"ant_name": "{Ant-Name}", "task_id": "{id}", "status": "completed|failed|blocked", "summary": "What you did", "files_created": [], "files_modified": [], "tests_written": [], "blockers": []}
458
481
  ```
459
482
 
460
- ### Step 5.2: Collect Wave 1 Results (BLOCKING)
483
+ **Queen Wisdom Section Template (injected only if wisdom exists):**
484
+ ```
485
+ --- QUEEN WISDOM (Eternal Guidance) ---
486
+ { if queen_philosophies: }
487
+ 📜 Philosophies:
488
+ {queen_philosophies}
489
+ { endif }
490
+ { if queen_patterns: }
491
+ 🧭 Patterns:
492
+ {queen_patterns}
493
+ { endif }
494
+ { if queen_redirects: }
495
+ ⚠️ Redirects (AVOID these):
496
+ {queen_redirects}
497
+ { endif }
498
+ { if queen_stack_wisdom: }
499
+ 🔧 Stack Wisdom:
500
+ {queen_stack_wisdom}
501
+ { endif }
502
+ { if queen_decrees: }
503
+ 🏛️ Decrees:
504
+ {queen_decrees}
505
+ { endif }
506
+ --- END QUEEN WISDOM ---
507
+ ```
461
508
 
462
- **CRITICAL: You MUST wait for ALL Wave 1 workers to complete before proceeding.**
509
+ ### Step 5.2: Process Wave 1 Results
463
510
 
464
- For each spawned worker, call TaskOutput with `block: true` to wait for completion:
465
- - Use the task_id from each Task tool response
466
- - Do NOT proceed to Step 5.3 until ALL workers have returned results
467
- - Parse each worker's JSON output to collect: status, files_created, files_modified, blockers
511
+ **Task calls return results directly (no TaskOutput needed).**
468
512
 
469
- Store all results for synthesis in Step 5.6.
513
+ **As each worker result arrives, immediately display:**
514
+ ```
515
+ ✅ 🔨🐜 {Builder-Name} completed Task {id}
516
+ 📖{read_count} 🔍{grep_count} ✏️{edit_count} ⚡{bash_count} {elapsed_time}
517
+ ```
470
518
 
471
- For each completed worker, log and update swarm display:
519
+ Log and update swarm display:
472
520
  ```bash
473
521
  bash .aether/aether-utils.sh spawn-complete "{ant_name}" "completed" "{summary}"
474
522
  bash .aether/aether-utils.sh swarm-display-update "{ant_name}" "builder" "completed" "{task_description}" "Queen" '{"read":5,"grep":3,"edit":2,"bash":1}' 100 "fungus_garden" 100
523
+ bash .aether/aether-utils.sh context-update worker-complete "{ant_name}" "completed"
475
524
  ```
476
525
 
477
- **Update swarm display with accumulated tool usage:**
478
- As workers complete, accumulate their actual tool usage (Read, Grep, Edit, Bash counts from their activity logs) and update the swarm display to show live progress.
526
+ **Parse each worker's JSON output to collect:** status, files_created, files_modified, blockers
479
527
 
480
- **Only proceed to Step 5.3 after ALL Wave 1 TaskOutput calls have returned.**
528
+ **Visual Mode: Render live display (if enabled):**
529
+ If `visual_mode` is true, render the swarm display after all workers complete:
530
+ ```bash
531
+ bash .aether/aether-utils.sh swarm-display-render "$build_id"
532
+ ```
481
533
 
482
534
  ### Step 5.3: Spawn Wave 2+ Workers (Sequential Waves)
483
535
 
@@ -487,129 +539,51 @@ Repeat Step 5.1-5.2 for each subsequent wave, waiting for previous wave to compl
487
539
 
488
540
  **MANDATORY: Always spawn a Watcher — testing must be independent.**
489
541
 
542
+ Spawn the Watcher using Task tool with `subagent_type="aether-watcher"` (DO NOT use run_in_background - task blocks until complete):
543
+
490
544
  ```bash
491
545
  bash .aether/aether-utils.sh spawn-log "Queen" "watcher" "{watcher_name}" "Independent verification"
492
546
  bash .aether/aether-utils.sh swarm-display-update "{watcher_name}" "watcher" "observing" "Verification in progress" "Queen" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "nursery" 50
493
547
  ```
494
548
 
495
- **Watcher Worker Prompt:**
549
+ **Watcher Worker Prompt (CLEAN OUTPUT):**
496
550
  ```
497
- You are {Watcher-Name}, a 👁️ Watcher Ant in the Aether Colony at depth {depth}.
498
-
499
- --- YOUR MISSION ---
500
- Independently verify all work done by Builders in Phase {id}.
501
-
502
- --- MODEL CONTEXT ---
503
- Optimal model for verification: {model} (from caste: watcher)
504
- Model characteristics: Efficient validation and testing model
505
- Verification focus: Quick, thorough checks with fast turnaround
506
-
507
- --- WHAT TO VERIFY ---
508
- Files created: {list from builder results}
509
- Files modified: {list from builder results}
551
+ You are {Watcher-Name}, a 👁️🐜 Watcher Ant.
510
552
 
511
- --- COMMAND RESOLUTION ---
512
- Resolve build, test, type-check, and lint commands using this priority chain (stop at first match per command):
513
- 1. **CLAUDE.md** — Check project CLAUDE.md (in your system context) for explicit commands
514
- 2. **CODEBASE.md** — Read `.planning/CODEBASE.md` `## Commands` section
515
- 3. **Fallback** — Use language-specific examples below (Execution Verification section)
553
+ Verify all work done by Builders in Phase {id}.
516
554
 
517
- Use resolved commands for all verification steps below.
555
+ Files to verify:
556
+ - Created: {list from builder results}
557
+ - Modified: {list from builder results}
518
558
 
519
- --- VERIFICATION CHECKLIST ---
520
- 1. Do the files exist? (Read each one)
521
- 2. Does the code compile/parse? (Run build command)
522
- 3. Do tests exist AND pass? (Run test command)
523
- 4. Are success criteria met? {list success_criteria}
524
-
525
- --- EXECUTION VERIFICATION (MANDATORY) ---
526
- Before assigning a quality score, you MUST attempt to execute the code:
527
-
528
- 1. Syntax check: Run the language's syntax checker
529
- - Python: `python3 -m py_compile {file}`
530
- - Swift: `swiftc -parse {file}`
531
- - TypeScript: `npx tsc --noEmit`
532
-
533
- 2. Import check: Verify main entry point can be imported
534
- - Python: `python3 -c "import {module}"`
535
- - Node: `node -e "require('{entry}')"`
536
-
537
- 3. Launch test: Attempt to start the application briefly
538
- - Run main entry point with timeout
539
- - If GUI, try headless mode if possible
540
- - If launches successfully = pass
541
- - If crashes = CRITICAL severity
542
-
543
- 4. Test suite: If tests exist, run them
544
- - Record pass/fail counts
545
-
546
- CRITICAL: If ANY execution check fails, quality_score CANNOT exceed 6/10.
547
-
548
- --- SPAWN CAPABILITY ---
549
- You are at depth {depth}. You MAY spawn sub-workers for:
550
- - Deep investigation of suspicious code patterns
551
- - Parallel verification of independent components
552
- - Debugging assistance for complex failures
553
-
554
- Spawn limits: Depth 1→4, Depth 2→2, Depth 3→0
555
-
556
- Before spawning:
557
- 1. Log spawn: bash .aether/aether-utils.sh spawn-log "{your_name}" "{caste}" "{child_name}" "{task}"
558
- 2. Update swarm display: bash .aether/aether-utils.sh swarm-display-update "{child_name}" "{caste}" "observing" "{task}" "{your_name}" '{"read":0,"grep":0,"edit":0,"bash":0}' 0 "nursery" 50
559
- 3. After completion: bash .aether/aether-utils.sh swarm-display-update "{child_name}" "{caste}" "completed" "{task}" "{your_name}" '{"read":3,"grep":2,"edit":0,"bash":0}' 100 "nursery" 100
559
+ Verification:
560
+ 1. Check files exist (Read each)
561
+ 2. Run build/type-check
562
+ 3. Run tests if they exist
563
+ 4. Check success criteria: {list}
560
564
 
561
- --- CRITICAL ---
562
- - You did NOT build this code verify it objectively
563
- - "Build passing" is NOT enough check runtime execution
564
- - Be skeptical — Builders may have cut corners
565
+ Spawn sub-workers if needed:
566
+ - Log: bash .aether/aether-utils.sh spawn-log "{Watcher-Name}" "watcher" "{child}" "{task}"
567
+ - Announce: "🐜 Spawning {child} to investigate {issue}"
565
568
 
566
- --- OUTPUT ---
567
- Return JSON:
568
- {
569
- "ant_name": "{your name}",
570
- "verification_passed": true | false,
571
- "files_verified": [],
572
- "execution_verification": {
573
- "syntax_check": {"command": "...", "passed": true|false},
574
- "import_check": {"command": "...", "passed": true|false},
575
- "launch_test": {"command": "...", "passed": true|false, "error": null},
576
- "test_suite": {"command": "...", "passed": N, "failed": N}
577
- },
578
- "build_result": {"command": "...", "passed": true|false},
579
- "test_result": {"command": "...", "passed": N, "failed": N},
580
- "success_criteria_results": [
581
- {"criterion": "...", "passed": true|false, "evidence": "..."}
582
- ],
583
- "issues_found": [],
584
- "quality_score": N,
585
- "recommendation": "proceed" | "fix_required",
586
- "spawns": [],
587
- "model_context": {
588
- "assigned": "{model}",
589
- "caste": "watcher",
590
- "source": "caste-default",
591
- "reported_at": "ISO-8601 timestamp"
592
- }
593
- }
569
+ Return ONLY this JSON:
570
+ {"ant_name": "{Watcher-Name}", "verification_passed": true|false, "files_verified": [], "issues_found": [], "quality_score": N, "recommendation": "proceed|fix_required"}
594
571
  ```
595
572
 
596
- ### Step 5.4.1: Collect Watcher Results (BLOCKING)
573
+ ### Step 5.5: Process Watcher Results
597
574
 
598
- **CRITICAL: You MUST wait for the Watcher to complete before proceeding.**
575
+ **Task call returns results directly (no TaskOutput needed).**
599
576
 
600
- Call TaskOutput with `block: true` using the Watcher's task_id:
601
- - Wait for the Watcher's JSON response
602
- - Parse: verification_passed, issues_found, quality_score, recommendation
603
- - Store results for synthesis in Step 5.6
577
+ **Parse the Watcher's JSON response:** verification_passed, issues_found, quality_score, recommendation
578
+
579
+ **Store results for synthesis in Step 5.7**
604
580
 
605
581
  **Update swarm display when Watcher completes:**
606
582
  ```bash
607
583
  bash .aether/aether-utils.sh swarm-display-update "{watcher_name}" "watcher" "completed" "Verification complete" "Queen" '{"read":3,"grep":2,"edit":0,"bash":1}' 100 "nursery" 100
608
584
  ```
609
585
 
610
- **Only proceed to Step 5.4.2 after Watcher TaskOutput has returned.**
611
-
612
- ### Step 5.4.2: Spawn Chaos Ant for Resilience Testing
586
+ ### Step 5.6: Spawn Chaos Ant for Resilience Testing
613
587
 
614
588
  **After the Watcher completes, spawn a Chaos Ant to probe the phase work for edge cases and boundary conditions.**
615
589
 
@@ -626,69 +600,36 @@ bash .aether/aether-utils.sh flag-list --phase {phase_number}
626
600
  ```
627
601
  Parse the result and extract unresolved flag titles into a list: `{existing_flag_titles}` (comma-separated titles from `.result.flags[].title`). If no flags exist, set `{existing_flag_titles}` to "None".
628
602
 
629
- Spawn the Chaos Ant using Task tool with `subagent_type="general"`:
603
+ Spawn the Chaos Ant using Task tool with `subagent_type="aether-chaos"` (DO NOT use run_in_background - task blocks until complete):
604
+ # FALLBACK: If "Agent type not found", use general-purpose and inject role: "You are a Chaos Ant - resilience tester that probes edge cases and boundary conditions."
630
605
 
631
- **Chaos Ant Prompt:**
606
+ **Chaos Ant Prompt (CLEAN OUTPUT):**
632
607
  ```
633
- You are {Chaos-Name}, a 🎲 Chaos Ant (Resilience Tester) in the Aether Colony at depth {depth}.
608
+ You are {Chaos-Name}, a 🎲🐜 Chaos Ant.
634
609
 
635
- --- YOUR MISSION ---
636
- Probe the work done by Builders in Phase {id} for edge cases, boundary conditions, and unexpected inputs.
610
+ Test Phase {id} work for edge cases and boundary conditions.
637
611
 
638
- --- MODEL CONTEXT ---
639
- Optimal model for chaos testing: {model} (from caste: chaos)
640
- Model characteristics: Efficient edge case exploration
641
- Testing focus: Rapid probing of boundaries and edge cases
612
+ Files to test:
613
+ - {list from builder results}
642
614
 
643
- --- SCOPE ---
644
- Files created: {list from builder results}
645
- Files modified: {list from builder results}
615
+ Skip these known issues: {existing_flag_titles}
646
616
 
647
- --- EXISTING FLAGS (already known — do NOT re-report) ---
648
- {existing_flag_titles}
649
- These issues have already been flagged. Do NOT report findings that duplicate or overlap with the above titles. Focus your 5 scenarios on NEW, undiscovered issues only.
617
+ Rules:
618
+ - Max 5 scenarios
619
+ - Read-only (don't modify code)
620
+ - Focus: edge cases, boundaries, error handling
650
621
 
651
- --- RULES ---
652
- 1. Limit to 5 edge case scenarios maximum
653
- 2. You are a TESTER, not an attacker — use investigating/probing language
654
- 3. Do NOT modify any code — read-only analysis
655
- 4. Focus on: edge cases, boundary conditions, error handling gaps, state corruption risks, unexpected inputs
656
- 5. Do NOT re-report issues listed in EXISTING FLAGS above — skip any finding that substantially overlaps with a known flag
657
-
658
- --- OUTPUT ---
659
- Return JSON:
660
- {
661
- "ant_name": "{your name}",
662
- "scenarios_tested": 5,
663
- "findings": [
664
- {
665
- "id": 1,
666
- "category": "edge_case|boundary|error_handling|state|unexpected_input",
667
- "severity": "critical|high|medium|low|info",
668
- "title": "...",
669
- "description": "...",
670
- "reproduction_steps": ["..."],
671
- "affected_files": ["..."],
672
- "recommendation": "..."
673
- }
674
- ],
675
- "overall_resilience": "strong|moderate|weak",
676
- "summary": "...",
677
- "model_context": {
678
- "assigned": "{model}",
679
- "caste": "chaos",
680
- "source": "caste-default",
681
- "reported_at": "ISO-8601 timestamp"
682
- }
683
- }
622
+ Return ONLY this JSON:
623
+ {"ant_name": "{Chaos-Name}", "scenarios_tested": 5, "findings": [{"id": 1, "category": "edge_case|boundary|error_handling", "severity": "critical|high|medium|low", "title": "...", "description": "..."}], "overall_resilience": "strong|moderate|weak", "summary": "..."}
684
624
  ```
685
625
 
686
- **Collect Chaos Ant results (BLOCKING):**
626
+ ### Step 5.7: Process Chaos Ant Results
687
627
 
688
- Call TaskOutput with `block: true` using the Chaos Ant's task_id:
689
- - Wait for the Chaos Ant's JSON response
690
- - Parse: findings, overall_resilience, summary
691
- - Store results for synthesis in Step 5.6
628
+ **Task call returns results directly (no TaskOutput needed).**
629
+
630
+ **Parse the Chaos Ant's JSON response:** findings, overall_resilience, summary
631
+
632
+ **Store results for synthesis in Step 5.9**
692
633
 
693
634
  **Flag critical/high findings:**
694
635
 
@@ -709,9 +650,7 @@ bash .aether/aether-utils.sh spawn-complete "{chaos_name}" "completed" "{summary
709
650
  bash .aether/aether-utils.sh swarm-display-update "{chaos_name}" "chaos" "completed" "Resilience testing done" "Queen" '{"read":2,"grep":1,"edit":0,"bash":0}' 100 "refuse_pile" 100
710
651
  ```
711
652
 
712
- **Only proceed to Step 5.5 after Chaos Ant TaskOutput has returned.**
713
-
714
- ### Step 5.5: Create Flags for Verification Failures
653
+ ### Step 5.8: Create Flags for Verification Failures
715
654
 
716
655
  If the Watcher reported `verification_passed: false` or `recommendation: "fix_required"`:
717
656
 
@@ -726,11 +665,11 @@ Log the flag creation:
726
665
  bash .aether/aether-utils.sh activity-log "FLAG" "Watcher" "Created blocker: {issue_title}"
727
666
  ```
728
667
 
729
- This ensures verification failures are persisted as blockers that survive context resets. Chaos Ant findings are flagged in Step 5.4.2.
668
+ This ensures verification failures are persisted as blockers that survive context resets. Chaos Ant findings are flagged in Step 5.7.
730
669
 
731
- ### Step 5.6: Synthesize Results
670
+ ### Step 5.9: Synthesize Results
732
671
 
733
- **This step runs ONLY after ALL TaskOutput calls have returned (Steps 5.2, 5.3, 5.4.1, 5.4.2).**
672
+ **This step runs after all worker tasks have completed (Builders, Watcher, Chaos).**
734
673
 
735
674
  Collect all worker outputs and create phase summary:
736
675
 
@@ -774,6 +713,39 @@ bash .aether/aether-utils.sh grave-add "{file}" "{ant_name}" "{task_id}" {phase}
774
713
  bash .aether/aether-utils.sh activity-log "GRAVE" "Queen" "Grave marker placed at {file} — {ant_name} failed: {summary}"
775
714
  ```
776
715
 
716
+ **Error Handoff Update:**
717
+ If workers failed, update handoff with error context for recovery:
718
+ ```bash
719
+ cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
720
+ # Colony Session — Build Errors
721
+
722
+ ## ⚠️ Build Status: ISSUES DETECTED
723
+ **Phase:** {phase_number} — {phase_name}
724
+ **Status:** Build completed with failures
725
+ **Updated:** $(date -u +%Y-%m-%dT%H:%M:%SZ)
726
+
727
+ ## Failed Workers
728
+ {for each failed worker:}
729
+ - {ant_name}: {failure_summary}
730
+ {end for}
731
+
732
+ ## Grave Markers Placed
733
+ {for each grave:}
734
+ - {file}: {caution_level} caution
735
+ {end for}
736
+
737
+ ## Recovery Options
738
+ 1. Review failures: Check `.aether/data/activity.log`
739
+ 2. Fix and retry: `/ant:build {phase_number}`
740
+ 3. Swarm fix: `/ant:swarm` for auto-repair
741
+ 4. Manual fix: Address issues, then `/ant:continue`
742
+
743
+ ## Session Note
744
+ Build completed but workers failed. Grave markers placed.
745
+ Review failures before advancing.
746
+ HANDOFF_EOF
747
+ ```
748
+
777
749
  Only fires when workers fail. Zero impact on successful builds.
778
750
 
779
751
  --- SPAWN TRACKING ---
@@ -868,6 +840,89 @@ Use AskUserQuestion to get approval. Record in events:
868
840
  - If approved: `"<timestamp>|visual_approved|build|Phase {id} UI approved"`
869
841
  - If rejected: `"<timestamp>|visual_rejected|build|Phase {id} UI rejected: {reason}"`
870
842
 
843
+ ### Step 6.5: Update Handoff Document
844
+
845
+ After synthesis is complete, update the handoff document with current state for session recovery:
846
+
847
+ ```bash
848
+ # Update handoff with build results
849
+ jq -n \
850
+ --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
851
+ --arg goal "$(jq -r '.goal' .aether/data/COLONY_STATE.json)" \
852
+ --arg phase "$(jq -r '.current_phase' .aether/data/COLONY_STATE.json)" \
853
+ --arg phase_name "{phase_name}" \
854
+ --arg status "{synthesis.status}" \
855
+ --arg summary "{synthesis.summary}" \
856
+ --argjson tasks_completed '{synthesis.tasks_completed | length}' \
857
+ --argjson tasks_failed '{synthesis.tasks_failed | length}' \
858
+ --arg next_action "{if synthesis.status == "completed" then "/ant:continue" else "/ant:flags" end}" \
859
+ '{
860
+ "last_updated": $timestamp,
861
+ "goal": $goal,
862
+ "current_phase": $phase,
863
+ "phase_name": $phase_name,
864
+ "build_status": $status,
865
+ "summary": $summary,
866
+ "tasks_completed": $tasks_completed,
867
+ "tasks_failed": $tasks_failed,
868
+ "next_recommended_action": $next_action,
869
+ "can_resume": true,
870
+ "note": "Phase build completed. Run /ant:continue to advance if verification passed."
871
+ }' > .aether/data/last-build-result.json
872
+
873
+ # Write handoff markdown
874
+ cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
875
+ # Colony Session — Build Complete
876
+
877
+ ## Quick Resume
878
+ Run `/ant:continue` to advance phase, or `/ant:resume-colony` to restore full context.
879
+
880
+ ## State at Build Completion
881
+ - Goal: "$(jq -r '.goal' .aether/data/COLONY_STATE.json)"
882
+ - Phase: {phase_number} — {phase_name}
883
+ - Build Status: {synthesis.status}
884
+ - Updated: $(date -u +%Y-%m-%dT%H:%M:%SZ)
885
+
886
+ ## Build Summary
887
+ {summary}
888
+
889
+ ## Tasks
890
+ - Completed: {synthesis.tasks_completed | length}
891
+ - Failed: {synthesis.tasks_failed | length}
892
+
893
+ ## Files Changed
894
+ - Created: {synthesis.files_created | length} files
895
+ - Modified: {synthesis.files_modified | length} files
896
+
897
+ ## Next Steps
898
+ - If verification passed: `/ant:continue` to advance to next phase
899
+ - If issues found: `/ant:flags` to review blockers
900
+ - To pause: `/ant:pause-colony`
901
+
902
+ ## Session Note
903
+ $(if synthesis.status == "completed" then "Build succeeded — ready to advance." else "Build completed with issues — review before continuing." end)
904
+ HANDOFF_EOF
905
+ ```
906
+
907
+ This ensures the handoff always reflects the latest build state, even if the session crashes before explicit pause.
908
+
909
+ ### Step 6.5: Update Context Document
910
+
911
+ Log this build activity to `.aether/CONTEXT.md`:
912
+
913
+ ```bash
914
+ bash .aether/aether-utils.sh context-update activity "build {phase_id}" "{synthesis.status}" "{files_created_count + files_modified_count}"
915
+ ```
916
+
917
+ Mark build as complete in context:
918
+ ```bash
919
+ bash .aether/aether-utils.sh context-update build-complete "{synthesis.status}" "{synthesis.status == 'completed' ? 'success' : 'failed'}"
920
+ ```
921
+
922
+ Also update safe-to-clear status:
923
+ - If build completed successfully: `context-update safe-to-clear "YES" "Build complete, ready to continue"`
924
+ - If build failed: `context-update safe-to-clear "NO" "Build failed — run /ant:swarm or /ant:flags"`
925
+
871
926
  ### Step 7: Display Results
872
927
 
873
928
  **This step runs ONLY after synthesis is complete. All values come from actual worker results.**
@@ -882,7 +937,7 @@ bash .aether/aether-utils.sh swarm-display-render "$build_id"
882
937
  ```
883
938
 
884
939
  The swarm display will show:
885
- - 🐜 All workers with their caste emojis (🔨 Builder, 👁️ Watcher, 🎲 Chaos)
940
+ - 🐜 All workers with their caste emojis (🔨🐜 Builder, 👁️🐜 Watcher, 🎲🐜 Chaos)
886
941
  - 📖 Tool usage stats (Read, Grep, Edit, Bash counts)
887
942
  - 🏠 Chamber activity map (Fungus Garden, Nursery, Refuse Pile)
888
943
  - ✅ Progress bars at 100% for completed work
@@ -985,3 +1040,11 @@ The swarm display will show:
985
1040
  - Mark tasks as completed
986
1041
  - Extract learnings
987
1042
  - Advance to next phase
1043
+
1044
+ ### Step 8: Update Session
1045
+
1046
+ Update the session tracking file to enable `/ant:resume` after context clear:
1047
+
1048
+ ```bash
1049
+ bash .aether/aether-utils.sh session-update "/ant:build {phase_id}" "/ant:continue" "Phase {phase_id} build completed: {synthesis.status}"
1050
+ ```