chrome-cli-bridge 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +333 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,333 @@
1
+ # chrome-cli-bridge
2
+
3
+ > Connect any CLI tool or AI agent to a **live Chrome tab** — bypass auth walls, anti-bot detection, and SPAs that defeat headless browsers.
4
+
5
+ ```sh
6
+ npm install -g chrome-cli-bridge
7
+ ```
8
+
9
+ ---
10
+
11
+ ## What it does
12
+
13
+ Headless browsers and `curl` can't handle pages protected by:
14
+
15
+ - OAuth / SSO / MFA login flows
16
+ - Cloudflare Turnstile, CAPTCHA, fingerprinting
17
+ - Client-side rendered SPAs that only show data after login
18
+
19
+ `chrome-cli-bridge` connects to a **real Chrome tab you already have open** and exposes it to any terminal tool — AI coding assistants, shell scripts, Node.js SDKs, pipelines. All traffic stays on localhost.
20
+
21
+ ```
22
+ ┌──────────────────────┐ WebSocket + JSON-RPC ┌─────────────────────┐
23
+ │ Chrome Extension │ ◄───────────────────────► │ Local Relay Server │
24
+ │ (your live tab) │ session token │ chrome-bridge CLI │
25
+ └──────────────────────┘ └──────────┬──────────┘
26
+
27
+ ┌─────────────▼────────────┐
28
+ │ Copilot CLI · Claude │
29
+ │ Code · shell scripts · │
30
+ │ Node.js SDK · pipelines │
31
+ └──────────────────────────┘
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ ### 1 — Install the CLI
39
+
40
+ ```sh
41
+ npm install -g chrome-cli-bridge
42
+ ```
43
+
44
+ Requires **Node.js ≥ 18**.
45
+
46
+ ### 2 — Load the Chrome extension
47
+
48
+ The companion extension is what actually acts in the browser. Install it using either method:
49
+
50
+ **Option A — Chrome Web Store (recommended)**
51
+
52
+ Install directly from the store — no Developer mode required:
53
+ [chrome-cli-bridge on the Chrome Web Store](https://chrome.google.com/webstore/detail/chrome-cli-bridge)
54
+
55
+ **Option B — Load from source (for contributors / offline)**
56
+
57
+ 1. Download the extension from the [GitHub releases page](https://github.com/nestormata/chrome-bridge/releases)
58
+ 2. Open **chrome://extensions** in Chrome
59
+ 3. Enable **Developer mode** (top-right toggle)
60
+ 4. Click **Load unpacked** → select the `extension/` folder
61
+
62
+ ### 3 — Start the relay and connect
63
+
64
+ ```sh
65
+ chrome-bridge start
66
+ # ✔ Relay started on ws://localhost:9876
67
+ # ✔ Session token: a1b2c3d4-… (saved to ~/.chrome-cli-bridge.token)
68
+ ```
69
+
70
+ Click the extension icon in Chrome, paste the token, click **Connect**. The bridge is live.
71
+
72
+ ---
73
+
74
+ ## Commands
75
+
76
+ ### Navigation & tabs
77
+
78
+ ```sh
79
+ chrome-bridge tabs # list all open tabs
80
+ chrome-bridge tabs --select 42 # select tab by ID
81
+ chrome-bridge tabs --select active # select the focused tab
82
+
83
+ chrome-bridge navigate --url https://example.com # navigate and await load
84
+ ```
85
+
86
+ ### Inspect the page
87
+
88
+ ```sh
89
+ chrome-bridge query --selector "h1" # query DOM elements
90
+ chrome-bridge query --html # full page HTML
91
+
92
+ chrome-bridge snapshot # full outerHTML snapshot
93
+ chrome-bridge snapshot --styles # with inline computed styles
94
+
95
+ chrome-bridge exec --code "document.title"
96
+ chrome-bridge exec --code "fetch('/api/me').then(r => r.json())"
97
+ ```
98
+
99
+ ### Screenshot
100
+
101
+ ```sh
102
+ chrome-bridge screenshot # prints base64 PNG
103
+ chrome-bridge screenshot --output shot.png # saves to file
104
+ ```
105
+
106
+ ### Storage
107
+
108
+ ```sh
109
+ chrome-bridge storage --type local # read all localStorage
110
+ chrome-bridge storage --type local --key token # read one key
111
+ chrome-bridge storage --type local --key x --set val # write a key
112
+ chrome-bridge storage --type session # sessionStorage
113
+ chrome-bridge storage --type cookies # cookies for tab origin
114
+ ```
115
+
116
+ ### Wait for elements
117
+
118
+ ```sh
119
+ chrome-bridge wait --selector "#app" # wait up to 5 s
120
+ chrome-bridge wait --selector ".loaded" --timeout 10000
121
+ # exits with code 1 on timeout
122
+ ```
123
+
124
+ ### Logs & network
125
+
126
+ ```sh
127
+ chrome-bridge logs # buffered console logs
128
+ chrome-bridge logs --level error # filter by level
129
+ chrome-bridge logs --watch # stream in real time (Ctrl+C stops)
130
+ chrome-bridge logs --network # captured HTTP requests
131
+ ```
132
+
133
+ ### Interact with the page
134
+
135
+ ```sh
136
+ chrome-bridge trigger --selector "#btn" --event click # dispatch DOM event
137
+ chrome-bridge type --selector "#search" --text "hello world"
138
+ chrome-bridge click --selector "button.submit"
139
+ chrome-bridge hover --selector ".dropdown-trigger"
140
+ chrome-bridge inject --file ./patch.js # inject a local JS file
141
+ ```
142
+
143
+ ### Interactive REPL
144
+
145
+ ```sh
146
+ chrome-bridge repl
147
+ # chrome-bridge REPL — JavaScript in the selected tab
148
+ # > document.title
149
+ # "My Page"
150
+ # > document.querySelectorAll('a').length
151
+ # 42
152
+ ```
153
+
154
+ ### DevTools data
155
+
156
+ ```sh
157
+ chrome-bridge devtools performance # runtime metrics
158
+ chrome-bridge devtools memory --output snap.heapsnapshot
159
+ chrome-bridge devtools coverage --duration 5000 # JS coverage, 5 s
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Pipeline / stdin mode
165
+
166
+ Output is always JSON when stdout is not a TTY — pipe freely:
167
+
168
+ ```sh
169
+ chrome-bridge tabs | jq '.[0].id'
170
+ chrome-bridge exec --code "document.title" | jq -r '.result'
171
+ ```
172
+
173
+ **NDJSON batch mode** — send one command per line, get one result per line:
174
+
175
+ ```sh
176
+ echo '{"command":"exec","code":"document.title"}' | chrome-bridge
177
+
178
+ cat <<EOF | chrome-bridge
179
+ {"command":"navigate","url":"https://example.com"}
180
+ {"command":"wait","selector":"#content"}
181
+ {"command":"snapshot"}
182
+ EOF
183
+ ```
184
+
185
+ Force pipe mode in environments that look like a TTY:
186
+
187
+ ```sh
188
+ chrome-bridge --pipe < commands.ndjson
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Node.js SDK
194
+
195
+ ```js
196
+ import { ChromeBridge } from 'chrome-cli-bridge';
197
+
198
+ const bridge = new ChromeBridge();
199
+ await bridge.connect();
200
+
201
+ const tabs = await bridge.tabs();
202
+ await bridge.selectTab(tabs[0].id);
203
+
204
+ // Navigate & inspect
205
+ await bridge.navigate({ url: 'https://example.com' });
206
+ await bridge.wait({ selector: '#app', timeout: 8000 });
207
+ const snap = await bridge.snapshot();
208
+
209
+ // Execute JS
210
+ const { result } = await bridge.exec({ code: 'document.title' });
211
+
212
+ // Interact
213
+ await bridge.type({ selector: '#q', text: 'search term' });
214
+ await bridge.click({ selector: 'button[type=submit]' });
215
+
216
+ // Screenshot
217
+ const { dataUrl } = await bridge.screenshot();
218
+
219
+ // Storage
220
+ const store = await bridge.storage({ type: 'local' });
221
+ const cookies = await bridge.storage({ type: 'cookies' });
222
+
223
+ // Real-time logs
224
+ const unsub = bridge.streamLogs((entry) => console.log(entry));
225
+ // ... later:
226
+ unsub();
227
+
228
+ // DevTools
229
+ const metrics = await bridge.devtools.performance();
230
+
231
+ await bridge.disconnect();
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Usage with AI coding assistants
237
+
238
+ `chrome-cli-bridge` is designed to be a tool layer for AI agents working in the terminal.
239
+
240
+ > **📄 `SKILLS.md`** — The repo includes a ready-to-use [`SKILLS.md`](https://github.com/nestormata/chrome-bridge/blob/main/SKILLS.md) file with copy-paste instructions for setting up chrome-cli-bridge with GitHub Copilot CLI, Claude Code, Cursor, Aider, Cline, Continue.dev, and any tool that accepts a system prompt.
241
+
242
+ ### GitHub Copilot CLI
243
+
244
+ Add to `.github/copilot-instructions.md`:
245
+ ```
246
+ You have access to a live Chrome tab via chrome-cli-bridge.
247
+ Use `chrome-bridge <command>` to read the DOM, run JavaScript,
248
+ capture screenshots, navigate, or interact with the page.
249
+ All output is JSON. Relay must be running: chrome-bridge start.
250
+ ```
251
+
252
+ Example session:
253
+ ```
254
+ you> read the current page title from my browser
255
+ copilot> chrome-bridge exec --code "document.title"
256
+ {"result":"Checkout — My Store"}
257
+ ```
258
+
259
+ ### Claude Code
260
+
261
+ Add to `CLAUDE.md` in your project root:
262
+ ```
263
+ You have access to a live Chrome tab via chrome-cli-bridge.
264
+ Use `chrome-bridge exec --code "<js>"` to read or manipulate the page.
265
+ Use `chrome-bridge navigate` then `chrome-bridge wait` before reading content.
266
+ All output is JSON. Relay must be running: chrome-bridge start.
267
+ ```
268
+
269
+ ### Cursor
270
+
271
+ Add to `.cursorrules`:
272
+ ```
273
+ You can interact with a live Chrome tab using chrome-bridge commands.
274
+ All output is JSON. Relay must be running: chrome-bridge start.
275
+ ```
276
+
277
+ ### Aider
278
+
279
+ ```sh
280
+ aider --read SKILLS.md
281
+ ```
282
+
283
+ ### Shell script automation
284
+
285
+ ```sh
286
+ #!/bin/bash
287
+ # Scrape a page that requires login (you're already logged in via Chrome)
288
+
289
+ chrome-bridge navigate --url "https://myapp.com/dashboard"
290
+ chrome-bridge wait --selector "#data-table"
291
+
292
+ DATA=$(chrome-bridge exec --code "
293
+ [...document.querySelectorAll('#data-table tr')]
294
+ .slice(1)
295
+ .map(r => r.cells[0].textContent + ',' + r.cells[1].textContent)
296
+ .join('\n')
297
+ ")
298
+
299
+ echo "$DATA" | jq -r '.result' > output.csv
300
+ ```
301
+
302
+ ### Automated testing of authenticated pages
303
+
304
+ ```js
305
+ import { ChromeBridge } from 'chrome-cli-bridge';
306
+
307
+ // You're already logged in — no need to re-auth in the test
308
+ const bridge = new ChromeBridge();
309
+ await bridge.connect();
310
+
311
+ await bridge.navigate({ url: 'https://app.example.com/orders' });
312
+ await bridge.wait({ selector: '.order-list' });
313
+
314
+ const count = await bridge.exec({ code: 'document.querySelectorAll(".order-row").length' });
315
+ console.assert(count.result > 0, 'Expected orders to be visible');
316
+
317
+ const shot = await bridge.screenshot({ output: 'test-screenshot.png' });
318
+ ```
319
+
320
+ ---
321
+
322
+ ## Security
323
+
324
+ - Relay **only listens on `127.0.0.1`** — zero external exposure
325
+ - **UUID v4 session token** rotated on every `chrome-bridge start`, stored at `~/.chrome-cli-bridge.token` (mode `0600`)
326
+ - Extension rejects connections without a valid token (WS close code `4001`)
327
+ - Network / DevTools access requires explicit commands and shows Chrome's "DevTools connected" banner — nothing is captured passively
328
+
329
+ ---
330
+
331
+ ## License
332
+
333
+ MIT © [Nestor Mata](https://github.com/nestormata)
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "chrome-cli-bridge",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Connect CLI tools and AI agents to a live Chrome tab via WebSocket bridge",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
- "chrome-bridge": "./bin/chrome-bridge.js"
8
+ "chrome-bridge": "bin/chrome-bridge.js"
9
9
  },
10
10
  "exports": {
11
11
  ".": "./src/index.js"
@@ -35,7 +35,7 @@
35
35
  "license": "MIT",
36
36
  "repository": {
37
37
  "type": "git",
38
- "url": "https://github.com/nestormata/chrome-bridge.git"
38
+ "url": "git+https://github.com/nestormata/chrome-bridge.git"
39
39
  },
40
40
  "homepage": "https://github.com/nestormata/chrome-bridge#readme",
41
41
  "bugs": {