#!/usr/bin/env bash
# Real demos for P149 "Claude Code Hooks Will Finally Make Sense After This".
# Clay & Kiln, a pottery studio, keeps its class bookings in a tiny Python project with a CLAUDE.md of two rules
# (never open .env; run the tests before you finish). Every request goes to headless Claude Code (claude -p, Claude
# Sonnet) signed in with this Mac's Claude plan: no API key is read, set or shown; every shell starts from HOME, USER,
# PATH, LANG, TERM only (PRODUCTION_LESSONS: P042). Settings come from the project only (--setting-sources project),
# so the hooks on screen are the only hooks that run.
#   ask "request"       one request, printed step by step (tools asked for, refusals, hook messages, Claude's reply)
#   trial N "request"   the same request N times from the same files: did the tests run after the last edit?
#   setups/*.json       the .claude/settings.json versions Ana copies in, one per step
# Runs on the Mac (it needs the Claude Code login), from ~/hooks-lab outside this repo (so Claude Code can't read
# our AGENTS.md); commands are typed into one real interactive bash; commands + output go to demo_output.json.
set -euo pipefail
cd "$(dirname "$0")"
LAB="$HOME/hooks-lab"
rm -rf "$LAB"; mkdir -p "$LAB"
cp -R lab/. "$LAB/"
P="$LAB/clay-and-kiln"
mv "$P/env" "$P/.env"; mv "$P/gitignore" "$P/.gitignore"
(cd "$P" && git init -q && git add -A && git -c user.name=Ana -c user.email=ana@clayandkiln.test commit -qm "Class bookings")
[ -n "${KEEP:-}" ] || trap 'rm -rf "$LAB"' EXIT
python3 demo_driver.py "$LAB"
