#!/usr/bin/env bash
# PMOS portable kit — kernel update (D54). Runs FROM the vendored kit inside a target repo:
#
#   pmos/scripts/kit-update.sh <path-to-pmos-checkout>
#
# Re-vendors ONLY the kernel (skills/, okf/core/, scripts/, check_rubrics.py, AGENTS.md, README.md,
# templates/) from the given PMOS checkout, stamps KIT-VERSION, and never touches state/,
# planning/ (beyond check_rubrics.py), or okf/product/. Updates flow one-way, PMOS -> kit.
# Review the resulting diff as a normal PR.
set -euo pipefail

[ -n "${1:-}" ] || { echo "usage: kit-update.sh <path-to-pmos-checkout>" >&2; exit 1; }
SRC="$1"
KIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
[ -x "$SRC/kit/build-kit.sh" ] || { echo "kit-update: ERROR — $SRC is not a PMOS checkout (no kit/build-kit.sh)" >&2; exit 1; }
exec "$SRC/kit/build-kit.sh" --update "$KIT"
