screw-bugs 0.1.5 → 0.1.6
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 +20 -3
- package/dist/build-info.json +3 -3
- package/dist/cli/commands.js +44 -19
- 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/report/html.d.ts +1 -1
- package/dist/report/html.js +29 -11
- 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 +9 -0
- package/dist/report/view.js +16 -6
- package/dist/report/walkthrough.d.ts +3 -2
- package/dist/report/walkthrough.js +25 -9
- package/dist/schema/findings.d.ts +2 -0
- package/dist/schema/findings.js +8 -2
- package/dist/schema/ledger.d.ts +30 -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 |
|
|
@@ -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
|
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-13T15:58:38.374Z-9931a6ee",
|
|
3
|
+
"builtAt": "2026-11-13T15:58:38.374Z",
|
|
4
|
+
"commit": "886a228b99dbb41e9e11a499e3f735e422657f32"
|
|
5
5
|
}
|
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'));
|
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,
|
package/dist/cli/operations.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cause, Clock, Context, Duration, Effect, FileSystem, Layer, Option, Path, Predicate, Schedule, Schema, } from 'effect';
|
|
2
2
|
import { AccountBook, Browser, describeSignInWhy, Engine, originOf, evidencePackOf, REPORT_STALE_MS, staleFor, Storage, } from '../core/index.js';
|
|
3
|
-
import { AccountAbout, AccountLabel, Findings, JobId, NewJobSpec, ProjectConfig, runFiles, } from '../schema/index.js';
|
|
3
|
+
import { AccountAbout, AccountLabel, Findings, JobId, judgedLedger, NewJobSpec, ProjectConfig, runFiles, } from '../schema/index.js';
|
|
4
4
|
import { CONFIG_FILE, loadConfig, missingConfig } from './config.js';
|
|
5
5
|
import { runDoctor } from './doctor.js';
|
|
6
6
|
import { ExitCode } from './exit-codes.js';
|
|
@@ -110,12 +110,18 @@ export class Operations extends Context.Service()('screw-bugs/Operations') {
|
|
|
110
110
|
return undefined;
|
|
111
111
|
})));
|
|
112
112
|
});
|
|
113
|
+
/**
|
|
114
|
+
* The run's saved findings (`findings.json`); none when there are none, or the file
|
|
115
|
+
* cannot be read or does not decode, as the report treats it.
|
|
116
|
+
*/
|
|
117
|
+
const savedFindings = (jobId) => storage.readFile(jobId, runFiles.findings).pipe(Effect.flatMap((text) => text === undefined ? Effect.succeed(undefined) : decodeFindingsText(text)), Effect.orElseSucceed(() => undefined));
|
|
113
118
|
/**
|
|
114
119
|
* The ledger read by `read`, and the report path of an ended run. Unless `writeReport` is
|
|
115
120
|
* false, an interrupted run's report may be written now (see `reportOf`).
|
|
116
121
|
*/
|
|
117
122
|
const ledgerOf = (jobId, read, writeReport = true) => Effect.gen(function* () {
|
|
118
123
|
const ledger = yield* read(jobId).pipe(orRunNotFound(jobId));
|
|
124
|
+
const findings = isOver(ledger) ? yield* savedFindings(jobId) : undefined;
|
|
119
125
|
const reportPath = isOver(ledger)
|
|
120
126
|
? yield* reportOf(jobId, ledger, writeReport)
|
|
121
127
|
: undefined;
|
|
@@ -125,6 +131,7 @@ export class Operations extends Context.Service()('screw-bugs/Operations') {
|
|
|
125
131
|
runDir: storage.runDir(jobId),
|
|
126
132
|
reportPath,
|
|
127
133
|
walkthroughPath,
|
|
134
|
+
judged: judgedLedger(ledger, findings),
|
|
128
135
|
};
|
|
129
136
|
});
|
|
130
137
|
/**
|
|
@@ -337,9 +344,11 @@ export class Operations extends Context.Service()('screw-bugs/Operations') {
|
|
|
337
344
|
}));
|
|
338
345
|
// Saved findings stay saved; a report that may not be rewritten yet shows them later.
|
|
339
346
|
const report = yield* rewriteReport(jobId).pipe(Effect.map((written) => written.path), Effect.catchTag('Failure', () => Effect.succeed(undefined)));
|
|
347
|
+
const ledger = yield* engine.status(jobId).pipe(orRunNotFound(jobId));
|
|
340
348
|
return {
|
|
341
349
|
jobId,
|
|
342
350
|
...saved,
|
|
351
|
+
judged: judgedLedger(ledger, findings),
|
|
343
352
|
reportPath: report,
|
|
344
353
|
walkthroughPath: yield* walkthroughOf(jobId, report),
|
|
345
354
|
};
|
|
@@ -414,7 +423,15 @@ export class Operations extends Context.Service()('screw-bugs/Operations') {
|
|
|
414
423
|
return { link, done: signIns.value.wait(label) };
|
|
415
424
|
}),
|
|
416
425
|
removeAccount: (raw) => decodeLabel(raw).pipe(Effect.flatMap((label) => accountBook.remove(label).pipe(Effect.mapError(accountsFailure)))),
|
|
417
|
-
listRuns: (limit) => storage.listRuns(limit).pipe(Effect.mapError(storageFailure)),
|
|
426
|
+
listRuns: (limit) => storage.listRuns(limit).pipe(Effect.mapError(storageFailure), Effect.flatMap((runs) => Effect.forEach(runs, (run) => run.ledger === undefined || !isOver(run.ledger)
|
|
427
|
+
? Effect.succeed({
|
|
428
|
+
...run,
|
|
429
|
+
judged: run.ledger && judgedLedger(run.ledger, undefined),
|
|
430
|
+
})
|
|
431
|
+
: savedFindings(run.job.jobId).pipe(Effect.map((findings) => ({
|
|
432
|
+
...run,
|
|
433
|
+
judged: judgedLedger(run.ledger, findings),
|
|
434
|
+
})))))),
|
|
418
435
|
answer: (input) => Effect.gen(function* () {
|
|
419
436
|
const jobId = yield* decodeJobId(input.jobId);
|
|
420
437
|
yield* engine.answer({ jobId, questionId: input.questionId, text: input.text }).pipe(Effect.catchTags({
|
|
@@ -447,5 +464,6 @@ export const schemaProblems = (message) => {
|
|
|
447
464
|
problems.push(pending.join(' '));
|
|
448
465
|
return problems;
|
|
449
466
|
};
|
|
467
|
+
const decodeFindingsText = Schema.decodeUnknownEffect(Schema.fromJsonString(Findings));
|
|
450
468
|
const invalidInput = (error) => new Failure({ code: ExitCode.Usage, reason: 'invalid_job', message: error.message });
|
|
451
469
|
const storageFailure = (error) => new Failure({ code: ExitCode.Internal, reason: 'storage_failed', message: error.message });
|
package/dist/report/html.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { type RenderOptions } from './assets.js';
|
|
|
19
19
|
* failed. Without script: the video has its own controls, timecodes open the video at their time
|
|
20
20
|
* and screenshots open the image.
|
|
21
21
|
*/
|
|
22
|
-
export declare const REPORT_SCRIPT = "(()=>{const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),empty=d.getElementById(p+'-none');let cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{if(!v.error)return;dead.add(cur);if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\nconst badImg=i=>{const f=i.closest('figure');if(!f||f.classList.contains('broken'))return;f.classList.add('broken');f.querySelectorAll('.unloaded').forEach(u=>u.removeAttribute('aria-hidden'))};\nconst scan=()=>d.querySelectorAll('figure img').forEach(i=>{if(i.complete&&i.naturalWidth===0)badImg(i)});\nd.addEventListener('error',e=>{const t=e.target;if(t instanceof Element&&t.matches('figure img'))badImg(t)},true);\naddEventListener('load',scan);\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();scan();\n const cards=[...d.querySelectorAll('.case[data-i]')],segs=[...d.querySelectorAll('.seg[data-case]')];\n const np=d.getElementById('rp-now'),loopB=d.getElementById('rp-loop'),dlg=d.getElementById('viewer');\n const N=cards.length,dash=String.fromCharCode(8211);let cur=null,loop=true,lock=0,lastT=0,P=null,sr=0;\n const timed=c=>!!c&&c.dataset.t0!==undefined;\n const span=c=>[Number(c.dataset.t0),Number(c.dataset.t1)];\n const shown=()=>cards.filter(c=>!c.hidden);\n const line=()=>{const b=topEdge();if(matchMedia('(max-width: 900px)').matches){const s=d.querySelector('.rp-left');return s?s.getBoundingClientRect().bottom+24:b+120}return Math.round(b+(innerHeight-b)*0.3)};\n const playable=c=>timed(c)&&!!P&&P.has(c.dataset.s);\n const chip=c=>{if(!playable(c)||P.down()!==null)return '';const s=span(c);return (loop?'Looping ':'Playing ')+clock(s[0])+dash+clock(s[1])};\n const paintNow=()=>{\n if(!np||!cur)return;\n np.querySelector('.np-st').replaceChildren(cur.querySelector('.case-head .st').cloneNode(true));\n np.querySelector('.np-n').textContent=cur.dataset.i+' / '+N;\n np.querySelector('.np-title').textContent=cur.querySelector('.case-go').textContent;\n np.querySelector('.np-status').textContent=cur.dataset.label+': ';\n const ch=np.querySelector('.np-chip'),t=chip(cur);ch.querySelector('span').textContent=t||'No video';ch.classList.toggle('none',!t);\n };\n const toCard=c=>{lock=Date.now()+700;const y=c.getBoundingClientRect().top+scrollY-line()+2;scrollTo({top:Math.max(0,y),behavior:still()?'auto':'smooth'})};\n const setCurrent=(c,seek,scroll)=>{\n if(!c)return;\n if(c!==cur){if(cur){cur.classList.remove('on');cur.removeAttribute('aria-current')}cur=c;c.classList.add('on');c.setAttribute('aria-current','true');segs.forEach(x=>x.classList.toggle('on',x.dataset.case===c.dataset.id));paintNow()}\n if(seek&&P){if(playable(c)){const a=span(c)[0];lastT=a;P.load(c.dataset.s,a,P.playing())}else P.none()}\n if(scroll)toCard(c);\n };\n const caseAt=(s,t)=>{let f=null;for(const c of shown()){if(timed(c)&&c.dataset.s===s){const x=span(c);if(t>=x[0]&&t<x[1])f=c}}return f};\n const onScroll=()=>{\n if(Date.now()<lock)return;const vis=shown();if(!vis.length)return;\n const L=line();let pick=vis[0];for(const c of vis){if(c.getBoundingClientRect().top<=L)pick=c}\n const last=vis[vis.length-1];if(innerHeight+scrollY>=r.scrollHeight-2&&last.getBoundingClientRect().bottom<=innerHeight)pick=last;\n if(pick!==cur)setCurrent(pick,true,false);\n };\n const stk=d.querySelector('.rp-sticky'),head=d.querySelector('.rp-head');\n const fit=()=>{if(stk)stk.style.setProperty('--rp-top',Math.round(stk.getBoundingClientRect().top)+'px')};\n fit();addEventListener('resize',fit);addEventListener('load',fit);\n if(head&&window.ResizeObserver)new ResizeObserver(fit).observe(head);\n addEventListener('scroll',()=>{if(!sr)sr=requestAnimationFrame(()=>{sr=0;fit();onScroll()})},{passive:true});\n if(d.getElementById('rp-video'))P=player('rp',{\n broken:paintNow,fine:paintNow,\n tick:t=>{\n if(!cur||P.down()!==null||P.v.seeking)return;const s=P.cur();\n if(loop){if(timed(cur)&&cur.dataset.s===s){const x=span(cur);if(!P.v.paused&&t>=x[1]-0.03&&lastT<x[1]){lastT=x[0];P.v.currentTime=x[0];return}}}\n else{const c=caseAt(s,t);if(c&&c!==cur)setCurrent(c,false,true)}\n lastT=t;\n },\n seek:t=>{lastT=t;const c=caseAt(P.cur(),t);if(c&&c!==cur)setCurrent(c,false,true)},\n ended:()=>{\n if(!cur)return false;\n if(loop&&timed(cur)&&cur.dataset.s===P.cur()){P.load(P.cur(),span(cur)[0],true);return true}\n if(!loop){const later=shown().find(c=>timed(c)&&Number(c.dataset.s)>Number(P.cur())&&P.has(c.dataset.s));if(later){setCurrent(later,false,true);P.load(later.dataset.s,span(later)[0],true);return true}}\n return false;\n },\n });\n if(loopB)loopB.addEventListener('click',()=>{loop=!loop;loopB.setAttribute('aria-pressed',String(loop));paintNow()});\n const filter=f=>{\n d.querySelectorAll('[data-filter]').forEach(x=>x.setAttribute('aria-pressed',String(x.dataset.filter===f)));\n cards.forEach(c=>{c.hidden=!(f==='all'||c.dataset.status===f)});\n segs.forEach(x=>{const c=cards.find(k=>k.dataset.id===x.dataset.case);x.classList.toggle('off',!!c&&c.hidden)});\n if(cur&&cur.hidden)setCurrent(shown()[0],true,false);\n };\n d.querySelectorAll('[data-filter]').forEach(b=>b.addEventListener('click',()=>filter(b.dataset.filter)));\n d.querySelectorAll('.filters').forEach(f=>f.classList.add('live'));\n let vCase=null,vIdx=0,opener=null;\n const q=s=>dlg.querySelector(s);\n const list=c=>{const t=c&&c.querySelector('template.shots');return t?[...t.content.children]:[]};\n const showShot=()=>{\n const l=list(vCase),f=l[vIdx];if(!f)return;\n q('.v-body').replaceChildren(f.cloneNode(true));\n q('.v-st').replaceChildren(vCase.querySelector('.case-head .st').cloneNode(true));\n q('.v-title').textContent=vCase.querySelector('.case-go').textContent;\n q('.v-what').textContent=f.dataset.cap+(l.length>1?' ('+(vIdx+1)+' of '+l.length+')':'');\n q('.v-prev').disabled=vIdx===0;q('.v-next').disabled=vIdx>=l.length-1;scan();\n };\n if(dlg){\n q('.v-prev').addEventListener('click',()=>{if(vIdx>0){vIdx--;showShot()}});\n q('.v-next').addEventListener('click',()=>{if(vIdx<list(vCase).length-1){vIdx++;showShot()}});\n q('.v-close').addEventListener('click',()=>dlg.close());\n dlg.addEventListener('click',e=>{if(e.target===dlg)dlg.close()});\n dlg.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'){e.preventDefault();q('.v-prev').click()}else if(e.key==='ArrowRight'){e.preventDefault();q('.v-next').click()}});\n dlg.addEventListener('close',()=>{q('.v-body').replaceChildren();if(opener&&opener.isConnected)opener.focus()});\n }\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const tc=t.closest('a.tc[data-t]');\n if(tc){if(!P||!P.has(tc.dataset.s))return;e.preventDefault();const s=tc.dataset.s,at=Number(tc.dataset.t),c=caseAt(s,at)||tc.closest('.case')||(dlg&&dlg.open?vCase:null);if(dlg&&dlg.open)dlg.close();if(c)setCurrent(c,false,!tc.closest('.case'));lastT=at;P.load(s,at,P.playing());return}\n const go=t.closest('a[href^=\"#case-\"]');\n if(go){const c=d.getElementById(go.getAttribute('href').slice(1));if(!c||!c.matches('.case[data-i]'))return;e.preventDefault();if(c.hidden)filter('all');toCard(c);setCurrent(c,true,false);return}\n const shot=t.closest('[data-shot]');\n if(shot&&dlg&&dlg.showModal){e.preventDefault();opener=shot;vCase=shot.closest('.case');vIdx=Number(shot.dataset.shot)||0;showShot();dlg.showModal();q('.v-close').focus();return}\n const c=t.closest('.case[data-i]');\n if(!c||t.closest('a,summary,details,input,label')||(t.closest('button')&&!t.closest('.case-go')))return;\n toCard(c);setCurrent(c,true,false);\n });\n const first=cards.find(c=>timed(c)&&(!P||P.has(c.dataset.s)))||cards[0];\n if(first){setCurrent(first,false,false);if(timed(first))lastT=span(first)[0]}\n});\n})();";
|
|
22
|
+
export declare const REPORT_SCRIPT = "(()=>{const d=document,r=d.documentElement,K='screw-bugs-theme';\nconst still=()=>matchMedia('(prefers-reduced-motion: reduce)').matches;\nconst topEdge=()=>{const b=d.querySelector('.menubar');return b?Math.max(0,b.getBoundingClientRect().bottom):0};\nconst pad=n=>String(n).padStart(2,'0');\nconst clock=s=>{s=Math.max(0,Math.floor(s||0));const h=Math.floor(s/3600),m=Math.floor(s%3600/60);return(h?h+':'+pad(m):String(m))+':'+pad(s%60)};\nlet theme='system';try{theme=localStorage.getItem(K)||theme}catch(e){}r.dataset.theme=theme;\nconst themeCycle=(b,key)=>{\n const r=document.documentElement,T=['light','dark','system'],N={light:'Light theme',dark:'Dark theme',system:'Theme from system'};\n const at=()=>{const i=T.indexOf(r.dataset.theme);return i<0?2:i};\n const show=()=>{const i=at(),f=document.getElementById('favicon'),h=f&&f.dataset[T[i]];if(h)f.href=h;b.setAttribute('aria-label',N[T[i]]+'. Switch to '+N[T[(i+1)%3]].toLowerCase());b.title=N[T[i]]};\n show();\n b.addEventListener('click',()=>{const m=T[(at()+1)%3];r.dataset.theme=m;if(key)try{localStorage.setItem(key,m)}catch(e){}show()});\n};\nconst chrome=()=>{\n d.querySelectorAll('.menubar .theme').forEach(b=>{themeCycle(b,K);b.hidden=false});\n if(location.protocol==='http:'&&(location.hostname==='127.0.0.1'||location.hostname==='localhost'))d.querySelectorAll('a.share-btn').forEach(a=>{a.hidden=false});\n d.querySelectorAll('time.when[datetime]').forEach(e=>{\n const t=new Date(e.getAttribute('datetime'));if(isNaN(t.getTime()))return;const p={};\n try{new Intl.DateTimeFormat('en-US',{month:'short',day:'numeric',year:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).forEach(x=>{p[x.type]=x.value});\n const y=d.createElement('span');y.className='year';y.textContent=', '+p.year;\n e.replaceChildren(p.month+' '+p.day,y,' '+String.fromCharCode(183)+' '+p.hour+':'+p.minute);\n e.title=new Intl.DateTimeFormat('en-US',{dateStyle:'full',timeStyle:'long'}).format(t)}catch(x){}\n });\n d.querySelectorAll('.prompt').forEach(p=>{\n const t=p.querySelector('.prompt-text'),b=p.querySelector('.prompt-more');if(!t||!b)return;\n const fits=()=>{if(!p.classList.contains('open'))b.hidden=t.scrollHeight<=t.clientHeight+1};\n fits();if(window.ResizeObserver)new ResizeObserver(fits).observe(t);if(d.fonts&&d.fonts.ready)d.fonts.ready.then(fits);\n b.addEventListener('click',()=>{const o=p.classList.toggle('open');b.textContent=o?'Show less':'Show full prompt';b.setAttribute('aria-expanded',String(o));fits()});\n });\n};\nconst bare=u=>{const i=u.indexOf('://');return i<0?u:u.slice(i+3)};\nconst player=(p,o)=>{\n const v=d.getElementById(p+'-video'),fig=v.closest('.player'),note=d.getElementById(p+'-unloaded'),c=d.getElementById(p+'-controls'),url=d.getElementById(p+'-url');\n const srcs=new Map([...fig.querySelectorAll('[data-session-src]')].map(e=>[e.dataset.session,e.dataset.sessionSrc]));\n const order=[...srcs.keys()];\n const urls=[...fig.querySelectorAll('[data-url]')].map(e=>({s:e.dataset.s,t:Number(e.dataset.at),u:e.dataset.url}));\n const dead=new Set(),errs=new Map(),empty=d.getElementById(p+'-none');let shown=0,cur=v.dataset.session,down=null,held=false,ask=0,auto=false,rate=1,raf=0,drag=false;\n const play=c.querySelector('.play'),now=c.querySelector('.now'),total=c.querySelector('.total'),bar=c.querySelector('.scrub'),head=c.querySelector('.head'),tracks=[...c.querySelectorAll('.track')];\n v.removeAttribute('controls');c.hidden=false;\n const big=d.getElementById(p+'-start');\n if(big){big.hidden=false;big.addEventListener('click',()=>{grow();v.play().catch(()=>{})});v.addEventListener('play',()=>big.remove(),{once:true})}\n const track=()=>tracks.find(t=>t.dataset.s===cur);\n const len=()=>{const t=track(),n=t?Number(t.dataset.total):0;return n>0?n:(isFinite(v.duration)?v.duration:0)};\n const paint=()=>{\n const L=len(),t=v.currentTime,f=L?Math.min(1,t/L):0,k=track();\n tracks.forEach(x=>{x.hidden=x!==k});head.style.left=(f*100)+'%';\n const done=k&&k.querySelector('.done');if(done)done.style.width=(f*100)+'%';\n now.textContent=clock(t);total.textContent=clock(L);\n bar.setAttribute('aria-valuemax',String(Math.round(L)));bar.setAttribute('aria-valuenow',String(Math.round(t)));bar.setAttribute('aria-valuetext',clock(t)+' of '+clock(L));\n play.classList.toggle('playing',!v.paused);play.setAttribute('aria-label',v.paused?'Play':'Pause');\n if(url){let u='';if(down!=='')for(const x of urls){if(x.s===cur&&x.t<=t+0.02)u=x.u}url.textContent=bare(u);url.parentElement.title=u}\n };\n const update=()=>{paint();if(o.tick)o.tick(v.currentTime)};\n const frame=()=>{update();raf=v.paused?0:requestAnimationFrame(frame)};\n const show=s=>{if(down===null)held=!v.paused;down=s;v.pause();fig.classList.add('broken');c.hidden=true;if(empty)empty.hidden=true;if(note){++shown;note.hidden=false;const a=note.querySelector('a');if(a){a.href=srcs.get(s);a.textContent=srcs.get(s)}const ft=note.querySelector('.fix-text'),fd=note.querySelector('.fix-done');if(ft){ft.hidden=true;ft.value=''}if(fd)fd.textContent=''}if(o.broken)o.broken()};\n const fine=()=>{if(down===null)return;down=null;fig.classList.remove('broken');c.hidden=false;if(note)note.hidden=true;if(empty)empty.hidden=true;if(o.fine)o.fine()};\n const none=()=>{if(down===null)held=!v.paused;++ask;auto=false;down='';v.pause();fig.classList.add('broken');c.hidden=true;if(note)note.hidden=true;if(empty)empty.hidden=false;paint();if(o.broken)o.broken()};\n const playing=()=>down===null?!v.paused:held;\n const next=s=>order.slice(order.indexOf(s)+1).find(n=>!dead.has(n));\n const load=(s,t,go,a)=>{\n const my=++ask;auto=!!a;if(dead.has(s))return show(s);\n if(s!==cur||!v.currentSrc||v.error){cur=s;v.dataset.session=s;v.src=srcs.get(s);v.load()}\n const done=()=>{if(my!==ask)return;auto=false;fine();v.playbackRate=rate;v.currentTime=t;update();if(go)v.play().catch(()=>{})};\n if(v.readyState>0)done();else v.addEventListener('loadedmetadata',done,{once:true});\n };\n const bad=()=>{const e=v.error;if(!e)return;dead.add(cur);errs.set(cur,'error code '+e.code+(e.message?': '+e.message:''));if(down==='')return;const n=auto?next(cur):undefined;if(n!==undefined)return load(n,0,true,true);auto=false;show(cur)};\n ['timeupdate','seeked','loadedmetadata','pause','play','durationchange'].forEach(n=>v.addEventListener(n,update));\n v.addEventListener('play',()=>{if(!raf)raf=requestAnimationFrame(frame)});\n addEventListener('resize',update);\n v.addEventListener('error',bad);if(v.error)queueMicrotask(bad);\n const fix=d.getElementById(p+'-fix');\n if(fix){const box=fix.parentElement,ta=box.querySelector('.fix-text'),said=box.querySelector('.fix-done');\n fix.addEventListener('click',()=>{\n let t=ta.dataset.template||'';\n [['video',down?srcs.get(down)||'':''],['page',location.href],['browser',navigator.userAgent],['error',errs.get(down)||'nothing']].forEach(([k,x])=>{t=t.split('{'+k+'}').join(x)});\n const g=shown;ta.value=t;const ok=()=>{if(g!==shown)return;said.textContent='Copied. Paste it into your coding agent.'};\n const by=()=>{if(g!==shown)return;ta.hidden=false;ta.focus();ta.setSelectionRange(0,t.length);ta.scrollTop=0;let c=false;try{c=d.execCommand('copy')}catch(x){}if(c)ok();else said.textContent='Copy the prompt below.'};\n if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(t).then(ok,by);else by();\n })}\n v.addEventListener('ended',()=>{if(o.ended&&o.ended())return;const n=next(cur);if(n!==undefined)load(n,0,true,true)});\n play.addEventListener('click',()=>{if(v.paused)v.play().catch(()=>{});else v.pause()});\n v.addEventListener('click',()=>{if(down!==null)return;if(grow())v.play().catch(()=>{});else play.click()});\n c.querySelectorAll('[data-rate]').forEach(b=>b.addEventListener('click',()=>{rate=Number(b.dataset.rate);v.playbackRate=rate;v.defaultPlaybackRate=rate;c.querySelectorAll('[data-rate]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)))}));\n const seek=t=>{const L=len();t=Math.max(0,L?Math.min(L,t):t);v.currentTime=t;if(o.seek)o.seek(t);update()};\n const at=e=>{const b=bar.getBoundingClientRect();return Math.max(0,Math.min(1,(e.clientX-b.left)/b.width))*len()};\n bar.addEventListener('pointerdown',e=>{if(e.button>0||down!==null)return;drag=true;bar.setPointerCapture(e.pointerId);seek(at(e))});\n bar.addEventListener('pointermove',e=>{if(drag)seek(at(e))});\n ['pointerup','pointercancel'].forEach(n=>bar.addEventListener(n,()=>{drag=false}));\n bar.addEventListener('keydown',e=>{\n const k=e.key,t=v.currentTime,by={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1,PageDown:-10,PageUp:10}[k];\n const to=by!==undefined?t+by:k==='Home'?0:k==='End'?len():null;if(to===null)return;e.preventDefault();seek(to);\n });\n const full=c.querySelector('.full'),screen=o.full||fig.querySelector('.screen');\n const api=!!(d.fullscreenEnabled&&screen.requestFullscreen),inPage=()=>!!o.inPage&&(o.inPage()||!api);\n const mark=()=>{const f=d.fullscreenElement===screen||screen.classList.contains('focus');full.classList.toggle('out',f);full.setAttribute('aria-label',f?'Exit fullscreen':'Fullscreen');update()};\n let back=0;const focus=on=>{if(on)back=scrollY;screen.classList.toggle('focus',on);scrollTo({top:on?0:back,behavior:'auto'});mark()};\n const grow=()=>{if(!o.expand||!o.inPage||!o.inPage()||d.fullscreenElement||screen.classList.contains('focus'))return false;focus(true);return true};\n if(!api&&!o.inPage)full.hidden=true;\n else{full.addEventListener('click',()=>{const f=screen.classList.contains('focus');if(d.fullscreenElement){d.exitFullscreen().catch(()=>{});if(f)focus(false)}else if(f)focus(false);else if(inPage())focus(true);else screen.requestFullscreen().catch(()=>{})});\n d.addEventListener('fullscreenchange',mark);\n d.addEventListener('keydown',e=>{if(e.key==='Escape'&&!e.defaultPrevented&&screen.classList.contains('focus')&&!d.querySelector('dialog[open]')){e.preventDefault();focus(false)}})}\n d.addEventListener('keydown',e=>{if(e.key!==' '||down!==null||e.defaultPrevented||d.querySelector('dialog[open]')||e.target.closest('button,a,input,textarea,select,summary,[role=slider]'))return;e.preventDefault();play.click()});\n return {v,load,none,playing,update,len,cur:()=>cur,down:()=>down,has:s=>srcs.has(s)};\n};\n\nconst badImg=i=>{const f=i.closest('figure');if(!f||f.classList.contains('broken'))return;f.classList.add('broken');f.querySelectorAll('.unloaded').forEach(u=>u.removeAttribute('aria-hidden'))};\nconst scan=()=>d.querySelectorAll('figure img').forEach(i=>{if(i.complete&&i.naturalWidth===0)badImg(i)});\nd.addEventListener('error',e=>{const t=e.target;if(t instanceof Element&&t.matches('figure img'))badImg(t)},true);\naddEventListener('load',scan);\nd.addEventListener('DOMContentLoaded',()=>{\n chrome();scan();\n const cards=[...d.querySelectorAll('.case[data-i]')],segs=[...d.querySelectorAll('.seg[data-case]')];\n const np=d.getElementById('rp-now'),loopB=d.getElementById('rp-loop'),dlg=d.getElementById('viewer');\n const N=cards.length,dash=String.fromCharCode(8211);let cur=null,loop=true,lock=0,lastT=0,P=null,sr=0;\n const timed=c=>!!c&&c.dataset.t0!==undefined;\n const span=c=>[Number(c.dataset.t0),Number(c.dataset.t1)];\n const shown=()=>cards.filter(c=>!c.hidden);\n const line=()=>{const b=topEdge();if(matchMedia('(max-width: 900px)').matches){const s=d.querySelector('.rp-left');return s?s.getBoundingClientRect().bottom+24:b+120}return Math.round(b+(innerHeight-b)*0.3)};\n const playable=c=>timed(c)&&!!P&&P.has(c.dataset.s);\n const chip=c=>{if(!playable(c)||P.down()!==null)return '';const s=span(c);return (loop?'Looping ':'Playing ')+clock(s[0])+dash+clock(s[1])};\n const paintNow=()=>{\n if(!np||!cur)return;\n np.querySelector('.np-st').replaceChildren(cur.querySelector('.case-head .st').cloneNode(true));\n np.querySelector('.np-n').textContent=cur.dataset.i+' / '+N;\n np.querySelector('.np-title').textContent=cur.querySelector('.case-go').textContent;\n np.querySelector('.np-status').textContent=cur.dataset.label+': ';\n const ch=np.querySelector('.np-chip'),t=chip(cur);ch.querySelector('span').textContent=t||'No video';ch.classList.toggle('none',!t);\n };\n const toCard=c=>{lock=Date.now()+700;const y=c.getBoundingClientRect().top+scrollY-line()+2;scrollTo({top:Math.max(0,y),behavior:still()?'auto':'smooth'})};\n const setCurrent=(c,seek,scroll)=>{\n if(!c)return;\n if(c!==cur){if(cur){cur.classList.remove('on');cur.removeAttribute('aria-current')}cur=c;c.classList.add('on');c.setAttribute('aria-current','true');segs.forEach(x=>x.classList.toggle('on',x.dataset.case===c.dataset.id));paintNow()}\n if(seek&&P){if(playable(c)){const a=span(c)[0];lastT=a;P.load(c.dataset.s,a,P.playing())}else P.none()}\n if(scroll)toCard(c);\n };\n const caseAt=(s,t)=>{let f=null;for(const c of shown()){if(timed(c)&&c.dataset.s===s){const x=span(c);if(t>=x[0]&&t<x[1])f=c}}return f};\n const onScroll=()=>{\n if(Date.now()<lock)return;const vis=shown();if(!vis.length)return;\n const L=line();let pick=vis[0];for(const c of vis){if(c.getBoundingClientRect().top<=L)pick=c}\n const last=vis[vis.length-1];if(innerHeight+scrollY>=r.scrollHeight-2&&last.getBoundingClientRect().bottom<=innerHeight)pick=last;\n if(pick!==cur)setCurrent(pick,true,false);\n };\n const stk=d.querySelector('.rp-sticky'),head=d.querySelector('.rp-head');\n const fit=()=>{if(stk)stk.style.setProperty('--rp-top',Math.round(stk.getBoundingClientRect().top)+'px')};\n fit();addEventListener('resize',fit);addEventListener('load',fit);\n if(head&&window.ResizeObserver)new ResizeObserver(fit).observe(head);\n addEventListener('scroll',()=>{if(!sr)sr=requestAnimationFrame(()=>{sr=0;fit();onScroll()})},{passive:true});\n if(d.getElementById('rp-video'))P=player('rp',{\n broken:paintNow,fine:paintNow,\n tick:t=>{\n if(!cur||P.down()!==null||P.v.seeking)return;const s=P.cur();\n if(loop){if(timed(cur)&&cur.dataset.s===s){const x=span(cur);if(!P.v.paused&&t>=x[1]-0.03&&lastT<x[1]){lastT=x[0];P.v.currentTime=x[0];return}}}\n else{const c=caseAt(s,t);if(c&&c!==cur)setCurrent(c,false,true)}\n lastT=t;\n },\n seek:t=>{lastT=t;const c=caseAt(P.cur(),t);if(c&&c!==cur)setCurrent(c,false,true)},\n ended:()=>{\n if(!cur)return false;\n if(loop&&timed(cur)&&cur.dataset.s===P.cur()){P.load(P.cur(),span(cur)[0],true);return true}\n if(!loop){const later=shown().find(c=>timed(c)&&Number(c.dataset.s)>Number(P.cur())&&P.has(c.dataset.s));if(later){setCurrent(later,false,true);P.load(later.dataset.s,span(later)[0],true);return true}}\n return false;\n },\n });\n if(loopB)loopB.addEventListener('click',()=>{loop=!loop;loopB.setAttribute('aria-pressed',String(loop));paintNow()});\n const filter=f=>{\n d.querySelectorAll('[data-filter]').forEach(x=>x.setAttribute('aria-pressed',String(x.dataset.filter===f)));\n cards.forEach(c=>{c.hidden=!(f==='all'||c.dataset.status===f)});\n segs.forEach(x=>{const c=cards.find(k=>k.dataset.id===x.dataset.case);x.classList.toggle('off',!!c&&c.hidden)});\n if(cur&&cur.hidden)setCurrent(shown()[0],true,false);\n };\n d.querySelectorAll('[data-filter]').forEach(b=>b.addEventListener('click',()=>filter(b.dataset.filter)));\n d.querySelectorAll('.filters').forEach(f=>f.classList.add('live'));\n let vCase=null,vIdx=0,opener=null;\n const q=s=>dlg.querySelector(s);\n const list=c=>{const t=c&&c.querySelector('template.shots');return t?[...t.content.children]:[]};\n const showShot=()=>{\n const l=list(vCase),f=l[vIdx];if(!f)return;\n q('.v-body').replaceChildren(f.cloneNode(true));\n q('.v-st').replaceChildren(vCase.querySelector('.case-head .st').cloneNode(true));\n q('.v-title').textContent=vCase.querySelector('.case-go').textContent;\n q('.v-what').textContent=f.dataset.cap+(l.length>1?' ('+(vIdx+1)+' of '+l.length+')':'');\n q('.v-prev').disabled=vIdx===0;q('.v-next').disabled=vIdx>=l.length-1;scan();\n };\n if(dlg){\n q('.v-prev').addEventListener('click',()=>{if(vIdx>0){vIdx--;showShot()}});\n q('.v-next').addEventListener('click',()=>{if(vIdx<list(vCase).length-1){vIdx++;showShot()}});\n q('.v-close').addEventListener('click',()=>dlg.close());\n dlg.addEventListener('click',e=>{if(e.target===dlg)dlg.close()});\n dlg.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'){e.preventDefault();q('.v-prev').click()}else if(e.key==='ArrowRight'){e.preventDefault();q('.v-next').click()}});\n dlg.addEventListener('close',()=>{q('.v-body').replaceChildren();if(opener&&opener.isConnected)opener.focus()});\n }\n d.addEventListener('click',e=>{\n const t=e.target;if(!(t instanceof Element))return;\n const tc=t.closest('a.tc[data-t]');\n if(tc){if(!P||!P.has(tc.dataset.s))return;e.preventDefault();const s=tc.dataset.s,at=Number(tc.dataset.t),c=caseAt(s,at)||tc.closest('.case')||(dlg&&dlg.open?vCase:null);if(dlg&&dlg.open)dlg.close();if(c)setCurrent(c,false,!tc.closest('.case'));lastT=at;P.load(s,at,P.playing());return}\n const go=t.closest('a[href^=\"#case-\"]');\n if(go){const c=d.getElementById(go.getAttribute('href').slice(1));if(!c||!c.matches('.case[data-i]'))return;e.preventDefault();if(c.hidden)filter('all');toCard(c);setCurrent(c,true,false);return}\n const shot=t.closest('[data-shot]');\n if(shot&&dlg&&dlg.showModal){e.preventDefault();opener=shot;vCase=shot.closest('.case');vIdx=Number(shot.dataset.shot)||0;showShot();dlg.showModal();q('.v-close').focus();return}\n const c=t.closest('.case[data-i]');\n if(!c||t.closest('a,summary,details,input,label')||(t.closest('button')&&!t.closest('.case-go')))return;\n toCard(c);setCurrent(c,true,false);\n });\n const first=cards.find(c=>timed(c)&&(!P||P.has(c.dataset.s)))||cards[0];\n if(first){setCurrent(first,false,false);if(timed(first))lastT=span(first)[0]}\n});\n})();";
|
|
23
23
|
/**
|
|
24
24
|
* Images and video load from the run folder by relative path (`'self'`, and `file:` for a report
|
|
25
25
|
* opened from disk); styles are inline, but for Google Fonts' stylesheet, whose fonts come from
|