Files
okxlinandSisyphus cd62e4fab9 fix(opencode-workstation): use meta-package with baseline env flag
Replace platform-specific npm package resolution with the meta-package oh-my-opencode and OH_MY_OPENCODE_FORCE_BASELINE=1 env export. The meta-package's JS wrapper handles baseline binary selection, avoiding npm exec binary-not-found errors with platform-specific packages while still supporting non-AVX2 hosts. Also works around the OMO_PACKAGE env var leakage issue by making resolver always output the meta-package name.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-06 19:15:12 +08:00

55 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
claude_mode="${OMO_CLAUDE_MODE:-no}"
gemini_mode="${OMO_GEMINI_MODE:-${OMO_GEMINI:-0}}"
copilot_mode="${OMO_COPILOT_MODE:-${OMO_COPILOT:-0}}"
normalize_yes_no() {
case "$1" in
1|yes|true|on) printf 'yes' ;;
0|no|false|off|'') printf 'no' ;;
*) printf '%s' "$1" ;;
esac
}
claude_mode_normalized="$claude_mode"
case "$claude_mode" in
''|0|no|false|off) claude_mode_normalized='no' ;;
1|yes|true|on) claude_mode_normalized='yes' ;;
max|pro|team|max20) claude_mode_normalized='max20' ;;
esac
gemini_mode_normalized="$(normalize_yes_no "$gemini_mode")"
copilot_mode_normalized="$(normalize_yes_no "$copilot_mode")"
args=(
install
--no-tui
--claude "$claude_mode_normalized"
--gemini "$gemini_mode_normalized"
--copilot "$copilot_mode_normalized"
)
append_if_enabled() {
local env_name="$1"
local flag="$2"
if [[ "${!env_name:-0}" == "1" ]]; then
args+=("${flag}")
fi
}
append_if_enabled OMO_OPENAI --openai
append_if_enabled OMO_OPENCODE_GO --opencode-go
append_if_enabled OMO_OPENCODE_ZEN --opencode-zen
append_if_enabled OMO_VERCEL_AI_GATEWAY --vercel-ai-gateway
mapfile -t _omo_lines < <(bash "${SCRIPT_DIR}/resolve-omo-package.sh")
package_name="${_omo_lines[0]}"
unset _omo_lines
printf 'npm exec --yes --package=%q -- oh-my-opencode' "${package_name}"
printf ' %q' "${args[@]}"
printf '\n'