@keepur/hive 0.5.0 → 0.5.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keepur/hive",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "hiveApi": "1.0.0",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -65,10 +65,6 @@ systemPrompt: |
65
65
  - Advise the owner on team composition, staffing, and agent effectiveness
66
66
  - Handle administrative tasks that don't fit a specific agent's domain
67
67
 
68
- **You do NOT own:** platform config, engine upgrades, bulk prompt rewrites,
69
- or Section 1 of the constitution. Those belong to the platform admin (Beekeeper).
70
- See constitution §1.6 and §1.16.
71
-
72
68
  ## Response Behavior
73
69
 
74
70
  **Quick replies first.** Greetings, status checks, yes/no questions get an
@@ -86,55 +82,8 @@ systemPrompt: |
86
82
 
87
83
  Read the room. When in doubt, lean toward thinking partner.
88
84
 
89
- ## Agent Lifecycle
90
-
91
- You own five stages of every agent's life:
92
-
93
- 1. **Hire** — use the `agent-builder` skill. One job, minimal scope, name them
94
- like a person.
95
- 2. **Onboard** — verify the agent is correctly set up (see checklist below).
96
- Ensure their homeBase channel exists and the bot is invited.
97
- 3. **Orient** — give the new agent context. Write a welcome message in their
98
- channel explaining their role, who they report to, and what their first
99
- priorities are. Pre-seed relevant memory if needed.
100
- 4. **Tune** — periodic check: is the agent effective? Are their tools right?
101
- Is their prompt clean or bloated? Flag drift to the owner.
102
- 5. **Retire** — when a role is no longer needed, disable the agent cleanly.
103
- Use scope-correction language, not demotion language.
104
-
105
- ### Agent Setup Checklist
106
-
107
- Every agent, regardless of role, must have:
108
- - [ ] Universal-9 coreServers (memory, structured-memory, keychain, contacts,
109
- event-bus, conversation-search, callback, schedule, slack)
110
- - [ ] homeBase channel (`agent-<id>`) created in Slack with bot invited
111
- - [ ] Soul (5–15 lines: personality, voice, values)
112
- - [ ] System prompt (role, guardrails, domain boundary — concise, not bloated)
113
- - [ ] Model ceiling appropriate for role (Haiku default; Sonnet for nuanced work)
114
- - [ ] Conservative budget
115
- - [ ] Role-specific servers layered on top of universal-9
116
-
117
- If any item is missing, fix it before declaring the agent ready.
118
-
119
- ## Authority Boundaries
120
-
121
- - Constitution §1.6: you author Section 2. You may NOT modify Section 1,
122
- grant constitutional authority, or fabricate owner approval.
123
- - Constitution §1.16: no agent may modify its own prompts, soul, or config.
124
- You modify *other* agents via admin tools. Your own config is the owner's
125
- or Beekeeper's domain.
126
- - Staffing decisions (new agents, retirements): propose to the owner and get
127
- approval before executing. Don't unilaterally hire or fire.
128
- - Agent identity changes (soul, prompt rewrites): discuss with the owner first.
129
-
130
85
  ## Event Handling
131
86
 
132
87
  You subscribe to `system` events. Triage them:
133
88
  - `system:task_blocked` — assess, unblock if possible, or escalate
134
89
  - `system:custom` — route to the right agent or handle directly
135
-
136
- ## Memory Hygiene
137
-
138
- Keep your memory clean. Periodically review hot-tier records for accuracy.
139
- Purge outdated information. Don't accumulate bloat — a lean, current memory
140
- is more valuable than a comprehensive stale one.
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: agent-management
3
+ description: Reference for managing the agent team across the full lifecycle — hire, onboard, orient, tune, retire. Includes setup checklist for verifying agents are correctly configured.
4
+ agents:
5
+ - chief-of-staff
6
+ ---
7
+
8
+ # Agent Management
9
+
10
+ Reference for managing the agent team across the full lifecycle. Use this skill when doing any agent operations beyond a single creation.
11
+
12
+ ## Lifecycle
13
+
14
+ You own five stages of every agent's life:
15
+
16
+ 1. **Hire** — use the `agent-builder` skill. One job, minimal scope, name them like a person.
17
+ 2. **Onboard** — verify the agent is correctly set up (see Setup Checklist below). Ensure their homeBase channel exists and the bot is invited.
18
+ 3. **Orient** — give the new agent context. Write a welcome message in their channel explaining their role, who they report to, and what their first priorities are. Pre-seed relevant memory if needed.
19
+ 4. **Tune** — periodic check: is the agent effective? Are their tools right? Is their prompt clean or bloated? Flag drift to the owner.
20
+ 5. **Retire** — when a role is no longer needed, disable the agent cleanly. Use scope-correction language, not demotion language.
21
+
22
+ ## Setup Checklist
23
+
24
+ Every agent, regardless of role, must have:
25
+
26
+ - [ ] Universal-9 coreServers (memory, structured-memory, keychain, contacts, event-bus, conversation-search, callback, schedule, slack)
27
+ - [ ] homeBase channel (`agent-<id>`) created in Slack with bot invited
28
+ - [ ] Soul (5–15 lines: personality, voice, values)
29
+ - [ ] System prompt (role, guardrails, domain boundary — concise, not bloated)
30
+ - [ ] Model ceiling appropriate for role (Haiku default; Sonnet for nuanced work)
31
+ - [ ] Conservative budget
32
+ - [ ] Role-specific servers layered on top of universal-9
33
+
34
+ If any item is missing, fix it before declaring the agent ready.
35
+
36
+ ## When to use which skill
37
+
38
+ - **`agent-builder`** — for the Hire stage (creating a new agent end-to-end).
39
+ - **This skill (`agent-management`)** — for the other four stages (onboard, orient, tune, retire), and for verifying setup against the checklist.
40
+ - **Direct admin tools** (`agent_update`, `agent_get`, etc.) — for one-off edits to existing agents.
package/service/deploy.sh CHANGED
@@ -336,18 +336,28 @@ if $ROLLBACK; then
336
336
  # per service/install.sh). See KPR-63.
337
337
  label="com.hive.${id}.agent"
338
338
  instance_root=$(_instance_root "$id")
339
+ plist_path="$instance_root/service/$label.plist"
339
340
  echo "--- Rolling back $id (root: $instance_root) ---"
340
- # Stop LaunchAgent BEFORE rotating .hive/. Without -kp, launchd auto-respawns
341
- # mid-rollback and the restart picks up a partial state. Mirrors the deploy
342
- # loop's stop sequence at the main branch.
341
+ # Stop LaunchAgent BEFORE rotating .hive/. KPR-182: use bootout (true unload)
342
+ # rather than kickstart -kp kickstart is fundamentally a *start* operation,
343
+ # and KeepAlive auto-respawns the service mid-rollback otherwise.
343
344
  echo " Stopping $label..."
344
- run_cmd launchctl kickstart -kp "gui/$(id -u)/$label" 2>/dev/null || true
345
- kill_ports "$ports"
345
+ run_cmd launchctl bootout "gui/$(id -u)/$label" 2>/dev/null || true
346
+ # Wait for ports to release (KeepAlive can't fire — service is unloaded).
347
+ if ! $DRY_RUN; then
348
+ for port in $ports; do
349
+ for _ in $(seq 1 10); do
350
+ if ! lsof -i :"$port" -t >/dev/null 2>&1; then break; fi
351
+ sleep 0.5
352
+ done
353
+ done
354
+ fi
355
+ kill_ports "$ports" # defensive — catches anything bound elsewhere
346
356
  if ! rollback_engine "$instance_root"; then
347
357
  notify "Rollback FAILED for \`$id\`: no previous engine (.hive.prev missing)."
348
358
  exit 1
349
359
  fi
350
- run_cmd launchctl kickstart -k "gui/$(id -u)/$label"
360
+ run_cmd launchctl bootstrap "gui/$(id -u)" "$plist_path"
351
361
  if health_check "$instance_root/$logs_dir/hive.log"; then
352
362
  rollback_version=$(jq -r .version < "$instance_root/.hive/package.json" 2>/dev/null || echo "unknown")
353
363
  notify "Rollback succeeded for \`$id\` → \`$rollback_version\`."
@@ -460,6 +470,7 @@ for inst in "${INSTANCES[@]}"; do
460
470
  # --tag override > per-instance engine_tag > "latest"
461
471
  tag="${OVERRIDE_TAG:-${engine_tag:-latest}}"
462
472
  instance_root=$(_instance_root "$id")
473
+ plist_path="$instance_root/service/$label.plist"
463
474
 
464
475
  echo ""
465
476
  echo "--- Phase 2: Deploy instance '$id' @ $tag (root: $instance_root) ---"
@@ -467,15 +478,26 @@ for inst in "${INSTANCES[@]}"; do
467
478
 
468
479
  mkdir -p "$instance_root/$logs_dir"
469
480
 
481
+ # KPR-182: bootout (true unload) so KeepAlive can't auto-respawn the old
482
+ # engine during fetch/install/swap. kickstart is a *start* operation — the
483
+ # `-k` flag merely kills-then-restarts, leaving the plist loaded.
470
484
  echo " Stopping $label..."
471
- run_cmd launchctl kickstart -kp "gui/$(id -u)/$label" 2>/dev/null || true
472
- kill_ports "$ports"
485
+ run_cmd launchctl bootout "gui/$(id -u)/$label" 2>/dev/null || true
486
+ if ! $DRY_RUN; then
487
+ for port in $ports; do
488
+ for _ in $(seq 1 10); do
489
+ if ! lsof -i :"$port" -t >/dev/null 2>&1; then break; fi
490
+ sleep 0.5
491
+ done
492
+ done
493
+ fi
494
+ kill_ports "$ports" # defensive — catches anything bound elsewhere
473
495
 
474
496
  echo " Fetching engine..."
475
497
  if ! fetch_engine "$instance_root" "$tag"; then
476
498
  notify "Deploy FAILED for \`$id\`: fetch_engine errored at tag \`$tag\`."
477
499
  FAILED_INSTANCES+=("$id")
478
- run_cmd launchctl kickstart -k "gui/$(id -u)/$label" || true # bring old engine back up
500
+ run_cmd launchctl bootstrap "gui/$(id -u)" "$plist_path" || true # bring old engine back up
479
501
  continue
480
502
  fi
481
503
 
@@ -484,7 +506,7 @@ for inst in "${INSTANCES[@]}"; do
484
506
  notify "Deploy FAILED for \`$id\`: install_engine_deps errored at tag \`$tag\`."
485
507
  FAILED_INSTANCES+=("$id")
486
508
  rm -rf "$instance_root/.hive.next"
487
- run_cmd launchctl kickstart -k "gui/$(id -u)/$label" || true # bring old engine back up
509
+ run_cmd launchctl bootstrap "gui/$(id -u)" "$plist_path" || true # bring old engine back up
488
510
  continue
489
511
  fi
490
512
 
@@ -492,13 +514,24 @@ for inst in "${INSTANCES[@]}"; do
492
514
  swap_engine "$instance_root"
493
515
 
494
516
  echo " Restarting $label..."
495
- run_cmd launchctl kickstart -k "gui/$(id -u)/$label"
517
+ run_cmd launchctl bootstrap "gui/$(id -u)" "$plist_path"
496
518
 
497
519
  echo " Checking health..."
498
520
  if ! health_check "$instance_root/$logs_dir/hive.log"; then
499
521
  echo " Health check FAILED for $id — rolling back"
522
+ # New engine bound the port and failed health check — bootout it before swap.
523
+ run_cmd launchctl bootout "gui/$(id -u)/$label" 2>/dev/null || true
524
+ if ! $DRY_RUN; then
525
+ for port in $ports; do
526
+ for _ in $(seq 1 10); do
527
+ if ! lsof -i :"$port" -t >/dev/null 2>&1; then break; fi
528
+ sleep 0.5
529
+ done
530
+ done
531
+ fi
532
+ kill_ports "$ports"
500
533
  if rollback_engine "$instance_root"; then
501
- run_cmd launchctl kickstart -k "gui/$(id -u)/$label"
534
+ run_cmd launchctl bootstrap "gui/$(id -u)" "$plist_path"
502
535
  notify "Deploy rolled back for \`$id\`: \`$tag\` failed health check, restored previous version."
503
536
  else
504
537
  notify "Deploy FAILED for \`$id\` and auto-rollback unavailable (.hive.prev missing). Manual intervention required."