"""Run from either tested checkout after starting its isolated development server.
Usage: python seed-real-provider.py ISOLATED_HOME
CURSOR_API_KEY must already be present in the server environment.
"""
import json,pathlib,subprocess,sys
home=pathlib.Path(sys.argv[1]);p=home/'userdata/settings.json'
s=json.loads(p.read_text());s['providerInstances']['cursor']={'driver':'cursor','enabled':True};s['followUpBehavior']='steer';s['defaultRuntimeMode']='full-access';p.write_text(json.dumps(s))
repo=home/'demo';repo.mkdir(exist_ok=True)
subprocess.run(['git','init',str(repo)],check=True,capture_output=True)
(repo/'README.md').write_text('# Queued edit demo\n')
subprocess.run(['git','-C',str(repo),'add','README.md'],check=True)
subprocess.run(['git','-C',str(repo),'-c','user.name=Demo','-c','user.email=demo@example.com','commit','-m','Initial demo'],check=True,capture_output=True)
def cli(args):return subprocess.check_output(['node','apps/server/src/bin.ts',*args,'--base-dir',str(home)],text=True)
print(cli(['project','add',str(repo),'--title','Queued edit demo']))
for title in ['Queued edit capture','Mobile queued edit']:
 print(cli(['thread','start',str(repo),'Run sleep 1200 in the foreground shell and wait for it to finish. Do not edit files or run background commands.','--title',title,'--provider','cursor','--model','auto','--json']))
