"""Run from a checkout whose fresh dev server is already listening.
Usage: python3 driver.py CHECKOUT DATA_ROOT
Keep seed.py and prompt.txt beside this script. DATA_ROOT must not exist yet.
Record the web client while resending prompt.txt in the resulting parent thread.
"""
import pathlib,subprocess,sys
checkout=pathlib.Path(sys.argv[1]).resolve()
data=pathlib.Path(sys.argv[2]).resolve()
here=pathlib.Path(__file__).parent
subprocess.run([sys.executable,str(here/'seed.py'),str(data)],check=True)
cli=['node','apps/server/src/bin.ts']
def run(args,**kwargs):return subprocess.run(cli+args+['--base-dir',str(checkout/'.t3')],cwd=checkout,check=True,text=True,**kwargs)
run(['project','add',str(data/'a'),'--track',str(data/'b'),'--title','Branch inheritance proof'])
run(['thread','start','--provider','codex','--model','gpt-6-luna','--title','Release branch parent','--wait','--json',str(data/'a'),'-'],input=(here/'prompt.txt').read_text())
subprocess.run([sys.executable,str(here/'verify.py'),str(data)],check=True)
