#!/usr/bin/env bash # # omg - one-command setup for a fresh VPS or macOS workstation. # # Provisions Bun, git, fetches omg, optionally joins your Tailscale # tailnet, and runs the web UI as a background user service. Agent CLIs are # detected but not installed unless explicitly requested. # # Brand-new VPS (run as a normal sudo user, NOT root): # curl -fsSL https://raw.githubusercontent.com/BennyKok/omg.dev/main/scripts/setup.sh | bash # # or non-interactively, with the Tailscale auth key supplied up front: # curl -fsSL https://raw.githubusercontent.com/BennyKok/omg.dev/main/scripts/setup.sh | TS_AUTHKEY=tskey-auth-xxxx bash # # Re-run / update after install: # omg setup # # It is idempotent - safe to run repeatedly. set -euo pipefail # ---- OMG_* / LFG_* aliasing --------------------------------------------- # The bash half of src/env-compat.ts. This script reads LFG_* names internally; # mirroring first means `OMG_PORT=9000 curl ... | bash` works, and OMG_ wins # when a name is somehow set both ways. Must run before any default below is # resolved, or the mirrored value would arrive after the ${VAR:-default} that # was supposed to see it. for _omg_var in $(compgen -v OMG_ 2>/dev/null || true); do _legacy_var="LFG_${_omg_var#OMG_}" printf -v "$_legacy_var" '%s' "${!_omg_var}" export "${_legacy_var?}" done unset _omg_var _legacy_var # ---- config (override via env) ---- LFG_REPO_URL="${LFG_REPO_URL:-https://github.com/BennyKok/omg.dev.git}" # Where prebuilt release tarballs live (GitHub "owner/repo"). Defaults align # with LFG_REPO_URL but can be pointed at a fork. LFG_REPO_SLUG="${LFG_REPO_SLUG:-BennyKok/omg.dev}" # Install location. A fresh box gets ~/omg; a box that already has ~/lfg keeps # it, because moving a live install's directory would strip it of its data/ and # .env and orphan the unit's WorkingDirectory. if [ -n "${LFG_DIR:-}" ]; then LFG_DIR="$LFG_DIR" elif [ -d "$HOME/lfg" ] && [ ! -d "$HOME/omg" ]; then LFG_DIR="$HOME/lfg" else LFG_DIR="$HOME/omg" fi LFG_REPOS_ROOT="${LFG_REPOS_ROOT:-$HOME/repos}" LFG_PORT="${LFG_PORT:-8766}" # Named local URL, opt-in. Maps a hostname to 127.0.0.1 in /etc/hosts so the UI # has a memorable address, without binding the server to any non-loopback # interface - an mDNS .local name resolves to the LAN address instead, # where nothing is listening. # # Off by default because /etc/hosts is root-owned, and a sudo password prompt # has no business interrupting a first install for a cosmetic URL. Turn it on # when you want it: OMG_LOCAL_HOSTNAME=omg.local omg setup LFG_LOCAL_HOSTNAME="${LFG_LOCAL_HOSTNAME-}" LFG_HOSTS_FILE="${LFG_HOSTS_FILE:-/etc/hosts}" TS_AUTHKEY="${TS_AUTHKEY:-}" # Service identity. Same rule as the install directory: new boxes get `omg`, # and a box already running `lfg.service` keeps it rather than being migrated # out from under a running control plane. Renaming a unit means stopping the # thing that is currently working and hoping its replacement comes up. if [ -f "$HOME/.config/systemd/user/lfg.service" ] && [ ! -f "$HOME/.config/systemd/user/omg.service" ]; then SERVICE="lfg" else SERVICE="omg" fi # Not dev.omg.omg: the mechanical reverse-DNS answer duplicates the word and # reads like a packaging bug in `launchctl list`. if [ -f "$HOME/Library/LaunchAgents/dev.omg.lfg.plist" ] && [ ! -f "$HOME/Library/LaunchAgents/dev.omg.serve.plist" ]; then SERVICE_LABEL="dev.omg.lfg" else SERVICE_LABEL="dev.omg.serve" fi # Install source: # release (default) - download the bundled tarball, then run a production # install. Private/unpublished deps may be bundled under # vendor/*.tgz and referenced from package.json. # source - git clone + `bun install` (for development / forks that # can resolve the private provider themselves). LFG_INSTALL_MODE="${LFG_INSTALL_MODE:-release}" # Background service installation: # auto (default) - use systemd/launchd when the host provides it; otherwise # leave process supervision to the hosting platform. # 1 - require and install the native user service. # 0 - install the application without a native user service. LFG_INSTALL_SERVICE="${LFG_INSTALL_SERVICE:-auto}" # Which release to pull in release mode: "latest" or a tag like v0.1.0. LFG_RELEASE="${LFG_RELEASE:-latest}" # Non-destructive defaults: # - macOS never installs/updates user tools unless opted in. # - agent CLIs are never installed unless opted in; existing installs are used. if [ "$(uname -s)" = "Darwin" ]; then LFG_INSTALL_SYSTEM_DEPS="${LFG_INSTALL_SYSTEM_DEPS:-0}" LFG_INSTALL_BUN="${LFG_INSTALL_BUN:-0}" LFG_UPDATE_SHELL_RC="${LFG_UPDATE_SHELL_RC:-0}" else LFG_INSTALL_SYSTEM_DEPS="${LFG_INSTALL_SYSTEM_DEPS:-1}" LFG_INSTALL_BUN="${LFG_INSTALL_BUN:-1}" LFG_UPDATE_SHELL_RC="${LFG_UPDATE_SHELL_RC:-1}" fi LFG_INSTALL_CLAUDE="${LFG_INSTALL_CLAUDE:-0}" LFG_INSTALL_CODEX="${LFG_INSTALL_CODEX:-0}" LFG_INSTALL_OPENCODE="${LFG_INSTALL_OPENCODE:-0}" LFG_INSTALL_JCODE="${LFG_INSTALL_JCODE:-0}" LFG_INSTALL_GROK="${LFG_INSTALL_GROK:-0}" LFG_INSTALL_CURSOR="${LFG_INSTALL_CURSOR:-0}" LFG_INSTALL_FX="${LFG_INSTALL_FX:-0}" LFG_INSTALL_MUSE="${LFG_INSTALL_MUSE:-0}" LFG_INSTALL_DEEPSEEK="${LFG_INSTALL_DEEPSEEK:-0}" LFG_INSTALL_DEVIN="${LFG_INSTALL_DEVIN:-0}" LFG_INSTALL_COPILOT="${LFG_INSTALL_COPILOT:-0}" # pi is not bundled any more: its provider layer pulls eleven SDKs (Anthropic, # OpenAI, Google GenAI, Mistral, Bedrock) totalling ~115MB, for one optional # agent. Opting in is recorded in .env so a later update reinstalls it instead # of silently dropping it when the release tree is replaced. LFG_INSTALL_PI="${LFG_INSTALL_PI:-0}" # Pin the installed @github/copilot version so setup is reproducible. Override # with LFG_COPILOT_VERSION=x.y.z (or "latest" for opt-in floating installs). # 1.0.71 audits clean; <=1.0.42 is affected by GHSA-9ccr-r5hg-74gf # (core.fsmonitor RCE via nested bare repo) and <=0.0.422 is affected by # GHSA-g8r9-g2v8-jv6f (shell parameter-expansion bypass of the read-only # safety classification, exploitable through prompt injection). LFG_COPILOT_VERSION="${LFG_COPILOT_VERSION:-1.0.71}" LFG_DEEPSEEK_HARNESS_VERSION="${LFG_DEEPSEEK_HARNESS_VERSION:-0.1.1-rc.2}" LFG_INSTALL_MCP="${LFG_INSTALL_MCP:-1}" # Installing the Tailscale daemon is a separate decision from exposing the UI # over it. Both are off unless asked for. LFG_INSTALL_TAILSCALE="${LFG_INSTALL_TAILSCALE:-0}" LFG_TAILSCALE_SERVE="${LFG_TAILSCALE_SERVE:-0}" LFG_TAILSCALE_SERVE_OVERWRITE="${LFG_TAILSCALE_SERVE_OVERWRITE:-0}" # Asking to be served over the tailnet is asking for the tailnet. Without this, # OMG_TAILSCALE_SERVE=1 on a box with no Tailscale would quietly do nothing. [ "$LFG_TAILSCALE_SERVE" = "1" ] && LFG_INSTALL_TAILSCALE=1 LFG_TAILSCALE_HTTPS_PORT="${LFG_TAILSCALE_HTTPS_PORT:-443}" say() { printf '\033[1;36m==>\033[0m %s\n' "$*"; } warn() { printf '\033[1;33m[!]\033[0m %s\n' "$*" >&2; } die() { printf '\033[1;31m[x]\033[0m %s\n' "$*" >&2; exit 1; } resolve_service_mode() { case "$LFG_INSTALL_SERVICE" in auto) if [ "$OS_NAME" = "Darwin" ]; then LFG_INSTALL_SERVICE=1 elif [ -d "${LFG_SYSTEMD_RUNTIME_DIR:-/run/systemd/system}" ] \ && command -v systemctl >/dev/null 2>&1; then LFG_INSTALL_SERVICE=1 else LFG_INSTALL_SERVICE=0 fi ;; 0|1) ;; *) die "LFG_INSTALL_SERVICE must be auto, 0, or 1." ;; esac } on_err() { die "setup failed at line $1. Fix the issue above and re-run - it resumes safely."; } trap 'on_err $LINENO' ERR # ---- preflight ---- [ "$(id -u)" -eq 0 ] && die "Run as a normal sudo-capable user, not root - agents must not run as root." OS_NAME="$(uname -s)" case "$OS_NAME" in Linux) command -v sudo >/dev/null || die "sudo is required." command -v apt-get >/dev/null || die "This script targets Debian/Ubuntu on Linux (apt-get not found)." ;; Darwin) ;; *) die "Unsupported OS: $OS_NAME. This script supports Debian/Ubuntu Linux and macOS." ;; esac resolve_service_mode if [ "$OS_NAME" = "Linux" ] && [ "$LFG_INSTALL_SERVICE" = "1" ]; then command -v systemctl >/dev/null || die "systemd (systemctl) is required when LFG_INSTALL_SERVICE=1." fi # If invoked from inside an existing checkout (i.e. via `omg setup`), use it. SCRIPT_SRC="${BASH_SOURCE[0]:-}" if [ -n "$SCRIPT_SRC" ] && [ -f "$SCRIPT_SRC" ]; then MAYBE_ROOT="$(cd "$(dirname "$SCRIPT_SRC")/.." && pwd)" if [ -f "$MAYBE_ROOT/package.json" ] && grep -qE '"name": *"(omg|lfg)"' "$MAYBE_ROOT/package.json" 2>/dev/null; then LFG_DIR="$MAYBE_ROOT" fi fi # Tag every line we append to a user's shell rc, so uninstall can take exactly # its own lines back out instead of leaving PATH edits behind forever. Keep in # sync with src/commands/uninstall.ts. RC_MARKER="# added by omg.dev setup" ensure_path_line() { # append a line to common interactive shell rc files once [ "$LFG_UPDATE_SHELL_RC" = "1" ] || return 0 local line="$1" local files=("$HOME/.bashrc") if [ "$OS_NAME" = "Darwin" ]; then files+=("$HOME/.zshrc") fi for file in "${files[@]}"; do # Substring match, not whole-line: installs from before the marker existed # carry the bare line, and appending a marked twin would duplicate the PATH # entry on every subsequent setup. grep -qF "$line" "$file" 2>/dev/null && continue printf '%s %s\n' "$line" "$RC_MARKER" >> "$file" done } # Link a command name at our CLI without trampling someone else's. # # `ln -sf` overwrites whatever is in the way, which made setup the destructive # half of a pair whose uninstall carefully refuses to remove a link it does not # own. That asymmetry bites hardest on `omg`: the omg.dev CLI installs a command # by the same name, so an unconditional force-link silently replaces it. # Marker identifying a launcher this script wrote. Keep in sync with # src/commands/uninstall.ts, which uses it to decide what is safe to remove. LAUNCHER_MARKER="# omg.dev launcher" # Did this script install the command at $1? # # Two shapes exist: the launcher current installs write, and the plain symlink # older ones created. Every ownership question below routes through here - # asking only about the symlink meant a launcher failed to be recognised as # ours, so setup treated its own command as a rival program and handed the name # over to itself. is_our_command() { local path="$1" case "$(readlink "$path" 2>/dev/null || true)" in */src/cli.ts) return 0 ;; esac grep -qF "$LAUNCHER_MARKER" "$path" 2>/dev/null } link_command() { local name="$1" target="$2" path="$HOME/.local/bin/$1" if [ -e "$path" ] || [ -L "$path" ]; then if ! is_our_command "$path"; then warn "Leaving existing ${path} alone (not installed by omg.dev). Run it as ${target} or remove that file and re-run setup." return 0 fi fi # A launcher, not a symlink to src/cli.ts. # # That symlink relies on the CLI's `#!/usr/bin/env bun` shebang, which needs # bun on PATH. On macOS setup deliberately does not touch your shell profile # (LFG_UPDATE_SHELL_RC defaults to 0 there), so ~/.bun/bin usually is not on # it — and `omg` failed with "env: bun: No such file or directory" in a plain # terminal, on a machine where bun was installed and working. Find bun the way # the npm CLI's shim does, and say something useful when it is genuinely # missing. rm -f "$path" cat > "$path" </dev/null 2>&1; then BUN="\$(command -v bun)" else for candidate in "\${BUN_INSTALL:-\$HOME/.bun}/bin/bun" "\$HOME/.bun/bin/bun" /opt/homebrew/bin/bun /usr/local/bin/bun; do if [ -x "\$candidate" ]; then BUN="\$candidate"; break; fi done fi if [ -z "\${BUN:-}" ]; then echo "omg: this CLI runs on Bun, which was not found." >&2 echo " Install Bun: curl -fsSL https://bun.sh/install | bash" >&2 echo " Or point at it: OMG_BUN_PATH=/path/to/bun \$0 ..." >&2 exit 1 fi exec "\$BUN" "\$TARGET" "\$@" LAUNCHER chmod +x "$path" } sha256_file() { if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | awk '{print $1}' elif command -v shasum >/dev/null 2>&1; then shasum -a 256 "$1" | awk '{print $1}' else die "sha256sum or shasum is required to verify the checksum." fi } mktemp_tgz() { mktemp "${TMPDIR:-/tmp}/lfg.XXXXXX" } platform_asset() { local os arch case "$OS_NAME" in Linux) os="linux" ;; Darwin) os="darwin" ;; *) die "Unsupported OS: $OS_NAME" ;; esac case "$(uname -m)" in x86_64|amd64) arch="x64" ;; arm64|aarch64) arch="arm64" ;; *) die "Unsupported CPU architecture: $(uname -m)" ;; esac printf 'omg-%s-%s.tar.gz' "$os" "$arch" } tailscale_sudo() { if [ "$OS_NAME" = "Linux" ]; then sudo tailscale "$@" else tailscale "$@" fi } tailscale_serve_endpoint_target() { local port_key="tcp:$1" local cfg cfg="$(tailscale_sudo serve get-config --all 2>/dev/null || true)" [ -n "$cfg" ] || return 0 printf '%s' "$cfg" | PORT_KEY="$port_key" "$BUN_BIN" -e ' const cfg = JSON.parse(require("fs").readFileSync(0, "utf8")); for (const svc of Object.values(cfg.services ?? {})) { const target = (svc?.endpoints ?? {})[process.env.PORT_KEY]; if (target != null) { console.log(target); break; } } ' 2>/dev/null || true } # ---- named local URL ---- # Two ways to give the UI a memorable address, preferred in this order: # # 1. A public DNS name whose A record points at 127.0.0.1. Costs the user # nothing: no sudo, no hosts file, no cleanup on uninstall, and it works # identically on macOS and Linux. This is how Drizzle Studio and friends do # it. Requires one A record on a domain we control, so it is checked rather # than assumed - and only trusted when it really resolves to loopback, # since a name that resolves anywhere else would point the UI at a machine # that is not this one. # 2. An /etc/hosts entry, which works offline and for any name, but is # root-owned and therefore needs sudo. Opt-in via OMG_LOCAL_HOSTNAME. LFG_DNS_HOSTNAME="${LFG_DNS_HOSTNAME-local.omg.dev}" # Keep these markers in sync with src/commands/uninstall.ts, which removes the # same block. They delimit the only lines setup owns in the hosts file. HOSTS_BEGIN="# >>> omg local hostname >>>" HOSTS_END="# <<< omg local hostname <<<" resolves_to_loopback() { # every A record for $1 is 127.x, and there is at least one local name="$1" addrs="" if command -v dig >/dev/null 2>&1; then addrs="$(dig +short +time=2 +tries=1 A "$name" 2>/dev/null | grep -E '^[0-9.]+$' || true)" elif command -v getent >/dev/null 2>&1; then addrs="$(getent ahostsv4 "$name" 2>/dev/null | awk '{print $1}' | sort -u || true)" elif command -v dscacheutil >/dev/null 2>&1; then addrs="$(dscacheutil -q host -a name "$name" 2>/dev/null | awk '/^ip_address:/ {print $2}' || true)" else return 1 fi [ -n "$addrs" ] || return 1 local addr while IFS= read -r addr; do [ -n "$addr" ] || continue case "$addr" in 127.*) ;; *) return 1 ;; esac done </dev/null } LOCAL_HOSTNAME_READY=0 ensure_local_hostname() { # A DNS name that already points at loopback needs nothing installed, so it # wins over the hosts file whenever it is available - no sudo, nothing for # uninstall to clean up. An explicit OMG_LOCAL_HOSTNAME still overrides it, # because someone naming a host by hand means it. if [ -z "$LFG_LOCAL_HOSTNAME" ] && [ -n "$LFG_DNS_HOSTNAME" ]; then if resolves_to_loopback "$LFG_DNS_HOSTNAME"; then LFG_LOCAL_HOSTNAME="$LFG_DNS_HOSTNAME" LOCAL_HOSTNAME_READY=1 say "Named local URL: ${LFG_DNS_HOSTNAME} (public DNS, already points at 127.0.0.1)." return 0 fi fi [ -n "$LFG_LOCAL_HOSTNAME" ] || return 0 # An explicit name that is already a loopback DNS record needs no hosts entry # either. if resolves_to_loopback "$LFG_LOCAL_HOSTNAME"; then LOCAL_HOSTNAME_READY=1 say "Named local URL: ${LFG_LOCAL_HOSTNAME} (already resolves to 127.0.0.1)." return 0 fi # A pre-existing mapping counts as ready. Rewriting a line we did not add # would take ownership of it, and uninstall would then delete someone else's # entry. if hosts_entry_present "$LFG_LOCAL_HOSTNAME"; then LOCAL_HOSTNAME_READY=1 say "Named local URL already configured (${LFG_LOCAL_HOSTNAME})." return 0 fi # curl|bash leaves stdin on the pipe, so -t 0 is false even on a real # terminal; sudo can still prompt through /dev/tty. Only give up when there is # no cached credential AND nowhere to ask. if ! sudo -n true 2>/dev/null && [ ! -t 0 ] && [ ! -c /dev/tty ]; then warn "No sudo available for ${LFG_HOSTS_FILE}; skipping ${LFG_LOCAL_HOSTNAME}. http://localhost:$LFG_PORT still works." return 0 fi say "Mapping ${LFG_LOCAL_HOSTNAME} to 127.0.0.1 in ${LFG_HOSTS_FILE} (needs sudo)..." # 127.0.0.1 only. The service binds IPv4 loopback, so publishing a ::1 twin # would hand browsers an address that refuses the connection - and browsers # prefer IPv6 when both resolve. if printf '%s\n127.0.0.1\t%s\n%s\n' "$HOSTS_BEGIN" "$LFG_LOCAL_HOSTNAME" "$HOSTS_END" \ | sudo tee -a "$LFG_HOSTS_FILE" >/dev/null; then LOCAL_HOSTNAME_READY=1 else warn "Could not write ${LFG_HOSTS_FILE}; skipping ${LFG_LOCAL_HOSTNAME}. http://localhost:$LFG_PORT still works." fi } # ---- 1. base packages ---- # Only git and curl are required, plus CA certificates so curl can reach HTTPS. # jq is gone: the few JSON reads below run through Bun. tmux is optional: new # sessions run as direct SDK/ACP processes, and tmux only drives old native-TUI # sessions created before that change. Check before installing, so a box that # already has everything never pays for `apt-get update`. MISSING_PKGS=() for pkg in git curl; do command -v "$pkg" >/dev/null 2>&1 || MISSING_PKGS+=("$pkg") done if [ "$OS_NAME" = "Linux" ] && [ ! -s /etc/ssl/certs/ca-certificates.crt ]; then MISSING_PKGS+=("ca-certificates") fi if [ "${#MISSING_PKGS[@]}" -eq 0 ]; then say "Base packages already installed." elif [ "$OS_NAME" = "Linux" ]; then [ "$LFG_INSTALL_SYSTEM_DEPS" = "1" ] || die "Missing required packages: ${MISSING_PKGS[*]}. Install them yourself, or re-run with OMG_INSTALL_SYSTEM_DEPS=1." say "Installing base packages (${MISSING_PKGS[*]})..." sudo apt-get update -y -qq sudo apt-get install -y -qq "${MISSING_PKGS[@]}" else if [ "$LFG_INSTALL_SYSTEM_DEPS" = "1" ]; then command -v brew >/dev/null 2>&1 || die "Homebrew is required to install missing packages on macOS: ${MISSING_PKGS[*]}" say "Installing base packages with Homebrew (${MISSING_PKGS[*]})..." brew install "${MISSING_PKGS[@]}" else die "Missing required commands on macOS: ${MISSING_PKGS[*]}. Install them yourself, or re-run with OMG_INSTALL_SYSTEM_DEPS=1 to let setup use Homebrew." fi fi command -v tmux >/dev/null 2>&1 || say "tmux not found (optional). It is only needed to resume old native-TUI sessions." # ---- 2. Bun ---- # Extend PATH *before* deciding bun is missing. # # The check used to run first, so setup died with "Bun is required but was not # found on PATH" on machines where the very next line would have found it. That # is the normal state on macOS: bun installs to ~/.bun/bin, and setup # deliberately does not edit your shell profile there (LFG_UPDATE_SHELL_RC # defaults to 0), so the login PATH does not include it. `omg setup` was # unusable in a plain terminal on a Mac with bun installed and working. export PATH="$HOME/.bun/bin:$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" if ! command -v bun >/dev/null 2>&1; then if [ "$LFG_INSTALL_BUN" = "1" ]; then say "Installing Bun..." curl -fsSL https://bun.sh/install | bash # The installer drops it here; pick it up without a new shell. export PATH="$HOME/.bun/bin:$PATH" else die "Bun is required but was not found. Install it with: curl -fsSL https://bun.sh/install | bash — or re-run with OMG_INSTALL_BUN=1 to let setup do it." fi fi ensure_path_line 'export PATH="$HOME/.bun/bin:$PATH"' BUN_BIN="$(command -v bun || true)" [ -n "$BUN_BIN" ] || die "Bun is required but was not found on PATH." BUN_BIN="$(cd "$(dirname "$BUN_BIN")" && pwd)/$(basename "$BUN_BIN")" # ---- 3. agent CLIs ---- # omg.dev drives whatever claude / codex / opencode / jcode / grok / cursor-agent / # copilot it finds on PATH (override via OMG__PATH). None are installed # or upgraded by default: they own the user's auth and config. # # A missing agent is not worth a warning. Six near-identical paragraphs of "X # not found, re-run with LFG_INSTALL_X=1" buried the actual outcome of the # install in noise, for a situation that is both normal and fixable later from # Settings -> Coding agents. They are counted and reported in one line instead. AGENTS_READY=() AGENTS_MISSING=() is_grok_agent() { local bin="$1" local real real="$(readlink -f "$bin" 2>/dev/null || printf '%s' "$bin")" case "$real" in "$HOME"/.grok/*|*/grok-linux-x86_64) return 0 ;; *) return 1 ;; esac } has_cursor_cli() { if command -v cursor-agent >/dev/null 2>&1; then return 0 fi local agent_bin agent_bin="$(command -v agent 2>/dev/null || true)" [ -n "$agent_bin" ] && ! is_grok_agent "$agent_bin" } deepseek_harness_ready() { command -v dsh >/dev/null 2>&1 || return 1 local dsh_home="${DSH_HOME:-$HOME/.dsh}" grep -q '"@deepseek-ai/dsh-acp"' "$dsh_home/profiles/omg/package.json" 2>/dev/null } pi_pinned_version() { "$BUN_BIN" -e ' const pkg = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")); const name = "@earendil-works/pi-coding-agent"; console.log(pkg.devDependencies?.[name] ?? pkg.dependencies?.[name] ?? "latest"); ' "$LFG_DIR/package.json" 2>/dev/null | sed 's/^[\^~]//' } run_agent_installer() { case "$1" in claude) curl -fsSL https://claude.ai/install.sh | bash ;; codex) "$BUN_BIN" add -g @openai/codex >/dev/null 2>&1 ;; opencode) "$BUN_BIN" add -g opencode-ai >/dev/null 2>&1 ;; jcode) curl -fsSL https://jcode.sh/install | bash ;; grok) curl -fsSL https://x.ai/cli/install.sh | bash ;; cursor) curl -fsSL https://cursor.com/install | bash ;; fx) curl -fsSL https://fx.sh/setup.sh | bash ;; muse) curl -fsSL https://dev.meta.ai/install.sh | bash ;; deepseek) "$BUN_BIN" add -g "@deepseek-ai/dsh@${LFG_DEEPSEEK_HARNESS_VERSION}" pnpm >/dev/null 2>&1 dsh plugin --profile omg add "@deepseek-ai/dsh-acp@${LFG_DEEPSEEK_HARNESS_VERSION}" >/dev/null ;; devin) curl -fsSL https://cli.devin.ai/install.sh | bash ;; pi) # Installed into the install directory, which is where the harness and # detection both look for it. ( cd "$LFG_DIR" && "$BUN_BIN" add "@earendil-works/pi-coding-agent@$(pi_pinned_version)" >/dev/null 2>&1 ) ;; copilot) if [ "$LFG_COPILOT_VERSION" = "latest" ]; then npm install -g "@github/copilot" >/dev/null 2>&1 else npm install -g "@github/copilot@${LFG_COPILOT_VERSION}" >/dev/null 2>&1 fi ;; *) return 1 ;; esac } # ensure_agent