import sqlite3,json,time,pathlib,sys
root=pathlib.Path(sys.argv[1]);root.mkdir(parents=True,exist_ok=True)
c=sqlite3.connect(root/'opencode.db')
c.execute('pragma journal_mode=WAL');c.execute('pragma wal_autocheckpoint=0')
c.execute('create table if not exists message(id text primary key,session_id text,time_created integer,time_updated integer,data text)')
c.execute('create index if not exists message_time on message(time_created)')
now=int(time.time()*1000)
body='synthetic assistant history '*20000
for i in range(4096):
 d=json.dumps(dict(role='assistant',modelID='gpt-4o',providerID='openai',time=dict(created=now),tokens=dict(input=1000,output=100,cache=dict(read=0,write=0)),cost=.01,content=body))
 c.execute('insert into message values(?,?,?,?,?)',(f'msg-{i}','synthetic-session',now,now,d))
 if i%256==0:c.commit()
c.commit()
print('Seeded 4096 assistant messages; expected 4,505,600 tokens and $40.96',flush=True)
# Keep a WAL connection open during captures.
while True:time.sleep(60)
