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

repo="${1:-.}"

if [ ! -d "$repo/.git" ]; then
  echo "Not a git repository: $repo" >&2
  exit 2
fi

cd "$repo"

violations="$(
  {
    git diff --name-only -- prompt || true
    git diff --cached --name-only -- prompt || true
    git ls-files --others --exclude-standard -- prompt || true
  } | sort -u
)"

if [ -n "$violations" ]; then
  echo "Target-repo prompt boundary violation:"
  echo "$violations"
  echo
  echo "Move these assets to zhctprompt/work_store/<ticket-or-topic>/ and remove them from the target-repo diff before commit or MR."
  exit 1
fi

echo "OK: no target-repo prompt changes detected."
