Files
msd-core/scripts/install-golem15.sh
2026-09-24 12:54:10 +02:00

140 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Install the private golem15 GSD 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 GSD profile: core, standard, or full (default: full).
-h, --help Show this help.
EOF
}
update=false
install_deps=true
profile="${GSD_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 <<EOF
ERROR: this GSD checkout requires Node.js 24 or newer.
Active Node: ${node_version:-not found}
Install/activate Node 24, then rerun this script.
EOF
exit 1
fi
if [[ "$update" == true ]]; then
echo "==> 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 "==> Installing GSD for Claude Code (profile: $profile)"
node bin/install.js --claude --global "--profile=$profile"
echo "==> Installing GSD 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=gsd-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 <<EOF
WARNING: PATH selects ${active_codex:-no Codex binary} (${active_version}),
but the newer Bun installation is $bun_codex (${bun_version}).
Put $HOME/.bun/bin before /usr/bin in PATH before starting Codex.
EOF
fi
if command -v grok >/dev/null 2>&1; then
grok_report=$(mktemp)
trap 'rm -f "$grok_report"' EXIT
shared_skill="$agents_root/skills/gsd-plan-phase/SKILL.md"
claude_skill="$claude_root/skills/gsd-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: gsd-plan-phase skill discovered"
else
echo "WARNING: Grok did not report a compatible gsd-plan-phase skill; restart Grok and run 'grok inspect'." >&2
fi
fi
cat <<EOF
Private GSD installation complete.
Source: $repo_root
Claude: $claude_root
Codex: $codex_root
Grok: $agents_root/skills (shared Codex surface, with Claude compatibility fallback)
Profile: $profile
Restart Claude Code, Codex, and Grok Build before using the updated skills.
For future updates run:
$repo_root/scripts/install-golem15.sh --update
EOF