@testsprite/testsprite-cli 0.11.0 → 0.13.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 (99) hide show
  1. package/README.md +52 -44
  2. package/dist/commands/agent.js +16 -13
  3. package/dist/commands/auth.d.ts +19 -0
  4. package/dist/commands/auth.js +60 -24
  5. package/dist/commands/ci.d.ts +86 -1
  6. package/dist/commands/ci.js +470 -9
  7. package/dist/commands/doctor.d.ts +2 -0
  8. package/dist/commands/doctor.js +22 -9
  9. package/dist/commands/init.js +14 -11
  10. package/dist/commands/project-env.d.ts +90 -0
  11. package/dist/commands/project-env.js +486 -0
  12. package/dist/commands/project.d.ts +15 -5
  13. package/dist/commands/project.js +88 -92
  14. package/dist/commands/schedule.d.ts +2 -0
  15. package/dist/commands/schedule.js +18 -10
  16. package/dist/commands/test.d.ts +102 -30
  17. package/dist/commands/test.js +1949 -419
  18. package/dist/commands/testlist.js +77 -21
  19. package/dist/commands/tunnel.d.ts +26 -3
  20. package/dist/commands/tunnel.js +211 -14
  21. package/dist/commands/usage.d.ts +3 -0
  22. package/dist/commands/usage.js +12 -5
  23. package/dist/index.js +47 -23
  24. package/dist/lib/agent-targets.d.ts +3 -3
  25. package/dist/lib/agent-targets.js +2 -2
  26. package/dist/lib/billing-refusal.d.ts +43 -0
  27. package/dist/lib/billing-refusal.js +171 -0
  28. package/dist/lib/bundle.d.ts +5 -0
  29. package/dist/lib/bundle.js +43 -13
  30. package/dist/lib/ci-linkage.d.ts +90 -0
  31. package/dist/lib/ci-linkage.js +181 -0
  32. package/dist/lib/client-factory.d.ts +4 -1
  33. package/dist/lib/client-factory.js +25 -2
  34. package/dist/lib/client-tag.d.ts +13 -0
  35. package/dist/lib/client-tag.js +44 -0
  36. package/dist/lib/config.d.ts +17 -0
  37. package/dist/lib/config.js +20 -1
  38. package/dist/lib/conflict-reason.d.ts +67 -2
  39. package/dist/lib/conflict-reason.js +148 -13
  40. package/dist/lib/credentials.js +56 -14
  41. package/dist/lib/cron.js +8 -1
  42. package/dist/lib/dry-run/samples.d.ts +13 -1
  43. package/dist/lib/dry-run/samples.js +51 -7
  44. package/dist/lib/errors.d.ts +62 -12
  45. package/dist/lib/errors.js +180 -25
  46. package/dist/lib/failing-fe-resolver.d.ts +1 -1
  47. package/dist/lib/failing-fe-resolver.js +3 -3
  48. package/dist/lib/gh-output.d.ts +26 -11
  49. package/dist/lib/gh-output.js +47 -15
  50. package/dist/lib/history-retention.d.ts +8 -0
  51. package/dist/lib/history-retention.js +24 -0
  52. package/dist/lib/http.d.ts +44 -19
  53. package/dist/lib/http.js +53 -26
  54. package/dist/lib/interrupt.d.ts +21 -13
  55. package/dist/lib/interrupt.js +32 -21
  56. package/dist/lib/junit-report.d.ts +11 -1
  57. package/dist/lib/junit-report.js +15 -3
  58. package/dist/lib/local-target.d.ts +33 -1
  59. package/dist/lib/local-target.js +78 -1
  60. package/dist/lib/output.d.ts +27 -1
  61. package/dist/lib/output.js +22 -3
  62. package/dist/lib/plan-poll.d.ts +11 -11
  63. package/dist/lib/plan-poll.js +12 -12
  64. package/dist/lib/plans.types.d.ts +9 -9
  65. package/dist/lib/plans.types.js +3 -3
  66. package/dist/lib/poll.d.ts +2 -2
  67. package/dist/lib/poll.js +9 -3
  68. package/dist/lib/render-error.d.ts +2 -0
  69. package/dist/lib/render-error.js +13 -0
  70. package/dist/lib/response-schemas.d.ts +54 -12
  71. package/dist/lib/response-schemas.js +106 -7
  72. package/dist/lib/runs.types.d.ts +92 -6
  73. package/dist/lib/secret-file.js +72 -14
  74. package/dist/lib/skill-nudge.d.ts +6 -1
  75. package/dist/lib/skill-nudge.js +32 -5
  76. package/dist/lib/target-url-preflight.d.ts +6 -4
  77. package/dist/lib/target-url-preflight.js +64 -51
  78. package/dist/lib/target-url.js +31 -12
  79. package/dist/lib/telemetry.d.ts +172 -3
  80. package/dist/lib/telemetry.js +276 -15
  81. package/dist/lib/ticker.js +93 -4
  82. package/dist/lib/tunnel-session.d.ts +13 -0
  83. package/dist/lib/tunnel-session.js +4 -1
  84. package/dist/lib/tunnel.types.d.ts +12 -2
  85. package/dist/lib/tunnel.types.js +2 -2
  86. package/dist/lib/version-notice.d.ts +20 -1
  87. package/dist/lib/version-notice.js +59 -12
  88. package/dist/lib/wait-exit.d.ts +8 -0
  89. package/dist/lib/wait-exit.js +76 -4
  90. package/dist/lib/workspace-status.d.ts +23 -0
  91. package/dist/lib/workspace-status.js +15 -0
  92. package/dist/version-guard.d.ts +7 -1
  93. package/dist/version-guard.js +19 -1
  94. package/dist/version.d.ts +1 -1
  95. package/dist/version.js +1 -1
  96. package/package.json +4 -4
  97. package/skills/testsprite-onboard.skill.md +4 -4
  98. package/skills/testsprite-verify.codex.md +59 -57
  99. package/skills/testsprite-verify.skill.md +53 -36
@@ -15,29 +15,32 @@
15
15
  * notice names the npm LATEST and fires whenever a newer release exists. Each
16
16
  * owns its own number — the backend never advertises "latest".
17
17
  *
18
+ * Under GitHub Actions the same below-floor observation is surfaced as a
19
+ * `::warning::` workflow command instead (see {@link formatPinnedVersionWarning}):
20
+ * a `ci init`-generated workflow pins `cli-version` to the version that
21
+ * generated it, so the job keeps running that version forever and the plain
22
+ * stderr line (TTY-gated) would never be seen. The floor header is the only
23
+ * version signal a CI run has in-process — the npm update check is skipped
24
+ * under `CI` by design — so this fires only when the pin has fallen BELOW the
25
+ * floor, not merely behind the newest release.
26
+ *
18
27
  * Reuses `compareSemver` and the `TESTSPRITE_NO_UPDATE_NOTIFIER` opt-out from
19
28
  * `update-check.ts` so the gating and semver semantics stay consistent.
20
29
  */
21
30
  import { compareSemver, UPDATE_CHECK_OPT_OUT_ENV } from './update-check.js';
22
31
  import { VERSION } from '../version.js';
23
32
  /**
24
- * True when every gate passes and the running version is strictly below the
25
- * advertised floor. Gates mirror the update notice: opt-out env, JSON output,
26
- * dry-run, and non-TTY all suppress. Pure — no side effects, no process state.
33
+ * The gates every advisory shares: opt-out env, dry-run, a present + parseable
34
+ * floor, and the running version strictly below it. Pure.
27
35
  */
28
- export function shouldWarnBelowFloor(info, deps = {}) {
36
+ function isBelowFloor(info, deps) {
29
37
  const env = deps.env ?? process.env;
30
38
  const currentVersion = deps.currentVersion ?? VERSION;
31
- const isTTY = deps.isTTY ?? process.stderr.isTTY === true;
32
39
  const optOut = env[UPDATE_CHECK_OPT_OUT_ENV];
33
40
  if (optOut !== undefined && optOut !== '')
34
41
  return false;
35
- if (deps.outputMode === 'json')
36
- return false;
37
42
  if (deps.dryRun === true)
38
43
  return false;
39
- if (!isTTY)
40
- return false;
41
44
  const minVersion = info.minVersion;
42
45
  if (!minVersion)
43
46
  return false;
@@ -45,6 +48,33 @@ export function shouldWarnBelowFloor(info, deps = {}) {
45
48
  // Unparseable input on either side compares as 0, so garbage never warns.
46
49
  return compareSemver(currentVersion, minVersion) === -1;
47
50
  }
51
+ /**
52
+ * True when every gate passes and the running version is strictly below the
53
+ * advertised floor. Gates mirror the update notice: opt-out env, JSON output,
54
+ * dry-run, and non-TTY all suppress. Pure — no side effects, no process state.
55
+ */
56
+ export function shouldWarnBelowFloor(info, deps = {}) {
57
+ const isTTY = deps.isTTY ?? process.stderr.isTTY === true;
58
+ if (deps.outputMode === 'json')
59
+ return false;
60
+ if (!isTTY)
61
+ return false;
62
+ return isBelowFloor(info, deps);
63
+ }
64
+ /**
65
+ * True when the below-floor state should be surfaced as a GitHub Actions
66
+ * `::warning::` annotation: running under Actions (`GITHUB_ACTIONS=true`), not
67
+ * opted out, not dry-run, and strictly below the floor. Deliberately NOT gated
68
+ * on TTY or `--output json` — an Actions job is never a TTY, and a workflow
69
+ * command is parsed by the runner from either stream, so it can ride stderr
70
+ * without touching a JSON envelope on stdout.
71
+ */
72
+ export function shouldWarnPinnedInActions(info, deps = {}) {
73
+ const env = deps.env ?? process.env;
74
+ if (env.GITHUB_ACTIONS !== 'true')
75
+ return false;
76
+ return isBelowFloor(info, deps);
77
+ }
48
78
  /**
49
79
  * The single advisory line. Names the floor (the backend's authority) and the
50
80
  * upgrade command — it deliberately does NOT name a target release; the npm
@@ -55,6 +85,18 @@ export function formatBelowFloorNotice(currentVersion, minVersion) {
55
85
  `Upgrade: npm install -g @testsprite/testsprite-cli ` +
56
86
  `(disable this notice with ${UPDATE_CHECK_OPT_OUT_ENV}=1).`);
57
87
  }
88
+ /**
89
+ * The GitHub Actions workflow-command form of the advisory. Names the pinned
90
+ * (running) version, the floor it has fallen below, and the one command that
91
+ * re-pins the workflow to a current release. Both versions come from semver
92
+ * strings that already parsed (see `isBelowFloor`), so no command-data escaping
93
+ * is needed — neither can carry `%`, CR or LF.
94
+ */
95
+ export function formatPinnedVersionWarning(currentVersion, minVersion) {
96
+ return (`::warning title=TestSprite::testsprite-cli ${currentVersion} is pinned in this workflow ` +
97
+ `and is below the minimum supported version ${minVersion}. ` +
98
+ `Regenerate with testsprite ci init github --force.`);
99
+ }
58
100
  /** Module-level guard: at most one below-floor advisory per process. */
59
101
  let warnedThisProcess = false;
60
102
  /** Test-only: reset the once-per-process guard between cases. */
@@ -64,20 +106,25 @@ export function resetBelowFloorNoticeState() {
64
106
  /**
65
107
  * Emit the below-floor advisory at most once per process. Wired to the HTTP
66
108
  * client's `onServerVersion` hook. Never throws — an advisory must not break or
67
- * delay the command it rides along with.
109
+ * delay the command it rides along with. Under GitHub Actions the advisory is
110
+ * the `::warning::` workflow command (annotates the job) instead of the plain
111
+ * TTY line; exactly one of the two is ever emitted.
68
112
  */
69
113
  export function noteServerVersion(info, deps = {}) {
70
114
  try {
71
115
  if (warnedThisProcess)
72
116
  return;
73
- if (!shouldWarnBelowFloor(info, deps))
117
+ const inActions = shouldWarnPinnedInActions(info, deps);
118
+ if (!inActions && !shouldWarnBelowFloor(info, deps))
74
119
  return;
75
120
  const minVersion = info.minVersion;
76
121
  if (!minVersion)
77
122
  return;
78
123
  const currentVersion = deps.currentVersion ?? VERSION;
79
124
  const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
80
- stderr(formatBelowFloorNotice(currentVersion, minVersion));
125
+ stderr(inActions
126
+ ? formatPinnedVersionWarning(currentVersion, minVersion)
127
+ : formatBelowFloorNotice(currentVersion, minVersion));
81
128
  warnedThisProcess = true;
82
129
  }
83
130
  catch {
@@ -14,8 +14,16 @@ export interface WaitMemberResult {
14
14
  code: string;
15
15
  message: string;
16
16
  exitCode?: number;
17
+ nextAction?: string;
18
+ serverNextAction?: string;
19
+ requestId?: string;
20
+ details?: Record<string, unknown>;
21
+ apiUrl?: string;
17
22
  };
18
23
  }
24
+ export declare function waitMemberError(err: ApiError): NonNullable<WaitMemberResult['error']> & {
25
+ exitCode: number;
26
+ };
19
27
  /**
20
28
  * Resolve the process-level failure for a completed `--wait` fan-out, or `null`
21
29
  * when every member passed. Shared by `test run --all` / `test rerun` and
@@ -1,4 +1,47 @@
1
- import { ApiError, CLIError, isAuthCode } from './errors.js';
1
+ import { ApiError, CLIError, isAuthCode, isErrorCode } from './errors.js';
2
+ import { classifyBillingRefusal, isPausedReason } from './billing-refusal.js';
3
+ /**
4
+ * Envelope metadata for a billing/feature-gate member error, keyed by the
5
+ * IDENTITY of the object `waitMemberError` returns. The enumerable shape of
6
+ * that object must stay exactly `{ code, message, exitCode }` — it lands
7
+ * verbatim in `--output json` stdout (`accepted[]` / `results[]`), and a
8
+ * `nextAction` / `details` / `apiUrl` riding along there would both leak
9
+ * internal fields to every consumer AND (since the guard below fires for
10
+ * every FEATURE_GATED, including `rollout`) attach billing-looking data to a
11
+ * refusal that isn't one. The extra fields `resolveWaitFailure` needs to
12
+ * reconstruct a faithful ApiError travel here instead, out of band.
13
+ */
14
+ const memberEnvelopeMeta = new WeakMap();
15
+ export function waitMemberError(err) {
16
+ const memberError = { code: err.code, message: err.message, exitCode: err.exitCode };
17
+ if (err.code === 'FEATURE_GATED' || classifyBillingRefusal(err)) {
18
+ memberEnvelopeMeta.set(memberError, {
19
+ nextAction: err.nextAction,
20
+ serverNextAction: err.serverNextAction,
21
+ requestId: err.requestId,
22
+ details: err.details,
23
+ apiUrl: err.apiUrl,
24
+ });
25
+ }
26
+ return memberError;
27
+ }
28
+ /**
29
+ * Read a member error's out-of-band envelope metadata, falling back to
30
+ * whatever the object carries as OWN enumerable properties. The fallback
31
+ * exists for callers that build a `WaitMemberResult['error']` by hand (a
32
+ * legacy/shared JUnit result shape, or a test fixture) rather than through
33
+ * `waitMemberError` — those never got a `memberEnvelopeMeta` entry, so their
34
+ * fields must still be read the old way.
35
+ */
36
+ function memberMeta(error) {
37
+ return (memberEnvelopeMeta.get(error) ?? {
38
+ nextAction: error.nextAction,
39
+ serverNextAction: error.serverNextAction,
40
+ requestId: error.requestId,
41
+ details: error.details,
42
+ apiUrl: error.apiUrl,
43
+ });
44
+ }
2
45
  /**
3
46
  * Exit-code precedence for a `--wait` fan-out, highest first. Ordered
4
47
  * batch-wide-non-retriable → per-run → transient → timeout → generic:
@@ -61,10 +104,39 @@ export function resolveWaitFailure(results, opts) {
61
104
  // non-1 exit like 0/99). Routed through the ENVELOPE so `--output json`
62
105
  // carries `error.code` — the machine-readable field this fix exists for;
63
106
  // `ApiError.fromEnvelope` derives the exit via `exitCodeFor(code)`.
64
- const operational = errored
65
- .filter(r => isOperationalCode(r.error.exitCode ?? 1))
66
- .sort((a, b) => priorityOf(a.error.exitCode) - priorityOf(b.error.exitCode))[0];
107
+ const operationalCandidates = errored.filter(r => isOperationalCode(r.error.exitCode ?? 1));
108
+ // Narrow exception to the table above (mirrors the identical rule in
109
+ // conflict-reason.ts's `isPausedRefusal`): when EVERY operational
110
+ // member is a billing refusal and at least one is a paused workspace, paused
111
+ // wins over a plain credits shortfall — topping up credits cannot resume a
112
+ // paused workspace. This does not reorder WAIT_EXIT_PRIORITY for any other
113
+ // code combination.
114
+ const isPausedMember = (r) => r.error.code === 'FEATURE_GATED' && isPausedReason(memberMeta(r.error).details?.reason);
115
+ const isBillingRefusalMember = (r) => r.error.code === 'INSUFFICIENT_CREDITS' || isPausedMember(r);
116
+ const operational = operationalCandidates.length > 0 &&
117
+ operationalCandidates.every(isBillingRefusalMember) &&
118
+ operationalCandidates.some(isPausedMember)
119
+ ? operationalCandidates.find(isPausedMember)
120
+ : operationalCandidates.sort((a, b) => priorityOf(a.error.exitCode) - priorityOf(b.error.exitCode))[0];
67
121
  if (operational) {
122
+ const meta = memberMeta(operational.error);
123
+ if (meta.details && isErrorCode(operational.error.code)) {
124
+ // Merge the server's own details with the local runId/testId (never the
125
+ // reverse) so automation reading `error.details.runId`/`testId` keeps
126
+ // working for a billing refusal exactly as it does for any other typed
127
+ // error, while `reason` (billing_hold / rollout / …) survives untouched.
128
+ return new ApiError({
129
+ code: operational.error.code,
130
+ message: operational.error.message,
131
+ nextAction: meta.nextAction ?? '',
132
+ requestId: meta.requestId ?? 'local',
133
+ details: {
134
+ ...meta.details,
135
+ runId: operational.runId ?? null,
136
+ testId: operational.testId ?? null,
137
+ },
138
+ }, undefined, undefined, meta.apiUrl, meta.serverNextAction);
139
+ }
68
140
  return ApiError.fromEnvelope({
69
141
  error: {
70
142
  code: operational.error.code,
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The workspace's billing standing, as `GET /me` reports it under
3
+ * `activeOrg.workspace` (backend `WorkspaceGateService.status`). `state` is
4
+ * what the FE banners key on; `notice` is the refusal every write will get
5
+ * while the workspace is paused, already worded — it is null while the
6
+ * workspace can be written to.
7
+ */
8
+ export interface WorkspaceStatus {
9
+ state: 'ok' | 'pending' | 'paused';
10
+ tier: string;
11
+ notice: {
12
+ title: string;
13
+ message: string;
14
+ cta: string;
15
+ billingUrl: string;
16
+ } | null;
17
+ }
18
+ /**
19
+ * One line for the text renderers (`auth status`, `usage`) — undefined when
20
+ * the workspace is simply on its plan, so the callers print nothing then.
21
+ * `--output json` carries the whole object; this is the human reading of it.
22
+ */
23
+ export declare function formatWorkspaceStatus(ws: WorkspaceStatus | undefined): string | undefined;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * One line for the text renderers (`auth status`, `usage`) — undefined when
3
+ * the workspace is simply on its plan, so the callers print nothing then.
4
+ * `--output json` carries the whole object; this is the human reading of it.
5
+ */
6
+ export function formatWorkspaceStatus(ws) {
7
+ if (!ws || ws.state === 'ok')
8
+ return undefined;
9
+ if (ws.notice)
10
+ return `${ws.state} — ${ws.notice.message} ${ws.notice.cta}: ${ws.notice.billingUrl}`;
11
+ if (ws.state === 'pending')
12
+ return 'pending — a scheduled plan change or a payment retry is in progress; the workspace keeps working meanwhile';
13
+ return ws.state;
14
+ }
15
+ //# sourceMappingURL=workspace-status.js.map
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * The CLI targets modern Node (see `engines.node` in package.json). Running on
5
5
  * an older runtime tends to fail later with a cryptic ESM/syntax error, so the
6
- * entrypoint (`src/index.ts`) uses {@link shouldRejectNodeVersion} to exit early
6
+ * entrypoint (`src/index.ts`) uses {@link rejectUnsupportedNodeVersion} to exit early
7
7
  * with a clear, actionable message instead.
8
8
  *
9
9
  * The logic lives here (rather than inline) so it can be unit-tested against the
@@ -34,3 +34,9 @@ export declare function parseMajorVersion(nodeVersion: string): number;
34
34
  * @returns `true` when the runtime is unsupported and should be rejected.
35
35
  */
36
36
  export declare function shouldRejectNodeVersion(nodeVersion: string): boolean;
37
+ export interface RejectUnsupportedNodeDeps {
38
+ writeStderr?: (message: string) => void;
39
+ exit?: (code: number) => void;
40
+ }
41
+ /** Write synchronously so an immediate exit cannot truncate piped stderr. */
42
+ export declare function rejectUnsupportedNodeVersion(nodeVersion: string, deps?: RejectUnsupportedNodeDeps): void;
@@ -3,12 +3,13 @@
3
3
  *
4
4
  * The CLI targets modern Node (see `engines.node` in package.json). Running on
5
5
  * an older runtime tends to fail later with a cryptic ESM/syntax error, so the
6
- * entrypoint (`src/index.ts`) uses {@link shouldRejectNodeVersion} to exit early
6
+ * entrypoint (`src/index.ts`) uses {@link rejectUnsupportedNodeVersion} to exit early
7
7
  * with a clear, actionable message instead.
8
8
  *
9
9
  * The logic lives here (rather than inline) so it can be unit-tested against the
10
10
  * real implementation the entrypoint uses — not a copy.
11
11
  */
12
+ import { writeSync } from 'node:fs';
12
13
  /** Canonical supported range, pinned to package.json by the unit test. */
13
14
  export const SUPPORTED_NODE_ENGINE = '^20.19.0 || ^22.13.0 || >=24';
14
15
  /** Human-readable form of the supported range for startup errors. */
@@ -64,4 +65,21 @@ export function shouldRejectNodeVersion(nodeVersion) {
64
65
  return true;
65
66
  return false;
66
67
  }
68
+ /** Write synchronously so an immediate exit cannot truncate piped stderr. */
69
+ export function rejectUnsupportedNodeVersion(nodeVersion, deps = {}) {
70
+ if (!shouldRejectNodeVersion(nodeVersion))
71
+ return;
72
+ const writeStderr = deps.writeStderr ??
73
+ ((message) => {
74
+ try {
75
+ writeSync(process.stderr.fd, message);
76
+ }
77
+ catch {
78
+ // Best-effort: the runtime still exits when stderr is unavailable.
79
+ }
80
+ });
81
+ const exit = deps.exit ?? ((code) => process.exit(code));
82
+ writeStderr(`Error: testsprite requires Node.js ${SUPPORTED_NODE_RANGE} (found ${nodeVersion}).\nInstall a supported Node.js release from https://nodejs.org\n`);
83
+ exit(1);
84
+ }
67
85
  //# sourceMappingURL=version-guard.js.map
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.11.0";
1
+ export declare const VERSION = "0.13.0";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED by scripts/generate-version.mjs — do not edit by hand.
2
2
  // Run `npm run build` (or `npm run generate:version`) to regenerate.
3
- export const VERSION = '0.11.0';
3
+ export const VERSION = '0.13.0';
4
4
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testsprite/testsprite-cli",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Official TestSprite command-line interface",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "prebuild": "node scripts/generate-version.mjs",
19
19
  "build": "tsc -p tsconfig.build.json && node scripts/postbuild.mjs",
20
20
  "clean": "rm -rf dist coverage",
21
- "lint": "eslint .",
21
+ "lint": "eslint . && node .github/scripts/check-ticket-refs.mjs",
22
22
  "lint:fix": "eslint . --fix",
23
23
  "format": "prettier --write .",
24
24
  "format:check": "prettier --check .",
@@ -67,7 +67,7 @@
67
67
  "devDependencies": {
68
68
  "@eslint/js": "^10.0.1",
69
69
  "@types/node": "^22.9.0",
70
- "@vitest/coverage-v8": "^2.1.4",
70
+ "@vitest/coverage-v8": "^4.1.11",
71
71
  "ajv": "^8.20.0",
72
72
  "eslint": "^10.7.0",
73
73
  "eslint-config-prettier": "^9.1.0",
@@ -78,6 +78,6 @@
78
78
  "selfsigned": "^5.5.0",
79
79
  "typescript": "^5.6.3",
80
80
  "typescript-eslint": "^8.13.0",
81
- "vitest": "^2.1.4"
81
+ "vitest": "^4.1.11"
82
82
  }
83
83
  }
@@ -216,9 +216,9 @@ testsprite test run <testId> --local <port> --local-host <host> # local fronten
216
216
 
217
217
  Do **not** run the whole suite automatically. V3 frontend runs, including local runs,
218
218
  cost 0.5 credit each; check `testsprite usage` before sizing the suite.
219
- Local runs imply waiting (1200 seconds by default); one test per invocation, parallel
220
- invocations allowed, 5 live tunnel bindings per user. Keep the early stderr `Run <runId>`
221
- receipt. An owned local timeout cancels by default: start a new run with
219
+ Local runs wait (1200 s per run). Put several in ONE `test run <id> <id> --local <port>`
220
+ (one tunnel, 5 at a time); each process holds 1 of 5 tunnel slots. Keep the stderr
221
+ `Run <runId>` receipt. An owned local timeout cancels by default: start a new run with
222
222
  `--local <port> --local-host <host> --timeout 1800` (same host), not `test wait`. A run cancelled before it finished is refunded.
223
223
 
224
224
  ### 6. Report
@@ -229,7 +229,7 @@ Tell the user, plainly:
229
229
  - "I smoke-ran **M** — here's the result: <pass/fail + the dashboard link from the run output>."
230
230
  - "To run the rest (≈X credits — state the cost so they choose knowingly):
231
231
  - frontend — use `test run <testId> --wait` for deployed targets or
232
- `test run <testId> --local <port> --local-host <host>` for local targets (`--all --local` is refused);
232
+ `test run --all --project <id> --local <port> --local-host <host>` for local targets;
233
233
  - backend — `testsprite test run --all --project <id>` (wave-ordered, runs every BE test)."
234
234
 
235
235
  ## Quality checklist (self-check before reporting done)
@@ -1,8 +1,7 @@
1
1
  # TestSprite Verification Loop
2
2
 
3
- After a feature/fix, run relevant tests and inspect failures before reporting done.
4
- Skip docs-only/build-config edits. Missing credentials mean unverified.
5
- Honor the user's explicit choice of CLI or MCP.
3
+ Run relevant tests and inspect failures before reporting. Skip docs/build-config
4
+ edits; missing credentials mean unverified. Honor the user's CLI/MCP choice.
6
5
 
7
6
  ## 1. Preflight and project
8
7
 
@@ -11,78 +10,82 @@ testsprite --version
11
10
  testsprite auth status
12
11
  ```
13
12
 
14
- If missing, tell the user to install the CLI or run `testsprite setup` respectively.
15
- Resolve the project from `$TESTSPRITE_PROJECT_ID`, `.testsprite/config.json`, then
16
- `testsprite project list --output json`; ask if multiple projects match.
13
+ If missing, advise CLI install or `testsprite setup`. Find the project via
14
+ `$TESTSPRITE_PROJECT_ID`, `.testsprite/config.json`, then `testsprite project list
15
+ --output json`; ask if several match.
17
16
 
18
- For a local app with no project, start it and bootstrap:
17
+ For a local app without a project:
19
18
 
20
19
  ```bash
21
20
  testsprite project create --type frontend --name "<repo name>" --local <port> --local-host <host>
22
21
  testsprite test create --plan-from plan.json --project <projectId>
23
- testsprite test run <test-id> --local <port> --local-host <host> --output json
22
+ testsprite test run <id> <id> --local <port> --local-host <host> --output json
24
23
  ```
25
24
 
26
- Local projects need V3 (V2-only: exit 7, `local-origin-requires-v3`). They skip
27
- exploration; `test plan generate` is refused before charge (exit 6). Author plans
28
- with `test create --plan-from` without `--run`, then run each id with `--local`.
29
- Portal runs are blocked for free until `project update <id> --url https://…` sets
30
- a public URL. Deployed projects retain `project create --url`; an empty deployed
31
- suite can use `test plan generate --project <id>` then `test plan accept`.
25
+ Local projects need V3 (V2-only: exit 7, `local-origin-requires-v3`). Exploration
26
+ and `test plan generate` exit 6 before charge. Create plans with `test create
27
+ --plan-from` without `--run`; then run several ids with `--local`. Portal runs
28
+ are blocked free until `project update <id> --url https://…` sets a public URL.
29
+ For deployed projects use `project create --url`; empty suites can use `test plan
30
+ generate --project <id>` then `test plan accept`.
32
31
 
33
32
  ## 2. Run against the change
34
33
 
35
- Reuse a test covering the change or create one. Public `--target-url` must contain
36
- the new deployment. The CLI does not build/host apps. For local-only changes use
37
- `testsprite test run <test-id> --local <port>` (frontend only).
34
+ The CLI does not host apps. Create a deployed environment once; select it with
35
+ `--env <name>` or omit for Default. Unknown names list valid names. Use `--local
36
+ <port>` for local FE runs.
38
37
 
39
38
  ```bash
40
39
  # Deployed frontend: create + run, or run an existing test
40
+ testsprite project env create <id> --name staging --url https://staging.example.com
41
41
  testsprite test create --plan-from plan.json --run --wait \
42
- --target-url https://staging.example.com --timeout 600 --output json
43
- testsprite test run <test-id> --target-url https://staging.example.com \
42
+ --env staging --timeout 600 --output json
43
+ testsprite test run <test-id> --env staging \
44
44
  --wait --timeout 600 --output json
45
45
  # Backend Python assertion
46
46
  testsprite test create --type backend --name "Login rejects empty password" \
47
47
  --project <id> --code-file /tmp/test.py --run --wait --timeout 600
48
48
  # Deployed replay (V3 FE: 0.5 credit)
49
- testsprite test rerun <test-id> --wait --output json
49
+ testsprite test rerun <test-id> --env staging --wait --output json
50
50
  # Dependency batch; optional --filter <substring>
51
- testsprite test run --all --project <id> --wait --max-concurrency 4 --output json
51
+ testsprite test run --all --project <id> --env staging --wait --output json
52
52
  ```
53
53
 
54
- - Local runs need `run:tunnel`; keys minted before that scope existed must be
55
- replaced if the CLI names it as missing (exit 3). Free-plan local runs work;
56
- a V3 frontend run costs 0.5 credit. Backend tests cannot use `--local`.
57
- - `--local` implies `--wait`; timeout defaults to 1200 seconds, ordinary waits
58
- to 600. `--local-host` accepts `localhost`, `127.0.0.1` (default), or `::1`.
59
- A dead port exits 5 before charge; `--skip-preflight` bypasses the probe.
60
- Public `--target-url` rejects localhost/private addresses and excludes `--local`.
61
- - One test per local invocation; parallel invocations are fine. `--all --local`
62
- exits 5. A user has 5 live tunnel bindings; `tunnel_binding_limit` is exit 11,
63
- not auto-retried. Stop an unused tunnel or reuse one with `--tunnel-client`.
64
- - Keep the early **stderr** `Run <runId>` receipt, emitted after triggering;
65
- `Dashboard: <url>` follows when supplied. Stdout remains the JSON result channel.
66
- - An **owned** local timeout, Ctrl-C, or polling failure cancels the run by
67
- default and closes the tunnel. Check the reported cancellation outcome.
68
- A run cancelled before it finished is refunded. `--no-cancel-on-interrupt`
69
- detaches instead, but the owned tunnel still closes and the run remains billable.
70
- - Owned local timeout: start a **new**
71
- `testsprite test run <test-id> --local <port> --timeout 1800`,
72
- keeping `--local-host <host>` if used. `test wait` cannot reopen the tunnel.
73
- Ordinary/adopted waits can resume with `testsprite test wait <run-id>`
74
- while the target is reachable.
75
- - `tunnel start` (no port) holds a tunnel in a terminal; keep it alive.
76
- Borrow via `--local <port> --tunnel-client <uuid>`; no automatic cancel or close.
77
- A second `tunnel start`/process using the same credential takes over; the first exits **10**.
78
- - A case last run through a tunnel stays local: later Portal Run, schedules, or
79
- bare CLI runs are free BLOCKED (`tunnel-required`, exit 6). Use `--local` again
80
- or explicitly retarget with public `--target-url`. V3 local runs use the agent
81
- path, never saved-code replay, and preserve saved code.
54
+ - Supported backends grant existing keys `run:tunnel`; a narrowed key without it
55
+ exits 3. Free-plan local runs work; V3 FE costs 0.5 credit. BE cannot use `--local`.
56
+ - `--local` implies `--wait` (1200 s per run; ordinary: 600). `--local-host`:
57
+ `localhost`, `127.0.0.1` (default), `::1`. A dead port exits 5 before charge;
58
+ `--skip-preflight` skips the probe. Environment `--url` rejects private hosts.
59
+ `--local` selects/creates `local-<port>`; a named `--env` must be local.
60
+ `--target-url` cannot combine with `--local`.
61
+ - Run local ids together (`test run <id> <id> … --local <port>`); `--all --project
62
+ <id> --local <port>` skips BE tests. One tunnel, 5 concurrent runs by default
63
+ (`--max-concurrency` 1–10). Five live bindings per user; `tunnel_binding_limit`
64
+ exits 11 without retry. Use `tunnel list` then `tunnel stop <id>` or `--all --confirm`.
65
+ - Keep early **stderr** `Run <runId>` receipts and any `Dashboard: <url>`.
66
+ Stdout is the JSON channel.
67
+ - An **owned** local timeout, Ctrl-C, or poll failure requests cancellation and
68
+ closes the tunnel. Before a terminal V3 FE verdict, the backend attempts a refund;
69
+ check `refund.status`: cancellation does not guarantee a refund.
70
+ `--no-cancel-on-interrupt` detaches, but the owned tunnel still closes.
71
+ - After an owned timeout, start a **new** `test run <test-id> --local <port>
72
+ --timeout 1800` (retain `--local-host`). `test wait` cannot reopen the tunnel;
73
+ ordinary/adopted waits can resume with `test wait <run-id>` if reachable.
74
+ - Keep `tunnel start` alive; borrow with `--local <port> --tunnel-client <uuid>`.
75
+ Adopted runs normally detach without cancellation or closing the owner's tunnel.
76
+ If the owner has disappeared during a run, cancellation is requested by default;
77
+ `--no-cancel-on-interrupt` skips it. A second connection with the same credential
78
+ takes over; the first exits **10**.
79
+ - Loopback environments need `--local <port>`. Bare CLI runs selecting one by
80
+ name or Default exit 6 (`tunnel-required`) before dispatch or charge. The Portal
81
+ shows no Run; backend requests are refused free. Schedules and test lists get
82
+ free BLOCKED results. A public `--env` or Default works regardless of earlier
83
+ tunnel runs. V3 local runs use the agent path, never saved-code replay, and
84
+ preserve saved code.
82
85
  - `--wait` handles polling/backoff; do not wrap it in a retry loop.
83
- - Backend Python runs top-to-bottom, not via pytest: call your `test_*` functions.
84
- The sandbox has stdlib, `requests`, `pytest`, `numpy`, and `scipy`; use HTTP,
85
- not imports from the project's source or uninstalled packages.
86
+ - Backend Python runs top-to-bottom, not via pytest: call `test_*` functions.
87
+ The sandbox has stdlib, `requests`, `pytest`, `numpy`, `scipy`; use HTTP,
88
+ not project imports or uninstalled packages.
86
89
  - Backend `--produces`/`--needs` are repeatable; `--category teardown` marks cleanup.
87
90
  Set dependencies with `test create` or edit with `test update`; do not delete
88
91
  and recreate. Use `test run --all` for producer → consumer → teardown ordering
@@ -97,10 +100,9 @@ testsprite test artifact get <run-id> --out ./.testsprite/runs/<run-id>/
97
100
  testsprite test steps <test-id> --run-id <run-id> --output json
98
101
  ```
99
102
 
100
- Read the failing step, screenshots and root cause. Bare `test steps <test-id>`
101
- means the latest run's steps; pin the receipt's
102
- run id. An empty latest run does not substitute earlier steps; choose an earlier
103
- id from `test result <test-id> --history`. Report the verdict and dashboard link.
103
+ Read failing steps, screenshots and root cause. Bare `test steps <test-id>`
104
+ shows the latest run; pin the receipt's id. For empty latest steps, choose an
105
+ earlier run from `test result <test-id> --history`. Report verdict and dashboard.
104
106
 
105
107
  Exits: 0 passed; 1 failed/blocked/cancelled; 3 auth/scope; 4 not found;
106
108
  5 validation; 6 conflict/precondition; 7 timeout/unsupported; 10 unavailable;
@@ -115,4 +117,4 @@ testsprite test run <test-id> --dry-run --output json
115
117
  testsprite test create --plan-from plan.json --dry-run --output json
116
118
  ```
117
119
 
118
- Setup: `npm install -g @testsprite/testsprite-cli`, then `testsprite setup`.
120
+ Setup: `npm install -g @testsprite/testsprite-cli`; `testsprite setup`.