# PAI Companion: Update Instructions > **For AI Assistants.** If you were directed here by your user to update their PAI Companion installation, follow the phases below. Each phase is independently verifiable. If interrupted, you can resume from any phase. This updates an existing PAI Companion installation to the latest version. It refreshes system portal pages (skills catalog, agent roster, exchange, clipboard, etc.) without touching any pages the user has created. **Prerequisites:** - PAI Companion already installed and working - Docker running - Portal server (`pai-portal` container) running - Git installed --- ### Phase 1: Pre-flight Verify the current installation and check for the companion source repo. **Steps:** 1. Verify the portal is running: ```bash VM_IP=$(cat ~/.vm-ip 2>/dev/null || hostname -I | awk '{print $1}') PORT=$(grep PORTAL_PORT ~/.claude/.env 2>/dev/null | cut -d= -f2 || echo 8080) echo "=== Current Installation ===" echo -n "Portal server: " curl -sf http://$VM_IP:$PORT/ >/dev/null && echo "RUNNING" || echo "NOT RUNNING" echo -n "Docker container: " docker ps | grep -q pai-portal && echo "RUNNING" || echo "NOT RUNNING" ``` 2. Check current version: ```bash if [ -f ~/portal/.companion-version ]; then echo "Current version: $(cat ~/portal/.companion-version)" else echo "No version marker found (pre-marker installation)" fi ``` 3. Inventory user-created portal pages (these will NOT be touched): ```bash echo "=== User Portal Pages (will be preserved) ===" SYSTEM_DIRS="skills agents context system clipboard exchange shared welcome algorithm hooks identity isas knowledge observability plugins reflections relationships sessions settings signals tasks .thumbs" for dir in ~/portal/*/; do dir_name=$(basename "$dir") if ! echo "$SYSTEM_DIRS" | grep -qw "$dir_name"; then echo " USER: $dir_name/" fi done ``` **Verification:** Portal is running. Docker container `pai-portal` is active. **STOP if:** Portal is not running or Docker is not available. Fix the underlying issue first. --- ### Phase 2: Get Latest Source Pull the latest companion source code. **Steps:** 1. Update or clone the companion repo: ```bash if [ -d ~/pai-companion ]; then echo "Updating existing companion repo..." git -C ~/pai-companion pull echo "Updated to: $(git -C ~/pai-companion log --oneline -1)" else echo "Cloning companion repo..." git clone https://github.com/chriscantey/pai-companion.git ~/pai-companion echo "Cloned: $(git -C ~/pai-companion log --oneline -1)" fi ``` **Verification:** `git -C ~/pai-companion log --oneline -1` shows a recent commit. --- ### Phase 3: Update System Pages Replace system-managed portal pages with the latest versions. User-created pages are never touched. **Steps:** 1. Update system portal directories: ```bash echo "=== Updating System Portal Pages ===" SYSTEM_DIRS="skills agents context system clipboard exchange shared welcome algorithm hooks identity isas knowledge observability plugins reflections relationships sessions settings signals tasks" for dir in $SYSTEM_DIRS; do if [ ! -d ~/portal/$dir ]; then echo " Skipped: $dir/ (not installed, leaving it that way)" elif [ -d ~/pai-companion/companion/portal/public/$dir ]; then rm -rf ~/portal/$dir cp -r ~/pai-companion/companion/portal/public/$dir ~/portal/ echo " Updated: $dir/" else echo " Skipped: $dir/ (not in source)" fi done ``` **Refresh, never re-add.** A page that is not in `~/portal/` was removed on purpose. A minimal install (`companion/portal/minimal/`) deliberately carries only home, clipboard, and exchange. Restoring the System hub underneath someone would undo that silently, so the loop above updates what is installed and leaves the rest alone. 2. Update server infrastructure files and the home-screen app assets: ```bash for f in server.ts Dockerfile docker-compose.yml; do if [ -f ~/pai-companion/companion/portal/$f ]; then cp ~/pai-companion/companion/portal/$f ~/portal/$f echo " Updated: $f" fi done for f in manifest.webmanifest icon.svg icon-192.png icon-512.png icon-maskable-512.png apple-touch-icon.png; do if [ -f ~/pai-companion/companion/portal/public/$f ]; then # Do not clobber custom artwork: only add what is missing. if [ -f ~/portal/$f ]; then echo " Kept: $f (already present)" else cp ~/pai-companion/companion/portal/public/$f ~/portal/$f echo " Added: $f" fi fi done ``` 3. If the install predates PWA support, its pages have no manifest or home-screen icon tags. Check the homepage: ```bash grep -q 'rel="manifest"' ~/portal/index.html && echo "PWA tags present" || echo "PWA tags MISSING" ``` If missing, insert this block into the `
` of **`~/portal/index.html` only**, just before its `