#!/usr/bin/env bash
set -euo pipefail
# Run once per fresh server: seed.sh <checkout> <isolated-home> <synthetic-workspace>
checkout=$1
data_dir=$2
workspace=$3
mkdir -p "$workspace"
git init --initial-branch=main "$workspace"
git -C "$workspace" remote add origin https://github.com/pingdotgg/t3code.git
cd "$checkout"
node apps/server/src/bin.ts project add "$workspace" --title Shortcut-proof --base-dir "$data_dir"
node apps/server/src/bin.ts thread start "$workspace" Hello --title 'Link target' --provider devReplay --model multi-turn --wait --json --base-dir "$data_dir"
python3 - "$data_dir" <<'PY'
import json, pathlib, sys
p = pathlib.Path(sys.argv[1]) / 'userdata/keybindings.json'
rules = json.loads(p.read_text())
rules.append({'key': 'alt+w', 'command': 'rightPanel.close', 'when': '!terminalFocus'})
p.write_text(json.dumps(rules, indent=2))
PY
