patchright-cli 0.9.0__tar.gz → 0.10.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 (73) hide show
  1. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.claude-plugin/marketplace.json +1 -1
  2. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.github/workflows/ci.yml +15 -5
  3. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.github/workflows/publish-docker.yml +1 -1
  4. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.github/workflows/publish.yml +8 -8
  5. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/CLAUDE.md +6 -3
  6. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/Dockerfile +1 -1
  7. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/PKG-INFO +102 -8
  8. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/README.md +101 -7
  9. patchright_cli-0.10.0/docs/daemon-protocol.md +140 -0
  10. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/pyproject.toml +2 -2
  11. patchright_cli-0.10.0/scripts/gen_skill.py +79 -0
  12. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/SKILL.md +203 -41
  13. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/src/patchright_cli/__init__.py +1 -1
  14. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/src/patchright_cli/__main__.py +1 -1
  15. patchright_cli-0.10.0/src/patchright_cli/_entry.py +26 -0
  16. patchright_cli-0.10.0/src/patchright_cli/agent_hooks.py +470 -0
  17. patchright_cli-0.10.0/src/patchright_cli/cli.py +1991 -0
  18. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/src/patchright_cli/daemon.py +282 -61
  19. patchright_cli-0.10.0/src/patchright_cli/daemon_pid.py +168 -0
  20. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/src/patchright_cli/mcp_server.py +78 -0
  21. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/src/patchright_cli/ref_registry.py +42 -21
  22. patchright_cli-0.10.0/src/patchright_cli/toon.py +281 -0
  23. patchright_cli-0.10.0/tests/test_agent_hooks.py +416 -0
  24. patchright_cli-0.10.0/tests/test_cli_axi.py +539 -0
  25. patchright_cli-0.10.0/tests/test_cli_home.py +256 -0
  26. patchright_cli-0.10.0/tests/test_daemon_axi.py +485 -0
  27. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_daemon_handlers.py +4 -2
  28. patchright_cli-0.10.0/tests/test_daemon_info.py +53 -0
  29. patchright_cli-0.10.0/tests/test_daemon_pid.py +245 -0
  30. patchright_cli-0.10.0/tests/test_daemon_read.py +118 -0
  31. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_daemon_token.py +22 -0
  32. patchright_cli-0.10.0/tests/test_docker.py +112 -0
  33. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_e2e.py +1 -1
  34. patchright_cli-0.10.0/tests/test_emulation.py +203 -0
  35. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_mcp.py +1 -1
  36. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_navigation_policy.py +1 -1
  37. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_profiles.py +16 -2
  38. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_ref_registry.py +123 -11
  39. patchright_cli-0.10.0/tests/test_skill_sync.py +60 -0
  40. patchright_cli-0.10.0/tests/test_toon.py +275 -0
  41. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/uv.lock +1 -1
  42. patchright_cli-0.9.0/src/patchright_cli/cli.py +0 -944
  43. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.claude-plugin/skills/browser-automation.json +0 -0
  44. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.github/dependabot.yml +0 -0
  45. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.gitignore +0 -0
  46. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/.pre-commit-config.yaml +0 -0
  47. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/CONTRIBUTING.md +0 -0
  48. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/GLOSSARY.md +0 -0
  49. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/LICENSE +0 -0
  50. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/Makefile +0 -0
  51. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/compose.yml +0 -0
  52. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/docs/installation.md +0 -0
  53. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/docs/mcp-architecture.svg +0 -0
  54. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/patchright-cli +0 -0
  55. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/patchright-cli.cmd +0 -0
  56. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/references/request-mocking.md +0 -0
  57. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/references/running-code.md +0 -0
  58. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/references/session-management.md +0 -0
  59. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/references/snapshot-refs.md +0 -0
  60. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/references/storage-state.md +0 -0
  61. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/references/tracing.md +0 -0
  62. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/skills/patchright-cli/references/video-recording.md +0 -0
  63. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/src/patchright_cli/dashboard.py +0 -0
  64. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/src/patchright_cli/snapshot.py +0 -0
  65. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/__init__.py +0 -0
  66. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/fixture.html +0 -0
  67. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_annotate.py +0 -0
  68. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_attach.py +0 -0
  69. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_cli_config.py +0 -0
  70. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_network_guard.py +0 -0
  71. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_packaging.py +0 -0
  72. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_supply_chain.py +0 -0
  73. {patchright_cli-0.9.0 → patchright_cli-0.10.0}/tests/test_tabs.py +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.9.0"
8
+ "version": "0.10.0"
9
9
  },
10
10
  "plugins": [
11
11
  {
@@ -10,8 +10,8 @@ jobs:
10
10
  lint:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v4
14
- - uses: astral-sh/setup-uv@v6
13
+ - uses: actions/checkout@v7
14
+ - uses: astral-sh/setup-uv@v7
15
15
  with:
16
16
  version: ">=0.7,<0.8"
17
17
  python-version: "3.12"
@@ -28,8 +28,8 @@ jobs:
28
28
  python-version: "3.12"
29
29
  runs-on: ${{ matrix.os }}
30
30
  steps:
31
- - uses: actions/checkout@v4
32
- - uses: astral-sh/setup-uv@v6
31
+ - uses: actions/checkout@v7
32
+ - uses: astral-sh/setup-uv@v7
33
33
  with:
34
34
  version: ">=0.7,<0.8"
35
35
  python-version: ${{ matrix.python-version }}
@@ -39,7 +39,7 @@ jobs:
39
39
  docker:
40
40
  runs-on: ubuntu-latest
41
41
  steps:
42
- - uses: actions/checkout@v4
42
+ - uses: actions/checkout@v7
43
43
  - run: docker build -t patchright-cli:ci .
44
44
  - run: docker run --rm patchright-cli:ci --help
45
45
  - name: Browser session inside the container
@@ -78,6 +78,16 @@ jobs:
78
78
  grep -q "refusing to start \`mcp --http\`" unprotected.log
79
79
  - name: compose.yml works without a token
80
80
  run: docker compose config -q
81
+ - uses: astral-sh/setup-uv@v7
82
+ with:
83
+ version: ">=0.7,<0.8"
84
+ python-version: "3.12"
85
+ - name: Image test suite
86
+ run: |
87
+ uv venv && uv pip install -e ".[dev]"
88
+ uv run pytest tests/test_docker.py -v
89
+ env:
90
+ PATCHRIGHT_CLI_DOCKER_IMAGE: patchright-cli:ci
81
91
  - if: failure()
82
92
  run: |
83
93
  docker logs cli || true
@@ -24,7 +24,7 @@ jobs:
24
24
 
25
25
  steps:
26
26
  - name: Checkout repository
27
- uses: actions/checkout@v6
27
+ uses: actions/checkout@v7
28
28
 
29
29
  - name: Set up Docker Buildx
30
30
  uses: docker/setup-buildx-action@v4
@@ -15,10 +15,10 @@ jobs:
15
15
  build:
16
16
  runs-on: ubuntu-latest
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v7
19
19
 
20
20
  - name: Install uv
21
- uses: astral-sh/setup-uv@v5
21
+ uses: astral-sh/setup-uv@v7
22
22
 
23
23
  - name: Set up Python
24
24
  run: uv python install 3.12
@@ -27,7 +27,7 @@ jobs:
27
27
  run: uv build
28
28
 
29
29
  - name: Upload artifacts
30
- uses: actions/upload-artifact@v4
30
+ uses: actions/upload-artifact@v7
31
31
  with:
32
32
  name: dist
33
33
  path: dist/
@@ -40,13 +40,13 @@ jobs:
40
40
  id-token: write
41
41
  steps:
42
42
  - name: Download artifacts
43
- uses: actions/download-artifact@v4
43
+ uses: actions/download-artifact@v8
44
44
  with:
45
45
  name: dist
46
46
  path: dist/
47
47
 
48
48
  - name: Install uv
49
- uses: astral-sh/setup-uv@v5
49
+ uses: astral-sh/setup-uv@v7
50
50
 
51
51
  - name: Publish to PyPI
52
52
  run: uv publish
@@ -59,16 +59,16 @@ jobs:
59
59
  permissions:
60
60
  contents: write
61
61
  steps:
62
- - uses: actions/checkout@v4
62
+ - uses: actions/checkout@v7
63
63
 
64
64
  - name: Download artifacts
65
- uses: actions/download-artifact@v4
65
+ uses: actions/download-artifact@v8
66
66
  with:
67
67
  name: dist
68
68
  path: dist/
69
69
 
70
70
  - name: Create GitHub Release
71
- uses: softprops/action-gh-release@v2
71
+ uses: softprops/action-gh-release@v3
72
72
  with:
73
73
  files: dist/*
74
74
  generate_release_notes: true
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4
4
 
5
5
  ## Project Overview
6
6
 
7
- patchright-cli is an anti-detect browser automation CLI built on [Patchright](https://github.com/kaliiiiiiiiii/patchright-python) (undetected Playwright fork). It provides the same command interface as Microsoft's playwright-cli but bypasses bot detection (Akamai, Cloudflare, etc.).
7
+ patchright-cli is an anti-detect browser automation CLI built on [Patchright](https://github.com/kaliiiiiiiiii/patchright-python) (undetected Playwright fork). Its commands follow Microsoft's playwright-cli, but it bypasses bot detection (Akamai, Cloudflare, etc.) and is not a drop-in replacement: playwright-cli features Patchright cannot support (other browsers, extensions) are left out, and unknown flags are rejected with exit 2 rather than ignored.
8
8
 
9
9
  ## Development Setup
10
10
 
@@ -37,6 +37,9 @@ pytest tests/test_e2e.py -v
37
37
 
38
38
  # Lint
39
39
  pre-commit run --all-files
40
+
41
+ # SKILL.md command block in sync with COMMAND_SPECS (rewrite without --check)
42
+ python scripts/gen_skill.py --check
40
43
  ```
41
44
 
42
45
  ## Architecture
@@ -47,7 +50,7 @@ Three-component client-daemon-browser design:
47
50
  CLI (cli.py) --TCP:9321--> Daemon (daemon.py) --Patchright--> Chrome
48
51
  ```
49
52
 
50
- - **CLI (`src/patchright_cli/cli.py`)**: Stateless thin client. Parses argv manually (not click subcommands), builds a JSON `{command, args, options, cwd}` message, sends it over a length-prefixed TCP socket to the daemon, prints the response, and exits. All commands are defined in the `COMMANDS_HELP` dict and `ALL_COMMANDS` list.
53
+ - **CLI (`src/patchright_cli/cli.py`)**: Stateless thin client. Parses argv manually (not click subcommands), builds a JSON `{command, args, options, cwd}` message, sends it over a length-prefixed TCP socket to the daemon, prints the response, and exits. All commands are defined in the `COMMAND_SPECS` dict (usage, summary, flags, examples; `COMMANDS_HELP` and `ALL_COMMANDS` derive from it) and grouped for the manual in `COMMAND_CATEGORIES`. With no arguments it prints the home view (`_print_home`): live daemon state from an already-running daemon only, never starting one. `--toon` renders a reply's `data` field with `toon.py`.
51
54
 
52
55
  - **Daemon (`src/patchright_cli/daemon.py`)**: Long-running async process managing browser sessions. Auto-spawned on `open` via `ensure_daemon_running()` which launches a subprocess. Uses `DaemonState` → multiple `Session` objects, each owning a Patchright persistent browser context. Command dispatch uses `@register()` decorated handlers in `COMMAND_HANDLERS` dict, dispatched by `handle_command()`. Console capture uses CDP sessions (not Playwright's `page.on('console')`) because Patchright suppresses it.
53
56
 
@@ -59,7 +62,7 @@ CLI (cli.py) --TCP:9321--> Daemon (daemon.py) --Patchright--> Chrome
59
62
  - Headed by default (headless is more detectable)
60
63
  - 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
64
  - CLI-daemon protocol: length-prefixed (4-byte big-endian `!I`) JSON over TCP; every message carries a `token` field read from `~/.patchright-cli/daemon-<port>.token` (written 0600 by the daemon before it listens), and the daemon rejects messages without the right one
62
- - CLI parses argv manually in `main()` — click is only used for `click.echo()`, not subcommands. New commands need a `COMMANDS_HELP` entry and a `@register("<name>")` handler in daemon.py; only session and lifecycle commands (open, attach, close, kill-all, ...) live in `handle_command()` itself
65
+ - CLI parses argv manually in `main()` — click is only used for `click.echo()`, not subcommands. New commands need a `COMMAND_SPECS` entry, a place in `COMMAND_CATEGORIES`, and a `@register("<name>")` handler in daemon.py, then `python scripts/gen_skill.py` to refresh the generated command block in `skills/patchright-cli/SKILL.md` (`--check` exits 1 when stale; `tests/test_skill_sync.py` enforces it); only session and lifecycle commands (open, attach, close, kill-all, ...) live in `handle_command()` itself
63
66
  - 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
67
  - `python -m patchright_cli` works via `__main__.py`
65
68
  - Uses hatchling as build backend, ruff for linting (line-length=120, target py310)
@@ -1,6 +1,6 @@
1
1
  # Base images are pinned by multi-arch index digest; Dependabot (.github/dependabot.yml) bumps them.
2
2
  # uv is a named stage because Dependabot only reads image references on FROM lines.
3
- FROM ghcr.io/astral-sh/uv:latest@sha256:32a7bb39b496babbd997b0a39a4d66c126bdaf5661b302bf6f06abda8deca6ff AS uv
3
+ FROM ghcr.io/astral-sh/uv:latest@sha256:af22a52f5eafef3d78e551599d405c02df61919d18028f0cea8eda93bc9986d0 AS uv
4
4
 
5
5
  FROM python:3.12-slim@sha256:5b8b1421ccb6a525860a77863c049eab5847076cda34e030c75a80c58faf3f3c
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: patchright-cli
3
- Version: 0.9.0
3
+ Version: 0.10.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
@@ -46,7 +46,7 @@ Description-Content-Type: text/markdown
46
46
  [![GitHub issues](https://img.shields.io/github/issues/AhaiMk01/patchright-cli?label=Issues)](https://github.com/AhaiMk01/patchright-cli/issues)
47
47
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
48
48
 
49
- Anti-detect browser automation CLI. Same command interface as [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli) but using [Patchright](https://github.com/kaliiiiiiiiii/patchright-python) (undetected Playwright fork) to bypass bot detection.
49
+ Anti-detect browser automation CLI. Commands follow [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli), but it uses [Patchright](https://github.com/kaliiiiiiiiii/patchright-python) (undetected Playwright fork) to bypass bot detection.
50
50
 
51
51
  [Install](#install) · [Quick Start](#quick-start) · [Commands](#-commands) · [Snapshots](#snapshots) · [Agent Integration](#agent-integration)
52
52
 
@@ -55,7 +55,7 @@ Anti-detect browser automation CLI. Same command interface as [Microsoft's playw
55
55
  | | Feature |
56
56
  |---|---|
57
57
  | :shield: | Bypasses Akamai, Cloudflare, and other anti-bot systems |
58
- | :rocket: | Same command interface as playwright-cli — zero learning curve |
58
+ | :rocket: | playwright-cli's command names and arguments — little to relearn |
59
59
  | :robot: | Built for AI agents (Claude Code, Codex, etc.) with YAML snapshots |
60
60
  | :zap: | Daemon architecture — browser stays open between commands |
61
61
  | :package: | `pip install` / `uvx` — no Docker, no config files |
@@ -211,6 +211,16 @@ patchright-cli screenshot
211
211
  patchright-cli close
212
212
  ```
213
213
 
214
+ Quote URLs that contain `&`; unquoted, bash, PowerShell and cmd.exe all split the command there. On Windows two cases need more than quotes: in cmd.exe without quotes, escape it as `^&` (inside quotes the `^` stays in the URL, so use one or the other), and when PowerShell runs a `.cmd`/`.bat` wrapper such as the repo's `patchright-cli.cmd`, PowerShell drops the quotes and cmd.exe splits at `&`, so pass the rest verbatim with `--%`:
215
+
216
+ ```
217
+ patchright-cli goto "https://example.com/?a=1&b=2" # any shell, patchright-cli.exe
218
+ patchright-cli goto https://example.com/?a=1^&b=2 # cmd.exe, unquoted
219
+ .\patchright-cli.cmd --% goto "https://example.com/?a=1&b=2" # PowerShell, .cmd wrapper
220
+ ```
221
+
222
+ Don't use `--%` with the installed `patchright-cli.exe`: in PowerShell 7 the quotes after it reach the CLI and end up in the URL.
223
+
214
224
  ---
215
225
 
216
226
  ## Architecture
@@ -236,6 +246,16 @@ The daemon only listens on `127.0.0.1`, but any local process can reach that por
236
246
  - Run the CLI as the same user, with the same home directory, as the daemon. In Docker the MCP server and daemon share a user and `HOME`, so this holds.
237
247
  - An older CLI talking to a newer daemon gets an error saying the daemon requires an auth token: upgrade, or stop the daemon (`patchright-cli kill-all` from the newer install, or end the process). A newer CLI talking to an older daemon finds no token file and sends none, which the older daemon accepts.
238
248
 
249
+ ### Stopping a stuck daemon
250
+
251
+ The daemon runs without a window. `kill-all` asks it to close every session and exit. If it does not answer within 20 seconds, or with `--force`, the CLI ends the daemon process and the browsers it launched (`taskkill /T` on Windows, the daemon's process group elsewhere). It finds the process through `~/.patchright-cli/daemon-<port>.pid`, which the daemon writes at startup with its PID and start time, and kills only a process whose start time still matches, so a reused PID is never touched. A daemon from a version that writes no PID file has to be ended by hand: its command line contains `patchright_cli.daemon`.
252
+
253
+ ### Daemon client protocol
254
+
255
+ Third-party clients can use the daemon TCP interface directly. The
256
+ [client protocol reference](docs/daemon-protocol.md) defines discovery,
257
+ authentication, message framing, replies, and compatibility rules.
258
+
239
259
  ---
240
260
 
241
261
  <details>
@@ -322,6 +342,22 @@ patchright-cli upload ./file.pdf e5 # Upload to specific input
322
342
  patchright-cli resize 1920 1080 # Resize viewport
323
343
  ```
324
344
 
345
+ ### Emulation
346
+ ```bash
347
+ patchright-cli set-color-scheme dark # dark | light | no-preference
348
+ patchright-cli clear-color-scheme
349
+ patchright-cli set-reduced-motion reduce # reduce | no-preference
350
+ patchright-cli clear-reduced-motion
351
+ patchright-cli set-forced-colors active # active | none
352
+ patchright-cli clear-forced-colors
353
+ patchright-cli set-contrast more # more | no-preference
354
+ patchright-cli clear-contrast
355
+ patchright-cli set-media print # screen | print
356
+ patchright-cli clear-media
357
+ ```
358
+
359
+ Each setting holds for the whole session, including tabs and popups opened later; `clear-*` drops just that one, back to the browser default. A popup gets the setting just after it opens, so a script that reads media queries the instant the popup is created may still see the default.
360
+
325
361
  ### Tabs
326
362
  ```bash
327
363
  patchright-cli tab-list
@@ -409,6 +445,35 @@ patchright-cli console --clear # Clear after printing
409
445
  ```bash
410
446
  patchright-cli --raw eval --file=s.js # Raw output (no page/snapshot decoration)
411
447
  patchright-cli --raw snapshot > p.yml # Pipe raw snapshot to file
448
+ patchright-cli --json tab-list # Whole reply as JSON ({success, output, data, ...})
449
+ patchright-cli --toon tab-list # Structured result as TOON
450
+ ```
451
+
452
+ `--toon` prints a reply's structured `data` as [TOON](https://github.com/toon-format/spec), a compact
453
+ format for agents: `list`, `tab-list`, `cookie-list`, `localstorage-list`, `sessionstorage-list`,
454
+ `route-list`, `console`, `network`, `profile-list` and `find` give a table, `url` and `title` a single
455
+ field. A cut-short list adds `total` and a `help:` line. Commands without structured data, and errors,
456
+ print exactly as they do without the flag. `--json` and `--toon` together are a usage error.
457
+
458
+ ```
459
+ tabs[2]{index,title,url,active}:
460
+ 0,Example Domain,"https://example.com/",true
461
+ 1,"","about:blank",false
462
+ ```
463
+
464
+ Run with no arguments, `patchright-cli` prints a short home view instead of the manual (that is
465
+ `--help`): where the binary is, whether the daemon is running on the port (`--port=N` picks another),
466
+ the open sessions with their URL and tab count, and what to run next. It only asks a daemon that is
467
+ already running and never starts one. Add `--toon` or `--json` for the same state as data.
468
+
469
+ ```
470
+ ~/.local/bin/patchright-cli v0.10.0 -- anti-detect Chrome automation CLI (playwright-cli style commands)
471
+ daemon: running on port 9321 (1 session)
472
+ sessions[1]{name,status,url,tabs}:
473
+ default,open,"https://example.com/",2
474
+ help: patchright-cli snapshot (element refs for the current page; -s=<name> for another session)
475
+ help: patchright-cli list (sessions and their tabs)
476
+ help: patchright-cli --help (all commands); patchright-cli <command> --help (one command)
412
477
  ```
413
478
 
414
479
  ### Setup
@@ -423,7 +488,8 @@ patchright-cli -s=mysession click e6
423
488
  patchright-cli -s=mysession close
424
489
  patchright-cli list # List all sessions
425
490
  patchright-cli close-all
426
- patchright-cli kill-all
491
+ patchright-cli kill-all # Stop the daemon; force-stops it if it does not answer
492
+ patchright-cli kill-all --force # Kill the daemon and its browsers without asking
427
493
  patchright-cli delete-data # Delete the profile named after the session
428
494
  patchright-cli profile-list # Profiles, size, and which session uses each
429
495
  patchright-cli profile-delete <name> # Delete an idle named profile
@@ -436,10 +502,36 @@ patchright-cli --port=9322 open # Custom daemon port
436
502
 
437
503
  ## Agent Integration
438
504
 
439
- Works with Claude Code, Cursor, Gemini CLI, Codex, and [40+ other agents](https://github.com/vercel-labs/skills).
505
+ The CLI follows the [AXI](https://github.com/kunchenguid/axi) standard for agent-facing tools: errors and hints on stdout, exit 2 for usage errors, `(no-op)` for repeated actions, and a no-argument home view with live state.
506
+
507
+ There are two ways to teach your agent about patchright-cli. Both get it to the same place, so you only need one.
508
+
509
+ | | Session hook | Skill |
510
+ |---|---|---|
511
+ | Install | `patchright-cli install --hooks` | `npx skills add AhaiMk01/patchright-cli` or `patchright-cli install --skills` |
512
+ | What the agent gets | Live state (open sessions, the commands to drive them) at the start of every session | Full command reference, loaded when a browser task comes up |
513
+ | Cost | A few lines of context in every session | Nothing until it is needed |
514
+ | Agents | Claude Code, Codex, OpenCode | Claude Code, Cursor, Gemini CLI, Codex and [40+ others](https://github.com/vercel-labs/skills) |
515
+
516
+ ### Session hook (recommended)
517
+
518
+ ```bash
519
+ patchright-cli install --hooks # install or repair
520
+ patchright-cli install --hooks --uninstall # remove
521
+ ```
522
+
523
+ At the start of each session the agent runs `patchright-cli` with no arguments, which prints the home view (see [Output](#output)): whether the daemon is up and which sessions are open, so the agent can pick up an open browser session without asking. The hook goes only to apps whose config directory exists, and prints one line per app (`installed`, `updated`, `(no-op)` or `skipped`):
524
+
525
+ - **Claude Code**: a `SessionStart` hook in `~/.claude/settings.json`
526
+ - **Codex**: a `SessionStart` hook in `~/.codex/hooks.json`, plus `hooks = true` under `[features]` in `~/.codex/config.toml`
527
+ - **OpenCode**: a managed plugin at `~/.config/opencode/plugins/patchright-cli.js` that adds the dashboard to the system prompt
528
+
529
+ The hook calls plain `patchright-cli` when that name on your `PATH` is the same binary you ran the install with, and its absolute path otherwise. Re-run `install --hooks` after reinstalling or moving patchright-cli and it rewrites the path. Your other hooks and settings are left as they are, and `--uninstall` removes only patchright-cli's entries (the Codex `[features]` flag stays, since other hooks may need it).
530
+
531
+ ### Skill
440
532
 
441
533
  ```bash
442
- # Install skill for all detected agents (recommended)
534
+ # Install skill for all detected agents
443
535
  npx skills add AhaiMk01/patchright-cli
444
536
  ```
445
537
 
@@ -530,7 +622,7 @@ URLs passed to `patchright_open`, `patchright_goto` and `patchright_tab_new` mus
530
622
  <details>
531
623
  <summary><h2>Differences from playwright-cli</h2></summary>
532
624
 
533
- patchright-cli aims for full command parity with [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli). The following playwright-cli features are **intentionally not implemented** due to Patchright's architecture:
625
+ patchright-cli follows the command names and arguments of [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli) where Patchright allows it, but it is **not a drop-in replacement**. Some playwright-cli features cannot work on Patchright and are not implemented:
534
626
 
535
627
  | Feature | Reason |
536
628
  |---------|--------|
@@ -538,7 +630,7 @@ patchright-cli aims for full command parity with [Microsoft's playwright-cli](ht
538
630
  | `--extension` | Browser extension connection not supported. Patchright uses CDP directly. |
539
631
  | `install` / `install-browser` | Use `python -m patchright install chromium` instead. |
540
632
 
541
- All other commands and options are fully supported.
633
+ Each command accepts only the flags it implements. A playwright-cli flag patchright-cli does not support, such as `open --browser=firefox`, is rejected with `error: unknown flag` and exit code 2 rather than silently ignored, so a script ported from playwright-cli fails loudly where it would otherwise behave differently. `patchright-cli <command> --help` lists a command's flags.
542
634
 
543
635
  </details>
544
636
 
@@ -558,6 +650,8 @@ This project builds on the work of:
558
650
  - **[Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright)** by [@Kaliiiiiiiiii-Vinyzu](https://github.com/Kaliiiiiiiiii-Vinyzu) — the undetected Playwright fork that makes this possible. All anti-detect capabilities come from Patchright.
559
651
  - **[playwright-cli](https://github.com/microsoft/playwright-cli)** by Microsoft — the original CLI that patchright-cli's command interface is modeled after.
560
652
  - **[camoufox-cli](https://github.com/Bin-Huang/camoufox-cli)** by [@Bin-Huang](https://github.com/Bin-Huang) — inspiration for the CLI-first approach to anti-detect browser automation and the SKILL.md agent integration pattern.
653
+ - **[AXI (Agent eXperience Interface)](https://github.com/kunchenguid/axi)** by [@kunchenguid](https://github.com/kunchenguid) — the standard for agent-facing CLIs that shaped the home view, strict per-command flags, `error:`/`help:` output, `(no-op)` replies, explicit empty states and the session-start hook.
654
+ - **[TOON](https://github.com/toon-format/spec)** — the token-oriented output format behind `--toon`.
561
655
 
562
656
  ---
563
657
 
@@ -9,7 +9,7 @@
9
9
  [![GitHub issues](https://img.shields.io/github/issues/AhaiMk01/patchright-cli?label=Issues)](https://github.com/AhaiMk01/patchright-cli/issues)
10
10
  [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
11
11
 
12
- Anti-detect browser automation CLI. Same command interface as [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli) but using [Patchright](https://github.com/kaliiiiiiiiii/patchright-python) (undetected Playwright fork) to bypass bot detection.
12
+ Anti-detect browser automation CLI. Commands follow [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli), but it uses [Patchright](https://github.com/kaliiiiiiiiii/patchright-python) (undetected Playwright fork) to bypass bot detection.
13
13
 
14
14
  [Install](#install) · [Quick Start](#quick-start) · [Commands](#-commands) · [Snapshots](#snapshots) · [Agent Integration](#agent-integration)
15
15
 
@@ -18,7 +18,7 @@ Anti-detect browser automation CLI. Same command interface as [Microsoft's playw
18
18
  | | Feature |
19
19
  |---|---|
20
20
  | :shield: | Bypasses Akamai, Cloudflare, and other anti-bot systems |
21
- | :rocket: | Same command interface as playwright-cli — zero learning curve |
21
+ | :rocket: | playwright-cli's command names and arguments — little to relearn |
22
22
  | :robot: | Built for AI agents (Claude Code, Codex, etc.) with YAML snapshots |
23
23
  | :zap: | Daemon architecture — browser stays open between commands |
24
24
  | :package: | `pip install` / `uvx` — no Docker, no config files |
@@ -174,6 +174,16 @@ patchright-cli screenshot
174
174
  patchright-cli close
175
175
  ```
176
176
 
177
+ Quote URLs that contain `&`; unquoted, bash, PowerShell and cmd.exe all split the command there. On Windows two cases need more than quotes: in cmd.exe without quotes, escape it as `^&` (inside quotes the `^` stays in the URL, so use one or the other), and when PowerShell runs a `.cmd`/`.bat` wrapper such as the repo's `patchright-cli.cmd`, PowerShell drops the quotes and cmd.exe splits at `&`, so pass the rest verbatim with `--%`:
178
+
179
+ ```
180
+ patchright-cli goto "https://example.com/?a=1&b=2" # any shell, patchright-cli.exe
181
+ patchright-cli goto https://example.com/?a=1^&b=2 # cmd.exe, unquoted
182
+ .\patchright-cli.cmd --% goto "https://example.com/?a=1&b=2" # PowerShell, .cmd wrapper
183
+ ```
184
+
185
+ Don't use `--%` with the installed `patchright-cli.exe`: in PowerShell 7 the quotes after it reach the CLI and end up in the URL.
186
+
177
187
  ---
178
188
 
179
189
  ## Architecture
@@ -199,6 +209,16 @@ The daemon only listens on `127.0.0.1`, but any local process can reach that por
199
209
  - Run the CLI as the same user, with the same home directory, as the daemon. In Docker the MCP server and daemon share a user and `HOME`, so this holds.
200
210
  - An older CLI talking to a newer daemon gets an error saying the daemon requires an auth token: upgrade, or stop the daemon (`patchright-cli kill-all` from the newer install, or end the process). A newer CLI talking to an older daemon finds no token file and sends none, which the older daemon accepts.
201
211
 
212
+ ### Stopping a stuck daemon
213
+
214
+ The daemon runs without a window. `kill-all` asks it to close every session and exit. If it does not answer within 20 seconds, or with `--force`, the CLI ends the daemon process and the browsers it launched (`taskkill /T` on Windows, the daemon's process group elsewhere). It finds the process through `~/.patchright-cli/daemon-<port>.pid`, which the daemon writes at startup with its PID and start time, and kills only a process whose start time still matches, so a reused PID is never touched. A daemon from a version that writes no PID file has to be ended by hand: its command line contains `patchright_cli.daemon`.
215
+
216
+ ### Daemon client protocol
217
+
218
+ Third-party clients can use the daemon TCP interface directly. The
219
+ [client protocol reference](docs/daemon-protocol.md) defines discovery,
220
+ authentication, message framing, replies, and compatibility rules.
221
+
202
222
  ---
203
223
 
204
224
  <details>
@@ -285,6 +305,22 @@ patchright-cli upload ./file.pdf e5 # Upload to specific input
285
305
  patchright-cli resize 1920 1080 # Resize viewport
286
306
  ```
287
307
 
308
+ ### Emulation
309
+ ```bash
310
+ patchright-cli set-color-scheme dark # dark | light | no-preference
311
+ patchright-cli clear-color-scheme
312
+ patchright-cli set-reduced-motion reduce # reduce | no-preference
313
+ patchright-cli clear-reduced-motion
314
+ patchright-cli set-forced-colors active # active | none
315
+ patchright-cli clear-forced-colors
316
+ patchright-cli set-contrast more # more | no-preference
317
+ patchright-cli clear-contrast
318
+ patchright-cli set-media print # screen | print
319
+ patchright-cli clear-media
320
+ ```
321
+
322
+ Each setting holds for the whole session, including tabs and popups opened later; `clear-*` drops just that one, back to the browser default. A popup gets the setting just after it opens, so a script that reads media queries the instant the popup is created may still see the default.
323
+
288
324
  ### Tabs
289
325
  ```bash
290
326
  patchright-cli tab-list
@@ -372,6 +408,35 @@ patchright-cli console --clear # Clear after printing
372
408
  ```bash
373
409
  patchright-cli --raw eval --file=s.js # Raw output (no page/snapshot decoration)
374
410
  patchright-cli --raw snapshot > p.yml # Pipe raw snapshot to file
411
+ patchright-cli --json tab-list # Whole reply as JSON ({success, output, data, ...})
412
+ patchright-cli --toon tab-list # Structured result as TOON
413
+ ```
414
+
415
+ `--toon` prints a reply's structured `data` as [TOON](https://github.com/toon-format/spec), a compact
416
+ format for agents: `list`, `tab-list`, `cookie-list`, `localstorage-list`, `sessionstorage-list`,
417
+ `route-list`, `console`, `network`, `profile-list` and `find` give a table, `url` and `title` a single
418
+ field. A cut-short list adds `total` and a `help:` line. Commands without structured data, and errors,
419
+ print exactly as they do without the flag. `--json` and `--toon` together are a usage error.
420
+
421
+ ```
422
+ tabs[2]{index,title,url,active}:
423
+ 0,Example Domain,"https://example.com/",true
424
+ 1,"","about:blank",false
425
+ ```
426
+
427
+ Run with no arguments, `patchright-cli` prints a short home view instead of the manual (that is
428
+ `--help`): where the binary is, whether the daemon is running on the port (`--port=N` picks another),
429
+ the open sessions with their URL and tab count, and what to run next. It only asks a daemon that is
430
+ already running and never starts one. Add `--toon` or `--json` for the same state as data.
431
+
432
+ ```
433
+ ~/.local/bin/patchright-cli v0.10.0 -- anti-detect Chrome automation CLI (playwright-cli style commands)
434
+ daemon: running on port 9321 (1 session)
435
+ sessions[1]{name,status,url,tabs}:
436
+ default,open,"https://example.com/",2
437
+ help: patchright-cli snapshot (element refs for the current page; -s=<name> for another session)
438
+ help: patchright-cli list (sessions and their tabs)
439
+ help: patchright-cli --help (all commands); patchright-cli <command> --help (one command)
375
440
  ```
376
441
 
377
442
  ### Setup
@@ -386,7 +451,8 @@ patchright-cli -s=mysession click e6
386
451
  patchright-cli -s=mysession close
387
452
  patchright-cli list # List all sessions
388
453
  patchright-cli close-all
389
- patchright-cli kill-all
454
+ patchright-cli kill-all # Stop the daemon; force-stops it if it does not answer
455
+ patchright-cli kill-all --force # Kill the daemon and its browsers without asking
390
456
  patchright-cli delete-data # Delete the profile named after the session
391
457
  patchright-cli profile-list # Profiles, size, and which session uses each
392
458
  patchright-cli profile-delete <name> # Delete an idle named profile
@@ -399,10 +465,36 @@ patchright-cli --port=9322 open # Custom daemon port
399
465
 
400
466
  ## Agent Integration
401
467
 
402
- Works with Claude Code, Cursor, Gemini CLI, Codex, and [40+ other agents](https://github.com/vercel-labs/skills).
468
+ The CLI follows the [AXI](https://github.com/kunchenguid/axi) standard for agent-facing tools: errors and hints on stdout, exit 2 for usage errors, `(no-op)` for repeated actions, and a no-argument home view with live state.
469
+
470
+ There are two ways to teach your agent about patchright-cli. Both get it to the same place, so you only need one.
471
+
472
+ | | Session hook | Skill |
473
+ |---|---|---|
474
+ | Install | `patchright-cli install --hooks` | `npx skills add AhaiMk01/patchright-cli` or `patchright-cli install --skills` |
475
+ | What the agent gets | Live state (open sessions, the commands to drive them) at the start of every session | Full command reference, loaded when a browser task comes up |
476
+ | Cost | A few lines of context in every session | Nothing until it is needed |
477
+ | Agents | Claude Code, Codex, OpenCode | Claude Code, Cursor, Gemini CLI, Codex and [40+ others](https://github.com/vercel-labs/skills) |
478
+
479
+ ### Session hook (recommended)
480
+
481
+ ```bash
482
+ patchright-cli install --hooks # install or repair
483
+ patchright-cli install --hooks --uninstall # remove
484
+ ```
485
+
486
+ At the start of each session the agent runs `patchright-cli` with no arguments, which prints the home view (see [Output](#output)): whether the daemon is up and which sessions are open, so the agent can pick up an open browser session without asking. The hook goes only to apps whose config directory exists, and prints one line per app (`installed`, `updated`, `(no-op)` or `skipped`):
487
+
488
+ - **Claude Code**: a `SessionStart` hook in `~/.claude/settings.json`
489
+ - **Codex**: a `SessionStart` hook in `~/.codex/hooks.json`, plus `hooks = true` under `[features]` in `~/.codex/config.toml`
490
+ - **OpenCode**: a managed plugin at `~/.config/opencode/plugins/patchright-cli.js` that adds the dashboard to the system prompt
491
+
492
+ The hook calls plain `patchright-cli` when that name on your `PATH` is the same binary you ran the install with, and its absolute path otherwise. Re-run `install --hooks` after reinstalling or moving patchright-cli and it rewrites the path. Your other hooks and settings are left as they are, and `--uninstall` removes only patchright-cli's entries (the Codex `[features]` flag stays, since other hooks may need it).
493
+
494
+ ### Skill
403
495
 
404
496
  ```bash
405
- # Install skill for all detected agents (recommended)
497
+ # Install skill for all detected agents
406
498
  npx skills add AhaiMk01/patchright-cli
407
499
  ```
408
500
 
@@ -493,7 +585,7 @@ URLs passed to `patchright_open`, `patchright_goto` and `patchright_tab_new` mus
493
585
  <details>
494
586
  <summary><h2>Differences from playwright-cli</h2></summary>
495
587
 
496
- patchright-cli aims for full command parity with [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli). The following playwright-cli features are **intentionally not implemented** due to Patchright's architecture:
588
+ patchright-cli follows the command names and arguments of [Microsoft's playwright-cli](https://github.com/microsoft/playwright-cli) where Patchright allows it, but it is **not a drop-in replacement**. Some playwright-cli features cannot work on Patchright and are not implemented:
497
589
 
498
590
  | Feature | Reason |
499
591
  |---------|--------|
@@ -501,7 +593,7 @@ patchright-cli aims for full command parity with [Microsoft's playwright-cli](ht
501
593
  | `--extension` | Browser extension connection not supported. Patchright uses CDP directly. |
502
594
  | `install` / `install-browser` | Use `python -m patchright install chromium` instead. |
503
595
 
504
- All other commands and options are fully supported.
596
+ Each command accepts only the flags it implements. A playwright-cli flag patchright-cli does not support, such as `open --browser=firefox`, is rejected with `error: unknown flag` and exit code 2 rather than silently ignored, so a script ported from playwright-cli fails loudly where it would otherwise behave differently. `patchright-cli <command> --help` lists a command's flags.
505
597
 
506
598
  </details>
507
599
 
@@ -521,6 +613,8 @@ This project builds on the work of:
521
613
  - **[Patchright](https://github.com/Kaliiiiiiiiii-Vinyzu/patchright)** by [@Kaliiiiiiiiii-Vinyzu](https://github.com/Kaliiiiiiiiii-Vinyzu) — the undetected Playwright fork that makes this possible. All anti-detect capabilities come from Patchright.
522
614
  - **[playwright-cli](https://github.com/microsoft/playwright-cli)** by Microsoft — the original CLI that patchright-cli's command interface is modeled after.
523
615
  - **[camoufox-cli](https://github.com/Bin-Huang/camoufox-cli)** by [@Bin-Huang](https://github.com/Bin-Huang) — inspiration for the CLI-first approach to anti-detect browser automation and the SKILL.md agent integration pattern.
616
+ - **[AXI (Agent eXperience Interface)](https://github.com/kunchenguid/axi)** by [@kunchenguid](https://github.com/kunchenguid) — the standard for agent-facing CLIs that shaped the home view, strict per-command flags, `error:`/`help:` output, `(no-op)` replies, explicit empty states and the session-start hook.
617
+ - **[TOON](https://github.com/toon-format/spec)** — the token-oriented output format behind `--toon`.
524
618
 
525
619
  ---
526
620