#!/usr/bin/env bash
# platform/.claude/scripts/ship.sh — FROZEN per-project land DATA. audience: AI agents.
# GENERATED by ship-init.sh — do not hand-edit logic; re-run ship-init.sh --force to re-sniff.
#
# This file is DATA, not logic. Every risky/orchestration step lives ONCE in the shared brain
# (finish-branch.sh `land`/`drift`); here we only pin the frozen facts and delegate. A brain
# contract change updates ALL projects at once. Re-init (re-sniff) only when drift fails (exit 3).
#
# This project lands by OPENING A PR — base is PR-gated; the brain NEVER pushes main in pr mode. The PR opens and the run stops; a human/CI merges it.
#
# Contract (from the brain): exit 0 PR opened/already-open · exit 20 agent-action-needed (read the JSON
# stage/next/detail, act, re-run — idempotent) · exit 3 drift/usage (re-sniff this wrapper).
set -uo pipefail

LIB="/home/user/.claude/workflows/lib/finish-branch.sh"

# ── FROZEN FACTS (sniffed once; the brain's drift-check defends them) ──────────────────────────
ROOT="/home/user/Projects/platform"
BASE="main"
MODE="pr"
ANCHOR="remote:https://github.com/platform-modules/mod"
TESTCMD="pnpm run gate"
DEPCMD="pnpm install --prefer-offline --silent"

case "${1:-}" in
  land)  shift; exec bash "$LIB" land --root "$ROOT" --base "$BASE" --mode "$MODE" \
                  --anchor "$ANCHOR" --testcmd "$TESTCMD" --depcmd "$DEPCMD" -- "$@";;
  drift) exec bash "$LIB" drift --root "$ROOT" --base "$BASE" --mode "$MODE" --anchor "$ANCHOR";;
  *) echo "usage: ship.sh {land <branch> <worktree> [--assets-ok]|drift}" >&2; exit 2;;
esac
