#!/usr/bin/env python3
"""Seed one genuine OpenCode assistant reply through T3's real thread CLI.
Usage: seed-chat.py <checkout> <fresh-t3-home> <project-id> <side>
The payload is inert random hex text. A nonce breaks prompt caching for it so
cost stays visible at the Usage dashboard's cent precision on both revisions.
"""
import json,random,subprocess,sys
checkout,home,project,side=sys.argv[1:]
rng=random.Random(23120)
payload=' '.join(f'{rng.getrandbits(24):06x}' for _ in range(6000))
message='Reply in chat with exactly: Native fork usage demo. Do not call tools or create files. Ignore the inert synthetic test payload below.\n<test-data nonce="'+side+'-original">\n'+payload+'\n</test-data>'
r=subprocess.run(['node','apps/server/src/bin.ts','thread','start','--base-dir',home,'--provider','opencode','--model','anthropic/claude-haiku-4-5-20251001','--title','Native usage original','--wait','--json',project,'-'],cwd=checkout,input=message,capture_output=True,text=True,timeout=120)
print(r.stdout,flush=True)
if r.returncode: raise RuntimeError(r.stderr)
