screw-bugs 0.1.5 → 0.1.7
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 +23 -6
- package/dist/browser-playwright/launch.d.ts +4 -2
- package/dist/browser-playwright/launch.js +8 -1
- package/dist/browser-playwright/still.d.ts +12 -0
- package/dist/browser-playwright/still.js +51 -0
- package/dist/build-info.json +3 -3
- package/dist/cli/app.d.ts +1 -1
- package/dist/cli/commands.js +45 -20
- package/dist/cli/mcp.d.ts +13 -7
- package/dist/cli/mcp.js +55 -12
- package/dist/cli/operations.d.ts +12 -2
- package/dist/cli/operations.js +20 -2
- package/dist/cli/share.js +10 -10
- package/dist/core/engine.js +22 -7
- package/dist/core/services.d.ts +6 -1
- package/dist/core/video.d.ts +31 -0
- package/dist/core/video.js +132 -0
- package/dist/report/html.d.ts +1 -1
- package/dist/report/html.js +38 -11
- package/dist/report/menu-bar.js +1 -1
- package/dist/report/player.d.ts +18 -2
- package/dist/report/player.js +54 -5
- package/dist/report/pr-summary.d.ts +1 -1
- package/dist/report/pr-summary.js +13 -4
- package/dist/report/sign-in.d.ts +1 -1
- package/dist/report/sign-in.js +37 -8
- package/dist/report/styles.js +8 -0
- package/dist/report/view.d.ts +25 -5
- package/dist/report/view.js +74 -30
- package/dist/report/walkthrough.d.ts +5 -3
- package/dist/report/walkthrough.js +29 -12
- package/dist/schema/evidence.d.ts +15 -0
- package/dist/schema/evidence.js +8 -0
- package/dist/schema/findings.d.ts +2 -0
- package/dist/schema/findings.js +8 -2
- package/dist/schema/ledger.d.ts +38 -0
- package/dist/schema/ledger.js +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -184,6 +184,7 @@ fixed slots with short texts:
|
|
|
184
184
|
"did": ["Signed in with a wrong password."],
|
|
185
185
|
"worked": ["The form stayed filled in."],
|
|
186
186
|
"didnt": ["No error message appeared."],
|
|
187
|
+
"failed": "A wrong password gets no error, so users cannot tell what happened.",
|
|
187
188
|
"highlights": [
|
|
188
189
|
{
|
|
189
190
|
"shot": "02-02",
|
|
@@ -203,7 +204,21 @@ fixed slots with short texts:
|
|
|
203
204
|
|
|
204
205
|
Case IDs, screenshot IDs and timecodes must be ones `run_status` gave for that case; findings that
|
|
205
206
|
do not fit are rejected with one line per problem saying what to change (exit code 6), and nothing
|
|
206
|
-
is saved.
|
|
207
|
+
is saved. A case named that does not exist is one of those problems.
|
|
208
|
+
|
|
209
|
+
Code sets each case's status; findings can only mark a case failed, never make one pass. Give a
|
|
210
|
+
case `failed` (one line saying what is wrong) whenever your own evidence (the app's database, its
|
|
211
|
+
logs, the screenshots, the video) shows it did not do what its `success` says, even if every check
|
|
212
|
+
passed, such as a chat reply that claims the right persona's name but comes from another one.
|
|
213
|
+
Minor things that did not work go in `didnt`, which never fails a case. A case marked failed then
|
|
214
|
+
counts as failed everywhere results are shown: the report's card (failed, labelled as the agent's
|
|
215
|
+
verdict, with its reason and the code's result beside it, such as "Checks passed") and its counts,
|
|
216
|
+
the walkthrough, the PR summary, the `submit_findings` reply, `run_status` (`2 failed (1 by the
|
|
217
|
+
agent's review)`, with the case listed among the failures) and the CLI's `status`, `findings`,
|
|
218
|
+
`report` and `runs` (`--json`: `cases`, each with its `status` as shown, the code's `checkStatus`
|
|
219
|
+
and `agentFailed`). `ledger.json` and `evidence.json` keep the code's statuses.
|
|
220
|
+
|
|
221
|
+
A highlight names an element like a step `target`; code
|
|
207
222
|
finds it in the page state saved with that screenshot and draws the box: red for a problem, green
|
|
208
223
|
for what is as expected. One it cannot place unambiguously is reported in words, never guessed;
|
|
209
224
|
so is one on a page with more elements than were saved with the screenshot, unless none of those
|
|
@@ -252,6 +267,7 @@ Limits (each text is one line, not blank; findings past them are rejected with w
|
|
|
252
267
|
| `fixes` | at most 10; `title` 120 characters, `why` 240, `caseIds` 1 to 10 |
|
|
253
268
|
| `cases` | at most 100 |
|
|
254
269
|
| `did`, `worked`, `didnt` (per case) | at most 8 lines each, 160 characters a line |
|
|
270
|
+
| `failed` (per case) | 160 characters |
|
|
255
271
|
| `highlights` (per case) | at most 6; `note` 120 characters |
|
|
256
272
|
| `keyMoments` (per case) | at most 8; `label` 80 characters |
|
|
257
273
|
| `observed` (per case) | at most 5 lines, 200 characters a line |
|
|
@@ -738,7 +754,7 @@ npx screw-bugs accounts sign-in trial-user --url http://localhost:3000 --about "
|
|
|
738
754
|
| `report <job-id> --serve [--port N]` | Serve the report at a `http://127.0.0.1` URL |
|
|
739
755
|
| `walkthrough <job-id> [--serve]` | Write (or serve) the run's video walkthrough |
|
|
740
756
|
| `findings <job-id> <file\|->` | Submit an agent's write-up of an ended run |
|
|
741
|
-
| `share <job-id>` | Share a report through
|
|
757
|
+
| `share <job-id>` | Share a report through Screw Bugs Cloud |
|
|
742
758
|
| `runs` | List recent runs |
|
|
743
759
|
| `analytics` | Show whether analytics are on (off by default) |
|
|
744
760
|
|
|
@@ -796,8 +812,9 @@ arrow keys step through the case's screenshots. "Steps and details" opens the ca
|
|
|
796
812
|
their timecodes and the agent's write-up of it. Then what to test next, and the run's details
|
|
797
813
|
(what it checks, target, times, video, version, raw files). Scrolling the cases drives the player:
|
|
798
814
|
the case at the reading line plays, in a loop unless "Loop case" is off, when the cases follow the
|
|
799
|
-
video instead. Code lays out the page and decides every status
|
|
800
|
-
|
|
815
|
+
video instead. Code lays out the page and decides every status, except that the agent's write-up
|
|
816
|
+
may mark a case failed (its card then says so, as the agent's verdict, beside the code's result);
|
|
817
|
+
the write-up fills fixed slots and is labelled as its own.
|
|
801
818
|
|
|
802
819
|
It is one self-contained file: inline styles and one inline script allowed by its hash in the
|
|
803
820
|
Content Security Policy. The only thing it loads from the network is Geist and Geist Mono from
|
|
@@ -840,7 +857,7 @@ reports](#viewing-reports)).
|
|
|
840
857
|
With `report.html`, the run writes `walkthrough.html`: a page to click through what the run did. The
|
|
841
858
|
video in a browser window (a phone, for a run on a phone, with the script beside it on a wide
|
|
842
859
|
screen) with the page's address at each moment, controls under it (speed, "Skip inactive" to jump
|
|
843
|
-
over stretches where
|
|
860
|
+
over stretches where nothing happened, the cursor overlay, fullscreen), and below it the script: every
|
|
844
861
|
step of every case in run order, grouped by case (its title and status), each with its timecode
|
|
845
862
|
and the step in words (`0:01.5 Fill the field labelled "Note" with "this is a new line"`). As the
|
|
846
863
|
video plays, the step playing now is the script's top row, highlighted (without motion when the
|
|
@@ -983,7 +1000,7 @@ The one other thing they answer is the Share button's routes, under `/.screw-bug
|
|
|
983
1000
|
### Sharing
|
|
984
1001
|
|
|
985
1002
|
A report or walkthrough opened through the report server (its `http://127.0.0.1` URL) has a
|
|
986
|
-
**Share** button that puts the run on
|
|
1003
|
+
**Share** button that puts the run on Screw Bugs Cloud: a link anyone can open for 7 days. Opened
|
|
987
1004
|
from disk, or on Cloud itself, the page has no server to share it, so the button is not there.
|
|
988
1005
|
|
|
989
1006
|
1. Share sends the browser to `screwbugs.dev`, which signs you in with GitHub and shows what will
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Effect, FileSystem, Layer, Path } from 'effect';
|
|
2
|
+
import { ChildProcessSpawner } from 'effect/process';
|
|
2
3
|
import { Browser } from '../core/index.js';
|
|
3
4
|
/**
|
|
4
5
|
* Launches the installed Chrome, else Edge, else Playwright's downloaded Chromium. Needs the
|
|
5
|
-
* platform (`FileSystem`, `Path`) to find Playwright's ffmpeg
|
|
6
|
+
* platform (`FileSystem`, `Path`) to find Playwright's ffmpeg, and `ChildProcessSpawner` to run it
|
|
7
|
+
* over saved videos (`stillVideo`).
|
|
6
8
|
*/
|
|
7
|
-
export declare const BrowserPlaywright: Layer.Layer<Browser, never, FileSystem.FileSystem | Path.Path>;
|
|
9
|
+
export declare const BrowserPlaywright: Layer.Layer<Browser, never, ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path>;
|
|
8
10
|
/**
|
|
9
11
|
* Downloads the Chromium build that matches the bundled Playwright. Pinned to our version so the
|
|
10
12
|
* browser revision is the one we look for.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Effect, FileSystem, Layer, Path, Schema } from 'effect';
|
|
2
|
+
import { ChildProcessSpawner } from 'effect/process';
|
|
2
3
|
import { chromium } from 'playwright-core';
|
|
3
4
|
import { Browser, BrowserNotFound } from '../core/index.js';
|
|
4
5
|
import { annotateAll } from './annotate.js';
|
|
6
|
+
import { stillVideo } from './still.js';
|
|
5
7
|
import { signInBrowser } from './sign-in.js';
|
|
6
8
|
import { deviceLabel, newSession } from './page.js';
|
|
7
9
|
/** Order matters: prefer what the user already has installed. */
|
|
@@ -50,11 +52,13 @@ const open = (options) => launchAny(options.headed).pipe(Effect.map(({ candidate
|
|
|
50
52
|
})));
|
|
51
53
|
/**
|
|
52
54
|
* Launches the installed Chrome, else Edge, else Playwright's downloaded Chromium. Needs the
|
|
53
|
-
* platform (`FileSystem`, `Path`) to find Playwright's ffmpeg
|
|
55
|
+
* platform (`FileSystem`, `Path`) to find Playwright's ffmpeg, and `ChildProcessSpawner` to run it
|
|
56
|
+
* over saved videos (`stillVideo`).
|
|
54
57
|
*/
|
|
55
58
|
export const BrowserPlaywright = Layer.effect(Browser, Effect.gen(function* () {
|
|
56
59
|
const fs = yield* FileSystem.FileSystem;
|
|
57
60
|
const path = yield* Path.Path;
|
|
61
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
58
62
|
const videoSupport = Effect.gen(function* () {
|
|
59
63
|
const lookup = yield* findFfmpeg;
|
|
60
64
|
if (lookup.found)
|
|
@@ -64,6 +68,9 @@ export const BrowserPlaywright = Layer.effect(Browser, Effect.gen(function* () {
|
|
|
64
68
|
return {
|
|
65
69
|
detect: Effect.scoped(open({ headed: false })).pipe(Effect.map((session) => session.info)),
|
|
66
70
|
videoSupport,
|
|
71
|
+
stillVideo: (file) => findFfmpeg.pipe(Effect.flatMap((lookup) => lookup.found && lookup.path !== undefined
|
|
72
|
+
? stillVideo(lookup.path, file)
|
|
73
|
+
: Effect.succeed(undefined)), Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(Path.Path, path), Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner)),
|
|
67
74
|
open,
|
|
68
75
|
deviceLabel,
|
|
69
76
|
annotate: (jobs) => Effect.scoped(launchAny(false).pipe(Effect.flatMap(({ browser }) => annotateAll(browser, jobs)))),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Effect, FileSystem, Path } from 'effect';
|
|
2
|
+
import { ChildProcessSpawner } from 'effect/process';
|
|
3
|
+
import type { StillStretch } from '../schema/index.js';
|
|
4
|
+
/** How long measuring one video may take before it is given up (the run waits for it). */
|
|
5
|
+
export declare const STILL_TIMEOUT = "2 minutes";
|
|
6
|
+
/**
|
|
7
|
+
* Where the video at `file` stands still: Playwright's ffmpeg (at `ffmpeg`, the one that recorded it) writes it
|
|
8
|
+
* as small grey PNG frames into a temporary folder, removed afterwards, and `stillStretches`
|
|
9
|
+
* compares them. Undefined when ffmpeg fails, takes longer than `STILL_TIMEOUT`, or
|
|
10
|
+
* writes frames that cannot be read. Never changes the video.
|
|
11
|
+
*/
|
|
12
|
+
export declare const stillVideo: (ffmpeg: string, file: string) => Effect.Effect<ReadonlyArray<StillStretch> | undefined, never, FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { inflateSync } from 'node:zlib';
|
|
2
|
+
import { Effect, FileSystem, Path } from 'effect';
|
|
3
|
+
import { ChildProcess, ChildProcessSpawner } from 'effect/process';
|
|
4
|
+
import { grayPng, STILL_FPS, STILL_WIDTH, stillStretches } from '../core/index.js';
|
|
5
|
+
/** How long measuring one video may take before it is given up (the run waits for it). */
|
|
6
|
+
export const STILL_TIMEOUT = '2 minutes';
|
|
7
|
+
/**
|
|
8
|
+
* Boundary: zlib has no Effect service, and PNG frames are zlib-compressed. Only ever given the
|
|
9
|
+
* small frames ffmpeg wrote for `stillVideo`.
|
|
10
|
+
*/
|
|
11
|
+
const inflate = (data) => inflateSync(data);
|
|
12
|
+
/**
|
|
13
|
+
* Where the video at `file` stands still: Playwright's ffmpeg (at `ffmpeg`, the one that recorded it) writes it
|
|
14
|
+
* as small grey PNG frames into a temporary folder, removed afterwards, and `stillStretches`
|
|
15
|
+
* compares them. Undefined when ffmpeg fails, takes longer than `STILL_TIMEOUT`, or
|
|
16
|
+
* writes frames that cannot be read. Never changes the video.
|
|
17
|
+
*/
|
|
18
|
+
export const stillVideo = (ffmpeg, file) => Effect.scoped(Effect.gen(function* () {
|
|
19
|
+
const fs = yield* FileSystem.FileSystem;
|
|
20
|
+
const path = yield* Path.Path;
|
|
21
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
22
|
+
const dir = yield* fs.makeTempDirectoryScoped({ prefix: 'screw-bugs-still-' });
|
|
23
|
+
const code = yield* spawner.exitCode(ChildProcess.make(ffmpeg, [
|
|
24
|
+
'-hide_banner',
|
|
25
|
+
'-loglevel',
|
|
26
|
+
'error',
|
|
27
|
+
'-nostdin',
|
|
28
|
+
'-i',
|
|
29
|
+
file,
|
|
30
|
+
'-vf',
|
|
31
|
+
`scale=${STILL_WIDTH}:-2`,
|
|
32
|
+
'-r',
|
|
33
|
+
String(STILL_FPS),
|
|
34
|
+
'-pix_fmt',
|
|
35
|
+
'gray',
|
|
36
|
+
'-f',
|
|
37
|
+
'image2',
|
|
38
|
+
path.join(dir, 'f%06d.png'),
|
|
39
|
+
], { stdin: 'ignore', stdout: 'ignore', stderr: 'ignore' }));
|
|
40
|
+
if (code !== 0)
|
|
41
|
+
return undefined;
|
|
42
|
+
const names = (yield* fs.readDirectory(dir)).filter((n) => n.endsWith('.png')).toSorted();
|
|
43
|
+
const frames = [];
|
|
44
|
+
for (const name of names) {
|
|
45
|
+
const image = grayPng(yield* fs.readFile(path.join(dir, name)), inflate);
|
|
46
|
+
if (image === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
frames.push(image);
|
|
49
|
+
}
|
|
50
|
+
return frames.length === 0 ? undefined : stillStretches(frames, 1000 / STILL_FPS);
|
|
51
|
+
})).pipe(Effect.timeout(STILL_TIMEOUT), Effect.orElseSucceed(() => undefined));
|
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-13T20:15:56.148Z-adc7b8b2",
|
|
3
|
+
"builtAt": "2026-11-13T20:15:56.148Z",
|
|
4
|
+
"commit": "3059253e41bf40735ac3344abd03346997e55dfb"
|
|
5
5
|
}
|
package/dist/cli/app.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const appLayer: (projectRoot: string) => Layer.Layer<Operations |
|
|
|
18
18
|
* What the detached report server (`serveDetached`) shares runs with: the engine of the project whose
|
|
19
19
|
* folder is `projectRoot`.
|
|
20
20
|
*/
|
|
21
|
-
export declare const detachedShareLayer: (projectRoot: string) => Layer.Layer<ShareSource, never, import("effect/FileSystem").FileSystem | Path.Path>;
|
|
21
|
+
export declare const detachedShareLayer: (projectRoot: string) => Layer.Layer<ShareSource, never, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | Path.Path>;
|
|
22
22
|
/**
|
|
23
23
|
* Runs the CLI and resolves to the process exit code. A due update check started with it gets
|
|
24
24
|
* the rest of its time after the command has written everything; it never changes the code.
|
package/dist/cli/commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Console, Data, Duration, Effect, Option, Path } from 'effect';
|
|
2
2
|
import { Argument, Command, Flag } from 'effect/cli';
|
|
3
|
-
import { summaryOf } from '../schema/index.js';
|
|
3
|
+
import { 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';
|
|
@@ -79,8 +79,21 @@ const formatLedgerHuman = (ledger, walkthrough) => [
|
|
|
79
79
|
countsSentence(ledger, walkthrough),
|
|
80
80
|
...(ledger.error ? [ledger.error] : []),
|
|
81
81
|
...ledger.cases.map((c) => `${statusMark[c.status]} ${c.id} ${c.status.replace('_', ' ')}` +
|
|
82
|
+
(c.agentFailed !== undefined
|
|
83
|
+
? ` by the agent's review: ${c.agentFailed} (checks ${c.checkStatus.replace('_', ' ')})`
|
|
84
|
+
: '') +
|
|
82
85
|
(c.status !== 'passed' && c.reason ? `: ${c.reason}` : '')),
|
|
83
86
|
].join('\n');
|
|
87
|
+
/**
|
|
88
|
+
* The `--json` field `cases`: each case's status as results show it (after the agent's findings,
|
|
89
|
+
* see `judgedLedger`), beside the code's (`checkStatus`, as `ledger` keeps it).
|
|
90
|
+
*/
|
|
91
|
+
const caseResults = (ledger) => ledger.cases.map((c) => ({
|
|
92
|
+
id: c.id,
|
|
93
|
+
status: c.status,
|
|
94
|
+
checkStatus: c.checkStatus,
|
|
95
|
+
...(c.agentFailed !== undefined ? { agentFailed: c.agentFailed } : {}),
|
|
96
|
+
}));
|
|
84
97
|
const run = Command.make('run', {
|
|
85
98
|
json,
|
|
86
99
|
spec: Flag.String('spec').pipe(Flag.withDescription('JSON file with the job: url, plus optional cases and their steps'), Flag.optional),
|
|
@@ -105,7 +118,7 @@ const run = Command.make('run', {
|
|
|
105
118
|
}, { requireConfig: yield* isNonInteractive });
|
|
106
119
|
if (!flags.json)
|
|
107
120
|
yield* Console.log(`Running job ${jobId}...`);
|
|
108
|
-
const { ledger, reportPath, walkthroughPath } = yield* ops.awaitRun(jobId).pipe(
|
|
121
|
+
const { ledger, judged, reportPath, walkthroughPath } = yield* ops.awaitRun(jobId).pipe(
|
|
109
122
|
// Stops the run here rather than when the engine shuts down, so the message can give
|
|
110
123
|
// the report path once the final report is written.
|
|
111
124
|
Effect.onInterrupt(() => Effect.gen(function* () {
|
|
@@ -123,7 +136,7 @@ const run = Command.make('run', {
|
|
|
123
136
|
})
|
|
124
137
|
: Console.error([`screw-bugs: ${message}`, ...(reportPath ? [reportPath] : [])].join('\n'));
|
|
125
138
|
})));
|
|
126
|
-
const passed = allPassed(
|
|
139
|
+
const passed = allPassed(judged);
|
|
127
140
|
const links = yield* pageLinks({ reportPath, walkthroughPath });
|
|
128
141
|
yield* flags.json
|
|
129
142
|
? printJson({
|
|
@@ -133,10 +146,11 @@ const run = Command.make('run', {
|
|
|
133
146
|
reportPath,
|
|
134
147
|
walkthroughPath,
|
|
135
148
|
...urlFields(links),
|
|
149
|
+
cases: caseResults(judged),
|
|
136
150
|
ledger,
|
|
137
151
|
})
|
|
138
152
|
: Console.log([
|
|
139
|
-
formatLedgerHuman(
|
|
153
|
+
formatLedgerHuman(judged, links.walkthrough?.kind),
|
|
140
154
|
runDir,
|
|
141
155
|
links.report?.link ??
|
|
142
156
|
`report.html could not be written; try \`screw-bugs report ${jobId}\`.`,
|
|
@@ -151,7 +165,7 @@ const oneLine = (text, max = 100) => {
|
|
|
151
165
|
return flat.length <= max ? flat : `${flat.slice(0, max - 1).trimEnd()}…`;
|
|
152
166
|
};
|
|
153
167
|
const status = Command.make('status', { json, jobId: Argument.String('job-id') }, (flags) => handle(flags.json)(Effect.gen(function* () {
|
|
154
|
-
const { ledger, job, runDir, reportPath, walkthroughPath, evidence, evidencePath } = yield* (yield* Operations).runStatus(flags.jobId);
|
|
168
|
+
const { ledger, judged, job, runDir, reportPath, walkthroughPath, evidence, evidencePath } = yield* (yield* Operations).runStatus(flags.jobId);
|
|
155
169
|
const { instructions, title } = job.spec;
|
|
156
170
|
const summary = summaryOf(job.spec);
|
|
157
171
|
const links = yield* pageLinks({ reportPath, walkthroughPath });
|
|
@@ -161,6 +175,7 @@ const status = Command.make('status', { json, jobId: Argument.String('job-id') }
|
|
|
161
175
|
title,
|
|
162
176
|
summary,
|
|
163
177
|
instructions,
|
|
178
|
+
cases: caseResults(judged),
|
|
164
179
|
ledger,
|
|
165
180
|
evidence,
|
|
166
181
|
runDir,
|
|
@@ -173,9 +188,9 @@ const status = Command.make('status', { json, jobId: Argument.String('job-id') }
|
|
|
173
188
|
...(title?.trim() ? [`Title: ${oneLine(title)}`] : []),
|
|
174
189
|
`Summary: ${oneLine(summary.text)}`,
|
|
175
190
|
...(instructions?.trim() ? [`Asked: ${oneLine(instructions)}`] : []),
|
|
176
|
-
countsSentence(
|
|
191
|
+
countsSentence(judged, links.walkthrough?.kind),
|
|
177
192
|
...(ledger.error ? [ledger.error] : []),
|
|
178
|
-
...formatEvidence(
|
|
193
|
+
...formatEvidence(judged, evidence),
|
|
179
194
|
runDir,
|
|
180
195
|
...(evidencePath ? [evidencePath] : []),
|
|
181
196
|
...(links.report ? [links.report.link] : []),
|
|
@@ -188,7 +203,9 @@ const portFlag = Flag.Int('port').pipe(Flag.withDescription("Port for --serve, w
|
|
|
188
203
|
* the URL of `path`, a page in a run folder; runs until Ctrl+C, unless another screw-bugs process
|
|
189
204
|
* already serves them. `report --serve` and `walkthrough --serve` share it.
|
|
190
205
|
*/
|
|
191
|
-
const serve = (path, portOption, asJson
|
|
206
|
+
const serve = (path, portOption, asJson,
|
|
207
|
+
/** More `--json` fields, such as `report`'s `cases`. */
|
|
208
|
+
extra = {}) => Effect.gen(function* () {
|
|
192
209
|
const port = Option.getOrUndefined(portOption);
|
|
193
210
|
if (port !== undefined && (!Number.isInteger(port) || port < 0 || port > 65535)) {
|
|
194
211
|
return yield* usage(`--port must be 0-65535, not ${port}.`);
|
|
@@ -202,7 +219,7 @@ const serve = (path, portOption, asJson) => Effect.gen(function* () {
|
|
|
202
219
|
const reused = served.on === 'reused';
|
|
203
220
|
const url = fileUrl(paths, base, root, path) ?? base;
|
|
204
221
|
yield* asJson
|
|
205
|
-
? printJson({ url, ok: true, path, reused })
|
|
222
|
+
? printJson({ url, ok: true, path, reused, ...extra })
|
|
206
223
|
: Console.log(reused
|
|
207
224
|
? `${url}\nAnother screw-bugs process already serves ${root} on ${base}; ` +
|
|
208
225
|
'the link works while it runs.'
|
|
@@ -225,21 +242,28 @@ const report = Command.make('report', {
|
|
|
225
242
|
port: portFlag,
|
|
226
243
|
}, (flags) => handle(flags.json)(Effect.gen(function* () {
|
|
227
244
|
const { path, bundle, walkthroughPath } = yield* (yield* Operations).report(flags.jobId);
|
|
245
|
+
const cases = caseResults(judgedLedger(bundle.ledger, bundle.findings));
|
|
228
246
|
if (flags.serve) {
|
|
229
247
|
if (flags.format === 'markdown') {
|
|
230
248
|
return yield* usage('--serve serves the html report; leave out --format markdown.');
|
|
231
249
|
}
|
|
232
|
-
return yield* serve(path, flags.port, flags.json);
|
|
250
|
+
return yield* serve(path, flags.port, flags.json, { cases });
|
|
233
251
|
}
|
|
234
252
|
if (flags.format === 'markdown') {
|
|
235
253
|
const markdown = renderPrSummary(bundle);
|
|
236
254
|
return yield* flags.json
|
|
237
|
-
? printJson({ ok: true, path, markdown })
|
|
255
|
+
? printJson({ ok: true, path, markdown, cases })
|
|
238
256
|
: Console.log(markdown.trimEnd());
|
|
239
257
|
}
|
|
240
258
|
const links = yield* pageLinks({ reportPath: path, walkthroughPath });
|
|
241
259
|
yield* flags.json
|
|
242
|
-
? printJson({
|
|
260
|
+
? printJson({
|
|
261
|
+
ok: true,
|
|
262
|
+
path,
|
|
263
|
+
walkthroughPath,
|
|
264
|
+
...urlFields(links),
|
|
265
|
+
cases,
|
|
266
|
+
})
|
|
243
267
|
: Console.log(links.report?.link ?? path);
|
|
244
268
|
}))).pipe(Command.withDescription("Write a run's report and print its path, print a Markdown summary for a pull request, or serve it over http with --serve"));
|
|
245
269
|
const walkthrough = Command.make('walkthrough', {
|
|
@@ -268,6 +292,7 @@ const findings = Command.make('findings', { json, jobId: Argument.String('job-id
|
|
|
268
292
|
reportPath: result.reportPath,
|
|
269
293
|
walkthroughPath: result.walkthroughPath,
|
|
270
294
|
...urlFields(links),
|
|
295
|
+
cases: caseResults(result.judged),
|
|
271
296
|
annotated: result.annotated,
|
|
272
297
|
marks: result.marks,
|
|
273
298
|
})
|
|
@@ -370,22 +395,22 @@ const runs = Command.make('runs', {
|
|
|
370
395
|
if (flags.json) {
|
|
371
396
|
return yield* printJson({
|
|
372
397
|
ok: true,
|
|
373
|
-
runs: list.map(({ job,
|
|
398
|
+
runs: list.map(({ job, judged }) => ({
|
|
374
399
|
jobId: job.jobId,
|
|
375
400
|
url: job.spec.url,
|
|
376
401
|
createdAt: job.createdAt,
|
|
377
|
-
state:
|
|
378
|
-
cases:
|
|
402
|
+
state: judged?.state,
|
|
403
|
+
cases: judged && caseResults(judged),
|
|
379
404
|
})),
|
|
380
405
|
});
|
|
381
406
|
}
|
|
382
407
|
if (list.length === 0)
|
|
383
408
|
return yield* Console.log('No runs yet in this project.');
|
|
384
409
|
yield* Console.log(list
|
|
385
|
-
.map(({ job,
|
|
386
|
-
const passed =
|
|
387
|
-
const total =
|
|
388
|
-
const state = (
|
|
410
|
+
.map(({ job, judged }) => {
|
|
411
|
+
const passed = judged?.cases.filter((c) => c.status === 'passed').length ?? 0;
|
|
412
|
+
const total = judged?.cases.length ?? 0;
|
|
413
|
+
const state = (judged?.state ?? 'unknown').replaceAll('_', ' ');
|
|
389
414
|
return `${job.jobId} ${state.padEnd(10)} ${passed}/${total} passed ${job.spec.url}`;
|
|
390
415
|
})
|
|
391
416
|
.join('\n'));
|
|
@@ -484,7 +509,7 @@ export const root = Command.make('screw-bugs').pipe(Command.withDescription('Loc
|
|
|
484
509
|
report,
|
|
485
510
|
walkthrough,
|
|
486
511
|
findings,
|
|
487
|
-
stub('share', 'Share a report through
|
|
512
|
+
stub('share', 'Share a report through Screw Bugs Cloud'),
|
|
488
513
|
runs,
|
|
489
514
|
analytics,
|
|
490
515
|
]));
|
package/dist/cli/mcp.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
2
|
import { Effect, Path } from 'effect';
|
|
3
|
-
import { type CaseLedger, type DoctorReport, type EvidencePack } from '../schema/index.js';
|
|
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';
|
|
6
6
|
export declare const formatDoctor: (report: DoctorReport) => string;
|
|
7
|
-
|
|
7
|
+
/** A ledger as a reply reads it: the code's, or with the agent's findings (`judgedLedger`). */
|
|
8
|
+
export type ShownLedger = CaseLedger | JudgedLedger;
|
|
9
|
+
/**
|
|
10
|
+
* `Job … is finished: 3 passed, 2 failed (1 by the agent's review), 0 blocked, 0 not verified.`
|
|
11
|
+
* The counts are the statuses results show: a case the agent's findings mark failed is failed.
|
|
12
|
+
*/
|
|
13
|
+
export declare const formatLedger: (ledger: ShownLedger) => string;
|
|
8
14
|
/** A run counts as passed only when it finished and every case passed. */
|
|
9
|
-
export declare const allPassed: (ledger:
|
|
15
|
+
export declare const allPassed: (ledger: ShownLedger) => boolean;
|
|
10
16
|
/** Screenshot IDs and timecodes listed per case; evidence.json has them all. */
|
|
11
17
|
export declare const SHOTS_LISTED = 8;
|
|
12
18
|
export declare const TIMECODES_LISTED = 12;
|
|
@@ -15,18 +21,18 @@ export declare const TIMECODES_LISTED = 12;
|
|
|
15
21
|
* line per flagged step (see `flagLines`), cases that did not pass first, then passed ones with
|
|
16
22
|
* flags, then the rest; and a line for a video that is missing or incomplete.
|
|
17
23
|
*/
|
|
18
|
-
export declare const formatEvidence: (ledger:
|
|
24
|
+
export declare const formatEvidence: (ledger: ShownLedger, pack: EvidencePack) => ReadonlyArray<string>;
|
|
19
25
|
/** One line per case that did not pass, for a run without an evidence pack. */
|
|
20
|
-
export declare const formatNotPassing: (ledger:
|
|
26
|
+
export declare const formatNotPassing: (ledger: ShownLedger) => ReadonlyArray<string>;
|
|
21
27
|
/** How a reply gives the walkthrough: its URL, or its path when there is no URL. */
|
|
22
28
|
export type WalkthroughLink = 'url' | 'path';
|
|
23
29
|
/** The counts sentence, saying where to watch the run when it has a walkthrough. */
|
|
24
|
-
export declare const countsSentence: (ledger:
|
|
30
|
+
export declare const countsSentence: (ledger: ShownLedger, walkthrough: WalkthroughLink | undefined) => string;
|
|
25
31
|
/**
|
|
26
32
|
* A status reply: the counts (and where to watch the run, when it has a walkthrough), then the
|
|
27
33
|
* evidence pack (see `formatEvidence`).
|
|
28
34
|
*/
|
|
29
|
-
export declare const formatStatus: (ledger:
|
|
35
|
+
export declare const formatStatus: (ledger: ShownLedger, pack?: EvidencePack, walkthrough?: WalkthroughLink) => string;
|
|
30
36
|
/**
|
|
31
37
|
* The reply to saved findings: one sentence (naming the walkthrough as the place to watch the run,
|
|
32
38
|
* when the reply gives it), maybe one about highlights, then the paths.
|
package/dist/cli/mcp.js
CHANGED
|
@@ -51,10 +51,20 @@ export const formatDoctor = (report) => {
|
|
|
51
51
|
? ready
|
|
52
52
|
: `${ready} Warning: ${problemsOf(failing)}; to fix, ${fixesOf(failing)}.`;
|
|
53
53
|
};
|
|
54
|
-
|
|
54
|
+
/** What is wrong with a case its agent's findings mark failed; undefined for any other. */
|
|
55
|
+
const failedByAgent = (c) => 'agentFailed' in c ? c.agentFailed : undefined;
|
|
56
|
+
/**
|
|
57
|
+
* `Job … is finished: 3 passed, 2 failed (1 by the agent's review), 0 blocked, 0 not verified.`
|
|
58
|
+
* The counts are the statuses results show: a case the agent's findings mark failed is failed.
|
|
59
|
+
*/
|
|
60
|
+
export const formatLedger = (ledger) => `Job ${ledger.jobId} is ${ledger.state.replaceAll('_', ' ')}: ${countsText(ledger)}.`;
|
|
61
|
+
/** `3 passed, 2 failed (1 by the agent's review), 0 blocked, 0 not verified`. */
|
|
62
|
+
const countsText = (ledger) => {
|
|
55
63
|
const count = (status) => ledger.cases.filter((c) => c.status === status).length;
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
const byAgent = ledger.cases.filter((c) => failedByAgent(c) !== undefined).length;
|
|
65
|
+
return (`${count('passed')} passed, ` +
|
|
66
|
+
`${count('failed')} failed${byAgent > 0 ? ` (${byAgent} by the agent's review)` : ''}, ` +
|
|
67
|
+
`${count('blocked')} blocked, ${count('not_verified')} not verified`);
|
|
58
68
|
};
|
|
59
69
|
/** A run counts as passed only when it finished and every case passed. */
|
|
60
70
|
export const allPassed = (ledger) => ledger.state === 'finished' && ledger.cases.every((c) => c.status === 'passed');
|
|
@@ -70,9 +80,20 @@ const capped = (values, max) => values.length > max
|
|
|
70
80
|
? `${values.slice(0, max).join(' ')} +${values.length - max}`
|
|
71
81
|
: values.join(' ');
|
|
72
82
|
const isOver = (ledger) => ledger.state === 'finished' || ledger.state === 'errored';
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
/**
|
|
84
|
+
* The first line of a listed case: `- <id> (<status>): <reason>`. A case the agent's findings
|
|
85
|
+
* mark failed gives the agent's verdict and the code's result as its reason, then the code's own.
|
|
86
|
+
*/
|
|
87
|
+
const caseLine = (c) => {
|
|
88
|
+
const reason = c.agentFailed !== undefined
|
|
89
|
+
? `agent's review: ${c.agentFailed} (${checksNote(c.checkStatus ?? 'passed')})` +
|
|
90
|
+
(c.reason?.trim() ? `; ${c.reason}` : '')
|
|
91
|
+
: c.reason;
|
|
92
|
+
return (`- ${c.id} (${c.status.replace('_', ' ')})` +
|
|
93
|
+
(c.status !== 'passed' && reason?.trim() ? `: ${oneLine(reason, REASON_MAX)}` : ''));
|
|
94
|
+
};
|
|
95
|
+
/** The checks' result beside the agent's verdict: `checks passed`, `checks: blocked`. */
|
|
96
|
+
const checksNote = (status) => status === 'passed' ? 'checks passed' : `checks: ${status.replace('_', ' ')}`;
|
|
76
97
|
/**
|
|
77
98
|
* The second line of a listed case: what an agent needs to write it up and the IDs its findings
|
|
78
99
|
* may use. Short fields, each capped: the deciding step and when, screenshot IDs, timecodes (ms
|
|
@@ -128,10 +149,21 @@ export const formatEvidence = (ledger, pack) => {
|
|
|
128
149
|
if (!isOver(ledger))
|
|
129
150
|
return [];
|
|
130
151
|
const flagged = (c) => flagLines(c).length > 0;
|
|
152
|
+
// Statuses as results show them: a case the agent's findings mark failed sorts with failures.
|
|
153
|
+
const verdicts = new Map(ledger.cases.flatMap((c) => {
|
|
154
|
+
const failed = failedByAgent(c);
|
|
155
|
+
return failed === undefined ? [] : [[c.id, failed]];
|
|
156
|
+
}));
|
|
157
|
+
const cases = pack.cases.map((c) => {
|
|
158
|
+
const agentFailed = verdicts.get(c.id);
|
|
159
|
+
return agentFailed === undefined
|
|
160
|
+
? c
|
|
161
|
+
: { ...c, status: 'failed', checkStatus: c.status, agentFailed };
|
|
162
|
+
});
|
|
131
163
|
const ordered = [
|
|
132
|
-
...
|
|
133
|
-
...
|
|
134
|
-
...
|
|
164
|
+
...cases.filter((c) => c.status !== 'passed'),
|
|
165
|
+
...cases.filter((c) => c.status === 'passed' && flagged(c)),
|
|
166
|
+
...cases.filter((c) => c.status === 'passed' && !flagged(c)),
|
|
135
167
|
];
|
|
136
168
|
const lines = ordered
|
|
137
169
|
.flatMap((c) => [caseLine(c), detailLine(c), ...flagLines(c)])
|
|
@@ -169,12 +201,21 @@ const unplacedLine = (marks) => {
|
|
|
169
201
|
return (`${missed.length} of ${all.length} highlights could not be drawn (${oneLine(listed, 300)}` +
|
|
170
202
|
`${missed.length > 3 ? '; …' : ''}); the report says so in words.`);
|
|
171
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* When the findings mark cases failed, the counts they make: `with them it is 3 passed, 2 failed
|
|
206
|
+
* (1 by the agent's review), 0 blocked, 0 not verified; `. Empty otherwise.
|
|
207
|
+
*/
|
|
208
|
+
const agentCounts = (judged) => {
|
|
209
|
+
if (!judged.cases.some((c) => c.agentFailed !== undefined))
|
|
210
|
+
return '';
|
|
211
|
+
return `with them it is ${countsText(judged)}; `;
|
|
212
|
+
};
|
|
172
213
|
/**
|
|
173
214
|
* The reply to saved findings: one sentence (naming the walkthrough as the place to watch the run,
|
|
174
215
|
* when the reply gives it), maybe one about highlights, then the paths.
|
|
175
216
|
*/
|
|
176
217
|
export const formatFindings = (result, walkthrough) => [
|
|
177
|
-
`Findings saved for job ${result.jobId}; ${!result.reportPath
|
|
218
|
+
`Findings saved for job ${result.jobId}; ${agentCounts(result.judged)}${!result.reportPath
|
|
178
219
|
? 'the report shows them once it is written.'
|
|
179
220
|
: walkthrough === undefined
|
|
180
221
|
? 'the report now shows them.'
|
|
@@ -274,7 +315,9 @@ const SubmitFindingsInput = Schema.Struct({
|
|
|
274
315
|
'expected) and key moments (its timecodes), what you did not test and why (notTested: ' +
|
|
275
316
|
'what and why; a passing run covers only what its cases did), and next tests. Short ' +
|
|
276
317
|
'texts and capped lists; see the field limits. Use only IDs and timecodes ' +
|
|
277
|
-
|
|
318
|
+
"from run_status. The run's checks decide statuses; you can only mark a case failed (its " +
|
|
319
|
+
'failed: what is wrong), whenever your own evidence (a database, logs, the screenshots) ' +
|
|
320
|
+
'shows it did not do what its success says, even if its checks passed. Never a pass.',
|
|
278
321
|
}),
|
|
279
322
|
});
|
|
280
323
|
const AnswerQuestionInput = Schema.Struct({
|
|
@@ -325,7 +368,7 @@ export const makeMcpServer = Effect.gen(function* () {
|
|
|
325
368
|
inputSchema: input(RunStatusInput),
|
|
326
369
|
}, ({ jobId, waitSeconds }) => run(ops
|
|
327
370
|
.runStatus(jobId, { waitSeconds })
|
|
328
|
-
.pipe(Effect.flatMap((status) => reportLinks(status).pipe(Effect.map((report) => ({ ...status, report }))))), ({ ledger, runDir, report, evidence, evidencePath }) => reply(formatStatus(
|
|
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), [
|
|
329
372
|
runDir,
|
|
330
373
|
path.join(runDir, LEDGER_FILE),
|
|
331
374
|
...(evidencePath ? [evidencePath] : []),
|
package/dist/cli/operations.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Effect, FileSystem, Layer, Path } from 'effect';
|
|
2
2
|
import { AccountBook, Browser, Engine, type RunSummary, Storage } from '../core/index.js';
|
|
3
|
-
import { type AccountEntry, type CaseLedger, type Device, type DoctorReport, type EvidencePack, JobId, type JobRecord, type PlacedMark, type ReportBundle } from '../schema/index.js';
|
|
3
|
+
import { type AccountEntry, type CaseLedger, type Device, type DoctorReport, type EvidencePack, JobId, type JobRecord, type JudgedLedger, type PlacedMark, type ReportBundle } from '../schema/index.js';
|
|
4
4
|
import { Failure } from './failure.js';
|
|
5
5
|
import { PackageInfo } from './package-info.js';
|
|
6
6
|
import { type SignInOutcome } from './sign-in.js';
|
|
@@ -49,6 +49,8 @@ export interface FindingsResult {
|
|
|
49
49
|
readonly marks: Readonly<Record<string, ReadonlyArray<PlacedMark>>>;
|
|
50
50
|
/** Absolute paths of the screenshots with the highlights drawn in. */
|
|
51
51
|
readonly annotated: ReadonlyArray<string>;
|
|
52
|
+
/** The run's ledger as results now show it, after these findings (see `judgedLedger`). */
|
|
53
|
+
readonly judged: JudgedLedger;
|
|
52
54
|
}
|
|
53
55
|
export interface RunResult {
|
|
54
56
|
readonly ledger: CaseLedger;
|
|
@@ -63,6 +65,11 @@ export interface RunResult {
|
|
|
63
65
|
* (never for an interrupted run's report).
|
|
64
66
|
*/
|
|
65
67
|
readonly walkthroughPath: string | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* The ledger as results show it: each case's status after the agent's saved findings, if any
|
|
70
|
+
* (see `judgedLedger`). `ledger` keeps the code's statuses.
|
|
71
|
+
*/
|
|
72
|
+
readonly judged: JudgedLedger;
|
|
66
73
|
}
|
|
67
74
|
declare const Operations_base: Context.ServiceClass<Operations, "screw-bugs/Operations", {
|
|
68
75
|
readonly doctor: Effect.Effect<DoctorReport>;
|
|
@@ -134,7 +141,10 @@ declare const Operations_base: Context.ServiceClass<Operations, "screw-bugs/Oper
|
|
|
134
141
|
readonly path: string;
|
|
135
142
|
readonly reportPath: string | undefined;
|
|
136
143
|
}, Failure>;
|
|
137
|
-
|
|
144
|
+
/** Recent runs, each ledger also as results show it (`judged`, see `judgedLedger`). */
|
|
145
|
+
readonly listRuns: (limit: number) => Effect.Effect<ReadonlyArray<RunSummary & {
|
|
146
|
+
readonly judged: JudgedLedger | undefined;
|
|
147
|
+
}>, Failure>;
|
|
138
148
|
/**
|
|
139
149
|
* Checks an agent's findings (parsed JSON) against an ended run and saves them, draws their
|
|
140
150
|
* highlights onto copies of the screenshots, then rewrites the run's report as `report` does,
|