@testsprite/testsprite-cli 0.11.0 → 0.12.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.
package/README.md CHANGED
@@ -153,46 +153,47 @@ See [the full local-testing reference](./DOCUMENTATION.md#local-frontend-testing
153
153
 
154
154
  ## Commands
155
155
 
156
- | Group | Command | What it does |
157
- | -------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
158
- | **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
159
- | | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
160
- | **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
161
- | | `auth remove` | Remove the active profile from the credentials file |
162
- | | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
163
- | **Read** | `project list` / `project get` | List projects / fetch one by id |
164
- | | `test list` / `test get` | List tests under a project / fetch one by id |
165
- | | `test code get` | Print (or write) the generated test source |
166
- | | `test steps` | List the latest run's steps with screenshot / DOM pointers |
167
- | | `test result` | Latest result; `--history` lists a test's prior runs |
168
- | | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
169
- | | `test failure summary` | One-screen triage card (no media download) |
170
- | | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
171
- | **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
172
- | | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--step-timeout <ms>` sets a per-test timeout; dependency flags wire BE metadata |
173
- | | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
174
- | | `test code put` | Replace generated code (etag-guarded) |
175
- | | `test plan put` | Replace a frontend test's plan-steps |
176
- | | `project create` / `project update` / `project delete` | Manage projects; `--test-id-attributes <list>` registers the app's own test-hook attributes (priority order) for exported locators, `--clear-test-id-attributes` reverts; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
177
- | | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
178
- | **Generate** | `test plan generate` | Ask TestSprite to propose test cases for a project — proposals are staged server-side for review, never written to disk; only the stages the project is missing actually run |
179
- | | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
180
- | | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
181
- | **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order |
182
- | | `test rerun` | Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); `--all --project <id>` reruns all tests |
183
- | | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
184
- | | `test wait` | Block on one or more `runId`s until terminal |
185
- | | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except an owned `--local` run, which Ctrl-C cancels by default) |
186
- | | `test artifact get` | Download the failure bundle for a specific `runId` |
187
- | **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
188
- | | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
189
- | | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar |
190
- | **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
191
- | | `schedule create` | Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced |
192
- | | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it |
193
- | | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
194
- | | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
195
- | **Agent** | `agent install` / `agent list` / `agent status` | Add, list, or health-check coding-agent skills (pure-local): `claude`, `codex`, `cursor`, `cline`, `antigravity`, `kiro`, `windsurf`, `copilot` |
156
+ | Group | Command | What it does |
157
+ | -------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
158
+ | **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
159
+ | | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
160
+ | **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
161
+ | | `auth remove` | Remove the active profile from the credentials file |
162
+ | | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
163
+ | **Read** | `project list` / `project get` | List projects / fetch one by id |
164
+ | | `test list` / `test get` | List tests under a project / fetch one by id |
165
+ | | `test code get` | Print (or write) the generated test source |
166
+ | | `test steps` | List the latest run's steps with screenshot / DOM pointers |
167
+ | | `test result` | Latest result; `--history` lists a test's prior runs (ENV column; `--env <name>` filters by environment) |
168
+ | | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
169
+ | | `test failure summary` | One-screen triage card (no media download) |
170
+ | | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
171
+ | **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
172
+ | | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--step-timeout <ms>` sets a per-test timeout; dependency flags wire BE metadata |
173
+ | | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
174
+ | | `test code put` | Replace generated code (etag-guarded) |
175
+ | | `test plan put` | Replace a frontend test's plan-steps |
176
+ | | `project create` / `project update` / `project delete` | Manage projects; `--test-id-attributes <list>` registers the app's own test-hook attributes (priority order) for exported locators, `--clear-test-id-attributes` reverts; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
177
+ | | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
178
+ | | `project env list` / `create` / `update` / `delete` / `set-default` | Manage a project's environments — named URL + login bundles that `test run --env <name>` selects. An app on your own machine is named with `--local <port>` instead of `--url` — the same spelling as `project create` — and run with `test run --local <port>`; `delete` refuses the default environment |
179
+ | **Generate** | `test plan generate` | Ask TestSprite to propose test cases for a project — proposals are staged server-side for review, never written to disk; only the stages the project is missing actually run |
180
+ | | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
181
+ | | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
182
+ | **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order `--env <name>` runs against a named environment. |
183
+ | | `test rerun` | Replay one/many tests (FE verbatim; BE with deps); billed as a run (0.5 credits FE / 0.2 BE); `--all --project <id>` reruns all tests `--env <name>` replays against a named environment. |
184
+ | | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
185
+ | | `test wait` | Block on one or more `runId`s until terminal |
186
+ | | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except an owned `--local` run, which Ctrl-C cancels by default) |
187
+ | | `test artifact get` | Download the failure bundle for a specific `runId` |
188
+ | **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
189
+ | | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
190
+ | | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar |
191
+ | **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
192
+ | | `schedule create` | Run a project or test list on a 5-field cron; states the frequency before sending and the per-run / monthly credit cost once priced |
193
+ | | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it |
194
+ | | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
195
+ | | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
196
+ | **Agent** | `agent install` / `agent list` / `agent status` | Add, list, or health-check coding-agent skills (pure-local): `claude`, `codex`, `cursor`, `cline`, `antigravity`, `kiro`, `windsurf`, `copilot` |
196
197
 
197
198
  > The earlier command names — `init`, `auth configure`, `auth whoami`, `auth logout` — still work as hidden, deprecated aliases (each prints a one-line notice pointing at the new name), so existing scripts keep running. `auth configure` now runs the full `setup` (it also installs the skill).
198
199
 
@@ -7,6 +7,7 @@ import { CLIError, localValidationError } from '../lib/errors.js';
7
7
  import { loadConfig } from '../lib/config.js';
8
8
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
9
9
  import { assertNotLocal } from '../lib/target-url.js';
10
+ import { recordTelemetryExtras } from '../lib/telemetry.js';
10
11
  import { VERSION } from '../version.js';
11
12
  // ── constants ────────────────────────────────────────────────────────────────
12
13
  /** Platforms `ci init` can scaffold. One today; the positional arg leaves room. */
@@ -259,16 +260,43 @@ function trySetSecret(opts, deps, cwd) {
259
260
  }
260
261
  // ── orchestrator ─────────────────────────────────────────────────────────────
261
262
  export async function runCiInit(opts, deps = {}) {
263
+ if (!SUPPORTED_PLATFORMS.includes(opts.platform)) {
264
+ throw localValidationError('platform', `unsupported "${opts.platform}" — supported: ${SUPPORTED_PLATFORMS.join(', ')}`, undefined, 'field');
265
+ }
266
+ const platform = opts.platform;
267
+ // Telemetry facts for this invocation (see lib/telemetry.ts — low-cardinality
268
+ // only: never the path, the project id, or the filter). `workflowExisted` is
269
+ // learned only once the write is attempted, so it is filled in below and the
270
+ // whole set is recorded on every exit path, including a thrown error.
271
+ let workflowExisted;
272
+ try {
273
+ await runCiInitScaffold(opts, deps, platform, existed => {
274
+ workflowExisted = existed;
275
+ });
276
+ }
277
+ finally {
278
+ recordTelemetryExtras({
279
+ platform,
280
+ force: opts.force,
281
+ projectResolved: opts.project ? 'flag' : 'auto',
282
+ ...(workflowExisted !== undefined ? { workflowExisted } : {}),
283
+ });
284
+ }
285
+ }
286
+ /**
287
+ * The scaffold proper (everything after platform validation). Reports whether a
288
+ * workflow file already existed at the target path via `onExisted` the moment
289
+ * that is known — BEFORE the `--force` decision throws or overwrites. Under
290
+ * `--dry-run` it returns before the write is attempted, so `onExisted` is never
291
+ * called and the fact stays unknown.
292
+ */
293
+ async function runCiInitScaffold(opts, deps, platform, onExisted) {
262
294
  const stdout = deps.stdout ?? ((line) => process.stdout.write(`${line}\n`));
263
295
  const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
264
296
  const fs = deps.fs ?? defaultCiFs;
265
297
  const spawn = deps.spawn ?? defaultSpawn;
266
298
  const cwd = deps.cwd ?? process.cwd();
267
299
  const out = new Output(opts.output, { stdout, stderr });
268
- if (!SUPPORTED_PLATFORMS.includes(opts.platform)) {
269
- throw localValidationError('platform', `unsupported "${opts.platform}" — supported: ${SUPPORTED_PLATFORMS.join(', ')}`, undefined, 'field');
270
- }
271
- const platform = opts.platform;
272
300
  // Validate the caller's own inputs up front — BEFORE the project-list round
273
301
  // trip — so a bad --filter/--project fails fast without a wasted request.
274
302
  if (opts.filter)
@@ -336,6 +364,7 @@ export async function runCiInit(opts, deps = {}) {
336
364
  let wrote = true;
337
365
  try {
338
366
  await fs.writeFile(absPath, workflow, { exclusive: true });
367
+ onExisted(false);
339
368
  }
340
369
  catch (err) {
341
370
  const code = err.code;
@@ -344,6 +373,7 @@ export async function runCiInit(opts, deps = {}) {
344
373
  }
345
374
  if (code !== 'EEXIST')
346
375
  throw err;
376
+ onExisted(true);
347
377
  const prior = await fs.readFile(absPath);
348
378
  if (prior === workflow) {
349
379
  // Already exactly what we'd write — no rewrite, no `.bak` churn. This also
@@ -0,0 +1,90 @@
1
+ import { Command } from 'commander';
2
+ import { type CommonOptions } from '../lib/client-factory.js';
3
+ import type { ProjectDeps } from './project.js';
4
+ /** One environment row as the facade returns it. Never carries a password. */
5
+ export interface CliProjectEnvironment {
6
+ id: string;
7
+ name: string;
8
+ /**
9
+ * The address runs against this environment open. May be a loopback URL for
10
+ * an app that only runs on your own machine — pair it with `--local`.
11
+ */
12
+ url: string;
13
+ isDefault: boolean;
14
+ /**
15
+ * How a run signs in: `account` (the stored test account), `otp` (a one-time
16
+ * code account), `manual` (a human-captured Google/SSO session, set up in the
17
+ * Portal) or `public` (no sign-in). Open string, rendered verbatim, so a mode
18
+ * added server-side shows up without a CLI release.
19
+ */
20
+ authMode: string;
21
+ /** Whether a test-account username/password is stored. The password is never returned. */
22
+ hasCredentials: boolean;
23
+ /** The test-account username this environment signs in with; `null` when none is stored. */
24
+ username: string | null;
25
+ enableOtp: boolean;
26
+ updatedAt: string;
27
+ }
28
+ export interface CliProjectEnvListResponse {
29
+ environments: CliProjectEnvironment[];
30
+ }
31
+ export interface CliProjectEnvCreateResponse {
32
+ environment: CliProjectEnvironment;
33
+ created: true;
34
+ }
35
+ export interface CliProjectEnvUpdateResponse {
36
+ environment: CliProjectEnvironment;
37
+ }
38
+ export interface CliProjectEnvDeleteResponse {
39
+ deleted: true;
40
+ name: string;
41
+ }
42
+ interface EnvListOptions extends CommonOptions {
43
+ projectId: string;
44
+ }
45
+ export declare function runEnvList(opts: EnvListOptions, deps?: ProjectDeps): Promise<CliProjectEnvListResponse>;
46
+ interface EnvCreateOptions extends CommonOptions {
47
+ projectId: string;
48
+ name?: string;
49
+ url?: string;
50
+ /** `--local <port>`: an app on this machine; builds the loopback URL and sends the marker. */
51
+ local?: string;
52
+ localHost?: string;
53
+ skipPreflight?: boolean;
54
+ username?: string;
55
+ password?: string;
56
+ passwordFile?: string;
57
+ setDefault?: boolean;
58
+ idempotencyKey?: string;
59
+ }
60
+ export declare function runEnvCreate(opts: EnvCreateOptions, deps?: ProjectDeps): Promise<CliProjectEnvCreateResponse>;
61
+ interface EnvUpdateOptions extends CommonOptions {
62
+ projectId: string;
63
+ name: string;
64
+ url?: string;
65
+ /** `--local <port>`: repoint at an app on this machine (see `runEnvCreate`). */
66
+ local?: string;
67
+ localHost?: string;
68
+ skipPreflight?: boolean;
69
+ username?: string;
70
+ password?: string;
71
+ passwordFile?: string;
72
+ rename?: string;
73
+ idempotencyKey?: string;
74
+ }
75
+ export declare function runEnvUpdate(opts: EnvUpdateOptions, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
76
+ interface EnvDeleteOptions extends CommonOptions {
77
+ projectId: string;
78
+ name: string;
79
+ confirm: boolean;
80
+ idempotencyKey?: string;
81
+ }
82
+ export declare function runEnvDelete(opts: EnvDeleteOptions, deps?: ProjectDeps): Promise<CliProjectEnvDeleteResponse>;
83
+ interface EnvSetDefaultOptions extends CommonOptions {
84
+ projectId: string;
85
+ name: string;
86
+ idempotencyKey?: string;
87
+ }
88
+ export declare function runEnvSetDefault(opts: EnvSetDefaultOptions, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
89
+ export declare function createProjectEnvCommand(deps?: ProjectDeps): Command;
90
+ export {};