┌─────────────────────────────────────────────────────────────────┐
│ Command: monosurf x.com search "AI terminal" --profile work │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. Resolve profile → port 9222 │
│ └── Check CDP alive (TcpStream connect) │
│ └── Auto-starts Chrome if not running │
│ │
│ 2. Connect via chromiumoxide │
│ └── Browser::connect_with_config("http://127.0.0.1:9222") │
│ └── WebSocket CDP session established │
│ │
│ 3. Load site plugin (x.com.json) │
│ └── Validate domain matches base_url │
│ └── Integrity check (checksum) │
│ │
│ 4. Check auth gate │
│ └── Read scope: grant required │
│ └── Write scope: separate grant required │
│ │
│ 5. Inject cookies from keychain │
│ └── CDP Network.setCookies (supports HttpOnly) │
│ │
│ 6. Navigate via CDP │
│ └── page.goto(url) with 15s timeout │
│ └── Fallback: window.location.href via JS evaluate │
│ │
│ 7. Dismiss cookie banners (auto JS evaluate) │
│ │
│ 8. Wait for content selector │
│ └── JS polling via page.evaluate() │
│ └── Falls back to timeout if selector not found │
│ │
│ 9. Execute extraction JavaScript │
│ └── page.evaluate(extract_js) — direct CDP Runtime.evaluate │
│ └── Returns JSON array │
│ │
│ 10. Format and output │
│ └── Display template or generic key:value │
│ └── --json for structured output │
│ │
└─────────────────────────────────────────────────────────────────┘