@molecule/api-ai-tools 1.16.8 → 1.17.1
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 +209 -6
- package/dist/backends/local.d.ts.map +1 -1
- package/dist/backends/local.js +60 -14
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/playwright-feedback-reporter.d.ts +16 -0
- package/dist/playwright-feedback-reporter.d.ts.map +1 -0
- package/dist/playwright-feedback-reporter.js +85 -0
- package/dist/playwright-feedback-selection.d.ts +13 -0
- package/dist/playwright-feedback-selection.d.ts.map +1 -0
- package/dist/playwright-feedback-selection.js +206 -0
- package/dist/playwright-feedback-types.d.ts +65 -0
- package/dist/playwright-feedback-types.d.ts.map +1 -0
- package/dist/playwright-feedback-types.js +1 -0
- package/dist/playwright-feedback.d.ts +42 -0
- package/dist/playwright-feedback.d.ts.map +1 -0
- package/dist/playwright-feedback.js +318 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +17 -5
- package/dist/types.d.ts +2 -2
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.d.ts.map +1 -1
- package/dist/utilities.js +24 -8
- package/package.json +5 -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-11-
|
|
6
|
+
Generated: 2026-11-06T15:20:37.703Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-ai-tools
|
|
@@ -51,7 +51,7 @@ for await (const event of requireProvider().chat({ system, tools, messages, stre
|
|
|
51
51
|
## Installation
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
npm install @molecule/api-ai-tools @molecule/api-ai
|
|
54
|
+
npm install @molecule/api-ai-tools @molecule/api-ai typescript
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
## API
|
|
@@ -404,6 +404,111 @@ interface RunnerOutputFilter {
|
|
|
404
404
|
}
|
|
405
405
|
```
|
|
406
406
|
|
|
407
|
+
#### `FeedbackSource`
|
|
408
|
+
|
|
409
|
+
A source file already read by the caller. Paths are absolute.
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
interface FeedbackSource {
|
|
413
|
+
path: string
|
|
414
|
+
content: string
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
#### `FeedbackSpec`
|
|
419
|
+
|
|
420
|
+
One supplied or scaffolded spec, with its normal, locally targeted runner command.
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
interface FeedbackSpec extends FeedbackSource {
|
|
424
|
+
command: string
|
|
425
|
+
cwd: string
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
#### `FeedbackProject`
|
|
430
|
+
|
|
431
|
+
The inputs the host already knows; no suite discovery or vendor selection in the scheduler.
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
interface FeedbackProject {
|
|
435
|
+
/** Base for relative source-change paths, already resolved by the host. */
|
|
436
|
+
root?: string
|
|
437
|
+
sources: FeedbackSource[]
|
|
438
|
+
specs: FeedbackSpec[]
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
#### `PlaywrightFeedbackFailure`
|
|
443
|
+
|
|
444
|
+
A native failure, never a static prediction or a completed-suite proof.
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
interface PlaywrightFeedbackFailure {
|
|
448
|
+
spec: string
|
|
449
|
+
line: number
|
|
450
|
+
error: string
|
|
451
|
+
/** The native runner's locator, assertion or timed-out browser operation, apart from redaction. */
|
|
452
|
+
locator: string
|
|
453
|
+
/** Playwright's own failure-time accessibility snapshot, when recorded. */
|
|
454
|
+
rendered?: string
|
|
455
|
+
/** Route render dependencies affected by this write, or the triggering source paths. */
|
|
456
|
+
sourceFiles: string[]
|
|
457
|
+
}
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
#### `PlaywrightFeedbackResult`
|
|
461
|
+
|
|
462
|
+
A diagnosis of one spec file at one source revision. A pass is not whole-suite proof.
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
interface PlaywrightFeedbackResult {
|
|
466
|
+
spec: string
|
|
467
|
+
revision: number
|
|
468
|
+
durationMs: number
|
|
469
|
+
status: 'passed' | 'failed' | 'unavailable'
|
|
470
|
+
failures: PlaywrightFeedbackFailure[]
|
|
471
|
+
/** Native counts for this one diagnostic selection, never whole-suite proof. */
|
|
472
|
+
nativeStats?: PlaywrightReportStats
|
|
473
|
+
reason?: string
|
|
474
|
+
}
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
#### `PlaywrightFeedbackOptions`
|
|
478
|
+
|
|
479
|
+
Host operations for the same scheduler in a CLI process or a remote sandbox.
|
|
480
|
+
|
|
481
|
+
```typescript
|
|
482
|
+
interface PlaywrightFeedbackOptions {
|
|
483
|
+
load: () => Promise<FeedbackProject>
|
|
484
|
+
run: (
|
|
485
|
+
spec: FeedbackSpec,
|
|
486
|
+
sources: string[],
|
|
487
|
+
revision: number,
|
|
488
|
+
emit: (result: PlaywrightFeedbackResult) => void,
|
|
489
|
+
) => Promise<PlaywrightFeedbackResult>
|
|
490
|
+
/** Only current native failures are delivered. Passing apps receive no note. */
|
|
491
|
+
onFailures?: (result: PlaywrightFeedbackResult) => void
|
|
492
|
+
/** Operational state is separate from defect feedback. */
|
|
493
|
+
onResult?: (result: PlaywrightFeedbackResult) => void
|
|
494
|
+
debounceMs?: number
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
#### `PlaywrightFeedback`
|
|
499
|
+
|
|
500
|
+
A nonblocking source-change subscription.
|
|
501
|
+
|
|
502
|
+
```typescript
|
|
503
|
+
interface PlaywrightFeedback {
|
|
504
|
+
changed: (paths: readonly string[]) => void
|
|
505
|
+
takeFailures: () => PlaywrightFeedbackResult[]
|
|
506
|
+
/** Wait only in tests or shutdown; file writes and deploys must never await this. */
|
|
507
|
+
settled: () => Promise<void>
|
|
508
|
+
close: () => Promise<void>
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
407
512
|
#### `PlaywrightReportAttachment`
|
|
408
513
|
|
|
409
514
|
One artifact the runner saved for one test, as the report records it.
|
|
@@ -1350,7 +1455,7 @@ interface ToolBuildConfig {
|
|
|
1350
1455
|
/** Maximum time (ms) one `wait_for_task` call may wait, independently of the foreground {@link commandBudgetMs}. */
|
|
1351
1456
|
waitBudgetMs?: number
|
|
1352
1457
|
|
|
1353
|
-
/** Opt in to
|
|
1458
|
+
/** Opt in to partial diagnostics for new final failure causes at this known deployed URL. */
|
|
1354
1459
|
yieldOnFirstFailureFor?: (taskId: string) => string | null
|
|
1355
1460
|
|
|
1356
1461
|
/** How long (ms) exec_command waits for a command it backgrounded only because the command asked for more than {@link commandBudgetMs}, before handing back a task… */
|
|
@@ -2550,6 +2655,96 @@ function pipelineExitCodeNote(command: string, exitCode: number, output: string)
|
|
|
2550
2655
|
|
|
2551
2656
|
**Returns:** One sentence naming the stage the code came from, or null.
|
|
2552
2657
|
|
|
2658
|
+
#### `selectFeedbackSpecs(project, changed)`
|
|
2659
|
+
|
|
2660
|
+
Prioritize spec files potentially affected by writes. Every file still runs: a click or
|
|
2661
|
+
a helper can navigate somewhere a literal-goto index cannot see. This index never excludes work.
|
|
2662
|
+
|
|
2663
|
+
```typescript
|
|
2664
|
+
function selectFeedbackSpecs(
|
|
2665
|
+
project: FeedbackProject,
|
|
2666
|
+
changed: readonly string[],
|
|
2667
|
+
): Array<{ spec: FeedbackSpec; sourceFiles: string[] }>
|
|
2668
|
+
```
|
|
2669
|
+
|
|
2670
|
+
- `project` — Caller-supplied source and runner inventory.
|
|
2671
|
+
- `changed` — Absolute source paths changed since the previous diagnosis.
|
|
2672
|
+
|
|
2673
|
+
**Returns:** Spec files to run, with their rendering-source context.
|
|
2674
|
+
|
|
2675
|
+
#### `isPlaywrightFeedbackSource(path)`
|
|
2676
|
+
|
|
2677
|
+
Whether a source change can alter markup, copy, styling or local runner configuration.
|
|
2678
|
+
|
|
2679
|
+
```typescript
|
|
2680
|
+
function isPlaywrightFeedbackSource(path: string): boolean
|
|
2681
|
+
```
|
|
2682
|
+
|
|
2683
|
+
- `path` — The path reported by the host's file-change subscription.
|
|
2684
|
+
|
|
2685
|
+
**Returns:** True for app source and data formats; never a correctness judgment.
|
|
2686
|
+
|
|
2687
|
+
#### `createPlaywrightFeedback(options)`
|
|
2688
|
+
|
|
2689
|
+
Subscribe to writes without making them wait for browser work.
|
|
2690
|
+
|
|
2691
|
+
```typescript
|
|
2692
|
+
function createPlaywrightFeedback(options: PlaywrightFeedbackOptions): PlaywrightFeedback
|
|
2693
|
+
```
|
|
2694
|
+
|
|
2695
|
+
- `options` — Source loader, native runner and delivery callbacks.
|
|
2696
|
+
|
|
2697
|
+
**Returns:** A source-change subscription; settle/close are for tests and shutdown only.
|
|
2698
|
+
|
|
2699
|
+
#### `readFeedbackSources(backend, sourceRoots, suiteFiles)`
|
|
2700
|
+
|
|
2701
|
+
Read explicit source roots and supplied helper/spec paths in one backend round trip.
|
|
2702
|
+
The standard filesystem and TypeScript parser own traversal/syntax; this is transport batching.
|
|
2703
|
+
|
|
2704
|
+
```typescript
|
|
2705
|
+
function readFeedbackSources(
|
|
2706
|
+
backend: ExecutionBackend,
|
|
2707
|
+
sourceRoots: readonly string[],
|
|
2708
|
+
suiteFiles: readonly string[],
|
|
2709
|
+
): Promise<FeedbackSource[]>
|
|
2710
|
+
```
|
|
2711
|
+
|
|
2712
|
+
- `backend` — Local or sandbox execution backend.
|
|
2713
|
+
- `sourceRoots` — App source directories, absolute.
|
|
2714
|
+
- `suiteFiles` — Supplied spec/helper paths, absolute.
|
|
2715
|
+
|
|
2716
|
+
**Returns:** Existing, bounded text sources. Missing/unsupported files are ignored.
|
|
2717
|
+
|
|
2718
|
+
#### `runPlaywrightFeedback(backend, spec, sourceFiles, revision, options)`
|
|
2719
|
+
|
|
2720
|
+
Run ONE spec's native command. Callers supply the correctly configured local command and
|
|
2721
|
+
append these runner flags at composition time (rather than modifying shell text here).
|
|
2722
|
+
Native failures are diagnosis, never proof that a complete supplied suite passed.
|
|
2723
|
+
|
|
2724
|
+
```typescript
|
|
2725
|
+
function runPlaywrightFeedback(
|
|
2726
|
+
backend: ExecutionBackend,
|
|
2727
|
+
spec: FeedbackSpec,
|
|
2728
|
+
sourceFiles: string[],
|
|
2729
|
+
revision: number,
|
|
2730
|
+
options: {
|
|
2731
|
+
command: (flags: string[]) => string
|
|
2732
|
+
scratchRoot?: string
|
|
2733
|
+
timeoutMs?: number
|
|
2734
|
+
emit?: (result: PlaywrightFeedbackResult) => void
|
|
2735
|
+
pollMs?: number
|
|
2736
|
+
},
|
|
2737
|
+
): Promise<PlaywrightFeedbackResult>
|
|
2738
|
+
```
|
|
2739
|
+
|
|
2740
|
+
- `backend` — Existing execution backend.
|
|
2741
|
+
- `spec` — The supplied spec and its normal per-file command.
|
|
2742
|
+
- `sourceFiles` — Triggering component files, known to the write/index.
|
|
2743
|
+
- `revision` — Source revision the scheduler will validate before delivery.
|
|
2744
|
+
- `options` — Output location, command composition and a bounded backend budget.
|
|
2745
|
+
|
|
2746
|
+
**Returns:** The actual native outcome and actionable failures only.
|
|
2747
|
+
|
|
2553
2748
|
#### `reportCarriesIdentities(status)`
|
|
2554
2749
|
|
|
2555
2750
|
The report statuses for which the report's own per-test identities and attachments may be used.
|
|
@@ -4712,13 +4907,13 @@ With `finalOnly`, only a failure the run has FINISHED with counts; a pending ret
|
|
|
4712
4907
|
function logShowsInlineFailureBodies(
|
|
4713
4908
|
log: string,
|
|
4714
4909
|
excluded?: readonly string[],
|
|
4715
|
-
options?: { finalOnly?: boolean; noRetries?: boolean },
|
|
4910
|
+
options?: { finalOnly?: boolean; noRetries?: boolean; onCause?: (cause: string) => void },
|
|
4716
4911
|
): boolean
|
|
4717
4912
|
```
|
|
4718
4913
|
|
|
4719
4914
|
- `log` — A log, or the slice of one a wait reads.
|
|
4720
4915
|
- `excluded` — The test titles the request carves out, if the caller knows them.
|
|
4721
|
-
- `options` — `finalOnly` reads only a failure the run has finished with; `noRetries` says the command proves the run cannot retry (`--retries=0`), so its first failure is final.
|
|
4916
|
+
- `options` — `finalOnly` reads only a failure the run has finished with; `noRetries` says the command proves the run cannot retry (`--retries=0`), so its first failure is final. `onCause` receives each distinct normalized native error from the matching bodies.
|
|
4722
4917
|
|
|
4723
4918
|
**Returns:** True when a `✘` row's own test, outside the request's exclusions, has a failure body under it — and, with `finalOnly`, that failure is final in the log read so far.
|
|
4724
4919
|
|
|
@@ -5804,7 +5999,15 @@ Peer dependencies:
|
|
|
5804
5999
|
### Runtime Dependencies
|
|
5805
6000
|
|
|
5806
6001
|
- `@molecule/api-ai`
|
|
5807
|
-
|
|
6002
|
+
- `typescript`
|
|
6003
|
+
|
|
6004
|
+
- **Background Playwright feedback:** `createPlaywrightFeedback({ load, run, onFailures })`
|
|
6005
|
+
coalesces `changed(paths)` events without delaying writes. Use `readFeedbackSources`
|
|
6006
|
+
to batch source reads over either backend and `runPlaywrightFeedback` to run each
|
|
6007
|
+
supplied spec through its native command. Its incremental reporter supplies exact
|
|
6008
|
+
locator failures and the failure-time page snapshot. Healthy runs emit no note;
|
|
6009
|
+
no suite schedules no runner. `settled()`/`close()` are for tests and shutdown,
|
|
6010
|
+
never a deployment barrier. Diagnoses are not whole-suite completion proof.
|
|
5808
6011
|
- **Opaque command plans:** prepare each logical step with `streamingBackgroundCommand`,
|
|
5809
6012
|
call `createCommandPlan`, and attach it to the executed wrapper with `commandWithPlan`.
|
|
5810
6013
|
The launcher prints each step's `startMarker` and `endMarker` on their own lines around
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/backends/local.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/backends/local.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,CA6FxE"}
|
package/dist/backends/local.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { spawn } from 'child_process';
|
|
8
8
|
import { mkdir, readdir, readFile, unlink, writeFile } from 'fs/promises';
|
|
9
9
|
import { dirname } from 'path';
|
|
10
10
|
/**
|
|
@@ -38,23 +38,69 @@ export function createLocalBackend(projectRoot) {
|
|
|
38
38
|
},
|
|
39
39
|
run(command, opts) {
|
|
40
40
|
return new Promise((resolve) => {
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
41
|
+
// A native runner owns children. execFile's timeout killed only sh,
|
|
42
|
+
// leaving the runner/browser alive. Use the OS process group, with a
|
|
43
|
+
// graceful signal followed by a bounded forceful cleanup of that group.
|
|
44
|
+
const grouped = process.platform !== 'win32';
|
|
45
|
+
const child = spawn('sh', ['-c', command], {
|
|
44
46
|
cwd: opts?.cwd || projectRoot,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
detached: grouped,
|
|
48
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
49
|
+
});
|
|
50
|
+
let stdout = '', stderr = '', closed = false, code = 1;
|
|
51
|
+
let stopped;
|
|
52
|
+
let force;
|
|
53
|
+
const finish = () => {
|
|
54
|
+
if (closed && !force)
|
|
55
|
+
resolve({ stdout, stderr, exitCode: stopped === 'timeout' ? 124 : stopped ? 1 : code });
|
|
56
|
+
};
|
|
57
|
+
const signal = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
if (grouped && child.pid)
|
|
60
|
+
process.kill(-child.pid, value);
|
|
61
|
+
else
|
|
62
|
+
child.kill(value);
|
|
51
63
|
}
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
catch (_error) {
|
|
65
|
+
/* the owned group already exited */
|
|
54
66
|
}
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
};
|
|
68
|
+
const stop = (why) => {
|
|
69
|
+
if (stopped)
|
|
70
|
+
return;
|
|
71
|
+
stopped = why;
|
|
72
|
+
signal('SIGTERM');
|
|
73
|
+
force = setTimeout(() => {
|
|
74
|
+
signal('SIGKILL');
|
|
75
|
+
force = undefined;
|
|
76
|
+
finish();
|
|
77
|
+
}, 1000);
|
|
78
|
+
};
|
|
79
|
+
const timeout = Math.min(opts?.timeout || 30_000, opts?.budgetMs || Infinity);
|
|
80
|
+
const deadline = setTimeout(() => stop('timeout'), timeout);
|
|
81
|
+
const collect = (text, channel) => {
|
|
82
|
+
if (stopped)
|
|
83
|
+
return;
|
|
84
|
+
if (stdout.length + stderr.length + text.length > 10 * 1024 * 1024) {
|
|
85
|
+
stderr += '\nCommand exceeded the 10 MB output limit.';
|
|
86
|
+
stop('output');
|
|
87
|
+
return;
|
|
57
88
|
}
|
|
89
|
+
if (channel === 'stdout')
|
|
90
|
+
stdout += text;
|
|
91
|
+
else
|
|
92
|
+
stderr += text;
|
|
93
|
+
};
|
|
94
|
+
child.stdout.setEncoding('utf8').on('data', (text) => collect(text, 'stdout'));
|
|
95
|
+
child.stderr.setEncoding('utf8').on('data', (text) => collect(text, 'stderr'));
|
|
96
|
+
child.on('error', (error) => {
|
|
97
|
+
stderr += error.message;
|
|
98
|
+
});
|
|
99
|
+
child.on('close', (exitCode) => {
|
|
100
|
+
closed = true;
|
|
101
|
+
code = exitCode ?? 1;
|
|
102
|
+
clearTimeout(deadline);
|
|
103
|
+
finish();
|
|
58
104
|
});
|
|
59
105
|
});
|
|
60
106
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* (identity, tool listing, project docs, discovered skills).
|
|
13
13
|
*
|
|
14
14
|
* @remarks
|
|
15
|
+
* - **Background Playwright feedback:** `createPlaywrightFeedback({ load, run, onFailures })`
|
|
16
|
+
* coalesces `changed(paths)` events without delaying writes. Use `readFeedbackSources`
|
|
17
|
+
* to batch source reads over either backend and `runPlaywrightFeedback` to run each
|
|
18
|
+
* supplied spec through its native command. Its incremental reporter supplies exact
|
|
19
|
+
* locator failures and the failure-time page snapshot. Healthy runs emit no note;
|
|
20
|
+
* no suite schedules no runner. `settled()`/`close()` are for tests and shutdown,
|
|
21
|
+
* never a deployment barrier. Diagnoses are not whole-suite completion proof.
|
|
15
22
|
* - **Opaque command plans:** prepare each logical step with `streamingBackgroundCommand`,
|
|
16
23
|
* call `createCommandPlan`, and attach it to the executed wrapper with `commandWithPlan`.
|
|
17
24
|
* The launcher prints each step's `startMarker` and `endMarker` on their own lines around
|
|
@@ -165,6 +172,9 @@ export * from './line-diff.js';
|
|
|
165
172
|
export * from './no-test-run.js';
|
|
166
173
|
export * from './output-filter.js';
|
|
167
174
|
export * from './pipeline-exit-note.js';
|
|
175
|
+
export * from './playwright-feedback.js';
|
|
176
|
+
export * from './playwright-feedback-selection.js';
|
|
177
|
+
export * from './playwright-feedback-types.js';
|
|
168
178
|
export * from './playwright-report.js';
|
|
169
179
|
export * from './schemas.js';
|
|
170
180
|
export * from './server-command.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
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+JG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* (identity, tool listing, project docs, discovered skills).
|
|
13
13
|
*
|
|
14
14
|
* @remarks
|
|
15
|
+
* - **Background Playwright feedback:** `createPlaywrightFeedback({ load, run, onFailures })`
|
|
16
|
+
* coalesces `changed(paths)` events without delaying writes. Use `readFeedbackSources`
|
|
17
|
+
* to batch source reads over either backend and `runPlaywrightFeedback` to run each
|
|
18
|
+
* supplied spec through its native command. Its incremental reporter supplies exact
|
|
19
|
+
* locator failures and the failure-time page snapshot. Healthy runs emit no note;
|
|
20
|
+
* no suite schedules no runner. `settled()`/`close()` are for tests and shutdown,
|
|
21
|
+
* never a deployment barrier. Diagnoses are not whole-suite completion proof.
|
|
15
22
|
* - **Opaque command plans:** prepare each logical step with `streamingBackgroundCommand`,
|
|
16
23
|
* call `createCommandPlan`, and attach it to the executed wrapper with `commandWithPlan`.
|
|
17
24
|
* The launcher prints each step's `startMarker` and `endMarker` on their own lines around
|
|
@@ -165,6 +172,9 @@ export * from './line-diff.js';
|
|
|
165
172
|
export * from './no-test-run.js';
|
|
166
173
|
export * from './output-filter.js';
|
|
167
174
|
export * from './pipeline-exit-note.js';
|
|
175
|
+
export * from './playwright-feedback.js';
|
|
176
|
+
export * from './playwright-feedback-selection.js';
|
|
177
|
+
export * from './playwright-feedback-types.js';
|
|
168
178
|
export * from './playwright-report.js';
|
|
169
179
|
export * from './schemas.js';
|
|
170
180
|
export * from './server-command.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PlaywrightFeedbackFailure } from './playwright-feedback-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A standard Playwright reporter, placed beside each run's private outputs. It
|
|
4
|
+
* records onTestEnd, so the first exact failure need not wait for the rest of
|
|
5
|
+
* the spec file. No page injection, test rewrite, screenshots or trace overhead.
|
|
6
|
+
* @returns A CommonJS reporter loadable by the project's installed Playwright.
|
|
7
|
+
*/
|
|
8
|
+
export declare function feedbackReporterSource(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Read native failure events; incomplete final lines wait for the next read.
|
|
11
|
+
* @param text - Reporter JSONL, not runner-log inference.
|
|
12
|
+
* @param sourceFiles - Triggering source files from the scheduler.
|
|
13
|
+
* @returns Native locator/assertion failures and timed-out browser operations, redacted and bounded.
|
|
14
|
+
*/
|
|
15
|
+
export declare function nativeFeedbackFailures(text: string, sourceFiles: string[]): PlaywrightFeedbackFailure[];
|
|
16
|
+
//# sourceMappingURL=playwright-feedback-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright-feedback-reporter.d.ts","sourceRoot":"","sources":["../src/playwright-feedback-reporter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAG/E;;;;;GAKG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAyB/C;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EAAE,GACpB,yBAAyB,EAAE,CA4C7B"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Native Playwright events for incremental background feedback.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
7
|
+
import { redactSecrets } from './utilities.js';
|
|
8
|
+
/**
|
|
9
|
+
* A standard Playwright reporter, placed beside each run's private outputs. It
|
|
10
|
+
* records onTestEnd, so the first exact failure need not wait for the rest of
|
|
11
|
+
* the spec file. No page injection, test rewrite, screenshots or trace overhead.
|
|
12
|
+
* @returns A CommonJS reporter loadable by the project's installed Playwright.
|
|
13
|
+
*/
|
|
14
|
+
export function feedbackReporterSource() {
|
|
15
|
+
return String.raw `
|
|
16
|
+
const fs = require('node:fs');
|
|
17
|
+
module.exports = class FeedbackReporter {
|
|
18
|
+
onTestEnd(test, result) {
|
|
19
|
+
if (result.status === test.expectedStatus || !['failed','timedOut'].includes(result.status)) return;
|
|
20
|
+
const errors = result.errors || [];
|
|
21
|
+
const error = errors.map(e => e.message || '').join('\n');
|
|
22
|
+
const location = [...errors].reverse().find(e => e.location)?.location || test.location;
|
|
23
|
+
const attachment = result.attachments.find(a => a.name === 'error-context' && a.path);
|
|
24
|
+
let rendered;
|
|
25
|
+
if (attachment) try {
|
|
26
|
+
const text = fs.readFileSync(attachment.path, 'utf8');
|
|
27
|
+
const fence = String.fromCharCode(96).repeat(3);
|
|
28
|
+
const yaml = text.split(fence + 'yaml\n')[1];
|
|
29
|
+
if (yaml) rendered = yaml.split(fence)[0].trim().slice(0, 2000);
|
|
30
|
+
else {
|
|
31
|
+
const section = text.split('# Page snapshot')[1];
|
|
32
|
+
if (section) rendered = section.split(fence)[1]?.split('\n').slice(1).join('\n').trim().slice(0, 2000);
|
|
33
|
+
}
|
|
34
|
+
} catch {}
|
|
35
|
+
if (process.env.MOL_TEST_FEEDBACK_EVENTS) fs.appendFileSync(process.env.MOL_TEST_FEEDBACK_EVENTS,
|
|
36
|
+
JSON.stringify({spec: location.file, line: location.line, error: error.slice(0, 6000), rendered}) + '\n');
|
|
37
|
+
}
|
|
38
|
+
};`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Read native failure events; incomplete final lines wait for the next read.
|
|
42
|
+
* @param text - Reporter JSONL, not runner-log inference.
|
|
43
|
+
* @param sourceFiles - Triggering source files from the scheduler.
|
|
44
|
+
* @returns Native locator/assertion failures and timed-out browser operations, redacted and bounded.
|
|
45
|
+
*/
|
|
46
|
+
export function nativeFeedbackFailures(text, sourceFiles) {
|
|
47
|
+
const out = [];
|
|
48
|
+
if (text.length > 1_000_000)
|
|
49
|
+
return out;
|
|
50
|
+
for (const line of text.split('\n').slice(0, -1)) {
|
|
51
|
+
try {
|
|
52
|
+
const event = JSON.parse(line);
|
|
53
|
+
if (typeof event.spec !== 'string' ||
|
|
54
|
+
typeof event.line !== 'number' ||
|
|
55
|
+
typeof event.error !== 'string')
|
|
56
|
+
continue;
|
|
57
|
+
const error = redactSecrets(stripVTControlCharacters(event.error).slice(0, 6_000));
|
|
58
|
+
const locator = /(?:Locator:\s*|waiting for )(locator\([^\n]+|getBy[^\n]+)/.exec(error)?.[1] ??
|
|
59
|
+
/strict mode violation: ([^\n]+)/.exec(error)?.[1] ??
|
|
60
|
+
/(?:^|\n)((?:Error: )?expect\([^\n]+|AssertionError:[^\n]+)/.exec(error)?.[1] ??
|
|
61
|
+
// A UI loop can exhaust the test budget between actions. Playwright then names
|
|
62
|
+
// page.waitForTimeout/locator.count rather than a locator. That is still the
|
|
63
|
+
// supplied test's real failure, with its native location and page snapshot.
|
|
64
|
+
(/Test timeout of \d+ms exceeded\./.test(error)
|
|
65
|
+
? /(?:^|\n)Error: ((?:page|locator)\.[\w.]+):/.exec(error)?.[1]
|
|
66
|
+
: undefined);
|
|
67
|
+
if (!locator)
|
|
68
|
+
continue;
|
|
69
|
+
out.push({
|
|
70
|
+
spec: event.spec,
|
|
71
|
+
line: event.line,
|
|
72
|
+
error,
|
|
73
|
+
locator,
|
|
74
|
+
...(typeof event.rendered === 'string' && event.rendered
|
|
75
|
+
? { rendered: redactSecrets(event.rendered.slice(0, 2000)) }
|
|
76
|
+
: {}),
|
|
77
|
+
sourceFiles,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (_error) {
|
|
81
|
+
/* not a completed native event */
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FeedbackProject, FeedbackSpec } from './playwright-feedback-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Prioritize spec files potentially affected by writes. Every file still runs: a click or
|
|
4
|
+
* a helper can navigate somewhere a literal-goto index cannot see. This index never excludes work.
|
|
5
|
+
* @param project - Caller-supplied source and runner inventory.
|
|
6
|
+
* @param changed - Absolute source paths changed since the previous diagnosis.
|
|
7
|
+
* @returns Spec files to run, with their rendering-source context.
|
|
8
|
+
*/
|
|
9
|
+
export declare function selectFeedbackSpecs(project: FeedbackProject, changed: readonly string[]): Array<{
|
|
10
|
+
spec: FeedbackSpec;
|
|
11
|
+
sourceFiles: string[];
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=playwright-feedback-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright-feedback-selection.d.ts","sourceRoot":"","sources":["../src/playwright-feedback-selection.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,eAAe,EAAkB,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAsLnG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,KAAK,CAAC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAwBtD"}
|