"""Run with the isolated dev server stopped: python3 setup.py CHECKOUT WORKSPACE.
Then start with T3CODE_DEV_SEED=0 vp run dev, add WORKSPACE with the project CLI,
and use its project ID with drive.mjs CHECKOUT PROJECT_ID MODE MODEL.
Run MODE approval-required then full-access. MODEL is a locally available Claude model.
Capture the server's stdout and stderr for both runs.
"""
import json
import pathlib
import subprocess
import sys
root, workspace = map(pathlib.Path, sys.argv[1:])
p = root / '.t3/userdata/settings.json'
d = json.loads(p.read_text()) if p.exists() else {}
d.setdefault('providerInstances', {})['claude'] = {
    'driver': 'claudeAgent', 'enabled': True, 'config': {}
}
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(json.dumps(d))
workspace.mkdir(parents=True, exist_ok=True)
subprocess.run(['git', 'init', '-q', str(workspace)], check=True)
subprocess.run(['git', '-C', str(workspace), '-c', 'user.name=Evidence',
                '-c', 'user.email=evidence@example.invalid', 'commit',
                '--allow-empty', '-qm', 'Initial'], check=True)
