#!/bin/sh
set -eu

BASE_URL="${ROXI_OFFICE_BASE_URL:-http://10.0.0.1/roxi-office}"
INSTALL_ROOT="${ROXI_OFFICE_HOME:-$HOME/RoxiOffice}"

mkdir -p "$INSTALL_ROOT"
curl -fsSL "$BASE_URL/manifest.json" -o "$INSTALL_ROOT/manifest.json"
curl -fsSL "$BASE_URL/ROXI-OFFICE-CODEX.md" -o "$INSTALL_ROOT/AGENTS.md"

cat > "$INSTALL_ROOT/roxi-office-codex" <<'EOF'
#!/bin/sh
set -eu
cd "$(dirname "$0")"
export ROXI_RESOURCE_API_URL="${ROXI_RESOURCE_API_URL:-http://10.0.0.1:8797}"
if ! command -v codex >/dev/null 2>&1; then
  echo "Codex is not on PATH. Install the OpenAI Codex CLI, then rerun this command." >&2
  exit 127
fi
exec codex
EOF
chmod +x "$INSTALL_ROOT/roxi-office-codex"

cat <<EOF
Roxi Office Codex workspace installed at:
  $INSTALL_ROOT

Run it with:
  $INSTALL_ROOT/roxi-office-codex

This macOS installer sets up the office Codex workspace and server-resource
instructions. The Windows voice assistant is installed only by install-windows.ps1.
EOF
