# Remote Bootstrap

Set up a new Adom container from an existing one entirely over SSH -- zero browser interaction required. Auth credentials (GitHub + Claude) are copied from the current container.

## When to use

- You already have a working Adom container and want to set up a new one
- You don't want to go through interactive browser auth flows
- You need to bootstrap a container created via `adom-cli carbon containers create`

## Prerequisites

On the **source container** (the one you're running this from):
- SSH key registered with Adom (`adom-cli carbon user ssh-keys` returns at least one key)
- GitHub authenticated (`gh auth status` succeeds)
- Claude Code authenticated (`~/.claude/.credentials.json` exists)
- gallia cloned (`~/gallia` exists)

## Quick start

```bash
bash ~/gallia/scripts/remote-bootstrap.sh <ssh-target>
```

Example:
```bash
bash ~/gallia/scripts/remote-bootstrap.sh john-galliaapril-8v0y8o3547h2@adom.cloud
```

The script handles everything:
1. Copies GitHub + Claude auth credentials (no browser auth needed)
2. Installs Claude Code extension + CLI
3. Installs adom-cli + skills
4. Copies and registers the adom-vscode extension
5. Configures VS Code settings (disables Copilot, configures Claude Code)
6. Clones gallia and runs `npm install` + `install.mjs`
7. Fixes project directory permissions

After the script completes, open the editor URL and reload VS Code once.

## Full workflow: create + bootstrap a container

```bash
# 1. Create repo (if needed)
adom-cli carbon user repos  # check if repo exists
# If not: create via Carbon API (see adom-repo-management skill)

# 2. Create container with SSH
adom-cli carbon containers create \
  --image-id 69b43b3458d13e5ce628cdc4 \
  --class large \
  --ssh \
  --repo-id <ADOM_REPO_ID>
# Note the ssh_credentials.command from the response

# 3. Wait for container to provision (~15-30 seconds)
sleep 20

# 4. Bootstrap it
bash ~/gallia/scripts/remote-bootstrap.sh <username>@adom.cloud

# 5. Open the editor
# https://hydrogen.adom.inc/<owner>/<repo>/edit
# Reload VS Code: Ctrl+Shift+P > Developer: Reload Window
```

## What the script does NOT do

- **Claude Squad** -- not launched (use the Claude Code panel in VS Code instead)
- **Service startup** -- services start on next container boot or editor open (install.mjs skips startup without `VSCODE_PROXY_URI`)
- **Entrypoint patching** -- handled by install.mjs, takes effect on next boot

## Script location

`~/gallia/scripts/remote-bootstrap.sh`

## Key implementation details

- **scp is slow through the SSH gateway** -- the script pipes files through SSH (`cat file | ssh target "cat > dest"`) instead of using scp for large files
- **adom-vscode must be registered in extensions.json** -- code-server only loads extensions listed in `~/.local/share/code-server/extensions/extensions.json`. Just copying the extension directory is not enough.
- **Claude OAuth tokens are short-lived** -- copy credentials right before bootstrapping. The VS Code extension auto-refreshes using the refresh token once running.

## Troubleshooting

| Symptom | Fix |
|---------|-----|
| Claude Code "Failed to authenticate" | Token expired. Recopy `~/.claude/.credentials.json` from source and reload VS Code |
| adom-vscode not in sidebar | Reload VS Code. If still missing, check `extensions.json` has `adom.adom-vscode` entry |
| `scp` hangs | Known issue with SSH gateway. Script uses pipe approach to avoid this |
| `gh repo clone` fails | Verify `gh auth status` on target. Token may have expired -- recopy `~/.config/gh/hosts.yml` |
| Services not running | Open the editor URL -- services start when `VSCODE_PROXY_URI` is available |
