#!/usr/bin/env bash set -euo pipefail selection=() if (($#)); then if [[ "$#" -ne 2 || "$1" != "--plugins" || ! "$2" =~ ^(agents|multi-work|quota|optchat)(,(agents|multi-work|quota|optchat))*$ ]]; then printf 'Usage: %s [--plugins agents,multi-work,quota,optchat]\n' "$0" >&2 exit 2 fi if [[ ",$2," == *,multi-work,* && ",$2," != *,agents,* ]]; then printf 'Multi-work requires Agents\n' >&2 exit 2 fi selection=("$2") fi command -v bun >/dev/null || { printf 'Required command not found: bun\n' >&2; exit 1; } checkout=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P) config="${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}" mkdir -p "$config" config=$(cd "$config" && pwd -P) (cd "$checkout" && bun install --frozen-lockfile && bun run build) bun "$checkout/dist/install.js" "$checkout" "$config" "${selection[@]}"