← back to Morning Review Features

build-overnight.sh

40 lines

#!/bin/bash
# Overnight build for morning-review features #6-10.
# Fires Claude CLI with the specs in SPECS.md. Strict 90-min budget.
# Emails Steve a digest of what shipped via George.
set -uo pipefail

LOG_DIR=$HOME/Projects/morning-review-features/logs
mkdir -p "$LOG_DIR"
TS=$(date +%Y%m%d-%H%M%S)
LOG="$LOG_DIR/build-$TS.log"
DIGEST="$LOG_DIR/build-$TS.md"

echo "[overnight-build] start $(date -Iseconds)" | tee -a "$LOG"

SPECS=$(cat "$HOME/Projects/morning-review-features/specs/SPECS.md")
PROMPT="You are an overnight builder. Build features #6-10 from this spec, in order, with a strict 90-minute total budget. After each feature: restart morning-review (pm2 restart morning-review), smoke-test the server, write progress to $DIGEST. NO pm2 restart on cncp-listed domains besides morning-review itself, NO git push, NO modifications to dw_unified. Single git-style commit message per feature. If budget is tight, partial-ship + write FIXME blocks. End by writing a SHIPPED/PARTIAL/SKIPPED summary to $DIGEST.

SPEC:

$SPECS"

# 90-min cap via perl alarm (macOS lacks GNU timeout).
perl -e 'alarm shift; exec @ARGV' 5400 \
  /Users/macstudio3/.claude/local/claude --print "$PROMPT" >> "$LOG" 2>&1
RC=$?

echo "[overnight-build] claude rc=$RC $(date -Iseconds)" | tee -a "$LOG"

# Email digest via George (GEORGE_AUTH from env or default)
GEORGE_AUTH=${GEORGE_AUTH:-admin:DWSecure2024!}
if [ -s "$DIGEST" ]; then
  PAYLOAD=$(BODY="$(cat "$DIGEST")" /opt/homebrew/bin/node -e \
    'process.stdout.write(JSON.stringify({to:"steveabramsdesigns@gmail.com",subject:"Morning-review overnight build "+new Date().toISOString().slice(0,10),body:process.env.BODY}))')
  curl -sS --max-time 12 -X POST http://localhost:9850/api/send \
    -u "$GEORGE_AUTH" -H 'content-type: application/json' \
    -d "$PAYLOAD" >> "$LOG" 2>&1 || echo "[overnight-build] email failed" | tee -a "$LOG"
fi

exit $RC