"""Run from either installed checkout with its isolated dev server running.
Supply a fresh output directory and a configured Claude model alias.
Record the app while this runs, then open the returned thread in the web client.
AI-assisted; verified with the tests and tools listed above.
"""
import pathlib, subprocess, json, sys
out = pathlib.Path(sys.argv[1]); out.mkdir(parents=True, exist_ok=False)
project = out / "slow-hook"; project.mkdir(); (project / ".claude").mkdir()
(project / ".claude/settings.json").write_text(json.dumps({"hooks":{"SessionStart":[{"matcher":"startup","hooks":[{"type":"command","command":"bash .claude/setup.sh","timeout":600}]}]}}))
(project / ".claude/setup.sh").write_text("#!/bin/bash\nif [ ! -f .claude/setup-complete ]; then\n date -u +%FT%TZ > .claude/setup-started\n sleep 105\n date -u +%FT%TZ > .claude/setup-complete\nfi\n")
(project / ".gitignore").write_text(".claude/setup-started\n.claude/setup-complete\n")
for args in [["init","-q","-b","main"],["add","."],["-c","user.name=Evidence","-c","user.email=evidence@example.invalid","commit","-qm","Setup reproduction"]]:
 subprocess.run(["git",*args],cwd=project,check=True)
def cli(args):
 return subprocess.check_output(["node","apps/server/src/bin.ts",*args,"--base-dir",".t3"],text=True)
print(cli(["project","add",str(project),"--title","Slow startup hook"]))
print(cli(["thread","start",str(project),"reply ok","--provider","claudeAgent","--model",sys.argv[2],"--worktree","main","--branch","slow-hook-proof","--title","105-second startup","--json"]))
