#!/usr/bin/env python3
"""Create synthetic Pi question threads through the real T3 CLI.
Usage: seed.py CHECKOUT T3_HOME PROJECT [basic|preview|interleaved]
Install @juicesharp/rpiv-ask-user-question@2.15.0 and configure Pi launchArgs
with --extension pointing at its index.ts (interleaved.ts for the last mode).
Start each checkout using T3CODE_DEV_SEED=0 vp run dev before this script.
"""
import json, pathlib, subprocess, sys
checkout, home, project = sys.argv[1:4]
mode = sys.argv[4] if len(sys.argv)>4 else 'basic'
q={'header':'Area','question':'Which area should we work on?','options':[
 {'label':'Docker/Compose','description':'Review or edit Compose projects'},
 {'label':'Home Assistant','description':'Automations, dashboards or YAML'}]}
questions=[q]
if mode=='preview':
 q['options'][0]['preview']='services:\n  web: {}'
 questions.append({**q,'question':q['question']+' Only for staging?'})
prompt='Call ask_user_question exactly once with these exact arguments. Do not call other tools. After it returns say only Done. Do not summarize or reinterpret the result.\n'+json.dumps({'questions':questions})
title={'basic':'Literal custom answer proof','preview':'Preview and full title','interleaved':'Interleaved dialogs'}[mode]
subprocess.run(['node','apps/server/src/bin.ts','thread','start',project,'-','--title',title,'--provider','pi','--model','openai/gpt-6-luna','--base-dir',home,'--json'],cwd=checkout,input=prompt,text=True,check=True)
