pw-repl 0.4.1 → 0.5.0
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.
- package/AGENTS.md +7 -3
- package/README.md +90 -101
- package/bin/pw-repl.js +6 -5
- package/lib/background.js +41 -8
- package/lib/cli-names.js +1 -3
- package/lib/client.js +6 -1
- package/lib/commands.js +372 -41
- package/lib/help.js +30 -18
- package/lib/launch.js +97 -27
- package/lib/output.js +1 -1
- package/lib/runner.js +6 -3
- package/lib/send.js +9 -0
- package/lib/server.js +9 -2
- package/lib/skill.js +29 -0
- package/lib/start.js +15 -5
- package/lib/state.js +4 -1
- package/package.json +1 -1
- package/skill/SKILL.md +54 -20
package/skill/SKILL.md
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pw-repl
|
|
3
|
-
description: Inspect and drive a Chromium browser, possibly one a person is using, through the pw-repl (playwright-repl) REPL - tabs, page snapshots, clicks and typing, requests and their bodies, console messages, waiting for pages and elements, choosing files, faking, patching or delaying responses, cutting or slowing the network, emulating a phone, dark mode, a locale or a timezone, and recording what the person does. Use when asked to look at, debug or test something in a web page, in an existing Chromium with remote debugging or in one it starts itself.
|
|
4
|
-
allowed-tools: Bash(pw-repl:*) Bash(npx pw-repl:*)
|
|
3
|
+
description: Inspect and drive a Chromium browser, possibly one a person is using, through the pw-repl (playwright-repl) REPL - tabs, page snapshots, clicks and typing, the mouse at a point (moves, buttons, wheel), requests and their bodies, console messages, waiting for pages and elements, choosing files, faking, patching or delaying responses, cutting or slowing the network, emulating a phone, dark mode, a locale or a timezone, and recording what the person does. Use when asked to look at, debug or test something in a web page, in an existing Chromium with remote debugging or in one it starts itself.
|
|
4
|
+
allowed-tools: Bash(pw-repl:*) Bash(npx pw-repl@latest:*)
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# pw-repl
|
|
8
8
|
|
|
9
|
+
<!-- pw-repl skill stamp -->
|
|
10
|
+
|
|
9
11
|
pw-repl (playwright-repl) is a REPL that drives a running Chromium over CDP. The browser may be a
|
|
10
12
|
shared session: a person can have their own tabs open in it and be using it while you work.
|
|
11
13
|
|
|
12
|
-
`pw-repl` below is the command the `pw-repl` npm package installs. Without a global install,
|
|
13
|
-
`npx pw-repl`
|
|
14
|
+
`pw-repl` below is the command the `pw-repl` npm package installs. Without a global install, use
|
|
15
|
+
`npx pw-repl@latest` in its place, in that same form for every command, so each one runs the same
|
|
16
|
+
version; from a clone, `<clone>/bin/pw-repl.js`.
|
|
17
|
+
|
|
18
|
+
`pw-repl where` also names the skill of the pw-repl you run: `skill: e5f6a7b8 (pw-repl 0.4.3)`. When that
|
|
19
|
+
is not the skill named at the top of this file, tell the user before going on:
|
|
20
|
+
|
|
21
|
+
- if this file's pw-repl version is newer than that one, pw-repl is behind: say "⚠️ pw-repl is older
|
|
22
|
+
than this skill (pw-repl <that version>, skill from <this file's>); `npx pw-repl@latest` or
|
|
23
|
+
`npm install -g pw-repl` updates it."
|
|
24
|
+
- otherwise, the skill is: ask "⚠️ This pw-repl skill is out of date (from pw-repl <this file's
|
|
25
|
+
version>; <that version> has a newer one). Update it? Everything but its Custom rules section will be
|
|
26
|
+
replaced." On a yes, save what `pw-repl skill` prints over this file, with this file's Custom rules
|
|
27
|
+
section in place of the new one's.
|
|
14
28
|
|
|
15
29
|
## Arguments
|
|
16
30
|
|
|
@@ -20,17 +34,27 @@ the sections below are how to carry it out. With no args, get a REPL running and
|
|
|
20
34
|
|
|
21
35
|
## Start it
|
|
22
36
|
|
|
23
|
-
`pw-repl where` says whether a REPL is running and how `send` reaches it
|
|
24
|
-
|
|
37
|
+
`pw-repl where` says whether a REPL is running and how `send` reaches it, or that one is still starting
|
|
38
|
+
(retry shortly; it exits 64 until the REPL serves, as when none is running). Right after you start one,
|
|
39
|
+
for a moment before its process is up, it can still say none is there: retry for a few seconds before
|
|
40
|
+
taking that as a failed start. There are three ways to run one; each takes an optional start URL, which
|
|
41
|
+
opens in a new tab.
|
|
25
42
|
|
|
26
43
|
- `pw-repl serve --background` runs it detached, with a command server on `/tmp/playwright-repl.sock`
|
|
27
44
|
(owner-only) and its output in `/tmp/playwright-repl.log`. `pw-repl attach` shows everything it does
|
|
28
|
-
and takes commands; `pw-repl stop` stops it.
|
|
45
|
+
and takes commands; `pw-repl stop` stops it. It returns once the REPL serves; Ctrl-C before then gives
|
|
46
|
+
up on the start, stops the REPL, exits 130, and says so in the log.
|
|
29
47
|
- `pw-repl serve` runs the same in a terminal, where the pane shows every command. Its prompt is
|
|
30
|
-
`pw[serve]>`.
|
|
48
|
+
`pw[serve]>`. It stops at that prompt (`quit`, or Ctrl-C); `pw-repl stop` is for a background one.
|
|
31
49
|
- Add `--launch` to `run` or `serve` (with or without `--background`) to have it start a Chromium of its
|
|
32
|
-
own instead of connecting to one: headless unless `--headed`, in a temporary profile,
|
|
33
|
-
|
|
50
|
+
own instead of connecting to one: headless unless `--headed`, in a temporary profile, on a free port of
|
|
51
|
+
its own (never 9222). It stops with the REPL, Ctrl-C while it starts included, and `stop` returns once
|
|
52
|
+
it has exited. It prints the command it ran; flags after `--` are passed to that Chromium, and a
|
|
53
|
+
`--user-data-dir=<dir>` among them is used instead of the temporary profile, and kept. Started again in
|
|
54
|
+
a kept profile, Chromium picks up where it left off, as it would for a person, headless too: its tabs
|
|
55
|
+
come back, and session cookies with them, so a login stays. They start loading before the REPL is
|
|
56
|
+
attached, so `requests` and `console` have only what came after, often nothing: `reload` for a full
|
|
57
|
+
record.
|
|
34
58
|
- `pw-repl run` runs it in a terminal with no server; `send` then reaches it through tmux, if it runs in
|
|
35
59
|
the tmux session `playwright-repl`:
|
|
36
60
|
|
|
@@ -41,9 +65,11 @@ one; each takes an optional start URL, which opens in a new tab.
|
|
|
41
65
|
|
|
42
66
|
`serve` and `serve --background` take a socket path of your own instead of the default
|
|
43
67
|
(`pw-repl serve --background /tmp/mine.sock`); `send`, `attach`, `stop` and `where` then need
|
|
44
|
-
`-e /tmp/mine.sock`, or `PW_SOCKET=/tmp/mine.sock
|
|
45
|
-
|
|
46
|
-
|
|
68
|
+
`-e /tmp/mine.sock`, or `PW_SOCKET=/tmp/mine.sock`; a socket file left by a REPL that died is replaced
|
|
69
|
+
when the next one starts there. The log of a background REPL is next to its socket
|
|
70
|
+
(`/tmp/mine.log`), appended to run after run, with a line where each starts and stops (past 5 MB, a
|
|
71
|
+
start moves it to `/tmp/mine.log.1`); `tail -f` on it follows along without a terminal to attach from.
|
|
72
|
+
`serve <port>` listens on TCP 127.0.0.1 instead of a socket, with no access control.
|
|
47
73
|
|
|
48
74
|
### One REPL, many clients
|
|
49
75
|
|
|
@@ -70,11 +96,12 @@ pw-repl send tab
|
|
|
70
96
|
pw-repl send -t 90 'screenshot -d 60' # wait longer than the 20s default
|
|
71
97
|
```
|
|
72
98
|
|
|
73
|
-
Always send commands with `pw-repl send`; don't type into the pane yourself
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
99
|
+
Always send commands with `pw-repl send`; don't type into the pane yourself, except `quit` at the prompt
|
|
100
|
+
of a REPL of your own, which `send` refuses. The words after `send` are the command. For `fill`, `type`,
|
|
101
|
+
`select`, `press` and `upload`, a word quoted in your shell stays one word
|
|
102
|
+
(`pw-repl send fill "text=Your name" Ada`); other commands get the words as they are, joined by spaces
|
|
103
|
+
(`pw-repl send eval "document.title + ' x'"`). A command that takes only a selector takes the whole line,
|
|
104
|
+
spaces and all: `pw-repl send click "text=Your name"`. It works however the REPL was started:
|
|
78
105
|
|
|
79
106
|
- `run` (in tmux): `send` types the command into the tmux pane and reads the result back off the screen.
|
|
80
107
|
It types only when the pane's last line is a bare prompt, so nothing lands in a shell or in the middle
|
|
@@ -145,8 +172,10 @@ pw-repl send -c <name> close # your modes off; tab close
|
|
|
145
172
|
- The browser may have tabs that are not yours, and someone may be using it. Whether to read or act in
|
|
146
173
|
one of those tabs, or to open your own (`tab new <url>`), depends on the task; when that is not
|
|
147
174
|
clear, ask.
|
|
148
|
-
- No tab is selected when the REPL starts
|
|
149
|
-
|
|
175
|
+
- No tab is selected when the REPL starts. A start URL's tab, marked `(the start URL)` in `tab`, is
|
|
176
|
+
selected at its prompt and for `send` without a client name; a named client (`-c`) selects it with
|
|
177
|
+
`tab <index>`. Closing a tab the REPL opened goes back to the tab before it, if the REPL opened that
|
|
178
|
+
one too; otherwise no tab is selected.
|
|
150
179
|
Tab numbers change when tabs open or close; `tab <url-part>` and `tab close <url-part>` pick a tab by
|
|
151
180
|
its URL and refuse if it is ambiguous.
|
|
152
181
|
- Dialogs are never answered on their own. While one is open, its page and the commands that read it
|
|
@@ -155,6 +184,11 @@ pw-repl send -c <name> close # your modes off; tab close
|
|
|
155
184
|
lists what is on in every tab (the prompt shows the selected tab's, e.g. `(watch routes:1) pw>`);
|
|
156
185
|
`modes off` turns off every mode in every tab.
|
|
157
186
|
- Someone may be attached to the REPL's tmux session; killing the session ends it for them too.
|
|
187
|
+
- pw-repl does not record video. For one of a flow in a browser of its own, Microsoft's playwright-cli (a
|
|
188
|
+
separate tool, the npm package `@playwright/cli`: `video-start`, `video-stop`); for this browser as the
|
|
189
|
+
person sees it, a screen recorder (`ffmpeg -f x11grab`, macOS `screencapture -v`, OBS). A screen
|
|
190
|
+
recorder records their whole screen, not the tab: ask before starting one, or have them start it. A
|
|
191
|
+
headless browser is not on the screen, so it does not show.
|
|
158
192
|
|
|
159
193
|
## Environment
|
|
160
194
|
|