screw-bugs 0.0.0-stage → 0.1.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.
Files changed (125) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +906 -2
  3. package/bin/screw-bugs.js +29 -0
  4. package/dist/browser-playwright/annotate.d.ts +9 -0
  5. package/dist/browser-playwright/annotate.js +86 -0
  6. package/dist/browser-playwright/capture.d.ts +232 -0
  7. package/dist/browser-playwright/capture.js +1049 -0
  8. package/dist/browser-playwright/frames.d.ts +77 -0
  9. package/dist/browser-playwright/frames.js +191 -0
  10. package/dist/browser-playwright/index.d.ts +2 -0
  11. package/dist/browser-playwright/index.js +2 -0
  12. package/dist/browser-playwright/input.d.ts +44 -0
  13. package/dist/browser-playwright/input.js +116 -0
  14. package/dist/browser-playwright/launch.d.ts +21 -0
  15. package/dist/browser-playwright/launch.js +86 -0
  16. package/dist/browser-playwright/page.d.ts +387 -0
  17. package/dist/browser-playwright/page.js +1930 -0
  18. package/dist/build-info.json +5 -0
  19. package/dist/cli/app.d.ts +19 -0
  20. package/dist/cli/app.js +70 -0
  21. package/dist/cli/build-info.d.ts +52 -0
  22. package/dist/cli/build-info.js +82 -0
  23. package/dist/cli/commands.d.ts +14 -0
  24. package/dist/cli/commands.js +308 -0
  25. package/dist/cli/config.d.ts +16 -0
  26. package/dist/cli/config.js +71 -0
  27. package/dist/cli/doctor.d.ts +19 -0
  28. package/dist/cli/doctor.js +113 -0
  29. package/dist/cli/environment.d.ts +20 -0
  30. package/dist/cli/environment.js +34 -0
  31. package/dist/cli/exit-codes.d.ts +29 -0
  32. package/dist/cli/exit-codes.js +28 -0
  33. package/dist/cli/failure.d.ts +20 -0
  34. package/dist/cli/failure.js +15 -0
  35. package/dist/cli/index.d.ts +6 -0
  36. package/dist/cli/index.js +6 -0
  37. package/dist/cli/install-method.d.ts +96 -0
  38. package/dist/cli/install-method.js +148 -0
  39. package/dist/cli/main.d.ts +1 -0
  40. package/dist/cli/main.js +10 -0
  41. package/dist/cli/mcp.d.ts +30 -0
  42. package/dist/cli/mcp.js +309 -0
  43. package/dist/cli/node-version.d.ts +3 -0
  44. package/dist/cli/node-version.js +22 -0
  45. package/dist/cli/operations.d.ts +127 -0
  46. package/dist/cli/operations.js +337 -0
  47. package/dist/cli/package-info.d.ts +22 -0
  48. package/dist/cli/package-info.js +25 -0
  49. package/dist/cli/report-server.d.ts +170 -0
  50. package/dist/cli/report-server.js +387 -0
  51. package/dist/cli/signals.d.ts +37 -0
  52. package/dist/cli/signals.js +61 -0
  53. package/dist/cli/stamp-build.d.ts +1 -0
  54. package/dist/cli/stamp-build.js +9 -0
  55. package/dist/cli/update-check.d.ts +140 -0
  56. package/dist/cli/update-check.js +316 -0
  57. package/dist/cli/uploads.d.ts +16 -0
  58. package/dist/cli/uploads.js +80 -0
  59. package/dist/core/css.d.ts +95 -0
  60. package/dist/core/css.js +436 -0
  61. package/dist/core/engine.d.ts +65 -0
  62. package/dist/core/engine.js +436 -0
  63. package/dist/core/errors.d.ts +66 -0
  64. package/dist/core/errors.js +30 -0
  65. package/dist/core/evidence.d.ts +14 -0
  66. package/dist/core/evidence.js +127 -0
  67. package/dist/core/index.d.ts +12 -0
  68. package/dist/core/index.js +12 -0
  69. package/dist/core/labels.d.ts +47 -0
  70. package/dist/core/labels.js +199 -0
  71. package/dist/core/liveness.d.ts +45 -0
  72. package/dist/core/liveness.js +64 -0
  73. package/dist/core/marks.d.ts +63 -0
  74. package/dist/core/marks.js +410 -0
  75. package/dist/core/services.d.ts +444 -0
  76. package/dist/core/services.js +22 -0
  77. package/dist/core/steps.d.ts +96 -0
  78. package/dist/core/steps.js +656 -0
  79. package/dist/core/uploads.d.ts +49 -0
  80. package/dist/core/uploads.js +133 -0
  81. package/dist/core/video.d.ts +16 -0
  82. package/dist/core/video.js +101 -0
  83. package/dist/core/viewport.d.ts +28 -0
  84. package/dist/core/viewport.js +50 -0
  85. package/dist/report/html.d.ts +37 -0
  86. package/dist/report/html.js +762 -0
  87. package/dist/report/index.d.ts +5 -0
  88. package/dist/report/index.js +5 -0
  89. package/dist/report/markup.d.ts +27 -0
  90. package/dist/report/markup.js +75 -0
  91. package/dist/report/pr-summary.d.ts +11 -0
  92. package/dist/report/pr-summary.js +110 -0
  93. package/dist/report/sha256.d.ts +9 -0
  94. package/dist/report/sha256.js +97 -0
  95. package/dist/report/styles.d.ts +1 -0
  96. package/dist/report/styles.js +328 -0
  97. package/dist/report/view.d.ts +141 -0
  98. package/dist/report/view.js +368 -0
  99. package/dist/report/walkthrough.d.ts +75 -0
  100. package/dist/report/walkthrough.js +458 -0
  101. package/dist/schema/config.d.ts +7 -0
  102. package/dist/schema/config.js +6 -0
  103. package/dist/schema/doctor.d.ts +46 -0
  104. package/dist/schema/doctor.js +23 -0
  105. package/dist/schema/evidence.d.ts +994 -0
  106. package/dist/schema/evidence.js +521 -0
  107. package/dist/schema/findings.d.ts +159 -0
  108. package/dist/schema/findings.js +80 -0
  109. package/dist/schema/index.d.ts +7 -0
  110. package/dist/schema/index.js +7 -0
  111. package/dist/schema/job.d.ts +1724 -0
  112. package/dist/schema/job.js +505 -0
  113. package/dist/schema/ledger.d.ts +951 -0
  114. package/dist/schema/ledger.js +193 -0
  115. package/dist/schema/status.d.ts +7 -0
  116. package/dist/schema/status.js +11 -0
  117. package/dist/store-local/accounts.d.ts +7 -0
  118. package/dist/store-local/accounts.js +9 -0
  119. package/dist/store-local/index.d.ts +3 -0
  120. package/dist/store-local/index.js +3 -0
  121. package/dist/store-local/paths.d.ts +10 -0
  122. package/dist/store-local/paths.js +17 -0
  123. package/dist/store-local/storage.d.ts +20 -0
  124. package/dist/store-local/storage.js +170 -0
  125. package/package.json +73 -4
package/README.md CHANGED
@@ -1,3 +1,907 @@
1
- # Temporary Holding Version
1
+ # screw-bugs
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local browser QA. Coding agents use it through its MCP server; people and CI use the CLI. MIT licensed.
4
+
5
+ screw-bugs has no AI of its own and never calls a model. Your coding agent (or you) decides what to
6
+ test and writes the cases as structured steps. screw-bugs runs them in a real headless browser,
7
+ saves screenshots, and reports a status for each case.
8
+
9
+ > **Status: early.** `doctor`, `init`, `run`, `status`, `report` and `runs` work. `answer`,
10
+ > `accounts`, `share` and `analytics on|off` exit with code 5 and say they are not implemented yet.
11
+
12
+ ## Requirements
13
+
14
+ Node.js 22.13 or newer, and Google Chrome or Microsoft Edge (or Playwright's Chromium). Check with:
15
+
16
+ ```sh
17
+ npx screw-bugs@latest doctor
18
+ ```
19
+
20
+ `doctor` installs nothing. It tells you what is missing, the command that fixes it and why.
21
+
22
+ Session videos need Playwright's ffmpeg. If `doctor` cannot find it, it warns (exit code stays 0)
23
+ and prints the command that downloads it, `npx -y playwright-core@<version> install ffmpeg`, pinned
24
+ to the Playwright that screw-bugs uses. Runs still work without it; they just have no video.
25
+
26
+ ## Use from a coding agent (MCP)
27
+
28
+ ```sh
29
+ claude mcp add screw-bugs -- npx -y screw-bugs@latest mcp
30
+ ```
31
+
32
+ Tools: `doctor`, `start_run` (returns a job ID right away; the run continues inside the MCP
33
+ server), `run_status`, `submit_findings`, `answer_question`. `start_run` takes the same job as a
34
+ `--spec` file, without `version`, and there `summary` is required. Upload paths are relative to the
35
+ project the MCP server runs in; the agent creates those files there with synthetic content (see
36
+ [Uploads](#uploads)), and when one is missing or unusable, `start_run` starts nothing and replies
37
+ with the files needed.
38
+
39
+ The loop has two passes. The agent plans: it submits cases, each with a plain `success` sentence
40
+ of what success looks like. screw-bugs runs them in a real browser, records a video, captures
41
+ screenshots and decides every status in code. Then the agent reads the evidence and writes it up
42
+ with `submit_findings`; screw-bugs checks the write-up against the run and re-renders the report.
43
+ Without a write-up the report still renders from the run alone.
44
+
45
+ `run_status` takes a `jobId` and an optional `waitSeconds` (0–60, default 0): if the run is still
46
+ queued or running, it waits up to that long for the run to end before replying. It rereads the
47
+ ledger, so it also works for runs started by another process. Once the run has ended, its reply is
48
+ the counts, then a compact evidence pack: two lines per case (cases that did not pass first), the
49
+ status and reason, then the deciding step and when it ran, the screenshot IDs, the timecodes (ms
50
+ into the session video) a write-up may use, where the page was, HTTP errors, the visible text
51
+ near where the case stopped, the start of the first visible frame's text (`frame "…"`, such as
52
+ an `<iframe>` preview) and how many images and links the page showed (`4 images, 6 links in
53
+ evidence.json`). Then the paths:
54
+
55
+ ```text
56
+ Job 20261029-104857-3f9a01c2 is finished: 1 passed, 1 failed, 0 blocked, 0 not verified.
57
+ - blog-link (failed): Step 2 (click link "Blog"): The page it opened returned HTTP 404.
58
+ step 2 at 5400 ms; shots 02-01 02-02; timecodes 5000 5100 5400 6300; url http://localhost:3000/blog; http 404 http://localhost:3000/blog; text "Not found"
59
+ - home (passed)
60
+ shots 01-01; timecodes 0 120 4900
61
+ /path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2
62
+ /path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2/ledger.json
63
+ /path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2/evidence.json
64
+ /path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2/video/session-1.webm
65
+ /path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2/report.html
66
+ http://127.0.0.1:41234/20261029-104857-3f9a01c2/report.html
67
+ /path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2/walkthrough.html
68
+ http://127.0.0.1:41234/20261029-104857-3f9a01c2/walkthrough.html
69
+ ```
70
+
71
+ Each reason is cut to 150 characters and every field is capped; at most 10 cases are listed, then
72
+ `- and N more; see evidence.json.` A video that is missing or incomplete gets a line saying why.
73
+ `evidence.json` has the whole pack. The report path comes once the run has ended and its report
74
+ exists (see [Report](#report)), followed by its URL on the MCP server's local report server (see
75
+ [Viewing reports](#viewing-reports)); then the [walkthrough](#walkthrough) and its URL, when the run
76
+ has one. `submit_findings` gives them too.
77
+
78
+ ### Findings
79
+
80
+ `submit_findings` (CLI: `screw-bugs findings <job-id> <file|->`) takes the agent's write-up, in
81
+ fixed slots with short texts:
82
+
83
+ ```json
84
+ {
85
+ "headline": "Signing in works, but a wrong password gets no error.",
86
+ "fixes": [
87
+ {
88
+ "title": "Show an error for a wrong password",
89
+ "severity": "high",
90
+ "caseIds": ["wrong-password"],
91
+ "why": "Users are left on the form with no idea what happened."
92
+ }
93
+ ],
94
+ "cases": [
95
+ {
96
+ "id": "wrong-password",
97
+ "did": ["Signed in with a wrong password."],
98
+ "worked": ["The form stayed filled in."],
99
+ "didnt": ["No error message appeared."],
100
+ "highlights": [
101
+ {
102
+ "shot": "02-02",
103
+ "target": { "label": "Password" },
104
+ "mark": "red",
105
+ "note": "No error here"
106
+ }
107
+ ],
108
+ "keyMoments": [{ "ms": 5400, "label": "Sign in pressed" }],
109
+ "observed": ["The button stays enabled while signing in."]
110
+ }
111
+ ],
112
+ "notTested": [{ "what": "Password reset", "why": "The test inbox was not available." }],
113
+ "nextTests": ["A locked account"]
114
+ }
115
+ ```
116
+
117
+ Case IDs, screenshot IDs and timecodes must be ones `run_status` gave for that case; findings that
118
+ do not fit are rejected with one line per problem saying what to change (exit code 6), and nothing
119
+ is saved. Findings cannot set a status. A highlight names an element like a step `target`; code
120
+ finds it in the page state saved with that screenshot and draws the box: red for a problem, green
121
+ for what is as expected. One it cannot place unambiguously is reported in words, never guessed;
122
+ so is one on a page with more elements than were saved with the screenshot, unless none of those
123
+ could match it too.
124
+ A highlight takes the targets a step takes: `role` (with `name`), `text`, `label`, `alt` and
125
+ `css`, with `frame`. Since the browser is gone by then, CSS is matched against what was saved with
126
+ the screenshot: each element's tag, ID, classes and attributes (at most 12, values cut to 120
127
+ characters; never `style`, event handlers or `value`), and the elements it is in. So tags, `*`,
128
+ `#id`, `.class`, attribute selectors with every operator and the `i` flag
129
+ (`iframe[data-test="preview"]`, `a[href*="linkedin.com/in/" i]`), `:not()`, lists (`a, button`)
130
+ and the descendant and child combinators (`.clients img`, `footer > a`) work, for elements and for
131
+ frames, including the frame selectors that hints suggest (`iframe[title='Inner box']`). Values are
132
+ compared as Chromium does: ignoring ASCII case for the attributes HTML lists as case-insensitive
133
+ (such as `type`, `lang`, `rel` and `target`) on HTML elements, and with the `i` flag (ASCII letters
134
+ only); otherwise exactly, or with the `s` flag (which Chromium itself does not take, so a step
135
+ cannot use it). Whatever was not saved whole is never guessed at: a selector whose result depends
136
+ on a value cut at 120 characters (such as `[data-x$="…"]`), on an attribute that was not saved
137
+ (such as `style`, or past the first 12), on a class past the first 8 (as in `:not(.ghost)`) or on
138
+ an enclosing element that was not saved is refused in words, as one that matches nothing is not. What needs
139
+ more than that, such as `:nth-child()`, `:hover`, the `+` and `~` combinators or Playwright's `>>`,
140
+ is refused in words naming the highlight, such as
141
+ `02-03 css "li:nth-child(2)": the CSS selector uses ":nth-child(2)", which cannot be checked
142
+ against the page state saved with the screenshot; …`. Name such an element by role, text, label
143
+ or alt instead. An element inside an `<iframe>` is named with `frame`, as in a step
144
+ (`{ "frame": { "css": "iframe.preview" }, "text": "Hi, I'm Nadia" }`): the frame is found among
145
+ the frames visible on that screenshot, the element among that frame's elements, and its box is cut
146
+ to the part of the frame that shows. A highlight without `frame` names an element of the page
147
+ itself; when it is only inside a frame, the reply says to name the frame. A highlight is drawn
148
+ only on what the screenshot shows: an element that was in the page or frame but not visible when
149
+ it was taken (transparent, such as a section that had not faded in yet, or cut away by its box or
150
+ by its frame) gets no box and says why; and when another match is on the screenshot, matches
151
+ outside it (a copy far below a viewport screenshot, or outside the part of its frame that shows)
152
+ or not visible are left out, and the legend says how many. `notTested` lists what the run did not
153
+ cover and why; the report shows it next to the counts, and a run whose cases all passed then reads
154
+ "7 of 7 cases passed · 3 areas not tested" rather than "All 7 cases passed". `observed` lines are
155
+ shown as "observed, not checked by a step". The findings go to `findings.json`; screenshots with
156
+ highlights get a copy with the boxes drawn in, under `annotated/` (named for that write-up, so a
157
+ copy drawn for an earlier one is never shown), and the report is written again, so it shows the
158
+ write-up, labelled as the agent's.
159
+
160
+ Limits (each text is one line, not blank; findings past them are rejected with what to change):
161
+
162
+ | Field | Limit |
163
+ | ----------------------------------- | ---------------------------------------------------------------- |
164
+ | `headline` | 160 characters |
165
+ | `fixes` | at most 10; `title` 120 characters, `why` 240, `caseIds` 1 to 10 |
166
+ | `cases` | at most 100 |
167
+ | `did`, `worked`, `didnt` (per case) | at most 8 lines each, 160 characters a line |
168
+ | `highlights` (per case) | at most 6; `note` 120 characters |
169
+ | `keyMoments` (per case) | at most 8; `label` 80 characters |
170
+ | `observed` (per case) | at most 5 lines, 200 characters a line |
171
+ | `notTested` | at most 8; `what` 100 characters, `why` 160 |
172
+ | `nextTests` | at most 8 lines, 200 characters a line |
173
+
174
+ ## Jobs, cases and steps
175
+
176
+ ```json
177
+ {
178
+ "version": 1,
179
+ "url": "http://localhost:3000",
180
+ "instructions": "check that login still works after my refactor",
181
+ "summary": "Signing in with a test account still reaches the dashboard and greets the user.",
182
+ "cases": [
183
+ {
184
+ "id": "login-works",
185
+ "title": "Signing in reaches the dashboard",
186
+ "steps": [
187
+ { "action": "goto", "url": "/login" },
188
+ { "action": "fill", "target": { "label": "Email" }, "value": "test@example.com" },
189
+ { "action": "click", "target": { "role": "button", "name": "Sign in" } },
190
+ { "action": "expectUrl", "includes": "/dashboard" },
191
+ { "action": "expectText", "text": "Welcome" },
192
+ { "action": "screenshot", "name": "dashboard" }
193
+ ]
194
+ }
195
+ ]
196
+ }
197
+ ```
198
+
199
+ Two optional free-text fields describe a job. screw-bugs saves both in `job.json` and shows them in
200
+ `status` and the report, but never reads or interprets them: only `cases` decide what runs.
201
+
202
+ - `instructions`: what the user asked for, in their own words (verbatim when possible). Provenance.
203
+ - `summary`: what these cases test and why, written by whoever wrote the cases, for a reader who
204
+ never sees the steps. Not a list of steps. Without one, screw-bugs derives a summary from the case
205
+ titles, such as `Checks: page loads; signup with a valid email`.
206
+
207
+ With `run`, `--instructions <text>` and `--summary <text>` override the same fields in a `--spec`
208
+ file.
209
+
210
+ `device` is optional: `desktop` (the default, a 1280×800 window) or `mobile`, which emulates an
211
+ iPhone 17 (Playwright's profile: viewport, user agent, pixel ratio and touch). screw-bugs only
212
+ launches Chrome, Edge or Playwright's Chromium, never WebKit, so mobile pages are still rendered by
213
+ Chromium: this catches responsive layout and touch problems, not Safari-only bugs. With `run`,
214
+ `--device desktop|mobile` overrides the value in a `--spec` file.
215
+
216
+ | Step | Fields | What it does |
217
+ | -------------- | ------------------------------------- | --------------------------------------------------------------- |
218
+ | `goto` | `url` | Open a URL; paths resolve against the job URL. HTTP 400+ fails. |
219
+ | `reload` | | Reload the page; judged like `goto` |
220
+ | `click` | `target` | Click an element; a page it opens with HTTP 400+ fails |
221
+ | `fill` | `target`, `value` | Replace the value of an input |
222
+ | `upload` | `target`, `files` | Choose files for a file input (see [Uploads](#uploads)) |
223
+ | `press` | `key` | Press a key, such as `Enter`; a page it opens with 400+ fails |
224
+ | `expectText` | `text`, `frame`? | Expect the text to become visible (case-insensitive substring) |
225
+ | `expectNoText` | `text`, `frame`? or `target`? | Expect the text not to show, as text, alt text or label |
226
+ | `expectUrl` | `includes` | Expect the page URL to contain this |
227
+ | `expectLink` | `target`, `href`, `match`? | Expect a link to go to an address, without following it |
228
+ | `waitFor` | `target`, `state`? | Wait until the target is visible, hidden, attached or detached |
229
+ | `scroll` | one of `target`, `to`, `by`; `frame`? | Scroll, then screenshot the view |
230
+ | `screenshot` | `name` | Save a full-page screenshot as evidence |
231
+
232
+ Every step that waits (all but `screenshot`) takes an optional `timeoutMs`, from 100 to 180000
233
+ (three minutes): how long to wait for its element, text, URL, state or frame (default 5000), or
234
+ for the page it loads (`goto`, `reload`, `press`; default 15000). A page that a `click`, `fill`, `upload` or an
235
+ expectation starts loading gets at least the default 15 seconds, or the step's `timeoutMs` when
236
+ that is longer. Use it for slow work, such as generation that takes a minute:
237
+ `{ "action": "expectText", "text": "Your portfolio is ready", "timeoutMs": 120000 }`. A failed
238
+ expectation says how long it waited (`did not appear within 5 s`), and the report shows a timeout
239
+ that is not the default next to its step (`waited up to 120 s`).
240
+
241
+ ### Waiting and scrolling
242
+
243
+ `waitFor` waits until its target reaches `state`: `visible` (the default; a match is visible),
244
+ `hidden` (none is), `attached` (a match is in the page, seen or not) or `detached` (none is). Use
245
+ it for work that ends without a message, such as a preview that restyles after a template switch:
246
+
247
+ ```json
248
+ { "action": "waitFor", "target": { "css": "iframe.preview--restyling" }, "state": "detached" }
249
+ ```
250
+
251
+ It is an expectation: not reaching the state in time fails the case, such as
252
+ `An element matching css "iframe.preview--restyling" was still in the page after 5 s.` A
253
+ screenshot follows, with the target's box for `visible` and `attached`.
254
+
255
+ `scroll` takes exactly one of `target` (scroll that element into view, in its frame too), `to`
256
+ (`"top"` or `"bottom"`) or `by` (CSS pixels down, negative for up; at most 20000 either way); with
257
+ `to` or `by`, `frame` scrolls that frame's document instead of the page:
258
+ `{ "action": "scroll", "frame": { "css": "iframe.preview" }, "to": "bottom" }`. A screenshot of
259
+ what is in view follows, so content below the first screen, in the page or in a frame, shows up
260
+ in the evidence. A target that is not found blocks the case. Pages that scroll an inner box of
261
+ their own rather than the document need a `target` in that box.
262
+
263
+ ### Checking that something is not there
264
+
265
+ `expectNoText` passes when its text does not show: not as visible text, not as the alt text of an
266
+ image (an `<img>`'s `alt`, an `<svg>` logo's label) and not as an ARIA label. So sample content
267
+ that is only images, such as client logos, fails it as it should:
268
+
269
+ ```json
270
+ { "action": "expectNoText", "text": "Acme" }
271
+ ```
272
+
273
+ Without `frame` or `target`, it looks at the page and at every frame visible in it, as a person
274
+ sees the page; with `frame`, in that frame's document and the frames inside it; with `target`,
275
+ inside that element (itself included, so its own `aria-label` or `alt` counts) and the frames
276
+ inside it (give a frame in the target itself). What is not seen does not count: hidden, without
277
+ a size, or almost transparent (opacity below 0.1, with what is around it and its frame). It does
278
+ not pass just because the page has not rendered yet: it first waits until there is something to
279
+ look at (any visible text or image; an `<iframe>` counts only by what it shows) and every frame
280
+ where it looks shows something, up to its `timeoutMs` (default 5000), and then watches for 1
281
+ second, so text that shows a moment late still counts. It passes only when every look in that
282
+ second read everything it had to. The reason says where it was found:
283
+
284
+ ```text
285
+ Step 3 (expectNoText "Acme"): "Acme" is on the page (image alt "Acme logo" in .clients).
286
+ Step 4 (expectNoText "Hooli"): "Hooli" is on the page, in iframe css "iframe.preview" (image alt "Hooli").
287
+ ```
288
+
289
+ A page (or frame, or target) that shows nothing at all within the wait blocks the case
290
+ (`Nothing showed on the page within 5 s, so there was nothing to look for "Acme" in.`), and so does
291
+ a target that is not there. Every visible frame where it looks is read, whatever its size. Only
292
+ what happens when a frame cannot be judged depends on it, and on what the frame holds:
293
+
294
+ - A frame smaller than 16×16 CSS pixels in both directions where it shows (a 1×1 tracking pixel)
295
+ that cannot be read or stays empty blocks nothing: it cannot show text a person can read. Text
296
+ it does show is still found.
297
+ - A frame that stays empty and is tiny, or is a blank `about:blank` frame nothing was loaded into
298
+ (a placeholder a script may fill), is watched for the whole `timeoutMs` rather than 1 second:
299
+ text that appears in it at any point then fails the case; if it stays empty, the case passes.
300
+
301
+ Shadow roots (custom elements, web components) are read as they render, slotted content included,
302
+ for text, alt text, labels and the frames inside them; opacity and clipping follow what renders
303
+ where (a slot, a host), not only the markup. Open roots are read like the rest of the page.
304
+ Closed ones, which no page script can reach, are found and read through the browser's DevTools
305
+ protocol (CDP), with the same rules, in every process the documents where it looks run in (a frame
306
+ of another site may have its own); when one of those cannot be reached, the case is blocked. They
307
+ are looked for as the 1-second watch starts and as it ends, and when a document where it looks
308
+ shows nothing else (so a frame whose only content is in a closed root is ready). Once a check has
309
+ found any where it looks, it reads them on every look, so text that shows in one for a moment
310
+ still counts; a page with none pays nothing more. One read lists the whole page: about 15 ms for
311
+ 2,000 nodes, 80 ms for 10,000 and 300–500 ms for 50,000, plus about 1 ms per closed root. When
312
+ reading them on every look takes more than 1 second, they cannot be watched closely, and the case
313
+ is blocked. CDP's answers are checked like any other outside input; one that does not fit blocks
314
+ the case. screw-bugs only drives Chromium-based browsers, which all have CDP; without it, closed
315
+ roots would not be read. A closed root that cannot be read blocks the
316
+ case. An absence is never
317
+ told from a look that did not see everything: when, by the end of the wait, any other frame where
318
+ it looks showed nothing (such as one still loading its page) or could not be read, where it looks
319
+ shows more than 20 frames (for a check with `frame` or `target`, frames elsewhere on the page are
320
+ neither counted nor read), or a document holds more than it reads (200,000 elements and text nodes, 20,000 images
321
+ and labelled elements), the case is blocked and the reason says what was missed, such as
322
+ `Not everything could be looked at (the frame iframe css "iframe.preview" showed nothing within 5 s), so it cannot be told that "Acme" is not there.` A screenshot of what is in view follows a pass. Check after the page
323
+ has done its work, such as after an `expectText` for its success message, and in a case that
324
+ continues from the one that made it (see [Continuing a case](#continuing-a-case)).
325
+
326
+ ### Images and links
327
+
328
+ Logos and icons are often images with no text of their own, so text targets never find them. A
329
+ `target` finds an image by its alternative text with `alt`: the `alt` of an `<img>` (or an
330
+ `<area>` or image button), or the ARIA label of an element with role `img`, such as an `<svg>`
331
+ logo (case-insensitive substring, like `text`):
332
+
333
+ ```json
334
+ { "action": "waitFor", "target": { "alt": "Acme logo" } }
335
+ ```
336
+
337
+ `expectLink` checks where a link goes without following it. Its target is the link, or an element
338
+ inside one (such as a logo in a link); `href` is what its absolute address must contain, or with
339
+ `"match": "exact"`, what it must be (a path such as `/about` is resolved against the page URL):
340
+
341
+ ```json
342
+ {
343
+ "action": "expectLink",
344
+ "target": { "role": "link", "name": "LinkedIn" },
345
+ "href": "linkedin.com/in/"
346
+ }
347
+ ```
348
+
349
+ A link elsewhere fails the case with where it goes
350
+ (`The link goes to https://twitter.com/ada, which does not contain "linkedin.com/in/".`), and so
351
+ does an element that is not a link, or none at all within the step's wait. A screenshot with the
352
+ link's box follows when it passes. It takes `frame` in its target, as every target does.
353
+
354
+ What a run saves says what images and links a page shows. Each screenshot's page state has, for
355
+ images, their alt text (`alt`) and source (`src`; a `data:` URL is cut to its type, such as
356
+ `data:image/png;base64,…`), and for links their absolute address (`href`); their boxes give their
357
+ size. Every case's page facts (in the ledger and `evidence.json`) list the images visible in the
358
+ page and in each visible frame when it ended, with alt text, source and size in CSS pixels, and
359
+ the links, with text and address: at most 12 of each, addresses cut to 300 characters. Decorative
360
+ images, with an empty `alt`, are left out. The evidence pack names each screenshot's page state
361
+ file (`page`).
362
+
363
+ ### Frames
364
+
365
+ Pages often show content in an `<iframe>`, such as a generated portfolio's preview. A `target`
366
+ reaches into one with `frame`, itself found like a target (the first visible match is used):
367
+
368
+ ```json
369
+ { "action": "click", "target": { "frame": { "css": "iframe.preview" }, "text": "Contact" } }
370
+ ```
371
+
372
+ For frames inside frames, `frame` is a list, outermost first (at most 4). `expectText` takes
373
+ `frame` too, to look for its text in that frame's document. Same- and cross-origin frames both
374
+ work. Reasons and reports name the frame: `click text "Contact" in iframe css "iframe.preview"`.
375
+ Text inside a frame is never found without `frame`, as in the browser, where the page's own
376
+ document does not hold it.
377
+
378
+ When a step did not find its text or element, and it is in a visible frame the step did not
379
+ name (or, for a step with `frame`, in the page itself or in another frame), the reason says what
380
+ to change, in the form a step takes it:
381
+
382
+ ```text
383
+ Step 4 (expectText "Get in touch"): Not found within 5 s; it is in an iframe: add "frame":{"css":"iframe[title='Portfolio preview']"}.
384
+ ```
385
+
386
+ The frame is named as a person would: by its ID, test ID, name, title or ARIA label, else by a
387
+ class, as a selector that matches only it; up to 2 are named when several hold it. This is looked
388
+ for only after the step's own wait is over, for at most a second, so passing runs never pay for
389
+ it. A reason with a hint fits within the 150 characters `run_status` shows, so it is never cut:
390
+ the step's message is shortened first.
391
+
392
+ Screenshots save the elements of the frames that show on them, judged as the page's own are: an
393
+ element is not visible when it is almost transparent with its `<iframe>` and what is around that,
394
+ or in a part of the frame that a box around the `<iframe>` cuts away. The scroll-through before a
395
+ full-page screenshot scrolls only the page, so frames it brings into view get to show what they
396
+ show once scrolled to, and a frame stays where a `scroll` step left it.
397
+
398
+ ### Uploads
399
+
400
+ ```json
401
+ {
402
+ "action": "upload",
403
+ "target": { "role": "button", "name": "Upload résumé" },
404
+ "files": [
405
+ {
406
+ "path": "fixtures/resume.pdf",
407
+ "about": "A 2-page PDF résumé of a fictional product designer: name, 3 jobs, 3 projects"
408
+ },
409
+ "fixtures/photo.png"
410
+ ],
411
+ "timeoutMs": 10000
412
+ }
413
+ ```
414
+
415
+ `files` holds 1 to 10 files, each a path or `{ "path", "about", "allowMismatch" }`. Paths are relative to the project
416
+ (the folder with `screw-bugs.json`, where `run` or the MCP server runs); absolute paths and `..`
417
+ are rejected. `about` is one plain sentence (at most 200 characters) of what the file holds, shown
418
+ next to the step in the report and in the reply that asks for a missing file; never interpreted.
419
+
420
+ screw-bugs never makes these files: whoever writes the cases creates them in the project, such as
421
+ in `fixtures/`, with synthetic test content and no real personal data. **The files are sent to the
422
+ site under test.** Before anything starts, every file is checked: it must exist inside the project
423
+ (a link that resolves outside it is refused), be a file, not be empty, be at most 50 MB, and have
424
+ content that matches its extension, by its first and last bytes: `%PDF-` and `%%EOF` for `.pdf`,
425
+ the PNG signature and end chunk for `.png`, JPEG, GIF and WebP signatures, a ZIP archive for
426
+ `.docx`, `.pptx` and `.xlsx`, and valid UTF-8 text without NUL bytes for `.txt`, `.csv`, `.json`
427
+ and `.md`. Files of other types are checked for existence and size only.
428
+
429
+ To test how a site handles an invalid file on purpose, such as a text file named `.pdf`, give it as
430
+ an object with `"allowMismatch": true`: `{ "path": "fixtures/not-a-resume.pdf", "allowMismatch":
431
+ true }`. Only the content check is skipped: the file must still exist inside the project, not be
432
+ empty and be at most 50 MB. The report says `type check skipped on purpose` next to it. When one
433
+ step sends a file without the check and another with it, the check applies.
434
+
435
+ When any file does not do, nothing starts, and the reply lists the files needed (`run` exits with
436
+ code 7):
437
+
438
+ ```text
439
+ Nothing was started: 1 upload file is missing or unusable.
440
+ - fixtures/resume.pdf (PDF): missing. About: A 2-page PDF résumé of a fictional product designer: name, 3 jobs, 3 projects
441
+ Create it at that path in the project with synthetic test content (no real personal data), then start the run again.
442
+ /path/to/project
443
+ ```
444
+
445
+ Each `about` is shown whole, on one line. A file with `allowMismatch` is listed as
446
+ `- fixtures/not-a-resume.pdf (PDF, type check skipped on purpose): missing`. Other reasons are
447
+ `a folder, not a file`, `empty`, `too big (63.0 MB; at most 50 MB)`,
448
+ `not really a PDF; its content does not match its extension`, `outside the project (it links to a
449
+ file elsewhere)` and `could not be read`. With `--json`, the error also has `projectRoot` and
450
+ `files`: one `{ path, type, about?, allowMismatch?, problem, reason }` each, where `problem` is one of `missing`,
451
+ `not_a_file`, `empty`, `too_big`, `wrong_type`, `outside_project` and `unreadable`.
452
+
453
+ The target is the file input itself, or the control that opens the file chooser. A file input that
454
+ the target matches, or one inside it, gets the files directly, even when it is hidden (styled
455
+ dropzones usually hide theirs); otherwise the target is clicked and the files are set on the file
456
+ chooser it opens. With neither within the step's wait, the case is blocked
457
+ (`No file input or file chooser for label "Upload" within 5 s.`), and so it is when a single-file
458
+ input or chooser is given more than one file. A screenshot after the upload shows the target, the
459
+ ledger records each file's name and size (never its contents) with the step, and the evidence pack
460
+ lists the file names. Files are never copied into the run folder.
461
+
462
+ ### Continuing a case
463
+
464
+ Every case starts by opening the job URL (or its first `goto`), so what an earlier case made, such
465
+ as a page generated at a URL that only exists in this run, would be gone. A case with
466
+ `"continue": true` opens nothing: it starts on the page the case before it ended on, as it was.
467
+ That way each check of what a case made is a case of its own, and one failure hides no other:
468
+
469
+ ```json
470
+ {
471
+ "cases": [
472
+ {
473
+ "id": "generate",
474
+ "title": "Generate a portfolio",
475
+ "steps": [
476
+ { "action": "click", "target": { "role": "button", "name": "Generate" } },
477
+ { "action": "expectText", "text": "Your portfolio is ready", "timeoutMs": 120000 }
478
+ ]
479
+ },
480
+ {
481
+ "id": "no-sample-logos",
482
+ "title": "The portfolio shows no sample client logos",
483
+ "continue": true,
484
+ "steps": [{ "action": "expectNoText", "text": "Acme" }]
485
+ },
486
+ {
487
+ "id": "linkedin",
488
+ "title": "The LinkedIn link goes to the user's profile",
489
+ "continue": true,
490
+ "steps": [
491
+ {
492
+ "action": "expectLink",
493
+ "target": { "role": "link", "name": "LinkedIn" },
494
+ "href": "linkedin.com/in/"
495
+ }
496
+ ]
497
+ }
498
+ ]
499
+ }
500
+ ```
501
+
502
+ A continuing case runs whatever the case before it came to, failed or blocked; only a browser that
503
+ crashed stops the run, as always. Tabs and windows the case before it opened are closed, and its
504
+ page loads are not judged again, but a way off the web it took (such as a `data:` frame) still
505
+ blocks the continuing case. The first case of a job cannot continue: that job is rejected
506
+ (`The first case, "generate", cannot continue: there is no case before it to continue from. …`).
507
+ The ledger and the evidence pack record `continuedFrom` (the ID of the case before it), and the
508
+ report says `Continued from case generate, on the page it ended on`. Its steps are its own, from
509
+ step 1, without the added opening navigation.
510
+
511
+ A case may also have `success`: one plain sentence of what success looks like, shown in the report
512
+ next to the case and never interpreted.
513
+
514
+ Before a full-page screenshot (a `screenshot` step, or the one taken when a case stops), screw-bugs
515
+ scrolls through the page a viewport at a time and back (at most 3 seconds), so sections that only
516
+ appear once scrolled to (fade-ins, lazy images, counters) are in it. The scrolling shows in the
517
+ video.
518
+
519
+ Expectations must prove the behavior: expect what only shows when it worked (or failed), such as
520
+ the exact success or error message or a URL change. `{"action": "expectText", "text": "Welcome,
521
+ Ada! Your account is ready."}` after signing up proves something; `{"action": "expectText",
522
+ "text": "Email"}` does not, since a field label is on the page before and after.
523
+
524
+ A `target` is exactly one of `{ "role": "button", "name": "Save" }` (`name` optional),
525
+ `{ "text": "..." }`, `{ "label": "..." }`, `{ "alt": "..." }` (an image's alt text, see
526
+ [Images and links](#images-and-links)) or `{ "css": "..." }`, plus an optional `frame` (see
527
+ [Frames](#frames)). When several elements match, the first visible one is used.
528
+
529
+ Cases run one after another, in job order, in one browser session (one test user in one browser),
530
+ recorded as one continuous video (`video/session-1.webm`, at most 1280×720). Cookies and storage
531
+ carry over from one case to the next, so a case can rely on what an earlier one did (signing in)
532
+ and can be affected by it. A failed or blocked case does not stop the session; only a browser that
533
+ crashes does, and the cases after it are then `not_verified`. A case whose first step is not `goto`
534
+ starts at the job URL, unless it continues (see below). A job without cases gets one "page loads" case: it opens the URL, passes when there is no HTTP
535
+ error, and takes a screenshot. Waiting for elements and expectations gives up after 5 seconds, and
536
+ page loads after 15, unless a step gives its own `timeoutMs`.
537
+
538
+ Every page load of a case is judged, in its own page and in any tab or window it opens (a
539
+ `target="_blank"` link, `window.open`), whenever it happens. Before each step runs, and before the
540
+ case is judged, screw-bugs waits until no page is loading (each for up to 15 seconds from when it
541
+ started, or the `timeoutMs` of its step), then judges every page load since the previous step against the step during which it
542
+ started:
543
+
544
+ - An HTTP error status (400 or above) fails that step, such as
545
+ `Step 2 (click link "Blog"): The page it opened returned HTTP 404.` A redirect counts by the page
546
+ it ends at.
547
+ - A page that could not be loaded at all blocks it
548
+ (`The page it opened in a new tab or window could not be loaded: net::ERR_CONNECTION_REFUSED.`),
549
+ and so does one that did not get its response within 15 seconds
550
+ (`The page it opened did not finish loading within 15 s.`).
551
+ - A page load that starts during an expectation or a screenshot is that step's, although the step
552
+ did not cause it: `A page load that started during this step returned HTTP 404.`
553
+
554
+ Only the page itself counts: a missing image, a failing request or a frame inside it does not, and
555
+ neither does a link that only changes the hash, a download, or a navigation that a newer one
556
+ replaced. A click or key press returns as soon as it is done and then waits a quarter of a second,
557
+ so a navigation it causes (such as a form that Enter submits) starts during its step. A click that
558
+ cannot be done within 5 seconds blocks the case, whatever else is loading. Later steps act on the
559
+ case's own page, never a new tab, and every tab the case opened closes before the next case starts. A page
560
+ load that starts after the last step is over is not judged.
561
+
562
+ screw-bugs only opens `http` and `https` pages; `localhost` and private addresses are fine. The job
563
+ URL must be one, and a case is blocked at any step that would leave the web for a local file or a
564
+ `data:`, `blob:`, `javascript:`, `view-source:` or browser page: a `goto` to one is not opened, a
565
+ link to one is not clicked, and a case whose browser ends up on one anyway is blocked and nothing
566
+ more is captured from it. That last check watches every navigation of every frame in every page of
567
+ the case, new tabs included, however it happened (a link changed as it was clicked, a script, a
568
+ redirect, an iframe): `A frame in the page went to a data: URL`. Frames may also be `about:blank`
569
+ or `about:srcdoc` (HTML the page wrote itself), and a frame that failed to load shows Chromium's
570
+ own error page. A `javascript:` link that a page swaps in at the last moment is not a navigation:
571
+ it runs as the page's own script, like any other script on the page, so it is not blocked.
572
+ Chromium itself refuses an `http` page's navigation to a `file:` URL, and a page's own top-level
573
+ navigation to a `data:` URL; nothing happens then.
574
+
575
+ | Status | Meaning |
576
+ | -------------- | ---------------------------------------------------------------------- |
577
+ | `passed` | Every step ran and every expectation held |
578
+ | `failed` | An expectation did not hold (including an HTTP error status) |
579
+ | `blocked` | A step could not run, such as a target not found or a failed page load |
580
+ | `not_verified` | Never reached: no browser, or the run was stopped |
581
+
582
+ ## CLI
583
+
584
+ | Command | What it does |
585
+ | ------------------------------------- | ---------------------------------------------- |
586
+ | `doctor` | Check Node, browser, video, disk and updates |
587
+ | `run [--spec job.json] [--url <url>]` | Run cases and wait; exit 1 unless all passed |
588
+ | `status <job-id>` | State and case results of a run |
589
+ | `answer <job-id> <question-id>` | Answer a question a waiting run asked |
590
+ | `mcp` | Serve the MCP server over stdio |
591
+ | `init` | Write `screw-bugs.json` for this project |
592
+ | `accounts` | Manage test accounts for logins |
593
+ | `report <job-id> [--format markdown]` | Write the report, or print a PR summary |
594
+ | `report <job-id> --serve [--port N]` | Serve the report at a `http://127.0.0.1` URL |
595
+ | `walkthrough <job-id> [--serve]` | Write (or serve) the run's video walkthrough |
596
+ | `findings <job-id> <file\|->` | Submit an agent's write-up of an ended run |
597
+ | `share <job-id>` | Share a report through screw-bugs Cloud |
598
+ | `runs` | List recent runs |
599
+ | `analytics` | Show whether analytics are on (off by default) |
600
+
601
+ Every command accepts `--json`. `run --url <url>` alone checks that the page loads. `init --url
602
+ <url>` saves a default URL, so a bare `run` uses it.
603
+
604
+ Runs go to `.screw-bugs/runs/<job-id>/` in your project: `job.json`, `ledger.json` (the status and
605
+ reason of every case, and when each case and step ran in the video), `evidence/` (screenshots, each
606
+ with a `.json` file of the page state at that moment), `video/` (one video per session),
607
+ `evidence.json` (the evidence pack), `findings.json` and `annotated/` (once an agent submitted a
608
+ write-up), `report.html` (or `report-interrupted.html`; see [Report](#report)) and
609
+ `walkthrough.html` (see [Walkthrough](#walkthrough)). The folder
610
+ ignores itself in git.
611
+
612
+ Besides screenshot steps and the page when a case stopped, a case gets a screenshot at each step
613
+ that acts on or finds an element: before a click, after a fill, and when expected text appears,
614
+ with the box of that element; and after each `waitFor` and `scroll`, of what is in view. Each
615
+ screenshot's `.json` holds the elements of the page and of the frames visible on it (at most 8
616
+ frames and 150 elements each, 400 in all frames together), with their boxes on the image. Video problems (no recording possible, an empty or cut-short file)
617
+ are reported in words and never change a status.
618
+ Screenshots are numbered by case and shot, such as `evidence/01/02-after-login.png` for the second
619
+ screenshot of the first case, so names never collide on Windows or macOS, where `A` and `a` are the
620
+ same file; `ledger.json` keeps the name each was saved under in `evidenceNames`. Case IDs must be
621
+ unique ignoring case.
622
+
623
+ Ctrl+C (or SIGTERM) stops a run cleanly: the job is marked `errored`, cases it did not finish are
624
+ `not_verified`, `report.html` is written (`run` prints its path, and `--json` adds `reportPath`),
625
+ the browser closes and the command exits 130. Each write
626
+ of `report.html` or `ledger.json` gets at most 5 seconds, so a hung disk cannot hold up the first
627
+ Ctrl+C for long; writes are atomic, so one that times out leaves the old file whole. Press Ctrl+C
628
+ again to quit at once. `mcp` does the same for its runs when it gets a signal or its client
629
+ disconnects. While a run is going, its process refreshes `heartbeatAt` (and records its `pid`) in
630
+ `ledger.json` every 5 seconds. If the process is killed or crashes, `status`, `runs` and
631
+ `run_status` report the run as `errored` once the heartbeat is 30 seconds old; `ledger.json` itself
632
+ is not rewritten. A process that is only paused (a laptop asleep) is still alive and goes on when it
633
+ wakes, so `status` and `run_status` write a report showing it errored, `report-interrupted.html`,
634
+ only once the heartbeat is 10 minutes old. They never write or remove `report.html`: only the run
635
+ itself writes that. If the process comes back anyway, its `report.html` takes precedence, and it
636
+ deletes the interrupted report once it has written its own.
637
+
638
+ ### Report
639
+
640
+ Every run that ends, finished or errored, writes `report.html` into its folder. It reads like a QA
641
+ write-up: the headline verdict and the counts, with what was not tested and why; what to fix,
642
+ most severe first; run details (target, device, times, video, version); then each case with its
643
+ status, the session video starting at the case with timecodes to jump to, what was done and what
644
+ worked and what didn't, its screenshots with the highlights drawn over them (a checkbox hides
645
+ them), and its steps with their timecodes; then what to test next. Code lays out the page and
646
+ decides every status; the agent's write-up fills fixed slots and is labelled as its own. Without a
647
+ write-up the report shows the run alone.
648
+
649
+ It is one self-contained file: inline styles, one small inline script allowed by its hash in the
650
+ Content Security Policy, no fonts or network requests. Screenshots and the video load by relative
651
+ paths, so it opens from disk and still works when the run folder is zipped or moved. It has a light
652
+ and a dark theme: it follows the system, and a switch picks one (kept in the browser where it
653
+ allows). Without script it follows the system, and timecodes are plain links that open the video
654
+ at that time. Each case has its own player, which loads nothing until played (its "Play from"
655
+ button shows where the case starts), and only one video plays at a time; so the screenshots load
656
+ from any static server, also one without HTTP range requests such as `python3 -m http.server`.
657
+ `run`, `status` and the MCP tool `run_status` give its path once the run has ended.
658
+
659
+ Only the run writes its `report.html`, plus `report` and `findings` under the rules below. For a
660
+ run whose process is gone (see above), `status` and
661
+ `run_status` write `report-interrupted.html` instead (each process tries that once per run). The
662
+ path they give is `report.html` when it exists, otherwise `report-interrupted.html` when that does.
663
+
664
+ The report is built from `ledger.json`, so it can always be written again. If writing it fails, the
665
+ run's result does not change; `screw-bugs report <job-id>` writes it again. It follows the same
666
+ rules: `report.html` for a run that ended by itself, `report-interrupted.html` for one whose
667
+ heartbeat is 10 minutes old (unless its own `report.html` exists, which it then prints), and nothing
668
+ (exit code 2) for a run that is still going or stopped responding less than 10 minutes ago.
669
+
670
+ ```sh
671
+ screw-bugs report <job-id> # (re)write the report and print its path
672
+ screw-bugs report <job-id> --format markdown # print a short summary for a pull request
673
+ ```
674
+
675
+ The Markdown summary has the headline (the agent's, if it wrote one up, with the code's verdict
676
+ next to it), the counts, what to fix, a table of the cases that did not pass with their reasons and
677
+ where in the video they failed, the video's path, the paths of the screenshots with highlights
678
+ drawn in, and the report's path. It embeds no images, so it can be pasted into a PR as is. With
679
+ `--json`, `report` prints `{ "ok": true, "path": "...", "walkthroughPath": "..." }` (plus
680
+ `markdown` with `--format markdown`; `walkthroughPath` only when the run has a walkthrough).
681
+
682
+ ### Walkthrough
683
+
684
+ With `report.html`, the run writes `walkthrough.html`: a page to click through what the run did. A
685
+ video player on top, and below it the script: every step of every case in run order, grouped by
686
+ case (its title and status), each with its timecode and the step in words (`0:01.5 Fill the field
687
+ labelled "Note" with "this is a new line"`). As the video plays, the step playing now is shown in
688
+ full contrast and the others are dimmed; the script scrolls to keep it in view (without motion
689
+ when the system asks for less). Every timecode is a link: it seeks the video there and plays, and
690
+ switches to the right session's video when it is in another one; when one session's video ends,
691
+ the next one plays. Cases that did not pass are listed at the top, each with a link to where it
692
+ was decided, and the step that decided one says its status and reason, in the report's words.
693
+ While a step that acted on an element is playing, a box over the video shows that element: taken
694
+ from the step's screenshot of the viewport, measured as the step ran, and drawn only around the
695
+ moment it was measured. Steps with no such measurement get no box. Boxes on the video, on the
696
+ report's screenshots and on the annotated copies are placed where the screen showed the element,
697
+ also on a phone, where a page without a viewport meta tag is laid out wider than the screen and
698
+ shown smaller, or a page is zoomed in: each screenshot records the visual viewport its boxes were
699
+ measured in (`visual` in `ledger.json` and its page state). Where that cannot be told for sure,
700
+ and in runs on a phone from before it was recorded, no box is drawn and the report says why.
701
+
702
+ Over the video it also shows what the mouse and keyboard did, drawn by the page from where and when
703
+ each action happened as the run recorded it (`steps[].action` in `ledger.json`), never painted into
704
+ the video or the screenshots: a cursor that glides to each point the mouse pressed and rests there,
705
+ a ripple where it pressed, a ring around a field typed into (the step's box, when that shows), and a short label such as
706
+ `Click "Save"`, `Type "this is a new line"` or `Press Enter`, in the step's words. It follows the
707
+ video's time, so seeking or pausing anywhere shows the state at that moment. Where and when the
708
+ mouse pressed or a key went down is the trusted `pointerdown`, `mousedown` or `keydown` the browser
709
+ actually dispatched to the page, watched (in Chromium) from an isolated world that page scripts
710
+ cannot see, reading nothing from the page as it does; recording it never changes the run. The
711
+ point is where the press was on the screen, so it lands on the right spot of the video also on a
712
+ phone, where a page without a viewport meta tag is laid out wider than the screen and shown
713
+ smaller, or a page is zoomed in; when that cannot be told for sure, the step has no point. On a
714
+ phone this needs Playwright's own Chromium (its headless shell): an installed Chrome or Edge, and
715
+ any headed browser (a window of its own, as for logins), lays the page out in a window whose
716
+ position and toolbar move where the press was on the screen in a way nothing on the event tells
717
+ apart from a page zoomed in and moved, so a phone click there records only its time and label.
718
+ On a desktop, where only pinch zoom moves the page, every browser records the point. Only
719
+ those count, because a page cannot make them trusted itself. It can make trusted edits
720
+ (`document.execCommand`), so typing into a field, and files set on a file input directly, have no
721
+ time or point of their own: their label shows while the step plays. A step whose input was not
722
+ seen, such as a click inside an iframe, gets no cursor point and no ripple, never a guessed one,
723
+ and its label shows while the step plays. With reduced
724
+ motion the cursor jumps instead of gliding and there is no ripple. **Show cursor** under the video
725
+ turns it off; the choice is remembered like the theme. Runs from before actions were recorded have
726
+ none of it.
727
+
728
+ Like the report it is self-contained, loads nothing from the network, links the video by relative
729
+ path, follows the light and dark theme, and works from disk and over the report server. A run with
730
+ no video, or an older run with no step times, still lists every step and error, and says why the
731
+ times cannot be played.
732
+
733
+ It is written under the same rules as `report.html`: by the run when it ends, and again by
734
+ `report`, `findings`/`submit_findings` and `walkthrough`; never by status reads, and never for an
735
+ interrupted run (`report-interrupted.html` has no walkthrough). The report links it near the top
736
+ when it exists.
737
+
738
+ ```sh
739
+ screw-bugs walkthrough <job-id> # (re)write it with the report and print its path
740
+ screw-bugs walkthrough <job-id> --serve # serve it at a http://127.0.0.1 URL, as report --serve
741
+ ```
742
+
743
+ With `--json`, `walkthrough` prints `{ "ok": true, "path": "...", "reportPath": "..." }`; with
744
+ `--serve`, the same as `report --serve`. For an interrupted run it exits 2.
745
+
746
+ ### Viewing reports
747
+
748
+ In a normal browser, open `report.html` from the run folder (or the path `run`, `status` and
749
+ `run_status` give): it works from disk.
750
+
751
+ Browsers built into coding tools, such as Cursor's browser or the browser pane of the Claude
752
+ desktop app, cannot open `file://` pages, but they can open `http://127.0.0.1`. Use a URL instead:
753
+
754
+ - From an agent, `run_status` (and `submit_findings`) give the report's URL on the line after its
755
+ path. The MCP server starts a small local server for this the first time it has a report to give,
756
+ and keeps it for as long as it runs; one per MCP server. `SCREW_BUGS_SERVE=0` turns it off, and
757
+ replies then give the path alone.
758
+ - From a terminal, `screw-bugs report <job-id> --serve` (or `walkthrough <job-id> --serve`) writes
759
+ the report as `report` does, prints its URL (or the walkthrough's) and serves until Ctrl+C (which exits with 130, like any interrupted command). With
760
+ `--json` it prints `{ "url": "...", "ok": true, "path": "...", "reused": false }`.
761
+
762
+ **Ports.** Each project gets its own port in 41000–41999, the same one every time: a hash of the
763
+ real path of its `.screw-bugs/runs` folder picks it. So a report link keeps working across MCP
764
+ processes, sessions and `report --serve`, as long as one of them serves the project.
765
+
766
+ - If that port is free, the server takes it.
767
+ - If this project's report server in another screw-bugs process holds it, and proves it (below),
768
+ that one is used: replies give its URL, and `report --serve` prints it and ends at once
769
+ (`"reused": true`).
770
+ - If anything else holds it (another project whose hash landed on the same port, another program,
771
+ or anything that cannot prove it), the server tries the port once or twice more (its holder may
772
+ just have been stopping), then takes a free port, whose links last as long as it runs.
773
+ - An MCP server that is not on the project's port tries it again each time it gives a URL. Once it
774
+ is free, it serves there too and gives that URL from then on; a free-port server it started
775
+ keeps running, so links it gave before still work.
776
+ - `report --serve --port <n>` uses exactly that port, and fails if it is taken (`--port 0` picks a
777
+ free one).
778
+
779
+ **Proving a server is this project's.** Each project has a secret, `.screw-bugs/report-server.secret`:
780
+ 32 random bytes, made on first use, readable by its owner only (mode 0600). A server is reused only if
781
+ it answers a challenge: `GET /.screw-bugs/identity?nonce=<64 hex digits>` (a fresh random nonce)
782
+ must return `{ "app": "screw-bugs-report-server", "root": "<hash>", "proof": "<hmac>" }`, where
783
+ `root` is a hash of the runs folder's real path (never the path) and `proof` is an HMAC-SHA256,
784
+ under the secret, of the nonce, that hash and the port it answers on. Only a process that can read
785
+ the secret can answer, and an answer passed on from this project's server on another port does not
786
+ fit. The endpoint has the same Host and method checks as everything else, and answers 404 when the
787
+ server has no secret. A secret that others can read is not used, and nothing is reused then.
788
+
789
+ On Windows there are no proofs: mode 0600 does not make a file private there (a folder's inherited
790
+ access rules may let other users read it), so a secret could be read and proofs forged. So on
791
+ Windows no secret is made, another process's server is never reused (not even this project's), and
792
+ a taken project port always means a free port of the server's own. Links there last as long as the
793
+ process that gave them, unless it got the project's port.
794
+
795
+ This check cannot stop a process from taking the port after it, such as one that grabs it in the
796
+ moment between another screw-bugs process stopping and this one trying the port again. Links given
797
+ out then reach that process until screw-bugs serves on the port again.
798
+
799
+ Both listen on 127.0.0.1 only, answer only requests addressed to `127.0.0.1` or `localhost`, and
800
+ serve only the project's run folders, read-only: reports, screenshots, videos and JSON files. They
801
+ never list folders or serve dotfiles, anything outside `.screw-bugs/runs` or symlinks out of it.
802
+ Videos are served with HTTP range requests, so they play and seek (unlike `python3 -m
803
+ http.server`). A URL works as long as some process serves the project on its port.
804
+
805
+ ### CI
806
+
807
+ With `CI=true` or no terminal, screw-bugs never waits for input. A missing `screw-bugs.json` is an
808
+ error, not a prompt. Exit codes:
809
+
810
+ | Code | Meaning |
811
+ | ---- | ------------------------------------ |
812
+ | 0 | OK |
813
+ | 1 | A case did not pass |
814
+ | 2 | Bad arguments |
815
+ | 3 | `screw-bugs.json` missing or invalid |
816
+ | 4 | `doctor` found something missing |
817
+ | 5 | Not implemented yet |
818
+ | 6 | Findings do not fit the run |
819
+ | 7 | Upload files missing or unusable |
820
+ | 70 | Internal error (please report it) |
821
+ | 130 | Stopped by Ctrl+C or SIGTERM |
822
+
823
+ ### Updates
824
+
825
+ Once a day screw-bugs asks the npm registry whether a newer version exists, in the background: it
826
+ never delays the MCP server or a command's output. When a check is due, a CLI command waits for it
827
+ after its output, so that CLI-only use gets checked too (the update check never holds a command
828
+ back more than 3 seconds in all, even when the cache folder's disk hangs); the exit code does not
829
+ change, and when no check is due the command exits at once. A check that gets no answer (offline, a
830
+ timeout) is tried again on the next start, or after an hour in a running MCP server. The result is
831
+ cached in your cache folder (`~/.cache/screw-bugs/update-check.json`, or under `$XDG_CACHE_HOME`,
832
+ `~/Library/Caches` on macOS, `%LOCALAPPDATA%` on Windows), not in the project. screw-bugs never
833
+ updates itself; when a newer version is known it says so, with the exact command for how you
834
+ installed it (`npm i -g`, `pnpm add -g`, `<pm> add` in your project, keeping the `package.json`
835
+ section it is in, `-D` when none, `npx -y screw-bugs@latest mcp` in the MCP config, or `git pull &&
836
+ pnpm build` in a checkout). On macOS and Linux a project's or checkout's command starts with
837
+ `cd <folder> &&`; on Windows it names the folder to run it in instead, because `cd` in cmd does
838
+ not change the drive:
839
+
840
+ - `doctor` (CLI and MCP tool) shows it as an `update` warning; the exit code does not change.
841
+ - The MCP server adds one sentence to its instructions when a session connects, such as
842
+ ``screw-bugs 0.4.0 is available (you have 0.3.2). To update, run `npm i -g screw-bugs@latest`
843
+ (ask the user first), then restart the MCP server.`` Tool replies never mention it.
844
+ - The CLI prints that line on stderr at most once a day, only in a terminal, never with `--json`.
845
+
846
+ In a git checkout, `doctor` also works offline: if `dist/` was built from another commit than the
847
+ checkout's (`pnpm build` stamps `dist/build-info.json`), it suggests `pnpm build`; if the running
848
+ MCP server loaded an older build or version than is installed now, it says to restart the server
849
+ (in Claude Code: `/mcp`, pick screw-bugs, Reconnect).
850
+
851
+ Turn the check off with `SCREW_BUGS_UPDATE_CHECK=0`. It is always off with `CI=true`.
852
+
853
+ ### Analytics
854
+
855
+ Off by default. Opt in with `SCREW_BUGS_ANALYTICS=1`; `DO_NOT_TRACK=1` always turns them off.
856
+ Nothing is collected yet.
857
+
858
+ ## Development
859
+
860
+ ```sh
861
+ pnpm install
862
+ pnpm check # format check, lint (including module boundaries), typecheck, tests
863
+ pnpm build
864
+ ```
865
+
866
+ Tests that record video need Playwright's ffmpeg; CI downloads it with
867
+ `pnpm exec playwright-core install ffmpeg`, and so can you.
868
+
869
+ CI never runs automatically; start it by hand from the Actions tab (CI → "Run workflow") or with
870
+ `gh workflow run CI -R uxstudioteam/screw-bugs --ref <branch>`.
871
+
872
+ ### End-to-end test (local only)
873
+
874
+ `pnpm e2e` checks screw-bugs the way users meet it: the real `claude` CLI gets a plain-language
875
+ request ("test the signup flow") and uses the MCP tools to test a small fixture website with
876
+ planted bugs (a signup form that rejects every real email address, and a Blog link that returns
877
+ 404).
878
+
879
+ Prerequisites: Node 24 (the script runs as TypeScript through Node's type stripping), the `claude`
880
+ CLI logged in, and a browser `doctor` accepts.
881
+
882
+ ```sh
883
+ pnpm e2e # all scenarios: signup, navigation, contact, upload
884
+ pnpm e2e --scenario signup # one scenario
885
+ pnpm e2e --model opus # another model (default: sonnet)
886
+ pnpm e2e --keep # also keep the tarball and npm caches in the temp folder
887
+ ```
888
+
889
+ For each scenario it builds and packs screw-bugs, makes an empty project in a temp folder, and
890
+ starts `claude -p` there with only the screw-bugs MCP server, which runs from the tarball through
891
+ `npx -y file:<tarball> mcp` with an empty npm cache. Claude gets no other tools (no shell, files
892
+ or web) and none of your personal settings, hooks or plugins. You see Claude's messages and tool
893
+ calls live. Afterwards it checks that Claude called `start_run` then `run_status`, that every
894
+ reply is short, that every run finished with a `ledger.json` and wrote `report.html`, and that the outcomes are right (the
895
+ signup bug is caught, the working contact form passes). It exits 1 if any check fails.
896
+
897
+ The results page, `e2e-results/<timestamp>/index.html` (gitignored), shows each prompt, the whole
898
+ session, the case table with screenshots and a link to each run's `report.html`, the checks, duration and tokens, and a
899
+ `claude --resume` command to reopen the session. The project folders stay in the temp folder for
900
+ that; the script prints where.
901
+
902
+ It uses your Claude subscription: a full run is three Sonnet sessions, about a minute or two and
903
+ roughly 70k input tokens (mostly cached) and a few thousand output tokens. It is never run in CI.
904
+
905
+ `src/` holds one folder per module, each published as a sub-path (`screw-bugs/core`,
906
+ `screw-bugs/schema`, ...). `schema`, `core` and `report` must not import Node, Playwright or other
907
+ modules' internals; `pnpm lint` enforces this.