# KERNL Chrome Export - Setup Guide

## The Problem
When KERNL launches a new Chrome instance, it creates a **guest session** without your Google account, so Claude.ai requires login.

## The Solution
Connect to your **existing Chrome browser** that's already logged in!

## Setup Instructions

### Option 1: One-Time Chrome Launch (Recommended)

1. **Close ALL Chrome windows** completely
2. **Launch Chrome with remote debugging:**

**Windows:**
```powershell
# PowerShell
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="$env:LOCALAPPDATA\Google\Chrome\User Data"
```

**Mac:**
```bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir="$HOME/Library/Application Support/Google/Chrome"
```

**Linux:**
```bash
google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.config/google-chrome"
```

3. **Navigate to claude.ai** in the Chrome window that opens
4. **Keep this Chrome window open**
5. **Run KERNL export** - it will connect to this Chrome instance

### Option 2: Permanent Chrome Shortcut

Create a desktop shortcut that always launches Chrome with debugging enabled:

**Windows:**
1. Right-click Desktop → New → Shortcut
2. Target: `"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%LOCALAPPDATA%\Google\Chrome\User Data"`
3. Name it "Chrome Debug"
4. Use this shortcut instead of regular Chrome

**Mac:**
1. Create `chrome-debug.command` file:
```bash
#!/bin/bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir="$HOME/Library/Application Support/Google/Chrome"
```
2. Make executable: `chmod +x chrome-debug.command`
3. Double-click to launch

### Option 3: Always-On Remote Debugging (Advanced)

**⚠️ Security Note:** This makes Chrome's debugging port always available. Only use on trusted networks.

**Windows:**
- Edit Chrome shortcut properties
- Add to Target (after chrome.exe): ` --remote-debugging-port=9222`

**Mac/Linux:**
- Create alias in `~/.bashrc` or `~/.zshrc`:
```bash
alias chrome-debug='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222'
```

## How It Works

1. **Normal Chrome**: Launches clean, no remote debugging
2. **Chrome with `--remote-debugging-port=9222`**: Opens debugging port
3. **KERNL connects** to port 9222 via Puppeteer
4. **Your session preserved**: All logins, cookies, extensions work!

## Testing Connection

Run this to verify Chrome is accessible:
```bash
curl http://localhost:9222/json/version
```

Should return Chrome version info.

## Benefits of This Approach

✅ **Uses YOUR logged-in session** (no login needed)
✅ **All cookies and auth tokens** preserved
✅ **Extensions available** (password managers, etc.)
✅ **Profile settings maintained**
✅ **Multiple tabs/windows** work normally

## Troubleshooting

**"Connection refused"**
- Chrome not running with remote debugging
- Wrong port (try 9222, 9223, 9224)
- Firewall blocking localhost:9222

**"Profile is in use"**
- Close all Chrome windows first
- Kill Chrome processes: `taskkill /F /IM chrome.exe` (Windows)

**Claude.ai still asks for login**
- Launched wrong Chrome (guest session)
- Need to use `--user-data-dir` flag
- Open claude.ai in the debuggable Chrome window

## Quick Start

```bash
# 1. Launch Chrome with debugging (Windows PowerShell)
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="$env:LOCALAPPDATA\Google\Chrome\User Data"

# 2. Open claude.ai in that Chrome

# 3. Run KERNL export
node dist/export/test-chrome.js

# KERNL will connect to your Chrome and export conversations!
```

## Security Notes

- Remote debugging port only accessible from localhost (127.0.0.1)
- No external network access to debugging port
- Still recommended to close debugging port when done
- Don't use on public/untrusted networks with debugging enabled
