aether-colony 1.1.9 → 1.1.11

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.
@@ -464,6 +464,10 @@ EOF
464
464
  elif [[ "$c_type" == "focus" ]]; then
465
465
  sed -i.bak "/^## 💭 Active Pheromones/,/^## /{ /^| Signal |/a\\
466
466
  | FOCUS | $c_message | normal |
467
+ }" "$ctx_file" && rm -f "$ctx_file.bak"
468
+ elif [[ "$c_type" == "feedback" ]]; then
469
+ sed -i.bak "/^## 💭 Active Pheromones/,/^## /{ /^| Signal |/a\\
470
+ | FEEDBACK | $c_message | low |
467
471
  }" "$ctx_file" && rm -f "$ctx_file.bak"
468
472
  fi
469
473
 
@@ -499,6 +503,14 @@ EOF
499
503
  ' "$ctx_file" > "$ctx_tmp"
500
504
 
501
505
  mv "$ctx_tmp" "$ctx_file"
506
+
507
+ # Auto-emit FEEDBACK pheromone for the decision so builders see it
508
+ bash "$0" pheromone-write FEEDBACK "Decision: $decision — $rationale" \
509
+ --strength 0.65 \
510
+ --source "system:decision" \
511
+ --reason "Auto-emitted from architectural decision" \
512
+ --ttl "30d" 2>/dev/null || true
513
+
502
514
  json_ok "{\"updated\":true,\"action\":\"decision\"}"
503
515
  ;;
504
516
 
@@ -5274,6 +5286,14 @@ $updated_meta
5274
5286
 
5275
5287
  promote_result=$(bash "$0" queen-promote "$wisdom_type" "$content" "$colony_name" 2>/dev/null || echo '{}')
5276
5288
  if echo "$promote_result" | jq -e '.ok == true' >/dev/null 2>&1; then
5289
+ # Also create an instinct from the promoted learning
5290
+ bash "$0" instinct-create \
5291
+ --trigger "When working on $wisdom_type patterns" \
5292
+ --action "$content" \
5293
+ --confidence 0.6 \
5294
+ --domain "$wisdom_type" \
5295
+ --source "promoted_from_learning" \
5296
+ --evidence "Auto-promoted after $observation_count observations" 2>/dev/null || true
5277
5297
  json_ok "{\"promoted\":true,\"mode\":\"auto\",\"policy_threshold\":$policy_threshold,\"observation_count\":$observation_count,\"colony_count\":$colony_count,\"event_type\":\"$event_type\"}"
5278
5298
  else
5279
5299
  promote_msg=$(echo "$promote_result" | jq -r '.error.message // "promotion_failed"' 2>/dev/null || echo "promotion_failed")
@@ -7132,6 +7152,123 @@ $updated_meta
7132
7152
  fi
7133
7153
  ;;
7134
7154
 
7155
+ instinct-create)
7156
+ # Create or update an instinct in COLONY_STATE.json
7157
+ # Usage: instinct-create --trigger "when X" --action "do Y" --confidence 0.5 --domain "architecture" --source "phase-3" --evidence "observation"
7158
+ # Deduplicates: if trigger+action matches existing instinct, boosts confidence instead
7159
+ # Cap: max 30 instincts, evicts lowest confidence when exceeded
7160
+
7161
+ ic_trigger=""
7162
+ ic_action=""
7163
+ ic_confidence="0.5"
7164
+ ic_domain="workflow"
7165
+ ic_source=""
7166
+ ic_evidence=""
7167
+
7168
+ while [[ $# -gt 0 ]]; do
7169
+ case "$1" in
7170
+ --trigger) ic_trigger="$2"; shift 2 ;;
7171
+ --action) ic_action="$2"; shift 2 ;;
7172
+ --confidence) ic_confidence="$2"; shift 2 ;;
7173
+ --domain) ic_domain="$2"; shift 2 ;;
7174
+ --source) ic_source="$2"; shift 2 ;;
7175
+ --evidence) ic_evidence="$2"; shift 2 ;;
7176
+ *) shift ;;
7177
+ esac
7178
+ done
7179
+
7180
+ [[ -z "$ic_trigger" ]] && json_err "$E_VALIDATION_FAILED" "instinct-create requires --trigger"
7181
+ [[ -z "$ic_action" ]] && json_err "$E_VALIDATION_FAILED" "instinct-create requires --action"
7182
+
7183
+ ic_state_file="$DATA_DIR/COLONY_STATE.json"
7184
+ [[ -f "$ic_state_file" ]] || json_err "$E_FILE_NOT_FOUND" "COLONY_STATE.json not found. Run /ant:init first."
7185
+
7186
+ # Validate confidence range
7187
+ if ! [[ "$ic_confidence" =~ ^(0(\.[0-9]+)?|1(\.0+)?)$ ]]; then
7188
+ ic_confidence="0.5"
7189
+ fi
7190
+
7191
+ ic_now=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
7192
+ ic_epoch=$(date +%s)
7193
+ ic_id="instinct_${ic_epoch}"
7194
+
7195
+ # Check for existing instinct with matching trigger+action (fuzzy: exact substring match)
7196
+ ic_existing=$(jq -c --arg trigger "$ic_trigger" --arg action "$ic_action" '
7197
+ [(.memory.instincts // [])[] | select(.trigger == $trigger and .action == $action)] | first // null
7198
+ ' "$ic_state_file" 2>/dev/null)
7199
+
7200
+ if [[ -n "$ic_existing" && "$ic_existing" != "null" ]]; then
7201
+ # Update existing: boost confidence by +0.1, increment applications
7202
+ ic_updated=$(jq --arg trigger "$ic_trigger" --arg action "$ic_action" --arg now "$ic_now" '
7203
+ .memory.instincts = [
7204
+ (.memory.instincts // [])[] |
7205
+ if .trigger == $trigger and .action == $action then
7206
+ .confidence = ([(.confidence + 0.1), 1.0] | min) |
7207
+ .applications = ((.applications // 0) + 1) |
7208
+ .last_applied = $now
7209
+ else
7210
+ .
7211
+ end
7212
+ ]
7213
+ ' "$ic_state_file" 2>/dev/null)
7214
+
7215
+ if [[ -n "$ic_updated" ]]; then
7216
+ atomic_write "$ic_state_file" "$ic_updated"
7217
+ ic_new_conf=$(echo "$ic_updated" | jq --arg trigger "$ic_trigger" --arg action "$ic_action" '
7218
+ [(.memory.instincts // [])[] | select(.trigger == $trigger and .action == $action)] | first | .confidence // 0
7219
+ ' 2>/dev/null)
7220
+ json_ok "{\"instinct_id\":\"existing\",\"action\":\"updated\",\"confidence\":$ic_new_conf}"
7221
+ else
7222
+ json_err "$E_INTERNAL" "Failed to update existing instinct"
7223
+ fi
7224
+ else
7225
+ # Create new instinct
7226
+ ic_new_instinct=$(jq -n \
7227
+ --arg id "$ic_id" \
7228
+ --arg trigger "$ic_trigger" \
7229
+ --arg action "$ic_action" \
7230
+ --argjson confidence "$ic_confidence" \
7231
+ --arg status "hypothesis" \
7232
+ --arg domain "$ic_domain" \
7233
+ --arg source "$ic_source" \
7234
+ --arg evidence "$ic_evidence" \
7235
+ --arg created_at "$ic_now" \
7236
+ '{
7237
+ id: $id,
7238
+ trigger: $trigger,
7239
+ action: $action,
7240
+ confidence: $confidence,
7241
+ status: $status,
7242
+ domain: $domain,
7243
+ source: $source,
7244
+ evidence: [$evidence],
7245
+ tested: false,
7246
+ created_at: $created_at,
7247
+ last_applied: null,
7248
+ applications: 0,
7249
+ successes: 0,
7250
+ failures: 0
7251
+ }')
7252
+
7253
+ # Add instinct, enforce 30-instinct cap (evict lowest confidence)
7254
+ ic_updated=$(jq --argjson new_instinct "$ic_new_instinct" '
7255
+ .memory.instincts = (
7256
+ ((.memory.instincts // []) + [$new_instinct])
7257
+ | sort_by(-.confidence)
7258
+ | .[:30]
7259
+ )
7260
+ ' "$ic_state_file" 2>/dev/null)
7261
+
7262
+ if [[ -n "$ic_updated" ]]; then
7263
+ atomic_write "$ic_state_file" "$ic_updated"
7264
+ json_ok "{\"instinct_id\":\"$ic_id\",\"action\":\"created\",\"confidence\":$ic_confidence}"
7265
+ else
7266
+ json_err "$E_INTERNAL" "Failed to create instinct"
7267
+ fi
7268
+ fi
7269
+ exit 0
7270
+ ;;
7271
+
7135
7272
  pheromone-prime)
7136
7273
  # Combine active pheromone signals and learned instincts into a prompt-ready block
7137
7274
  # Usage: pheromone-prime [--compact] [--max-signals N] [--max-instincts N]
@@ -9183,10 +9320,10 @@ EOF
9183
9320
  exit 0
9184
9321
  fi
9185
9322
 
9186
- # Extract failures, sort by created_at descending, limit results
9323
+ # Extract failures from .entries[], sort by timestamp descending, limit results
9187
9324
  result=$(jq --argjson limit "$limit" '{
9188
- "count": ([.signals[]? | select(.type == "failure")] | length),
9189
- "failures": ([.signals[]? | select(.type == "failure")] | sort_by(.created_at) | reverse | [.[:$limit][] | {created_at, source, context, content: .content.text}])
9325
+ "count": ([.entries[]?] | length),
9326
+ "failures": ([.entries[]?] | sort_by(.timestamp) | reverse | .[:$limit] | [.[] | {timestamp, category, source, message}])
9190
9327
  }' "$midden_file" 2>/dev/null)
9191
9328
 
9192
9329
  if [[ -z "$result" ]]; then
@@ -259,6 +259,19 @@ Run using the Bash tool with description "Marking build start...": `bash .aether
259
259
  Before dispatching each worker, refresh colony context so new pheromones/memory are visible:
260
260
  Run using the Bash tool with description "Refreshing colony context...": `prime_result=$(bash .aether/aether-utils.sh colony-prime --compact 2>/dev/null)` and update `prompt_section` from `prime_result.result.prompt_section`.
261
261
 
262
+ **PER WAVE:** Query midden for recent failures to inject into builder context:
263
+ Run using the Bash tool with description "Checking midden for recent failures...":
264
+ `midden_result=$(bash .aether/aether-utils.sh midden-recent-failures 5 2>/dev/null || echo '{"count":0,"failures":[]}')`
265
+
266
+ Parse `midden_result`. If `count > 0`, format as `midden_context`:
267
+ ```
268
+ **Previous Failures (from colony midden):**
269
+ - [{category}] {message} (source: {source}, {timestamp})
270
+ ...
271
+ ```
272
+
273
+ If `count == 0`, set `midden_context` to empty.
274
+
262
275
  > **Platform note**: In Claude Code, use `Task tool with subagent_type`. In OpenCode, use the equivalent agent spawning mechanism for your platform (e.g., invoke the agent definition from `.opencode/agents/`).
263
276
 
264
277
  For each Wave 1 task, use Task tool with `subagent_type="aether-builder"`, include `description: "🔨 Builder {Ant-Name}: {task_description}"` (DO NOT use run_in_background - multiple Task calls in a single message run in parallel and block until complete):
@@ -289,6 +302,12 @@ Goal: "{colony_goal}"
289
302
 
290
303
  { grave_context if exists }
291
304
 
305
+ { midden_context if exists }
306
+
307
+ **Midden Context (if provided):**
308
+ - These are previous failures from this colony. Avoid repeating these patterns.
309
+ - If a failure is related to your task, take extra care or try a different approach.
310
+
292
311
  **External Integration Context (if provided by Ambassador):**
293
312
  If integration_plan is provided above, you MUST:
294
313
  1. Follow the implementation_steps in order
@@ -79,50 +79,28 @@ Update COLONY_STATE.json:
79
79
 
80
80
  Memory capture also auto-emits a FEEDBACK pheromone and attempts auto-promotion when recurrence policy is met.
81
81
 
82
- 3. **Extract instincts from patterns:**
82
+ 3. **Extract instincts from phase patterns:**
83
83
 
84
- Read activity.log for patterns from this phase's build.
84
+ Review the completed phase for repeating patterns. For each pattern observed:
85
85
 
86
- For each pattern observed (success, error_resolution, user_feedback):
87
-
88
- **If pattern matches existing instinct:**
89
- - Update confidence: +0.1 for success outcome, -0.1 for failure
90
- - Increment applications count
91
- - Update last_applied timestamp
92
-
93
- **If new pattern:**
94
- - Create new instinct with initial confidence:
95
- - success: 0.4
96
- - error_resolution: 0.5
97
- - user_feedback: 0.7
98
-
99
- Append to `memory.instincts`:
100
- ```json
101
- {
102
- "id": "instinct_<unix_timestamp>",
103
- "trigger": "<when X>",
104
- "action": "<do Y>",
105
- "confidence": 0.5,
106
- "status": "hypothesis",
107
- "domain": "<testing|architecture|code-style|debugging|workflow>",
108
- "source": "phase-<id>",
109
- "evidence": ["<specific observation that led to this>"],
110
- "tested": false,
111
- "created_at": "<ISO-8601>",
112
- "last_applied": null,
113
- "applications": 0,
114
- "successes": 0,
115
- "failures": 0
116
- }
86
+ Run using the Bash tool with description "Creating instinct from pattern...":
87
+ ```bash
88
+ bash .aether/aether-utils.sh instinct-create \
89
+ --trigger "<when this situation arises>" \
90
+ --action "<what worked or should be done>" \
91
+ --confidence <0.4-0.7 based on evidence> \
92
+ --domain "<testing|architecture|code-style|debugging|workflow>" \
93
+ --source "phase-{id}" \
94
+ --evidence "<specific observation>" 2>/dev/null || true
117
95
  ```
118
96
 
119
- **Instinct confidence updates:**
120
- - Success when applied: +0.1, increment `successes`
121
- - Failure when applied: -0.15, increment `failures`
122
- - If `failures` >= 2 and `successes` == 0: mark `status: "disproven"`
123
- - If `successes` >= 2 and tested: mark `status: "validated"`
97
+ Confidence guidelines:
98
+ - 0.4: success pattern (worked once)
99
+ - 0.5: error_resolution (fixed a problem)
100
+ - 0.7: user_feedback (explicit guidance)
124
101
 
125
- Cap: Keep max 30 instincts (remove lowest confidence when exceeded).
102
+ If pattern matches existing instinct, confidence will be boosted automatically.
103
+ Cap: max 30 instincts enforced by `instinct-create` (lowest confidence evicted).
126
104
 
127
105
  4. **Advance state:**
128
106
  - Set `current_phase` to next phase number
@@ -19,10 +19,11 @@ This only applies to genuinely new conversations, not after /clear.
19
19
 
20
20
  ## Available Commands
21
21
 
22
- ### Getting Started
22
+ ### Setup & Getting Started
23
23
  | Command | Purpose |
24
24
  |---------|---------|
25
- | `/ant:init "<goal>"` | Set colony intention and initialize |
25
+ | `/ant:lay-eggs` | Set up Aether in this repo (one-time, creates .aether/) |
26
+ | `/ant:init "<goal>"` | Start a colony with a goal |
26
27
  | `/ant:colonize` | Analyze existing codebase |
27
28
  | `/ant:plan` | Generate project phases |
28
29
  | `/ant:build <phase>` | Execute a phase with parallel workers |
@@ -75,19 +76,28 @@ This only applies to genuinely new conversations, not after /clear.
75
76
  ## Typical Workflow
76
77
 
77
78
  ```
78
- /ant:init "Build feature X" → Set colony goal
79
- /ant:colonize → Understand existing code (optional)
80
- /ant:plan → Generate phases
81
- /ant:focus "security" → Steer attention (optional)
82
- /ant:build 1 → Execute phase 1
83
- /ant:continue → Verify, learn, advance
84
- /ant:build 2 → Execute phase 2
85
- ...repeat until complete...
86
- /ant:seal → Seal completed colony
79
+ First time in a repo:
80
+ 0. /ant:lay-eggs (set up Aether in this repo)
81
+
82
+ Starting a colony:
83
+ 1. /ant:init "Build feature X" (start colony with a goal)
84
+ 2. /ant:colonize (if existing code)
85
+ 3. /ant:plan (generates phases)
86
+ 4. /ant:focus "security" (optional guidance)
87
+ 5. /ant:build 1 (workers execute phase 1)
88
+ 6. /ant:continue (verify, learn, advance)
89
+ 7. /ant:build 2 (repeat until complete)
90
+
91
+ After /clear or session break:
92
+ 8. /ant:resume-colony (restore full context)
93
+ 9. /ant:status (see where you left off)
94
+
95
+ After completing a colony:
96
+ 10. /ant:seal (mark as complete)
97
+ 11. /ant:entomb (archive to chambers)
98
+ 12. /ant:init "next project goal" (start fresh colony)
87
99
  ```
88
100
 
89
- After `/clear` or session break: `/ant:resume-colony` to restore context.
90
-
91
101
  ## Worker Castes
92
102
 
93
103
  Workers are assigned to castes based on task type:
@@ -48,6 +48,13 @@ User feedback is high-value learning. Generate ISO-8601 timestamp and append to
48
48
 
49
49
  Write COLONY_STATE.json.
50
50
 
51
+ ### Step 2.5: Update Context Document
52
+
53
+ Run using the Bash tool with description "Updating context document...":
54
+ ```bash
55
+ bash .aether/aether-utils.sh context-update constraint feedback "<content>" "user" 2>/dev/null || true
56
+ ```
57
+
51
58
  ### Step 3: Get Active Counts
52
59
 
53
60
  Run using the Bash tool with description "Counting active signals...":
@@ -30,6 +30,13 @@ bash .aether/aether-utils.sh pheromone-write FOCUS "<content>" --strength 0.8 --
30
30
 
31
31
  Parse the returned JSON for the signal ID.
32
32
 
33
+ ### Step 2.5: Update Context Document
34
+
35
+ Run using the Bash tool with description "Updating context document...":
36
+ ```bash
37
+ bash .aether/aether-utils.sh context-update constraint focus "<content>" "user" 2>/dev/null || true
38
+ ```
39
+
33
40
  ### Step 3: Get Active Counts
34
41
 
35
42
  Run using the Bash tool with description "Counting active signals...":
@@ -16,9 +16,10 @@ Output the following:
16
16
  A multi-agent system built on ant colony intelligence.
17
17
  Workers self-organize via pheromone signals. You guide with intention.
18
18
 
19
- GETTING STARTED
19
+ SETUP & GETTING STARTED
20
20
 
21
- /ant:init "<goal>" Set colony intention and initialize
21
+ /ant:lay-eggs Set up Aether in this repo (one-time, creates .aether/)
22
+ /ant:init "<goal>" Start a colony with a goal
22
23
  /ant:colonize Analyze existing codebase (optional)
23
24
  /ant:plan Generate project plan
24
25
  /ant:build <phase> Execute a phase (spawns parallel workers)
@@ -53,7 +54,6 @@ COLONY LIFECYCLE
53
54
 
54
55
  /ant:seal Seal colony with Crowned Anthill milestone
55
56
  /ant:entomb Archive completed colony into chambers
56
- /ant:lay-eggs Lay first eggs of new colony (First Eggs milestone)
57
57
  /ant:history Browse colony event history
58
58
 
59
59
  ADVANCED
@@ -75,7 +75,11 @@ MAINTENANCE
75
75
 
76
76
  TYPICAL WORKFLOW
77
77
 
78
- 1. /ant:init "Build a REST API with auth"
78
+ First time in a repo:
79
+ 0. /ant:lay-eggs (set up Aether in this repo)
80
+
81
+ Starting a colony:
82
+ 1. /ant:init "Build a REST API with auth" (start colony with a goal)
79
83
  2. /ant:colonize (if existing code)
80
84
  3. /ant:plan (generates phases)
81
85
  4. /ant:focus "security" (optional guidance)
@@ -87,6 +91,11 @@ TYPICAL WORKFLOW
87
91
  8. /ant:resume-colony (restore full context)
88
92
  9. /ant:status (see where you left off)
89
93
 
94
+ After completing a colony:
95
+ 10. /ant:seal (mark as complete)
96
+ 11. /ant:entomb (archive to chambers)
97
+ 12. /ant:init "next project goal" (start fresh colony)
98
+
90
99
  WORKER CASTES
91
100
 
92
101
  👑 Queen — orchestrates, spawns workers, synthesizes results
@@ -64,57 +64,26 @@ Aether Colony
64
64
 
65
65
  Stop here. Do not proceed.
66
66
 
67
- ### Step 1.5: Bootstrap System Files (Conditional)
67
+ ### Step 1.5: Verify Aether Setup
68
68
 
69
69
  Check if `.aether/aether-utils.sh` exists using the Read tool.
70
70
 
71
- **If the file already exists** — skip this step entirely. System files are present.
71
+ **If the file already exists** — skip this step entirely. Aether is set up.
72
72
 
73
73
  **If the file does NOT exist:**
74
- - Check if `~/.aether/system/aether-utils.sh` exists (expand `~` to the user's home directory)
75
- - **If the hub exists:** Run using the Bash tool:
76
- ```bash
77
- mkdir -p \
78
- .aether/data \
79
- .aether/data/midden \
80
- .aether/data/backups \
81
- .aether/data/survey \
82
- .aether/dreams \
83
- .aether/chambers \
84
- .aether/locks \
85
- .aether/temp \
86
- .aether/docs \
87
- .aether/utils \
88
- .aether/templates \
89
- .aether/schemas \
90
- .aether/exchange \
91
- .aether/rules \
92
- .claude/rules && \
93
- cp -f ~/.aether/system/aether-utils.sh .aether/ && \
94
- cp -f ~/.aether/system/workers.md .aether/ 2>/dev/null || true && \
95
- cp -f ~/.aether/system/CONTEXT.md .aether/ 2>/dev/null || true && \
96
- cp -f ~/.aether/system/model-profiles.yaml .aether/ 2>/dev/null || true && \
97
- cp -Rf ~/.aether/system/docs/* .aether/docs/ 2>/dev/null || true && \
98
- cp -Rf ~/.aether/system/utils/* .aether/utils/ 2>/dev/null || true && \
99
- cp -Rf ~/.aether/system/templates/* .aether/templates/ 2>/dev/null || true && \
100
- cp -Rf ~/.aether/system/schemas/* .aether/schemas/ 2>/dev/null || true && \
101
- cp -Rf ~/.aether/system/exchange/* .aether/exchange/ 2>/dev/null || true && \
102
- cp -Rf ~/.aether/system/rules/* .claude/rules/ 2>/dev/null || true && \
103
- touch .aether/dreams/.gitkeep && \
104
- touch .aether/chambers/.gitkeep && \
105
- touch .aether/data/midden/.gitkeep && \
106
- chmod +x .aether/aether-utils.sh
107
- ```
108
- This copies system files from the global hub into `.aether/` and creates all required directories upfront. Display:
109
- ```
110
- Bootstrapped system files from global hub.
111
- ```
112
- - **If the hub does NOT exist:** Output:
113
- ```
114
- No Aether system files found locally or in ~/.aether/system/.
115
- Run `aether install` or `npx aether-colony install` to set up the global hub first.
116
- ```
117
- Stop here. Do not proceed.
74
+ ```
75
+ Aether is not set up in this repo yet.
76
+
77
+ Run /ant:lay-eggs first to create the .aether/ directory
78
+ with all system files, then run /ant:init "your goal" to
79
+ start a colony.
80
+
81
+ If the global hub isn't installed either:
82
+ npm install -g aether-colony (installs the hub)
83
+ /ant:lay-eggs (sets up this repo)
84
+ /ant:init "your goal" (starts the colony)
85
+ ```
86
+ Stop here. Do not proceed.
118
87
 
119
88
  ### Step 1.6: Initialize QUEEN.md Wisdom Document
120
89