#!/usr/bin/env bash # Binky operating-rhythm bridge session (BINKY-WP-0003-T04). # Runs a headless Claude Code session that does queue hygiene, writes the # daily brief, and pulls one AutopilotWorkQueue item when idle. # This is a BRIDGE until activity-core + llm-connect own scheduling/execution # (BINKY-WP-0003 T05/T06). Disable: see OperatingRhythm.md "Bridge scheduler". set -euo pipefail REPO="$HOME/binky-control" LOGDIR="$HOME/.cache/binky-control/rhythm" LOCK="$LOGDIR/rhythm.lock" mkdir -p "$LOGDIR" # never overlap a prior run exec 9>"$LOCK" flock -n 9 || { echo "$(date -Is) skipped: previous rhythm session still running" >>"$LOGDIR/cron.log"; exit 0; } PROMPT=$(cat <<'EOF' You are the Binky operating-rhythm bridge session (see OperatingRhythm.md). Work autonomously, Green/Blue lane only. Do, in order: 1. Queue hygiene: check DecisionQueue.md (flag items older than 14 days), OfficeHourQueue.md, RiskRegister.md escalation dates against today. 2. Write today's daily brief to briefs/-daily-brief.md in the format defined in OperatingRhythm.md (Decide now / Progress / Risks / Best next hour; one screen max). Skip if today's brief already exists. 3. If time remains, pull ONE item from AutopilotWorkQueue.md you can fully complete in Green/Blue lane; mark it in_progress with agent "agt-rhythm-bridge", do it, move it to the Completed log. 4. Commit all changes with a concise message. Never touch Red/Yellow lane actions; queue them instead. Keep total effort bounded — this is a maintenance pass, not a project session. EOF ) cd "$REPO" "$HOME/.local/bin/claude" -p "$PROMPT" \ --permission-mode acceptEdits \ --allowedTools "Read,Write,Edit,Glob,Grep,Bash(git add:*),Bash(git commit:*),Bash(git status),Bash(git log:*),Bash(git diff:*),Bash(date:*),Bash(ls:*)" \ >>"$LOGDIR/cron.log" 2>&1 echo "$(date -Is) rhythm session finished rc=$?" >>"$LOGDIR/cron.log"