aether-colony 5.1.0 → 5.3.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 (185) hide show
  1. package/.aether/aether-utils.sh +157 -42
  2. package/.aether/agents/aether-ambassador.md +140 -0
  3. package/.aether/agents/aether-archaeologist.md +108 -0
  4. package/.aether/agents/aether-architect.md +133 -0
  5. package/.aether/agents/aether-auditor.md +144 -0
  6. package/.aether/agents/aether-builder.md +184 -0
  7. package/.aether/agents/aether-chaos.md +115 -0
  8. package/.aether/agents/aether-chronicler.md +122 -0
  9. package/.aether/agents/aether-gatekeeper.md +116 -0
  10. package/.aether/agents/aether-includer.md +117 -0
  11. package/.aether/agents/aether-keeper.md +177 -0
  12. package/.aether/agents/aether-measurer.md +128 -0
  13. package/.aether/agents/aether-oracle.md +137 -0
  14. package/.aether/agents/aether-probe.md +133 -0
  15. package/.aether/agents/aether-queen.md +286 -0
  16. package/.aether/agents/aether-route-setter.md +130 -0
  17. package/.aether/agents/aether-sage.md +106 -0
  18. package/.aether/agents/aether-scout.md +101 -0
  19. package/.aether/agents/aether-surveyor-disciplines.md +391 -0
  20. package/.aether/agents/aether-surveyor-nest.md +329 -0
  21. package/.aether/agents/aether-surveyor-pathogens.md +264 -0
  22. package/.aether/agents/aether-surveyor-provisions.md +334 -0
  23. package/.aether/agents/aether-tracker.md +137 -0
  24. package/.aether/agents/aether-watcher.md +174 -0
  25. package/.aether/agents/aether-weaver.md +130 -0
  26. package/.aether/commands/claude/archaeology.md +334 -0
  27. package/.aether/commands/claude/build.md +65 -0
  28. package/.aether/commands/claude/chaos.md +336 -0
  29. package/.aether/commands/claude/colonize.md +259 -0
  30. package/.aether/commands/claude/continue.md +60 -0
  31. package/.aether/commands/claude/council.md +507 -0
  32. package/.aether/commands/claude/data-clean.md +81 -0
  33. package/.aether/commands/claude/dream.md +268 -0
  34. package/.aether/commands/claude/entomb.md +498 -0
  35. package/.aether/commands/claude/export-signals.md +57 -0
  36. package/.aether/commands/claude/feedback.md +96 -0
  37. package/.aether/commands/claude/flag.md +151 -0
  38. package/.aether/commands/claude/flags.md +169 -0
  39. package/.aether/commands/claude/focus.md +76 -0
  40. package/.aether/commands/claude/help.md +154 -0
  41. package/.aether/commands/claude/history.md +140 -0
  42. package/.aether/commands/claude/import-signals.md +71 -0
  43. package/.aether/commands/claude/init.md +505 -0
  44. package/.aether/commands/claude/insert-phase.md +105 -0
  45. package/.aether/commands/claude/interpret.md +278 -0
  46. package/.aether/commands/claude/lay-eggs.md +210 -0
  47. package/.aether/commands/claude/maturity.md +113 -0
  48. package/.aether/commands/claude/memory-details.md +77 -0
  49. package/.aether/commands/claude/migrate-state.md +171 -0
  50. package/.aether/commands/claude/oracle.md +642 -0
  51. package/.aether/commands/claude/organize.md +232 -0
  52. package/.aether/commands/claude/patrol.md +620 -0
  53. package/.aether/commands/claude/pause-colony.md +233 -0
  54. package/.aether/commands/claude/phase.md +115 -0
  55. package/.aether/commands/claude/pheromones.md +156 -0
  56. package/.aether/commands/claude/plan.md +693 -0
  57. package/.aether/commands/claude/preferences.md +65 -0
  58. package/.aether/commands/claude/quick.md +100 -0
  59. package/.aether/commands/claude/redirect.md +76 -0
  60. package/.aether/commands/claude/resume-colony.md +197 -0
  61. package/.aether/commands/claude/resume.md +388 -0
  62. package/.aether/commands/claude/run.md +231 -0
  63. package/.aether/commands/claude/seal.md +774 -0
  64. package/.aether/commands/claude/skill-create.md +286 -0
  65. package/.aether/commands/claude/status.md +410 -0
  66. package/.aether/commands/claude/swarm.md +349 -0
  67. package/.aether/commands/claude/tunnels.md +426 -0
  68. package/.aether/commands/claude/update.md +132 -0
  69. package/.aether/commands/claude/verify-castes.md +143 -0
  70. package/.aether/commands/claude/watch.md +239 -0
  71. package/.aether/commands/colonize.yaml +4 -0
  72. package/.aether/commands/council.yaml +205 -0
  73. package/.aether/commands/init.yaml +46 -13
  74. package/.aether/commands/insert-phase.yaml +4 -0
  75. package/.aether/commands/opencode/archaeology.md +331 -0
  76. package/.aether/commands/opencode/build.md +1168 -0
  77. package/.aether/commands/opencode/chaos.md +329 -0
  78. package/.aether/commands/opencode/colonize.md +195 -0
  79. package/.aether/commands/opencode/continue.md +1436 -0
  80. package/.aether/commands/opencode/council.md +437 -0
  81. package/.aether/commands/opencode/data-clean.md +77 -0
  82. package/.aether/commands/opencode/dream.md +260 -0
  83. package/.aether/commands/opencode/entomb.md +377 -0
  84. package/.aether/commands/opencode/export-signals.md +54 -0
  85. package/.aether/commands/opencode/feedback.md +99 -0
  86. package/.aether/commands/opencode/flag.md +149 -0
  87. package/.aether/commands/opencode/flags.md +167 -0
  88. package/.aether/commands/opencode/focus.md +73 -0
  89. package/.aether/commands/opencode/help.md +157 -0
  90. package/.aether/commands/opencode/history.md +136 -0
  91. package/.aether/commands/opencode/import-signals.md +68 -0
  92. package/.aether/commands/opencode/init.md +518 -0
  93. package/.aether/commands/opencode/insert-phase.md +111 -0
  94. package/.aether/commands/opencode/interpret.md +272 -0
  95. package/.aether/commands/opencode/lay-eggs.md +213 -0
  96. package/.aether/commands/opencode/maturity.md +108 -0
  97. package/.aether/commands/opencode/memory-details.md +83 -0
  98. package/.aether/commands/opencode/migrate-state.md +165 -0
  99. package/.aether/commands/opencode/oracle.md +593 -0
  100. package/.aether/commands/opencode/organize.md +226 -0
  101. package/.aether/commands/opencode/patrol.md +626 -0
  102. package/.aether/commands/opencode/pause-colony.md +203 -0
  103. package/.aether/commands/opencode/phase.md +113 -0
  104. package/.aether/commands/opencode/pheromones.md +162 -0
  105. package/.aether/commands/opencode/plan.md +684 -0
  106. package/.aether/commands/opencode/preferences.md +71 -0
  107. package/.aether/commands/opencode/quick.md +91 -0
  108. package/.aether/commands/opencode/redirect.md +84 -0
  109. package/.aether/commands/opencode/resume-colony.md +190 -0
  110. package/.aether/commands/opencode/resume.md +394 -0
  111. package/.aether/commands/opencode/run.md +237 -0
  112. package/.aether/commands/opencode/seal.md +452 -0
  113. package/.aether/commands/opencode/skill-create.md +63 -0
  114. package/.aether/commands/opencode/status.md +307 -0
  115. package/.aether/commands/opencode/swarm.md +15 -0
  116. package/.aether/commands/opencode/tunnels.md +400 -0
  117. package/.aether/commands/opencode/update.md +127 -0
  118. package/.aether/commands/opencode/verify-castes.md +139 -0
  119. package/.aether/commands/opencode/watch.md +227 -0
  120. package/.aether/commands/plan.yaml +53 -2
  121. package/.aether/commands/quick.yaml +104 -0
  122. package/.aether/commands/resume-colony.yaml +6 -4
  123. package/.aether/commands/resume.yaml +9 -0
  124. package/.aether/commands/run.yaml +37 -1
  125. package/.aether/commands/seal.yaml +9 -0
  126. package/.aether/commands/status.yaml +45 -1
  127. package/.aether/docs/command-playbooks/build-full.md +3 -2
  128. package/.aether/docs/command-playbooks/build-prep.md +12 -4
  129. package/.aether/docs/command-playbooks/build-verify.md +51 -0
  130. package/.aether/docs/command-playbooks/continue-advance.md +115 -6
  131. package/.aether/docs/command-playbooks/continue-full.md +1 -0
  132. package/.aether/docs/command-playbooks/continue-verify.md +33 -0
  133. package/.aether/utils/clash-detect.sh +239 -0
  134. package/.aether/utils/council.sh +425 -0
  135. package/.aether/utils/error-handler.sh +3 -3
  136. package/.aether/utils/flag.sh +23 -12
  137. package/.aether/utils/hive.sh +2 -2
  138. package/.aether/utils/hooks/clash-pre-tool-use.js +99 -0
  139. package/.aether/utils/immune.sh +508 -0
  140. package/.aether/utils/learning.sh +2 -2
  141. package/.aether/utils/merge-driver-lockfile.sh +35 -0
  142. package/.aether/utils/midden.sh +712 -0
  143. package/.aether/utils/pheromone.sh +1376 -108
  144. package/.aether/utils/queen.sh +31 -21
  145. package/.aether/utils/session.sh +264 -0
  146. package/.aether/utils/spawn-tree.sh +7 -7
  147. package/.aether/utils/spawn.sh +2 -2
  148. package/.aether/utils/state-api.sh +216 -5
  149. package/.aether/utils/swarm.sh +1 -1
  150. package/.aether/utils/worktree.sh +189 -0
  151. package/.claude/commands/ant/colonize.md +2 -0
  152. package/.claude/commands/ant/council.md +205 -0
  153. package/.claude/commands/ant/init.md +53 -14
  154. package/.claude/commands/ant/insert-phase.md +4 -0
  155. package/.claude/commands/ant/plan.md +27 -1
  156. package/.claude/commands/ant/quick.md +100 -0
  157. package/.claude/commands/ant/resume-colony.md +3 -2
  158. package/.claude/commands/ant/resume.md +9 -0
  159. package/.claude/commands/ant/run.md +37 -1
  160. package/.claude/commands/ant/seal.md +9 -0
  161. package/.claude/commands/ant/status.md +45 -1
  162. package/.opencode/commands/ant/colonize.md +2 -0
  163. package/.opencode/commands/ant/council.md +143 -0
  164. package/.opencode/commands/ant/init.md +53 -13
  165. package/.opencode/commands/ant/insert-phase.md +4 -0
  166. package/.opencode/commands/ant/plan.md +26 -1
  167. package/.opencode/commands/ant/quick.md +91 -0
  168. package/.opencode/commands/ant/resume-colony.md +3 -2
  169. package/.opencode/commands/ant/resume.md +9 -0
  170. package/.opencode/commands/ant/run.md +37 -1
  171. package/.opencode/commands/ant/status.md +2 -0
  172. package/CHANGELOG.md +116 -0
  173. package/README.md +34 -8
  174. package/bin/cli.js +103 -61
  175. package/bin/lib/banner.js +14 -0
  176. package/bin/lib/init.js +8 -7
  177. package/bin/lib/interactive-setup.js +251 -0
  178. package/bin/npx-entry.js +21 -0
  179. package/bin/npx-install.js +9 -167
  180. package/bin/validate-package.sh +23 -0
  181. package/package.json +11 -3
  182. package/.aether/docs/plans/pheromone-display-plan.md +0 -257
  183. package/.aether/schemas/example-prompt-builder.xml +0 -234
  184. package/.aether/scripts/incident-test-add.sh +0 -47
  185. package/.aether/scripts/weekly-audit.sh +0 -79
@@ -0,0 +1,518 @@
1
+ <!-- Generated from .aether/commands/init.yaml - DO NOT EDIT DIRECTLY -->
2
+ ---
3
+ name: ant:init
4
+ description: "Initialize Aether colony - scan repo, approve charter, create colony"
5
+ ---
6
+
7
+ ### Step -1: Normalize Arguments
8
+
9
+ Run: `normalized_args=$(bash .aether/aether-utils.sh normalize-args "$@")`
10
+
11
+ This ensures arguments work correctly in both Claude Code and OpenCode. Use `$normalized_args` throughout this command.
12
+
13
+ You are the **Queen Ant Colony**. Initialize the colony with the Queen's intention.
14
+
15
+ ## Instructions
16
+
17
+ The user's goal is: `$normalized_args`
18
+
19
+ Parse `$normalized_args`:
20
+ - If contains `--no-visual`: set `visual_mode = false` (visual is ON by default)
21
+ - Otherwise: set `visual_mode = true`
22
+
23
+
24
+ Note: Use `$normalized_args` instead of `$ARGUMENTS` throughout this command.
25
+
26
+ ### Step 0: Initialize Visual Mode (if enabled)
27
+
28
+ If `visual_mode` is true:
29
+
30
+
31
+ <failure_modes>
32
+ ### Colony State Overwrite
33
+ Re-init mode detects existing COLONY_STATE.json and preserves all state. Charter content is updated in-place via charter-write. Colony state, wisdom, instincts, learnings, pheromones, and phase progress are never reset.
34
+
35
+ ### Write Failure Mid-Init
36
+ If writing COLONY_STATE.json fails partway:
37
+ - Remove the incomplete file (partial state is worse than no state)
38
+ - Report the error
39
+ - Recovery: user can run /ant:init again safely
40
+ </failure_modes>
41
+
42
+ <success_criteria>
43
+ Command is complete when:
44
+ - User has approved the charter prompt (Charter, Context, Pheromones sections)
45
+ - Charter content is written to QUEEN.md via charter-write
46
+ - COLONY_STATE.json exists and is valid JSON (fresh init only)
47
+ - Session file is written
48
+ - User sees confirmation of colony creation or re-init
49
+ </success_criteria>
50
+
51
+ <read_only>
52
+ Do not touch during init:
53
+ - .aether/dreams/ (user notes)
54
+ - .aether/chambers/ (archived colonies)
55
+ - .env* files
56
+ - .claude/settings.json
57
+ - .github/workflows/
58
+ </read_only>
59
+
60
+ ### Step 1: Validate Input
61
+
62
+ If `$normalized_args` is empty or blank, output:
63
+
64
+ ```
65
+ Aether Colony
66
+
67
+ Initialize the colony with a goal. This scans the repo, generates
68
+ a charter for your approval, then creates colony files.
69
+
70
+ Usage: /ant:init "<your goal here>"
71
+
72
+ Examples:
73
+ /ant:init "Build a REST API with authentication"
74
+ /ant:init "Create a soothing sound application"
75
+ /ant:init "Design a calculator CLI tool"
76
+ ```
77
+
78
+ Stop here. Do not proceed.
79
+
80
+ ### Step 1.5: Verify Aether Setup
81
+
82
+ Check if `.aether/aether-utils.sh` exists using the Read tool.
83
+
84
+ **If the file already exists** -- skip this step entirely. Aether is set up.
85
+
86
+ **If the file does NOT exist:**
87
+ ```
88
+ Aether is not set up in this repo yet.
89
+
90
+ Run /ant:lay-eggs first to create the .aether/ directory
91
+ with all system files, then run /ant:init "your goal" to
92
+ start a colony.
93
+
94
+ If the global hub isn't installed either:
95
+ npm install -g aether-colony (installs the hub)
96
+ /ant:lay-eggs (sets up this repo)
97
+ /ant:init "your goal" (starts the colony)
98
+ ```
99
+ Stop here. Do not proceed.
100
+
101
+ ### Step 2: Initialize QUEEN.md
102
+
103
+ Run:
104
+ ```
105
+ bash .aether/aether-utils.sh queen-init
106
+ ```
107
+
108
+ Parse the JSON result:
109
+ - If `created` is true: Display `QUEEN.md initialized`
110
+ - If `created` is false and `reason` is "already_exists": Display `QUEEN.md already exists`
111
+
112
+ This step is non-blocking -- proceed regardless of outcome.
113
+
114
+ ### Step 3: Scan Repository
115
+
116
+ Run the scan via Bash tool:
117
+ ```bash
118
+ scan_result=$(bash .aether/aether-utils.sh init-research 2>/dev/null)
119
+ scan_data=$(echo "$scan_result" | jq '.result')
120
+ ```
121
+
122
+ Extract fields with jq defaults for missing data:
123
+ - `tech_langs`: `.tech_stack.languages | if length > 0 then join(", ") else "not detected" end`
124
+ - `tech_fwks`: `.tech_stack.frameworks | if length > 0 then join(", ") else "none" end`
125
+ - `tech_pkg`: `.tech_stack.package_managers | join(", ")`
126
+ - `complexity`: `.complexity.size`
127
+ - `file_count`: `.complexity.metrics.file_count`
128
+ - `top_dirs`: `.directory_structure.top_level_dirs | if . and length > 0 then join(", ") else "flat" end`
129
+ - `commit_count`: `.git_history.commit_count // "unknown"`
130
+ - `is_git`: `.git_history.is_git_repo // false`
131
+ - `survey_suggestion`: `.survey_status.suggestion.reason // empty`
132
+ - `has_active`: `.prior_colonies.has_active_colony // false`
133
+ - `active_goal`: `.prior_colonies.active_goal // empty`
134
+
135
+ **Intelligence fields (new):**
136
+ - `colony_context_colonies`: `.colony_context.prior_colonies // []` -- array of prior colony summaries (each has goal, phases, outcome, summary)
137
+ - `colony_context_charter`: `.colony_context.existing_charter // {}` -- existing charter content from QUEEN.md
138
+ - `governance_rules`: `.governance.rules // []` -- array of governance rule objects (each has rule, source, strength)
139
+ - `pheromone_suggestions`: `.pheromone_suggestions // []` -- array of suggestion objects (each has type, content, reason, priority)
140
+
141
+ If `scan_result` is empty or `jq` fails, set all fields to fallback values (empty arrays/objects for intelligence fields) and proceed (graceful degradation -- never stop init because scan fails).
142
+
143
+ ### Step 4: Detect Re-Init Mode
144
+
145
+ Use Read tool to check `.aether/data/COLONY_STATE.json`.
146
+
147
+ - If file exists AND has a non-null `goal` field:
148
+ - Check the `milestone` field. If `milestone == "Crowned Anthill"`:
149
+ - This is a **sealed colony**. Treat as **fresh init**, NOT re-init.
150
+ - Set `reinit_mode = false`
151
+ - Display: `Previous colony was sealed. Starting fresh colony.`
152
+ - The old COLONY_STATE.json will be overwritten in Step 7 (fresh init path).
153
+ - Otherwise (colony exists but is NOT sealed): set `reinit_mode = true`, store `existing_goal`
154
+ - If file does not exist or `goal` is null: set `reinit_mode = false`
155
+
156
+ If re-init mode, read existing charter entries from `.aether/QUEEN.md`:
157
+ ```bash
158
+ existing_intent=$(grep '\[charter\] \*\*Intent\*\*:' .aether/QUEEN.md 2>/dev/null | sed 's/.*\*\*Intent\*\*: //' | sed 's/ (Colony:.*//' || true)
159
+ existing_vision=$(grep '\[charter\] \*\*Vision\*\*:' .aether/QUEEN.md 2>/dev/null | sed 's/.*\*\*Vision\*\*: //' | sed 's/ (Colony:.*//' || true)
160
+ existing_governance=$(grep '\[charter\] \*\*Governance\*\*:' .aether/QUEEN.md 2>/dev/null | sed 's/.*\*\*Governance\*\*: //' | sed 's/ (Colony:.*//' || true)
161
+ existing_goals=$(grep '\[charter\] \*\*Goal\*\*:' .aether/QUEEN.md 2>/dev/null | sed 's/.*\*\*Goal\*\*: //' | sed 's/ (Colony:.*//' || true)
162
+ ```
163
+
164
+ Strip `(Colony: ...)` suffixes using sed. If grep finds nothing, variables remain empty.
165
+
166
+ ### Step 5: Assemble and Display Approval Prompt
167
+
168
+ Display a brief header:
169
+ ```
170
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
171
+ A E T H E R C O L O N Y I N I T
172
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
173
+ ```
174
+
175
+ If re-init mode, display:
176
+ ```
177
+ Re-init mode detected (existing goal: "{existing_goal}")
178
+ Charter will be updated. All colony state, wisdom, instincts, and progress will be preserved.
179
+ ```
180
+
181
+ Then display the approval prompt as formatted Markdown. Section ordering: Prior Context (if any) -> Charter -> Context -> Pheromones.
182
+
183
+ **Section 1: Prior Context (conditional -- only when prior colonies exist)**
184
+
185
+ If `colony_context_colonies` has entries (length > 0), display:
186
+ ```markdown
187
+ ## Prior Context
188
+
189
+ Previous colonies in this repo:
190
+
191
+ {For each colony (max 3, most recent first):}
192
+ - **{goal}** -- {outcome} ({phases} phases){if summary is non-empty: ". {summary}"}
193
+ ```
194
+
195
+ Per locked decision: when no prior colonies exist, omit this section entirely. No placeholder, no header.
196
+
197
+ Keep each colony to 1-2 lines. Show goal, outcome (milestone), phase count, and summary from CROWNED-ANTHILL.md if available.
198
+
199
+ **Section 2: Charter**
200
+ ```markdown
201
+ ## Charter
202
+
203
+ **Intent:** {user's goal from $normalized_args, or existing_intent if re-init}
204
+ **Vision:** {derived from user's goal by Claude, or existing_vision if re-init}
205
+ **Governance:** {see governance logic below}
206
+ **Goals:** {blank for fresh init, or existing_goals if re-init}
207
+ ```
208
+
209
+ For fresh init, Claude should derive a brief Vision from the user's goal (1-2 sentences). Goals start blank. The user fills them in if desired.
210
+
211
+ **Governance field logic:**
212
+ - For fresh init with `governance_rules` available (length > 0): pre-populate with semicolon-separated rule text from the detected rules. Format: `"TDD required; ESLint enforced; Follow CONTRIBUTING.md"`. These are editable by the user.
213
+ - For fresh init with no governance_rules: leave blank.
214
+ - For re-init with existing_governance non-empty: pre-populate from existing QUEEN.md charter entries.
215
+ - For re-init with existing_governance empty but governance_rules available: pre-populate from governance_rules.
216
+
217
+ For re-init, pre-populate Intent, Vision, and Goals from existing QUEEN.md charter entries.
218
+
219
+ **Section 3: Context**
220
+ ```markdown
221
+ ## Context
222
+
223
+ **Tech Stack:** {tech_langs} | {tech_fwks} | {tech_pkg}
224
+ **Project Size:** {complexity} ({file_count} files)
225
+ **Structure:** {top_dirs}
226
+ **Git:** {commit_count} commits
227
+ {if survey_suggestion: **Note:** {survey_suggestion}}
228
+ ```
229
+
230
+ **Section 4: Pheromones**
231
+
232
+ If `pheromone_suggestions` has entries (length > 0), display:
233
+ ```markdown
234
+ ## Pheromones
235
+
236
+ Suggested signals based on repo analysis:
237
+
238
+ 1. [FOCUS] Testing infrastructure present (47 test files) -- maintain TDD discipline
239
+ 2. [REDIRECT] Environment files detected -- never commit secrets or .env files
240
+ 3. [FOCUS] Code quality tools configured -- follow existing lint/format rules
241
+
242
+ Edit, remove, or add signals as needed. Approved signals will be auto-applied.
243
+ ```
244
+
245
+ The numbered list uses the actual type and content from `pheromone_suggestions`. Each line format: `{N}. [{type}] {content}`.
246
+
247
+ Per locked decision: suggestions are fully editable. User can reword, remove, or add their own.
248
+ Per locked decision: all sections look the same -- no visual distinction between auto-generated and user-written content.
249
+
250
+ If no pheromone suggestions available (empty array), display the existing default:
251
+ ```markdown
252
+ ## Pheromones
253
+
254
+ No pheromone suggestions yet -- use /ant:focus and /ant:redirect to guide the colony.
255
+ ```
256
+
257
+ End with clear instructions:
258
+ ```
259
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
260
+ Review the prompt above. You can:
261
+ - Edit any section (just describe your changes)
262
+ - Say "approve" or "looks good" to proceed
263
+ - Say "cancel" to abort
264
+
265
+ If you don't respond, the colony will not be initialized.
266
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
267
+ ```
268
+
269
+ **STOP HERE.** Wait for the user's response. Do NOT proceed to Step 6 until the user responds.
270
+
271
+ ### Step 6: Handle User Response
272
+
273
+ Parse the user's response:
274
+ - If the user approves (says "approve", "looks good", "yes", "ok", or similar): proceed to Step 7
275
+ - If the user provides edits: apply the edits to the relevant section(s), re-display the full prompt, increment a revision counter, and wait again
276
+ - If the user cancels: display "Colony initialization cancelled." and stop
277
+ - Max 2 revision rounds. After 2 rejections/edits, display: "Maximum revisions reached. Approve current version, or cancel init?" and wait for final decision
278
+
279
+ When applying edits, Claude updates the section content in memory (not files) and re-displays the full prompt. Each re-display includes a revision counter: "(Revision {N}/2)"
280
+
281
+ ### Step 7: Create Colony (Post-Approval)
282
+
283
+ Only reached after user approval. ALL file writes happen here.
284
+
285
+ **If re-init mode:**
286
+
287
+ 1. Write charter content via:
288
+ ```bash
289
+ bash .aether/aether-utils.sh charter-write --intent "{approved_intent}" --vision "{approved_vision}" --governance "{approved_governance}" --goals "{approved_goals}"
290
+ ```
291
+
292
+ 2. Auto-apply approved pheromone suggestions (see pheromone auto-apply below).
293
+
294
+ 3. Update the goal field in COLONY_STATE.json in-place using the state API:
295
+ ```bash
296
+ bash .aether/aether-utils.sh state-write "$(jq --arg new_goal "{approved_intent}" '.goal = $new_goal' .aether/data/COLONY_STATE.json)"
297
+ ```
298
+
299
+ 4. **Verify the write** — read back and confirm goal is set:
300
+ ```bash
301
+ verify_goal=$(jq -r '.goal' .aether/data/COLONY_STATE.json)
302
+ if [[ "$verify_goal" == "null" || -z "$verify_goal" ]]; then
303
+ echo "ERROR: Colony state write failed — goal is still null after write. Re-run /ant:init."
304
+ # Attempt recovery: write goal directly
305
+ jq --arg g "{approved_intent}" '.goal = $g' .aether/data/COLONY_STATE.json > .aether/data/COLONY_STATE.json.tmp && mv .aether/data/COLONY_STATE.json.tmp .aether/data/COLONY_STATE.json
306
+ verify_goal=$(jq -r '.goal' .aether/data/COLONY_STATE.json)
307
+ if [[ "$verify_goal" == "null" || -z "$verify_goal" ]]; then
308
+ echo "FATAL: Recovery write also failed. Colony state may be corrupted."
309
+ stop
310
+ fi
311
+ fi
312
+ ```
313
+
314
+ 5. Run `bash .aether/aether-utils.sh session-init "$(jq -r '.session_id' .aether/data/COLONY_STATE.json)" "{approved_intent}"`
315
+
316
+ 6. Skip to Step 8 (display result). Do NOT write COLONY_STATE.json from template, do NOT write constraints.json, do NOT write pheromones.json.
317
+
318
+ **If fresh init:**
319
+
320
+ 1. Initialize QUEEN.md (already done in Step 2)
321
+ 2. Write charter content via charter-write (same command as above)
322
+ 3. Auto-apply approved pheromone suggestions (see pheromone auto-apply below).
323
+ 4. Write COLONY_STATE.json from template:
324
+ - Generate a session ID in the format `session_{unix_timestamp}_{random}` and an ISO-8601 UTC timestamp
325
+ - Resolve template: check `~/.aether/system/templates/colony-state.template.json` first, then `.aether/templates/colony-state.template.json`
326
+ - If no template found: output "Template missing: colony-state.template.json. Run aether update to fix." and stop
327
+ - Read the template file. Follow its `_instructions` field
328
+ - Replace placeholders: `__GOAL__` with approved intent, `__SESSION_ID__` with generated session ID, `__ISO8601_TIMESTAMP__` with current timestamp, `__PHASE_LEARNINGS__` with `[]`, `__INSTINCTS__` with `[]`
329
+ - Remove ALL keys starting with underscore
330
+ - Write the resulting JSON to `.aether/data/COLONY_STATE.json` using the Write tool
331
+
332
+ 5. **Verify the write** — read back and confirm COLONY_STATE.json is valid and goal is set:
333
+ ```bash
334
+ verify_goal=$(jq -r '.goal' .aether/data/COLONY_STATE.json 2>/dev/null)
335
+ verify_valid=$(jq -e . .aether/data/COLONY_STATE.json >/dev/null 2>&1 && echo "valid" || echo "invalid")
336
+ if [[ "$verify_valid" != "valid" || "$verify_goal" == "null" || -z "$verify_goal" ]]; then
337
+ echo "ERROR: Colony state write verification failed (valid=$verify_valid, goal=$verify_goal)"
338
+ echo "The colony file may be corrupted. Remove .aether/data/COLONY_STATE.json and re-run /ant:init."
339
+ stop
340
+ fi
341
+ echo "Colony state verified: goal=\"$verify_goal\""
342
+ ```
343
+
344
+ 6. Write constraints.json from template:
345
+ - Resolve template: check `~/.aether/system/templates/constraints.template.json` first, then `.aether/templates/constraints.template.json`
346
+ - If no template found: output "Template missing: constraints.template.json. Run aether update to fix." and stop
347
+ - Read template, follow `_instructions`, remove `_` prefixed keys, write to `.aether/data/constraints.json`
348
+
349
+ 7. Initialize runtime files from templates (non-blocking):
350
+ ```bash
351
+ for template in pheromones midden learning-observations; do
352
+ if [[ "$template" == "midden" ]]; then
353
+ target=".aether/data/midden/midden.json"
354
+ else
355
+ target=".aether/data/${template}.json"
356
+ fi
357
+ if [[ ! -f "$target" ]]; then
358
+ template_file=""
359
+ for path in ~/.aether/system/templates/${template}.template.json .aether/templates/${template}.template.json; do
360
+ if [[ -f "$path" ]]; then
361
+ template_file="$path"
362
+ break
363
+ fi
364
+ done
365
+ if [[ -n "$template_file" ]]; then
366
+ jq 'with_entries(select(.key | startswith("_") | not))' "$template_file" > "$target" 2>/dev/null || true
367
+ fi
368
+ fi
369
+ done
370
+ ```
371
+
372
+ 8. Run `bash .aether/aether-utils.sh context-update init "{approved_intent}"`
373
+ 9. Run `bash .aether/aether-utils.sh validate-state colony`
374
+ 10. Register repo (silent on failure):
375
+ ```bash
376
+ domain_tags=$(bash .aether/aether-utils.sh domain-detect 2>/dev/null | jq -r '.result.tags // ""' || echo "")
377
+ bash .aether/aether-utils.sh registry-add "$(pwd)" "$(jq -r '.version // "unknown"' ~/.aether/version.json 2>/dev/null || echo 'unknown')" --goal "{approved_intent}" --active true --tags "$domain_tags" 2>/dev/null || true
378
+ cp ~/.aether/version.json .aether/version.json 2>/dev/null || true
379
+ ```
380
+ 11. Install clash detection hook and merge driver (non-blocking):
381
+ ```bash
382
+ # Install PreToolUse hook to detect file conflicts across worktrees
383
+ bash .aether/aether-utils.sh clash-setup --install 2>/dev/null || true
384
+ # Register lockfile merge driver (keeps "ours" on package-lock.json conflicts)
385
+ git config merge.lockfile.driver "bash .aether/utils/merge-driver-lockfile.sh %O %A %B" 2>/dev/null || true
386
+ ```
387
+ 12. Seed QUEEN.md from hive (non-blocking):
388
+ ```bash
389
+ domain_tags=$(jq -r --arg repo "$(pwd)" \
390
+ '[.repos[] | select(.path == $repo) | .domain_tags // []] | .[0] // [] | join(",")' \
391
+ "$HOME/.aether/registry.json" 2>/dev/null || echo "")
392
+ seed_args="queen-seed-from-hive --limit 5"
393
+ [[ -n "$domain_tags" ]] && seed_args="$seed_args --domain $domain_tags"
394
+ seed_result=$(bash .aether/aether-utils.sh $seed_args 2>/dev/null || echo '{}')
395
+ seeded_count=$(echo "$seed_result" | jq -r '.result.seeded // 0' 2>/dev/null || echo "0")
396
+ ```
397
+ 13. Run `bash .aether/aether-utils.sh session-init "{session_id}" "{approved_intent}"`
398
+
399
+ **Pheromone auto-apply (referenced by both re-init and fresh init paths above):**
400
+
401
+ If approved pheromone suggestions exist (the user kept them in the prompt and didn't remove them during the approval loop):
402
+
403
+ For each approved pheromone suggestion, call:
404
+ ```bash
405
+ bash .aether/aether-utils.sh pheromone-write "{type}" '{content}' --source "system:init" --reason '{reason}' --ttl "30d" 2>/dev/null || true
406
+ ```
407
+
408
+ Implementation notes:
409
+ - Claude (the LLM executing init.md) tracks which pheromones the user kept, edited, or removed during the approval loop (Step 6). Only emit pheromones that survived approval.
410
+ - Use single quotes around pheromone content and reason to avoid shell metacharacter issues (per pitfall 4).
411
+ - Each `pheromone-write` call uses `2>/dev/null || true` to make it non-blocking -- a failed write should never stop colony creation.
412
+ - The `--source "system:init"` tag identifies these as init-derived pheromones.
413
+ - The `--ttl "30d"` gives suggestions a 30-day lifespan (project-level conventions, not phase-specific).
414
+ - `pheromone-write` handles deduplication via content hashing -- if a signal with the same content already exists, it will reinforce rather than duplicate.
415
+
416
+ ### Step 7.5: Import Previous Colony Data (optional)
417
+
418
+ Check if previous colony chambers contain importable XML data:
419
+
420
+ ```bash
421
+ # Find most recent chamber with XML files (per D-07)
422
+ latest_chamber=$(ls -d .aether/chambers/20* 2>/dev/null | sort -r | head -1)
423
+ xml_import_available=false
424
+ import_summary=""
425
+
426
+ if [[ -n "$latest_chamber" ]]; then
427
+ xml_count=$(find "$latest_chamber" -maxdepth 1 -name "*.xml" ! -name "colony-archive.xml" 2>/dev/null | wc -l | tr -d ' ')
428
+ if [[ "$xml_count" -gt 0 ]] && command -v xmllint >/dev/null 2>&1; then
429
+ xml_import_available=true
430
+ chamber_name=$(basename "$latest_chamber")
431
+ # Count importable items for display
432
+ signal_count=$(jq '.signals | length' "$latest_chamber/pheromones.json" 2>/dev/null || echo "0")
433
+ import_summary="Found ${signal_count} signal(s) and ${xml_count} XML file(s) from colony '${chamber_name}'"
434
+ fi
435
+ fi
436
+ ```
437
+
438
+ **If xml_import_available is true:**
439
+
440
+ Display the import offer (per D-08):
441
+ ```
442
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
443
+ PREVIOUS COLONY DATA FOUND
444
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
445
+
446
+ {import_summary}
447
+
448
+ Import signals and wisdom from this colony?
449
+ This will add to (not replace) your current colony data.
450
+
451
+ Import? (yes/no)
452
+ ```
453
+
454
+ Use `AskUserQuestion` with yes/no options.
455
+
456
+ **If user selects "yes":**
457
+
458
+ Import ALL available data types (per D-09 -- no cherry-picking):
459
+
460
+ ```bash
461
+ # Import pheromones (per D-09)
462
+ if [[ -f "$latest_chamber/pheromones.xml" ]]; then
463
+ pher_import=$(bash .aether/aether-utils.sh pheromone-import-xml "$latest_chamber/pheromones.xml" "imported" 2>/dev/null || echo '{"ok":false}')
464
+ pher_imported=$(echo "$pher_import" | jq -r '.result.imported // 0' 2>/dev/null || echo "0")
465
+ echo "Pheromones: ${pher_imported} signal(s) imported"
466
+ fi
467
+
468
+ # Import wisdom to queen-wisdom.json (per D-09)
469
+ if [[ -f "$latest_chamber/queen-wisdom.xml" ]]; then
470
+ wis_import=$(bash .aether/aether-utils.sh wisdom-import-xml "$latest_chamber/queen-wisdom.xml" ".aether/data/queen-wisdom.json" 2>/dev/null || echo '{"ok":false}')
471
+ wis_imported=$(echo "$wis_import" | jq -r '.result.imported // 0' 2>/dev/null || echo "0")
472
+ echo "Wisdom: ${wis_imported} entries(s) imported to queen-wisdom.json"
473
+ fi
474
+
475
+ # Import registry lineage (per D-09)
476
+ if [[ -f "$latest_chamber/colony-registry.xml" ]]; then
477
+ reg_import=$(bash .aether/aether-utils.sh registry-import-xml "$latest_chamber/colony-registry.xml" 2>/dev/null || echo '{"ok":false}')
478
+ reg_imported=$(echo "$reg_import" | jq -r '.result.imported // 0' 2>/dev/null || echo "0")
479
+ echo "Registry: ${reg_imported} colon(ies) lineage imported"
480
+ fi
481
+ ```
482
+
483
+ All imports are non-blocking -- log warning and continue if any fails.
484
+
485
+ **If user selects "no":**
486
+
487
+ Display "Import skipped. Starting fresh colony." and proceed to Step 8.
488
+
489
+ **If xml_import_available is false (no chambers, no XML, or no xmllint):**
490
+
491
+ Skip silently -- proceed directly to Step 8 without any mention of import (per D-11).
492
+ ### Step 8: Display Result
493
+
494
+ Display the success header and result block:
495
+
496
+ ```
497
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
498
+ A E T H E R C O L O N Y
499
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
500
+
501
+ Queen has set the colony's intention
502
+
503
+ "{approved_intent}"
504
+
505
+ Colony Status: READY
506
+
507
+ {If re-init: " Mode: Re-init (charter updated, state preserved)"}
508
+ {If fresh and seeded_count > 0: " Hive wisdom: {seeded_count} cross-colony pattern(s) seeded into QUEEN.md"}
509
+
510
+ State persisted -- safe to /clear, then run /ant:plan
511
+
512
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
513
+ Next Up
514
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
515
+ /ant:plan Generate execution plan
516
+ /ant:status Check colony state
517
+ /ant:focus Set initial focus
518
+ ```
@@ -0,0 +1,111 @@
1
+ <!-- Generated from .aether/commands/insert-phase.yaml - DO NOT EDIT DIRECTLY -->
2
+ ---
3
+ name: ant:insert-phase
4
+ description: "➕🐜 Insert a corrective phase into the active plan"
5
+ ---
6
+
7
+ ### Step -1: Normalize Arguments
8
+
9
+ Run: `normalized_args=$(bash .aether/aether-utils.sh normalize-args "$@")`
10
+
11
+ This ensures arguments work correctly in both Claude Code and OpenCode. Use `$normalized_args` throughout this command.
12
+
13
+ You are the **Queen**. Insert a new corrective phase without forcing the user to provide flags.
14
+
15
+ ## Instructions
16
+
17
+ ### Step 1: Validate Colony State
18
+
19
+ Read `.aether/data/COLONY_STATE.json`.
20
+
21
+ If `goal` is null:
22
+ `No colony initialized. Run /ant:init first.`
23
+ Stop.
24
+
25
+ If `milestone` == `"Crowned Anthill"`:
26
+ `This colony has been sealed. Start a new colony with /ant:init "new goal".`
27
+ Stop.
28
+
29
+ If `plan.phases` is empty:
30
+ `No project plan. Run /ant:plan first.`
31
+ Stop.
32
+
33
+ Determine:
34
+ - `current_phase`
35
+ - `total_phases`
36
+ - `current_phase_name` (if available)
37
+
38
+ ### Step 2: Collect Minimal Input
39
+
40
+ This command is designed to work with no arguments.
41
+
42
+ If `$normalized_args` is non-empty:
43
+ - Use `$normalized_args` as the issue summary.
44
+ - Skip the first question.
45
+
46
+ Otherwise ask:
47
+ ```text
48
+ What is not working and needs a corrective phase?
49
+ ```
50
+
51
+ Then ask:
52
+ ```text
53
+ What should the inserted phase accomplish?
54
+ ```
55
+
56
+ Then ask (optional):
57
+ ```text
58
+ Any hard constraints to enforce while fixing this? (or say "none")
59
+ ```
60
+
61
+ If constraints answer is `none` (case-insensitive), treat constraints as empty.
62
+
63
+ ### Step 3: Derive Phase Name
64
+
65
+ Create a concise phase name from the user goal:
66
+ - Start with `Stabilize`
67
+ - Add a short noun phrase from the goal (max 6 words)
68
+ - Keep under 80 characters
69
+
70
+ Example:
71
+ - Goal: `Fix retry flow and stop duplicate requests`
72
+ - Name: `Stabilize retry flow and duplicate requests`
73
+
74
+ ### Step 4: Insert Phase Safely
75
+
76
+ Run:
77
+
78
+ ```bash
79
+ bash .aether/aether-utils.sh phase-insert "<phase_name>" "<goal_text>" "<constraints_text>"
80
+ ```
81
+
82
+ Parse JSON result:
83
+ - If `ok != true`, display error and stop.
84
+ - Extract `inserted_phase_id` and `after_phase`.
85
+
86
+ ### Step 5: Confirm Outcome
87
+
88
+ Display:
89
+
90
+ ```text
91
+ Inserted corrective phase successfully.
92
+ New phase: <inserted_phase_id> — <phase_name>
93
+ Inserted after phase: <after_phase>
94
+ Goal: <goal_text>
95
+ ```
96
+
97
+ If constraints were provided, also display:
98
+ ```text
99
+ Constraints captured: <constraints_text>
100
+ ```
101
+
102
+ ### Step 6: Next Up
103
+
104
+ Show:
105
+
106
+ ```text
107
+ Next steps:
108
+ /ant:phase <inserted_phase_id> Review inserted phase details
109
+ /ant:build <inserted_phase_id> Execute corrective phase
110
+ /ant:status Verify updated plan state
111
+ ```