#!/usr/bin/env bash
set -eu
app_dir="$1"
state_home="$2"
workspace="$state_home/workspaces/Garden-planning"
mkdir -p "$workspace"
git -C "$workspace" init --quiet --initial-branch=main
printf 'Synthetic garden planning example.\n' > "$workspace/README.md"
git -C "$workspace" add README.md
git -C "$workspace" -c user.name=Scenario -c user.email=scenario@example.invalid commit --quiet -m 'Initial commit'
cd "$app_dir"
node apps/server/src/bin.ts project add "$workspace" --title 'Garden planning' --base-dir "$state_home"
node apps/server/src/bin.ts thread start "$workspace" 'Help me plan a garden' --title 'Garden questionnaire' --provider devReplay --model question --base-dir "$state_home" --wait --json || test "$?" = 2
