@molecule/api-ai-tools 1.9.1 → 1.9.3
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 +211 -28
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/pipeline-exit-note.d.ts +37 -0
- package/dist/pipeline-exit-note.d.ts.map +1 -0
- package/dist/pipeline-exit-note.js +154 -0
- package/dist/suite-overlap.d.ts +7 -4
- package/dist/suite-overlap.d.ts.map +1 -1
- package/dist/suite-overlap.js +154 -7
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +95 -17
- package/dist/trace-artifacts.d.ts +40 -0
- package/dist/trace-artifacts.d.ts.map +1 -1
- package/dist/trace-artifacts.js +169 -10
- package/dist/utilities.d.ts +83 -21
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +289 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-10-
|
|
6
|
+
Generated: 2026-10-17T20:38:26.582Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-ai-tools
|
|
@@ -352,6 +352,12 @@ interface TraceRequest {
|
|
|
352
352
|
sent?: string
|
|
353
353
|
/** What came back for that 4xx, bounded the same way — the API's own error body. */
|
|
354
354
|
got?: string
|
|
355
|
+
/**
|
|
356
|
+
* The browser's own resource type (`document`, `fetch`, `xhr`, `font`, `image`, `stylesheet`,
|
|
357
|
+
* `script`, …). `document` when the request was the page load itself; when it ended in a
|
|
358
|
+
* `net::ERR_*`, nothing rendered and no selector or app request was measured.
|
|
359
|
+
*/
|
|
360
|
+
type?: string
|
|
355
361
|
}
|
|
356
362
|
```
|
|
357
363
|
|
|
@@ -757,6 +763,28 @@ interface FailureCause {
|
|
|
757
763
|
* (xr-molecule-flash-m110 +18:42 rewrote a CORS middleware for a 20 s connection timeout).
|
|
758
764
|
*/
|
|
759
765
|
kind: RunFailureKind
|
|
766
|
+
/**
|
|
767
|
+
* What the page itself showed at the moment of the failure, when the caller read it from
|
|
768
|
+
* Playwright's `error-context.md` (the alert / error list). The failure's own error line names
|
|
769
|
+
* the symptom — `waitForURL` timed out — and never what the page was saying: xr-molecule-flash-
|
|
770
|
+
* m122 +23:39 grouped eight `waitForURL` timeouts under one line while the page snapshots named
|
|
771
|
+
* the cause (`email can't be blank`, `username can't be blank` — the settings form submitted
|
|
772
|
+
* before its values had loaded). Attached to the cause so the fix needs no `cat` of the file.
|
|
773
|
+
*/
|
|
774
|
+
pageShowed?: string[]
|
|
775
|
+
}
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
#### `CausePageErrors`
|
|
779
|
+
|
|
780
|
+
One failing test's page errors, as read from its `error-context.md`.
|
|
781
|
+
|
|
782
|
+
```typescript
|
|
783
|
+
interface CausePageErrors {
|
|
784
|
+
/** The test's location as the log prints it (`settings.spec.ts:107`). */
|
|
785
|
+
where: string
|
|
786
|
+
/** The alert / error items the page showed at the moment it failed. */
|
|
787
|
+
items: readonly string[]
|
|
760
788
|
}
|
|
761
789
|
```
|
|
762
790
|
|
|
@@ -905,6 +933,37 @@ function locatedCommandSegments(command: string): LocatedCommandSegment[]
|
|
|
905
933
|
|
|
906
934
|
**Returns:** One entry per statement or pipeline stage, in order.
|
|
907
935
|
|
|
936
|
+
#### `statementArgumentEnd(command, start, end)`
|
|
937
|
+
|
|
938
|
+
Where an option of a statement's program belongs: one past the statement's last ARGUMENT.
|
|
939
|
+
|
|
940
|
+
A flag written "at the end of the command" is not the runner's: a statement can end on a
|
|
941
|
+
redirection (`… 2>&1`), and a statement can sit inside a group whose closer belongs to the
|
|
942
|
+
shell, not to the words (`( … )`, `{ …; }`). Appending after that closer is a different shell
|
|
943
|
+
word that the group has already closed — `… --config=x 2>&1) --reporter=list` is
|
|
944
|
+
`sh: Syntax error: word unexpected`, which killed a backgrounded walk at once and pushed the
|
|
945
|
+
model off the platform's runner shape (xr-molecule-flash-m129 +34:29). Write the option where
|
|
946
|
+
the program's own arguments end and the rest of the statement still parses:
|
|
947
|
+
`… --config=x --reporter=list 2>&1)`.
|
|
948
|
+
|
|
949
|
+
The statement must be one {@link locatedCommandSegments} placed in THIS command: a statement
|
|
950
|
+
inside a nested `sh -c '<command>'` string has no offsets here (its positions are positions in
|
|
951
|
+
that string), so null is returned rather than a splice into the outer text.
|
|
952
|
+
|
|
953
|
+
```typescript
|
|
954
|
+
function statementArgumentEnd(
|
|
955
|
+
command: string,
|
|
956
|
+
start: number | null,
|
|
957
|
+
end: number | null,
|
|
958
|
+
): number | null
|
|
959
|
+
```
|
|
960
|
+
|
|
961
|
+
- `command` — The shell command.
|
|
962
|
+
- `start` — The statement's first character ({@link LocatedCommandSegment.start}).
|
|
963
|
+
- `end` — One past the statement's last character ({@link LocatedCommandSegment.end}).
|
|
964
|
+
|
|
965
|
+
**Returns:** The offset to write the option at, or null when the statement cannot be placed here.
|
|
966
|
+
|
|
908
967
|
#### `commandTimeoutSeconds(command)`
|
|
909
968
|
|
|
910
969
|
The bound a command puts on its own run: the largest `timeout <N>` any of its segments runs
|
|
@@ -1227,6 +1286,30 @@ function commandRunsNoTests(command: string): boolean
|
|
|
1227
1286
|
|
|
1228
1287
|
**Returns:** True when the command invokes a runner only to print.
|
|
1229
1288
|
|
|
1289
|
+
#### `pipelineExitCodeNote(command, exitCode, output)`
|
|
1290
|
+
|
|
1291
|
+
The sentence an `exec_command` result carries beside `exitCode` when the code belongs to a
|
|
1292
|
+
pipeline's last stage rather than to the check that printed the output.
|
|
1293
|
+
|
|
1294
|
+
Two shapes, both from a hand-run check with an unguarded pipe:
|
|
1295
|
+
|
|
1296
|
+
- the code says 0 and the output carries failures (`tsc | head` reports `head`'s 0);
|
|
1297
|
+
- the code is non-zero and the checker printed no failures (`tsc | head && tail missing.log`
|
|
1298
|
+
reports `tail`'s 1, and the checker was clean).
|
|
1299
|
+
|
|
1300
|
+
A command with no pipe, a pipe guarded by `pipefail`, a pipeline where no checker runs, or a
|
|
1301
|
+
code and an output that agree all return null.
|
|
1302
|
+
|
|
1303
|
+
```typescript
|
|
1304
|
+
function pipelineExitCodeNote(command: string, exitCode: number, output: string): string | null
|
|
1305
|
+
```
|
|
1306
|
+
|
|
1307
|
+
- `command` — The command as the executor sent it.
|
|
1308
|
+
- `exitCode` — The code the shell reported (the pipeline's last stage's).
|
|
1309
|
+
- `output` — The command's raw stdout and stderr, for the checker's own text.
|
|
1310
|
+
|
|
1311
|
+
**Returns:** One sentence naming the stage the code came from, or null.
|
|
1312
|
+
|
|
1230
1313
|
#### `leadingSleepPeek(command)`
|
|
1231
1314
|
|
|
1232
1315
|
The leading `sleep` of a command, when the first statement is one and it asks for at least
|
|
@@ -1316,7 +1399,7 @@ function withSuiteConfig(command: string, config: string | null | undefined): st
|
|
|
1316
1399
|
|
|
1317
1400
|
**Returns:** The command with the flag, or the command unchanged.
|
|
1318
1401
|
|
|
1319
|
-
#### `scopedRerunCommand(command, locations, excluded, config)`
|
|
1402
|
+
#### `scopedRerunCommand(command, locations, excluded, config, cwd)`
|
|
1320
1403
|
|
|
1321
1404
|
The whole-suite command made scoped to the tests it should re-run instead: the same
|
|
1322
1405
|
invocation — same directory, same settings — with the named `file:line`s in place of the whole
|
|
@@ -1334,13 +1417,15 @@ function scopedRerunCommand(
|
|
|
1334
1417
|
locations: readonly string[],
|
|
1335
1418
|
excluded?: readonly string[],
|
|
1336
1419
|
config?: string | null,
|
|
1420
|
+
cwd?: string | null,
|
|
1337
1421
|
): string
|
|
1338
1422
|
```
|
|
1339
1423
|
|
|
1340
1424
|
- `command` — The whole-suite run's command.
|
|
1341
|
-
- `locations` — The failing `file:line`s to re-run, as the run's own log printed them
|
|
1425
|
+
- `locations` — The failing `file:line`s to re-run, as the run's own log printed them. A location the reporter printed relative to the runner's own directory (`../../fixtures/…`, which no absolute path contains) is resolved here ({@link playwrightLocations}), so the command this returns is one Playwright can match.
|
|
1342
1426
|
- `excluded` — The test titles the request carves out. They are inverted out (`--grep-invert`) so a re-run of the failing locations cannot report one of them again — xr-molecule-flash-m101 re-ran the whole 139-test suite and spent ~4 minutes to be told about a test the request had already said does not count.
|
|
1343
1427
|
- `config` — The config the run loaded, when the caller knows it; added when the command does not name one.
|
|
1428
|
+
- `cwd` — The directory `exec_command` was given, when it was; the base a location is resolved against when the command does not `cd` anywhere.
|
|
1344
1429
|
|
|
1345
1430
|
**Returns:** The scoped command, or the command unchanged when it runs no Playwright suite.
|
|
1346
1431
|
|
|
@@ -1591,6 +1676,51 @@ function parseTraceArtifacts(stdout: string): TraceArtifact[]
|
|
|
1591
1676
|
|
|
1592
1677
|
**Returns:** One entry per trace it printed.
|
|
1593
1678
|
|
|
1679
|
+
#### `isStaticAssetRequest(request)`
|
|
1680
|
+
|
|
1681
|
+
Whether a request is one of the page shell's, not the test's (`STATIC_ASSET_PATH`).
|
|
1682
|
+
|
|
1683
|
+
The document itself is never incidental — a page that never loaded IS the failure — and a
|
|
1684
|
+
request whose type is the app's own API (`fetch`/`xhr`) is judged by its path alone.
|
|
1685
|
+
|
|
1686
|
+
```typescript
|
|
1687
|
+
function isStaticAssetRequest(request: TraceRequest): boolean
|
|
1688
|
+
```
|
|
1689
|
+
|
|
1690
|
+
- `request` — One request a trace recorded.
|
|
1691
|
+
|
|
1692
|
+
**Returns:** True when the request is incidental to the step under test.
|
|
1693
|
+
|
|
1694
|
+
#### `failedRequest(request)`
|
|
1695
|
+
|
|
1696
|
+
Whether a trace recorded a request the server actually failed: a 4xx/5xx, or a network error.
|
|
1697
|
+
|
|
1698
|
+
A 404 on a static asset is excepted: `/sw.js` and `/fonts/*` 404 on an app that never shipped
|
|
1699
|
+
them, and naming one as a failure sent m125 into writing the caching worker it had asked about.
|
|
1700
|
+
A 5xx on an asset, or a network error, still counts — the server did fail.
|
|
1701
|
+
|
|
1702
|
+
```typescript
|
|
1703
|
+
function failedRequest(request: TraceRequest): boolean
|
|
1704
|
+
```
|
|
1705
|
+
|
|
1706
|
+
- `request` — One request a trace recorded.
|
|
1707
|
+
|
|
1708
|
+
**Returns:** True when the request failed in a way the note should name.
|
|
1709
|
+
|
|
1710
|
+
#### `unansweredRequest(request)`
|
|
1711
|
+
|
|
1712
|
+
Whether a trace recorded NO response and no reason for it — a request that was aborted or still
|
|
1713
|
+
in flight when the test ended. It is not evidence that the server failed (m112 +30:45), and one
|
|
1714
|
+
the page shell made is not evidence about the step at all (m125 +29:33).
|
|
1715
|
+
|
|
1716
|
+
```typescript
|
|
1717
|
+
function unansweredRequest(request: TraceRequest): boolean
|
|
1718
|
+
```
|
|
1719
|
+
|
|
1720
|
+
- `request` — One request a trace recorded.
|
|
1721
|
+
|
|
1722
|
+
**Returns:** True when the request is still in flight and worth naming.
|
|
1723
|
+
|
|
1594
1724
|
#### `failureTraceNote(items, target, earlierFailures)`
|
|
1595
1725
|
|
|
1596
1726
|
The note a failed suite run's result carries: what each failing test's page actually sent, and
|
|
@@ -1911,6 +2041,12 @@ are output-only ({@link isOutputOnlyFilter}): a `| tee` or `| xargs` keeps its p
|
|
|
1911
2041
|
caller that reports the run's exit code must then treat it as unknown
|
|
1912
2042
|
({@link suiteRunPipedAfterRunner}).
|
|
1913
2043
|
|
|
2044
|
+
A statement after the run's own pipeline (`; echo done`, `&& echo ok`) does not protect the
|
|
2045
|
+
filters before it: the filter is thrown away and the trailing statement is kept, so the log the
|
|
2046
|
+
run writes still holds every failure (xr-molecule-flash-m121 — a `| tail -5; echo done` kept its
|
|
2047
|
+
tail, and a 95-second walk's log held only the tally while the platform's own hold had handed
|
|
2048
|
+
that command back).
|
|
2049
|
+
|
|
1914
2050
|
```typescript
|
|
1915
2051
|
function stripTrailingSuiteFilters(command: string): SuiteFilterStrip
|
|
1916
2052
|
```
|
|
@@ -2437,28 +2573,65 @@ function repeatingFailure(log: string): RepeatingFailure | null
|
|
|
2437
2573
|
|
|
2438
2574
|
**Returns:** The repeating cause, or null when no signature has {@link REPEATING_FAILURE_MIN} distinct tests behind it.
|
|
2439
2575
|
|
|
2440
|
-
#### `
|
|
2576
|
+
#### `specFilesSelected(command)`
|
|
2441
2577
|
|
|
2442
|
-
|
|
2443
|
-
|
|
2578
|
+
How many test FILES a Playwright run's own command narrows it to, or null when it selects the
|
|
2579
|
+
whole suite (or its selection cannot be read).
|
|
2580
|
+
|
|
2581
|
+
{@link universalCause}'s file threshold is written for a whole-suite run, which a narrowed run
|
|
2582
|
+
can never reach. xr-molecule-flash-m119 (+42:08) re-ran ONE spec file against a hand-started
|
|
2583
|
+
`vite preview` the browser could not reach, and every test in it failed `page.goto: Timeout` —
|
|
2584
|
+
but one file is below {@link UNIVERSAL_CAUSE_FILES}, so the wait sat out its entire 280 s
|
|
2585
|
+
budget on a run that had already measured all it could.
|
|
2444
2586
|
|
|
2445
|
-
The
|
|
2446
|
-
{@link
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
or that leaves other tests passing, or that shares the run with failures of another shape,
|
|
2451
|
-
leaves the run with something to say, and the run is the only thing that will say it. X1
|
|
2452
|
-
flash-m83 (2026-10-16) stopped eight local runs at their first repeating cause over 14.5
|
|
2453
|
-
minutes and never finished one; three of its deploys each fixed a single cause that a finished
|
|
2454
|
-
run would have listed alongside the others.
|
|
2587
|
+
The command is read through {@link commandSegments}, so a `playwright test` named as an
|
|
2588
|
+
argument is not a run. A {@link PLAYWRIGHT_VALUE_FLAGS} flag written without `=` takes the next
|
|
2589
|
+
word as its value, so a `--config app/e2e-suite.config.ts` is never counted as a spec file; a
|
|
2590
|
+
directory or a bare substring filter names files the command does not list, which answers null
|
|
2591
|
+
(the whole-suite threshold) rather than a count of the wrong files.
|
|
2455
2592
|
|
|
2456
2593
|
```typescript
|
|
2457
|
-
function
|
|
2594
|
+
function specFilesSelected(command: string): number | null
|
|
2595
|
+
```
|
|
2596
|
+
|
|
2597
|
+
- `command` — The run's command.
|
|
2598
|
+
|
|
2599
|
+
**Returns:** The number of distinct test files it names, or null when it names none (the whole suite) or the selection cannot be told.
|
|
2600
|
+
|
|
2601
|
+
#### `universalCause(log, found, command)`
|
|
2602
|
+
|
|
2603
|
+
Whether a repeating cause is failing the whole run — the one case where stopping it is the
|
|
2604
|
+
right call.
|
|
2605
|
+
|
|
2606
|
+
The test is: the cause accounts for every failure the log names, it has hit the spec-file
|
|
2607
|
+
threshold, and nothing has passed since its first failure. The threshold is
|
|
2608
|
+
{@link UNIVERSAL_CAUSE_FILES} for a whole-suite run but the number of files the command
|
|
2609
|
+
SELECTED for a narrowed one ({@link specFilesSelected}): a one-file run can never span three,
|
|
2610
|
+
and xr-molecule-flash-m119 (+42:08) waited out its whole budget on exactly that shape. An app
|
|
2611
|
+
that is not up, a 5xx on every request, or a selector that is missing on every page all look
|
|
2612
|
+
like that, and every remaining test will fail the same way — so the run's remaining minutes
|
|
2613
|
+
measure nothing. A CONNECTION-class cause ({@link CONNECTION_CAUSE}) needs no file span at all:
|
|
2614
|
+
three tests that could not reach the app, with nothing passing since, is the app-unreachable
|
|
2615
|
+
case however few files the run walks.
|
|
2616
|
+
|
|
2617
|
+
Anything less is NOT this: a cause that stops at one file of a multi-file run, or that leaves
|
|
2618
|
+
other tests passing, or that shares the run with failures of another shape, leaves the run with
|
|
2619
|
+
something to say, and the run is the only thing that will say it. X1 flash-m83 (2026-10-16)
|
|
2620
|
+
stopped eight local runs at their first repeating cause over 14.5 minutes and never finished
|
|
2621
|
+
one; three of its deploys each fixed a single cause that a finished run would have listed
|
|
2622
|
+
alongside the others.
|
|
2623
|
+
|
|
2624
|
+
```typescript
|
|
2625
|
+
function universalCause(
|
|
2626
|
+
log: string,
|
|
2627
|
+
found: RepeatingFailure,
|
|
2628
|
+
command?: string | null,
|
|
2629
|
+
): UniversalCause | null
|
|
2458
2630
|
```
|
|
2459
2631
|
|
|
2460
2632
|
- `log` — The log so far.
|
|
2461
2633
|
- `found` — The repeating cause {@link repeatingFailure} found in it.
|
|
2634
|
+
- `command` — How the run was started, when the caller knows it: its spec-file selection scales the file threshold ({@link specFilesSelected}).
|
|
2462
2635
|
|
|
2463
2636
|
**Returns:** The cause's count and files, or null when the run is not failing whole.
|
|
2464
2637
|
|
|
@@ -2469,8 +2642,10 @@ for: a PROVEN cause that is failing the whole run.
|
|
|
2469
2642
|
|
|
2470
2643
|
Both halves are load-bearing, each of them learned from a run that lost minutes to the other.
|
|
2471
2644
|
|
|
2472
|
-
- **Failing the WHOLE run** is {@link universalCause}: every failure the log names, across
|
|
2473
|
-
{@link UNIVERSAL_CAUSE_FILES}
|
|
2645
|
+
- **Failing the WHOLE run** is {@link universalCause}: every failure the log names, across the
|
|
2646
|
+
spec-file threshold — {@link UNIVERSAL_CAUSE_FILES}, or the files a narrowed run's own
|
|
2647
|
+
command selects, or {@link CONNECTION_CAUSE_TESTS} tests of an app that never answered — with
|
|
2648
|
+
nothing passing since the first. That is the
|
|
2474
2649
|
dont-stop-runs rule. X1 flash-m83 (2026-10-16) stopped eight local runs at their first
|
|
2475
2650
|
repeating cause in 14.5 minutes and never finished one, and a run that still has other causes
|
|
2476
2651
|
left to name is the only thing that will name them.
|
|
@@ -2481,9 +2656,6 @@ Both halves are load-bearing, each of them learned from a run that lost minutes
|
|
|
2481
2656
|
xr-molecule-flash-m99 (2026-10-16) was told `status: 'repeating_failure'` twice on that
|
|
2482
2657
|
shape — three `url-navigation.spec.ts` tests at ~16.2 s, one `timeout: 15_000` plus teardown
|
|
2483
2658
|
— read the early return as "stop waiting, edit now", and voided a run that was still walking;
|
|
2484
|
-
the second cost a 224 s wait that ended with no result at all.
|
|
2485
|
-
|
|
2486
|
-
Neither half alone is enough, and {@link repeatingFailure} finding a signature is not either:
|
|
2487
2659
|
|
|
2488
2660
|
_(description truncated — read the full text in `node_modules/@molecule/api-ai-tools/dist/utilities.d.ts`.)_
|
|
2489
2661
|
|
|
@@ -2581,6 +2753,7 @@ function failureCausesNote(
|
|
|
2581
2753
|
log: string,
|
|
2582
2754
|
excluded?: readonly string[],
|
|
2583
2755
|
run?: { command: string; cwd?: string; log?: string; config?: string | null },
|
|
2756
|
+
pageErrors?: readonly CausePageErrors[],
|
|
2584
2757
|
): string | null
|
|
2585
2758
|
```
|
|
2586
2759
|
|
|
@@ -2597,11 +2770,11 @@ invocation, in the same directory, narrowed to those tests — or null when the
|
|
|
2597
2770
|
is not a Playwright run this can narrow.
|
|
2598
2771
|
|
|
2599
2772
|
The `locations` are the paths the run's own log printed, which are relative to the directory
|
|
2600
|
-
that run started in, so
|
|
2601
|
-
unless it already changes into one of its own, because the
|
|
2602
|
-
wherever it starts. The returned command is for AFTER the run
|
|
2603
|
-
the same app and database, and that is exactly what is
|
|
2604
|
-
({@link suiteRunInTheWay}).
|
|
2773
|
+
that run started in, so the composer resolves them there ({@link scopedRerunCommand}): the
|
|
2774
|
+
command names that directory unless it already changes into one of its own, because the
|
|
2775
|
+
executor's next command starts wherever it starts. The returned command is for AFTER the run
|
|
2776
|
+
ends — it is a second run against the same app and database, and that is exactly what is
|
|
2777
|
+
refused while the run walks ({@link suiteRunInTheWay}).
|
|
2605
2778
|
|
|
2606
2779
|
```typescript
|
|
2607
2780
|
function rerunOfRunningSuite(
|
|
@@ -2651,12 +2824,13 @@ function repeatingFailureNote(
|
|
|
2651
2824
|
stop: string
|
|
2652
2825
|
universal?: UniversalCause | null
|
|
2653
2826
|
run?: { command: string; cwd?: string }
|
|
2827
|
+
editsInvalidateRun?: boolean
|
|
2654
2828
|
},
|
|
2655
2829
|
): string
|
|
2656
2830
|
```
|
|
2657
2831
|
|
|
2658
2832
|
- `found` — What {@link repeatingFailure} found.
|
|
2659
|
-
- `o` — The run's facts: its `taskId`, its `log` path, `stop` — the shell command that stops it, printed only for an {@link earlyReturnCause} — `universal`, what {@link universalCause} found (absent means the run is not failing whole),
|
|
2833
|
+
- `o` — The run's facts: its `taskId`, its `log` path, `stop` — the shell command that stops it, printed only for an {@link earlyReturnCause} — `universal`, what {@link universalCause} found (absent means the run is not failing whole), `run`, how the run was started ({@link rerunOfRunningSuite}) when the caller knows it, and `editsInvalidateRun`, true when the run measures the sandbox's own app (a local run, where an edit now changes what the suite is testing and its result stops counting).
|
|
2660
2834
|
|
|
2661
2835
|
**Returns:** The note.
|
|
2662
2836
|
|
|
@@ -3189,6 +3363,15 @@ property of the run rather than of a page.
|
|
|
3189
3363
|
const UNIVERSAL_CAUSE_FILES: 3
|
|
3190
3364
|
```
|
|
3191
3365
|
|
|
3366
|
+
#### `CONNECTION_CAUSE_TESTS`
|
|
3367
|
+
|
|
3368
|
+
How many tests a connection-class cause must cover before the run is stopped even when they
|
|
3369
|
+
are all in one file — see {@link universalCause}.
|
|
3370
|
+
|
|
3371
|
+
```typescript
|
|
3372
|
+
const CONNECTION_CAUSE_TESTS: 3
|
|
3373
|
+
```
|
|
3374
|
+
|
|
3192
3375
|
#### `PARSE_CHECKABLE`
|
|
3193
3376
|
|
|
3194
3377
|
Files a parse check can vouch for cheaply right after a write.
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,7 @@ export * from './cut-run.js';
|
|
|
137
137
|
export * from './failure-kind.js';
|
|
138
138
|
export * from './input-normalizer.js';
|
|
139
139
|
export * from './no-test-run.js';
|
|
140
|
+
export * from './pipeline-exit-note.js';
|
|
140
141
|
export * from './schemas.js';
|
|
141
142
|
export * from './sleep-peek.js';
|
|
142
143
|
export * from './suite-overlap.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkIG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkIG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -137,6 +137,7 @@ export * from './cut-run.js';
|
|
|
137
137
|
export * from './failure-kind.js';
|
|
138
138
|
export * from './input-normalizer.js';
|
|
139
139
|
export * from './no-test-run.js';
|
|
140
|
+
export * from './pipeline-exit-note.js';
|
|
140
141
|
export * from './schemas.js';
|
|
141
142
|
export * from './sleep-peek.js';
|
|
142
143
|
export * from './suite-overlap.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The exit code a hand-run check's result carries is the pipeline's LAST stage's, and a weak
|
|
3
|
+
* executor reads the number as the check's verdict.
|
|
4
|
+
*
|
|
5
|
+
* `npx tsc --noEmit 2>&1 | head -40` reports `head`'s 0 while the output above it carries a type
|
|
6
|
+
* error, and `… | head -40 && tail -30 missing.log` reports `tail`'s 1 while the checker was clean —
|
|
7
|
+
* both measured in xr-molecule-flash-m117 (+04:06, +08:05). A model that trusts the code concludes
|
|
8
|
+
* "clean" and ships a build that does not compile, or hunts an error that is not there. This module
|
|
9
|
+
* says which stage produced the code, and what the output actually carries, in one sentence beside
|
|
10
|
+
* `exitCode`.
|
|
11
|
+
*
|
|
12
|
+
* The parse is the package's own shell reader ({@link locatedCommandSegments}), so a `|` inside
|
|
13
|
+
* quotes or a heredoc is not a stage, and `set -o pipefail` (where it really runs) turns the note
|
|
14
|
+
* off: then the code IS the check's.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The sentence an `exec_command` result carries beside `exitCode` when the code belongs to a
|
|
20
|
+
* pipeline's last stage rather than to the check that printed the output.
|
|
21
|
+
*
|
|
22
|
+
* Two shapes, both from a hand-run check with an unguarded pipe:
|
|
23
|
+
*
|
|
24
|
+
* - the code says 0 and the output carries failures (`tsc | head` reports `head`'s 0);
|
|
25
|
+
* - the code is non-zero and the checker printed no failures (`tsc | head && tail missing.log`
|
|
26
|
+
* reports `tail`'s 1, and the checker was clean).
|
|
27
|
+
*
|
|
28
|
+
* A command with no pipe, a pipe guarded by `pipefail`, a pipeline where no checker runs, or a
|
|
29
|
+
* code and an output that agree all return null.
|
|
30
|
+
*
|
|
31
|
+
* @param command - The command as the executor sent it.
|
|
32
|
+
* @param exitCode - The code the shell reported (the pipeline's last stage's).
|
|
33
|
+
* @param output - The command's raw stdout and stderr, for the checker's own text.
|
|
34
|
+
* @returns One sentence naming the stage the code came from, or null.
|
|
35
|
+
*/
|
|
36
|
+
export declare function pipelineExitCodeNote(command: string, exitCode: number, output: string): string | null;
|
|
37
|
+
//# sourceMappingURL=pipeline-exit-note.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-exit-note.d.ts","sourceRoot":"","sources":["../src/pipeline-exit-note.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA2GH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,IAAI,CAsCf"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The exit code a hand-run check's result carries is the pipeline's LAST stage's, and a weak
|
|
3
|
+
* executor reads the number as the check's verdict.
|
|
4
|
+
*
|
|
5
|
+
* `npx tsc --noEmit 2>&1 | head -40` reports `head`'s 0 while the output above it carries a type
|
|
6
|
+
* error, and `… | head -40 && tail -30 missing.log` reports `tail`'s 1 while the checker was clean —
|
|
7
|
+
* both measured in xr-molecule-flash-m117 (+04:06, +08:05). A model that trusts the code concludes
|
|
8
|
+
* "clean" and ships a build that does not compile, or hunts an error that is not there. This module
|
|
9
|
+
* says which stage produced the code, and what the output actually carries, in one sentence beside
|
|
10
|
+
* `exitCode`.
|
|
11
|
+
*
|
|
12
|
+
* The parse is the package's own shell reader ({@link locatedCommandSegments}), so a `|` inside
|
|
13
|
+
* quotes or a heredoc is not a stage, and `set -o pipefail` (where it really runs) turns the note
|
|
14
|
+
* off: then the code IS the check's.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { locatedCommandSegments } from './command-position.js';
|
|
19
|
+
/** The shells whose `-o pipefail` makes a pipeline report its first failing stage. */
|
|
20
|
+
const PIPEFAIL_SHELLS = new Set(['ash', 'bash', 'dash', 'ksh', 'sh', 'zsh']);
|
|
21
|
+
/**
|
|
22
|
+
* The programs a pipeline may end with when all they do is read what was printed and print it
|
|
23
|
+
* again — the stages that hand back their own status in place of the check's.
|
|
24
|
+
*/
|
|
25
|
+
const OUTPUT_ONLY_FILTERS = new Set([
|
|
26
|
+
'awk',
|
|
27
|
+
'cat',
|
|
28
|
+
'column',
|
|
29
|
+
'cut',
|
|
30
|
+
'egrep',
|
|
31
|
+
'fgrep',
|
|
32
|
+
'fmt',
|
|
33
|
+
'fold',
|
|
34
|
+
'grep',
|
|
35
|
+
'head',
|
|
36
|
+
'jq',
|
|
37
|
+
'nl',
|
|
38
|
+
'rg',
|
|
39
|
+
'sed',
|
|
40
|
+
'sort',
|
|
41
|
+
'tail',
|
|
42
|
+
'tr',
|
|
43
|
+
'uniq',
|
|
44
|
+
'wc',
|
|
45
|
+
]);
|
|
46
|
+
/** `1 type error` / `2 type errors`. */
|
|
47
|
+
const plural = (count, one, many) => `${count} ${count === 1 ? one : many}`;
|
|
48
|
+
/**
|
|
49
|
+
* The failure count a runner's tally names. Vitest prints two tallies — `Test Files 1 failed`
|
|
50
|
+
* above `Tests 2 failed` — and the last one is the tests, which is the number the note means.
|
|
51
|
+
*
|
|
52
|
+
* @param output - The runner's output.
|
|
53
|
+
* @returns The count in the last `N failed` tally, or 0.
|
|
54
|
+
*/
|
|
55
|
+
const failedTally = (output) => {
|
|
56
|
+
const tallies = [...output.matchAll(/\b(\d+) failed\b/g)];
|
|
57
|
+
return Number(tallies.at(-1)?.[1] ?? 0);
|
|
58
|
+
};
|
|
59
|
+
/** The checkers whose output says pass or fail in text of its own. */
|
|
60
|
+
const CHECKERS = [
|
|
61
|
+
{
|
|
62
|
+
name: 'tsc',
|
|
63
|
+
runs: (program) => program === 'tsc' || program === 'vue-tsc',
|
|
64
|
+
failures: (output) => {
|
|
65
|
+
const errors = output.match(/\berror TS\d+/g)?.length ?? 0;
|
|
66
|
+
if (errors > 0)
|
|
67
|
+
return errors;
|
|
68
|
+
const found = /\bFound (\d+) errors?/.exec(output);
|
|
69
|
+
return found ? Number(found[1]) : 0;
|
|
70
|
+
},
|
|
71
|
+
label: (count) => plural(count, 'type error', 'type errors'),
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'eslint',
|
|
75
|
+
runs: (program) => program === 'eslint',
|
|
76
|
+
failures: (output) => {
|
|
77
|
+
const problems = /✖\s*(\d+)\s+problems?/.exec(output);
|
|
78
|
+
return problems ? Number(problems[1]) : 0;
|
|
79
|
+
},
|
|
80
|
+
label: (count) => plural(count, 'lint problem', 'lint problems'),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'vitest',
|
|
84
|
+
runs: (program) => program === 'vitest',
|
|
85
|
+
failures: failedTally,
|
|
86
|
+
label: (count) => plural(count, 'failing test', 'failing tests'),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'playwright',
|
|
90
|
+
runs: (_program, text) => /^playwright\s+test\b/.test(text),
|
|
91
|
+
failures: failedTally,
|
|
92
|
+
label: (count) => plural(count, 'failing test', 'failing tests'),
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
/** Whether the command turns on `pipefail`, so a pipeline reports the check's own status. */
|
|
96
|
+
function guardedByPipefail(segments) {
|
|
97
|
+
return segments.some(({ program, args }) => (program === 'set' || PIPEFAIL_SHELLS.has(program)) && args.includes('pipefail'));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The sentence an `exec_command` result carries beside `exitCode` when the code belongs to a
|
|
101
|
+
* pipeline's last stage rather than to the check that printed the output.
|
|
102
|
+
*
|
|
103
|
+
* Two shapes, both from a hand-run check with an unguarded pipe:
|
|
104
|
+
*
|
|
105
|
+
* - the code says 0 and the output carries failures (`tsc | head` reports `head`'s 0);
|
|
106
|
+
* - the code is non-zero and the checker printed no failures (`tsc | head && tail missing.log`
|
|
107
|
+
* reports `tail`'s 1, and the checker was clean).
|
|
108
|
+
*
|
|
109
|
+
* A command with no pipe, a pipe guarded by `pipefail`, a pipeline where no checker runs, or a
|
|
110
|
+
* code and an output that agree all return null.
|
|
111
|
+
*
|
|
112
|
+
* @param command - The command as the executor sent it.
|
|
113
|
+
* @param exitCode - The code the shell reported (the pipeline's last stage's).
|
|
114
|
+
* @param output - The command's raw stdout and stderr, for the checker's own text.
|
|
115
|
+
* @returns One sentence naming the stage the code came from, or null.
|
|
116
|
+
*/
|
|
117
|
+
export function pipelineExitCodeNote(command, exitCode, output) {
|
|
118
|
+
const running = locatedCommandSegments(command).filter((entry) => entry.segment !== null);
|
|
119
|
+
if (running.length < 2)
|
|
120
|
+
return null;
|
|
121
|
+
if (!running.some((entry) => entry.separator.trim() === '|'))
|
|
122
|
+
return null;
|
|
123
|
+
const segments = running.map((entry) => entry.segment);
|
|
124
|
+
if (guardedByPipefail(segments))
|
|
125
|
+
return null;
|
|
126
|
+
let checkerAt = -1;
|
|
127
|
+
for (let i = segments.length - 1; i >= 0; i -= 1) {
|
|
128
|
+
const segment = segments[i];
|
|
129
|
+
if (CHECKERS.some((checker) => checker.runs(segment.program, segment.text))) {
|
|
130
|
+
checkerAt = i;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (checkerAt < 0)
|
|
135
|
+
return null;
|
|
136
|
+
// The check's own status is lost only when a stage of the SAME pipeline follows it; a `&&` after
|
|
137
|
+
// the check already reports a real failure of its own, and a check followed by nothing reports
|
|
138
|
+
// its own code.
|
|
139
|
+
if (running[checkerAt + 1]?.separator.trim() !== '|')
|
|
140
|
+
return null;
|
|
141
|
+
const checkerSegment = segments[checkerAt];
|
|
142
|
+
const checker = CHECKERS.find((candidate) => candidate.runs(checkerSegment.program, checkerSegment.text));
|
|
143
|
+
const last = segments[segments.length - 1];
|
|
144
|
+
const failures = checker.failures(output);
|
|
145
|
+
if (exitCode === 0 && failures > 0) {
|
|
146
|
+
return (`the exit code 0 is the last stage's (${last.program}), not ${checker.name}'s — ` +
|
|
147
|
+
`the output carries ${checker.label(failures)}`);
|
|
148
|
+
}
|
|
149
|
+
if (exitCode !== 0 && failures === 0 && OUTPUT_ONLY_FILTERS.has(last.program)) {
|
|
150
|
+
return (`the exit code ${exitCode} is the last stage's (${last.program}), not ${checker.name}'s — ` +
|
|
151
|
+
'the checker printed no errors');
|
|
152
|
+
}
|
|
153
|
+
return null;
|
|
154
|
+
}
|
package/dist/suite-overlap.d.ts
CHANGED
|
@@ -89,18 +89,21 @@ export declare function withSuiteConfig(command: string, config: string | null |
|
|
|
89
89
|
* `Cannot navigate to invalid URL` because the re-run loaded no base URL).
|
|
90
90
|
*
|
|
91
91
|
* @param command - The whole-suite run's command.
|
|
92
|
-
* @param locations - The failing `file:line`s to re-run, as the run's own log printed them
|
|
93
|
-
*
|
|
94
|
-
*
|
|
92
|
+
* @param locations - The failing `file:line`s to re-run, as the run's own log printed them. A
|
|
93
|
+
* location the reporter printed relative to the runner's own directory (`../../fixtures/…`,
|
|
94
|
+
* which no absolute path contains) is resolved here ({@link playwrightLocations}), so the
|
|
95
|
+
* command this returns is one Playwright can match.
|
|
95
96
|
* @param excluded - The test titles the request carves out. They are inverted out
|
|
96
97
|
* (`--grep-invert`) so a re-run of the failing locations cannot report one of them again —
|
|
97
98
|
* xr-molecule-flash-m101 re-ran the whole 139-test suite and spent ~4 minutes to be told about
|
|
98
99
|
* a test the request had already said does not count.
|
|
99
100
|
* @param config - The config the run loaded, when the caller knows it; added when the command
|
|
100
101
|
* does not name one.
|
|
102
|
+
* @param cwd - The directory `exec_command` was given, when it was; the base a location is
|
|
103
|
+
* resolved against when the command does not `cd` anywhere.
|
|
101
104
|
* @returns The scoped command, or the command unchanged when it runs no Playwright suite.
|
|
102
105
|
*/
|
|
103
|
-
export declare function scopedRerunCommand(command: string, locations: readonly string[], excluded?: readonly string[], config?: string | null): string;
|
|
106
|
+
export declare function scopedRerunCommand(command: string, locations: readonly string[], excluded?: readonly string[], config?: string | null, cwd?: string | null): string;
|
|
104
107
|
/**
|
|
105
108
|
* One suite run, as the rule that decides whether a second may start beside it reads it.
|
|
106
109
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suite-overlap.d.ts","sourceRoot":"","sources":["../src/suite-overlap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;
|
|
1
|
+
{"version":3,"file":"suite-overlap.d.ts","sourceRoot":"","sources":["../src/suite-overlap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAQH;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAoB1D;AAKD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAc1F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,MAAM,EAAE,EAC5B,QAAQ,GAAE,SAAS,MAAM,EAAO,EAChC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAClB,MAAM,CAqCR;AA8ID;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+FAA+F;IAC/F,SAAS,EAAE,OAAO,CAAA;IAClB,oFAAoF;IACpF,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,EACzD,SAAS,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EAC7B,QAAQ,EAAE,SAAS,CAAC,EAAE,GACrB,CAAC,GAAG,IAAI,CAMV;AAqDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAQvD"}
|