pw-repl 0.3.2 → 0.4.1

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,7 @@
1
1
  ---
2
2
  name: pw-repl
3
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:*)
4
5
  ---
5
6
 
6
7
  # pw-repl
@@ -44,10 +45,21 @@ one; each takes an optional start URL, which opens in a new tab.
44
45
  (`/tmp/mine.log`); `tail -f` on it follows along without a terminal to attach from. `serve <port>`
45
46
  listens on TCP 127.0.0.1 instead of a socket, with no access control.
46
47
 
47
- Several REPLs can run at once, each on its own socket, e.g. one per agent. Each has its own selected tab,
48
- command queue and modes, so they do not wait on or select for each other. They share the browser,
49
- though: each sees every tab, `modes` lists only its own REPL's modes, and two REPLs acting on the same
50
- tab can undo each other's routes, network or emulation settings.
48
+ ### One REPL, many clients
49
+
50
+ One REPL serves everyone using its browser: the person at its prompt and any number of agents. When
51
+ `pw-repl where` finds one running for the browser you need, use it rather than start another, as a
52
+ client of your own: `PW_CLIENT=<name>` (or `send -c <name>`), with a name that says who you are.
53
+
54
+ - A client has its own selected tab, so clients do not move each other's. Its commands show in the pane
55
+ as `[server:<name>]` lines.
56
+ - `modes` and `tab` say which client turned each mode on and opened each tab. `modes off --mine` turns
57
+ off only what you turned on; `tab close <url-part>` closes a tab you opened.
58
+ - Commands run one at a time, from every client: a long one (`capture on 60`, `sleep`) holds the rest.
59
+
60
+ A REPL of your own, on a socket of its own, is for a browser of your own (`--launch`), or when you are
61
+ asked for one. Several REPLs on one browser each see every tab but list only their own modes, and can
62
+ undo each other's routes, network or emulation settings.
51
63
 
52
64
  A REPL in a terminal stops at its prompt (`quit`, or Ctrl-C); `send quit` is refused.
53
65
 
@@ -82,7 +94,20 @@ that, look at the browser itself: `tab` and `info` for where things are, `reques
82
94
  clicks made (`body <#>` for what one returned), `console` for console messages and page errors. `watch
83
95
  on` records each step someone takes in a tab, with the requests it caused (`watch on --changes` adds
84
96
  what each step changed on the page); `watch` reads it back, and `watch new` only what it has not shown
85
- yet.
97
+ yet. For a tab they have not opened yet, `watch on --next-tab [url-part]` waits for it and watches it
98
+ from its first page.
99
+
100
+ When watching someone:
101
+
102
+ - A watched tab keeps response bodies of up to 100 KB, so `body <#>` still has them after the tab
103
+ navigates. Read a bigger one that matters as soon as it shows up in `requests`: the browser drops it
104
+ once the tab navigates.
105
+ - `watch` leaves out images and other static files, failed ones too; `console error` and
106
+ `requests --all` show what failed.
107
+ - Without a url-part, `--next-tab` takes the first tab anyone opens; check `tab` and `info` once it
108
+ fires, since another tab opening later does not show in `watch`.
109
+ - A watch belongs to the tab: when another client watches it too, read it with `watch <n>`, since
110
+ `watch new`'s place is shared and each one's would hide steps from the other.
86
111
 
87
112
  Exit status: `0` ok, `1` the command failed, `2` completion not confirmed (outcome unknown: do not
88
113
  blindly retry a change), `64` usage or the REPL is not reachable. `pw-repl --help` has the options.
@@ -91,7 +116,29 @@ blindly retry a change), `64` usage or the REPL is not reachable. `pw-repl --hel
91
116
 
92
117
  Run `pw-repl send help`. It lists six topics; `help <topic>` lists their commands, `help <command>`
93
118
  gives usage and caveats, and `help --all` prints everything at once. It needs no running REPL. The
94
- help is the command reference; this file does not repeat it.
119
+ help is the command reference; this file does not repeat it. If you know playwright-cli, its command
120
+ names work too (`help playwright-cli` lists them).
121
+
122
+ ### Coming from playwright-cli
123
+
124
+ Its command names and most of their options work, and each says the first time what it is here. What
125
+ differs comes from the browser being shared. With `<name>` a client name of your own, e.g. from your
126
+ task (`cart-bug`), since two agents with one name are one client:
127
+
128
+ ```bash
129
+ pw-repl send -c <name> open http://localhost:3000 # a tab of your own in the shared browser
130
+ pw-repl send -c <name> snapshot # no snapshot after each command; ask for one
131
+ pw-repl send -c <name> click e5
132
+ pw-repl send -c <name> close # your modes off; tab close <url-part> closes your tab
133
+ ```
134
+
135
+ - There is no browser of your own to open or close: `open` opens a tab in the one the REPL uses, and
136
+ `close` turns off the modes you turned on and leaves every tab open.
137
+ - Instead of `-s=<session>`, send as a client: `-c <name>`, with a selected tab of its own, in a browser
138
+ whose cookies and storage are shared.
139
+ - `upload <selector> <file>` names the file input or the button that opens it; do not click a file
140
+ input first, since the file picker is not caught.
141
+ - Routes, network and emulation apply to one tab, not to the whole browser.
95
142
 
96
143
  ## Sharing the browser
97
144
 
@@ -115,8 +162,9 @@ help is the command reference; this file does not repeat it.
115
162
  one works too (`--headless=new`); nobody answers its dialogs but `dialog`.
116
163
  - `PW_CHROME` — the Chromium `--launch` starts (default: Playwright's own, then one on the `PATH`).
117
164
  - `PW_CDP_URL` — CDP endpoint (default `http://localhost:9222`).
118
- - `PW_SCREENSHOT_DIR` — where the REPL saves screenshots (default `/tmp`), read when it starts, not by
119
- `send`. `screenshot` prints each file's path; other REPLs may save theirs there too. Remove only your
165
+ - `PW_SCREENSHOT_DIR` — where the REPL saves screenshots, read when it starts, not by `send`. Without it,
166
+ a REPL on a socket of its own saves them next to its socket, and any other in `/tmp`. `screenshot`
167
+ prints each file's path; other REPLs may save theirs in the same place. Remove only your
120
168
  own, and keep those too if they are needed, e.g. as evidence or as something to hand over.
121
169
  - `PW_ENDPOINT` / `PW_TMUX_SESSION` — defaults for `send -e` / `-s`. `PW_SOCKET` — the socket `send`
122
170
  looks for when neither is given (default `/tmp/playwright-repl.sock`).