import pathlib,subprocess,json,sys
root=pathlib.Path(sys.argv[1]); home=root/'.t3'; project=home/'proof-workspace'
project.mkdir(exist_ok=True); (project/'README.md').write_text('Synthetic mobile color proof\n')
subprocess.run(['git','init','-q',str(project)],check=True)
subprocess.run(['git','-C',str(project),'add','.'],check=True)
subprocess.run(['git','-C',str(project),'-c','user.name=Proof','-c','user.email=proof@example.invalid','commit','-qm','Initial sample'],check=True)
def cli(args):
 p=subprocess.run(['node','apps/server/src/bin.ts',*args,'--base-dir',str(home)],cwd=root,text=True,capture_output=True)
 print(p.stdout,p.stderr); return p
cli(['project','add',str(project),'--title','Mobile color proof'])
results={}
for key,title,model,prompt in [('failure','Provider error','multi-turn','PROOF_PROVIDER_ERROR'),('question','Question preview','question','Ask a question'),('output','Command output','command-output','Print sample output')]:
 p=cli(['thread','start',str(project),prompt,'--title',title,'--provider','devReplay','--model',model,'--wait','--json'])
 try: results[key]=json.loads(p.stdout)
 except: results[key]={'stdout':p.stdout,'stderr':p.stderr}
(home/'proof-threads.json').write_text(json.dumps(results,indent=2))
