#!/bin/bash
# usage: run.sh <without|with> <outfile>
E=$(cd "$(dirname "$0")" && pwd)
mode=$1; out=$2
for v in $(compgen -e | grep -E "^(CLAUDE|CLAUDECODE)"); do unset "$v"; done
if [ "$mode" = without ]; then
  cd "$E/without"
  P="Install Ghost (the open-source blogging platform) on this machine with Docker, backed by a MySQL database, so it runs and its admin setup page loads in a browser. Work only inside the current directory. Publish it on host port 18080 only, and do not touch any other containers, networks or volumes on this machine. When you are done, verify with curl that http://localhost:18080/ghost/ responds (200, or a redirect to the setup page), then report the URL. Do not ask me questions; make reasonable choices."
else
  cd "$E/with"
  P="Install Ghost (the open-source blogging platform) on this machine, backed by a MySQL database, so it runs and its admin setup page loads in a browser. This machine has Zeltro installed; its docs are in /usr/local/share/zeltro-cli/AGENTS.md. Name the project ghost-test, and do not touch any other projects, containers, networks or volumes. When you are done, verify with curl that the Ghost admin (/ghost/) responds (200, or a redirect to the setup page), then report the URL. Do not ask me questions; make reasonable choices."
fi
start=$(date +%s)
timeout 1500 claude -p "$P" --model sonnet --output-format json --max-turns 60 --dangerously-skip-permissions > "$out" 2> "$out.err"
echo "{\"wall_seconds\": $(( $(date +%s) - start )), \"exit\": $?}" > "$out.meta"
