#!/usr/bin/env bash
# Copy the response schemas from the Python port to the TypeScript port.
#
# The two ports share these files BYTE FOR BYTE. Python is the source: edit
# `src/context_engine/llm_schemas/*.json`, run this, commit both directories.
# `tests/test_llm_schemas.py` and `js/tests/llm-schemas.test.ts` both fail if
# the directories drift, so a missed sync cannot reach a green suite.
set -euo pipefail

root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
src="$root/src/context_engine/llm_schemas"
dst="$root/js/src/llm-schemas"

mkdir -p "$dst"
# Remove JSON the Python side no longer ships, so a rename cannot leave a
# stale schema behind in the JS package.
for f in "$dst"/*.json; do
  [ -e "$f" ] || continue
  [ -e "$src/$(basename "$f")" ] || rm -v "$f"
done
for f in "$src"/*.json; do
  cp "$f" "$dst/"
  echo "synced $(basename "$f")"
done
