#!/usr/bin/env bash
# Recreates the synthetic files and isolated provider settings used for this proof.
# Arguments: scratch directory, checkout directory. Start each side on a fresh T3 home.
set -euo pipefail
scratch=$(realpath "$1")
checkout=$(realpath "$2")
npm install --prefix "$scratch/opencode" @opencode/cli@2.2.2
python3 - "$scratch" "$checkout" <<'PYTHON'
import json,sys
from pathlib import Path
s,w=map(Path,sys.argv[1:])
p=s/'project';p.mkdir(exist_ok=True)
(p/'README.md').write_text('Synthetic command reproduction.\n')
plugin=s/'plugin';plugin.mkdir(exist_ok=True)
(plugin/'package.json').write_text(json.dumps({'name':'repro-noop-command','version':'1.0.0','type':'module','main':'index.js'}))
# Put the accompanying plugin.js here as index.js.
(plugin/'index.js').write_text((s/'plugin.js').read_text())
(p/'opencode.json').write_text(json.dumps({'plugins':[str(plugin)]}))
home=w/'.t3/userdata';home.mkdir(parents=True,exist_ok=True)
instances={k:{'driver':k,'enabled':False} for k in ['codex','claudeAgent','cursor','grok','muse','pi','antigravity']}
instances['opencode']={'driver':'opencode','enabled':True,'config':{'binaryPath':str(s/'opencode/node_modules/.bin/opencode')}}
(home/'settings.json').write_text(json.dumps({'providerInstances':instances}))
PYTHON
git -C "$scratch/project" init --quiet --initial-branch=main
git -C "$scratch/project" add .
git -C "$scratch/project" -c user.name=Evidence -c user.email=evidence@example.invalid commit -qm 'Synthetic workspace'
cd "$checkout"
# Start in a retained terminal; do not detach.
T3CODE_DEV_SEED=0 T3CODE_ENVIRONMENT_LABEL=Evidence T3CODE_ENVIRONMENT_MACHINE_KIND=laptop vp run dev
# In another terminal:
# node apps/server/src/bin.ts project add "$scratch/project" --title 'Command demo' --base-dir .t3
# Then pair the web client and follow browser-steps.json.
