#!/usr/bin/env bash
set -euo pipefail
checkout=$1
state=$2
port=$3
cd "$checkout"
export T3CODE_PORT=$port
workspace="$state/workspaces/Search demo"
mkdir -p "$workspace"
printf '# Search demo\n' > "$workspace/README.md"
git -C "$workspace" init --quiet --initial-branch=main
git -C "$workspace" add README.md
git -C "$workspace" -c user.name=Scenario -c user.email=scenario@example.invalid commit --quiet -m 'Initial commit'
node apps/server/src/bin.ts project add "$workspace" --title 'Search demo' --base-dir "$state"
node apps/server/src/bin.ts thread start "$workspace" 'Plan the orchid garden' --title 'Orchid planning' --provider devReplay --model multi-turn --wait --json --base-dir "$state"
node apps/server/src/bin.ts thread start "$workspace" 'Plan the maple garden' --title 'Maple notes' --provider devReplay --model multi-turn --wait --json --base-dir "$state"
