#!/usr/bin/env bash set -euo pipefail usage() { cat <<'EOF' Install the private golem15 MSD build for Claude Code and Codex. Grok Build consumes the shared Codex skills or Claude compatibility surface. Usage: scripts/install-golem15.sh [--update] [--skip-deps] [--profile PROFILE] Options: --update Pull origin/next with --ff-only before installing. --skip-deps Do not run npm ci. --profile PROFILE MSD profile: core, standard, or full (default: full). -h, --help Show this help. EOF } update=false install_deps=true profile="${MSD_PROFILE:-full}" while (($#)); do case "$1" in --update) update=true ;; --skip-deps) install_deps=false ;; --profile) shift if (($# == 0)); then echo "ERROR: --profile requires a value." >&2 exit 2 fi profile="$1" ;; -h|--help) usage exit 0 ;; *) echo "ERROR: unknown argument: $1" >&2 usage >&2 exit 2 ;; esac shift done case "$profile" in core|standard|full) ;; *) echo "ERROR: profile must be core, standard, or full; got: $profile" >&2 exit 2 ;; esac script_dir=$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) repo_root=$(CDPATH='' cd -- "$script_dir/.." && pwd) cd "$repo_root" node_version=$(node --version 2>/dev/null || true) node_major=${node_version#v} node_major=${node_major%%.*} if [[ ! "$node_major" =~ ^[0-9]+$ ]] || ((node_major < 24)); then cat >&2 < Updating private mirror from origin/next" git pull --ff-only origin next fi if [[ "$install_deps" == true ]]; then echo "==> Installing locked dependencies" npm ci fi echo "==> Building runtime hooks from the private checkout" npm run build:hooks echo "==> Installing MSD for Claude Code (profile: $profile)" node bin/install.js --claude --global "--profile=$profile" echo "==> Installing MSD for Codex (profile: $profile)" node bin/install.js --codex --global "--profile=$profile" claude_root=${CLAUDE_CONFIG_DIR:-"$HOME/.claude"} codex_root=${CODEX_HOME:-"$HOME/.codex"} agents_root=${GROK_AGENTS_HOME:-"$HOME/.agents"} recovery_rel=msd-core/workflows/plan-phase/steps/agent-recovery-and-timing.md for install_root in "$claude_root" "$codex_root"; do if [[ ! -f "$install_root/$recovery_rel" ]]; then echo "ERROR: patched recovery workflow missing after install: $install_root/$recovery_rel" >&2 exit 1 fi done active_codex=$(command -v codex 2>/dev/null || true) bun_codex="$HOME/.bun/bin/codex" if [[ -x "$bun_codex" && "$active_codex" != "$bun_codex" ]]; then active_version=$(${active_codex:-false} --version 2>/dev/null || echo unknown) bun_version=$($bun_codex --version 2>/dev/null || echo unknown) cat >&2 </dev/null 2>&1; then grok_report=$(mktemp) trap 'rm -f "$grok_report"' EXIT shared_skill="$agents_root/skills/msd-plan-phase/SKILL.md" claude_skill="$claude_root/skills/msd-plan-phase/SKILL.md" if grok inspect --json >"$grok_report" 2>/dev/null \ && { grep -Fq "$shared_skill" "$grok_report" || grep -Fq "$claude_skill" "$grok_report"; }; then echo "==> Grok verified: msd-plan-phase skill discovered" else echo "WARNING: Grok did not report a compatible msd-plan-phase skill; restart Grok and run 'grok inspect'." >&2 fi fi cat <