Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

feat(daemon): version-resolving launcher survives plugin upgrades (#278)

Aurora Capital161fc592fdfd
diff --git a/claude-ops/scripts/ops-daemon-launcher.sh b/claude-ops/scripts/ops-daemon-launcher.sh
index 6f6e3dd1..2fc1ca7c 100755
--- a/claude-ops/scripts/ops-daemon-launcher.sh
+++ b/claude-ops/scripts/ops-daemon-launcher.sh
@@ -2,6 +2,11 @@
# ops-daemon-launcher.sh — version-agnostic launcher for the claude-ops daemon.
# Resolves the highest installed ops plugin version at run time, then execs its
# ops-daemon.sh. Survives plugin upgrades without plist edits.
+#
+# Why: ops-daemon.sh installs this file at $CACHE_ROOT/ops-daemon-launcher.sh
+# (outside semver dirs) so launchd/systemd paths survive version pruning. It
+# walks the plugin cache, finds the highest semver dir with a valid
+# ops-daemon.sh, and execs it.
set -euo pipefail
CACHE_ROOT="${CLAUDE_PLUGIN_CACHE_ROOT:-$HOME/.claude/plugins/cache/ops-marketplace/ops}"
@@ -14,11 +19,10 @@ fi
# Highest semver dir that contains scripts/ops-daemon.sh
LATEST_VERSION="$(
find "$CACHE_ROOT" -mindepth 1 -maxdepth 1 -type d -print 2>/dev/null \
- | awk -F/ '{print $NF}' \
- | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
- | sort -rV \
+ | awk -F/ '{v=$NF} v ~ /^[0-9]+\.[0-9]+\.[0-9]+$/ {print v}' \
+ | sort -t. -k1,1rn -k2,2rn -k3,3rn \
| while read -r v; do
- if [[ -x "$CACHE_ROOT/$v/scripts/ops-daemon.sh" ]]; then
+ if [[ -r "$CACHE_ROOT/$v/scripts/ops-daemon.sh" ]]; then
echo "$v"; break
fi
done
@@ -33,11 +37,6 @@ DAEMON="$CACHE_ROOT/$LATEST_VERSION/scripts/ops-daemon.sh"
export CLAUDE_PLUGIN_ROOT="$CACHE_ROOT/$LATEST_VERSION"
echo "[ops-daemon-launcher] resolved ops $LATEST_VERSION → $DAEMON"
-# Bash 4+ required for ops-daemon.sh (associative arrays). Mirror install-ops-daemon.sh.
-OPS_EXEC_BASH="/bin/bash"
-if [[ -x /opt/homebrew/bin/bash ]]; then
- OPS_EXEC_BASH="/opt/homebrew/bin/bash"
-elif [[ -x /usr/local/bin/bash ]]; then
- OPS_EXEC_BASH="/usr/local/bin/bash"
-fi
-exec "$OPS_EXEC_BASH" "$DAEMON" "$@"
+# Resolve bash via PATH so this works on Apple Silicon (/opt/homebrew/bin),
+# Intel Mac (/usr/local/bin), and Linux (/usr/bin) without hardcoding.
+exec bash "$DAEMON" "$@"
diff --git a/claude-ops/scripts/ops-daemon.sh b/claude-ops/scripts/ops-daemon.sh
index a3a11d7c..54bb0078 100755
--- a/claude-ops/scripts/ops-daemon.sh
+++ b/claude-ops/scripts/ops-daemon.sh
@@ -24,6 +24,9 @@ SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
[ -r "$SCRIPT_DIR/lib/os-detect.sh" ] && . "$SCRIPT_DIR/lib/os-detect.sh"
DATA_DIR="${OPS_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}"
+# Ops plugin cache: semver version dirs live here; must match ops-daemon-launcher.sh default.
+OPS_PLUGIN_CACHE_ROOT="${CLAUDE_PLUGIN_CACHE_ROOT:-$HOME/.claude/plugins/cache/ops-marketplace/ops}"
+OPS_DAEMON_LAUNCHER_STABLE="$OPS_PLUGIN_CACHE_ROOT/ops-daemon-launcher.sh"
LOG_DIR="$DATA_DIR/logs"
LOG="$LOG_DIR/ops-daemon.log"
SERVICES_CONFIG="$DATA_DIR/daemon-services.json"
@@ -1149,7 +1152,19 @@ except Exception:
# Resolve plugin-root-relative paths for daemon scripts (so the unit files
# embed absolute paths that still work when invoked by another user context).
-OPS_DAEMON_SCRIPT="$SCRIPT_DIR/scripts/ops-daemon.sh"
+#
+# Prefer ops-daemon-launcher.sh when present: it resolves the highest-installed
+# ops plugin version at run time, so service configs survive plugin upgrades.
+# Keep a copy at OPS_PLUGIN_CACHE_ROOT (outside semver dirs) so baked paths
+# are not removed when an old version directory is pruned from the cache.
+if [[ -x "$SCRIPT_DIR/scripts/ops-daemon-launcher.sh" ]]; then
+ mkdir -p "$OPS_PLUGIN_CACHE_ROOT"
+ cp -f "$SCRIPT_DIR/scripts/ops-daemon-launcher.sh" "$OPS_DAEMON_LAUNCHER_STABLE"
+ chmod +x "$OPS_DAEMON_LAUNCHER_STABLE"
+ OPS_DAEMON_SCRIPT="$OPS_DAEMON_LAUNCHER_STABLE"
+else
+ OPS_DAEMON_SCRIPT="$SCRIPT_DIR/scripts/ops-daemon.sh"
+fi
OPS_KEEPALIVE_SCRIPT="$SCRIPT_DIR/scripts/wacli-keepalive.sh"
install_daemon_launchd() {