@testsprite/testsprite-cli 0.4.0 → 0.5.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.
Files changed (56) hide show
  1. package/README.md +26 -1
  2. package/dist/commands/agent.js +17 -6
  3. package/dist/commands/auth.d.ts +46 -0
  4. package/dist/commands/auth.js +37 -2
  5. package/dist/commands/completion.d.ts +36 -0
  6. package/dist/commands/completion.js +111 -0
  7. package/dist/commands/doctor.js +20 -2
  8. package/dist/commands/init.d.ts +32 -1
  9. package/dist/commands/init.js +40 -10
  10. package/dist/commands/project.d.ts +77 -3
  11. package/dist/commands/project.js +176 -43
  12. package/dist/commands/test.d.ts +160 -10
  13. package/dist/commands/test.js +1261 -303
  14. package/dist/commands/usage.d.ts +56 -17
  15. package/dist/commands/usage.js +144 -29
  16. package/dist/index.js +132 -26
  17. package/dist/lib/browser.d.ts +6 -0
  18. package/dist/lib/browser.js +54 -0
  19. package/dist/lib/bundle.d.ts +32 -31
  20. package/dist/lib/bundle.js +125 -83
  21. package/dist/lib/client-factory.d.ts +23 -0
  22. package/dist/lib/client-factory.js +33 -1
  23. package/dist/lib/config.js +7 -3
  24. package/dist/lib/credentials.d.ts +17 -1
  25. package/dist/lib/credentials.js +175 -16
  26. package/dist/lib/dry-run/samples.js +15 -1
  27. package/dist/lib/errors.d.ts +6 -1
  28. package/dist/lib/errors.js +70 -19
  29. package/dist/lib/flaky.d.ts +12 -1
  30. package/dist/lib/flaky.js +7 -12
  31. package/dist/lib/gh-output.d.ts +62 -0
  32. package/dist/lib/gh-output.js +99 -0
  33. package/dist/lib/http.d.ts +33 -15
  34. package/dist/lib/http.js +68 -6
  35. package/dist/lib/org-render.d.ts +52 -0
  36. package/dist/lib/org-render.js +59 -0
  37. package/dist/lib/poll.js +1 -1
  38. package/dist/lib/render-error.d.ts +14 -0
  39. package/dist/lib/render-error.js +30 -0
  40. package/dist/lib/response-schemas.d.ts +83 -0
  41. package/dist/lib/response-schemas.js +272 -0
  42. package/dist/lib/runs.types.d.ts +53 -8
  43. package/dist/lib/skill-nudge.d.ts +17 -0
  44. package/dist/lib/skill-nudge.js +19 -0
  45. package/dist/lib/telemetry.d.ts +90 -0
  46. package/dist/lib/telemetry.js +171 -0
  47. package/dist/lib/text-table.d.ts +14 -0
  48. package/dist/lib/text-table.js +45 -0
  49. package/dist/lib/v3-advisory.d.ts +10 -1
  50. package/dist/lib/v3-advisory.js +12 -4
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.js +1 -1
  53. package/package.json +16 -5
  54. package/schemas/plan.schema.json +61 -0
  55. package/skills/testsprite-verify.codex.md +2 -2
  56. package/skills/testsprite-verify.skill.md +3 -3
@@ -326,7 +326,7 @@ export interface TestDeps {
326
326
  }
327
327
  type CommonOptions = FactoryCommonOptions;
328
328
  interface ListOptions extends CommonOptions {
329
- projectId: string;
329
+ projectId?: string;
330
330
  type?: 'frontend' | 'backend';
331
331
  createdFrom?: 'portal' | 'mcp' | 'cli';
332
332
  /**
@@ -339,6 +339,8 @@ interface ListOptions extends CommonOptions {
339
339
  pageSize?: number;
340
340
  startingToken?: string;
341
341
  maxItems?: number;
342
+ columns?: string;
343
+ noHeader?: boolean;
342
344
  }
343
345
  export declare function runList(opts: ListOptions, deps?: TestDeps): Promise<Page<CliTest>>;
344
346
  /**
@@ -361,7 +363,7 @@ export interface CliCreateTestResponse {
361
363
  export declare const CLI_CREATE_PRIORITIES: readonly ["p0", "p1", "p2", "p3"];
362
364
  export type CliCreatePriority = (typeof CLI_CREATE_PRIORITIES)[number];
363
365
  interface CreateOptions extends CommonOptions {
364
- projectId: string;
366
+ projectId?: string;
365
367
  type: 'frontend' | 'backend';
366
368
  name: string;
367
369
  description?: string;
@@ -644,6 +646,64 @@ export interface CliPlanInput {
644
646
  export interface CliCreateFromPlanResponse extends CliCreateTestResponse {
645
647
  planSteps?: CliPlanStep[];
646
648
  }
649
+ /**
650
+ * Public raw-content URL for
651
+ * `schemas/plan.schema.json`, shipped in both the npm package (see
652
+ * `package.json` `files`) and the repo. Points at the PUBLIC mirror
653
+ * (`TestSprite/testsprite-cli`) since that's what ships to npm consumers;
654
+ * the private atlas repo syncs to it via `scripts/make-public-snapshot.sh`.
655
+ *
656
+ * Pinned to the running CLI's own `v<VERSION>` git tag (the same `VERSION`
657
+ * constant `--version` / `doctor` / the update-check registry probe already
658
+ * read from `src/version.ts`) rather than the mutable `main` branch — a plan
659
+ * file authored against one CLI version should resolve the SAME schema
660
+ * forever, not whatever `main` happens to contain when the file is opened
661
+ * months later (`main` can gain new required fields between versions).
662
+ *
663
+ * This is deliberately DIFFERENT from `schemas/plan.schema.json`'s own
664
+ * internal `$id`, which stays the canonical `main` URL — `$id` is a schema
665
+ * IDENTITY (what this document calls itself, used for cross-referencing),
666
+ * not a fetch instruction, so it is intentionally version-independent.
667
+ * `PLAN_SCHEMA_URL` is the fetch instruction embedded in generated plan
668
+ * files and is intentionally version-PINNED. See DOCUMENTATION.md's "Plan
669
+ * file format" section for the same distinction spelled out for humans.
670
+ *
671
+ * Caveat: the pinned tag only resolves once that version is actually
672
+ * released — a locally-built/pre-release checkout may see a 404 until then.
673
+ */
674
+ export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.5.0/schemas/plan.schema.json";
675
+ /**
676
+ * The SINGLE canonical example plan. This
677
+ * exact value (via `PLAN_TEMPLATE_TEXT` below) is:
678
+ * - printed to stdout by `test create --plan-template`
679
+ * - embedded verbatim in `test create --help` (`PLAN_TEMPLATE_HELP_TEXT`)
680
+ * - asserted in tests against `schemas/plan.schema.json` and against
681
+ * `assertPlanShape` so the three surfaces can't drift
682
+ *
683
+ * Deliberately minimal (no optional `description`/`priority`) — this is
684
+ * the smallest shape `assertPlanShape` accepts, not a fully-annotated
685
+ * showcase (that lives in `skills/testsprite-verify.skill.md`).
686
+ */
687
+ export declare const PLAN_TEMPLATE: CliPlanInput;
688
+ /** `CliPlanInput` plus the optional editor-discoverability hint. */
689
+ export interface PlanFileTemplate extends CliPlanInput {
690
+ $schema: string;
691
+ }
692
+ /**
693
+ * `$schema` is an ordinary extra property from `assertPlanShape`'s point of
694
+ * view (no `additionalProperties` check exists on the plan-from path) — it
695
+ * validates exactly like a bare `CliPlanInput` while giving editors (VS
696
+ * Code's JSON language service, and by extension Copilot inline
697
+ * completions) something to resolve for live validation as the file is
698
+ * edited.
699
+ */
700
+ export declare const PLAN_TEMPLATE_WITH_SCHEMA: PlanFileTemplate;
701
+ /**
702
+ * Rendered once from the object above (never hand-formatted separately) so
703
+ * `test create --plan-template`'s stdout and `test create --help`'s example
704
+ * are generated from — not merely modeled on — the same source.
705
+ */
706
+ export declare const PLAN_TEMPLATE_TEXT: string;
647
707
  /** Per-spec result from `POST /tests/batch`. */
648
708
  export interface CliBatchSpecResult {
649
709
  /** Position of the spec in the input JSONL, preserved across the response. */
@@ -723,6 +783,39 @@ export declare const BATCH_RUN_RATE_LIMIT = 50;
723
783
  export declare const BATCH_RUN_RATE_WINDOW_MS = 60000;
724
784
  /** Maximum number of outer RATE_LIMITED retries inside the batch fan-out (beyond HTTP-layer retries). */
725
785
  export declare const BATCH_RUN_RATE_MAX_OUTER_RETRIES = 5;
786
+ /**
787
+ * Maximum number of outer RATE_LIMITED retries per member inside the multi-id
788
+ * `test wait` fan-out (beyond HTTP-layer retries). Lower than the trigger
789
+ * fan-out's budget on purpose: a throttled *poll* costs nothing but latency and
790
+ * the run is already executing, so a couple of Retry-After-length backoffs is
791
+ * enough to ride out one limiter window — burning the whole `--timeout` on
792
+ * backoff instead of reporting the throttle would be worse than reporting it.
793
+ */
794
+ export declare const WAIT_POLL_RATE_MAX_OUTER_RETRIES = 3;
795
+ /**
796
+ * Backoff to honour before retrying a `RATE_LIMITED` response, in ms.
797
+ *
798
+ * Precedence: `ApiError.retryAfterMs` (set by `HttpClient` from the HTTP
799
+ * `Retry-After` header, already clamped to [1s, 300s]) → `details.retryAfterSeconds`
800
+ * from the envelope body, capped at 120s → 60s. Callers clamp the result to their
801
+ * own remaining deadline; this function only decides "how long does the server
802
+ * want us to wait."
803
+ *
804
+ * Shared by the `test run --all` trigger fan-out and the multi-id `test wait`
805
+ * poll fan-out so the two can't drift — they were hand-copies of the same
806
+ * precedence rule.
807
+ */
808
+ /**
809
+ * Sleep that a termination signal cuts short by rejecting with the signal's
810
+ * `InterruptError`, so the caller's existing DEV-331 catch owns the detach UX.
811
+ *
812
+ * Mirrors `HttpClient.sleepBeforeRetry` — an in-flight backoff must not be a
813
+ * window where a first Ctrl-C hard-exits with empty stdout. The caller is
814
+ * responsible for having ARMED the shutdown scope; a disarmed controller never
815
+ * aborts its signal, so this would otherwise sleep straight through the signal.
816
+ */
817
+ export declare function sleepUntilOrInterrupt(ms: number, signal: AbortSignal | undefined, sleep: (ms: number) => Promise<void>): Promise<void>;
818
+ export declare function resolveRateLimitRetryMs(err: ApiError): number;
726
819
  /**
727
820
  * D3: max automatic retry attempts for deferred tests under `--wait`.
728
821
  * Each attempt is preceded by a Retry-After-aware sleep (server value if
@@ -1047,7 +1140,10 @@ export interface CliRunDiff {
1047
1140
  * green run?"). Pure client-side composition of the existing per-run read
1048
1141
  * (`GET /runs/{id}?includeSteps=true`); the endpoint accepts any two run-ids,
1049
1142
  * so a cross-test pair is a WARNING, not an error. Exit 0 when the verdicts
1050
- * match, exit 1 when they differ, so the command is CI-scriptable.
1143
+ * match, exit 1 when they differ, so the command is CI-scriptable —
1144
+ * `--dry-run` honors the same contract: the canned sample has a
1145
+ * changed verdict, so `test diff --dry-run` (with no overrides) exits 1,
1146
+ * same as a real regressed pair would.
1051
1147
  */
1052
1148
  export declare function runDiff(opts: DiffOptions, deps?: TestDeps): Promise<CliRunDiff>;
1053
1149
  export interface LintOptions extends CommonOptions {
@@ -1074,6 +1170,15 @@ export interface CliLintReport {
1074
1170
  * so authoring a 12-plan directory meant one error per paid round-trip. Zero
1075
1171
  * network, zero credentials: exit 0 when everything is valid, 5 otherwise, so
1076
1172
  * it drops into a pre-commit hook or CI step before `create-batch`.
1173
+ *
1174
+ * The collection granularity used to be per-FILE, not per-PROBLEM — a single
1175
+ * plan with 6 independent field errors reported one at a time across 6
1176
+ * fix-and-rerun cycles, because each file was validated through the
1177
+ * throw-on-first `assertPlanShape`/`assertPlanStepsShape`. Every branch below
1178
+ * now separates "parse the file" (still a single fatal issue on I/O/JSON
1179
+ * failure — there's nothing left to validate) from "check the parsed shape"
1180
+ * (routed through `collectPlanIssues` / `collectPlanStepsIssues`, which
1181
+ * report every failing field in one pass).
1077
1182
  */
1078
1183
  export declare function runLint(opts: LintOptions, deps?: TestDeps): Promise<CliLintReport>;
1079
1184
  export interface ScaffoldOptions extends CommonOptions {
@@ -1099,6 +1204,38 @@ export interface CliBackendScaffold {
1099
1204
  * would pass without asserting anything).
1100
1205
  */
1101
1206
  export declare function runScaffold(opts: ScaffoldOptions, deps?: TestDeps): Promise<CliPlanInput | CliBackendScaffold>;
1207
+ /**
1208
+ * `test create --plan-template` — prints the canonical minimal
1209
+ * valid plan file (`PLAN_TEMPLATE_WITH_SCHEMA` / `PLAN_TEMPLATE_TEXT`,
1210
+ * defined above near `CliPlanInput`) to stdout and exits — before any of
1211
+ * `test create`'s other flag handling runs. Pure-local: no network, no
1212
+ * credentials, no filesystem I/O.
1213
+ *
1214
+ * Deliberately simpler than `test scaffold --type frontend` (which
1215
+ * substitutes a live `TESTSPRITE_PROJECT_ID` when set, and supports
1216
+ * `--out`): `--plan-template`'s job is a single deterministic ground-truth
1217
+ * document that is BYTE-IDENTICAL every invocation, because it doubles as
1218
+ * the literal example embedded in `test create --help` and the
1219
+ * fixture asserted against `schemas/plan.schema.json` in tests.
1220
+ */
1221
+ export declare function runPlanTemplate(opts: CommonOptions, deps?: TestDeps): PlanFileTemplate;
1222
+ export interface OpenOptions extends CommonOptions {
1223
+ testId: string;
1224
+ /** Print the URL only; never spawn a browser (SSH/headless/CI/agents). */
1225
+ noBrowser: boolean;
1226
+ }
1227
+ /**
1228
+ * `test open <test-id>` (issue #121): jump from the terminal to the test's
1229
+ * dashboard page. The CLI already computes this deep-link and prints it as
1230
+ * text on other commands; this closes the last inch (the `gh browse` /
1231
+ * `cypress open` hop). The URL is ALWAYS printed to stdout (so `--no-browser`
1232
+ * and headless use still compose), then the OS browser is spawned unless
1233
+ * --no-browser. An endpoint with no known portal mapping is a hard error
1234
+ * rather than a silent no-op.
1235
+ */
1236
+ export declare function runOpen(opts: OpenOptions, deps?: TestDeps, opener?: (url: string) => void): Promise<{
1237
+ dashboardUrl: string;
1238
+ }>;
1102
1239
  export declare function runSteps(opts: StepsOptions, deps?: TestDeps): Promise<Page<CliTestStep>>;
1103
1240
  interface ResultOptions extends CommonOptions {
1104
1241
  testId: string;
@@ -1138,6 +1275,13 @@ interface ResultHistoryOptions extends CommonOptions {
1138
1275
  pageSize?: number;
1139
1276
  /** Opaque cursor from a prior page's `nextCursor`. */
1140
1277
  cursor?: string;
1278
+ /**
1279
+ * Client-side rerun filter. `true` → only reruns (isRerun), `false` → only
1280
+ * fresh runs, `undefined` → no filter. Applied to each page after the fetch.
1281
+ */
1282
+ rerun?: boolean;
1283
+ columns?: string;
1284
+ noHeader?: boolean;
1141
1285
  }
1142
1286
  /**
1143
1287
  * `test result <test-id> --history [options]`
@@ -1412,8 +1556,8 @@ export declare function createTestCancelCommand(deps: TestDeps): Command;
1412
1556
  */
1413
1557
  export declare function runTestWait(opts: RunTestWaitOptions, deps?: TestDeps): Promise<RunResponse>;
1414
1558
  interface RunTestRunAllOptions extends CommonOptions {
1415
- /** projectId to run all tests in. */
1416
- projectId: string;
1559
+ /** projectId to run all tests in; may be resolved from --project or TESTSPRITE_PROJECT_ID. */
1560
+ projectId?: string;
1417
1561
  /** --filter <substr>: only run tests whose name contains this substring (case-insensitive). */
1418
1562
  nameFilter?: string;
1419
1563
  /** --wait: block until terminal or --timeout. */
@@ -1430,6 +1574,10 @@ interface RunTestRunAllOptions extends CommonOptions {
1430
1574
  reportFile?: string;
1431
1575
  /** --report-suite-name: optional override for the JUnit <testsuite name=...>. */
1432
1576
  reportSuiteName?: string;
1577
+ /** --gh-output: force the GitHub-native output layer even off-Actions (issue #99). */
1578
+ ghOutput?: boolean;
1579
+ /** --summary-file: also write the reduced machine summary JSON to this path. */
1580
+ summaryFile?: string;
1433
1581
  }
1434
1582
  /**
1435
1583
  * `test run --all --project <id>` — M4 piece-2.
@@ -1442,8 +1590,9 @@ export declare function runTestRunAll(opts: RunTestRunAllOptions, deps?: TestDep
1442
1590
  /**
1443
1591
  * `test rerun` — M3.4 piece-3.
1444
1592
  *
1445
- * FE: `POST /tests/{id}/runs/rerun` → verbatim replay (no credit). With
1446
- * `--wait`, polls `GET /runs/{runId}` until terminal.
1593
+ * FE: `POST /tests/{id}/runs/rerun` → verbatim replay, billed at 0.5 credits
1594
+ * (same as a fresh run; legacy V2 accounts: free). With `--wait`, polls
1595
+ * `GET /runs/{runId}` until terminal.
1447
1596
  *
1448
1597
  * BE: same route → closure + per-member runIds. With `--wait`, polls every
1449
1598
  * closure-member runId; exits on the named test's verdict; failed closure
@@ -1508,9 +1657,10 @@ interface RunTestFlakyOptions extends CommonOptions {
1508
1657
  * `test flaky <test-id>` — replay a test N times and report a stability score.
1509
1658
  *
1510
1659
  * Each attempt is a `POST /tests/{id}/runs/rerun` with auto-heal OFF (a strict
1511
- * verbatim replay) followed by `pollRunUntilTerminal`. Frontend replays are
1512
- * free verbatim script replays; backend replays re-run the dependency closure
1513
- * (a one-line credit advisory is printed). The pure scoring lives in
1660
+ * verbatim replay) followed by `pollRunUntilTerminal`. Each replay is billed
1661
+ * as a rerun (0.5 credits FE / 0.2 credits BE, same as a fresh run; legacy V2
1662
+ * accounts: FE rerun remains free) — a one-line credit advisory is printed
1663
+ * for backend tests. The pure scoring lives in
1514
1664
  * `lib/flaky.ts`; this function is the I/O orchestrator.
1515
1665
  *
1516
1666
  * Exit code: 0 when every observed attempt passed (stable), else 1 — so CI can