#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" APP_DIR="${HOME}/.local/share/jarvis-qvac" EXT_DIR="${HOME}/.local/share/gnome-shell/extensions/jarvis@qvac.local" CONFIG_DIR="${HOME}/.config/jarvis" CACHE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/jarvis/models" mkdir -p "${APP_DIR}" "${EXT_DIR}" "${CONFIG_DIR}" "${HOME}/.config/systemd/user" "${CACHE_DIR}" tar --exclude='.git' --exclude='./.agents' --exclude='./.codex' --exclude='./dist' --exclude='./node_modules' --exclude='*/node_modules' --exclude='*/__pycache__' --exclude='*.pyc' -cf - -C "${ROOT_DIR}" . | tar -xf - -C "${APP_DIR}" if [[ ! -d "${APP_DIR}/node_modules" ]]; then ( cd "${APP_DIR}" && npm ci --omit=dev --ignore-scripts ) fi rm -rf "${EXT_DIR}" mkdir -p "${EXT_DIR}" cp -a "${ROOT_DIR}/apps/gnome-extension/jarvis@qvac.local/." "${EXT_DIR}/" cp "${ROOT_DIR}/packaging/jarvisd.service" "${HOME}/.config/systemd/user/jarvisd.service" if [[ ! -f "${CONFIG_DIR}/qvac.config.json" ]]; then sed "s#__JARVIS_CACHE__#${CACHE_DIR}#g" "${ROOT_DIR}/packaging/qvac.config.template.json" > "${CONFIG_DIR}/qvac.config.json" fi if [[ "${1:-}" == "--enable" ]]; then systemctl --user daemon-reload systemctl --user enable --now jarvisd.service fi echo "Installed JARVIS-QVAC to ${APP_DIR}" echo "Run: ${APP_DIR}/packaging/first-run.sh"