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
feat(pocket): templatize pocket-activity-notifier for fresh installs (#271)
Aurora Capital79a2d05362bc
diff --git a/claude-ops/bin/ops-marketing-portfolio b/claude-ops/bin/ops-marketing-portfolioindex 1ef598ff..405af796 100755--- a/claude-ops/bin/ops-marketing-portfolio+++ b/claude-ops/bin/ops-marketing-portfolio@@ -31,7 +31,7 @@ for ((i=1; i<=$#; i++)); do--json) JSON_OUT=1 ;;--project)j=$((i+1)); FILTER_PROJECT="${!j:-}"- i=$((i+1))+ i=$((i+1)) # skip value so it is not parsed as a flag on the next iteration;;esacdonediff --git a/claude-ops/scripts/com.claude-ops.daemon.plist b/claude-ops/scripts/com.claude-ops.daemon.plistindex 6ff8a4fe..aa587f19 100644--- a/claude-ops/scripts/com.claude-ops.daemon.plist+++ b/claude-ops/scripts/com.claude-ops.daemon.plist@@ -32,6 +32,8 @@<string>/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin</string><key>HOME</key><string>__HOME__</string>+ <key>CLAUDE_PLUGIN_ROOT</key>+ <string>__PLUGIN_ROOT__</string></dict></dict></plist>diff --git a/claude-ops/scripts/com.claude-ops.pocket-activity-notifier.plist b/claude-ops/scripts/com.claude-ops.pocket-activity-notifier.plistnew file mode 100644index 00000000..304b591c--- /dev/null+++ b/claude-ops/scripts/com.claude-ops.pocket-activity-notifier.plist@@ -0,0 +1,36 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>Label</key>+ <string>com.claude-ops.pocket-activity-notifier</string>++ <key>ProgramArguments</key>+ <array>+ <string>__BASH_PATH__</string>+ <string>__POCKET_NOTIFIER_LAUNCHER_PATH__</string>+ </array>++ <key>StartInterval</key>+ <integer>60</integer>++ <key>RunAtLoad</key>+ <true/>++ <key>StandardOutPath</key>+ <string>__HOME__/.claude/state/pocket/activity-notifier.stdout.log</string>++ <key>StandardErrorPath</key>+ <string>__HOME__/.claude/state/pocket/activity-notifier.stderr.log</string>++ <key>EnvironmentVariables</key>+ <dict>+ <key>PATH</key>+ <string>/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin</string>+ <key>HOME</key>+ <string>__HOME__</string>+ <key>USER</key>+ <string>__USER__</string>+ </dict>+</dict>+</plist>diff --git a/claude-ops/scripts/daemon-services.default.json b/claude-ops/scripts/daemon-services.default.jsonindex 5582dce5..e203ea1a 100644--- a/claude-ops/scripts/daemon-services.default.json+++ b/claude-ops/scripts/daemon-services.default.json@@ -20,6 +20,14 @@"restart_delay": 3600,"cron": "*/30 * * * *"},+ "pocket-activity-notifier": {+ "enabled": false,+ "command": "${CLAUDE_PLUGIN_ROOT}/scripts/ops-pocket-activity-notifier.py",+ "cron": "* * * * *",+ "health_file": "~/.claude/state/pocket/.activity-notifier-health",+ "restart_delay": 60,+ "_note": "Watches pocket spawn-ledger + executor-results dir; emits START + DONE events to WhatsApp self-chat + email with the report attached. Requires whatsapp-config.json and/or email-config.json under ~/.claude/state/pocket/. Run `bash scripts/install-pocket-notifier.sh` to register the launchd job (preferred over the cron-via-daemon path for sub-minute latency)."+ },"fires-watcher": {"enabled": false,"command": "${CLAUDE_PLUGIN_ROOT}/scripts/ops-fires-watcher.sh",diff --git a/claude-ops/scripts/install-pocket-notifier.sh b/claude-ops/scripts/install-pocket-notifier.shnew file mode 100755index 00000000..214cda99--- /dev/null+++ b/claude-ops/scripts/install-pocket-notifier.sh@@ -0,0 +1,99 @@+#!/usr/bin/env bash+# Install the pocket-activity-notifier as a launchd LaunchAgent.+#+# Generates the plist from the bundled template, sed-substitutes user-local+# paths, and bootstraps the agent. Idempotent — re-running re-bootstraps+# cleanly.+#+# Trigger: invoked from /ops:setup when the user opts in to pocket activity+# notifications (requires whatsapp-config.json and/or email-config.json under+# ~/.claude/state/pocket/). Can also be run standalone:+#+# bash scripts/install-pocket-notifier.sh+#+# Required env (any of the resolution paths below works):+# CLAUDE_PLUGIN_ROOT (set by Claude Code when invoking plugin code)++set -euo pipefail++if [[ "$(uname -s)" != "Darwin" ]]; then+ echo "skip: pocket-activity-notifier is macOS-only (launchd)" >&2+ echo "Linux users: wire scripts/ops-pocket-activity-notifier.py into systemd/cron with a 60s interval."+ exit 0+fi++# Resolve plugin root — never hardcode a version number.+# Fall back to the directory containing THIS script if CLAUDE_PLUGIN_ROOT is unset+# (lets the script work when invoked directly from a checkout).+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(ls -d "$HOME/.claude/plugins/cache/ops-marketplace/ops"/*/ 2>/dev/null | sort -V | tail -1)}"+if [[ -z "$PLUGIN_ROOT" || ! -d "$PLUGIN_ROOT" ]]; then+ PLUGIN_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"+fi++NOTIFIER_SCRIPT="$PLUGIN_ROOT/scripts/ops-pocket-activity-notifier.py"+LAUNCHER_SCRIPT="$PLUGIN_ROOT/scripts/ops-pocket-activity-notifier-launcher.sh"+LAUNCHER_DEST_DIR="$HOME/.claude/plugins/data/ops-ops-marketplace/bin"+LAUNCHER_DEST="$LAUNCHER_DEST_DIR/ops-pocket-activity-notifier-launcher.sh"+PLIST_TEMPLATE="$PLUGIN_ROOT/scripts/com.claude-ops.pocket-activity-notifier.plist"+PLIST_DEST="$HOME/Library/LaunchAgents/com.claude-ops.pocket-activity-notifier.plist"+STATE_DIR="$HOME/.claude/state/pocket"++# Fall back to script-dir-relative paths when invoked from a fresh checkout+# where the plugin root resolution above lands somewhere unexpected.+[[ -f "$NOTIFIER_SCRIPT" ]] || NOTIFIER_SCRIPT="$SCRIPT_DIR/ops-pocket-activity-notifier.py"+[[ -f "$LAUNCHER_SCRIPT" ]] || LAUNCHER_SCRIPT="$SCRIPT_DIR/ops-pocket-activity-notifier-launcher.sh"+[[ -f "$PLIST_TEMPLATE" ]] || PLIST_TEMPLATE="$SCRIPT_DIR/com.claude-ops.pocket-activity-notifier.plist"++for f in "$NOTIFIER_SCRIPT" "$LAUNCHER_SCRIPT" "$PLIST_TEMPLATE"; do+ [[ -f "$f" ]] || { echo "error: required plugin file not found: $f" >&2; exit 1; }+done++mkdir -p "$STATE_DIR" "$LAUNCHER_DEST_DIR"+chmod +x "$NOTIFIER_SCRIPT"++# Install the version-agnostic launcher to a stable location outside the+# version-pinned cache dir. The plist points at THIS path forever — the+# launcher resolves the latest installed ops version at run time.+cp "$LAUNCHER_SCRIPT" "$LAUNCHER_DEST"+chmod +x "$LAUNCHER_DEST"++# macOS ships bash 3; Homebrew installs bash 5 at /opt/homebrew/bin/bash.+BASH_PATH="/bin/bash"+if [[ -x /opt/homebrew/bin/bash ]]; then+ BASH_PATH="/opt/homebrew/bin/bash"+elif [[ -x /usr/local/bin/bash ]]; then+ BASH_PATH="/usr/local/bin/bash"+fi++# Generate plist from template. Point at the stable launcher path so plugin+# upgrades don't strand the plist on a deleted version dir.+TMP_PLIST="$(mktemp -t pocket-activity-notifier.XXXXXX.plist)"+trap 'rm -f "$TMP_PLIST"' EXIT++sed -e "s|__BASH_PATH__|$BASH_PATH|g" \+ -e "s|__POCKET_NOTIFIER_LAUNCHER_PATH__|$LAUNCHER_DEST|g" \+ -e "s|__HOME__|$HOME|g" \+ -e "s|__USER__|$USER|g" \+ "$PLIST_TEMPLATE" > "$TMP_PLIST"++mv "$TMP_PLIST" "$PLIST_DEST"+trap - EXIT++# Bootstrap the agent. bootout is best-effort (no-op if not loaded).+launchctl bootout "gui/$(id -u)/com.claude-ops.pocket-activity-notifier" 2>/dev/null || true+launchctl bootstrap "gui/$(id -u)" "$PLIST_DEST"+launchctl enable "gui/$(id -u)/com.claude-ops.pocket-activity-notifier"++# Verify.+if launchctl list | grep -q "com.claude-ops.pocket-activity-notifier"; then+ echo "✓ pocket-activity-notifier installed and bootstrapped"+ echo " plist: $PLIST_DEST"+ echo " launcher: $LAUNCHER_DEST"+ echo " script: $NOTIFIER_SCRIPT (resolved at run time via launcher)"+ echo " interval: 60s"+ echo " logs: $STATE_DIR/activity-notifier.{stdout,stderr}.log"+else+ echo "✗ pocket-activity-notifier failed to load — check $STATE_DIR/activity-notifier.stderr.log" >&2+ exit 1+fidiff --git a/claude-ops/scripts/ops-daemon-launcher.sh b/claude-ops/scripts/ops-daemon-launcher.shindex d1bc2784..d7eca206 100755--- a/claude-ops/scripts/ops-daemon-launcher.sh+++ b/claude-ops/scripts/ops-daemon-launcher.sh@@ -1,4 +1,4 @@-#!/opt/homebrew/bin/bash+#!/usr/bin/env bash# 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.@@ -15,8 +15,9 @@ fiLATEST_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 -rn -t. -k1,1 -k2,2 -k3,3 \+ | awk '/^[0-9]+\.[0-9]+\.[0-9]+$/ { print }' \+ | sort -V \+ | tac \| while read -r v; doif [[ -x "$CACHE_ROOT/$v/scripts/ops-daemon.sh" ]]; thenecho "$v"; break@@ -33,6 +34,11 @@ 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"-# Re-exec under the same bash that is running this script (plist/installer may-# use /opt/homebrew or /usr/local on Intel Mac); avoid hardcoding Homebrew path.-exec "${OPS_DAEMON_LAUNCHER_BASH:-$BASH}" "$DAEMON" "$@"+# Match install-ops-daemon.sh: Apple Silicon Homebrew → Intel Homebrew → system bash+BASH_PATH="/bin/bash"+if [[ -x /opt/homebrew/bin/bash ]]; then+ BASH_PATH="/opt/homebrew/bin/bash"+elif [[ -x /usr/local/bin/bash ]]; then+ BASH_PATH="/usr/local/bin/bash"+fi+exec "$BASH_PATH" "$DAEMON" "$@"diff --git a/claude-ops/scripts/ops-pocket-activity-notifier-launcher.sh b/claude-ops/scripts/ops-pocket-activity-notifier-launcher.shnew file mode 100755index 00000000..263edb6e--- /dev/null+++ b/claude-ops/scripts/ops-pocket-activity-notifier-launcher.sh@@ -0,0 +1,52 @@+#!/usr/bin/env bash+# ops-pocket-activity-notifier-launcher.sh — version-agnostic launcher for the+# pocket activity notifier. Resolves the highest installed ops plugin version+# at run time, then execs scripts/ops-pocket-activity-notifier.py with python3.+# Survives plugin upgrades without plist edits.+set -euo pipefail++CACHE_ROOT="${CLAUDE_PLUGIN_CACHE_ROOT:-$HOME/.claude/plugins/cache/ops-marketplace/ops}"++if [[ ! -d "$CACHE_ROOT" ]]; then+ echo "[ops-pocket-activity-notifier-launcher] FATAL: cache root missing: $CACHE_ROOT" >&2+ exit 64+fi++# Highest semver dir that contains scripts/ops-pocket-activity-notifier.py+LATEST_VERSION="$(+ find "$CACHE_ROOT" -mindepth 1 -maxdepth 1 -type d -print 2>/dev/null \+ | awk -F/ '{print $NF}' \+ | awk '/^[0-9]+\.[0-9]+\.[0-9]+$/ { print }' \+ | sort -V \+ | tac \+ | while read -r v; do+ if [[ -f "$CACHE_ROOT/$v/scripts/ops-pocket-activity-notifier.py" ]]; then+ echo "$v"; break+ fi+ done+)"++if [[ -z "${LATEST_VERSION:-}" ]]; then+ echo "[ops-pocket-activity-notifier-launcher] FATAL: no installed ops version has scripts/ops-pocket-activity-notifier.py" >&2+ exit 65+fi++NOTIFIER="$CACHE_ROOT/$LATEST_VERSION/scripts/ops-pocket-activity-notifier.py"+export CLAUDE_PLUGIN_ROOT="$CACHE_ROOT/$LATEST_VERSION"++# Match install-pocket-notifier.sh: Apple Silicon Homebrew → Intel Homebrew → PATH+PYTHON_PATH=""+if [[ -x /opt/homebrew/bin/python3 ]]; then+ PYTHON_PATH="/opt/homebrew/bin/python3"+elif [[ -x /usr/local/bin/python3 ]]; then+ PYTHON_PATH="/usr/local/bin/python3"+else+ PYTHON_PATH="$(command -v python3 || true)"+fi+if [[ -z "$PYTHON_PATH" || ! -x "$PYTHON_PATH" ]]; then+ echo "[ops-pocket-activity-notifier-launcher] FATAL: could not find python3" >&2+ exit 66+fi++echo "[ops-pocket-activity-notifier-launcher] resolved ops $LATEST_VERSION → $NOTIFIER (python: $PYTHON_PATH)"+exec "$PYTHON_PATH" "$NOTIFIER" "$@"diff --git a/claude-ops/scripts/ops-pocket-activity-notifier.py b/claude-ops/scripts/ops-pocket-activity-notifier.pyindex 72b6ee7c..1fc8ca90 100755--- a/claude-ops/scripts/ops-pocket-activity-notifier.py+++ b/claude-ops/scripts/ops-pocket-activity-notifier.py@@ -222,16 +222,25 @@ def process_spawns(chat_jid: str | None, email_to: str | None, titles: dict) ->f"attached when this completes.\n")email_subject = f"START — {(title or task_id)[:80]}"- try:- if chat_jid:+ enqueue_errors: list[str] = []+ if chat_jid:+ try:enqueue_whatsapp(chat_jid, wa_msg)- if email_to:+ except OSError as e:+ log(f"enqueue START whatsapp failed: {e}")+ enqueue_errors.append("whatsapp")+ if email_to:+ try:enqueue_email(email_to, email_subject, email_body)- sent += 1- except OSError as e:- log(f"enqueue START failed: {e}")- new_cursor = line_start # retry next tick+ except OSError as e:+ log(f"enqueue START email failed: {e}")+ enqueue_errors.append("email")+ channels_configured = (1 if chat_jid else 0) + (1 if email_to else 0)+ if channels_configured and len(enqueue_errors) == channels_configured:+ log("enqueue START all channels failed; retry next tick")+ new_cursor = line_startbreak+ sent += 1try:SPAWN_CURSOR.write_text(str(new_cursor))except OSError as e:@@ -331,17 +340,26 @@ def process_completions(chat_jid: str | None, email_to: str | None, titles: dictemail_body = "\n".join(email_body_parts)email_subject = f"DONE — {(title or task_id)[:80]}"- try:- if chat_jid:+ enqueue_errors: list[str] = []+ if chat_jid:+ try:enqueue_whatsapp(chat_jid, wa_msg, media_path=attachment)- if email_to:+ except OSError as e:+ log(f"enqueue DONE whatsapp failed for {name}: {e}")+ enqueue_errors.append("whatsapp")+ if email_to:+ try:attachments = [attachment] if attachment else []enqueue_email(email_to, email_subject, email_body, attachments)- sent += 1- new_seen.add(name)- except OSError as e:- log(f"enqueue DONE failed for {name}: {e}")- break # don't mark seen — retry next tick+ except OSError as e:+ log(f"enqueue DONE email failed for {name}: {e}")+ enqueue_errors.append("email")+ channels_configured = (1 if chat_jid else 0) + (1 if email_to else 0)+ if channels_configured and len(enqueue_errors) == channels_configured:+ log(f"enqueue DONE all channels failed for {name}; retry next tick")+ break+ sent += 1+ new_seen.add(name)if new_seen != seen:save_seen_results(new_seen)diff --git a/claude-ops/scripts/ops-pocket-email-bridge.py b/claude-ops/scripts/ops-pocket-email-bridge.pyindex 312d85d2..5926988b 100755--- a/claude-ops/scripts/ops-pocket-email-bridge.py+++ b/claude-ops/scripts/ops-pocket-email-bridge.py@@ -8,8 +8,8 @@ Mirrors ops-pocket-whatsapp-bridge.py but on Gmail. Two duties:Each entry includes a question-id (qid) in the subject so replies can becorrelated back via Gmail's threading.- 2. INBOUND: poll Gmail for messages in a known label/thread set, parse the- owner's natural-language replies against the list of currently-open supervisor+ 2. INBOUND: poll Gmail for messages in a known label/thread set, parse Sam's+ natural-language replies against the list of currently-open supervisorquestions using `claude -p` (Sonnet 4.6), and append matched answers tosupervisor-replies.jsonl — same downstream format as the WhatsApp bridge.@@ -54,16 +54,6 @@ LOG_FILE = STATE_DIR / "email-bridge.log"HEALTH = STATE_DIR / ".email-bridge-health"SENT = STATE_DIR / "email-sent.jsonl"-_USER_CONTEXT_PATH = Path(os.environ.get(- "POCKET_USER_CONTEXT",- HOME / ".claude/state/pocket/user-context.json",-))-try:- _uctx = json.loads(_USER_CONTEXT_PATH.read_text())- _OWNER_NAME: str = _uctx.get("owner_name") or "the user"-except (OSError, json.JSONDecodeError):- _OWNER_NAME = "the user"-GOG_BIN = os.environ.get("GOG_BIN", "gog")TIMEOUT = int(os.environ.get("EMAIL_BRIDGE_TIMEOUT", "60"))@@ -265,11 +255,11 @@ QID_SUBJECT_RE = re.compile(r"\[qid:([a-zA-Z0-9_-]{4,})\]")def fetch_recent_replies(cfg: dict) -> list[dict]:"""Use gog gmail search to find recent messages in the configured label- that are NOT from self (so we only get the owner's replies, not echoes).+ that are NOT from self (so we only get Sam's replies, not echoes).Returns list of {messageId, threadId, subject, body, ts, fromMe}."""label = cfg.get("label", "Pocket")- # Look for messages sent by the account owner in the label, within last 24h.+ # Look for messages SENT BY Sam in the label, within last 24h.query = f"label:{label} from:me newer_than:1d"try:proc = subprocess.run(@@ -318,21 +308,21 @@ def parse_reply_with_llm(body: str, opens: list[dict], parser_model: str) -> lisf" context: {(q.get('context') or '')[:200]}"for q in opens)- prompt = f"""You are the inbound-reply parser for {_OWNER_NAME}'s Pocket supervisor.+ prompt = f"""You are the inbound-reply parser for Account A' Pocket supervisor.-{_OWNER_NAME} just sent an EMAIL reply. Your job: figure out which of the currently-open supervisor questions they are replying to (it may be one, several, or none), and extract the answer in a form the worker can use.+Sam just sent an EMAIL reply. Your job: figure out which of the currently-open supervisor questions he's replying to (it may be one, several, or none), and extract the answer in a form the worker can use.Currently-open questions:{open_descriptions}-Their email body:+Sam's email body:\"\"\"{body[:4000]}\"\"\"Rules:-- If their message is clearly not a reply to any open question, return an empty array.-- If they address one specific question, return one item.-- If they address multiple, return multiple items.-- The 'answer' field should be in their voice and natural — the worker reads it as a direct instruction.+- If Sam's message is clearly not a reply to any open question, return an empty array.+- If Sam addresses one specific question, return one item.+- If Sam addresses multiple, return multiple items.+- The 'answer' field should be in Sam's voice and natural — the worker reads it as a direct instruction.- 'confidence' is your honest 0.0-1.0 estimate.- Output STRICT JSON array, no markdown fences, no prose.@@ -395,7 +385,7 @@ def drain_inbound(cfg: dict) -> tuple[int, int]:messages = fetch_recent_replies(cfg)if not messages:return (0, 0)- # Filter: only NEW messages (strictly after last_processed_id in this window)+ # Filter: only NEW messages after last_processed_id (skip through cursor, then take rest)new_messages: list[dict] = []if not last_id:new_messages = list(messages)@@ -406,8 +396,7 @@ def drain_inbound(cfg: dict) -> tuple[int, int]:new_messages.append(m)elif m["id"] == last_id:past_cursor = True- # If last_id wasn't found in current window, treat all as new (first run / drift)- if not any(m["id"] == last_id for m in messages):+ if not past_cursor:new_messages = list(messages)opens = open_questions()diff --git a/claude-ops/scripts/ops-pocket-triage.py b/claude-ops/scripts/ops-pocket-triage.pyindex f84d176b..9cb28f3c 100755--- a/claude-ops/scripts/ops-pocket-triage.py+++ b/claude-ops/scripts/ops-pocket-triage.py@@ -323,8 +323,16 @@ def main() -> int:write_health("ok", "no pending items", extra={"counts": {}})return 0+ # Claim file atomically so the watcher can append to a fresh pending-triage.jsonl+ claim = PENDING.with_name("pending-triage.processing")+ if not DRY_RUN:+ PENDING.rename(claim)+ pending_src = claim+ else:+ pending_src = PENDING+tasks = []- for raw in PENDING.read_text().splitlines():+ for raw in pending_src.read_text().splitlines():raw = raw.strip()if not raw:continue@@ -353,9 +361,9 @@ def main() -> int:"routed_to": verdict,})- # Truncate pending if not dry run (consumed)+ # Drop claimed batch if not dry run (watcher recreated PENDING as needed)if not DRY_RUN:- PENDING.write_text("")+ claim.unlink(missing_ok=True)log(f"done counts={counts}")write_health("ok", f"triaged={sum(counts.values())}", extra={"counts": counts})return 0