Hand out the right opencode command: the API's public URL, and setup uses the install script
install-newt now asks for the API's public URL first (--api-url) and records it; it names the Pangolin resource and refuses an endpoint on the same host. expose-dashboard records only that the dashboard is public. One rule (opencode.client_targets) decides which opencode-install.sh commands are shown -- local only without a tunnel; internet and local with one; internet only once the dashboard is public -- and setup's closing message, `llmhost opencode-config` and the dashboard's Connect dialog all use it. Setup's offer to install opencode now goes through opencode-install.sh --install-only, a new mode that only installs opencode; this machine's own provider is still configured by llm-host, which keeps it in sync on every switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c8b70afdbf
commit
3e9ebeed42
10 changed files with 266 additions and 109 deletions
|
|
@ -24,6 +24,7 @@
|
|||
# --default make it opencode's default model without asking
|
||||
# --no-default leave opencode's default model alone
|
||||
# --skip-install don't install opencode, only configure it
|
||||
# --install-only only install opencode (no --url or key needed); `llmhost setup` uses this
|
||||
# --remove take this server back out of opencode's config
|
||||
# Written for bash 3.2 so it runs on stock macOS.
|
||||
set -euo pipefail
|
||||
|
|
@ -44,12 +45,13 @@ Connect opencode to an llm-host server, installing opencode first if needed.
|
|||
--default make it opencode's default model without asking
|
||||
--no-default leave opencode's default model alone
|
||||
--skip-install don't install opencode, only configure it
|
||||
--install-only only install opencode (no --url or key needed)
|
||||
--remove take this server back out of opencode's config
|
||||
EOF
|
||||
}
|
||||
|
||||
[ "${1:-}" = "--" ] && shift
|
||||
URL=""; KEY="${LLMHOST_API_KEY:-}"; DEFAULT="ask"; INSTALL=1; REMOVE=0
|
||||
URL=""; KEY="${LLMHOST_API_KEY:-}"; DEFAULT="ask"; INSTALL=1; REMOVE=0; INSTALL_ONLY=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--url) URL="${2:-}"; shift 2 ;;
|
||||
|
|
@ -59,12 +61,30 @@ while [ $# -gt 0 ]; do
|
|||
--default) DEFAULT="yes"; shift ;;
|
||||
--no-default) DEFAULT="no"; shift ;;
|
||||
--skip-install) INSTALL=0; shift ;;
|
||||
--install-only) INSTALL_ONLY=1; shift ;;
|
||||
--remove) REMOVE=1; shift ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
*) die "unknown option: $1 (see --help)" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
find_opencode() {
|
||||
OC="$(command -v opencode || true)"
|
||||
if [ -z "$OC" ] && [ -x "$HOME/.opencode/bin/opencode" ]; then OC="$HOME/.opencode/bin/opencode"; fi
|
||||
}
|
||||
install_opencode() {
|
||||
say "Installing opencode (official installer)"
|
||||
curl -fsSL https://opencode.ai/install | bash
|
||||
find_opencode
|
||||
[ -n "$OC" ] || die "opencode didn't install; see the output above"
|
||||
}
|
||||
|
||||
if [ "$INSTALL_ONLY" = 1 ]; then
|
||||
find_opencode
|
||||
if [ -n "$OC" ]; then say "opencode is already installed ($OC)"; else install_opencode; fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# A terminal to ask on, even when this script arrived on stdin.
|
||||
TTY=""
|
||||
if [ -r /dev/tty ] && [ -w /dev/tty ] && (: </dev/tty) 2>/dev/null; then TTY=/dev/tty; fi
|
||||
|
|
@ -168,15 +188,10 @@ fi
|
|||
say "Server OK"
|
||||
|
||||
# ---- opencode ------------------------------------------------------------------------
|
||||
OC="$(command -v opencode || true)"
|
||||
[ -n "$OC" ] || { [ -x "$HOME/.opencode/bin/opencode" ] && OC="$HOME/.opencode/bin/opencode"; } || true
|
||||
find_opencode
|
||||
if [ -z "$OC" ]; then
|
||||
if [ "$INSTALL" = 1 ]; then
|
||||
say "Installing opencode (official installer)"
|
||||
curl -fsSL https://opencode.ai/install | bash
|
||||
OC="$HOME/.opencode/bin/opencode"
|
||||
[ -x "$OC" ] || OC="$(command -v opencode || true)"
|
||||
[ -n "$OC" ] || die "opencode didn't install; see the output above"
|
||||
install_opencode
|
||||
else
|
||||
warn "opencode isn't installed; configuring it anyway (--skip-install)"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue