# Update Adom from GitHub

Pull the latest Adom code, install dependencies, deploy skills, and verify everything is running.

## Step 1: Pull from GitHub

Check for local changes first:

```bash
cd ~/gallia && git status --short
```

**If local changes exist:**

```bash
cd ~/gallia && git stash && git pull && git stash pop
```

If `git stash pop` reports merge conflicts, show the user the conflicting files and stop. They must resolve manually, then ask you to continue.

**If clean:**

```bash
cd ~/gallia && git pull
```

**Report what changed.** Save the diff for later steps:

```bash
cd ~/gallia && git diff --name-only HEAD@{1}..HEAD 2>/dev/null
cd ~/gallia && git log --oneline HEAD@{1}..HEAD 2>/dev/null
```

If already up to date, tell the user but still proceed with steps 3-5 (the installer is idempotent and fixes drift).

## Step 2: Install npm dependencies

Only if dependency files changed in the pull:

```bash
cd ~/gallia && git diff --name-only HEAD@{1}..HEAD 2>/dev/null | grep -E 'package\.json|package-lock\.json'
```

If any matched, run `cd ~/gallia && npm install`. The root package.json uses npm workspaces (server, viewer, jlcpcb, mouser, digikey, gchat), so one install handles everything.

If none matched, skip and report "Dependencies unchanged."

## Step 3: Run the installer

This is the most important step. It deploys skills, configures MCP servers, and starts background servers.

```bash
cd ~/gallia && node install.mjs
```

Let the installer output speak for itself.

## Step 4: Restart all servers

The installer only starts servers that aren't already running — it never restarts them. After a pull, always restart all background servers so they pick up any code changes. Skipping this leaves the user on stale server code.

Kill all existing server processes and restart them:

```bash
pkill -f 'node.*server/server.js' 2>/dev/null
pkill -f 'node.*viewer/server.js' 2>/dev/null
pkill -f 'node.*jlcpcb/server.js' 2>/dev/null
sleep 1
cd ~/gallia && nohup node server/server.js > /dev/null 2>&1 &
cd ~/gallia && nohup node viewer/server.js > /dev/null 2>&1 &
cd ~/gallia && nohup node jlcpcb/server.js > /dev/null 2>&1 &
```

Wait a couple seconds, then verify they're responding (step 5).

## Step 5: Verify

Run these checks and report results:

**Servers responding:**

```bash
curl -s --max-time 2 -o /dev/null -w '%{http_code}' http://127.0.0.1:8766/ 2>/dev/null || echo 'DOWN'
curl -s --max-time 2 -o /dev/null -w '%{http_code}' http://127.0.0.1:8770/ 2>/dev/null || echo 'DOWN'
curl -s --max-time 2 -o /dev/null -w '%{http_code}' http://127.0.0.1:8774/ 2>/dev/null || echo 'DOWN'
```

**Skills deployed** (every skill dir in `~/gallia/skills/` except `adom` should have a matching guide):

```bash
ls ~/gallia/skills/ | grep -v README | grep -v adom | sort
ls ~/.claude/skills/adom/guides/ | sed 's/\.md$//' | sort
```

**Umbrella in sync:**

```bash
diff ~/gallia/skills/adom/SKILL.md ~/.claude/skills/adom/SKILL.md
```

## Step 6: Summary

Report to the user:

1. **Commits pulled** — count and notable changes
2. **New skills** — any new guide files that appeared
3. **Server status** — Conduit (8766), Viewer (8770), JLCPCB (8774)
4. **Action items** — missing env vars for optional servers (Mouser, DigiKey, Google Chat), merge conflicts, or anything else

If new MCP tools were added (new servers or new tools in existing servers), tell the user: **"Restart your Claude Code session for new MCP tools to appear."**
