patchright-cli 0.6.0__tar.gz → 0.7.0__tar.gz

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 (50) hide show
  1. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/.claude-plugin/marketplace.json +1 -1
  2. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/.gitignore +2 -0
  3. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/CLAUDE.md +2 -2
  4. patchright_cli-0.7.0/GLOSSARY.md +58 -0
  5. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/PKG-INFO +25 -7
  6. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/README.md +23 -5
  7. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/pyproject.toml +1 -1
  8. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/skills/patchright-cli/SKILL.md +171 -12
  9. patchright_cli-0.7.0/skills/patchright-cli/references/session-management.md +172 -0
  10. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/skills/patchright-cli/references/snapshot-refs.md +56 -0
  11. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/skills/patchright-cli/references/video-recording.md +31 -0
  12. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/src/patchright_cli/__init__.py +1 -1
  13. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/src/patchright_cli/cli.py +290 -16
  14. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/src/patchright_cli/daemon.py +1272 -130
  15. patchright_cli-0.7.0/src/patchright_cli/dashboard.py +443 -0
  16. patchright_cli-0.7.0/src/patchright_cli/ref_registry.py +316 -0
  17. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/src/patchright_cli/snapshot.py +1 -1
  18. patchright_cli-0.7.0/tests/test_annotate.py +357 -0
  19. patchright_cli-0.7.0/tests/test_attach.py +455 -0
  20. patchright_cli-0.7.0/tests/test_cli_config.py +630 -0
  21. patchright_cli-0.7.0/tests/test_daemon_handlers.py +1207 -0
  22. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/tests/test_e2e.py +94 -0
  23. patchright_cli-0.7.0/tests/test_packaging.py +39 -0
  24. patchright_cli-0.7.0/tests/test_profiles.py +430 -0
  25. patchright_cli-0.7.0/tests/test_ref_registry.py +522 -0
  26. patchright_cli-0.7.0/tests/test_tabs.py +401 -0
  27. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/uv.lock +1 -1
  28. patchright_cli-0.6.0/skills/patchright-cli/references/session-management.md +0 -106
  29. patchright_cli-0.6.0/src/patchright_cli/dashboard.py +0 -135
  30. patchright_cli-0.6.0/src/patchright_cli/ref_registry.py +0 -106
  31. patchright_cli-0.6.0/tests/test_cli_config.py +0 -203
  32. patchright_cli-0.6.0/tests/test_daemon_handlers.py +0 -543
  33. patchright_cli-0.6.0/tests/test_ref_registry.py +0 -137
  34. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/.claude-plugin/skills/browser-automation.json +0 -0
  35. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/.github/workflows/ci.yml +0 -0
  36. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/.github/workflows/publish.yml +0 -0
  37. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/.pre-commit-config.yaml +0 -0
  38. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/CONTRIBUTING.md +0 -0
  39. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/LICENSE +0 -0
  40. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/Makefile +0 -0
  41. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/docs/installation.md +0 -0
  42. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/patchright-cli +0 -0
  43. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/patchright-cli.cmd +0 -0
  44. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/skills/patchright-cli/references/request-mocking.md +0 -0
  45. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/skills/patchright-cli/references/running-code.md +0 -0
  46. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/skills/patchright-cli/references/storage-state.md +0 -0
  47. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/skills/patchright-cli/references/tracing.md +0 -0
  48. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/src/patchright_cli/__main__.py +0 -0
  49. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/tests/__init__.py +0 -0
  50. {patchright_cli-0.6.0 → patchright_cli-0.7.0}/tests/fixture.html +0 -0
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "metadata": {
7
7
  "description": "Anti-detect browser automation CLI & Skills for AI agents, powered by Patchright",
8
- "version": "0.5.0"
8
+ "version": "0.7.0"
9
9
  },
10
10
  "plugins": [
11
11
  {
@@ -8,3 +8,5 @@ build/
8
8
  docs/reddit-post.md
9
9
  docs/superpowers/
10
10
  .worktrees/
11
+ .claude/settings.local.json
12
+ =*
@@ -57,10 +57,10 @@ CLI (cli.py) --TCP:9321--> Daemon (daemon.py) --Patchright--> Chrome
57
57
 
58
58
  - Always uses persistent browser context (`launch_persistent_context`) with real Chrome (`channel="chrome"`), not Chromium
59
59
  - Headed by default (headless is more detectable)
60
- - Default daemon port: 9321, profiles stored at `~/.patchright-cli/profiles/<session-name>`
60
+ - Default daemon port: 9321, profiles stored at `~/.patchright-cli/profiles/<profile-name>`; a session's profile defaults to its session name (`--profile=<name>` overrides, a value with `/` or `\` is a directory). One session per profile at a time
61
61
  - CLI-daemon protocol: length-prefixed (4-byte big-endian `!I`) JSON over TCP
62
62
  - CLI parses argv manually in `main()` — click is only used for `click.echo()`, not subcommands. New commands must be added to both `COMMANDS_HELP` dict and the `handle_command()` if/elif chain in daemon.py
63
- - Version must be updated in both `pyproject.toml` and `src/patchright_cli/__init__.py` (then run `uv lock` to sync the lock file)
63
+ - Version must be updated in `pyproject.toml`, `src/patchright_cli/__init__.py` and `.claude-plugin/marketplace.json` (then run `uv lock` to sync the lock file; `tests/test_packaging.py` checks they match)
64
64
  - `python -m patchright_cli` works via `__main__.py`
65
65
  - Uses hatchling as build backend, ruff for linting (line-length=120, target py310)
66
66
  - Ruff rules: E, F, I, W, UP, B, SIM (ignores E501, SIM105, E402)
@@ -0,0 +1,58 @@
1
+ # patchright-cli
2
+
3
+ An anti-detect browser automation CLI: callers drive real Chrome through short commands sent to a long-running daemon.
4
+
5
+ ## Sessions and browsers
6
+
7
+ **Session**:
8
+ A named handle on one browser context that callers drive with commands; selected with `-s`.
9
+ _Avoid_: Browser, instance, profile
10
+
11
+ **Default Session**:
12
+ The Session used when no `-s` is given.
13
+
14
+ **Launched Session**:
15
+ A Session whose Chrome patchright-cli started itself and therefore owns outright.
16
+
17
+ **Profile**:
18
+ A named, persistent store of browser state — cookies, storage, logins, history — that a Launched Session runs on; at most one Session uses a Profile at a time. Unless told otherwise, a Session's Profile is named after the Session.
19
+ _Avoid_: User data dir, profile directory, persistent context
20
+
21
+ **Attached Session**:
22
+ A Session connected to a Chrome that something else started, reached over CDP.
23
+ _Avoid_: Connected session, remote session
24
+
25
+ **Host**:
26
+ Whatever started and owns the Chrome an Attached Session connects to — a person, a script, or a product such as a workspace manager.
27
+ _Avoid_: External browser, owner
28
+
29
+ **Host Context**:
30
+ The Host's own browser context, carrying its profile's cookies, storage and logins; at most one Session may use a given Host Context.
31
+ _Avoid_: Default context, existing context, persistent context
32
+
33
+ **Isolated Context**:
34
+ A fresh browser context an Attached Session creates inside the Host's Chrome, sharing none of the Host's state.
35
+ _Avoid_: Incognito context
36
+
37
+ ## Tabs and pages
38
+
39
+ **Page**:
40
+ One browser tab as Chrome sees it.
41
+ _Avoid_: Tab (except in the playwright-cli-compatible `tab-*` command names, which act on Pages)
42
+
43
+ **Tab**:
44
+ A named workspace inside a Session — its own Page, element refs and navigation history — selected with `--tab`.
45
+ _Avoid_: Lane, worker
46
+
47
+ **Default Tab**:
48
+ The Tab used when no `--tab` is given; it follows whichever Page is currently selected rather than owning one.
49
+
50
+ ## Ending a Session
51
+
52
+ **Close**:
53
+ Ending a Session by destroying what it owns: its Tabs' Pages and, for a context it owns, the context itself.
54
+ _Avoid_: Quit, kill (except `kill-all`)
55
+
56
+ **Detach**:
57
+ Letting go of an Attached Session while leaving the Host's Chrome, and anything the Host owns, untouched.
58
+ _Avoid_: Disconnect, release
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: patchright-cli
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Anti-detect browser automation CLI using Patchright (undetected Playwright fork)
5
5
  Project-URL: Homepage, https://github.com/AhaiMk01/patchright-cli
6
6
  Project-URL: Repository, https://github.com/AhaiMk01/patchright-cli
@@ -149,7 +149,7 @@ graph LR
149
149
  |-----------|------|
150
150
  | **Daemon** (`daemon.py`) | Long-running process managing browser sessions via Patchright. Auto-starts on first `open`. |
151
151
  | **CLI** (`cli.py`) | Thin client — connects, sends command, prints result, disconnects. Browser stays open. |
152
- | **Snapshot** (`snapshot.py`) | `TreeWalker`-based DOM scan assigning `data-patchright-ref` attributes for element targeting. |
152
+ | **Snapshot** (`snapshot.py`) | Playwright `aria_snapshot()` accessibility tree, annotated with sequential `[ref=eN]` handles for element targeting. |
153
153
 
154
154
  ---
155
155
 
@@ -159,9 +159,12 @@ graph LR
159
159
  ### Core
160
160
  ```bash
161
161
  patchright-cli open [url] # Launch browser
162
- patchright-cli open --persistent # With persistent profile
162
+ patchright-cli open --profile=work # Named profile any session can use (logins persist)
163
163
  patchright-cli open --headless # Run headless
164
- patchright-cli open --profile=<path> # Custom profile directory
164
+ patchright-cli open --profile=./dir # A value with / or \ is a profile directory
165
+ patchright-cli --tab <name> open <url> # Named tab: shared browser, own page/refs
166
+ patchright-cli open --mobile # Emulate a generic mobile device (Pixel 7)
167
+ patchright-cli open --device="Pixel 5" # Emulate a specific Playwright device
165
168
  patchright-cli goto <url> # Navigate
166
169
  patchright-cli click <ref> # Click element
167
170
  patchright-cli click <ref> right # Right-click
@@ -180,8 +183,13 @@ patchright-cli drag <from> <to> # Drag and drop
180
183
  patchright-cli snapshot # Accessibility snapshot
181
184
  patchright-cli snapshot -i # Interactive elements only (recommended)
182
185
  patchright-cli snapshot --depth=3 # Limit depth
186
+ patchright-cli snapshot --selector=CSS # Snapshot a CSS-scoped subtree
183
187
  patchright-cli snapshot <ref> # Snapshot element subtree
184
188
  patchright-cli snapshot --filename=f # Save to custom path
189
+ patchright-cli find "text" # Search snapshot for text
190
+ patchright-cli find --regex "a|b" # Search by regex
191
+ patchright-cli find "text" --all # Include text/paragraph nodes
192
+ patchright-cli find "text" --limit=50 # Cap hits (default 20)
185
193
  patchright-cli eval <expr> # Run JavaScript
186
194
  patchright-cli eval --file=script.js # Run JS from file
187
195
  patchright-cli run-code <code> # Run JS with return value
@@ -190,6 +198,7 @@ patchright-cli screenshot # Page screenshot
190
198
  patchright-cli screenshot --full-page # Full scrollable page
191
199
  patchright-cli screenshot <ref> # Element screenshot
192
200
  patchright-cli screenshot --filename=f # Save to custom path
201
+ patchright-cli screenshot --hires # Capture at device pixel ratio
193
202
  patchright-cli close # Close session
194
203
  ```
195
204
 
@@ -198,6 +207,10 @@ patchright-cli close # Close session
198
207
  patchright-cli go-back
199
208
  patchright-cli go-forward
200
209
  patchright-cli reload
210
+ patchright-cli wait 500 # Wait a fixed number of milliseconds
211
+ patchright-cli wait --url="**/dashboard" # Wait for the URL to match (`*` never crosses a `/`)
212
+ patchright-cli wait-for <ref> # Wait until an element is visible
213
+ patchright-cli wait-for <ref> --state=hidden
201
214
  ```
202
215
 
203
216
  ### Keyboard / Mouse
@@ -285,6 +298,9 @@ patchright-cli tracing-stop # Saves .zip trace file
285
298
  patchright-cli video-start # Start video recording (CDP screencast)
286
299
  patchright-cli video-stop # Stop and save video (requires ffmpeg for .webm)
287
300
  patchright-cli video-stop --filename=recording.webm
301
+ patchright-cli show --annotate # Ask a human to mark up the page, wait for it
302
+ patchright-cli video-show-actions # Annotate each action in the recording
303
+ patchright-cli video-hide-actions # Stop annotating actions
288
304
  patchright-cli pdf --filename=page.pdf
289
305
  ```
290
306
 
@@ -317,13 +333,15 @@ patchright-cli install --skills # Auto-install skills for detected AI age
317
333
 
318
334
  ### Sessions
319
335
  ```bash
320
- patchright-cli -s=mysession open https://example.com --persistent
336
+ patchright-cli -s=mysession open https://example.com
321
337
  patchright-cli -s=mysession click e6
322
338
  patchright-cli -s=mysession close
323
339
  patchright-cli list # List all sessions
324
340
  patchright-cli close-all
325
341
  patchright-cli kill-all
326
- patchright-cli delete-data # Delete persistent profile
342
+ patchright-cli delete-data # Delete the profile named after the session
343
+ patchright-cli profile-list # Profiles, size, and which session uses each
344
+ patchright-cli profile-delete <name> # Delete an idle named profile
327
345
  patchright-cli --port=9322 open # Custom daemon port
328
346
  ```
329
347
 
@@ -116,7 +116,7 @@ graph LR
116
116
  |-----------|------|
117
117
  | **Daemon** (`daemon.py`) | Long-running process managing browser sessions via Patchright. Auto-starts on first `open`. |
118
118
  | **CLI** (`cli.py`) | Thin client — connects, sends command, prints result, disconnects. Browser stays open. |
119
- | **Snapshot** (`snapshot.py`) | `TreeWalker`-based DOM scan assigning `data-patchright-ref` attributes for element targeting. |
119
+ | **Snapshot** (`snapshot.py`) | Playwright `aria_snapshot()` accessibility tree, annotated with sequential `[ref=eN]` handles for element targeting. |
120
120
 
121
121
  ---
122
122
 
@@ -126,9 +126,12 @@ graph LR
126
126
  ### Core
127
127
  ```bash
128
128
  patchright-cli open [url] # Launch browser
129
- patchright-cli open --persistent # With persistent profile
129
+ patchright-cli open --profile=work # Named profile any session can use (logins persist)
130
130
  patchright-cli open --headless # Run headless
131
- patchright-cli open --profile=<path> # Custom profile directory
131
+ patchright-cli open --profile=./dir # A value with / or \ is a profile directory
132
+ patchright-cli --tab <name> open <url> # Named tab: shared browser, own page/refs
133
+ patchright-cli open --mobile # Emulate a generic mobile device (Pixel 7)
134
+ patchright-cli open --device="Pixel 5" # Emulate a specific Playwright device
132
135
  patchright-cli goto <url> # Navigate
133
136
  patchright-cli click <ref> # Click element
134
137
  patchright-cli click <ref> right # Right-click
@@ -147,8 +150,13 @@ patchright-cli drag <from> <to> # Drag and drop
147
150
  patchright-cli snapshot # Accessibility snapshot
148
151
  patchright-cli snapshot -i # Interactive elements only (recommended)
149
152
  patchright-cli snapshot --depth=3 # Limit depth
153
+ patchright-cli snapshot --selector=CSS # Snapshot a CSS-scoped subtree
150
154
  patchright-cli snapshot <ref> # Snapshot element subtree
151
155
  patchright-cli snapshot --filename=f # Save to custom path
156
+ patchright-cli find "text" # Search snapshot for text
157
+ patchright-cli find --regex "a|b" # Search by regex
158
+ patchright-cli find "text" --all # Include text/paragraph nodes
159
+ patchright-cli find "text" --limit=50 # Cap hits (default 20)
152
160
  patchright-cli eval <expr> # Run JavaScript
153
161
  patchright-cli eval --file=script.js # Run JS from file
154
162
  patchright-cli run-code <code> # Run JS with return value
@@ -157,6 +165,7 @@ patchright-cli screenshot # Page screenshot
157
165
  patchright-cli screenshot --full-page # Full scrollable page
158
166
  patchright-cli screenshot <ref> # Element screenshot
159
167
  patchright-cli screenshot --filename=f # Save to custom path
168
+ patchright-cli screenshot --hires # Capture at device pixel ratio
160
169
  patchright-cli close # Close session
161
170
  ```
162
171
 
@@ -165,6 +174,10 @@ patchright-cli close # Close session
165
174
  patchright-cli go-back
166
175
  patchright-cli go-forward
167
176
  patchright-cli reload
177
+ patchright-cli wait 500 # Wait a fixed number of milliseconds
178
+ patchright-cli wait --url="**/dashboard" # Wait for the URL to match (`*` never crosses a `/`)
179
+ patchright-cli wait-for <ref> # Wait until an element is visible
180
+ patchright-cli wait-for <ref> --state=hidden
168
181
  ```
169
182
 
170
183
  ### Keyboard / Mouse
@@ -252,6 +265,9 @@ patchright-cli tracing-stop # Saves .zip trace file
252
265
  patchright-cli video-start # Start video recording (CDP screencast)
253
266
  patchright-cli video-stop # Stop and save video (requires ffmpeg for .webm)
254
267
  patchright-cli video-stop --filename=recording.webm
268
+ patchright-cli show --annotate # Ask a human to mark up the page, wait for it
269
+ patchright-cli video-show-actions # Annotate each action in the recording
270
+ patchright-cli video-hide-actions # Stop annotating actions
255
271
  patchright-cli pdf --filename=page.pdf
256
272
  ```
257
273
 
@@ -284,13 +300,15 @@ patchright-cli install --skills # Auto-install skills for detected AI age
284
300
 
285
301
  ### Sessions
286
302
  ```bash
287
- patchright-cli -s=mysession open https://example.com --persistent
303
+ patchright-cli -s=mysession open https://example.com
288
304
  patchright-cli -s=mysession click e6
289
305
  patchright-cli -s=mysession close
290
306
  patchright-cli list # List all sessions
291
307
  patchright-cli close-all
292
308
  patchright-cli kill-all
293
- patchright-cli delete-data # Delete persistent profile
309
+ patchright-cli delete-data # Delete the profile named after the session
310
+ patchright-cli profile-list # Profiles, size, and which session uses each
311
+ patchright-cli profile-delete <name> # Delete an idle named profile
294
312
  patchright-cli --port=9322 open # Custom daemon port
295
313
  ```
296
314
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "patchright-cli"
3
- version = "0.6.0"
3
+ version = "0.7.0"
4
4
  description = "Anti-detect browser automation CLI using Patchright (undetected Playwright fork)"
5
5
  license = "Apache-2.0"
6
6
  requires-python = ">=3.10"
@@ -9,6 +9,14 @@ patchright-cli drives a real Chrome browser that passes bot detection (Cloudflar
9
9
 
10
10
  ## Quick start
11
11
 
12
+ If `patchright-cli` is not on PATH yet, install it first -- one of:
13
+
14
+ ```bash
15
+ uvx patchright-cli --version # run without installing
16
+ pip install patchright-cli # or install it
17
+ python -m patchright install chromium # then fetch the browser, once
18
+ ```
19
+
12
20
  ```bash
13
21
  patchright-cli open https://example.com # launch browser + navigate
14
22
  patchright-cli snapshot # get element refs
@@ -35,33 +43,63 @@ patchright-cli snapshot # read refs from output
35
43
  patchright-cli click e5 # use discovered ref
36
44
  ```
37
45
 
46
+ ## Shell quoting
47
+
48
+ Quote any URL containing `&`. Unquoted, the shell eats it before patchright-cli
49
+ sees it:
50
+
51
+ ```bash
52
+ # WRONG -- PowerShell 7 treats `&` as the background operator: the command is
53
+ # detached and everything after `&` is run as a separate command.
54
+ # cmd.exe treats it as a command separator. Either way the URL is truncated.
55
+ patchright-cli goto https://example.com/search?q=cats&page=2
56
+
57
+ # RIGHT -- on any shell
58
+ patchright-cli goto "https://example.com/search?q=cats&page=2"
59
+ ```
60
+
61
+ The same applies to `#` (a bash comment), spaces, and `%` (expanded by
62
+ cmd.exe), and to any argument holding shell metacharacters. Quoting always
63
+ works; leave it on.
64
+
38
65
  ## Global options
39
66
 
40
67
  These go before the command:
41
68
 
42
69
  ```bash
43
70
  --headless # Run headless (default: headed -- headed is less detectable)
44
- --persistent # Use persistent profile (keeps cookies/storage across sessions)
45
- --profile=/path # Custom profile directory
71
+ --profile=<name> # Named profile any session can use (default: the session name);
72
+ # profiles always persist. A value with / or \ is a directory
46
73
  --proxy=<url> # Proxy server (http, https, socks5) -- supports user:pass@host auth
47
74
  -s=mysession # Named session (default: "default", or PATCHRIGHT_CLI_SESSION env var)
48
75
  --port=9322 # Custom daemon port (default: 9321)
49
76
  --config=<path> # Load options from JSON config file
50
77
  --cdp=<url> # Attach to Chrome via CDP endpoint (use with `attach` command)
78
+ --context=new|host # With `attach`: fresh isolated context (default) or the browser's own
51
79
  --device="iPhone 15" # Emulate a device
80
+ --mobile # Emulate a generic mobile device (Pixel 7); mobile pages
81
+ # are lighter, so snapshots are smaller and cheaper
52
82
  --viewport-size=1280x720 # Set viewport size
53
83
  --locale=en-US # Browser locale
54
84
  --timezone=America/New_York # Timezone ID
55
85
  --geolocation=40.7,-74.0 # Geolocation override (lat,lon)
56
86
  --user-agent=<ua> # Custom user agent string
57
87
  --grant-permissions=geolocation,camera # Grant permissions at launch
58
- --timeout-action=10000 # Default action timeout (ms)
59
- --timeout-navigation=30000 # Default navigation timeout (ms)
60
88
  --show-port=9322 # Dashboard port (default: 9322)
61
89
  --raw # Strip page/snapshot decorations from output
62
90
  --json # Wrap full response as JSON ({success, output, ...})
63
91
  ```
64
92
 
93
+ These go *after* the command instead:
94
+
95
+ ```bash
96
+ --timeout=1800 # Daemon idle timeout in seconds before it exits and
97
+ # takes the browser (and its login) with it. Default 1800.
98
+ # Also settable up front via $PATCHRIGHT_CLI_IDLE_TIMEOUT.
99
+ --timeout-action=10000 # Default action timeout (ms)
100
+ --timeout-navigation=30000 # Default navigation timeout (ms)
101
+ ```
102
+
65
103
  ---
66
104
 
67
105
  ## Core commands
@@ -70,10 +108,11 @@ These go before the command:
70
108
 
71
109
  ```bash
72
110
  open [url] # Launch browser (optionally navigate)
73
- open --persistent # Keep cookies/storage between runs
111
+ open --profile=work # Run on a named profile (logins persist; one session at a time)
74
112
  open --headless # Headless mode
75
- attach --cdp=<url> # Attach to existing Chrome via CDP
76
- close # Close session (closes the browser)
113
+ attach --cdp=<url> # Attach to existing Chrome via CDP (fresh, isolated context)
114
+ attach --cdp=<url> --context=host # Use the Host Context: the browser's own logins, cookies, storage
115
+ close # Close session (closes the browser); refused on --context=host -- use detach
77
116
  detach # Detach an attached session (keeps external browser running)
78
117
  ```
79
118
 
@@ -92,11 +131,47 @@ title # Print page title
92
131
  ```bash
93
132
  snapshot # Full page snapshot
94
133
  snapshot <ref> # Subtree of a specific element
134
+ snapshot --selector="#main" # Subtree of a CSS selector -- must match exactly
135
+ # one element. No ref needed, so
136
+ # this works before the first snapshot
95
137
  snapshot --depth=N # Limit depth
96
138
  snapshot -i # Interactive elements only
97
139
  snapshot --boxes # Append [box=x,y,w,h] to each [ref=eN] line
98
140
  ```
99
141
 
142
+ ### Searching instead of snapshotting
143
+
144
+ On a large page, `find` is the cheaper first move — a full snapshot of a
145
+ Wikipedia article is ~87k tokens; `find` returns a few hundred.
146
+
147
+ ```bash
148
+ patchright-cli find "Sign in" # substring, case-insensitive
149
+ patchright-cli find --regex "sign (in|up)" # regex, case-insensitive
150
+ patchright-cli find --regex "/Sign In/" # slash form carries flags (i, m, s)
151
+ patchright-cli find "price" --all # include text/paragraph nodes
152
+ patchright-cli find "hide" --limit=50 # default limit is 20
153
+ ```
154
+
155
+ `find` searches links, buttons, inputs and headings by default — the things
156
+ you can act on. Use `--all` when you are looking for page *content* rather
157
+ than a control.
158
+
159
+ Each hit prints a `#` breadcrumb showing where it sits, so identical
160
+ controls stay distinguishable:
161
+
162
+ ```
163
+ # table > rowgroup > cell "407 points by pluc 4 hours ago | hide | 321 ..."
164
+ - link "hide": [ref=e49]
165
+ - /url: hide?id=49489982
166
+ ```
167
+
168
+ Refs from `find` are numbered across the whole page and are immediately
169
+ usable with `click`, `fill`, and the rest. They stay valid until the next
170
+ `snapshot` or `find`.
171
+
172
+ When output says `Found 20 of 340 matches`, narrow the query rather than
173
+ raising `--limit`.
174
+
100
175
  ### Interaction
101
176
 
102
177
  ```bash
@@ -138,6 +213,9 @@ screenshot --filename=F # Custom filename
138
213
  scroll <dx> <dy> # Scroll by pixels
139
214
  scroll-to <ref> # Scroll element into view
140
215
  wait <ms> # Wait N milliseconds
216
+ wait --url="**/dashboard" # Wait until the URL matches -- the right tool
217
+ # after a login or any redirect. `*` does NOT
218
+ # cross a `/`, so use `**`; `/regex/i` also works
141
219
  wait-for <ref> # Wait until element visible
142
220
  wait-for <ref> --state=hidden # Wait until hidden
143
221
  press <key> # Keypress (Enter, ArrowDown, etc.)
@@ -157,10 +235,51 @@ mousewheel <dx> <dy> # Scroll wheel
157
235
  ```bash
158
236
  tab-list # List open tabs
159
237
  tab-new <url> # Open new tab
160
- tab-select <index> # Switch to tab
161
- tab-close [index] # Close tab
238
+ tab-select <index> # Switch to tab (default tab only; a --tab
239
+ # caller is pinned to its own page)
240
+ tab-close [index] # Close tab (with --context=host, only tabs this session opened)
241
+ ```
242
+
243
+ ### Parallel agents: --tab
244
+
245
+ `--tab <name>` gives a caller its own page, its own refs and its own history
246
+ inside one shared browser -- same fingerprint, same cookies, same login. It is
247
+ the cheap way to parallelise: one Chrome total, not one per agent.
248
+
249
+ ```bash
250
+ patchright-cli --tab inbox-scan open https://app.example.com/inbox
251
+ patchright-cli --tab report-pull open https://app.example.com/reports
252
+ patchright-cli --tab inbox-scan snapshot # refs belong to this tab only
253
+ patchright-cli tab-list # every tab, labelled by owner
254
+ patchright-cli --tab inbox-scan close # frees this tab; browser stays
255
+ ```
256
+
257
+ **Choose the name once, with a shell-generated suffix.** Nothing enforces
258
+ uniqueness -- two agents on the same name share one page and clobber each
259
+ other. Do not invent the random part yourself; LLM-chosen "random" characters
260
+ collide.
261
+
262
+ ```bash
263
+ TAB="price-scan-$(openssl rand -hex 2)" && echo "$TAB"
264
+ patchright-cli --tab "$TAB" open https://example.com
265
+ # reuse that exact printed name in every later command
162
266
  ```
163
267
 
268
+ `$PATCHRIGHT_CLI_TAB` sets it for a whole shell, the way `$PATCHRIGHT_CLI_SESSION`
269
+ does for sessions.
270
+
271
+ Cleanup needs no coordination: every agent runs `close` addressed to its own
272
+ tab, and the browser exits when the last tab goes. On an `attach --context=host`
273
+ session the host's browser never exits: closing tabs leaves it attached, and
274
+ whoever attached runs `detach` at the end.
275
+
276
+ **`--tab` vs `-s`.** `--tab` shares identity, one browser (~50-150MB per extra
277
+ tab), for agents acting as the same logged-in user. `-s` isolates identity --
278
+ its own profile, cookies and fingerprint, a full Chrome each (~300-500MB) --
279
+ for multi-account work. Tabs share one browser process, so commands from
280
+ different tabs queue behind a slow navigation; separate sessions run fully in
281
+ parallel.
282
+
164
283
  ### Dialogs
165
284
 
166
285
  Dialogs must be pre-armed *before* the action that triggers them:
@@ -191,11 +310,14 @@ highlight <ref> --hide # Remove overlay; `highlight --hide` clears all
191
310
  ```bash
192
311
  screenshot / pdf # Static capture
193
312
  video-start / video-stop # Video recording
313
+ video-show-actions # Label each action in the recording [--duration=ms] [--position=P]
314
+ video-hide-actions # Stop labelling actions
194
315
  tracing-start / tracing-stop # Playwright trace
195
316
  codegen / codegen-stop # Record interactions as script
196
317
  resize <w> <h> # Viewport resize
197
318
  upload <file> [ref] # File upload
198
319
  show # Live dashboard
320
+ show --annotate # Ask a human to mark up the page and wait for it
199
321
  ```
200
322
 
201
323
  ### Storage
@@ -224,6 +346,8 @@ list # List active sessions
224
346
  close-all # Close all sessions
225
347
  kill-all # Force-kill all + stop daemon
226
348
  delete-data # Delete session profile data
349
+ profile-list # List profiles, size, and which session uses each
350
+ profile-delete <name> # Delete an idle named profile
227
351
  grant-permissions <perms> # Grant browser permissions
228
352
  ```
229
353
 
@@ -234,13 +358,13 @@ grant-permissions <perms> # Grant browser permissions
234
358
  ### Login flow
235
359
 
236
360
  ```bash
237
- patchright-cli open https://example.com/login --persistent
361
+ patchright-cli open --profile=myapp https://example.com/login
238
362
  patchright-cli snapshot
239
363
  patchright-cli fill e3 "user@example.com"
240
364
  patchright-cli fill e5 "password123"
241
365
  patchright-cli click e8
242
366
  patchright-cli snapshot
243
- # With --persistent, cookies survive across sessions
367
+ # The login persists in profile "myapp" for any later session that opens it
244
368
  ```
245
369
 
246
370
  ### Extracting data
@@ -278,11 +402,35 @@ patchright-cli click e5 # This click triggers the dialog
278
402
  ```bash
279
403
  patchright-cli wait-for e12 # Wait for element
280
404
  patchright-cli wait 1000 # Fixed wait
405
+ patchright-cli wait --url="**/dashboard" # Wait for a redirect to land
281
406
  # For custom conditions, use run-code (see references/running-code.md)
282
407
  ```
283
408
 
284
409
  ---
285
410
 
411
+ ## Asking a human what to change
412
+
413
+ `show --annotate` is for design and UI review: it opens a page in the user's
414
+ browser showing a live capture of the current page, they draw on it and write
415
+ what they want changed, and the command returns their drawing plus their notes.
416
+
417
+ ```bash
418
+ patchright-cli show --annotate # waits up to 5 minutes
419
+ patchright-cli show --annotate --wait=900 # give them longer
420
+ patchright-cli show --annotate --no-open # headless box: do not launch a browser
421
+ ```
422
+
423
+ The command **blocks** until they submit, so it opens the review link for them
424
+ rather than printing it. The link is also written to
425
+ `.patchright-cli/annotate-url.txt`, which is how you get it when `--no-open`
426
+ suppressed the browser. You get back the annotated screenshot saved under
427
+ `.patchright-cli/`, their notes, and a fresh snapshot of the page -- enough to
428
+ act on the feedback without asking follow-up questions.
429
+
430
+ Reach for it when the decision is aesthetic or subjective and you would
431
+ otherwise be guessing: which of two layouts, where an element belongs, whether
432
+ spacing reads right. Do not use it for anything you can check yourself.
433
+
286
434
  ## Anti-detect notes
287
435
 
288
436
  - Uses real Chrome (not Chromium) -- this is what makes it undetectable
@@ -291,7 +439,8 @@ patchright-cli wait 1000 # Fixed wait
291
439
  - No custom user-agent or headers by default -- preserves Chrome's natural fingerprint
292
440
  - Persistent profiles maintain realistic browser history and cookies
293
441
  - The daemon architecture means Chrome stays running between commands, behaving like a real user's browser
294
- - `attach --cdp` lets you connect to an existing Chrome instance
442
+ - `attach --cdp` lets you connect to an existing Chrome instance; add `--context=host` to reuse its logins,
443
+ cookies and storage (see references/session-management.md)
295
444
 
296
445
  ## Config files
297
446
 
@@ -339,6 +488,16 @@ pip install patchright-cli && patchright-cli install --skills
339
488
  # "Install patchright-cli skill from https://raw.githubusercontent.com/AhaiMk01/patchright-cli/main/skills/patchright-cli/SKILL.md"
340
489
  ```
341
490
 
491
+ When an installed copy of this skill drifts from the tool version,
492
+ patchright-cli prints a one-line warning on stderr -- once a day per
493
+ version, so a chained run is not buried in it. Re-run
494
+ `patchright-cli install --skills` to resync, or set
495
+ `PATCHRIGHT_CLI_NO_SKILL_CHECK=1` to silence the check.
496
+
497
+ `open` also checks PyPI once a day for a newer patchright-cli and prints a
498
+ one-line note when there is one. Set `PATCHRIGHT_CLI_NO_VERSION_CHECK=1` to
499
+ turn that off.
500
+
342
501
  ## Specific tasks
343
502
 
344
503
  * **Snapshots and element refs** [references/snapshot-refs.md](references/snapshot-refs.md)