import os,json,sqlite3,pathlib,datetime root=pathlib.Path(__file__).parent home=root/'synthetic-home' project=root/'sample-project' scratch=home/'Documents/Codex/2026-11-10/new-chat' codex=home/'.codex' for p in (project,scratch,codex/'sessions/2026/11/10'):p.mkdir(parents=True,exist_ok=True) now=datetime.datetime.now(datetime.timezone.utc).isoformat().replace('+00:00','Z') chats=[('019a5f00-0000-7000-8000-00000000000a',scratch,'Started with no project'),('019a5f00-0000-7000-8000-00000000000b',project,'Started in the project')] db=sqlite3.connect(codex/'state_5.sqlite') db.executescript('CREATE TABLE projects(id TEXT PRIMARY KEY); CREATE TABLE project_roots(project_id TEXT,position INTEGER,path TEXT); CREATE TABLE threads(id TEXT PRIMARY KEY,rollout_path TEXT,cwd TEXT,project_id TEXT);') db.execute('INSERT INTO projects VALUES (?)',('sample',)) db.execute('INSERT INTO project_roots VALUES (?,0,?)',('sample',str(project))) for id,cwd,title in chats: p=codex/'sessions/2026/11/10'/f'rollout-2026-11-10T12-00-00-{id}.jsonl' records=[{'timestamp':now,'type':'session_meta','payload':{'id':id,'cwd':str(cwd)}},{'timestamp':now,'type':'turn_context','payload':{'cwd':str(cwd)}},{'timestamp':now,'type':'event_msg','payload':{'type':'user_message','message':title}},{'timestamp':now,'type':'response_item','payload':{'type':'message','role':'assistant','content':[{'type':'output_text','text':'Synthetic chat ready for import.'}]}}] p.write_text('\n'.join(map(json.dumps,records))+'\n') db.execute('INSERT INTO threads VALUES (?,?,?,?)',(id,str(p),str(cwd),'sample')) db.commit();db.close() print('Created two synthetic Codex chats; both assigned to sample-project, one retains scratch cwd.')