cd /news/developer-tools/daemonless-ticket-queue-poller-for-t… · home topics developer-tools article
[ARTICLE · art-82649] src=gist.github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Daemonless ticket-queue poller for the sonu plugin — cron wrapper that wakes a headless agent session only when a trigger label or in-flight ticket branch exists

PrabhdeepSingh's sonu plugin introduces a daemonless ticket-queue poller, a cron wrapper that wakes a headless agent session only when a trigger label or in-flight ticket branch exists. The script, factory-poll.sh, uses flock for serialization and checks for specific labels and ticket branches to minimize API calls and token usage.

read2 min views1 publishedAug 1, 2026

| #!/usr/bin/env bash | | | # factory-poll.sh — the entire "daemon" for the sonu plugin's ticket queue. | | | # | | | # Polls a repo's ticket queue and, only when there is something to do, spawns | | | # one headless agent session that runs /sonu:factory (scan, claim, route, | | | # build in a worktree, sweep). All the intelligence lives in the plugin; | | | # this script only decides whether it's worth waking the agent. | | | # | | | # Requires: the sonu plugin installed (github.com/PrabhdeepSingh/claude-plugins), | | | # an authenticated gh CLI, and a tracker configured via /sonu:factory init. | | | # | | | # Install (cron, every 15 minutes): | | | # /15 * * * * $HOME/.sonu/factory-poll.sh | | | # Or on macOS, a launchd plist with StartInterval 900. | | | # | | | # Notes: | | | # - flock keeps runs serialized (one at a time), matching one-ticket-per-pass. | | | # - The trigger labels are queried separately: gh issue list with two | | | # --label flags is AND semantics, and a ticket only ever carries one trigger. | | | # - In-flight ticket/ branches also wake the agent, or the close-the-loop | | | # sweep would starve once triggers are consumed. | | | # - Empty queue costs two API calls and zero tokens. | | | set -u | | | REPO_DIR="/path/to/repo" # <-- set me | | | cd "$REPO_DIR" || exit 1 | | | mkdir -p "$HOME/.sonu" | | | exec 9>"$HOME/.sonu/factory.lock" | | | flock -n 9 || exit 0 # a previous run is still going | | | queued=0 | |

| for label in factory-ready-for-spec factory-ready-to-implement; do | |
| n=$(gh issue list --state open --label "$label" --json number --jq 'length' 2>/dev/null || echo 0) | |
| queued=$((queued + n)) | |

| done | | | # Tickets mid-flight carry no trigger by definition; their ticket/* branches | | | # are what the sweep needs to see (status flips, worktree cleanup). | |

| inflight=$(git branch --list 'ticket/*' | wc -l | tr -d ' ') | |
| [ "$((queued + inflight))" -gt 0 ] || exit 0 # nothing queued, nothing to sweep | |
| timeout 2h claude -p "/sonu:factory" >> "$HOME/.sonu/factory.log" 2>&1 |
── more in #developer-tools 4 stories · sorted by recency
── more on @prabhdeepsingh 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/daemonless-ticket-qu…] indexed:0 read:2min 2026-08-01 ·