import subprocess,json,sys,os
from pathlib import Path
checkout,home,workspace=sys.argv[1:]
def cli(*args):
 p=subprocess.run(['node','apps/server/src/bin.ts',*args,'--base-dir',home],cwd=checkout,text=True,capture_output=True,check=True)
 return p.stdout
cli('project','add',workspace,'--title','Compaction proof')
first=json.loads(cli('thread','start',workspace,'Remember marker CEDAR. Reply exactly: CEDAR stored.','--title','Manual compaction','--provider','pi','--model','proof/gpt-6-luna','--wait','--json'))
second=json.loads(cli('thread','send',first['threadId'],'Reply exactly: Ready to compact CEDAR.','--wait','--json'))
Path(home,'seed-result.json').write_text(json.dumps({'first':first,'second':second},indent=2))
print(json.dumps({'threadId':first['threadId']}))
