main
John Lauer Publish 1.2.4 bfa420b 1mo ago
#!/usr/bin/env bash
# Install the grok USER skillpack: core `grok` + area sub-skills.
# Per the Bridge SDK a pkg ships ONLY user skills. DEV/PUBLISH stay in the repo
# (dev-skills/). The bridge RUNTIME is not here — Adom Bridge loads it from
# the release zip (adom-bridge-grok-v*.zip).
# Repo name (grok-bridge) != skill name (grok). Don't re-conflate (pup's lesson).
set -euo pipefail
PKG_DIR="$(cd "$(dirname "$0")" && pwd)"

deploy_into() {
  local BASE="$1"
  mkdir -p "$BASE"
  install_skill() {
    local dest="$BASE/$1"
    mkdir -p "$dest"
    cp "$PKG_DIR/$2" "$dest/SKILL.md"
    printf '%s\n' "grok-bridge" > "$dest/.adom-managed"
  }
  # Drop mis-slugged copies: page/repo slug must not become the skill dir.
  # Only drop THIS pack's mis-slug. Leave adom-bridge-grok (Anywhere MCP skill) alone.
  rm -rf "$BASE/grok-bridge"
  install_skill grok SKILL.md
  install_skill grok-anywhere skills/grok-anywhere/SKILL.md
  install_skill grok-app-control skills/grok-app-control/SKILL.md
  install_skill grok-chat skills/grok-chat/SKILL.md
  install_skill grok-record skills/grok-record/SKILL.md
  install_skill grok-webhook skills/grok-webhook/SKILL.md
  install_skill grok-account skills/grok-account/SKILL.md
  echo "  -> $BASE (grok + 6 sub-skills)"
}

echo "Installing grok-bridge skills:"
deploy_into "$HOME/.claude/skills"                          # Claude Code (always)
[ -d "$HOME/.codex" ] && deploy_into "$HOME/.codex/skills"  # Codex (if present)
mkdir -p "$HOME/.grok/skills"
deploy_into "$HOME/.grok/skills"                            # Grok Bot
if [ -d /home/box/agent-data ]; then
  mkdir -p /home/box/agent-data/workflows
  deploy_into /home/box/agent-data/workflows
fi
# ---------------------------------------------------------------------------
# The DASHBOARD and its launcher (dockbar.json runs `grok-dashboard serve --print-url`).
APPDIR="$HOME/.local/share/adom/grok-bridge"
BINDIR="$HOME/.local/bin"
mkdir -p "$APPDIR" "$BINDIR"
if [ -d "$PKG_DIR/dashboard" ]; then
  rm -rf "$APPDIR/dashboard"
  cp -R "$PKG_DIR/dashboard" "$APPDIR/dashboard"
fi
[ -f "$PKG_DIR/dockbar.json" ] && cp -f "$PKG_DIR/dockbar.json" "$APPDIR/dockbar.json"
mkdir -p "$APPDIR/docs"
[ -f "$PKG_DIR/docs/icon.svg" ] && cp -f "$PKG_DIR/docs/icon.svg" "$APPDIR/docs/icon.svg"

cat > "$BINDIR/grok-dashboard" <<LAUNCHER
#!/usr/bin/env bash
# Installed by adom/grok-bridge. Points at the INSTALLED dashboard, never a
# developer's working copy.
exec python3 "$APPDIR/dashboard/grok_dashboard.py" "\$@"
LAUNCHER
chmod +x "$BINDIR/grok-dashboard"

case ":$PATH:" in
  *":$BINDIR:"*) ;;
  *) echo "[grok-bridge] NOTE: $BINDIR is not on your PATH; the dock passes it explicitly." ;;
esac
echo "[grok-bridge] dashboard installed -> $BINDIR/grok-dashboard"
# Best-effort first-run: connect Adom Bridge on the laptop. Do not fail the install
# if the laptop is asleep or Grok local-exec is not approved.
PATH="$BINDIR:$PATH" grok-dashboard ensure-desktop || echo "[grok-bridge] ensure-desktop did not connect a laptop this time (ok if it is asleep)."
echo "Done. This package installed SKILLS + grok-dashboard; Adom Bridge loads the grok runtime from the release zip."