#!/usr/bin/env bash
set -euo pipefail
# Run from either isolated checkout, with its own dev server already running:
# T3CODE_DEV_SEED=0 vp run dev
# Set EVIDENCE_DIR to the directory containing connector.py and gallery.js.
# Set EVIDENCE_MODEL to an available inexpensive Claude model.
: "${EVIDENCE_DIR:?}" "${EVIDENCE_MODEL:?}"
mkdir -p "$EVIDENCE_DIR/sdk" "$EVIDENCE_DIR/project"
npm install --prefix "$EVIDENCE_DIR/sdk" @modelcontextprotocol/ext-apps@2.0.4 esbuild@0.28.2
cp "$EVIDENCE_DIR/gallery.js" "$EVIDENCE_DIR/sdk/gallery.js"
"$EVIDENCE_DIR/sdk/node_modules/.bin/esbuild" "$EVIDENCE_DIR/sdk/gallery.js" --bundle --format=iife --outfile="$EVIDENCE_DIR/gallery-bundle.js"
python3 - "$EVIDENCE_DIR" <<'PY'
import sys,json,pathlib
r=pathlib.Path(sys.argv[1]).resolve()
(r/'project/.mcp.json').write_text(json.dumps({'mcpServers':{'synthetic-screens':{'command':'python3','args':[str(r/'connector.py')]}}}))
PY
node apps/server/src/bin.ts project add "$EVIDENCE_DIR/project" --title 'MCP App evidence' --base-dir .t3
node apps/server/src/bin.ts thread start "$EVIDENCE_DIR/project" 'Call mcp__synthetic-screens__search_screens with platform "ios" and query "fitness app paywall screen" exactly once. Do not call any other tools. After it succeeds, reply only "Search complete."' --base-dir .t3 --provider claudeAgent --model "$EVIDENCE_MODEL" --title 'Fitness paywall gallery' --json
