#!/usr/bin/env python3
"""Seed synthetic reproduction workspace through the real T3 CLI."""
import argparse,json,subprocess
from pathlib import Path
ap=argparse.ArgumentParser();ap.add_argument('--checkout',type=Path,required=True);ap.add_argument('--home',type=Path,required=True);ap.add_argument('--workspace',type=Path,required=True);a=ap.parse_args()
p=a.workspace.resolve();(p/'.agents').mkdir(parents=True,exist_ok=True)
h={'enabled':True,'PreToolUse':[{'matcher':'*','hooks':[{'type':'command','command':'/bin/true'}]}],'PostToolUse':[{'matcher':'*','hooks':[{'type':'command','command':'/bin/true'}]}]}
(p/'.agents/hooks.json').write_text(json.dumps({'noop':h},indent=2));(p/'README.md').write_text('Synthetic workspace for local harness recovery.\n')
if not (p/'.git').exists():
 subprocess.run(['git','init','-b','main',str(p)],check=True)
 subprocess.run(['git','-C',str(p),'add','.'],check=True)
 subprocess.run(['git','-C',str(p),'-c','user.name=Evidence','-c','user.email=evidence@example.invalid','commit','-m','Synthetic workspace'],check=True)
subprocess.run(['node','apps/server/src/bin.ts','project','add','--base-dir',str(a.home.resolve()),'--title','Harness recovery',str(p)],cwd=a.checkout,check=True)
