#!/usr/bin/env bash
# Cursor is retired: every ca.sh copy refuses every invocation.
set -uo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
FAIL=0

check() {
  local script="$1"; shift
  local out rc
  out="$("$script" "$@" 2>&1 </dev/null)"; rc=$?
  if [[ $rc -ne 3 ]]; then
    echo "FAIL $script: exit $rc, want 3"; FAIL=1
  fi
  if [[ "$out" != *"We dont have cursor anymore."* ]]; then
    echo "FAIL $script: missing retirement message; got: $out"; FAIL=1
  fi
}

for script in "$ROOT/modules/harness/wrappers/ca.sh" \
              "$ROOT/modules/workstation/codex/skills/cursor-orchestrator/ca.sh"; do
  check "$script"
  check "$script" --health
  check "$script" --workspace "$ROOT" --trust "hi" --task-slug t --model auto
done

[[ $FAIL -eq 0 ]] && echo "ok: ca.sh retired" || exit 1
