#!/bin/bash
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/without2"
  P="Install Plausible Analytics Community Edition (self-hosted) on this machine with Docker, with whatever databases it needs, so it runs and its registration or login page loads in a browser. Work only inside the current directory. Publish it on host port 18081 only, and do not touch any other containers, networks or volumes on this machine. When you are done, verify with curl that http://localhost:18081/ responds (200, or a redirect to the register or login page), then report the URL. Do not ask me questions; make reasonable choices."
else
  cd "$E/with2"
  P="Install Plausible Analytics Community Edition (self-hosted) on this machine, with whatever databases it needs, so it runs and its registration or login page loads in a browser. This machine has Zeltro installed; its docs are in /usr/local/share/zeltro-cli/AGENTS.md. Name the project plausible-test, and do not touch any other projects, containers, networks or volumes. When you are done, verify with curl that the app responds (200, or a redirect to the register or login page), then report the URL. Do not ask me questions; make reasonable choices."
fi
start=$(date +%s)
timeout 2400 claude -p "$P" --model sonnet --output-format json --max-turns 80 --dangerously-skip-permissions > "$out" 2> "$out.err"
echo "{\"wall_seconds\": $(( $(date +%s) - start )), \"exit\": $?}" > "$out.meta"
