pw-repl 0.3.1 → 0.4.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,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
 
@@ -59,9 +71,10 @@ pw-repl send -t 90 'screenshot -d 60' # wait longer than the 20s default
59
71
  ```
60
72
 
61
73
  Always send commands with `pw-repl send`; don't type into the pane yourself. The words after `send`
62
- are the command. For `fill`, `type`, `select` and `press`, a word quoted in your shell stays one word
63
- (`pw-repl send fill "text=Your name" Ada`); other commands get the words as they are
64
- (`pw-repl send eval "document.title + ' x'"`). It works however the REPL was started:
74
+ are the command. For `fill`, `type`, `select`, `press` and `upload`, a word quoted in your shell stays
75
+ one word (`pw-repl send fill "text=Your name" Ada`); other commands get the words as they are, joined by
76
+ spaces (`pw-repl send eval "document.title + ' x'"`). A command that takes only a selector takes the whole
77
+ line, spaces and all: `pw-repl send click "text=Your name"`. It works however the REPL was started:
65
78
 
66
79
  - `run` (in tmux): `send` types the command into the tmux pane and reads the result back off the screen.
67
80
  It types only when the pane's last line is a bare prompt, so nothing lands in a shell or in the middle
@@ -81,7 +94,19 @@ that, look at the browser itself: `tab` and `info` for where things are, `reques
81
94
  clicks made (`body <#>` for what one returned), `console` for console messages and page errors. `watch
82
95
  on` records each step someone takes in a tab, with the requests it caused (`watch on --changes` adds
83
96
  what each step changed on the page); `watch` reads it back, and `watch new` only what it has not shown
84
- 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
+ - Read `body <#>` for any request that matters as soon as it shows up: the browser drops a body once
103
+ its tab navigates.
104
+ - `watch` leaves out images and other static files, failed ones too; `console error` and
105
+ `requests --all` show what failed.
106
+ - Without a url-part, `--next-tab` takes the first tab anyone opens; check `tab` and `info` once it
107
+ fires, since another tab opening later does not show in `watch`.
108
+ - A watch belongs to the tab: when another client watches it too, read it with `watch <n>`, since
109
+ `watch new`'s place is shared and each one's would hide steps from the other.
85
110
 
86
111
  Exit status: `0` ok, `1` the command failed, `2` completion not confirmed (outcome unknown: do not
87
112
  blindly retry a change), `64` usage or the REPL is not reachable. `pw-repl --help` has the options.
@@ -90,7 +115,29 @@ blindly retry a change), `64` usage or the REPL is not reachable. `pw-repl --hel
90
115
 
91
116
  Run `pw-repl send help`. It lists six topics; `help <topic>` lists their commands, `help <command>`
92
117
  gives usage and caveats, and `help --all` prints everything at once. It needs no running REPL. The
93
- help is the command reference; this file does not repeat it.
118
+ help is the command reference; this file does not repeat it. If you know playwright-cli, its command
119
+ names work too (`help playwright-cli` lists them).
120
+
121
+ ### Coming from playwright-cli
122
+
123
+ Its command names and most of their options work, and each says the first time what it is here. What
124
+ differs comes from the browser being shared. With `<name>` a client name of your own, e.g. from your
125
+ task (`cart-bug`), since two agents with one name are one client:
126
+
127
+ ```bash
128
+ pw-repl send -c <name> open http://localhost:3000 # a tab of your own in the shared browser
129
+ pw-repl send -c <name> snapshot # no snapshot after each command; ask for one
130
+ pw-repl send -c <name> click e5
131
+ pw-repl send -c <name> close # your modes off; tab close <url-part> closes your tab
132
+ ```
133
+
134
+ - There is no browser of your own to open or close: `open` opens a tab in the one the REPL uses, and
135
+ `close` turns off the modes you turned on and leaves every tab open.
136
+ - Instead of `-s=<session>`, send as a client: `-c <name>`, with a selected tab of its own, in a browser
137
+ whose cookies and storage are shared.
138
+ - `upload <selector> <file>` names the file input or the button that opens it; do not click a file
139
+ input first, since the file picker is not caught.
140
+ - Routes, network and emulation apply to one tab, not to the whole browser.
94
141
 
95
142
  ## Sharing the browser
96
143
 
@@ -114,8 +161,10 @@ help is the command reference; this file does not repeat it.
114
161
  one works too (`--headless=new`); nobody answers its dialogs but `dialog`.
115
162
  - `PW_CHROME` — the Chromium `--launch` starts (default: Playwright's own, then one on the `PATH`).
116
163
  - `PW_CDP_URL` — CDP endpoint (default `http://localhost:9222`).
117
- - `PW_SCREENSHOT_DIR` — where screenshots go (default `/tmp`). They are all named `screenshot-*.png`,
118
- so `rm /tmp/screenshot-*.png` cleans up.
164
+ - `PW_SCREENSHOT_DIR` — where the REPL saves screenshots, read when it starts, not by `send`. Without it,
165
+ a REPL on a socket of its own saves them next to its socket, and any other in `/tmp`. `screenshot`
166
+ prints each file's path; other REPLs may save theirs in the same place. Remove only your
167
+ own, and keep those too if they are needed, e.g. as evidence or as something to hand over.
119
168
  - `PW_ENDPOINT` / `PW_TMUX_SESSION` — defaults for `send -e` / `-s`. `PW_SOCKET` — the socket `send`
120
169
  looks for when neither is given (default `/tmp/playwright-repl.sock`).
121
170