@keepur/hive 0.2.0 → 0.2.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/install/migrate-0.2.sh +57 -22
- package/package.json +1 -1
- package/pkg/cli.min.js +71 -71
- package/pkg/mcp/admin.min.js +6 -6
- package/pkg/server.min.js +157 -157
package/install/migrate-0.2.sh
CHANGED
|
@@ -168,10 +168,27 @@ preflight() {
|
|
|
168
168
|
exit 0
|
|
169
169
|
fi
|
|
170
170
|
|
|
171
|
-
# Confirm it's 0.1.x
|
|
172
|
-
#
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
# Confirm it's a 0.1.x instance. Three valid shapes:
|
|
172
|
+
# 1. Repo-clone layout: dist/index.js present
|
|
173
|
+
# 2. Instance-git state: .hive/git/ present
|
|
174
|
+
# 3. Global-install layout: plist references a global npm path (not .hive/)
|
|
175
|
+
local is_01x=false
|
|
176
|
+
if [[ -f "$INSTANCE_DIR/dist/index.js" ]]; then
|
|
177
|
+
is_01x=true
|
|
178
|
+
elif [[ -d "$INSTANCE_DIR/.hive/git" ]]; then
|
|
179
|
+
is_01x=true
|
|
180
|
+
else
|
|
181
|
+
# Check if any plist in service/ points at a global npm install (0.1.x global pattern)
|
|
182
|
+
for plist in "$INSTANCE_DIR/service/"*.plist; do
|
|
183
|
+
[[ -f "$plist" ]] || continue
|
|
184
|
+
if grep -q 'node_modules/@keepur/hive/pkg/server.min.js' "$plist" 2>/dev/null; then
|
|
185
|
+
is_01x=true
|
|
186
|
+
break
|
|
187
|
+
fi
|
|
188
|
+
done
|
|
189
|
+
fi
|
|
190
|
+
if ! $is_01x; then
|
|
191
|
+
echo "ERROR: $INSTANCE_DIR doesn't look like 0.1.x (no dist/, .hive/git/, or global-install plist)." >&2
|
|
175
192
|
echo " Manual inspection required — refusing to proceed." >&2
|
|
176
193
|
exit 1
|
|
177
194
|
fi
|
|
@@ -211,7 +228,7 @@ preflight() {
|
|
|
211
228
|
echo "WARNING: the following LaunchAgents are currently loaded:"
|
|
212
229
|
echo " $running"
|
|
213
230
|
echo ""
|
|
214
|
-
read -p "Stop them now via launchctl bootout? [y/N] " reply
|
|
231
|
+
read -p "Stop them now via launchctl bootout? [y/N] " reply </dev/tty
|
|
215
232
|
if [[ "$reply" =~ ^[Yy]$ ]]; then
|
|
216
233
|
for label in $running; do
|
|
217
234
|
launchctl bootout "gui/$(id -u)/$label" 2>/dev/null || true
|
|
@@ -250,19 +267,37 @@ preflight() {
|
|
|
250
267
|
|
|
251
268
|
# Also check for lingering Playwright MCP children — see spec Runtime Failure Mode 6.
|
|
252
269
|
# Skip in dry-run: we're not mutating the instance, so lingering children
|
|
253
|
-
# aren't dangerous
|
|
254
|
-
# (e.g. the operator's own
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
270
|
+
# aren't dangerous. Only check processes whose cwd is under INSTANCE_DIR —
|
|
271
|
+
# a global pgrep picks up unrelated host processes (e.g. the operator's own
|
|
272
|
+
# editor-side Playwright MCP) that have nothing to do with this instance.
|
|
273
|
+
if ! $DRY_RUN; then
|
|
274
|
+
local instance_pids=""
|
|
275
|
+
while IFS= read -r pid; do
|
|
276
|
+
# lsof -a -d cwd: get the current working directory for this PID
|
|
277
|
+
local cwd
|
|
278
|
+
cwd=$(lsof -a -d cwd -p "$pid" -Fn 2>/dev/null | awk '/^n/{print substr($0,2)}')
|
|
279
|
+
if [[ "$cwd" == "$INSTANCE_DIR"* ]]; then
|
|
280
|
+
instance_pids="$instance_pids $pid"
|
|
281
|
+
fi
|
|
282
|
+
done < <(pgrep -f playwright-mcp 2>/dev/null || true)
|
|
283
|
+
|
|
284
|
+
if [[ -n "$instance_pids" ]]; then
|
|
285
|
+
echo "WARNING: playwright-mcp child processes from this instance still running (PIDs:$instance_pids)."
|
|
286
|
+
echo " Waiting up to 5 seconds for them to exit..."
|
|
287
|
+
for _ in 1 2 3 4 5; do
|
|
288
|
+
sleep 1
|
|
289
|
+
local still_running=""
|
|
290
|
+
for pid in $instance_pids; do
|
|
291
|
+
kill -0 "$pid" 2>/dev/null && still_running="$still_running $pid"
|
|
292
|
+
done
|
|
293
|
+
instance_pids="$still_running"
|
|
294
|
+
[[ -z "$instance_pids" ]] && break
|
|
295
|
+
done
|
|
296
|
+
if [[ -n "$instance_pids" ]]; then
|
|
297
|
+
echo "ERROR: playwright-mcp from this instance still running (PIDs:$instance_pids). Kill and retry:" >&2
|
|
298
|
+
echo " kill$instance_pids" >&2
|
|
299
|
+
exit 1
|
|
300
|
+
fi
|
|
266
301
|
fi
|
|
267
302
|
fi
|
|
268
303
|
|
|
@@ -711,7 +746,7 @@ step_regenerate_plists() {
|
|
|
711
746
|
|
|
712
747
|
# 10b. Regenerate one plist per config file.
|
|
713
748
|
# hive.yaml (primary) + any hive-<suffix>.yaml (e.g., hive-personal.yaml).
|
|
714
|
-
# hive daemon
|
|
749
|
+
# `hive start --daemon` reads HIVE_CONFIG, derives the label from that config's
|
|
715
750
|
# instance.id, writes service/<label>.plist, creates the LaunchAgents
|
|
716
751
|
# symlink, and launchctl-loads it (see src/cli/daemon.ts:84 startDaemon).
|
|
717
752
|
local regenerated=0
|
|
@@ -719,9 +754,9 @@ step_regenerate_plists() {
|
|
|
719
754
|
[[ -f "$yaml" ]] || continue
|
|
720
755
|
local cfg
|
|
721
756
|
cfg=$(basename "$yaml")
|
|
722
|
-
echo " hive daemon
|
|
723
|
-
if ! HIVE_HOME="$INSTANCE_DIR" HIVE_CONFIG="$cfg" hive daemon
|
|
724
|
-
echo "ERROR: hive daemon
|
|
757
|
+
echo " hive start --daemon (HIVE_CONFIG=$cfg)"
|
|
758
|
+
if ! HIVE_HOME="$INSTANCE_DIR" HIVE_CONFIG="$cfg" hive start --daemon; then
|
|
759
|
+
echo "ERROR: hive start --daemon failed for $cfg." >&2
|
|
725
760
|
return 1
|
|
726
761
|
fi
|
|
727
762
|
regenerated=$((regenerated + 1))
|