pw-repl 0.12.7 → 0.13.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/skill/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pw-repl
3
- description: Inspect and drive a Chromium browser, possibly one the user is using, through the pw-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, recording what the user does, profiling what makes a page slow (long tasks, forced layouts, input delay, dropped frames), and recording a video of a tab, with a pointer and on-screen captions. 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.
3
+ description: Inspect and drive a Chromium browser, possibly one the user is using, through the pw-repl REPL - tabs, page snapshots, clicks and typing, the mouse at a point (moves, buttons, wheel), requests and their bodies, console messages, what a page copied to the clipboard, 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, recording what the user does, profiling what makes a page slow (long tasks, forced layouts, input delay, dropped frames), and recording a video of a tab, with a pointer and on-screen captions. 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
4
  allowed-tools: Bash(pw-repl:*) Bash(npx pw-repl@latest:*)
5
5
  ---
6
6
 
@@ -43,7 +43,8 @@ and check the skill it names against the top of this file. It says whether a REP
43
43
  `send` reaches it, or that one is still starting (retry shortly; it exits 64 until the REPL serves, as
44
44
  when none is running). Right after you start one, for a moment before its process is up, it can still
45
45
  say none is there: retry for a few seconds before taking that as a failed start. There are three ways to
46
- run one; each takes an optional start URL, which opens in a new tab.
46
+ run one; each takes an optional start URL, which opens in a new tab (with `--launch`, in its browser's
47
+ first tab).
47
48
 
48
49
  - `pw-repl serve --background` runs it detached, with a command server on `/tmp/pw-repl.sock`
49
50
  (owner-only) and its output in `/tmp/pw-repl.log`. `pw-repl attach` shows everything it does and
@@ -52,14 +53,14 @@ run one; each takes an optional start URL, which opens in a new tab.
52
53
  - `pw-repl serve` runs the same in a terminal, where the pane shows every command. Its prompt is
53
54
  `pw[serve]>`. It stops at that prompt (`quit`, or Ctrl-C); `pw-repl stop` is for a background one.
54
55
  - Add `--launch` to `run` or `serve` (with or without `--background`) to have it start a Chromium of its
55
- own instead of connecting to one: headless unless `--headed`, in a temporary profile, on a free port
56
- of its own (never 9222). It stops with the REPL, Ctrl-C while it starts included, and `stop` returns
57
- once it has exited. It prints the command it ran; flags after `--` are passed to that Chromium (only
58
- flags: a start URL goes before `--`), and a `--user-data-dir=<dir>` among them is used instead of the
59
- temporary profile, and kept. Started again in a kept profile, Chromium picks up where it left off, as
60
- it would for the user, headless too: its tabs come back, and session cookies with them, so a login
61
- stays. They start loading before the REPL is attached, so `requests` and `console` have only what
62
- came after, often nothing: `reload` for a full record.
56
+ own instead of connecting to one: headless unless `--headed`, in a 1280x800 window, in a temporary
57
+ profile, on a free port of its own (never 9222). It stops with the REPL, Ctrl-C while it starts
58
+ included, and `stop` returns once it has exited. It prints the command it ran; flags after `--` are
59
+ passed to that Chromium (only flags: a start URL goes before `--`), and a `--user-data-dir=<dir>`
60
+ among them is used instead of the temporary profile, and kept. Started again in a kept profile,
61
+ Chromium picks up where it left off, as it would for the user, headless too: its tabs come back, and
62
+ session cookies with them, so a login stays. They start loading before the REPL is attached, so
63
+ `requests` and `console` have only what came after, often nothing: `reload` for a full record.
63
64
  - `pw-repl run` runs it in a terminal with no server; `send` then reaches it through tmux, if it runs in
64
65
  the tmux session `pw-repl`:
65
66
 
@@ -92,7 +93,7 @@ client of your own: `PW_CLIENT=<name>` (or `send -c <name>`), with a name that s
92
93
  as `[server:<name>]` lines.
93
94
  - `modes` and `tab` say which client turned each mode on and opened each tab. `modes off --mine` turns
94
95
  off only what you turned on; `tab close <url-part>` closes a tab you opened.
95
- - Commands run one at a time, from every client: a long one (`capture on 60`, `sleep`) holds the rest.
96
+ - Commands run one at a time, from every client: a long one (`capture on 60s`, `sleep`) holds the rest.
96
97
 
97
98
  A REPL of your own, on a socket of its own, is for a browser of your own (`--launch`), or when you are
98
99
  asked for one. Several REPLs on one browser each see every tab but list only their own modes, and can
@@ -104,16 +105,19 @@ A REPL in a terminal stops at its prompt (`quit`, or Ctrl-C); `send quit` is ref
104
105
 
105
106
  ```bash
106
107
  pw-repl send tab
107
- pw-repl send -t 90 'screenshot -d 60' # wait longer than the 20s default
108
+ pw-repl send -t 90s 'screenshot -d 60s' # wait longer than the 20s default
108
109
  ```
109
110
 
111
+ Times, in send's `-t` and in every command, are in milliseconds, as in Playwright, or in seconds with an
112
+ `s`: `-t 90000` or `-t 90s`.
113
+
110
114
  Always send commands with `pw-repl send`; don't type into the pane yourself, except `quit` at the prompt
111
115
  of a REPL of your own, which `send` refuses. The words after `send` are the command. For `fill`, `type`,
112
116
  `select`, `press`, `upload` and `wait`, a word quoted in your shell stays one word
113
117
  (`pw-repl send fill "text=Your name" Ada`, `pw-repl send wait text "Showing 1"`); other commands get the words as they are, joined by
114
118
  spaces (`pw-repl send eval "document.title + ' x'"`). A command that takes only a selector takes the
115
119
  whole line, spaces and all: `pw-repl send click "text=Your name"`. `send`'s own options (`-t`, `-c`, `-e`,
116
- `-s`, `--no-vars`) go before the command or after it (`pw-repl send open <url> -t 30`); after `--`, every
120
+ `-s`, `--no-vars`) go before the command or after it (`pw-repl send open <url> -t 30s`); after `--`, every
117
121
  word is the command's. It works however the REPL was started:
118
122
 
119
123
  - `run` (in tmux): `send` types the command into the tmux pane and reads the result back off the screen.
@@ -136,9 +140,10 @@ line, not in it; the REPL puts it in only as it runs the line, and its pane and
136
140
  written, so neither the file nor the line as logged holds the secret. Only `PW_` names are variables;
137
141
  any other `{{ ... }}` (a page's template text) is sent as written. One that is not set stops the file;
138
142
  `--no-vars` sends it as written. A single `send` takes them too: `PW_PASSWORD=... pw-repl send fill
139
- '#password' "{{ PW_PASSWORD }}"` types a password without it in the command. What reads it back can
140
- still show it: `snapshot`, `html` and `attrs` hide a password field's value, `eval` on the field does
141
- not.
143
+ '#password' "{{ PW_PASSWORD }}"` types a password without it in the command. Give the value without
144
+ typing it, from a file only you can read: `PW_PASSWORD="$(cat <file>)" pw-repl send ...`. What reads it
145
+ back can still show it: `snapshot`, `html` and `attrs` hide a password field's value, `eval` on the
146
+ field does not.
142
147
 
143
148
  `send` takes one command; chain several in your shell. Use `&&` when a step only makes sense if the one
144
149
  before it worked: it stops at any exit status but 0, a failure and an outcome not confirmed included.
@@ -161,40 +166,24 @@ background REPL (server commands as `[server]` lines), so whoever looks there se
161
166
  shows REPL commands only, not what was clicked in the browser (unless `watch on --live` is on); for
162
167
  that, look at the browser itself: `tab` and `info` for where things are, `requests` for the requests the
163
168
  clicks made (`body <#>` for what one returned), `console` for console messages and page errors.
164
- `watch on` records each step someone takes in a tab, with the requests it caused (`watch on --changes`
165
- adds what each step changed on the page); `watch` reads it back, and `watch new` only what it has not
166
- shown yet. For a tab they have not opened yet, `watch on --next-tab [url-part]` waits for it and
167
- watches it from its first page. `watch save <file>` writes the steps as commands that `send --file`
168
- runs again, a repro to keep. What is typed is recorded, except in password fields; `watch on
169
- --no-values` leaves it out. The file has a `{{ PW_PASSWORD }}` variable where a password was typed,
170
- set when it runs (`PW_PASSWORD=... pw-repl send --file login.txt`), so the file can be shared without
171
- it.
172
-
173
- When watching someone:
174
-
175
- - A watched tab keeps response bodies of up to 100 KB, so `body <#>` still has them after the tab
176
- navigates. Read a bigger one that matters as soon as it shows up in `requests`: the browser drops it
177
- once the tab navigates.
178
- - `watch` leaves out images and other static files, failed ones too; `console error` and
179
- `requests --all` show what failed.
180
- - Without a url-part, `--next-tab` takes the first tab anyone opens; check `tab` and `info` once it
181
- fires, since another tab opening later does not show in `watch`.
182
- - A watch belongs to the tab: when another client watches it too, read it with `watch <n>`, since
183
- `watch new`'s place is shared and each one's would hide steps from the other.
169
+ `watch on` records each step someone takes in a tab, with the requests it caused; `watch` reads it back,
170
+ and `watch save <file>` writes the steps as commands that `send --file` runs again, a repro to keep.
171
+ Before you watch someone, read `help watch`: what it keeps and leaves out, passwords, and sharing a watch
172
+ with another client.
184
173
 
185
174
  When a page is slow or feels laggy, `requests` shows a slow response; for what the page itself is busy
186
- with, `profile on` and `profile off` around what you do, or while the user uses it, sum up a performance
187
- trace of the tab: long tasks and the function behind each, forced layouts, each click's time to the next
188
- paint, and frames dropped while scrolling or dragging. `profile reload` profiles a load. `help profile`.
175
+ with, `profile on` and `profile off` around what you do, or while the user uses it (`help profile`).
189
176
 
190
177
  Exit status: `0` ok, `1` the command failed, `2` completion not confirmed (outcome unknown: do not
191
- blindly retry a change), `64` usage or the REPL is not reachable. `pw-repl --help` has the options.
178
+ blindly retry a change), `64` usage or the REPL is not reachable. `pw-repl --help` has the options, and
179
+ `pw-repl send --help` the rest of send's.
192
180
 
193
181
  ## Learn the commands
194
182
 
195
183
  Run `pw-repl send help`. It lists seven topics; `help <topic>` lists their commands, `help <command>`
196
- gives usage and caveats: read it before you use a command, since this file does not repeat them. `help
197
- --all` prints everything at once. pw-repl answers help itself: it needs no running REPL, and never
184
+ gives usage and caveats: read it before you use a command, since this file does not repeat them. When a
185
+ command fails or does something you did not expect, read its `help <command>` before working around it.
186
+ `help --all` prints everything at once. pw-repl answers help itself: it needs no running REPL, and never
198
187
  reaches one. If you know playwright-cli, its command names work too (`help playwright-cli` lists them).
199
188
 
200
189
  ### Coming from playwright-cli
@@ -210,8 +199,9 @@ pw-repl send -c <name> click e5
210
199
  pw-repl send -c <name> close # your modes off; tab close <url-part> closes yours
211
200
  ```
212
201
 
213
- - There is no browser of your own to open or close: `open` opens a tab in the one the REPL uses, and
214
- `close` turns off the modes you turned on and leaves every tab open.
202
+ - There is no browser of your own to open or close: `open` opens a new tab in the one the REPL uses,
203
+ each time, so use it once and `goto <url>` after that, which navigates the selected tab. `close` turns
204
+ off the modes you turned on and leaves every tab open.
215
205
  - Instead of `-s=<session>`, send as a client: `-c <name>`, with a selected tab of its own, in a browser
216
206
  whose cookies and storage are shared.
217
207
  - `upload <selector> <file>` names the file input or the button that opens it; do not click a file
@@ -240,6 +230,9 @@ pw-repl send -c <name> close # your modes off; tab close
240
230
  lists what is on in every tab (the prompt shows the selected tab's, e.g. `(watch routes:1) pw>`);
241
231
  `modes off` turns off every mode in every tab.
242
232
  - Someone may be attached to the REPL's tmux session; killing the session ends it for them too.
233
+ - What a page copied (a Copy button): click it, then `clipboard` prints it. In a headless browser
234
+ (`--launch`) that is the browser's own clipboard. In one with a window it is the user's, which may
235
+ hold a password, so `clipboard` refuses there without `--shared-clipboard`: ask the user first.
243
236
  - To point something out, to the user or in a screenshot, `highlight <ref|selector>` draws a box over it
244
237
  without changing the page (`--style=<css>` restyles it; `highlight off` hides them), without
245
238
  Playwright's locator label unless `highlight --labels on`.
@@ -262,6 +255,8 @@ pw-repl send -c <name> close # your modes off; tab close
262
255
  not by `send`. Without it, a REPL on a socket of its own saves them next to its socket, and any other
263
256
  in `/tmp`. `screenshot` prints each file's path; other REPLs may save theirs in the same place. Remove
264
257
  only your own, and keep those too if they are needed, e.g. as evidence or as something to hand over.
258
+ `close` (as a client, `-c <name>`) lists every file you wrote that is still there: screenshots,
259
+ videos, saved profiles and watches.
265
260
  - `PW_ENDPOINT` / `PW_TMUX_SESSION` — defaults for `send -e` / `-s`. `PW_SOCKET` — the socket `serve`
266
261
  serves on and `send` looks for when neither is given (default `/tmp/pw-repl.sock`).
267
262