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.
Shell agent-teamsai-agentai-automationanthropicautonomous-agentawsbusiness-operationsclaudeclaude-codeclaude-code-plugindevopsecommerceinbox-zeroklaviyomarketingmcpmorning-briefingpr-automationshopifyterminal
fix: wacli decommission follow-ups (autofix, daemon, sqlite, setup)
Cursor Agent3cda62bd4cc8
diff --git a/claude-ops/bin/ops-autofix b/claude-ops/bin/ops-autofixindex f5c82366..473f9586 100755--- a/claude-ops/bin/ops-autofix+++ b/claude-ops/bin/ops-autofix@@ -159,79 +159,20 @@ fix_vercel_mcp() {# ─── 4. Channel health — detect auth'd but broken channels ──────────────────fix_channel_health() {- # ── WhatsApp: @lid JID sync + stale connection ──+ # ── WhatsApp: bridge listen + recent message flow (wacli doctor removed) ──if lsof -i :8080 2>/dev/null | grep -q LISTEN; then- DOCTOR='{"success":true,"bridge":"running"}'- WA_AUTH=$(echo "$DOCTOR" | jq -r '.data.authenticated // false' 2>/dev/null)- WA_LOCK=$(echo "$DOCTOR" | jq -r '.data.lock_held // false' 2>/dev/null)-- if [ "$WA_AUTH" = "true" ]; then- # Kill stale lock if held >2 min — but never kill the legitimate- # bridge manages its own locking internally- # entire lifetime by design; that's not "stale").- if [ "$WA_LOCK" = "true" ]; then- LOCK_PID=$(echo "$DOCTOR" | jq -r '.data.lock_info' 2>/dev/null | grep -oE 'pid=[0-9]+' | cut -d= -f2)- if [ -n "$LOCK_PID" ] && kill -0 "$LOCK_PID" 2>/dev/null; then- LOCK_CMD=$(ps -p "$LOCK_PID" -o command= 2>/dev/null || echo "")- LOCK_ETIME=$(ps -p "$LOCK_PID" -o etime= 2>/dev/null | tr -d ' ')- # Skip if it's the persistent --follow daemon- if false; then # bridge manages locking internally- log_skip "bridge-health: lock held by persistent --follow daemon (pid=$LOCK_PID) — leaving alone"- else- # Parse etime to seconds. Formats: SS, MM:SS, HH:MM:SS, DD-HH:MM:SS- LOCK_AGE=$(echo "$LOCK_ETIME" | awk -F'[-:]' '{- n=NF; s=0- if (n==1) s=$1- else if (n==2) s=$1*60+$2- else if (n==3) s=$1*3600+$2*60+$3- else if (n==4) s=$1*86400+$2*3600+$3*60+$4- print s- }')- if [ -n "$LOCK_AGE" ] && [ "$LOCK_AGE" -gt 120 ]; then- log_fix "bridge-health: killed stale lock holder (pid=$LOCK_PID, age=${LOCK_AGE}s, cmd=$LOCK_CMD)"- kill "$LOCK_PID" 2>/dev/null; sleep 2- kill -0 "$LOCK_PID" 2>/dev/null && kill -9 "$LOCK_PID" 2>/dev/null- else- log_skip "bridge-health: lock holder pid=$LOCK_PID is young (${LOCK_AGE}s) — not stale"- fi- fi- fi- fi-- # Check @lid JIDs with empty messages- LID_EMPTY=0- # Bridge handles @lid resolution automatically — just ensure it is running- if true; then- jid="bridge"- MSG_COUNT=1- [ "$MSG_COUNT" = "0" ] && LID_EMPTY=$((LID_EMPTY + 1))- fi-- if [ "$LID_EMPTY" -gt 0 ]; then- if launchctl kickstart -k gui/$(id -u)/com.<user>.whatsapp-bridge 2>/dev/null; then- log_fix "bridge-health: synced @lid chats ($LID_EMPTY had empty messages)"- else- log_fail "bridge-health: sync timed out"- fi- fi-- # Check for zero recent messages (auth'd but dead session)- BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"- RECENT=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM messages WHERE timestamp >= datetime('now','-1 day');" 2>/dev/null || echo "0")- if [ "$RECENT" = "0" ]; then- # Try sync first- launchctl kickstart -k gui/$(id -u)/com.<user>.whatsapp-bridge 2>/dev/null || true- RECENT2=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM messages WHERE timestamp >= datetime('now','-1 day');" 2>/dev/null || echo "0")- if [ "$RECENT2" = "0" ]; then- log_fail "bridge-health: auth'd but 0 messages in 24h (likely app-state key desync — needs re-pair)"- else- log_fix "bridge-health: sync restored message flow"- fi+ BRIDGE_DB="${WHATSAPP_BRIDGE_DB:-$HOME/.local/share/whatsapp-mcp/whatsapp-bridge/store/messages.db}"+ RECENT=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM messages WHERE timestamp >= datetime('now','-1 day');" 2>/dev/null || echo "0")+ if [ "$RECENT" = "0" ]; then+ launchctl kickstart -k gui/$(id -u)/com.<user>.whatsapp-bridge 2>/dev/null || true+ RECENT2=$(sqlite3 "$BRIDGE_DB" "SELECT COUNT(*) FROM messages WHERE timestamp >= datetime('now','-1 day');" 2>/dev/null || echo "0")+ if [ "$RECENT2" = "0" ]; then+ log_fail "bridge-health: bridge up but 0 messages in 24h (may need re-pair or sync)"else- log_skip "bridge-health: messages flowing normally"+ log_fix "bridge-health: sync restored message flow"fielse- log_skip "bridge-health: not authenticated"+ log_skip "bridge-health: messages flowing normally"fifi@@ -282,7 +223,7 @@ case "$FIX_TARGET" infix_slack_mcpfix_vercel_mcp;;- wacli-fts) fix_bridge_fts ;;+ bridge-fts|wacli-fts) fix_bridge_fts ;;channel-health) fix_channel_health ;;slack-mcp) fix_slack_mcp ;;vercel-mcp) fix_vercel_mcp ;;diff --git a/claude-ops/bin/ops-status b/claude-ops/bin/ops-statusindex 6b396c9c..b1a76ecd 100755--- a/claude-ops/bin/ops-status+++ b/claude-ops/bin/ops-status@@ -105,7 +105,7 @@ _channel_configured() {whatsapp)_pref_has ".channels.whatsapp" && return 0# wacli decommissioned — bridge check instead- lsof -i :8080 2>/dev/null | grep -q LISTEN && return 0+ lsof -i :8080 2>/dev/null | grep -q LISTEN && return 0;;telegram)_pref_has ".channels.telegram" && return 0diff --git a/claude-ops/scripts/ops-cron-inbox-digest.sh b/claude-ops/scripts/ops-cron-inbox-digest.shindex c57373cb..46eefa40 100755--- a/claude-ops/scripts/ops-cron-inbox-digest.sh+++ b/claude-ops/scripts/ops-cron-inbox-digest.sh@@ -28,7 +28,10 @@ if [[ -f "$BRIDGE_DB" ]]; thenimport json, sysmsgs = json.load(sys.stdin)# Filter out messages from owner (is_from_me=true)-unread = [m for m in msgs if not m.get('is_from_me', False)]+def _from_me(m):+ v = m.get('is_from_me', False)+ return v is True or v == 1+unread = [m for m in msgs if not _from_me(m)]print(len(unread))" 2>/dev/null || echo "0")@@ -38,8 +41,11 @@ print(len(unread))WA_SENDERS=$(echo "$WA_RAW" | python3 -c "import json, sysmsgs = json.load(sys.stdin)-unread = [m for m in msgs if not m.get('is_from_me', False)]-senders = list({m.get('contact_name', m.get('from', 'unknown')) for m in unread})[:5]+def _from_me(m):+ v = m.get('is_from_me', False)+ return v is True or v == 1+unread = [m for m in msgs if not _from_me(m)]+senders = list({m.get('sender') or m.get('contact_name') or m.get('from') or 'unknown' for m in unread})[:5]print(', '.join(senders))" 2>/dev/null || echo "unknown")WA_SUMMARY="WhatsApp: $WA_COUNT unread from $WA_SENDERS"diff --git a/claude-ops/scripts/ops-daemon.sh b/claude-ops/scripts/ops-daemon.shindex 8372dea7..ebdd4dc3 100755--- a/claude-ops/scripts/ops-daemon.sh+++ b/claude-ops/scripts/ops-daemon.sh@@ -159,13 +159,13 @@ else:# ── Launchd ownership check ──────────────────────────────────────────────# Returns 0 if the launchd service for whatsapp-bridge is loaded and has a-# live process. When true, the daemon must NOT start wacli-sync itself —+# live process. When true, the daemon must NOT start whatsapp-bridge itself —# launchd is the sole owner and handles restarts via KeepAlive=true.-_wacli_owned_by_launchd() {+_whatsapp_bridge_owned_by_launchd() {command -v launchctl >/dev/null 2>&1 || return 1local pid_strpid_str=$(launchctl list 2>/dev/null \- | awk '$3=="com.claude-ops.wacli-keepalive" {print $1}' || true)+ | awk '$3=="com.<user>.whatsapp-bridge" {print $1}' || true)# Service must be registered AND have a live PID (not "-")if [[ -n "$pid_str" ]] && [[ "$pid_str" != "-" ]] && kill -0 "$pid_str" 2>/dev/null; thenreturn 0@@ -177,14 +177,14 @@ _wacli_owned_by_launchd() {start_service() {local name="$1"- # ── Race-condition guard: wacli-sync ownership ──────────────────────────- # The launchd keepalive service (com.claude-ops.wacli-keepalive) is the- # whatsapp-bridge is the sole owner of the WA connection. If it is loaded and running, the- # daemon must not spawn a competing wacli-sync — doing so causes store-lock- # errors and WhatsApp disconnections. Instead we mark the service as- # "delegated" and monitor health passively via the health file.- if [[ "$name" == "wacli-sync" ]] && _wacli_owned_by_launchd; then- log "START: $name — launchd keepalive is running, deferring ownership (no duplicate spawn)"+ # ── Race-condition guard: whatsapp-bridge ownership ─────────────────────+ # The LaunchAgent com.<user>.whatsapp-bridge is the sole owner of the WA+ # connection. If it is loaded and running, the daemon must not spawn a+ # competing whatsapp-bridge — doing so causes store-lock errors and+ # disconnections. Instead we mark the service as "delegated" and monitor+ # health passively.+ if [[ "$name" == "whatsapp-bridge" ]] && _whatsapp_bridge_owned_by_launchd; then+ log "START: $name — launchd WhatsApp bridge is running, deferring ownership (no duplicate spawn)"SERVICE_STATUS["$name"]="delegated"SERVICE_LAST_HEALTH["$name"]="launchd-owned"return 0@@ -285,8 +285,8 @@ restart_service() {local name="$1"# ── Race-condition guard (mirrors start_service) ────────────────────────- if [[ "$name" == "wacli-sync" ]] && _wacli_owned_by_launchd; then- log "RESTART: $name — launchd keepalive owns this service, skipping daemon restart"+ if [[ "$name" == "whatsapp-bridge" ]] && _whatsapp_bridge_owned_by_launchd; then+ log "RESTART: $name — launchd WhatsApp bridge owns this service, skipping daemon restart"SERVICE_STATUS["$name"]="delegated"return 0fi@@ -1647,15 +1647,15 @@ while true; dofielse# Persistent service: check health + restart if needed- # For wacli-sync delegated to launchd, re-check ownership each loop.+ # For whatsapp-bridge delegated to launchd, re-check ownership each loop.# If launchd stopped unexpectedly, the daemon can take over.- if [[ "$svc" == "wacli-sync" ]] && [[ "${SERVICE_STATUS[$svc]:-}" == "delegated" ]]; then- if _wacli_owned_by_launchd; then+ if [[ "$svc" == "whatsapp-bridge" ]] && [[ "${SERVICE_STATUS[$svc]:-}" == "delegated" ]]; then+ if _whatsapp_bridge_owned_by_launchd; then# Still owned by launchd — just read the health file passivelycheck_health "$svc" || trueSERVICE_STATUS["$svc"]="delegated"else- log "MONITOR: $svc — launchd keepalive no longer running, daemon taking ownership"+ log "MONITOR: $svc — launchd WhatsApp bridge no longer running, daemon taking ownership"SERVICE_STATUS["$svc"]="dead"start_service "$svc"fidiff --git a/claude-ops/scripts/ops-message-listener.sh b/claude-ops/scripts/ops-message-listener.shindex 69d7d20f..ec384bd0 100755--- a/claude-ops/scripts/ops-message-listener.sh+++ b/claude-ops/scripts/ops-message-listener.sh@@ -102,14 +102,17 @@ poll_whatsapp() {echo "$raw" | python3 -c "import json, sysmsgs = json.load(sys.stdin)+def _from_me(m):+ v = m.get('is_from_me', False)+ return v is True or v == 1filtered = []for m in msgs:- if not m.get('is_from_me', False):+ if not _from_me(m):filtered.append({'id': m.get('id', ''),'channel': 'whatsapp',- 'from': m.get('contact_name', m.get('from', '')),- 'text': m.get('body', m.get('text', '')),+ 'from': m.get('sender') or m.get('contact_name') or m.get('from', ''),+ 'text': m.get('content') or m.get('body') or m.get('text', ''),'timestamp': m.get('timestamp', ''),'raw': m})diff --git a/claude-ops/skills/setup/SKILL.md b/claude-ops/skills/setup/SKILL.mdindex 594d6b9b..da604fe4 100644--- a/claude-ops/skills/setup/SKILL.md+++ b/claude-ops/skills/setup/SKILL.md@@ -2998,7 +2998,7 @@ After auto-discovery (or if the user selects "I'll enter projects manually"):## Step 5b — Daemon Service Reconciliation-By now, the daemon was already installed in Step 2c and has been pre-warming the briefing cache in the background while the user configured channels. This step adds **channel-dependent services** (`whatsapp-bridge-sync`, `message-listener`, `inbox-digest`, `store-health`, `competitor-intel`) now that we know which channels and integrations are configured.+By now, the daemon was already installed in Step 2c and has been pre-warming the briefing cache in the background while the user configured channels. This step adds **channel-dependent services** (`whatsapp-bridge`, `message-listener`, `inbox-digest`, `store-health`, `competitor-intel`) now that we know which channels and integrations are configured.**Skip conditions:**- If the user declined daemon install in Step 2c, skip this step entirely.@@ -3026,7 +3026,7 @@ cat "$DATA_DIR/daemon-health.json" 2>/dev/nullParse the JSON. If `action_needed` is not null, surface the required action to the user. If the daemon wrote a health file, print:```-✓ Background daemon — running (whatsapp-bridge-sync: connected, memory-extractor: scheduled)+✓ Background daemon — running (whatsapp-bridge: connected, memory-extractor: scheduled)```If the health file is missing (daemon may still be initializing), wait 5 more seconds and retry once. If still missing, print:@@ -3041,7 +3041,7 @@ If the health file is missing (daemon may still be initializing), wait 5 more seDetermine which services to enable based on what was configured in earlier steps. The `briefing-pre-warm` and `memory-extractor` services were already enabled at Step 2c — preserve them. Add channel-dependent services based on what's now configured:-- `whatsapp-bridge-sync` — always include if WhatsApp is configured (`channels.whatsapp` is set)+- `whatsapp-bridge` — always include if WhatsApp is configured (`channels.whatsapp` is set)- `memory-extractor` — always include- `inbox-digest` — always include (runs every 4h, aggregates all configured channels)- `store-health` — include ONLY if ecommerce was configured (`ecom.shopify.store_url` is set in `$PREFS_PATH`)@@ -3052,9 +3052,9 @@ Build the services array programmatically (starting from the 2c baseline):```bashSERVICES='["briefing-pre-warm","memory-extractor","inbox-digest","competitor-intel"]'PREFS=$(cat "$PREFS_PATH" 2>/dev/null || echo '{}')-# Add whatsapp-bridge-sync + message-listener if WhatsApp is configured+# Add whatsapp-bridge + message-listener if WhatsApp is configuredif echo "$PREFS" | jq -e '.channels.whatsapp' > /dev/null 2>&1; then- SERVICES=$(echo "$SERVICES" | jq '. + ["whatsapp-bridge-sync","message-listener"]')+ SERVICES=$(echo "$SERVICES" | jq '. + ["whatsapp-bridge","message-listener"]')fi# Add message-listener for Telegram too (deduplicate)if echo "$PREFS" | jq -e '.channels.telegram' > /dev/null 2>&1; then@@ -3069,7 +3069,7 @@ echo "Services to enable: $SERVICES"Write daemon services config to `$DATA_DIR/daemon-services.json` — merge with the existing config from Step 2c, preserving `briefing-pre-warm` and `memory-extractor`, and enabling the new channel-dependent services. **Every service MUST include a `command` field** — the daemon's `start_service()` skips any service without one. Use `${CLAUDE_PLUGIN_ROOT}` (resolved at runtime) for script paths. Each service entry should include:- `briefing-pre-warm`: `{ "enabled": true, "command": "${CLAUDE_PLUGIN_ROOT}/bin/ops-gather", "cron": "*/2 * * * *" }` — pre-warms /ops:go cache (installed in 2c)-- `whatsapp-bridge-sync`: `{ "enabled": true, "command": "${CLAUDE_PLUGIN_ROOT}/scripts/whatsapp-bridge-keepalive.sh", "health_file": "~/.whatsapp-bridge/.health", "restart_delay": 60, "max_restarts": 10 }` — only if WhatsApp configured+- `whatsapp-bridge`: `{ "enabled": true, "command": "launchctl kickstart -k gui/$UID/com.<user>.whatsapp-bridge", "health_check": "lsof -i :8080 | grep LISTEN", "restart_delay": 60, "max_restarts": 10 }` — only if WhatsApp configured (matches `daemon-services.default.json`; bridge is owned by LaunchAgent, not a plugin script)- `memory-extractor`: `{ "enabled": true, "command": "${CLAUDE_PLUGIN_ROOT}/scripts/ops-memory-extractor.sh", "health_file": "~/.claude/plugins/data/ops-ops-marketplace/memories/.health", "cron": "*/30 * * * *" }` — every 30 min (installed in 2c)- `inbox-digest`: `{ "enabled": true, "command": "${CLAUDE_PLUGIN_ROOT}/scripts/ops-cron-inbox-digest.sh", "cron": "0 */4 * * *" }` — every 4h- `store-health`: `{ "enabled": true, "command": "${CLAUDE_PLUGIN_ROOT}/scripts/ops-cron-store-health.sh", "cron": "0 9 * * *" }` — daily 9am, only if ecom configured@@ -3095,7 +3095,7 @@ Use `run_in_background: true` on the reload command. Do NOT wait for it — contWrite `daemon.enabled = true` and `daemon.services` (the reconciled array) to `$PREFS_PATH`. Print:```-✓ Daemon services reconciled — N services enabled (briefing-pre-warm, memory-extractor, whatsapp-bridge-sync, ...)+✓ Daemon services reconciled — N services enabled (briefing-pre-warm, memory-extractor, whatsapp-bridge, ...)Daemon reloading in background.```@@ -3441,7 +3441,7 @@ Re-run the detector and present a final status dashboard:✓ MCPs: linear, sentry, vercel✓ Registry: 20 projects✓ Prefs: saved to ~/.claude/plugins/data/ops-ops-marketplace/preferences.json- ✓ Daemon: ops-daemon → whatsapp-bridge-sync, memory-extractor, inbox-digest+ ✓ Daemon: ops-daemon → whatsapp-bridge, memory-extractor, inbox-digestNext: /ops-go for your first briefing──────────────────────────────────────────────────────