#!/usr/bin/env bash # Self-contained smoke test: bring a 2-agent example project up and tear it down in an ISOLATED # sandbox (its own session_prefix + a throwaway log_dir), using only files in this repo and no # external agent CLI (the demo backend is just a shell that idles). Cleans up after itself. # # Usage: ./smoke.sh → prints "SMOKE PASS" and exits 0 on success. set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" PREFIX="ao-smoke-$$-" SANDBOX="$(mktemp -d)" CFG="$SANDBOX/agents.toml" cleanup() { local rc=$? python3 "$HERE/agents.py" --config "$CFG" down >/dev/null 2>&1 || true # belt-and-suspenders: kill any session that still carries our unique prefix if command -v tmux >/dev/null 2>&1; then tmux ls 2>/dev/null | sed 's/:.*//' | grep "^${PREFIX}" | while read -r s; do tmux kill-session -t "=$s" 2>/dev/null || true done || true fi rm -rf "$SANDBOX" exit "$rc" } trap cleanup EXIT fail() { echo "SMOKE FAIL: $1" >&2; exit 1; } command -v tmux >/dev/null 2>&1 || fail "tmux not on PATH (run inside 'nix develop')" # A throwaway config: project_dir points back at the repo so prompts/ resolve, but session_prefix # and log_dir are unique + temporary, so this run can never touch a real project's sessions. cat > "$CFG" </dev/null \ || fail "status on agents.example.toml failed" echo "== bring up isolated sandbox ($PREFIX) ==" python3 "$HERE/agents.py" --config "$CFG" up builder adversary for s in "${PREFIX}builder" "${PREFIX}adversary"; do tmux has-session -t "=$s" 2>/dev/null || fail "$s did not start" echo " up: $s" done # the kickoff prompt should have been assembled (template preamble + role prompt) into state/ KF="$SANDBOX/state/state/kickoff-${PREFIX}builder.txt" test -s "$KF" || fail "kickoff file not written ($KF)" grep -q "PROJECT PHASE: smoke" "$KF" || fail "kickoff template not rendered into kickoff" grep -q "You are the \*\*Builder\*\*" "$KF" || fail "role prompt not appended to kickoff" echo " kickoff assembled OK (template + role prompt)" echo "== tear down ==" python3 "$HERE/agents.py" --config "$CFG" down builder adversary sleep 1 for s in "${PREFIX}builder" "${PREFIX}adversary"; do ! tmux has-session -t "=$s" 2>/dev/null || fail "$s still alive after down" echo " down: $s" done echo "SMOKE PASS"