@plune-ai/cli 0.38.0 → 0.39.0

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.
@@ -1,7 +1,90 @@
1
+ type ClientFailureKind =
2
+ /** The token was refused. Retrying sends the same token to the same door. */
3
+ 'auth'
4
+ /** The server understood and said no: a closed run, an impossible lifecycle transition. */
5
+ | 'conflict'
6
+ /** The body was refused. It will be refused identically next time. */
7
+ | 'invalid'
8
+ /** Nobody answered, or answered with their own failure. Worth another try. */
9
+ | 'unavailable'
10
+ /** Everything else — reported, never retried, because we cannot say retrying would help. */
11
+ | 'other';
12
+ type ClientOutcome<T> = {
13
+ ok: true;
14
+ status: number;
15
+ body: T;
16
+ } | {
17
+ ok: false;
18
+ kind: ClientFailureKind;
19
+ status: number | null;
20
+ detail: string;
21
+ code?: string;
22
+ shardsExpected?: number;
23
+ };
24
+ /** What a PUT to a bucket carries: a file on disk, streamed at a length known beforehand, or bytes in memory. */
25
+ type PutSource = {
26
+ path: string;
27
+ size: number;
28
+ } | {
29
+ body: Buffer;
30
+ };
31
+ /**
32
+ * How a PUT ended. Never a URL, never a message: the link is a write key to someone's bucket, and the
33
+ * errors of the transports (`getaddrinfo ENOTFOUND <host>`, `no answer from <origin>`) name the host. All
34
+ * that survives is a status and a short code.
35
+ */
36
+ type PutOutcome = {
37
+ ok: true;
38
+ } | {
39
+ ok: false;
40
+ status: number | null;
41
+ code: string;
42
+ };
43
+ interface ClientOptions {
44
+ apiUrl: string;
45
+ token: string;
46
+ fetchImpl?: typeof fetch;
47
+ /** Test seam — the same idea as `fetchImpl`, so a retry test costs milliseconds, not seconds. */
48
+ wait?: (ms: number) => Promise<void>;
49
+ /** Retries of a file's requests (default 2 for the platform's, 3 for a bucket's): what `uploadRetries` is. */
50
+ uploadRetries?: number;
51
+ /** Test seam for the jitter: a number in [0, 1). */
52
+ random?: () => number;
53
+ /** Test seam for the clock the shared pause is read against. */
54
+ now?: () => number;
55
+ /** Called once for every retry that is about to wait. */
56
+ onRetry?: () => void;
57
+ }
58
+ interface PlatformClient {
59
+ /** `retries` after the first try: the default is 2; a file's requests ask for more. */
60
+ post<T>(path: string, body: unknown, retries?: number): Promise<ClientOutcome<T>>;
61
+ /**
62
+ * A file's bytes as the body, under the file's own type — not JSON. Through the
63
+ * same retries as a POST, so a 429 on the platform's upload limit waits out its `Retry-After`.
64
+ */
65
+ upload<T>(path: string, bytes: Buffer, contentType: string): Promise<ClientOutcome<T>>;
66
+ /**
67
+ * A DELETE, through the same retries, the same classification and the same token scrubbing as a
68
+ * POST. It is here rather than as a bare `fetch` in the one command that needs it because all
69
+ * three of those matter at least as much for a delete: an unclassified 404 reads as an outage, and
70
+ * a proxy error page that echoes the request would put a token in a CI log.
71
+ */
72
+ del<T>(path: string): Promise<ClientOutcome<T>>;
73
+ /** A GET, through the same retries, classification and token scrubbing. */
74
+ get<T>(path: string): Promise<ClientOutcome<T>>;
75
+ /**
76
+ * The bytes to a short-lived link of the customer's bucket: exactly the headers the
77
+ * link came with, no token of ours. Network failures and 5xx wait and try again, up to three times; a 403
78
+ * (the link has expired) comes back at once, for the caller to ask for a new one.
79
+ */
80
+ put(url: string, headers: Record<string, string>, source: PutSource): Promise<PutOutcome>;
81
+ }
82
+ declare function createClient(opts: ClientOptions): PlatformClient;
83
+
1
84
  /**
2
85
  * The platform's wire, mirrored in types — and only in types.
3
86
  *
4
- * There is deliberately no zod here. ADR 0012 says the platform owns the contract and clients
87
+ * There is deliberately no zod here. The platform owns the contract and clients
5
88
  * conform to it; a second copy of the schema on the client is a second place to drift, and it
6
89
  * would put a validation library into the dependency tree of every project that installs an
7
90
  * adapter. The platform validates and answers with a named reason (`validation failed — <field>:
@@ -101,7 +184,7 @@ interface PendingResult {
101
184
  /** What the author expected — `test.fail()` and friends. Absent means a pass was expected. */
102
185
  expectedStatus?: ResultStatus;
103
186
  /**
104
- * What to call this test, and where it lives — read ONLY when nothing resolved it (D14).
187
+ * What to call this test, and where it lives — read ONLY when nothing resolved it.
105
188
  *
106
189
  * A result that found its case needs neither: the case already has a title and a spec. These are
107
190
  * for the other path, where the reporter offers the test to the review queue and the queue needs a
@@ -115,7 +198,7 @@ interface PendingResult {
115
198
  specRef?: string;
116
199
  execution?: Execution;
117
200
  errorContext?: string;
118
- /** What failed and where, for a failed attempt (#790); a pass carries none. Built by `failureOf`. */
201
+ /** What failed and where, for a failed attempt; a pass carries none. Built by `failureOf`. */
119
202
  failure?: FailureDetail;
120
203
  params?: Record<string, unknown>;
121
204
  attachments?: Attachment[];
@@ -123,13 +206,13 @@ interface PendingResult {
123
206
  /**
124
207
  * The files the runner kept for this attempt, passed or not — built by `filesOf`. Never part of a
125
208
  * batch: the paths are this machine's. Once the platform has accepted the result, the core uploads
126
- * the screenshots and the text files among them to it (platform ADR 0040) — never a body to the
209
+ * the screenshots and the text files among them to it — never a body to the
127
210
  * fallback file either, which keeps a file by its path and leaves the bytes out.
128
211
  */
129
212
  files?: ResultFile[];
130
213
  }
131
214
  /**
132
- * What a failed attempt says about itself on the run page (#790, platform ADR-0002): every field
215
+ * What a failed attempt says about itself on the run page: every field
133
216
  * optional — a field the runner could not supply is absent, never guessed. Nothing here is cut: the
134
217
  * platform bounds the fields after its own cleaning, and a cut before that could halve a credential.
135
218
  */
@@ -174,7 +257,7 @@ interface DeclaredStep {
174
257
  }
175
258
  /**
176
259
  * One failed attempt, as both roads reduce their runner's data to it before anything is derived —
177
- * `plune run import` from the JSON report, the adapter from the reporter API (#790 ADR-0001). The same
260
+ * `plune run import` from the JSON report, the adapter from the reporter API. The same
178
261
  * shape in, so the same detail and the same text out.
179
262
  */
180
263
  interface FailedAttempt {
@@ -222,7 +305,7 @@ interface RunRecord {
222
305
  schemaVersion?: number;
223
306
  }
224
307
  /**
225
- * What the platform froze into a run at `finish` and answers the event with (plune#1247): the verdict a
308
+ * What the platform froze into a run at `finish` and answers the event with: the verdict a
226
309
  * release gate is made on, never recomputed. `counts` is by the status each result is counted under — a
227
310
  * muted case's `failed` or `broken` is under `muted`, outside both — and an absent key is zero.
228
311
  */
@@ -245,12 +328,11 @@ interface RunStats extends SubmitCounts {
245
328
  /** Results whose keys matched no case — never sent, because inventing an id would write into
246
329
  * somebody else's history. Rung 6 of C2's ladder is what to do about them: see `offered`. */
247
330
  unresolved: number;
248
- /** Unresolved tests offered to the review queue under `PLUNE_CREATE=1` (D14). Counted separately
331
+ /** Unresolved tests offered to the review queue under `PLUNE_CREATE=1`. Counted separately
249
332
  * from `unresolved` because they are the same tests seen twice, not a second population. */
250
333
  offered: number;
251
334
  /**
252
- * Offered tests the platform turned into cases outright, because the project trusts this source
253
- * (platform ADR 0030).
335
+ * Offered tests the platform turned into cases outright, because the project trusts this source.
254
336
  *
255
337
  * Its own number rather than part of `offered`: these are the opposite of work to do. `offered`
256
338
  * means "somebody has to look at this"; `created` means "nobody has to, and here is what appeared
@@ -259,7 +341,7 @@ interface RunStats extends SubmitCounts {
259
341
  */
260
342
  created: number;
261
343
  /**
262
- * Unmatched tests that were NOT offered, because the queue would not take them (#627).
344
+ * Unmatched tests that were NOT offered, because the queue would not take them.
263
345
  *
264
346
  * Separate from `offered` rather than a shortfall computed against `unresolved`: the reason a
265
347
  * test went unoffered is the caller's next action, and a subtraction cannot carry a reason. A
@@ -273,13 +355,13 @@ interface RunStats extends SubmitCounts {
273
355
  */
274
356
  unofferedWhy?: UnofferedWhy;
275
357
  /**
276
- * Results not delivered, written to the fallback file instead of the platform (#790): a batch
358
+ * Results not delivered, written to the fallback file instead of the platform: a batch
277
359
  * refused for any reason — its size, the network, the token, a closed run — or a result whose keys
278
360
  * the platform could not be asked about. Apart from `rejected` and `unresolved`, which it did answer.
279
361
  */
280
362
  deferred: number;
281
363
  /**
282
- * The screenshots of the accepted results (platform ADR 0040): uploaded to their result; skipped
364
+ * The screenshots of the accepted results: uploaded to their result; skipped
283
365
  * because the platform would refuse them or the file is not here; refused or unanswered on the way.
284
366
  * None of them costs a result — a result is reported whether its screenshots arrive or not.
285
367
  */
@@ -289,7 +371,7 @@ interface RunStats extends SubmitCounts {
289
371
  failed: number;
290
372
  };
291
373
  /**
292
- * The same for the JSON and plain-text files of the accepted results (plune-ai/plune#928): counted
374
+ * The same for the JSON and plain-text files of the accepted results: counted
293
375
  * apart from the screenshots because the two have limits of their own — 512 KiB and ten a result against
294
376
  * 2 MB and twenty — and a person reading "3 skipped" has to know which kind it was.
295
377
  */
@@ -299,7 +381,7 @@ interface RunStats extends SubmitCounts {
299
381
  failed: number;
300
382
  };
301
383
  /**
302
- * Every other file (a trace, a video, a page): only a project's bucket takes them (plune-ai/plune#946), so
384
+ * Every other file (a trace, a video, a page): only a project's bucket takes them, so
303
385
  * without one they are counted as skipped. With one, the summary adds all three kinds up.
304
386
  */
305
387
  otherFiles: {
@@ -325,7 +407,7 @@ interface ReporterConfig {
325
407
  /** How the run is marked — smoke, nightly, a team. */
326
408
  labels?: string[];
327
409
  /**
328
- * The combination this job runs, group name → value label (`PLUNE_CONFIGURATION`, plune-ai/plune#1251):
410
+ * The combination this job runs, group name → value label (`PLUNE_CONFIGURATION`):
329
411
  * sent as `configuration` on every results batch. Not the run's own `configuration` (what it expects).
330
412
  * Stated, it is all there is: the variable is not read, and `{}` sends none (what a replay passes for a line that recorded none).
331
413
  */
@@ -339,7 +421,7 @@ interface ReporterConfig {
339
421
  /** Where unsent batches go. Defaults beside the run file the CLI already writes. */
340
422
  fallbackPath?: string;
341
423
  /**
342
- * Offer tests that resolved to nothing to the platform's review queue (`PLUNE_CREATE=1`, D14).
424
+ * Offer tests that resolved to nothing to the platform's review queue (`PLUNE_CREATE=1`).
343
425
  *
344
426
  * Off by default, and that is the product decision rather than caution: a reporter that filled a
345
427
  * stranger's review queue on first run would teach the team to ignore the queue. Turning it on is
@@ -347,7 +429,7 @@ interface ReporterConfig {
347
429
  */
348
430
  offerDiscovered?: boolean;
349
431
  /**
350
- * This run is the whole suite (`PLUNE_FULL_RUN=1`, D20).
432
+ * This run is the whole suite (`PLUNE_FULL_RUN=1`).
351
433
  *
352
434
  * Sent as `configuration.full` beside `expected`. When such a run finishes having reported
353
435
  * everything it expected, the platform moves the cases this source used to report and did not
@@ -379,7 +461,7 @@ interface RunSession {
379
461
  /** Send whatever is buffered. Safe to call when nothing is. */
380
462
  flush(): Promise<void>;
381
463
  /**
382
- * Send what is left and close the run. Resolves to the summary the platform froze at `finish` (plune#1247), or
464
+ * Send what is left and close the run. Resolves to the summary the platform froze at `finish`, or
383
465
  * `undefined` when it answered with none: no run, a refused finish, a deployment older than the summary.
384
466
  */
385
467
  finish(reason?: string): Promise<FrozenSummary | undefined>;
@@ -433,8 +515,8 @@ declare function resultKey(testId: string, retry: number): string;
433
515
  * like success. A client believing it saved something the server discarded is the most expensive
434
516
  * kind of quiet — cheaper to say "not yet" out loud.
435
517
  *
436
- * `PLUNE_RUN_TITLE`, `PLUNE_ENV` and `PLUNE_LABELS` left this list when D13 gave a run somewhere to
437
- * put them. `PLUNE_GROUP` stays: a run group is D6's, and a group of one run means nothing.
518
+ * `PLUNE_RUN_TITLE`, `PLUNE_ENV` and `PLUNE_LABELS` left this list when the platform gave a run somewhere to
519
+ * put them. `PLUNE_GROUP` stays: run groups are a platform change of their own, and a group of one run means nothing.
438
520
  */
439
521
  declare const UNSUPPORTED_VARS: readonly ["PLUNE_GROUP"];
440
522
  interface ShardOf {
@@ -462,7 +544,7 @@ interface EnvSettings {
462
544
  }
463
545
  declare function readEnv(env?: NodeJS.ProcessEnv): EnvSettings;
464
546
  /**
465
- * The commit and the branch a run belongs to (plune-ai/plune#927), for `meta.sha` and `meta.branch`.
547
+ * The commit and the branch a run belongs to, for `meta.sha` and `meta.branch`.
466
548
  *
467
549
  * `reported` is what the runner said about its CI — Playwright's `metadata.ci`, or the copy of it in
468
550
  * its JSON report — and outranks the job's variables: it is a project's own word where the CI is one
@@ -498,7 +580,7 @@ declare const DEFAULT_FALLBACK_PATH: string;
498
580
  * `runId: null` is a real state, not a missing value — the platform was unreachable when the run
499
581
  * was supposed to be created, so these results have no run yet and replay has to make one.
500
582
  *
501
- * `meta` is where that run came from — the commit and branch, the CI run, the runner (plune-ai/plune#927).
583
+ * `meta` is where that run came from — the commit and branch, the CI run, the runner.
502
584
  * Recorded so the run replay makes is the run the reporter would have made; replay reads it and nothing
503
585
  * else about the machine it runs on. A line written before the field existed has none.
504
586
  *
@@ -507,7 +589,7 @@ declare const DEFAULT_FALLBACK_PATH: string;
507
589
  * marker rather than one for each. A line written before the field existed has none, and is one run's
508
590
  * worth by itself — nothing in it says otherwise.
509
591
  *
510
- * `configuration` is the combination the job named (`PLUNE_CONFIGURATION`, plune-ai/plune#1251), recorded for
592
+ * `configuration` is the combination the job named (`PLUNE_CONFIGURATION`), recorded for
511
593
  * the same reason as `meta`: replay sends the batch into the combination it ran in, whatever the machine that
512
594
  * replays it has set. A line without it was written by a job that named none, or before the field existed.
513
595
  */
@@ -533,7 +615,7 @@ interface DeferredBatch {
533
615
  declare function appendBatch(file: string, batch: DeferredBatch): void;
534
616
 
535
617
  /**
536
- * The failure detail of one attempt (#790, ADR-0001 of the feature): what failed, the declared steps
618
+ * The failure detail of one attempt: what failed, the declared steps
537
619
  * down to it, where, what the runner kept, and the CI run — derived from the attempt both roads
538
620
  * reduce their data to, so `plune run import` and the adapter cannot disagree about it.
539
621
  *
@@ -551,11 +633,11 @@ declare function repoRootOf(dir: string, stopAt?: string): string | undefined;
551
633
  * `errorContext` for one attempt: every error in order, colour codes gone, the repository as relative
552
634
  * paths and a home folder as `~` — any home folder when the root is unknown, since the report may come
553
635
  * from another machine — and no longer than the CLI's transport limit, cut by whole lines. Nothing is
554
- * searched for credentials: the platform does that before its own cut (ADR-0005).
636
+ * searched for credentials: the platform does that before its own cut.
555
637
  */
556
638
  declare function errorContextOf(attempt: FailedAttempt, home?: string): string;
557
639
  /**
558
- * The `errorContext` and `errorContextOmitted` keys of a result (plune-ai/plune#1281 AC-03), ready to spread:
640
+ * The `errorContext` and `errorContextOmitted` keys of a result (AC-03), ready to spread:
559
641
  * none for an empty text, and `errorContextOmitted` only when the cut took something out, a whole number of at
560
642
  * least 1 (the platform refuses 0). Counted in characters of the text as it would have been sent (`.length`,
561
643
  * the unit the platform counts in), never bytes; the `…[omitted N lines]…` marker is not counted.
@@ -566,11 +648,11 @@ declare function errorContextFields(attempt: FailedAttempt, home?: string): {
566
648
  };
567
649
  /**
568
650
  * The files the runner kept for one attempt, whatever its status: a screenshot of a test that passed
569
- * is how a person sees what it checked (plune-ai/plune#913). Which of them the platform takes, the
651
+ * is how a person sees what it checked. Which of them the platform takes, the
570
652
  * session decides as it uploads — once, for both roads.
571
653
  *
572
654
  * A file is what has a `path`. What a test attached as a `body` leaves none — Playwright hands the bytes
573
- * over and keeps nothing — so a JSON or a text is kept with its bytes (plune-ai/plune#928), and nothing
655
+ * over and keeps nothing — so a JSON or a text is kept with its bytes, and nothing
574
656
  * else is: an image, a trace or a page is not taken from memory, and a suite whose screenshots are
575
657
  * bodies must not hold them all until a batch is sent.
576
658
  */
@@ -582,87 +664,4 @@ declare function filesOf(attempt: FailedAttempt): ResultFile[];
582
664
  */
583
665
  declare function webLink(href: string | undefined): string | undefined;
584
666
 
585
- type ClientFailureKind =
586
- /** The token was refused. Retrying sends the same token to the same door. */
587
- 'auth'
588
- /** The server understood and said no: a closed run, an impossible lifecycle transition. */
589
- | 'conflict'
590
- /** The body was refused. It will be refused identically next time. */
591
- | 'invalid'
592
- /** Nobody answered, or answered with their own failure. Worth another try. */
593
- | 'unavailable'
594
- /** Everything else — reported, never retried, because we cannot say retrying would help. */
595
- | 'other';
596
- type ClientOutcome<T> = {
597
- ok: true;
598
- status: number;
599
- body: T;
600
- } | {
601
- ok: false;
602
- kind: ClientFailureKind;
603
- status: number | null;
604
- detail: string;
605
- code?: string;
606
- shardsExpected?: number;
607
- };
608
- /** What a PUT to a bucket carries: a file on disk, streamed at a length known beforehand, or bytes in memory. */
609
- type PutSource = {
610
- path: string;
611
- size: number;
612
- } | {
613
- body: Buffer;
614
- };
615
- /**
616
- * How a PUT ended. Never a URL, never a message: the link is a write key to someone's bucket, and the
617
- * errors of the transports (`getaddrinfo ENOTFOUND <host>`, `no answer from <origin>`) name the host. All
618
- * that survives is a status and a short code.
619
- */
620
- type PutOutcome = {
621
- ok: true;
622
- } | {
623
- ok: false;
624
- status: number | null;
625
- code: string;
626
- };
627
- interface ClientOptions {
628
- apiUrl: string;
629
- token: string;
630
- fetchImpl?: typeof fetch;
631
- /** Test seam — the same idea as `fetchImpl`, so a retry test costs milliseconds, not seconds. */
632
- wait?: (ms: number) => Promise<void>;
633
- /** Retries of a file's requests (default 2 for the platform's, 3 for a bucket's): what `uploadRetries` is. */
634
- uploadRetries?: number;
635
- /** Test seam for the jitter: a number in [0, 1). */
636
- random?: () => number;
637
- /** Test seam for the clock the shared pause is read against. */
638
- now?: () => number;
639
- /** Called once for every retry that is about to wait. */
640
- onRetry?: () => void;
641
- }
642
- interface PlatformClient {
643
- /** `retries` after the first try: the default is 2; a file's requests ask for more. */
644
- post<T>(path: string, body: unknown, retries?: number): Promise<ClientOutcome<T>>;
645
- /**
646
- * A file's bytes as the body, under the file's own type (platform ADR 0040) — not JSON. Through the
647
- * same retries as a POST, so a 429 on the platform's upload limit waits out its `Retry-After`.
648
- */
649
- upload<T>(path: string, bytes: Buffer, contentType: string): Promise<ClientOutcome<T>>;
650
- /**
651
- * A DELETE, through the same retries, the same classification and the same token scrubbing as a
652
- * POST. It is here rather than as a bare `fetch` in the one command that needs it because all
653
- * three of those matter at least as much for a delete: an unclassified 404 reads as an outage, and
654
- * a proxy error page that echoes the request would put a token in a CI log.
655
- */
656
- del<T>(path: string): Promise<ClientOutcome<T>>;
657
- /** A GET, through the same retries, classification and token scrubbing. */
658
- get<T>(path: string): Promise<ClientOutcome<T>>;
659
- /**
660
- * The bytes to a short-lived link of the customer's bucket (plune-ai/plune#946): exactly the headers the
661
- * link came with, no token of ours. Network failures and 5xx wait and try again, up to three times; a 403
662
- * (the link has expired) comes back at once, for the caller to ask for a new one.
663
- */
664
- put(url: string, headers: Record<string, string>, source: PutSource): Promise<PutOutcome>;
665
- }
666
- declare function createClient(opts: ClientOptions): PlatformClient;
667
-
668
667
  export { type AssertionRecord, type Attachment, type AttemptError, type ClientFailureKind, type ClientOptions, type ClientOutcome, DEFAULT_FALLBACK_PATH, type DeclaredStep, type DeferredBatch, type DeferredResult, type EnvSettings, type Execution, type ExpectedEntry, type ExternalKeyKind, type FailedAttempt, type FailureDetail, type FrozenSummary, type KeyRef, type PendingResult, type PlatformClient, RESULT_KEY_MAX, type ReporterConfig, type ResultFile, type ResultStatus, type ResultSubmission, type RunKind, type RunMeta, type RunRecord, type RunSession, type RunStats, type RunnerLocation, type SubmitCounts, UNSUPPORTED_VARS, type UnofferedWhy, appendBatch, ciCommit, createClient, errorContextFields, errorContextOf, failureOf, filesOf, readEnv, repoRootOf, resultKey, startRun, webLink };