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
@@ -0,0 +1,399 @@
1
+ # Aether Colony System - Comprehensive Review Report
2
+
3
+ **Research Date:** 2026-02-14
4
+ **Researcher:** Oracle Ant
5
+ **Iterations:** 9
6
+ **Confidence Level:** 95%
7
+
8
+ ---
9
+
10
+ ## Executive Summary
11
+
12
+ This report presents a comprehensive read-only review of the Aether colony system. The system is a sophisticated multi-agent framework with 34 slash commands, 4 OpenCode agents, a comprehensive CLI, and extensive utility functions. While the architecture is well-designed, several critical issues have been identified that impact functionality and consistency.
13
+
14
+ ### Key Findings
15
+
16
+ 1. **State Inconsistency**: The colony state shows "INITIALIZING" but phase 7 is marked "completed"
17
+ 2. **Path Inconsistency**: HANDOFF.md is written to `.aether/HANDOFF.md` but read from `HANDOFF.md`
18
+ 3. **Subagent Type Mismatch**: plan.md uses "general-purpose" but the system expects "general"
19
+ 4. **Missing State Fields**: References to milestone and workers fields that don't exist in COLONY_STATE.json
20
+
21
+ ---
22
+
23
+ ## Core Components Overview
24
+
25
+ ### 1. Slash Commands (34 commands)
26
+ **Location:** `/Users/callumcowie/repos/Aether/.claude/commands/ant/`
27
+
28
+ The slash commands form the primary user interface for the colony system:
29
+
30
+ **Lifecycle Commands:**
31
+ - `init.md` - Initialize colony with goal
32
+ - `plan.md` - Generate project plan (50-iteration research loop)
33
+ - `build.md` - Execute phase with workers
34
+ - `continue.md` - Complete phase and advance (6-phase verification loop)
35
+ - `pause-colony.md` - Save session state
36
+ - `resume-colony.md` - Restore session state
37
+ - `status.md` - Display colony status
38
+
39
+ **Management Commands:**
40
+ - `flags.md` - Manage blockers/issues/notes
41
+ - `watch.md` - Real-time activity monitoring
42
+ - `swarm.md` - Parallel bug investigation
43
+ - `oracle.md` - Deep research (this command)
44
+
45
+ ### 2. OpenCode Agents (4 agents)
46
+ **Location:** `/Users/callumcowie/repos/Aether/.opencode/agents/`
47
+
48
+ - `aether-queen.md` - Orchestrator agent
49
+ - `aether-builder.md` - Implementation agent
50
+ - `aether-scout.md` - Research agent
51
+ - `aether-watcher.md` - Verification agent
52
+
53
+ **Note:** These agents exist but are not integrated with the slash command system.
54
+
55
+ ### 3. CLI (Node.js)
56
+ **Location:** `/Users/callumcowie/repos/Aether/bin/cli.js`
57
+
58
+ Comprehensive CLI with 17 library modules:
59
+ - `errors.js` - Structured error handling
60
+ - `file-lock.js` - Concurrent access control
61
+ - `model-profiles.js` - Model selection and routing
62
+ - `telemetry.js` - Usage tracking
63
+ - `state-sync.js` - State reconciliation
64
+ - `update-transaction.js` - Atomic updates with rollback
65
+
66
+ ### 4. Utility Layer (Bash)
67
+ **Location:** `/Users/callumcowie/repos/Aether/.aether/aether-utils.sh`
68
+
69
+ 50+ subcommands for colony operations:
70
+ - State management (load-state, unload-state, validate-state)
71
+ - Error handling (error-add, error-pattern-check, error-summary)
72
+ - Activity logging (activity-log, spawn-log, spawn-complete)
73
+ - Flag management (flag-add, flag-check-blockers, flag-list)
74
+ - Model profiles (model-profile, model-get, model-list)
75
+
76
+ ### 5. State Files
77
+ **Location:** `/Users/callumcowie/repos/Aether/.aether/data/`
78
+
79
+ - `COLONY_STATE.json` - Unified colony state (v3.0)
80
+ - `constraints.json` - Focus and constraint signals
81
+ - `flags.json` - Blockers, issues, and notes
82
+ - `activity.log` - Activity stream
83
+ - `spawn-tree.txt` - Worker spawn tracking
84
+ - `telemetry.json` - Model performance data
85
+
86
+ ---
87
+
88
+ ## Critical Issues (Require Immediate Attention)
89
+
90
+ ### 1. State Inconsistency
91
+ **Severity:** HIGH
92
+ **Location:** `.aether/data/COLONY_STATE.json:4`
93
+
94
+ **Problem:**
95
+ The state field is set to "INITIALIZING" but the current_phase is 7 with status "completed". According to the state machine defined in status.md (line 124), valid states are: IDLE, READY, EXECUTING, PLANNING.
96
+
97
+ **Current State:**
98
+ ```json
99
+ {
100
+ "state": "INITIALIZING",
101
+ "current_phase": 7,
102
+ "plan": {
103
+ "phases": [
104
+ {"number": 7, "name": "Core Reliability", "status": "completed"}
105
+ ]
106
+ }
107
+ }
108
+ ```
109
+
110
+ **Fix Required:**
111
+ Update the state field to reflect actual status:
112
+ ```json
113
+ {
114
+ "state": "READY"
115
+ }
116
+ ```
117
+
118
+ ### 2. HANDOFF.md Path Inconsistency
119
+ **Severity:** HIGH
120
+ **Location:** Multiple command files
121
+
122
+ **Problem:**
123
+ - `pause-colony.md` (line 38): Writes to `.aether/HANDOFF.md`
124
+ - `continue.md`, `plan.md`, `status.md`: Look for `HANDOFF.md` in root
125
+
126
+ This breaks the pause/resume functionality.
127
+
128
+ **Files Affected:**
129
+ - `.claude/commands/ant/pause-colony.md`
130
+ - `.claude/commands/ant/continue.md`
131
+ - `.claude/commands/ant/plan.md`
132
+ - `.claude/commands/ant/status.md`
133
+ - `.claude/commands/ant/resume-colony.md`
134
+
135
+ **Fix Required:**
136
+ Standardize all references to `.aether/HANDOFF.md`:
137
+
138
+ ```bash
139
+ # In continue.md, plan.md, status.md - change:
140
+ Read HANDOFF.md
141
+ # To:
142
+ Read .aether/HANDOFF.md
143
+
144
+ # In resume-colony.md - change:
145
+ rm -f .aether/HANDOFF.md
146
+ # (This is already correct, just verify)
147
+ ```
148
+
149
+ ### 3. Subagent Type Mismatch
150
+ **Severity:** HIGH
151
+ **Location:** `.claude/commands/ant/plan.md:126`
152
+
153
+ **Problem:**
154
+ plan.md spawns scouts with `subagent_type="general-purpose"` but the OpenCode agents use `subagent_type: "general"` (see aether-queen.md line 45).
155
+
156
+ **Current Code:**
157
+ ```markdown
158
+ Spawn Research Ant (Scout) via Task tool with subagent_type="general-purpose":
159
+ ```
160
+
161
+ **Fix Required:**
162
+ Change to match the working pattern:
163
+ ```markdown
164
+ Spawn Research Ant (Scout) via Task tool with subagent_type="general":
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Medium Priority Issues
170
+
171
+ ### 4. Pause-Colony Step Numbering Error
172
+ **Severity:** MEDIUM
173
+ **Location:** `.claude/commands/ant/pause-colony.md:72-82`
174
+
175
+ **Problem:**
176
+ Step 4.6 (Set Paused Flag) appears before Step 4.5 (Commit Suggestion) in the document, causing confusion about execution order.
177
+
178
+ **Fix Required:**
179
+ Swap the step numbers:
180
+ - Step 4.5: Set Paused Flag
181
+ - Step 4.6: Commit Suggestion (Optional)
182
+
183
+ ### 5. Resume-Colony References Non-Existent Workers Field
184
+ **Severity:** MEDIUM
185
+ **Location:** `.claude/commands/ant/resume-colony.md:70-79`
186
+
187
+ **Problem:**
188
+ The command displays worker status from a `workers` object that doesn't exist in COLONY_STATE.json.
189
+
190
+ **Current Display Logic:**
191
+ ```markdown
192
+ WORKERS
193
+ If ALL workers have "idle" status, display:
194
+ All 6 workers idle -- colony ready
195
+ ```
196
+
197
+ **Fix Required:**
198
+ Either:
199
+ 1. Add workers tracking to COLONY_STATE.json schema, OR
200
+ 2. Remove the workers display section from resume-colony.md
201
+
202
+ ### 6. Status.md References Non-Existent Milestone Field
203
+ **Severity:** MEDIUM
204
+ **Location:** `.claude/commands/ant/status.md:127-128`
205
+
206
+ **Problem:**
207
+ The command references `milestone` and `milestone_updated_at` fields that don't exist in COLONY_STATE.json.
208
+
209
+ **Fix Required:**
210
+ Either:
211
+ 1. Add milestone tracking fields to COLONY_STATE.json:
212
+ ```json
213
+ {
214
+ "milestone": "First Mound",
215
+ "milestone_updated_at": "2026-02-14T00:00:00Z"
216
+ }
217
+ ```
218
+ 2. OR remove milestone display from status.md
219
+
220
+ ### 7. Hardcoded Proxy Auth Token
221
+ **Severity:** MEDIUM
222
+ **Location:** `.aether/model-profiles.yaml:99`
223
+
224
+ **Problem:**
225
+ The LiteLLM proxy auth token is hardcoded as 'sk-litellm-local'.
226
+
227
+ **Current:**
228
+ ```yaml
229
+ proxy:
230
+ endpoint: 'http://localhost:4000'
231
+ auth_token: sk-litellm-local
232
+ ```
233
+
234
+ **Fix Required:**
235
+ Use environment variable with fallback:
236
+ ```yaml
237
+ proxy:
238
+ endpoint: 'http://localhost:4000'
239
+ auth_token: ${LITELLM_AUTH_TOKEN:-sk-litellm-local}
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Low Priority Issues
245
+
246
+ ### 8. Test Flags Pollution
247
+ **Severity:** LOW
248
+ **Location:** `.aether/data/flags.json`
249
+
250
+ **Problem:**
251
+ 8 test flags from development are still present in the production data file.
252
+
253
+ **Fix Required:**
254
+ Archive test flags or reset flags.json:
255
+ ```bash
256
+ # Option 1: Archive
257
+ mv .aether/data/flags.json .aether/data/flags.json.backup.$(date +%s)
258
+ echo '{"version": 1, "flags": []}' > .aether/data/flags.json
259
+
260
+ # Option 2: Keep only unresolved flags
261
+ ```
262
+
263
+ ### 9. Verify-Castes.md Caste List Sync
264
+ **Severity:** LOW
265
+ **Location:** `.claude/commands/ant/verify-castes.md`
266
+
267
+ **Problem:**
268
+ The caste list in verify-castes.md may not match the full workers.md specification.
269
+
270
+ **Fix Required:**
271
+ Compare caste list with `.aether/workers.md` and sync any differences.
272
+
273
+ ---
274
+
275
+ ## Missing Features / Gaps
276
+
277
+ ### Gap 1: Signal/Pheromone Management
278
+ **Impact:** MEDIUM
279
+ **Location:** COLONY_STATE.json has "signals" array
280
+
281
+ **Problem:**
282
+ The COLONY_STATE.json has a "signals" array for pheromone signals, but no command manages it directly.
283
+
284
+ **Suggested Solution:**
285
+ Create `/ant:signal` command for CRUD operations:
286
+ - `/ant:signal add <type> <content>` - Add signal
287
+ - `/ant:signal list` - List active signals
288
+ - `/ant:signal decay <id>` - Mark signal for decay
289
+
290
+ ### Gap 2: Milestone Tracking
291
+ **Impact:** MEDIUM
292
+
293
+ **Problem:**
294
+ The milestone system is defined (6 milestones) but not tracked in state.
295
+
296
+ **Suggested Solution:**
297
+ Add to COLONY_STATE.json:
298
+ ```json
299
+ {
300
+ "milestone": "First Mound",
301
+ "milestone_updated_at": "2026-02-14T00:00:00Z"
302
+ }
303
+ ```
304
+
305
+ ### Gap 3: Worker Tracking
306
+ **Impact:** LOW
307
+
308
+ **Problem:**
309
+ resume-colony.md references workers but no tracking exists.
310
+
311
+ **Suggested Solution:**
312
+ Either add workers object to state or remove from display:
313
+ ```json
314
+ {
315
+ "workers": {
316
+ "builder": {"status": "idle"},
317
+ "watcher": {"status": "idle"}
318
+ }
319
+ }
320
+ ```
321
+
322
+ ### Gap 4: OpenCode Integration
323
+ **Impact:** LOW
324
+
325
+ **Problem:**
326
+ OpenCode agents exist but are not integrated with slash commands.
327
+
328
+ **Suggested Solution:**
329
+ Either:
330
+ 1. Integrate agents into slash command workflow, OR
331
+ 2. Deprecate and remove OpenCode agents if not needed
332
+
333
+ ---
334
+
335
+ ## Architecture Strengths
336
+
337
+ 1. **State Versioning**: Auto-upgrade from v1.0/v2.0 to v3.0
338
+ 2. **Concurrency Control**: File locking with load-state/unload-state pattern
339
+ 3. **Atomic Updates**: update-transaction.js with rollback capability
340
+ 4. **Observability**: Comprehensive logging (activity.log, spawn-tree.txt, telemetry.json)
341
+ 5. **Quality Gates**: 6-phase verification loop in continue.md
342
+ 6. **Model Routing**: Task-based routing to appropriate models
343
+ 7. **Error Handling**: Structured errors with recovery suggestions
344
+
345
+ ---
346
+
347
+ ## Actionable Fix Checklist
348
+
349
+ ### Immediate (HIGH Priority)
350
+ - [ ] Fix COLONY_STATE.json state field: "INITIALIZING" → "READY"
351
+ - [ ] Standardize HANDOFF.md path in all commands to `.aether/HANDOFF.md`
352
+ - [ ] Change plan.md subagent_type from "general-purpose" to "general"
353
+
354
+ ### Short-term (MEDIUM Priority)
355
+ - [ ] Fix pause-colony.md step numbering (4.5/4.6 swap)
356
+ - [ ] Add milestone fields to COLONY_STATE.json OR remove from status.md
357
+ - [ ] Add workers field to COLONY_STATE.json OR remove from resume-colony.md
358
+ - [ ] Use environment variable for proxy auth token
359
+
360
+ ### Long-term (LOW Priority)
361
+ - [ ] Clean up test flags from flags.json
362
+ - [ ] Create /ant:signal command for pheromone management
363
+ - [ ] Sync verify-castes.md with workers.md
364
+ - [ ] Evaluate OpenCode agent integration
365
+
366
+ ---
367
+
368
+ ## File Paths Reference
369
+
370
+ ### Critical Files
371
+ - `/Users/callumcowie/repos/Aether/.aether/data/COLONY_STATE.json` - Colony state
372
+ - `/Users/callumcowie/repos/Aether/.aether/data/flags.json` - Flags data
373
+ - `/Users/callumcowie/repos/Aether/.aether/model-profiles.yaml` - Model configuration
374
+
375
+ ### Command Files
376
+ - `/Users/callumcowie/repos/Aether/.claude/commands/ant/init.md`
377
+ - `/Users/callumcowie/repos/Aether/.claude/commands/ant/plan.md`
378
+ - `/Users/callumcowie/repos/Aether/.claude/commands/ant/build.md`
379
+ - `/Users/callumcowie/repos/Aether/.claude/commands/ant/continue.md`
380
+ - `/Users/callumcowie/repos/Aether/.claude/commands/ant/pause-colony.md`
381
+ - `/Users/callumcowie/repos/Aether/.claude/commands/ant/resume-colony.md`
382
+ - `/Users/callumcowie/repos/Aether/.claude/commands/ant/status.md`
383
+
384
+ ### System Files
385
+ - `/Users/callumcowie/repos/Aether/.aether/aether-utils.sh` - Utility layer
386
+ - `/Users/callumcowie/repos/Aether/bin/cli.js` - CLI entry point
387
+ - `/Users/callumcowie/repos/Aether/.aether/workers.md` - Worker specifications
388
+
389
+ ---
390
+
391
+ ## Conclusion
392
+
393
+ The Aether colony system is a well-architected framework with sophisticated state management, quality controls, and observability. The identified issues are primarily consistency problems rather than fundamental design flaws. With the fixes outlined in this report, the system should operate reliably and maintain data integrity across all components.
394
+
395
+ **Estimated Fix Time:** 2-4 hours for all HIGH and MEDIUM priority issues.
396
+
397
+ ---
398
+
399
+ *Report generated by Oracle Ant - Aether Colony Research System*
@@ -0,0 +1,164 @@
1
+ # Command Sync Strategy
2
+
3
+ This document describes how Aether slash commands are distributed to Claude Code and OpenCode, and the bulletproof sync mechanisms that ensure consistency.
4
+
5
+ ---
6
+
7
+ ## Distribution Model
8
+
9
+ ### Claude Code: Global Sync
10
+
11
+ Aether commands are synced to the global Claude Code config directory:
12
+
13
+ ```
14
+ ~/.claude/commands/ant/
15
+ ```
16
+
17
+ This is done via `aether install` which copies commands from the npm package to the global location. The sync uses **hash-based comparison** to only copy files that have changed.
18
+
19
+ ### OpenCode: Repo-Local Only
20
+
21
+ OpenCode **does not** have a global discovery mechanism for slash commands. Commands must exist in the repo-local directory:
22
+
23
+ ```
24
+ .opencode/commands/ant/
25
+ ```
26
+
27
+ This is why Aether maintains parallel command directories:
28
+ - `.claude/commands/ant/` — Claude Code commands
29
+ - `.opencode/commands/ant/` — OpenCode commands (repo-local)
30
+
31
+ ---
32
+
33
+ ## Why the Strategies Differ
34
+
35
+ | Feature | Claude Code | OpenCode |
36
+ |---------|-------------|----------|
37
+ | Global command discovery | Yes (`~/.claude/commands/`) | No |
38
+ | Repo-local commands | Supported | Required |
39
+ | Namespace isolation | `/ant:` prefix | `/ant:` prefix |
40
+
41
+ **Key insight:** OpenCode's architecture requires repo-local commands. There is no equivalent to `~/.claude/commands/` that provides automatic slash command discovery. This is a fundamental platform difference.
42
+
43
+ ---
44
+
45
+ ## Hash-Based Idempotent Sync
46
+
47
+ The sync system in `bin/cli.js` uses **hash comparison before copying**:
48
+
49
+ ```javascript
50
+ // Hash comparison: only copy if file doesn't exist or hash differs
51
+ let shouldCopy = true;
52
+ if (fs.existsSync(destPath)) {
53
+ const srcHash = hashFileSync(srcPath);
54
+ const destHash = hashFileSync(destPath);
55
+ if (srcHash === destHash) {
56
+ shouldCopy = false;
57
+ skipped++;
58
+ }
59
+ }
60
+
61
+ if (shouldCopy) {
62
+ fs.copyFileSync(srcPath, destPath);
63
+ }
64
+ ```
65
+
66
+ **Why this matters:**
67
+ - **Idempotent:** Running `aether install` multiple times produces the same result
68
+ - **Efficient:** Unchanged files are skipped (visible in logs as "skipped")
69
+ - **Bulletproof:** No unnecessary writes reduce the risk of corruption
70
+
71
+ ---
72
+
73
+ ## Environment Variable Validation
74
+
75
+ Before constructing any paths that use the user's home directory, the code validates the HOME environment variable:
76
+
77
+ ```javascript
78
+ const HOME = process.env.HOME || process.env.USERPROFILE;
79
+ if (!HOME) {
80
+ console.error('Error: HOME environment variable is not set');
81
+ console.error('Please ensure HOME or USERPROFILE is defined');
82
+ process.exit(1);
83
+ }
84
+
85
+ // Now safe to use
86
+ const COMMANDS_DEST = path.join(HOME, '.claude', 'commands', 'ant');
87
+ ```
88
+
89
+ **Why this matters:**
90
+ - Prevents crashes on systems where HOME is not set
91
+ - Provides clear error message instead of cryptic path errors
92
+ - Supports both Unix-like systems (HOME) and Windows (USERPROFILE)
93
+
94
+ ---
95
+
96
+ ## Verification Commands
97
+
98
+ ### Check Sync Status
99
+
100
+ To verify commands are in sync between Claude Code and OpenCode within the repo:
101
+
102
+ ```bash
103
+ ./bin/generate-commands.sh check
104
+ ```
105
+
106
+ This performs two passes:
107
+ 1. **Pass 1:** File count and name comparison
108
+ 2. **Pass 2:** SHA-1 hash comparison for content-level drift detection
109
+
110
+ ### Verify Global Installation
111
+
112
+ To verify global Claude Code commands are installed:
113
+
114
+ ```bash
115
+ ls ~/.claude/commands/ant/
116
+ ```
117
+
118
+ ### Verify Global OpenCode Commands
119
+
120
+ To verify global OpenCode commands (if previously synced):
121
+
122
+ ```bash
123
+ ls ~/.config/opencode/commands/ant/
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Sync Workflow
129
+
130
+ ```
131
+ ┌─────────────────┐
132
+ │ Write commands │
133
+ │ in .claude/ │
134
+ └────────┬────────┘
135
+
136
+
137
+ ┌─────────────────────────────────────┐
138
+ │ aether install │
139
+ │ (syncs to ~/.claude/commands/ant/)│
140
+ └────────┬────────────────────────────┘
141
+
142
+
143
+ ┌─────────────────────────────────────┐
144
+ │ Hash-based copy │
145
+ │ (only copies if hash differs) │
146
+ └─────────────────────────────────────┘
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Anti-Patterns to Avoid
152
+
153
+ 1. **Unconditional copy:** Never copy files without checking if they changed
154
+ 2. **Skip hash comparison:** Always use hash comparison for idempotency
155
+ 3. **Ignore HOME validation:** Always validate HOME before path construction
156
+ 4. **Assume OpenCode global:** OpenCode does not support global command discovery
157
+
158
+ ---
159
+
160
+ ## See Also
161
+
162
+ - `bin/cli.js` — Implementation of hash-based sync
163
+ - `bin/generate-commands.sh` — Repo-level sync verification
164
+ - `.aether/docs/namespace.md` — Namespace isolation strategy
@@ -0,0 +1,89 @@
1
+ # Implementation Learnings
2
+
3
+ Valuable findings from Aether v3.1 development that apply to other projects.
4
+
5
+ ## Workflow Patterns
6
+
7
+ 1. **Claude Code global sync** works by copying commands from `.claude/commands/` to `~/.claude/commands/`
8
+ - This enables sharing commands across all projects
9
+ - Source of truth is the repo, hub is the distribution mechanism
10
+
11
+ 2. **OpenCode requires repo-local setup**
12
+ - Each repo that wants ant commands must set them up locally
13
+ - Unlike Claude Code, there's no global command directory
14
+
15
+ 3. **Hash comparison prevents unnecessary file writes**
16
+ - Comparing SHA-1 hashes before writes preserves file timestamps
17
+ - Reduces git noise from unchanged files
18
+
19
+ 4. **Namespace isolation via 'ant:' prefix**
20
+ - Prevents collisions with other agents
21
+ - Creates clear command ownership
22
+
23
+ 5. **CLI sync verification catches content drift**
24
+ - `generate-commands.sh check` uses SHA-1 checksums
25
+ - Detects when .claude/ and .opencode/ mirrors diverge
26
+
27
+ ## Error Handling Patterns
28
+
29
+ - Use `json_err "$E_*" "message"` consistently (not bare strings)
30
+ - Always release locks in error paths (use trap or explicit release)
31
+ - Validate JSON before atomic writes
32
+ - Use fallback json_err for backward compatibility
33
+
34
+ ## File Operation Patterns
35
+
36
+ - Use `atomic_write()` for all state modifications
37
+ - Acquire locks before reading/writing shared state
38
+ - Create backups BEFORE validation for true atomicity
39
+ - Use temp file + mv pattern for atomic operations
40
+
41
+ ## Model Routing Patterns
42
+
43
+ - Validate LiteLLM proxy health before spawning
44
+ - Support CLI --model override for one-time changes
45
+ - Log actual model used per spawn for telemetry
46
+ - Use task-based routing keywords for automatic selection
47
+
48
+ ## Codebase Patterns Discovered
49
+
50
+ ### Pattern 1: JSON Error Response Standard
51
+ All commands output JSON with `{"ok": true/false, "result": ...}` or `{"ok": false, "error": ...}`
52
+
53
+ ### Pattern 2: Feature Degradation Pattern
54
+ ```bash
55
+ if type feature_enabled &>/dev/null && ! feature_enabled "file_locking"; then
56
+ json_warn "W_DEGRADED" "File locking disabled - proceeding without lock"
57
+ else
58
+ acquire_lock ...
59
+ fi
60
+ ```
61
+
62
+ ### Pattern 3: Atomic Write Pattern
63
+ All state modifications use `atomic_write()` from atomic-write.sh (temp file + mv)
64
+
65
+ ### Pattern 4: Trap-based Cleanup
66
+ file-lock.sh uses `trap cleanup_locks EXIT TERM INT` for lock cleanup
67
+
68
+ ### Pattern 5: Inconsistent Error Code Evolution
69
+ Commands added early use hardcoded strings; commands added later use `$E_VALIDATION_FAILED` constant. This creates inconsistency that should be standardized.
70
+
71
+ ## Connections Between Issues
72
+
73
+ 1. **BUG-005** (flag-auto-resolve lock leak) and **BUG-002** (flag-add lock leak) share the same root cause: inconsistent error handling patterns
74
+ 2. **BUG-004** and **ISSUE-001** are the same issue: missing error code constants
75
+ 3. **ISSUE-004** (template path) affects **GAP-006** (missing docs) - both relate to queen-* command usability
76
+ 4. **BUG-001** (awk apostrophes) affects the same lines that use Pattern 2 (feature degradation)
77
+
78
+ ## Fix Priority Matrix
79
+
80
+ | Priority | Issues | Effort | Impact |
81
+ |----------|--------|--------|--------|
82
+ | Critical | BUG-005, BUG-011 | Low | Deadlock prevention |
83
+ | High | BUG-002, BUG-008 | Low | Lock safety |
84
+ | Medium | BUG-003, BUG-006, BUG-007 | Medium | Code quality |
85
+ | Low | ISSUE-001 through ISSUE-007 | Medium | Consistency |
86
+
87
+ ---
88
+
89
+ *Preserved from Phase 0 cleanup - 2026-02-15*