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

if ! grep -q -- "# AgentRail" README.md; then
  echo "README does not present the project as AgentRail" >&2
  exit 1
fi

if ! grep -q -- "npx --package github:Bensigo/agentrail agentrail init --target ." README.md; then
  echo "README does not document the immediate AgentRail install path" >&2
  exit 1
fi

if ! grep -q -- "curated first-party skills" README.md; then
  echo "README does not document curated first-party skills" >&2
  exit 1
fi

if ! grep -q -- "not arbitrary third-party hot installs" README.md; then
  echo "README does not reject arbitrary third-party hot installs" >&2
  exit 1
fi

if ! grep -q -- "agentrail skills list --target ." README.md; then
  echo "README does not document agentrail skills list with an example" >&2
  exit 1
fi

if ! grep -q -- "agentrail skills resolve \"fix Tauri desktop UI\" --target ." README.md; then
  echo "README does not document agentrail skills resolve with the required example" >&2
  exit 1
fi

if ! grep -q -- "agentrail prompt issue 123 --skill frontend-web --no-auto-skills --target ." README.md; then
  echo "README does not document --skill and --no-auto-skills with an example" >&2
  exit 1
fi

if ! grep -q -- '"agentrail": "./scripts/agentrail"' package.json; then
  echo "package.json does not expose the agentrail CLI command" >&2
  exit 1
fi

legacy_product_name="Bensigo"" harness"
if grep -R -q -- "$legacy_product_name" README.md package.json templates skills scripts; then
  echo "public docs still use the legacy Bensigo product name" >&2
  exit 1
fi

echo "public positioning test passed"
