#!/usr/bin/env bash
set -euo pipefail
# Run in each checkout after its isolated server is running. The source dev server
# registers devReplay; that configuration also works in the desktop-owned server.
# Arguments: an existing empty directory for the synthetic git project, T3 home.
demo=$1
t3_home=$2
if ! git -C "$demo" rev-parse --git-dir >/dev/null 2>&1; then
  git init --initial-branch=main "$demo"
  git -C "$demo" -c user.name=Evidence -c user.email=evidence@example.invalid commit --allow-empty -m 'Initial commit'
fi
node apps/server/src/bin.ts project add "$demo" --title 'Keyboard menu demo' --base-dir "$t3_home"
node apps/server/src/bin.ts thread start "$demo" 'Show the keyboard menu demo' --title 'Keyboard focus example' --provider devReplay --model multi-turn --wait --json --base-dir "$t3_home"
