screw-bugs 0.1.7 → 0.1.8
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/README.md +83 -13
- package/dist/browser-playwright/page.d.ts +2 -2
- package/dist/browser-playwright/page.js +15 -2
- package/dist/build-info.json +3 -3
- package/dist/cli/commands.js +56 -11
- package/dist/cli/mcp.d.ts +11 -4
- package/dist/cli/mcp.js +86 -23
- package/dist/cli/operations.d.ts +30 -2
- package/dist/cli/operations.js +126 -20
- package/dist/cli/report-links.js +2 -2
- package/dist/cli/report-server.d.ts +41 -9
- package/dist/cli/report-server.js +139 -23
- package/dist/cli/share.d.ts +71 -4
- package/dist/cli/share.js +540 -109
- package/dist/cli/sign-in.d.ts +22 -10
- package/dist/cli/sign-in.js +23 -23
- package/dist/core/engine.js +45 -10
- package/dist/core/liveness.js +3 -1
- package/dist/core/services.d.ts +24 -4
- package/dist/core/share.d.ts +31 -0
- package/dist/core/share.js +139 -0
- package/dist/core/steps.d.ts +5 -0
- package/dist/core/steps.js +15 -1
- package/dist/report/html.d.ts +4 -2
- package/dist/report/html.js +36 -13
- package/dist/report/icons.d.ts +3 -0
- package/dist/report/icons.js +5 -1
- package/dist/report/index.d.ts +3 -1
- package/dist/report/index.js +3 -1
- package/dist/report/live.d.ts +7 -0
- package/dist/report/live.js +135 -0
- package/dist/report/menu-bar.d.ts +3 -3
- package/dist/report/menu-bar.js +3 -3
- package/dist/report/player.d.ts +3 -3
- package/dist/report/player.js +3 -3
- package/dist/report/share-page.d.ts +48 -0
- package/dist/report/share-page.js +291 -0
- package/dist/report/styles.d.ts +2 -0
- package/dist/report/styles.js +2 -2
- package/dist/report/view.js +2 -0
- package/dist/report/walkthrough.d.ts +5 -2
- package/dist/report/walkthrough.js +17 -5
- package/dist/schema/accounts.js +10 -1
- package/dist/schema/evidence.d.ts +15 -8
- package/dist/schema/evidence.js +9 -4
- package/dist/schema/findings.js +1 -1
- package/dist/schema/job.d.ts +205 -65
- package/dist/schema/job.js +63 -11
- package/dist/schema/ledger.d.ts +80 -16
- package/dist/schema/ledger.js +36 -0
- package/dist/schema/share.d.ts +17 -0
- package/dist/schema/share.js +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -125,7 +125,18 @@ Without a write-up the report still renders from the run alone.
|
|
|
125
125
|
|
|
126
126
|
`run_status` takes a `jobId` and an optional `waitSeconds` (0–60, default 0): if the run is still
|
|
127
127
|
queued or running, it waits up to that long for the run to end before replying. It rereads the
|
|
128
|
-
ledger, so it also works for runs started by another process.
|
|
128
|
+
ledger, so it also works for runs started by another process. While the run is still going, the
|
|
129
|
+
reply says which case and step it is on, then gives the run folder, `ledger.json` and its live page
|
|
130
|
+
(see [Following a run](#following-a-run)):
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
Job 20261029-104857-3f9a01c2 is running case 2 of 3 (reply-maya), step 4 (click): 0 passed, 1 failed, 0 blocked, 1 not verified; follow it as it runs in live.html (the URL below).
|
|
134
|
+
/path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2
|
|
135
|
+
/path/to/project/.screw-bugs/runs/20261029-104857-3f9a01c2/ledger.json
|
|
136
|
+
http://127.0.0.1:41234/20261029-104857-3f9a01c2/live.html
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Once the run has ended, its reply is
|
|
129
140
|
the counts, then a compact evidence pack: two lines per case (cases that did not pass first), the
|
|
130
141
|
status and reason, then the deciding step and when it ran, the screenshot IDs, the timecodes (ms
|
|
131
142
|
into the session video) a write-up may use, where the page was, HTTP errors, the visible text
|
|
@@ -326,6 +337,7 @@ Chromium: this catches responsive layout and touch problems, not Safari-only bug
|
|
|
326
337
|
| `goto` | `url` | Open a URL; paths resolve against the job URL. HTTP 400+ fails. |
|
|
327
338
|
| `reload` | | Reload the page; judged like `goto` |
|
|
328
339
|
| `click` | `target` | Click an element; a page it opens with HTTP 400+ fails |
|
|
340
|
+
| `hover` | `target` | Move the pointer over an element, for controls shown on hover |
|
|
329
341
|
| `fill` | `target`, `value` | Replace the value of an input |
|
|
330
342
|
| `upload` | `target`, `files` | Choose files for a file input (see [Uploads](#uploads)) |
|
|
331
343
|
| `press` | `key` | Press a key, such as `Enter`; a page it opens with 400+ fails |
|
|
@@ -711,7 +723,16 @@ When the account has no saved session for the job URL's origin, nothing starts.
|
|
|
711
723
|
reply gives a link to the live view (`http://127.0.0.1:<port>/<token>/`); open it, sign in as that
|
|
712
724
|
user (OAuth redirects and codes by email or an app work; passkeys and security keys do not, since
|
|
713
725
|
they need your own device), press **Save sign-in**, then
|
|
714
|
-
have your agent start the job again.
|
|
726
|
+
have your agent start the job again. `start_run` also takes an optional `waitSeconds` (0–600,
|
|
727
|
+
default 0): with it, the call waits up to that long for you to press **Save sign-in** and then
|
|
728
|
+
starts the run, so nobody has to tell the agent you are done. Since the link reaches you only in a
|
|
729
|
+
reply, an agent calls once without `waitSeconds` to get the link and show it to you, then again
|
|
730
|
+
with `waitSeconds` to wait. The wait counts from the call, opening the sign-in included; when it
|
|
731
|
+
runs out, a save already in progress gets up to 5 seconds to finish, then the call looks for a saved session once more and otherwise gives the same link again.
|
|
732
|
+
The live view opens the app at once, so when the account is not in `.screw-bugs/accounts.json`
|
|
733
|
+
yet, agents first get the app running and what that user needs to sign in (the user itself, in a
|
|
734
|
+
local database), then start the job before the rest of their preparation (seeding test data), so
|
|
735
|
+
you can sign in meanwhile. From the CLI, `screw-bugs run` exits with code 9
|
|
715
736
|
(`SignInNeeded`) and prints the command that opens the live view:
|
|
716
737
|
|
|
717
738
|
```sh
|
|
@@ -720,9 +741,10 @@ npx screw-bugs accounts sign-in trial-user --url http://localhost:3000 --about "
|
|
|
720
741
|
|
|
721
742
|
- **On another device.** The live view listens on 127.0.0.1, so by default it opens only on this
|
|
722
743
|
machine (in your coding tool's browser, for example). To sign in from your phone or another
|
|
723
|
-
computer on your network or tailnet, set `SCREW_BUGS_SIGN_IN_HOST`
|
|
724
|
-
|
|
725
|
-
|
|
744
|
+
computer on your network or tailnet, set `SCREW_BUGS_SIGN_IN_HOST` as `SCREW_BUGS_REPORT_HOST`
|
|
745
|
+
(below): this machine's full MagicDNS name or its Tailscale IP (`tailscale ip -4`). The link
|
|
746
|
+
then uses what you set, and with a name the IP it resolves to works too. It never listens on
|
|
747
|
+
every interface. The link holds a random token and works only while that
|
|
726
748
|
sign-in is open; it closes when you save or cancel, after 15 minutes without use, or when the
|
|
727
749
|
MCP server or the command stops.
|
|
728
750
|
- **Keeping it current.** A session is saved for one origin; a job on another origin (staging
|
|
@@ -754,6 +776,7 @@ npx screw-bugs accounts sign-in trial-user --url http://localhost:3000 --about "
|
|
|
754
776
|
| `report <job-id> --serve [--port N]` | Serve the report at a `http://127.0.0.1` URL |
|
|
755
777
|
| `walkthrough <job-id> [--serve]` | Write (or serve) the run's video walkthrough |
|
|
756
778
|
| `findings <job-id> <file\|->` | Submit an agent's write-up of an ended run |
|
|
779
|
+
| `schema <job\|findings>` | Print the JSON Schema of a job or write-up |
|
|
757
780
|
| `share <job-id>` | Share a report through Screw Bugs Cloud |
|
|
758
781
|
| `runs` | List recent runs |
|
|
759
782
|
| `analytics` | Show whether analytics are on (off by default) |
|
|
@@ -765,12 +788,14 @@ Runs go to `.screw-bugs/runs/<job-id>/` in your project: `job.json`, `ledger.jso
|
|
|
765
788
|
reason of every case, and when each case and step ran in the video), `evidence/` (screenshots, each
|
|
766
789
|
with a `.json` file of the page state at that moment), `video/` (one video per session),
|
|
767
790
|
`evidence.json` (the evidence pack), `findings.json` and `annotated/` (once an agent submitted a
|
|
768
|
-
write-up), `
|
|
769
|
-
`
|
|
791
|
+
write-up), `live.html` (see [Following a run](#following-a-run)), `report.html` (or
|
|
792
|
+
`report-interrupted.html`; see [Report](#report)) and `walkthrough.html` (see
|
|
793
|
+
[Walkthrough](#walkthrough)). The folder
|
|
770
794
|
ignores itself in git.
|
|
771
795
|
|
|
772
796
|
Besides screenshot steps and the page when a case stopped, a case gets a screenshot at each step
|
|
773
|
-
that acts on or finds an element: before a click, after a fill
|
|
797
|
+
that acts on or finds an element: before a click, after a fill or a hover (showing what the hover
|
|
798
|
+
revealed), and when expected text appears,
|
|
774
799
|
with the box of that element; and after each `waitFor` and `scroll`, of what is in view. Each
|
|
775
800
|
screenshot's `.json` holds the elements of the page and of the frames visible on it (at most 8
|
|
776
801
|
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)
|
|
@@ -795,6 +820,23 @@ only once the heartbeat is 10 minutes old. They never write or remove `report.ht
|
|
|
795
820
|
itself writes that. If the process comes back anyway, its `report.html` takes precedence, and it
|
|
796
821
|
deletes the interrupted report once it has written its own.
|
|
797
822
|
|
|
823
|
+
### Following a run
|
|
824
|
+
|
|
825
|
+
While a run is going, it writes `live.html` into its folder: a page to watch it on, with the
|
|
826
|
+
counts, every case (passed, failed, blocked, running or pending) and the case and step it is on.
|
|
827
|
+
The run writes it when it starts and again with every write of `ledger.json` (when a case ends,
|
|
828
|
+
and every 5 seconds with its heartbeat), and the page reloads itself every 3 seconds. `ledger.json`
|
|
829
|
+
keeps where the run is as `progress` (`{ "case": 2, "step": 4, "kind": "click" }`), saved with
|
|
830
|
+
those writes, so it may be a few seconds behind. When the run ends, its last write of `live.html`
|
|
831
|
+
stops the reloading and links `report.html` (and `walkthrough.html`). If the run's process dies,
|
|
832
|
+
the page's "last updated" time stops moving; `status` and `run_status` then report the run as
|
|
833
|
+
errored and give its interrupted report, as above.
|
|
834
|
+
|
|
835
|
+
`run_status` and `status` give its URL while the run is going (its path when there is no URL, see
|
|
836
|
+
[Viewing reports](#viewing-reports); with `--json`, `livePath` and `liveUrl`), and say which case
|
|
837
|
+
and step the run is on in their first sentence. `live.html` is never the report: the
|
|
838
|
+
report rules below do not change.
|
|
839
|
+
|
|
798
840
|
### Report
|
|
799
841
|
|
|
800
842
|
Every run that ends, finished or errored, writes `report.html` into its folder. One page, one
|
|
@@ -894,7 +936,11 @@ apart from a page zoomed in and moved, so a phone click there records only its t
|
|
|
894
936
|
On a desktop, where only pinch zoom moves the page, every browser records the point. Only
|
|
895
937
|
those count, because a page cannot make them trusted itself. It can make trusted edits
|
|
896
938
|
(`document.execCommand`), so typing into a field, and files set on a file input directly, have no
|
|
897
|
-
time or point of their own: their label shows while the step plays. A
|
|
939
|
+
time or point of their own: their label shows while the step plays. A `hover` has none either:
|
|
940
|
+
when a page moves or scrolls under a mouse that stands still, the browser itself sends trusted
|
|
941
|
+
mouse events, so no mouse move proves where or when a hover moved it. Its label shows while the
|
|
942
|
+
step plays, and the cursor is hidden from then until the next click (also after a hover that
|
|
943
|
+
failed, which may have moved the mouse all the same), never left where the mouse no longer is. A step whose input was not
|
|
898
944
|
seen, such as a click inside an iframe, gets no cursor point and no ripple, never a guessed one,
|
|
899
945
|
and its label shows while the step plays. With reduced
|
|
900
946
|
motion the cursor jumps instead of gliding and there is no ripple. **Show cursor** under the video
|
|
@@ -932,12 +978,13 @@ Browsers built into coding tools, such as Cursor's browser or the browser pane o
|
|
|
932
978
|
desktop app, cannot open `file://` pages, but they can open `http://127.0.0.1`. Use a URL instead:
|
|
933
979
|
|
|
934
980
|
- From an agent, `run_status` (and `submit_findings`) give the report's URL (and the
|
|
935
|
-
walkthrough's) in place of its path. The MCP server starts a small local server for this the first time it has a report to give,
|
|
981
|
+
walkthrough's, or while the run is going, its `live.html`'s) in place of its path. The MCP server starts a small local server for this the first time it has a report to give,
|
|
936
982
|
and keeps it for as long as it runs; one per MCP server. `SCREW_BUGS_SERVE=0` turns it off, and
|
|
937
983
|
replies then give the paths.
|
|
938
984
|
- From a terminal (or an agent using the CLI), `run`, `status`, `report`, `walkthrough` and
|
|
939
985
|
`findings` print the report's and walkthrough's URLs in place of their paths (with `--json`,
|
|
940
|
-
`reportUrl` and `walkthroughUrl` beside `reportPath` and `walkthroughPath`)
|
|
986
|
+
`reportUrl` and `walkthroughUrl` beside `reportPath` and `walkthroughPath`), and `status` that of
|
|
987
|
+
a running run's `live.html` (`liveUrl` beside `livePath`). They use the
|
|
941
988
|
project's report server when one is up (an MCP server's, say); otherwise they start one in the
|
|
942
989
|
background, which keeps serving after the command ends and stops on its own after 30 minutes
|
|
943
990
|
without a request (an MCP server of the project then takes its port over). A command waits at
|
|
@@ -946,6 +993,19 @@ desktop app, cannot open `file://` pages, but they can open `http://127.0.0.1`.
|
|
|
946
993
|
- From a terminal, `screw-bugs report <job-id> --serve` (or `walkthrough <job-id> --serve`) writes
|
|
947
994
|
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
|
|
948
995
|
`--json` it prints `{ "url": "...", "ok": true, "path": "...", "reused": false }`.
|
|
996
|
+
- **On another device.** The report server listens on 127.0.0.1, so by default its links open only
|
|
997
|
+
on this machine. To open reports from your phone or another computer on your network or
|
|
998
|
+
tailnet, set `SCREW_BUGS_REPORT_HOST` in the MCP server's environment (or the shell that runs
|
|
999
|
+
the commands) to this machine's full MagicDNS name (`pop-os.tail1234.ts.net`, from `tailscale
|
|
1000
|
+
status --self`) or its Tailscale IP (`tailscale ip -4`). Links then use what you set. The
|
|
1001
|
+
server listens only on the one address that resolves to, never on every interface, and answers
|
|
1002
|
+
requests addressed to the name you set or to that address, so `http://100.x.y.z:…` works with
|
|
1003
|
+
the name set (but a bare `http://pop-os:…` only when you set `pop-os`). A name is looked up each
|
|
1004
|
+
time a server starts. The short name (`pop-os`) works too, but what it resolves to depends on
|
|
1005
|
+
this machine's DNS setup: without Tailscale's DNS it can resolve to a LAN address (opening
|
|
1006
|
+
reports to your LAN) or to loopback, which is refused (many Linux systems map the machine's own
|
|
1007
|
+
name to 127.0.1.1). Check with `getent hosts pop-os`. The Share button works there with a
|
|
1008
|
+
pairing code (see Sharing below).
|
|
949
1009
|
|
|
950
1010
|
**Ports.** Each project gets its own port in 41000–41999, the same one every time: a hash of the
|
|
951
1011
|
real path of its `.screw-bugs/runs` folder picks it. So a report link keeps working across MCP
|
|
@@ -999,7 +1059,7 @@ The one other thing they answer is the Share button's routes, under `/.screw-bug
|
|
|
999
1059
|
|
|
1000
1060
|
### Sharing
|
|
1001
1061
|
|
|
1002
|
-
A report or walkthrough opened through the report server (its `http
|
|
1062
|
+
A report or walkthrough opened through the report server (its `http://` URL) has a
|
|
1003
1063
|
**Share** button that puts the run on Screw Bugs Cloud: a link anyone can open for 7 days. Opened
|
|
1004
1064
|
from disk, or on Cloud itself, the page has no server to share it, so the button is not there.
|
|
1005
1065
|
|
|
@@ -1010,8 +1070,18 @@ from disk, or on Cloud itself, the page has no server to share it, so the button
|
|
|
1010
1070
|
its progress, then sends the browser to the share's page on Cloud: its link, when it expires,
|
|
1011
1071
|
and a button to delete it.
|
|
1012
1072
|
|
|
1073
|
+
Opened from another device (with `SCREW_BUGS_REPORT_HOST`, above), Cloud cannot send the browser
|
|
1074
|
+
back to this machine, so Share works as `stripe login` does: the report server asks Cloud for a
|
|
1075
|
+
share request and shows a pairing code with a link to `screwbugs.dev`. Type the code there and
|
|
1076
|
+
confirm; meanwhile the server asks Cloud for the ticket every couple of seconds, gets it once you
|
|
1077
|
+
confirmed, and uploads as above, and the page with the code moves on to the share. Only that page
|
|
1078
|
+
shows the code, so a share link someone else sends you cannot upload into your account.
|
|
1079
|
+
|
|
1013
1080
|
Only a person can share: it takes a click in the report and a confirmation on Cloud. The share
|
|
1014
|
-
starts only from a click in a page of the same server
|
|
1081
|
+
starts only from a click in a page of the same server. Where the browser does not say where a
|
|
1082
|
+
click came from (it says so only to 127.0.0.1 and localhost), Share first asks "Share this run on
|
|
1083
|
+
Screw Bugs Cloud?", and only that page's button, posted from the same server, starts it. The
|
|
1084
|
+
share's pages never show inside another site's page, the ticket goes only to the Cloud the
|
|
1015
1085
|
server was set up with, and a ticket works once, for the share it was made for. The `share`
|
|
1016
1086
|
command is not implemented; there is no agent or CLI path.
|
|
1017
1087
|
|
|
@@ -13,8 +13,8 @@ export declare const NAVIGATION_TIMEOUT_MS = 15000;
|
|
|
13
13
|
export declare const EXPECT_TIMEOUT_MS = 5000;
|
|
14
14
|
export declare const SCREENSHOT_TIMEOUT_MS = 10000;
|
|
15
15
|
/**
|
|
16
|
-
* How long a click or key press waits after it is dispatched, so that a navigation it
|
|
17
|
-
* starts while it is still the current step, such as a form that the Enter key submits.
|
|
16
|
+
* How long a click, hover or key press waits after it is dispatched, so that a navigation it
|
|
17
|
+
* causes starts while it is still the current step, such as a form that the Enter key submits.
|
|
18
18
|
*/
|
|
19
19
|
export declare const NAVIGATION_START_MS = 250;
|
|
20
20
|
/**
|
|
@@ -17,8 +17,8 @@ export const NAVIGATION_TIMEOUT_MS = DEFAULT_LOAD_MS;
|
|
|
17
17
|
export const EXPECT_TIMEOUT_MS = DEFAULT_WAIT_MS;
|
|
18
18
|
export const SCREENSHOT_TIMEOUT_MS = 10_000;
|
|
19
19
|
/**
|
|
20
|
-
* How long a click or key press waits after it is dispatched, so that a navigation it
|
|
21
|
-
* starts while it is still the current step, such as a form that the Enter key submits.
|
|
20
|
+
* How long a click, hover or key press waits after it is dispatched, so that a navigation it
|
|
21
|
+
* causes starts while it is still the current step, such as a form that the Enter key submits.
|
|
22
22
|
*/
|
|
23
23
|
export const NAVIGATION_START_MS = 250;
|
|
24
24
|
const seconds = (ms) => `${ms / 1000} s`;
|
|
@@ -1317,6 +1317,19 @@ drawn) => {
|
|
|
1317
1317
|
: firstLine(error)));
|
|
1318
1318
|
return yield* tracedAfterPause(began, dispatched, true);
|
|
1319
1319
|
}),
|
|
1320
|
+
hover: (target, wait) => Effect.gen(function* () {
|
|
1321
|
+
const timeout = wait?.timeoutMs ?? ACTION_TIMEOUT_MS;
|
|
1322
|
+
const locator = yield* element(target, timeout);
|
|
1323
|
+
// Not watched: a page can make trusted mouse moves happen itself (see
|
|
1324
|
+
// `StepAction.atMs`), so a hover records no time or point.
|
|
1325
|
+
yield* attempt(() => locator.hover({ timeout }), (error) => isTimeout(error)
|
|
1326
|
+
? `The element was found but the mouse could not be moved over it within ${seconds(timeout)}.`
|
|
1327
|
+
: firstLine(error));
|
|
1328
|
+
// As after a click: a navigation the hover starts (a `mouseenter` handler's) starts while
|
|
1329
|
+
// it is still the current step, so its load is judged as the hover's.
|
|
1330
|
+
yield* Effect.sleep(NAVIGATION_START_MS);
|
|
1331
|
+
return {};
|
|
1332
|
+
}),
|
|
1320
1333
|
fill: (target, value, wait) => Effect.gen(function* () {
|
|
1321
1334
|
const timeout = wait?.timeoutMs ?? ACTION_TIMEOUT_MS;
|
|
1322
1335
|
const locator = yield* element(target, timeout);
|
package/dist/build-info.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "2026-11-
|
|
3
|
-
"builtAt": "2026-11-
|
|
4
|
-
"commit": "
|
|
2
|
+
"id": "2026-11-18T08:05:09.559Z-50a8fd73",
|
|
3
|
+
"builtAt": "2026-11-18T08:05:09.559Z",
|
|
4
|
+
"commit": "70dceb4f143198bbc0cd7186dde36323422809db"
|
|
5
5
|
}
|
package/dist/cli/commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Console, Data, Duration, Effect, Option, Path } from 'effect';
|
|
1
|
+
import { Console, Data, Duration, Effect, Option, Path, Schema } from 'effect';
|
|
2
2
|
import { Argument, Command, Flag } from 'effect/cli';
|
|
3
|
-
import { judgedLedger, summaryOf, } from '../schema/index.js';
|
|
3
|
+
import { Findings, JobSpec, judgedLedger, summaryOf, } from '../schema/index.js';
|
|
4
4
|
import { renderPrSummary } from '../report/index.js';
|
|
5
5
|
import { readFindingsFile, readSpecFile } from './config.js';
|
|
6
6
|
import { analyticsEnabled, isCi, isNonInteractive } from './environment.js';
|
|
@@ -96,7 +96,7 @@ const caseResults = (ledger) => ledger.cases.map((c) => ({
|
|
|
96
96
|
}));
|
|
97
97
|
const run = Command.make('run', {
|
|
98
98
|
json,
|
|
99
|
-
spec: Flag.String('spec').pipe(Flag.withDescription('JSON file with the job: url,
|
|
99
|
+
spec: Flag.String('spec').pipe(Flag.withDescription('JSON file with the job: {"version":1,"url":"http://localhost:3000","cases":[{"id":"home-loads","title":"Home page loads","steps":[{"action":"goto","url":"/"},{"action":"expectText","text":"Welcome"}]}]}. `screw-bugs schema job` prints its full JSON Schema: every field and step'), Flag.optional),
|
|
100
100
|
url: Flag.String('url').pipe(Flag.withDescription('URL of the app to test (overrides the URL in --spec)'), Flag.optional),
|
|
101
101
|
device: Flag.ChoiceWithValue('device', [
|
|
102
102
|
['desktop', 'desktop'],
|
|
@@ -165,10 +165,15 @@ const oneLine = (text, max = 100) => {
|
|
|
165
165
|
return flat.length <= max ? flat : `${flat.slice(0, max - 1).trimEnd()}…`;
|
|
166
166
|
};
|
|
167
167
|
const status = Command.make('status', { json, jobId: Argument.String('job-id') }, (flags) => handle(flags.json)(Effect.gen(function* () {
|
|
168
|
-
const { ledger, judged, job, runDir, reportPath, walkthroughPath, evidence, evidencePath } = yield* (yield* Operations).runStatus(flags.jobId);
|
|
168
|
+
const { ledger, judged, job, runDir, reportPath, walkthroughPath, livePath, evidence, evidencePath, } = yield* (yield* Operations).runStatus(flags.jobId);
|
|
169
169
|
const { instructions, title } = job.spec;
|
|
170
170
|
const summary = summaryOf(job.spec);
|
|
171
171
|
const links = yield* pageLinks({ reportPath, walkthroughPath });
|
|
172
|
+
// While the run is going: the page to follow it on.
|
|
173
|
+
const live = yield* pageLink(livePath);
|
|
174
|
+
// A queued or running run gives its ledger.json after its folder, as run_status does.
|
|
175
|
+
const going = ledger.state === 'queued' || ledger.state === 'running';
|
|
176
|
+
const ledgerPath = going ? (yield* Path.Path).join(runDir, 'ledger.json') : undefined;
|
|
172
177
|
yield* flags.json
|
|
173
178
|
? printJson({
|
|
174
179
|
ok: true,
|
|
@@ -183,25 +188,29 @@ const status = Command.make('status', { json, jobId: Argument.String('job-id') }
|
|
|
183
188
|
reportPath,
|
|
184
189
|
walkthroughPath,
|
|
185
190
|
...urlFields(links),
|
|
191
|
+
livePath,
|
|
192
|
+
liveUrl: live?.url,
|
|
186
193
|
})
|
|
187
194
|
: Console.log([
|
|
188
195
|
...(title?.trim() ? [`Title: ${oneLine(title)}`] : []),
|
|
189
196
|
`Summary: ${oneLine(summary.text)}`,
|
|
190
197
|
...(instructions?.trim() ? [`Asked: ${oneLine(instructions)}`] : []),
|
|
191
|
-
countsSentence(judged, links.walkthrough?.kind),
|
|
198
|
+
countsSentence(judged, links.walkthrough?.kind, live?.kind),
|
|
192
199
|
...(ledger.error ? [ledger.error] : []),
|
|
193
200
|
...formatEvidence(judged, evidence),
|
|
194
201
|
runDir,
|
|
202
|
+
...(ledgerPath ? [ledgerPath] : []),
|
|
195
203
|
...(evidencePath ? [evidencePath] : []),
|
|
196
204
|
...(links.report ? [links.report.link] : []),
|
|
197
205
|
...(links.walkthrough ? [links.walkthrough.link] : []),
|
|
206
|
+
...(live ? [live.link] : []),
|
|
198
207
|
].join('\n'));
|
|
199
208
|
}))).pipe(Command.withDescription('Show the state and case results of a run'));
|
|
200
209
|
const portFlag = Flag.Int('port').pipe(Flag.withDescription("Port for --serve, which fails if it is taken (default: the project's port in 41000-41999, else a free one)"), Flag.optional);
|
|
201
210
|
/**
|
|
202
|
-
* Serves the run folders on 127.0.0.1 (the project's port, see
|
|
203
|
-
* the URL of `path`, a page in a run folder; runs until Ctrl+C,
|
|
204
|
-
* already serves them. `report --serve` and `walkthrough --serve` share it.
|
|
211
|
+
* Serves the run folders on 127.0.0.1 or `SCREW_BUGS_REPORT_HOST` (the project's port, see
|
|
212
|
+
* `startReportServer`) and prints the URL of `path`, a page in a run folder; runs until Ctrl+C,
|
|
213
|
+
* unless another screw-bugs process already serves them. `report --serve` and `walkthrough --serve` share it.
|
|
205
214
|
*/
|
|
206
215
|
const serve = (path, portOption, asJson,
|
|
207
216
|
/** More `--json` fields, such as `report`'s `cases`. */
|
|
@@ -238,7 +247,7 @@ const report = Command.make('report', {
|
|
|
238
247
|
['html', 'html'],
|
|
239
248
|
['markdown', 'markdown'],
|
|
240
249
|
]).pipe(Flag.withDescription('html prints the path of the report; markdown prints a pull request summary'), Flag.withDefault('html')),
|
|
241
|
-
serve: Flag.Boolean('serve').pipe(Flag.withDescription('Serve the run folders on 127.0.0.1 and print the report URL, for browsers that cannot open files (such as those built into coding tools); runs until Ctrl+C'), Flag.withDefault(false)),
|
|
250
|
+
serve: Flag.Boolean('serve').pipe(Flag.withDescription('Serve the run folders on 127.0.0.1 (or SCREW_BUGS_REPORT_HOST) and print the report URL, for browsers that cannot open files (such as those built into coding tools); runs until Ctrl+C'), Flag.withDefault(false)),
|
|
242
251
|
port: portFlag,
|
|
243
252
|
}, (flags) => handle(flags.json)(Effect.gen(function* () {
|
|
244
253
|
const { path, bundle, walkthroughPath } = yield* (yield* Operations).report(flags.jobId);
|
|
@@ -269,7 +278,7 @@ const report = Command.make('report', {
|
|
|
269
278
|
const walkthrough = Command.make('walkthrough', {
|
|
270
279
|
json,
|
|
271
280
|
jobId: Argument.String('job-id'),
|
|
272
|
-
serve: Flag.Boolean('serve').pipe(Flag.withDescription('Serve the run folders on 127.0.0.1 and print the walkthrough URL, as report --serve does; runs until Ctrl+C'), Flag.withDefault(false)),
|
|
281
|
+
serve: Flag.Boolean('serve').pipe(Flag.withDescription('Serve the run folders on 127.0.0.1 (or SCREW_BUGS_REPORT_HOST) and print the walkthrough URL, as report --serve does; runs until Ctrl+C'), Flag.withDefault(false)),
|
|
273
282
|
port: portFlag,
|
|
274
283
|
}, (flags) => handle(flags.json)(Effect.gen(function* () {
|
|
275
284
|
const { path, reportPath } = yield* (yield* Operations).walkthrough(flags.jobId);
|
|
@@ -303,7 +312,7 @@ const findings = Command.make('findings', { json, jobId: Argument.String('job-id
|
|
|
303
312
|
...(links.walkthrough ? [links.walkthrough.link] : []),
|
|
304
313
|
...result.annotated,
|
|
305
314
|
].join('\n'));
|
|
306
|
-
}))).pipe(Command.withDescription("Submit an agent's write-up of an ended run (a JSON file, or - for standard input); it is checked, saved and shown in the report (exit 6 if it does not fit the run)"));
|
|
315
|
+
}))).pipe(Command.withDescription("Submit an agent's write-up of an ended run (a JSON file, or - for standard input; `screw-bugs schema findings` prints its JSON Schema); it is checked, saved and shown in the report (exit 6 if it does not fit the run)"));
|
|
307
316
|
const init = Command.make('init', {
|
|
308
317
|
json,
|
|
309
318
|
url: Flag.String('url').pipe(Flag.withDescription('Default URL to test (baseUrl), used when run gets no URL'), Flag.optional),
|
|
@@ -488,6 +497,41 @@ const accountRemove = Command.make('remove', { json, label: Argument.String('lab
|
|
|
488
497
|
: Console.log(`Removed test account ${flags.label} and its session.`);
|
|
489
498
|
}))).pipe(Command.withDescription('Remove a test account and its saved session'));
|
|
490
499
|
const accounts = accountsList.pipe(Command.withDescription('List the test accounts runs can start signed in as; sign in to one, or remove one'), Command.withSubcommands([accountSignIn, accountRemove]));
|
|
500
|
+
/**
|
|
501
|
+
* A `--spec` file as `run` reads it: `run` fills in `version` itself, and the URL may come from
|
|
502
|
+
* `--url` or `baseUrl` in screw-bugs.json instead, so neither is required here.
|
|
503
|
+
*/
|
|
504
|
+
const SpecFile = Schema.Struct({
|
|
505
|
+
...JobSpec.fields,
|
|
506
|
+
version: Schema.optionalKey(JobSpec.fields.version),
|
|
507
|
+
url: Schema.optionalKey(JobSpec.fields.url.annotate({
|
|
508
|
+
description: 'http or https URL of the app to test. Optional here when run gets --url, or screw-bugs.json has baseUrl.',
|
|
509
|
+
})),
|
|
510
|
+
});
|
|
511
|
+
/** The JSON files a caller writes for the CLI, by the name `schema` takes. */
|
|
512
|
+
const FILE_SCHEMAS = {
|
|
513
|
+
job: SpecFile.annotate({
|
|
514
|
+
description: 'A job for `screw-bugs run --spec`. Checked when it runs, beyond this schema: case IDs are ' +
|
|
515
|
+
'unique, also ignoring case; url is http or https; upload paths stay inside the project; ' +
|
|
516
|
+
'lengths count UTF-16 code units, as JavaScript does, so an emoji can count as 2. An error ' +
|
|
517
|
+
'names the field to fix.',
|
|
518
|
+
}),
|
|
519
|
+
findings: Findings.annotate({
|
|
520
|
+
description: 'A write-up for `screw-bugs findings`. Checked against the run when it is submitted, beyond ' +
|
|
521
|
+
'this schema: case IDs, screenshot IDs and timecodes must be ones run_status gave; ' +
|
|
522
|
+
'lengths count UTF-16 code units, as JavaScript does, so an emoji can count as 2. An error ' +
|
|
523
|
+
'lists what to fix.',
|
|
524
|
+
}),
|
|
525
|
+
};
|
|
526
|
+
const schema = Command.make('schema', {
|
|
527
|
+
json,
|
|
528
|
+
file: Argument.Literals('job|findings', ['job', 'findings']),
|
|
529
|
+
},
|
|
530
|
+
// Always JSON, on one line (it is long, and read mostly by agents): --json is accepted like
|
|
531
|
+
// every command's, and changes nothing.
|
|
532
|
+
(flags) => Console.log(JSON.stringify(Schema.toStandardJSONSchemaV1(FILE_SCHEMAS[flags.file])['~standard'].jsonSchema.input({
|
|
533
|
+
target: 'draft-2020-12',
|
|
534
|
+
})))).pipe(Command.withDescription('Print the JSON Schema of a file you write: job (for run --spec) or findings (for findings)'));
|
|
491
535
|
const mcp = Command.make('mcp', {}, () => serveMcp).pipe(Command.withDescription('Serve the screw-bugs MCP server over stdio, for coding agents'));
|
|
492
536
|
const analytics = Command.make('analytics', { json, setting: Argument.String('on|off').pipe(Argument.optional) }, (flags) => handle(flags.json)(Effect.gen(function* () {
|
|
493
537
|
if (Option.isSome(flags.setting))
|
|
@@ -509,6 +553,7 @@ export const root = Command.make('screw-bugs').pipe(Command.withDescription('Loc
|
|
|
509
553
|
report,
|
|
510
554
|
walkthrough,
|
|
511
555
|
findings,
|
|
556
|
+
schema,
|
|
512
557
|
stub('share', 'Share a report through Screw Bugs Cloud'),
|
|
513
558
|
runs,
|
|
514
559
|
analytics,
|
package/dist/cli/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
-
import { Effect, Path } from 'effect';
|
|
2
|
+
import { Duration, Effect, Path } from 'effect';
|
|
3
3
|
import { type CaseLedger, type DoctorReport, type EvidencePack, type JudgedLedger } from '../schema/index.js';
|
|
4
4
|
import { type FindingsResult, Operations } from './operations.js';
|
|
5
5
|
import { PackageInfo } from './package-info.js';
|
|
@@ -9,6 +9,8 @@ export type ShownLedger = CaseLedger | JudgedLedger;
|
|
|
9
9
|
/**
|
|
10
10
|
* `Job … is finished: 3 passed, 2 failed (1 by the agent's review), 0 blocked, 0 not verified.`
|
|
11
11
|
* The counts are the statuses results show: a case the agent's findings mark failed is failed.
|
|
12
|
+
* A running job also says where it is (`progressText`): `Job … is running case 2 of 3
|
|
13
|
+
* (reply-maya), step 4 (click): …`.
|
|
12
14
|
*/
|
|
13
15
|
export declare const formatLedger: (ledger: ShownLedger) => string;
|
|
14
16
|
/** A run counts as passed only when it finished and every case passed. */
|
|
@@ -26,18 +28,23 @@ export declare const formatEvidence: (ledger: ShownLedger, pack: EvidencePack) =
|
|
|
26
28
|
export declare const formatNotPassing: (ledger: ShownLedger) => ReadonlyArray<string>;
|
|
27
29
|
/** How a reply gives the walkthrough: its URL, or its path when there is no URL. */
|
|
28
30
|
export type WalkthroughLink = 'url' | 'path';
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The counts sentence, saying where to watch the run: in its walkthrough, when it has one, or
|
|
33
|
+
* while it is going, in its `live.html` (`live`).
|
|
34
|
+
*/
|
|
35
|
+
export declare const countsSentence: (ledger: ShownLedger, walkthrough: WalkthroughLink | undefined, live?: WalkthroughLink) => string;
|
|
31
36
|
/**
|
|
32
37
|
* A status reply: the counts (and where to watch the run, when it has a walkthrough), then the
|
|
33
38
|
* evidence pack (see `formatEvidence`).
|
|
34
39
|
*/
|
|
35
|
-
export declare const formatStatus: (ledger: ShownLedger, pack?: EvidencePack, walkthrough?: WalkthroughLink) => string;
|
|
40
|
+
export declare const formatStatus: (ledger: ShownLedger, pack?: EvidencePack, walkthrough?: WalkthroughLink, live?: WalkthroughLink) => string;
|
|
36
41
|
/**
|
|
37
42
|
* The reply to saved findings: one sentence (naming the walkthrough as the place to watch the run,
|
|
38
43
|
* when the reply gives it), maybe one about highlights, then the paths.
|
|
39
44
|
*/
|
|
40
45
|
export declare const formatFindings: (result: FindingsResult, walkthrough?: WalkthroughLink) => string;
|
|
46
|
+
/** How often `start_run` sends progress while it waits for a sign-in. */
|
|
47
|
+
export declare const SIGN_IN_PROGRESS_INTERVAL: Duration.Duration;
|
|
41
48
|
/** The MCP server: exactly five tools, each a thin call into `Operations`. */
|
|
42
49
|
export declare const makeMcpServer: Effect.Effect<McpServer, never, Operations | PackageInfo | Path.Path>;
|
|
43
50
|
/** Serves MCP over stdio until the client disconnects. Nothing else may write to stdout. */
|
package/dist/cli/mcp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
|
|
3
|
-
import { Effect, Option, Path, Schema } from 'effect';
|
|
3
|
+
import { Duration, Effect, Option, Path, Schedule, Schema } from 'effect';
|
|
4
4
|
import { describeOnScreen } from '../core/index.js';
|
|
5
5
|
import { LEDGER_FILE } from '../store-local/index.js';
|
|
6
|
-
import { CaseSpec, Device, Findings, JobAccount, REASON_MAX, } from '../schema/index.js';
|
|
7
|
-
import { MAX_WAIT_SECONDS, Operations } from './operations.js';
|
|
6
|
+
import { CaseSpec, Device, Findings, JobAccount, progressText, REASON_MAX, } from '../schema/index.js';
|
|
7
|
+
import { MAX_SIGN_IN_WAIT_SECONDS, MAX_WAIT_SECONDS, Operations, } from './operations.js';
|
|
8
8
|
import { PackageInfo } from './package-info.js';
|
|
9
9
|
import { ReportServer } from './report-server.js';
|
|
10
10
|
import { UpdateCheck } from './update-check.js';
|
|
@@ -17,8 +17,10 @@ import { UpdateCheck } from './update-check.js';
|
|
|
17
17
|
* unusable starts nothing and lists the files needed, one line each (`formatFilesNeeded`), then
|
|
18
18
|
* one sentence asking the agent to create them, then the project folder. start_run whose test
|
|
19
19
|
* account has no session to start from starts nothing either: one sentence, then the link of the
|
|
20
|
-
* sign-in it opened for the user, then `accounts.json
|
|
21
|
-
*
|
|
20
|
+
* sign-in it opened for the user, then `accounts.json`; with `waitSeconds` it first waits for the
|
|
21
|
+
* user to save that sign-in, then starts the run (a normal reply), or says it was cancelled.
|
|
22
|
+
* Wherever the report is given, it is its http://127.0.0.1 URL (or `SCREW_BUGS_REPORT_HOST`'s, see
|
|
23
|
+
* `ReportServer`) in place of
|
|
22
24
|
* its path, for browsers built into coding tools, which cannot open file:// pages and whose file
|
|
23
25
|
* viewers do not play its video; the path only when there is no URL. Then the run's walkthrough
|
|
24
26
|
* (`walkthrough.html`), when it has one, the same way, and the reply's sentence names it as the
|
|
@@ -56,8 +58,14 @@ const failedByAgent = (c) => 'agentFailed' in c ? c.agentFailed : undefined;
|
|
|
56
58
|
/**
|
|
57
59
|
* `Job … is finished: 3 passed, 2 failed (1 by the agent's review), 0 blocked, 0 not verified.`
|
|
58
60
|
* The counts are the statuses results show: a case the agent's findings mark failed is failed.
|
|
61
|
+
* A running job also says where it is (`progressText`): `Job … is running case 2 of 3
|
|
62
|
+
* (reply-maya), step 4 (click): …`.
|
|
59
63
|
*/
|
|
60
|
-
export const formatLedger = (ledger) =>
|
|
64
|
+
export const formatLedger = (ledger) => {
|
|
65
|
+
const where = progressText(ledger);
|
|
66
|
+
return (`Job ${ledger.jobId} is ${ledger.state.replaceAll('_', ' ')}` +
|
|
67
|
+
`${where === undefined ? '' : ` ${where}`}: ${countsText(ledger)}.`);
|
|
68
|
+
};
|
|
61
69
|
/** `3 passed, 2 failed (1 by the agent's review), 0 blocked, 0 not verified`. */
|
|
62
70
|
const countsText = (ledger) => {
|
|
63
71
|
const count = (status) => ledger.cases.filter((c) => c.status === status).length;
|
|
@@ -173,19 +181,25 @@ export const formatEvidence = (ledger, pack) => {
|
|
|
173
181
|
};
|
|
174
182
|
/** One line per case that did not pass, for a run without an evidence pack. */
|
|
175
183
|
export const formatNotPassing = (ledger) => isOver(ledger) ? ledger.cases.filter((c) => c.status !== 'passed').map(caseLine) : [];
|
|
176
|
-
/**
|
|
177
|
-
|
|
184
|
+
/**
|
|
185
|
+
* The counts sentence, saying where to watch the run: in its walkthrough, when it has one, or
|
|
186
|
+
* while it is going, in its `live.html` (`live`).
|
|
187
|
+
*/
|
|
188
|
+
export const countsSentence = (ledger, walkthrough, live) => {
|
|
178
189
|
const counts = formatLedger(ledger);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
const below = (link) => `(the ${link === 'url' ? 'URL' : 'path'} below)`;
|
|
191
|
+
return walkthrough !== undefined
|
|
192
|
+
? `${trimPeriod(counts)}; watch it step by step in walkthrough.html ${below(walkthrough)}.`
|
|
193
|
+
: live !== undefined
|
|
194
|
+
? `${trimPeriod(counts)}; follow it as it runs in live.html ${below(live)}.`
|
|
195
|
+
: counts;
|
|
182
196
|
};
|
|
183
197
|
/**
|
|
184
198
|
* A status reply: the counts (and where to watch the run, when it has a walkthrough), then the
|
|
185
199
|
* evidence pack (see `formatEvidence`).
|
|
186
200
|
*/
|
|
187
|
-
export const formatStatus = (ledger, pack, walkthrough) => [
|
|
188
|
-
countsSentence(ledger, walkthrough),
|
|
201
|
+
export const formatStatus = (ledger, pack, walkthrough, live) => [
|
|
202
|
+
countsSentence(ledger, walkthrough, live),
|
|
189
203
|
...(pack ? formatEvidence(ledger, pack) : formatNotPassing(ledger)),
|
|
190
204
|
].join('\n');
|
|
191
205
|
/** Highlights that could not be drawn, for the agent to name better and submit again. */
|
|
@@ -252,6 +266,8 @@ const StartRunInput = Schema.Struct({
|
|
|
252
266
|
'{"action":"goto","url":"/login"}, ' +
|
|
253
267
|
'{"action":"fill","target":{"label":"Email"},"value":"a@b.co"}, ' +
|
|
254
268
|
'{"action":"click","target":{"role":"button","name":"Sign in"}}, ' +
|
|
269
|
+
'{"action":"hover","target":{"text":"Hi there"}} (moves the pointer over it, for controls ' +
|
|
270
|
+
"that only show on hover, such as a message's Reply button; it stays there), " +
|
|
255
271
|
'{"action":"press","key":"Enter"}, {"action":"expectText","text":"Welcome"}, ' +
|
|
256
272
|
'{"action":"expectNoText","text":"Acme"} (passes when it does not show as text, image ' +
|
|
257
273
|
'alt text or ARIA label, in the page and its frames, or with frame or target only there), ' +
|
|
@@ -291,12 +307,22 @@ const StartRunInput = Schema.Struct({
|
|
|
291
307
|
'accounts are saved (for public pages, the sign-up or sign-in flow itself, or what a ' +
|
|
292
308
|
'visitor sees). Give it to run signed in as a test account: ' +
|
|
293
309
|
'the label of one in .screw-bugs/accounts.json (in the ' +
|
|
294
|
-
'project; read it to pick the one whose about fits, such as a user on a trial or a
|
|
295
|
-
'one), or {"label":"paid-user","about":"Pro plan, paying monthly"} for one the
|
|
296
|
-
|
|
297
|
-
'origin, nothing starts and the reply gives a link:
|
|
298
|
-
'start the same job again
|
|
299
|
-
'
|
|
310
|
+
'project; read it first, to pick the one whose about fits, such as a user on a trial or a ' +
|
|
311
|
+
'paying one), or {"label":"paid-user","about":"Pro plan, paying monthly"} for one the ' +
|
|
312
|
+
'user signs in to first. Every case starts signed in. When it has no saved session for ' +
|
|
313
|
+
"this URL's origin, nothing starts and the reply gives a link: show it to the user, who " +
|
|
314
|
+
'signs in there, then start the same job again (with waitSeconds to wait for the save). ' +
|
|
315
|
+
'The sign-in opens the app at once, so when the account the cases need is not in ' +
|
|
316
|
+
'accounts.json, get the app running and that user in place first, then start the job ' +
|
|
317
|
+
'before the rest of your preparation, and the user signs in while you prepare. If its ' +
|
|
318
|
+
'session stopped working (the run lands on a sign-in page), give ' +
|
|
319
|
+
'{"label":…,"renew":true} once to have the user sign in again.',
|
|
320
|
+
})),
|
|
321
|
+
waitSeconds: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: MAX_SIGN_IN_WAIT_SECONDS })).annotate({
|
|
322
|
+
description: `0-${MAX_SIGN_IN_WAIT_SECONDS}, default 0. If the account still needs the user to sign ` +
|
|
323
|
+
'in, wait up to this many seconds for them to press Save sign-in, then start the run. ' +
|
|
324
|
+
'The link reaches the user only in a reply, so first call with 0 to get it and show it, ' +
|
|
325
|
+
'then call again with waitSeconds.',
|
|
300
326
|
})),
|
|
301
327
|
});
|
|
302
328
|
const RunStatusInput = Schema.Struct({
|
|
@@ -325,6 +351,34 @@ const AnswerQuestionInput = Schema.Struct({
|
|
|
325
351
|
questionId: Schema.NonEmptyString,
|
|
326
352
|
answer: Schema.String,
|
|
327
353
|
});
|
|
354
|
+
/** How often `start_run` sends progress while it waits for a sign-in. */
|
|
355
|
+
export const SIGN_IN_PROGRESS_INTERVAL = Duration.seconds(15);
|
|
356
|
+
/**
|
|
357
|
+
* While `start_run` waits for a sign-in, a progress notification with the link every
|
|
358
|
+
* `SIGN_IN_PROGRESS_INTERVAL`, when the client asked for progress (`progressToken`). Clients that
|
|
359
|
+
* time a call out unless it makes progress keep waiting; Claude Code shows the message as the
|
|
360
|
+
* tool's one-line status, which may cut the link, so the reply that gives it stays the way to
|
|
361
|
+
* reach the user.
|
|
362
|
+
*/
|
|
363
|
+
const signInProgress = (request) => (wait) => {
|
|
364
|
+
const token = request._meta?.progressToken;
|
|
365
|
+
if (token === undefined)
|
|
366
|
+
return Effect.void;
|
|
367
|
+
let progress = 0;
|
|
368
|
+
// Boundary: the MCP SDK sends notifications through promises.
|
|
369
|
+
const send = Effect.promise(() => request
|
|
370
|
+
.notify({
|
|
371
|
+
method: 'notifications/progress',
|
|
372
|
+
params: {
|
|
373
|
+
progressToken: token,
|
|
374
|
+
progress: ++progress,
|
|
375
|
+
message: `Waiting for the user to sign in to test account "${wait.label}" and press ` +
|
|
376
|
+
`Save sign-in: ${wait.link}`,
|
|
377
|
+
},
|
|
378
|
+
})
|
|
379
|
+
.catch(() => undefined));
|
|
380
|
+
return send.pipe(Effect.repeat(Schedule.spaced(SIGN_IN_PROGRESS_INTERVAL)), Effect.asVoid);
|
|
381
|
+
};
|
|
328
382
|
/** The MCP server: exactly five tools, each a thin call into `Operations`. */
|
|
329
383
|
export const makeMcpServer = Effect.gen(function* () {
|
|
330
384
|
const ops = yield* Operations;
|
|
@@ -354,7 +408,9 @@ export const makeMcpServer = Effect.gen(function* () {
|
|
|
354
408
|
// Boundary: the MCP SDK calls tools through promises. Each call runs with the services this
|
|
355
409
|
// server was made with (clock, config, logger), not a fresh default runtime.
|
|
356
410
|
const runPromise = Effect.runPromiseWith(yield* Effect.context());
|
|
357
|
-
const run = (effect, onSuccess
|
|
411
|
+
const run = (effect, onSuccess,
|
|
412
|
+
// Interrupts the call when the client cancels it (or times it out), so nothing starts unseen.
|
|
413
|
+
signal) => runPromise(effect.pipe(Effect.match({ onFailure: replyFailure, onSuccess })), signal ? { signal } : undefined);
|
|
358
414
|
const server = new McpServer({ name, version }, instructions ? { instructions } : undefined);
|
|
359
415
|
server.registerTool('doctor', {
|
|
360
416
|
description: 'Check this machine can run screw-bugs: Node, a browser, disk space and updates.',
|
|
@@ -362,13 +418,18 @@ export const makeMcpServer = Effect.gen(function* () {
|
|
|
362
418
|
server.registerTool('start_run', {
|
|
363
419
|
description: 'Run your QA cases (structured steps) in a headless browser; returns a job ID immediately. Upload files are yours to create in the project (such as fixtures/), with synthetic content.',
|
|
364
420
|
inputSchema: input(StartRunInput),
|
|
365
|
-
}, (
|
|
421
|
+
}, ({ waitSeconds, ...spec }, ctx) => run(ops.startRun({ spec }, {
|
|
422
|
+
requireConfig: false,
|
|
423
|
+
signIn: 'serve',
|
|
424
|
+
waitSeconds,
|
|
425
|
+
onSignInWait: signInProgress(ctx.mcpReq),
|
|
426
|
+
}), ({ jobId, runDir }) => reply(`Started job ${jobId}; check it with run_status.`, [runDir]), ctx.mcpReq.signal));
|
|
366
427
|
server.registerTool('run_status', {
|
|
367
|
-
description: 'Get the state and case results of a run by job ID; an ended run
|
|
428
|
+
description: 'Get the state and case results of a run by job ID; a running run gives a live page URL, an ended run its report and video walkthrough URLs.',
|
|
368
429
|
inputSchema: input(RunStatusInput),
|
|
369
430
|
}, ({ jobId, waitSeconds }) => run(ops
|
|
370
431
|
.runStatus(jobId, { waitSeconds })
|
|
371
|
-
.pipe(Effect.flatMap((status) => reportLinks(status).pipe(Effect.map((report) => ({ ...status, report }))))), ({ ledger, judged, runDir, report, evidence, evidencePath }) => reply(formatStatus(judged, evidence, report.walkthrough), [
|
|
432
|
+
.pipe(Effect.flatMap((status) => Effect.all({ report: reportLinks(status), live: pageLink(status.livePath) }).pipe(Effect.map(({ report, live }) => ({ ...status, report, live }))))), ({ ledger, judged, runDir, report, live, evidence, evidencePath }) => reply(formatStatus(judged, evidence, report.walkthrough, live?.kind), [
|
|
372
433
|
runDir,
|
|
373
434
|
path.join(runDir, LEDGER_FILE),
|
|
374
435
|
...(evidencePath ? [evidencePath] : []),
|
|
@@ -378,6 +439,8 @@ export const makeMcpServer = Effect.gen(function* () {
|
|
|
378
439
|
? evidence.videos.flatMap((v) => v.path !== undefined && isOver(ledger) ? [path.join(runDir, v.path)] : [])
|
|
379
440
|
: []),
|
|
380
441
|
...report.links,
|
|
442
|
+
// While the run is going: the page to follow it on.
|
|
443
|
+
...(live ? [live.link] : []),
|
|
381
444
|
])));
|
|
382
445
|
server.registerTool('submit_findings', {
|
|
383
446
|
description: 'Submit your write-up of an ended run; screw-bugs checks it and re-renders the report.',
|