Files
stanp-opencode/install-local.sh
2026-10-10 13:17:48 +02:00

22 lines
870 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
selection=()
if (($#)); then
if [[ "$#" -ne 2 || "$1" != "--plugins" || ! "$2" =~ ^(agents|multi-work|quota)(,(agents|multi-work|quota))*$ ]]; then
printf 'Usage: %s [--plugins agents,multi-work,quota]\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[@]}"