# Harvey Browser Sync

Passive Chromium extension + local server that silently logs your browsing context to Harvey's memory.

## How it works

1. Extension runs in the background, tracking pages you visit for 30s+
2. Every hour, batches all visits → POSTs to `localhost:7429`
3. Server writes/updates `memory/browser-context.md`
4. Harvey reads this file at heartbeat to understand your current context

## Files

```
browser-sync/
├── browser-sync-extension/   ← Load this in Chrome/Arc/Comet
│   ├── manifest.json
│   ├── background.js         ← Service worker (tracks, filters, batches)
│   ├── popup.html/.js        ← Status popup with on/off toggle
│   └── icon*.png
├── browser-sync-server.py    ← stdlib Python server (no pip needed)
├── start-browser-sync.sh     ← Start server (checks PID, logs to /tmp)
├── com.harvey.browser-sync.plist  ← LaunchAgent (auto-start on login)
└── README.md
```

## Install

### 1. Start the server (manual)
```bash
./start-browser-sync.sh
```
Logs to `/tmp/browser-sync.log`. PID stored at `/tmp/harvey-browser-sync.pid`.

### 2. Auto-start on login (LaunchAgent)
```bash
cp com.harvey.browser-sync.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.harvey.browser-sync.plist
```

### 3. Load the extension
1. Open Chrome/Arc/Comet → Settings → Extensions → Enable Developer Mode
2. Click "Load unpacked" → select the `browser-sync-extension/` folder
3. The 🐹 icon appears in toolbar — click to see status

## What gets filtered out

- Social media: Facebook, Instagram, Twitter/X, Reddit, TikTok, LinkedIn, etc.
- Video: YouTube, Netflix, Twitch, Disney+, etc.
- Banking: Chase, TD, RBC, Scotiabank, BMO, CIBC, PayPal, etc.
- Anything under 30 seconds
- localhost, chrome://, about:// URLs

## Output format

```markdown
# Browser Context — Last 7 Days

## 2026-03-21
- [10:45] **Perplexity Comet review** (perplexity.ai/comet) — 4m
- [11:02] **Arc browser tab management** (arc.net) — 2m
- [11:15] **Workona tab manager** (workona.com) — 9m ⭐ (revisit)
```

Pages visited more than once show ⭐ (revisit) with accumulated time.
Entries auto-prune after 7 days.

## Popup controls

- **Status badge** — Active (green) or Paused (orange)
- **Pause/Resume** — Toggle tracking on/off
- **Sync Now** — Force immediate sync instead of waiting for hourly batch
- Shows: pending visits, total synced, active tabs being tracked, time to next sync
