#!/usr/bin/env bash # Launch OpenCode 2 with an isolated config so it cannot rewrite # ~/.config/opencode/opencode.json (OpenCode 1 / firstmate). set -euo pipefail bin="${OPENCODE2_BIN:-/opt/homebrew/bin/opencode2}" cfg="${OPENCODE_CONFIG:-$HOME/.config/opencode2/opencode.json}" if [ ! -x "$bin" ]; then echo "oc2: opencode2 not installed. Rebuild, or run:" >&2 echo " /opt/homebrew/bin/npm install -g --allow-scripts=@opencode-ai/cli @opencode-ai/cli@beta" >&2 exit 1 fi if [ ! -e "$cfg" ]; then echo "oc2: missing config $cfg (managed by home.nix)" >&2 exit 1 fi export OPENCODE_CONFIG="$cfg" exec "$bin" "$@"