#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"

echo "==> Python unit tests"
python3 -m pytest -q tests/unit

echo "==> Shell syntax checks"
bash -n tests/test-two-console-demo.sh
bash -n tests/test-two-console-demo-agent.sh
bash -n tests/test-two-console-demo-agent-approval.sh

echo "==> Python syntax checks"
python3 -m py_compile \
  scripts/http-audit-summary.py \
  scripts/pi-session-timing.py \
  scripts/rho-agent-run.py \
  scripts/rho-controlled-action-relay.py \
  scripts/rho_fixture_scrub.py \
  scripts/rho-request.py \
  tests/run_yaml_scenario.py

echo "==> Scenario YAML parse"
python3 - <<'PY'
import pathlib
import yaml

for path in [
    "tests/scenarios/two-console-demo/scenario.yaml",
    "tests/scenarios/two-console-demo-agent/scenario.yaml",
    "tests/scenarios/two-console-demo-agent-approval/scenario.yaml",
]:
    yaml.safe_load(pathlib.Path(path).read_text())
    print(f"ok: {path}")
PY

echo "PASS"
