import pathlib, subprocess, json, sys
repo=pathlib.Path.cwd()
home=repo/('.t3/proof-'+sys.argv[1])
fixture=repo/'apps/server/scripts/dev-replay/showcase_transcript.ndjson'
entries=[{'type':'expect_outbound','frame':{'kind':'request','method':'session/prompt','params':{}}},{'type':'emit_inbound','frame':{'kind':'notification','method':'session/update','params':{'sessionId':'replay','update':{'sessionUpdate':'agent_message_chunk','content':{'type':'text','text':'\ufeff:codex-file-citation{path="/tmp/x.md"}'}}}}},{'type':'emit_inbound','frame':{'kind':'response','method':'session/prompt','result':{'stopReason':'end_turn'}}}]
fixture.write_text('\n'.join(map(json.dumps, entries))+'\n')
workspace=home/'workspaces/Citation demo'
workspace.mkdir(parents=True,exist_ok=True)
(workspace/'README.md').write_text('Synthetic citation reproduction\n')
def run(*cmd):
 return subprocess.check_output(cmd,text=True)
run('git','-C',str(workspace),'init','--quiet','--initial-branch=main')
run('git','-C',str(workspace),'add','README.md')
run('git','-C',str(workspace),'-c','user.name=Scenario','-c','user.email=scenario@example.invalid','commit','--quiet','-m','Initial commit')
cli=['node','apps/server/src/bin.ts']
print(run(*cli,'project','add',str(workspace),'--title','Citation demo','--base-dir',str(home)))
print(run(*cli,'thread','start',str(workspace),'cite the file','--title','BOM citation','--provider','devReplay','--model','showcase','--wait','--json','--base-dir',str(home)))
