aether-colony 3.1.17 → 5.0.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 (183) hide show
  1. package/{runtime → .aether}/CONTEXT.md +1 -1
  2. package/{runtime → .aether}/aether-utils.sh +1772 -98
  3. package/.aether/docs/QUEEN-SYSTEM.md +211 -0
  4. package/.aether/docs/QUEEN.md +84 -0
  5. package/.aether/docs/README.md +68 -0
  6. package/.aether/docs/caste-system.md +48 -0
  7. package/{runtime → .aether/docs/disciplines}/DISCIPLINES.md +8 -8
  8. package/.aether/docs/error-codes.md +268 -0
  9. package/{runtime → .aether}/docs/known-issues.md +42 -26
  10. package/.aether/docs/queen-commands.md +97 -0
  11. package/.aether/exchange/colony-registry.xml +11 -0
  12. package/{runtime → .aether}/exchange/pheromone-xml.sh +2 -1
  13. package/.aether/exchange/pheromones.xml +87 -0
  14. package/.aether/exchange/queen-wisdom.xml +14 -0
  15. package/{runtime → .aether}/exchange/registry-xml.sh +7 -3
  16. package/{runtime → .aether}/exchange/wisdom-xml.sh +11 -4
  17. package/.aether/rules/aether-colony.md +134 -0
  18. package/.aether/schemas/example-prompt-builder.xml +234 -0
  19. package/.aether/templates/colony-state-reset.jq.template +22 -0
  20. package/.aether/templates/colony-state.template.json +35 -0
  21. package/.aether/templates/constraints.template.json +9 -0
  22. package/.aether/templates/crowned-anthill.template.md +36 -0
  23. package/.aether/templates/handoff-build-error.template.md +30 -0
  24. package/.aether/templates/handoff-build-success.template.md +39 -0
  25. package/.aether/templates/handoff.template.md +40 -0
  26. package/{runtime → .aether}/utils/atomic-write.sh +5 -5
  27. package/{runtime → .aether}/utils/chamber-compare.sh +23 -10
  28. package/{runtime → .aether}/utils/chamber-utils.sh +32 -20
  29. package/{runtime → .aether}/utils/error-handler.sh +13 -1
  30. package/{runtime → .aether}/utils/file-lock.sh +49 -13
  31. package/.aether/utils/semantic-cli.sh +413 -0
  32. package/{runtime → .aether}/utils/xml-compose.sh +7 -1
  33. package/.aether/utils/xml-convert.sh +273 -0
  34. package/.aether/utils/xml-query.sh +201 -0
  35. package/.aether/utils/xml-utils.sh +110 -0
  36. package/{runtime → .aether}/workers.md +14 -17
  37. package/.claude/agents/ant/aether-ambassador.md +264 -0
  38. package/.claude/agents/ant/aether-archaeologist.md +322 -0
  39. package/.claude/agents/ant/aether-auditor.md +266 -0
  40. package/.claude/agents/ant/aether-builder.md +187 -0
  41. package/.claude/agents/ant/aether-chaos.md +268 -0
  42. package/.claude/agents/ant/aether-chronicler.md +304 -0
  43. package/.claude/agents/ant/aether-gatekeeper.md +325 -0
  44. package/.claude/agents/ant/aether-includer.md +373 -0
  45. package/.claude/agents/ant/aether-keeper.md +271 -0
  46. package/.claude/agents/ant/aether-measurer.md +317 -0
  47. package/.claude/agents/ant/aether-probe.md +210 -0
  48. package/.claude/agents/ant/aether-queen.md +325 -0
  49. package/.claude/agents/ant/aether-route-setter.md +173 -0
  50. package/.claude/agents/ant/aether-sage.md +353 -0
  51. package/.claude/agents/ant/aether-scout.md +142 -0
  52. package/.claude/agents/ant/aether-surveyor-disciplines.md +416 -0
  53. package/.claude/agents/ant/aether-surveyor-nest.md +354 -0
  54. package/.claude/agents/ant/aether-surveyor-pathogens.md +288 -0
  55. package/.claude/agents/ant/aether-surveyor-provisions.md +359 -0
  56. package/.claude/agents/ant/aether-tracker.md +265 -0
  57. package/.claude/agents/ant/aether-watcher.md +244 -0
  58. package/.claude/agents/ant/aether-weaver.md +247 -0
  59. package/.claude/commands/ant/archaeology.md +16 -7
  60. package/.claude/commands/ant/build.md +415 -284
  61. package/.claude/commands/ant/chaos.md +19 -10
  62. package/.claude/commands/ant/colonize.md +58 -24
  63. package/.claude/commands/ant/continue.md +155 -145
  64. package/.claude/commands/ant/council.md +15 -5
  65. package/.claude/commands/ant/dream.md +16 -7
  66. package/.claude/commands/ant/entomb.md +274 -157
  67. package/.claude/commands/ant/feedback.md +33 -29
  68. package/.claude/commands/ant/flag.md +18 -10
  69. package/.claude/commands/ant/flags.md +14 -6
  70. package/.claude/commands/ant/focus.md +29 -21
  71. package/.claude/commands/ant/help.md +11 -1
  72. package/.claude/commands/ant/history.md +10 -0
  73. package/.claude/commands/ant/init.md +91 -65
  74. package/.claude/commands/ant/interpret.md +15 -4
  75. package/.claude/commands/ant/lay-eggs.md +55 -7
  76. package/.claude/commands/ant/maturity.md +11 -1
  77. package/.claude/commands/ant/migrate-state.md +14 -2
  78. package/.claude/commands/ant/oracle.md +23 -15
  79. package/.claude/commands/ant/organize.md +29 -20
  80. package/.claude/commands/ant/pause-colony.md +17 -7
  81. package/.claude/commands/ant/phase.md +17 -8
  82. package/.claude/commands/ant/plan.md +20 -9
  83. package/.claude/commands/ant/redirect.md +29 -32
  84. package/.claude/commands/ant/resume-colony.md +19 -9
  85. package/.claude/commands/ant/resume.md +272 -96
  86. package/.claude/commands/ant/seal.md +201 -191
  87. package/.claude/commands/ant/status.md +71 -32
  88. package/.claude/commands/ant/swarm.md +26 -44
  89. package/.claude/commands/ant/tunnels.md +279 -105
  90. package/.claude/commands/ant/update.md +81 -20
  91. package/.claude/commands/ant/verify-castes.md +14 -4
  92. package/.claude/commands/ant/watch.md +13 -12
  93. package/.opencode/agents/aether-ambassador.md +63 -20
  94. package/.opencode/agents/aether-archaeologist.md +29 -12
  95. package/.opencode/agents/aether-auditor.md +51 -18
  96. package/.opencode/agents/aether-builder.md +69 -19
  97. package/.opencode/agents/aether-chaos.md +29 -12
  98. package/.opencode/agents/aether-chronicler.md +60 -18
  99. package/.opencode/agents/aether-gatekeeper.md +27 -18
  100. package/.opencode/agents/aether-includer.md +27 -18
  101. package/.opencode/agents/aether-keeper.md +89 -18
  102. package/.opencode/agents/aether-measurer.md +27 -18
  103. package/.opencode/agents/aether-probe.md +60 -18
  104. package/.opencode/agents/aether-queen.md +172 -24
  105. package/.opencode/agents/aether-route-setter.md +57 -12
  106. package/.opencode/agents/aether-sage.md +26 -18
  107. package/.opencode/agents/aether-scout.md +27 -19
  108. package/.opencode/agents/aether-surveyor-disciplines.md +53 -1
  109. package/.opencode/agents/aether-surveyor-nest.md +53 -1
  110. package/.opencode/agents/aether-surveyor-pathogens.md +51 -1
  111. package/.opencode/agents/aether-surveyor-provisions.md +53 -1
  112. package/.opencode/agents/aether-tracker.md +64 -18
  113. package/.opencode/agents/aether-watcher.md +66 -19
  114. package/.opencode/agents/aether-weaver.md +61 -18
  115. package/.opencode/commands/ant/build.md +406 -192
  116. package/.opencode/commands/ant/continue.md +66 -76
  117. package/.opencode/commands/ant/entomb.md +106 -45
  118. package/.opencode/commands/ant/init.md +46 -48
  119. package/.opencode/commands/ant/organize.md +5 -5
  120. package/.opencode/commands/ant/resume.md +334 -0
  121. package/.opencode/commands/ant/seal.md +33 -24
  122. package/.opencode/commands/ant/status.md +11 -0
  123. package/.opencode/commands/ant/tunnels.md +149 -0
  124. package/.opencode/commands/ant/update.md +59 -16
  125. package/CHANGELOG.md +79 -0
  126. package/README.md +135 -353
  127. package/bin/cli.js +243 -122
  128. package/bin/generate-commands.sh +2 -2
  129. package/bin/lib/init.js +13 -3
  130. package/bin/lib/update-transaction.js +119 -117
  131. package/bin/sync-to-runtime.sh +5 -137
  132. package/bin/validate-package.sh +84 -0
  133. package/package.json +9 -6
  134. package/.opencode/agents/aether-architect.md +0 -66
  135. package/.opencode/agents/aether-guardian.md +0 -107
  136. package/.opencode/agents/workers.md +0 -1034
  137. package/runtime/QUEEN_ANT_ARCHITECTURE.md +0 -402
  138. package/runtime/data/signatures.json +0 -41
  139. package/runtime/docs/AETHER-2.0-IMPLEMENTATION-PLAN.md +0 -1343
  140. package/runtime/docs/AETHER-PHEROMONE-SYSTEM-MASTER-SPEC.md +0 -2642
  141. package/runtime/docs/PHEROMONE-INJECTION.md +0 -240
  142. package/runtime/docs/PHEROMONE-INTEGRATION.md +0 -192
  143. package/runtime/docs/PHEROMONE-SYSTEM-DESIGN.md +0 -426
  144. package/runtime/docs/README.md +0 -94
  145. package/runtime/docs/VISUAL-OUTPUT-SPEC.md +0 -219
  146. package/runtime/docs/biological-reference.md +0 -272
  147. package/runtime/docs/codebase-review.md +0 -399
  148. package/runtime/docs/command-sync.md +0 -164
  149. package/runtime/docs/constraints.md +0 -116
  150. package/runtime/docs/implementation-learnings.md +0 -89
  151. package/runtime/docs/namespace.md +0 -148
  152. package/runtime/docs/pathogen-schema-example.json +0 -36
  153. package/runtime/docs/pathogen-schema.md +0 -111
  154. package/runtime/docs/planning-discipline.md +0 -159
  155. package/runtime/docs/progressive-disclosure.md +0 -184
  156. package/runtime/lib/queen-utils.sh +0 -729
  157. package/runtime/planning.md +0 -159
  158. package/runtime/recover.sh +0 -136
  159. package/runtime/utils/xml-utils.sh +0 -2196
  160. package/runtime/workers-new-castes.md +0 -516
  161. /package/{runtime → .aether/docs/disciplines}/coding-standards.md +0 -0
  162. /package/{runtime → .aether/docs/disciplines}/debugging.md +0 -0
  163. /package/{runtime → .aether/docs/disciplines}/learning.md +0 -0
  164. /package/{runtime → .aether/docs/disciplines}/tdd.md +0 -0
  165. /package/{runtime → .aether/docs/disciplines}/verification-loop.md +0 -0
  166. /package/{runtime → .aether/docs/disciplines}/verification.md +0 -0
  167. /package/{runtime → .aether}/docs/pheromones.md +0 -0
  168. /package/{runtime → .aether}/model-profiles.yaml +0 -0
  169. /package/{runtime → .aether}/schemas/aether-types.xsd +0 -0
  170. /package/{runtime → .aether}/schemas/colony-registry.xsd +0 -0
  171. /package/{runtime → .aether}/schemas/pheromone.xsd +0 -0
  172. /package/{runtime → .aether}/schemas/prompt.xsd +0 -0
  173. /package/{runtime → .aether}/schemas/queen-wisdom.xsd +0 -0
  174. /package/{runtime → .aether}/schemas/worker-priming.xsd +0 -0
  175. /package/{runtime → .aether}/templates/QUEEN.md.template +0 -0
  176. /package/{runtime → .aether}/utils/colorize-log.sh +0 -0
  177. /package/{runtime → .aether}/utils/queen-to-md.xsl +0 -0
  178. /package/{runtime → .aether}/utils/spawn-tree.sh +0 -0
  179. /package/{runtime → .aether}/utils/spawn-with-model.sh +0 -0
  180. /package/{runtime → .aether}/utils/state-loader.sh +0 -0
  181. /package/{runtime → .aether}/utils/swarm-display.sh +0 -0
  182. /package/{runtime → .aether}/utils/watch-spawn-tree.sh +0 -0
  183. /package/{runtime → .aether}/utils/xml-core.sh +0 -0
@@ -0,0 +1,334 @@
1
+ ---
2
+ name: ant:resume
3
+ description: "Resume Previous Session"
4
+ ---
5
+
6
+ # /ant:resume — Resume Previous Session
7
+
8
+ Resume work after `/clear` or in a new session. Reads colony state, detects codebase drift, and gives you a clear "do this next" recommendation.
9
+
10
+ ## Usage
11
+
12
+ ```bash
13
+ /ant:resume
14
+ ```
15
+
16
+ ---
17
+
18
+ ## Implementation
19
+
20
+ Execute the following steps in order when the user runs `/ant:resume`.
21
+
22
+ ---
23
+
24
+ ### Step 1: Read Session State
25
+
26
+ Run using the Bash tool with description "Restoring colony session...":
27
+ ```bash
28
+ bash .aether/aether-utils.sh session-read
29
+ ```
30
+
31
+ Parse the JSON result.
32
+
33
+ - If `exists` is `false`: display the following and **stop**:
34
+
35
+ ```
36
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
37
+ RESUME SESSION
38
+
39
+ No previous session found.
40
+
41
+ Start fresh: /ant:init "your goal"
42
+ Or check: /ant:status
43
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
44
+ ```
45
+
46
+ - If `exists` is `true`: extract from the session data:
47
+ - `colony_goal`
48
+ - `current_phase`
49
+ - `last_command`
50
+ - `suggested_next`
51
+ - `baseline_commit`
52
+ - `session_id`
53
+
54
+ ---
55
+
56
+ ### Step 2: Read COLONY_STATE.json (Authoritative Source)
57
+
58
+ Use the Read tool to read `.aether/data/COLONY_STATE.json`.
59
+
60
+ COLONY_STATE.json is the authoritative source for goal and state (session.json may be stale). Extract:
61
+ - `goal` (use this as authoritative, overriding session.json colony_goal)
62
+ - `state` (READY, PLANNING, EXECUTING, PAUSED)
63
+ - `current_phase`
64
+ - `plan.phases` (array with id, name, status for each phase)
65
+ - `plan.generated_at`
66
+ - `memory.decisions` (flat list — do NOT distinguish user vs Claude origin)
67
+ - `events` (last 5 for recent activity context)
68
+
69
+ If the file is missing or the JSON cannot be parsed, **stop immediately** and display:
70
+
71
+ ```
72
+ State file missing or corrupted.
73
+
74
+ Options:
75
+ 1. Start fresh with /ant:init "goal"
76
+ 2. Try to recover (I'll look for backup files)
77
+
78
+ What would you like to do?
79
+ ```
80
+
81
+ Do NOT proceed with stale or fabricated data.
82
+
83
+ ---
84
+
85
+ ### Step 3: Read Pheromone Signals
86
+
87
+ Use the Read tool to read `.aether/data/constraints.json`.
88
+
89
+ Extract the following top-level keys:
90
+ - `focus` array — active focus signals (if key missing, treat as empty array)
91
+ - `constraints` array — active redirect/constraint signals (if key missing, treat as empty array)
92
+
93
+ If the file is missing: skip silently (no pheromones active).
94
+
95
+ Pheromones persist until explicitly cleared — no decay.
96
+
97
+ ---
98
+
99
+ ### Step 4: Read CONTEXT.md
100
+
101
+ Use the Read tool to read `.aether/CONTEXT.md` if it exists.
102
+
103
+ If missing: fall back to COLONY_STATE.json for narrative context. Note: "Context document not found — reconstructing from state."
104
+
105
+ ---
106
+
107
+ ### Step 5: Drift Detection
108
+
109
+ Extract `baseline_commit` from the session.json data read in Step 1.
110
+
111
+ ```bash
112
+ current_commit=$(git rev-parse HEAD 2>/dev/null || echo "")
113
+ ```
114
+
115
+ If `baseline_commit` is non-empty and differs from `current_commit`:
116
+
117
+ ```bash
118
+ commit_count=$(git rev-list --count "$baseline_commit..HEAD" 2>/dev/null || echo "0")
119
+ changed_count=$(git diff --stat "$baseline_commit" HEAD 2>/dev/null | tail -1 | grep -oE '[0-9]+ file' | grep -oE '[0-9]+' || echo "0")
120
+ ```
121
+
122
+ Store `drift_detected=true`, `commit_count`, `changed_count` for dashboard rendering.
123
+
124
+ If `baseline_commit` is empty or matches `current_commit`: set `drift_detected=false`.
125
+
126
+ Restore identically regardless of time elapsed — no warnings about session age.
127
+
128
+ ---
129
+
130
+ ### Step 6: Compute Workflow Position and Next-Step Guidance
131
+
132
+ Compute `suggested_next` dynamically from COLONY_STATE.json data. Do not use the static value from session.json.
133
+
134
+ Use this decision tree:
135
+
136
+ ```
137
+ Case 1 — No plan created yet:
138
+ Check: plan.phases is empty AND plan.generated_at is null
139
+ recommended = "/ant:plan"
140
+ reason = "No plan created yet"
141
+ alternatives = ["/ant:colonize — analyze codebase first"]
142
+
143
+ Case 2 — Plan ready, first phase not started:
144
+ Check: plan.phases is not empty AND state == "READY" AND current_phase == 0
145
+ recommended = "/ant:build 1"
146
+ reason = "Plan ready, first phase not started"
147
+ alternatives = ["/ant:plan — review or regenerate plan"]
148
+
149
+ Case 3 — Build in progress:
150
+ Check: state == "EXECUTING"
151
+ recommended = "/ant:continue"
152
+ reason = "Build in progress"
153
+ alternatives = ["/ant:build {current_phase} — rebuild current phase", "/ant:flags — check for blockers"]
154
+
155
+ Case 4 — Phase complete, next phase available:
156
+ Check: state == "READY" AND current_phase > 0 AND current_phase < plan.phases.length
157
+ next = current_phase + 1
158
+ recommended = "/ant:build {next}"
159
+ reason = "Phase {current_phase} complete, ready for next"
160
+ alternatives = ["/ant:plan — regenerate plan", "/ant:phase {next} — preview next phase"]
161
+
162
+ Case 5 — All phases complete:
163
+ Check: state == "READY" AND current_phase > 0 AND current_phase >= plan.phases.length
164
+ recommended = "/ant:seal"
165
+ reason = "All phases complete"
166
+ alternatives = ["/ant:status — view final state"]
167
+
168
+ Case 6 — Colony paused:
169
+ Check: state == "PAUSED"
170
+ recommended = "/ant:resume-colony"
171
+ reason = "Colony is paused"
172
+ alternatives = ["/ant:status — check state first"]
173
+
174
+ Default:
175
+ recommended = "/ant:status"
176
+ reason = "Check colony status"
177
+ alternatives = []
178
+ ```
179
+
180
+ ---
181
+
182
+ ### Step 7: Workflow-Step Blocking (Early-Return Guards)
183
+
184
+ Run these guards BEFORE rendering the dashboard. If a blocking condition is detected, output the block message and STOP. Do not render the dashboard. Do not offer alternative commands.
185
+
186
+ **BLOCK CONDITION 1: No plan exists**
187
+
188
+ Check: plan.phases is empty AND plan.generated_at is null
189
+
190
+ Output and STOP:
191
+
192
+ ```
193
+ BLOCKED: No plan exists yet.
194
+ Required: Run /ant:plan to create a build plan.
195
+ Goal: {goal}
196
+ ```
197
+
198
+ Stop here — do not continue to Step 8 or render the dashboard.
199
+
200
+ ---
201
+
202
+ **BLOCK CONDITION 2: Plan attempted but failed**
203
+
204
+ Check: plan.phases is empty AND plan.generated_at is not null
205
+
206
+ Output and STOP:
207
+
208
+ ```
209
+ BLOCKED: Plan was attempted but has no phases.
210
+ Required: Run /ant:plan to regenerate the plan.
211
+ Goal: {goal}
212
+ ```
213
+
214
+ Stop here — do not continue to Step 8 or render the dashboard.
215
+
216
+ ---
217
+
218
+ **BLOCK CONDITION 3: Build interrupted**
219
+
220
+ Check: state == "EXECUTING" AND the last 3 events show no recent build activity
221
+
222
+ Output and STOP:
223
+
224
+ ```
225
+ BLOCKED: Build may have been interrupted.
226
+ Required: Run /ant:continue to check and advance.
227
+ Goal: {goal}
228
+ ```
229
+
230
+ Stop here — do not continue to Step 8 or render the dashboard.
231
+
232
+ ---
233
+
234
+ ### Step 8: Render Dashboard
235
+
236
+ Lead with the next-step recommendation. Context follows underneath ("straight to action" ordering).
237
+
238
+ ```
239
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
240
+ RESUME SESSION
241
+
242
+ Next: {recommended}
243
+ {reason}
244
+ {if alternatives exist:}
245
+ Also: {alternatives, comma-separated}
246
+ {end}
247
+
248
+ {if drift_detected:}
249
+ Note: Codebase changed since last session ({commit_count} commit(s), {changed_count} file(s) modified)
250
+ {end}
251
+
252
+ Goal: {goal}
253
+ State: {state}
254
+ Phase: {current_phase}/{total_phases}
255
+
256
+ Phase Progress:
257
+ {for each phase in plan.phases:}
258
+ [{status_icon}] Phase {id}: {name}
259
+ {end}
260
+ ```
261
+
262
+ Status icons:
263
+ - completed: `v` (checkmark)
264
+ - in_progress: `~` (tilde)
265
+ - pending: ` ` (space)
266
+
267
+ ```
268
+ {if memory.decisions is not empty:}
269
+ Recent Decisions:
270
+ {for each of the last 5 decisions:}
271
+ - {decision text}
272
+ {end}
273
+ {end}
274
+
275
+ {if focus array or constraints array is not empty:}
276
+ Active Signals:
277
+ {for each focus signal:}
278
+ FOCUS: {focus text}
279
+ {end}
280
+ {for each constraint signal:}
281
+ REDIRECT: {constraint text}
282
+ {end}
283
+ {end}
284
+
285
+ Last Command: {last_command}
286
+ Session: {session_id}
287
+ ```
288
+
289
+ ---
290
+
291
+ ### Step 9: Mark Session Resumed
292
+
293
+ Run using the Bash tool with description "Marking session as resumed...":
294
+ ```bash
295
+ bash .aether/aether-utils.sh session-mark-resumed
296
+ ```
297
+
298
+ ### Step 10: Next Up
299
+
300
+ Generate the state-based Next Up block by running using the Bash tool with description "Generating Next Up suggestions...":
301
+ ```bash
302
+ state=$(jq -r '.state // "IDLE"' .aether/data/COLONY_STATE.json)
303
+ current_phase=$(jq -r '.current_phase // 0' .aether/data/COLONY_STATE.json)
304
+ total_phases=$(jq -r '.plan.phases | length' .aether/data/COLONY_STATE.json)
305
+ bash .aether/aether-utils.sh print-next-up "$state" "$current_phase" "$total_phases"
306
+ ```
307
+
308
+ ---
309
+
310
+ ## Error Handling Reference
311
+
312
+ | Condition | Response |
313
+ |-----------|----------|
314
+ | session.json missing (exists=false) | "No previous session found" — offer /ant:init and /ant:status |
315
+ | COLONY_STATE.json missing or corrupted | Pause, ask user: start fresh or recover |
316
+ | constraints.json missing | Skip silently (no pheromones) |
317
+ | CONTEXT.md missing | Fall back to COLONY_STATE.json narrative |
318
+ | No plan phases, no generated_at | BLOCK — redirect to /ant:plan |
319
+ | Plan attempted but no phases | BLOCK — redirect to /ant:plan |
320
+ | State EXECUTING, events show no activity | BLOCK — redirect to /ant:continue |
321
+ | baseline_commit matches current HEAD | No drift warning shown |
322
+ | baseline_commit differs from current HEAD | Show informational drift note |
323
+
324
+ ---
325
+
326
+ ## Key Constraints
327
+
328
+ - Use Read tool for COLONY_STATE.json and constraints.json (not bash cat/jq)
329
+ - Use Bash tool only for aether-utils.sh commands and git commands
330
+ - Handle ALL missing/corrupted file cases gracefully
331
+ - Time-agnostic: restore identically regardless of how long ago the session was
332
+ - Decisions shown as flat list — no user vs Claude distinction
333
+ - Blocking guards run BEFORE dashboard rendering (early-return pattern)
334
+ - Drift detection is informational only — not alarming, not a blocker
@@ -150,36 +150,44 @@ Update COLONY_STATE.json:
150
150
 
151
151
  After archiving, write the final handoff documenting the completed colony:
152
152
 
153
- ```bash
154
- cat > .aether/HANDOFF.md << 'HANDOFF_EOF'
155
- # Colony Session — SEALED (Crowned Anthill)
153
+ Resolve the handoff template path:
154
+ Check ~/.aether/system/templates/handoff.template.md first,
155
+ then .aether/templates/handoff.template.md.
156
156
 
157
- ## 🏆 Colony Complete
158
- **Status:** Crowned Anthill — All phases completed and archived
157
+ If no template found: output "Template missing: handoff.template.md. Run aether update to fix." and stop.
159
158
 
160
- ## Archive Location
161
- {archive_dir}
159
+ Read the template file. Fill all {{PLACEHOLDER}} values:
160
+ - {{CHAMBER_NAME}} → archive directory name
161
+ - {{GOAL}} → goal
162
+ - {{PHASES_COMPLETED}} → total_phases (OpenCode seal archives completed colonies)
163
+ - {{TOTAL_PHASES}} → total_phases
164
+ - {{MILESTONE}} → "Crowned Anthill"
165
+ - {{ENTOMB_TIMESTAMP}} → seal timestamp
162
166
 
163
- ## Colony Summary
164
- - Goal: "{goal}"
165
- - Total Phases: {total_phases}
166
- - Milestone: Crowned Anthill
167
- - Sealed At: {timestamp}
167
+ Remove the HTML comment lines at the top of the template.
168
+ Write the result to .aether/HANDOFF.md using the Write tool.
168
169
 
169
- ## Files Archived
170
- - COLONY_STATE.json
171
- - activity.log
172
- - spawn-tree.txt
173
- - flags.json (if existed)
174
- - constraints.json (if existed)
170
+ This handoff serves as the final record of the completed colony.
175
171
 
176
- ## Session Note
177
- This colony has been sealed and archived. The anthill stands crowned.
178
- To start anew, run: /ant:lay-eggs "<new goal>"
179
- HANDOFF_EOF
180
- ```
172
+ ### Step 5.75: Export XML Archive (best-effort)
181
173
 
182
- This handoff serves as the final record of the completed colony.
174
+ Export colony data as a combined XML archive. This is best-effort — seal proceeds even if XML export fails.
175
+
176
+ ```bash
177
+ # Check if xmllint is available
178
+ if command -v xmllint >/dev/null 2>&1; then
179
+ xml_result=$(bash .aether/aether-utils.sh colony-archive-xml ".aether/exchange/colony-archive.xml" 2>&1)
180
+ xml_ok=$(echo "$xml_result" | jq -r '.ok // false' 2>/dev/null)
181
+ if [[ "$xml_ok" == "true" ]]; then
182
+ xml_pheromone_count=$(echo "$xml_result" | jq -r '.result.pheromone_count // 0' 2>/dev/null)
183
+ xml_export_line="XML Archive: colony-archive.xml (${xml_pheromone_count} active signals)"
184
+ else
185
+ xml_export_line="XML Archive: export failed (non-blocking)"
186
+ fi
187
+ else
188
+ xml_export_line="XML Archive: skipped (xmllint not available)"
189
+ fi
190
+ ```
183
191
 
184
192
  ### Step 6: Display Result
185
193
 
@@ -207,6 +215,7 @@ Output:
207
215
  - spawn-tree.txt
208
216
  - flags.json (if existed)
209
217
  - constraints.json (if existed)
218
+ {xml_export_line}
210
219
 
211
220
  🐜 The colony has reached its final form.
212
221
  The anthill stands crowned and sealed.
@@ -114,6 +114,14 @@ Extract:
114
114
  - Issues count (high, warnings)
115
115
  - Notes count (low, informational)
116
116
 
117
+ **Escalation state:**
118
+ Count escalated flags by checking for blocker flags with source "escalation":
119
+
120
+ ```bash
121
+ escalated_count=$(bash .aether/aether-utils.sh flag-list --type blocker 2>/dev/null | jq '[.result.flags[] | select(.source == "escalation")] | length' 2>/dev/null || echo "0")
122
+ echo "escalated_count=$escalated_count"
123
+ ```
124
+
117
125
  **Instincts:**
118
126
  From `memory.instincts`:
119
127
  - Total count: `instincts.length`
@@ -156,6 +164,9 @@ Output format:
156
164
  🎯 Focus: <focus_count> areas | 🚫 Avoid: <constraints_count> patterns
157
165
  🧠 Instincts: <total> learned (<high_confidence> strong)
158
166
  🚩 Flags: <blockers> blockers | <issues> issues | <notes> notes
167
+ {if escalated_count > 0:}
168
+ ⚠️ Escalated: {escalated_count} task(s) awaiting your decision
169
+ {end if}
159
170
  🏆 Milestone: <milestone> (<version>)
160
171
  💭 Dreams: <dream_count> recorded (latest: <latest_dream>)
161
172
 
@@ -106,6 +106,37 @@ To get the counts and hash status:
106
106
  - If not verified: hash_status = "⚠️ hash mismatch"
107
107
  - If error: hash_status = "⚠️ error"
108
108
 
109
+ Check if `colony-archive.xml` exists in the chamber:
110
+
111
+ ```bash
112
+ chamber_has_xml=false
113
+ [[ -f ".aether/chambers/{chamber_name}/colony-archive.xml" ]] && chamber_has_xml=true
114
+ ```
115
+
116
+ **If `colony-archive.xml` exists**, add import option to the detail view footer:
117
+ ```
118
+ 📁 Files:
119
+ - COLONY_STATE.json (verified: {hash_status})
120
+ - manifest.json
121
+ - colony-archive.xml (XML Archive)
122
+
123
+ Actions:
124
+ 1. Import signals from this colony into current colony
125
+ 2. Return to chamber list
126
+
127
+ Select an action (1/2)
128
+ ```
129
+
130
+ Use AskUserQuestion with two options.
131
+
132
+ If option 1 selected: proceed to Step 6 (Import Signals from Chamber).
133
+ If option 2 selected: return to chamber list (run /ant:tunnels).
134
+
135
+ **If `colony-archive.xml` does NOT exist**, show existing footer unchanged:
136
+ ```
137
+ Run /ant:tunnels to return to chamber list.
138
+ ```
139
+
109
140
  Stop here.
110
141
 
111
142
  ### Step 5: Chamber Comparison Mode (Two Arguments)
@@ -231,6 +262,124 @@ Run /ant:tunnels <chamber_name> to view details
231
262
  - Missing COLONY_STATE.json: show "⚠️ Incomplete chamber" for that chamber
232
263
  - Very long chamber list: display all (no pagination for now)
233
264
 
265
+ ### Step 6: Import Signals from Chamber
266
+
267
+ When user selects "Import signals" from Step 3:
268
+
269
+ **Step 6.1: Check XML tools**
270
+ ```bash
271
+ if command -v xmllint >/dev/null 2>&1; then
272
+ xmllint_available=true
273
+ else
274
+ xmllint_available=false
275
+ fi
276
+ ```
277
+
278
+ If xmllint not available:
279
+ ```
280
+ Import requires xmllint. Install it first:
281
+ macOS: xcode-select --install
282
+ Linux: apt-get install libxml2-utils
283
+ ```
284
+ Stop here (return to chamber list).
285
+
286
+ **Step 6.2: Extract source colony name**
287
+ ```bash
288
+ chamber_xml=".aether/chambers/{chamber_name}/colony-archive.xml"
289
+ # Extract colony_id from the archive root element
290
+ source_colony=$(xmllint --xpath "string(/*/@colony_id)" "$chamber_xml" 2>/dev/null)
291
+ [[ -z "$source_colony" ]] && source_colony="{chamber_name}"
292
+ ```
293
+
294
+ **Step 6.3: Extract pheromone section and show import preview**
295
+
296
+ The combined `colony-archive.xml` contains pheromones, wisdom, and registry sections. Extract the pheromone section to a temp file before counting or importing. This prevents over-counting signals from wisdom/registry sections and ensures `pheromone-import-xml` receives the format it expects (`<pheromones>` as root element).
297
+
298
+ ```bash
299
+ # Extract the <pheromones> section from the combined archive into a standalone temp file
300
+ import_tmp_dir=$(mktemp -d)
301
+ import_tmp_pheromones="$import_tmp_dir/pheromones-extracted.xml"
302
+
303
+ # Use xmllint to extract the pheromones element (with its namespace)
304
+ xmllint --xpath "//*[local-name()='pheromones']" "$chamber_xml" > "$import_tmp_pheromones" 2>/dev/null
305
+
306
+ # Add XML declaration to make it a standalone well-formed document
307
+ if [[ -s "$import_tmp_pheromones" ]]; then
308
+ # Portable approach: prepend declaration via temp file (avoids macOS/Linux sed -i differences)
309
+ { echo '<?xml version="1.0" encoding="UTF-8"?>'; cat "$import_tmp_pheromones"; } > "$import_tmp_dir/tmp_decl.xml"
310
+ mv "$import_tmp_dir/tmp_decl.xml" "$import_tmp_pheromones"
311
+ fi
312
+
313
+ # Count pheromone signals in extracted pheromone-only XML
314
+ # Scoped to pheromone section only — no over-counting from wisdom/registry sections
315
+ pheromone_count=$(xmllint --xpath "count(//*[local-name()='signal'])" "$import_tmp_pheromones" 2>/dev/null || echo "unknown")
316
+ ```
317
+
318
+ Display:
319
+ ```
320
+ IMPORT FROM COLONY: {source_colony}
321
+
322
+ Source: .aether/chambers/{chamber_name}/colony-archive.xml
323
+ Signals available: ~{pheromone_count} pheromone signals
324
+
325
+ Import behavior:
326
+ - Signals tagged with prefix "{source_colony}:" to identify origin
327
+ - Additive merge — your current signals are never overwritten
328
+ - On conflict, your current colony wins
329
+
330
+ Import these signals? (yes/no)
331
+ ```
332
+
333
+ Use AskUserQuestion with yes/no options.
334
+
335
+ If no: "Import cancelled." Clean up: `rm -rf "$import_tmp_dir"`. Return to chamber list.
336
+
337
+ **Step 6.4: Perform import**
338
+
339
+ Pass the extracted pheromone-only temp file (NOT the combined `colony-archive.xml`) to `pheromone-import-xml`, along with `$source_colony` as the second argument. This ensures:
340
+ 1. `pheromone-import-xml` receives XML with `<pheromones>` as root element (the format it expects)
341
+ 2. The prefix-tagging logic prepends `${source_colony}:` to each imported signal's ID before the merge
342
+
343
+ ```bash
344
+ # Import the EXTRACTED pheromone-only XML (NOT the combined colony-archive.xml)
345
+ # $import_tmp_pheromones has <pheromones> as root — the format pheromone-import-xml expects
346
+ # Second argument triggers prefix-tagging — imported signal IDs become "{source_colony}:original_id"
347
+ import_result=$(bash .aether/aether-utils.sh pheromone-import-xml "$import_tmp_pheromones" "$source_colony" 2>&1)
348
+ import_ok=$(echo "$import_result" | jq -r '.ok // false' 2>/dev/null)
349
+
350
+ if [[ "$import_ok" == "true" ]]; then
351
+ imported_count=$(echo "$import_result" | jq -r '.result.signal_count // 0' 2>/dev/null)
352
+ else
353
+ imported_count=0
354
+ import_error=$(echo "$import_result" | jq -r '.error // "Unknown error"' 2>/dev/null)
355
+ fi
356
+
357
+ # Clean up temp files
358
+ rm -rf "$import_tmp_dir"
359
+ ```
360
+
361
+ **Step 6.5: Display result**
362
+
363
+ If import succeeded:
364
+ ```
365
+ SIGNALS IMPORTED
366
+
367
+ Source: {source_colony}
368
+ Imported: {imported_count} pheromone signals
369
+ Tagged with: "{source_colony}:" prefix
370
+
371
+ Your colony now carries wisdom from {source_colony}.
372
+ Run /ant:status to see current colony state.
373
+ ```
374
+
375
+ If import failed:
376
+ ```
377
+ Import failed: {import_error}
378
+
379
+ The archive may be malformed. Check:
380
+ .aether/chambers/{chamber_name}/colony-archive.xml
381
+ ```
382
+
234
383
  ## Implementation Notes
235
384
 
236
385
  The `chamber-list` utility returns JSON in this format: