#!/usr/bin/env python3
"""Run from either checkout. Arguments: thread-id, new output directory.
Prepare: create a fresh dev database with T3CODE_DEV_SEED=0; add a synthetic
project; start a Claude thread asking it to read large.txt; enable Context window.
Start browser recording before this script. Both runs use a 1280x800 light web UI.
The published recordings crop to the unmodified Context window meter for privacy.
"""
import datetime,json,pathlib,subprocess,sys,time
thread=sys.argv[1]
out=pathlib.Path(sys.argv[2]);out.mkdir(parents=True,exist_ok=False)
t0=time.monotonic();events=[]
for message in ['/clear','/context','Reply only: Fresh measurement.']:
    time.sleep(5)
    events.append({'seconds':round(time.monotonic()-t0,3),'message':message})
    p=subprocess.run(['node','apps/server/src/bin.ts','thread','send','--base-dir','.t3','--wait',thread,message],capture_output=True,text=True)
    if p.returncode: raise RuntimeError('Thread command failed')
time.sleep(5)
(out/'timing.json').write_text(json.dumps(events,indent=2))
