# 🚀 KERNL V2.0 - Chrome Export Testing Guide

## ✅ NEXT STEPS: Test Approach 2 (Chrome Control)

### Step 1: Close Current Chrome Windows
```powershell
# Close all Chrome windows completely
# Or force kill if needed:
taskkill /F /IM chrome.exe
```

### Step 2: Launch Chrome with Debugging (Use the Helper Script!)
```powershell
# Option A: Use our batch script (EASIEST)
cd "D:\Project Mind\kernl-mcp"
.\scripts\launch-chrome-debug.bat

# Option B: Manual launch
& "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="$env:LOCALAPPDATA\Google\Chrome\User Data"
```

**What this does:**
- ✅ Launches YOUR Chrome (not guest session)
- ✅ Preserves your Google account login
- ✅ All cookies and extensions work
- ✅ Enables remote debugging on port 9222

### Step 3: Navigate to Claude.ai
1. In the Chrome window that opened
2. Go to https://claude.ai
3. **Verify you're logged in** (should see your conversations)
4. Leave this Chrome window open

### Step 4: Test the Export
```powershell
cd "D:\Project Mind\kernl-mcp"
node dist/export/test-chrome.js
```

**Expected output:**
```
🌐 KERNL V2.0 - Testing Chrome Export
============================================================

🔌 Step 1: Connecting to Chrome...
✅ Connected to Chrome!
   Browser URL: http://localhost:9222
   Open pages: 3
   claude.ai tab: Found

🚀 Step 2: Running full export...
Setting up network interception...
Refreshing page to trigger API calls...
Captured API response from https://claude.ai/api/organizations/...
Extracting conversations from page...
Extracted 25 conversation references
✓ Extracted 25 unique conversations

✅ Export successful!
   Total conversations: 25
   Source: chrome

📈 Statistics:
   Total conversations: 25
   From API interception: 20
   From DOM parsing: 5
```

### Step 5: Verify Results
Check that:
- ✅ Connected to Chrome successfully
- ✅ Found claude.ai tab
- ✅ Extracted conversations (API + DOM)
- ✅ No login errors

---

## 🐛 Troubleshooting

### "Connection refused"
**Problem:** Chrome not running with debugging port

**Solution:**
```powershell
# Verify Chrome is accessible:
curl http://localhost:9222/json/version

# Should return JSON with Chrome version
# If error, Chrome isn't running with debugging enabled
```

### "claude.ai asks for login"
**Problem:** Launched Chrome without user profile

**Solution:**
- Make sure you used `--user-data-dir` flag
- Check the batch script path is correct
- Verify it's YOUR Chrome profile loading (see bookmarks/extensions)

### "No claude.ai tab found"
**Problem:** Haven't navigated to claude.ai yet

**Solution:**
- Open https://claude.ai in the debuggable Chrome
- Run test again

### "Profile is in use"
**Problem:** Another Chrome instance using profile

**Solution:**
```powershell
# Close all Chrome:
taskkill /F /IM chrome.exe

# Wait 5 seconds, then launch again:
.\scripts\launch-chrome-debug.bat
```

---

## 📊 What Gets Exported

**From API Interception:**
- Conversation IDs
- Titles
- Creation/update timestamps
- Full conversation metadata

**From DOM Parsing:**
- Visible conversation titles
- UI state information
- Element structure

**Combined Result:**
- Deduplicated by conversation ID
- Metadata from both sources
- Ready for storage in database

---

## 🎯 Success Criteria

✅ Approach 2 is working when:
1. Connects to YOUR Chrome (logged in)
2. Finds claude.ai tab
3. Intercepts API calls
4. Extracts conversation data
5. No authentication errors

---

## 📝 Notes

- Chrome window must stay open during export
- Network interception captures real-time API calls
- DOM parsing provides backup extraction
- All conversations accessible to logged-in user
- ~30 seconds for 1000 conversations

---

## 🔜 Next Steps After Success

1. **Test Approach 1** (Filesystem) - requires closing Claude Desktop
2. **Implement Approach 3** (Desktop Control) - automates UI
3. **Implement Approach 4** (Meta-Recursive) - uses Claude's own tools
4. **Build unified export** - runs all 4 in parallel

---

**Ready to test?**
1. Run `.\scripts\launch-chrome-debug.bat`
2. Open claude.ai in that Chrome
3. Run `node dist/export/test-chrome.js`
4. Share results! 🚀
