#!/bin/bash set -e # --- Configuration --- PROJECT_ID="propane-will-491900-m5" REGION="us-central1" BRANCH="feat/osvx-mcp-full-catalog" OSVAUCO_DIR="/home/chris_christiansen/OSVauco" EXPECTED_ACCOUNT="357036551735-compute@developer.gserviceaccount.com" # --- Style and Colors --- COLOR_BLUE="" COLOR_GREEN="" COLOR_YELLOW="" COLOR_RED="" COLOR_RESET="" # --- Banner --- echo -e "${COLOR_BLUE}" echo "======================================================================" echo " 🚀 OPAX - OSVauco Professional Agent Experience 🚀" echo "======================================================================" echo -e "${COLOR_RESET}" # --- Main Script --- # 1. Navigate to project directory echo -e "${COLOR_GREEN}▶ Navigating to project directory...${COLOR_RESET}" cd "$OSVAUCO_DIR" echo " Done." # 2. Configure gcloud echo -e "${COLOR_GREEN}▶ Configuring gcloud...${COLOR_RESET}" gcloud config set project "$PROJECT_ID" --quiet gcloud config set compute/region "$REGION" --quiet echo " Project set to '$PROJECT_ID', Region set to '$REGION'." # 3. Git Operations echo -e "${COLOR_GREEN}▶ Syncing Git repository...${COLOR_RESET}" echo " Fetching latest changes from remote..." git remote update echo " Checking out branch '$BRANCH'..." if git show-ref --quiet "refs/heads/$BRANCH"; then git checkout "$BRANCH" else echo -e " ${COLOR_YELLOW}Branch '$BRANCH' not found locally. Creating and tracking...${COLOR_RESET}" git checkout -b "$BRANCH" --track "origin/$BRANCH" fi echo " Pulling latest changes..." git pull --ff-only echo " Git sync complete." # 4. Verify Authentication echo -e "${COLOR_GREEN}▶ Verifying authentication...${COLOR_RESET}" ACTIVE_ACCOUNT=$(gcloud config get-value account 2>/dev/null || echo "not-set") if [[ "$ACTIVE_ACCOUNT" == "$EXPECTED_ACCOUNT" ]]; then echo -e " ${COLOR_GREEN}✅ Authenticated as correct service account: $EXPECTED_ACCOUNT${COLOR_RESET}" else echo -e " ${COLOR_YELLOW}⚠️ WARNING: Active account ('$ACTIVE_ACCOUNT') is not the expected VM service account.${COLOR_RESET}" echo " If you have issues, run 'gcloud auth revoke' to default to the VM's account." fi # 5. Prepare Gemini Context echo -e "${COLOR_GREEN}▶ Preparing Gemini context...${COLOR_RESET}" CONTEXT_FILES=( "docs/AGENT_RULEBOOK.md" "docs/MASTERPLAN.md" "docs/ROADMAP.md" "docs/HANDOFF.md" "docs/PLATFORM_MAP.md" ".gemini/GEMINI.md" ) GEMINI_BOOT_PROMPT="BOOT: OPAX MODE [Branch: $BRANCH]. Read the following critical documents: " for file in "${CONTEXT_FILES[@]}"; do if [ -f "$file" ]; then GEMINI_BOOT_PROMPT+="$file, " echo " - Will load: $file" else echo -e " ${COLOR_RED}- NOT FOUND: $file${COLOR_RESET}" fi done # Clean up trailing comma and space GEMINI_BOOT_PROMPT="${GEMINI_BOOT_PROMPT%, }." GEMINI_BOOT_PROMPT+=" Review LOCKED DEFINITIONS and NESTE OPPGAVE. Await new PLAN." echo " Context prompt prepared." # 6. Launch Gemini CLI echo -e " ${COLOR_BLUE}--- Launching Gemini CLI ---${COLOR_RESET}" GEMINI_CLI_PATH=$(which gemini) if [ -z "$GEMINI_CLI_PATH" ]; then echo -e "${COLOR_RED}❌ ERROR: 'gemini' command not found in your PATH.${COLOR_RESET}" exit 1 fi # --skip-preflight is used to avoid Vertex AI API checks blocked by VPC SC "$GEMINI_CLI_PATH" --project-id "$PROJECT_ID" --region "$REGION" --skip-preflight -i "$GEMINI_BOOT_PROMPT" echo -e " ${COLOR_BLUE}--- OPAX session ended ---${COLOR_RESET}"