@testsprite/testsprite-cli 0.12.0 → 0.14.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 (113) hide show
  1. package/README.md +59 -49
  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 +436 -5
  7. package/dist/commands/doctor.d.ts +2 -0
  8. package/dist/commands/doctor.js +34 -20
  9. package/dist/commands/init.js +14 -11
  10. package/dist/commands/project-env.d.ts +11 -1
  11. package/dist/commands/project-env.js +408 -70
  12. package/dist/commands/project-sign-in.d.ts +60 -0
  13. package/dist/commands/project-sign-in.js +289 -0
  14. package/dist/commands/project.d.ts +14 -5
  15. package/dist/commands/project.js +110 -70
  16. package/dist/commands/schedule.d.ts +14 -0
  17. package/dist/commands/schedule.js +193 -15
  18. package/dist/commands/test.d.ts +123 -44
  19. package/dist/commands/test.js +2993 -636
  20. package/dist/commands/testlist.d.ts +10 -5
  21. package/dist/commands/testlist.js +217 -47
  22. package/dist/commands/tunnel.d.ts +26 -3
  23. package/dist/commands/tunnel.js +221 -18
  24. package/dist/commands/usage.d.ts +3 -0
  25. package/dist/commands/usage.js +12 -5
  26. package/dist/index.js +39 -50
  27. package/dist/lib/agent-targets.d.ts +3 -3
  28. package/dist/lib/agent-targets.js +2 -2
  29. package/dist/lib/billing-refusal.d.ts +43 -0
  30. package/dist/lib/billing-refusal.js +171 -0
  31. package/dist/lib/bundle.d.ts +5 -0
  32. package/dist/lib/bundle.js +43 -13
  33. package/dist/lib/ci-linkage.d.ts +90 -0
  34. package/dist/lib/ci-linkage.js +181 -0
  35. package/dist/lib/client-factory.d.ts +16 -2
  36. package/dist/lib/client-factory.js +37 -6
  37. package/dist/lib/config.d.ts +17 -0
  38. package/dist/lib/config.js +20 -1
  39. package/dist/lib/conflict-reason.d.ts +27 -3
  40. package/dist/lib/conflict-reason.js +53 -4
  41. package/dist/lib/credentials.js +56 -14
  42. package/dist/lib/dry-run/samples.d.ts +13 -1
  43. package/dist/lib/dry-run/samples.js +104 -7
  44. package/dist/lib/environment-tunnel.d.ts +109 -0
  45. package/dist/lib/environment-tunnel.js +465 -0
  46. package/dist/lib/errors.d.ts +18 -11
  47. package/dist/lib/errors.js +123 -14
  48. package/dist/lib/failing-fe-resolver.d.ts +1 -1
  49. package/dist/lib/failing-fe-resolver.js +3 -3
  50. package/dist/lib/gh-output.d.ts +1 -0
  51. package/dist/lib/gh-output.js +16 -4
  52. package/dist/lib/history-retention.d.ts +8 -0
  53. package/dist/lib/history-retention.js +24 -0
  54. package/dist/lib/http.d.ts +39 -19
  55. package/dist/lib/http.js +46 -24
  56. package/dist/lib/interrupt.d.ts +21 -13
  57. package/dist/lib/interrupt.js +32 -21
  58. package/dist/lib/junit-report.d.ts +18 -4
  59. package/dist/lib/junit-report.js +23 -5
  60. package/dist/lib/local-target.d.ts +14 -4
  61. package/dist/lib/local-target.js +48 -13
  62. package/dist/lib/output.js +15 -1
  63. package/dist/lib/plan-poll.d.ts +11 -11
  64. package/dist/lib/plan-poll.js +15 -16
  65. package/dist/lib/plans.types.d.ts +9 -9
  66. package/dist/lib/plans.types.js +3 -3
  67. package/dist/lib/poll.d.ts +2 -2
  68. package/dist/lib/poll.js +9 -3
  69. package/dist/lib/redact.d.ts +38 -0
  70. package/dist/lib/redact.js +140 -0
  71. package/dist/lib/render-error.d.ts +21 -5
  72. package/dist/lib/render-error.js +44 -0
  73. package/dist/lib/response-schemas.d.ts +54 -12
  74. package/dist/lib/response-schemas.js +88 -7
  75. package/dist/lib/runs.types.d.ts +68 -11
  76. package/dist/lib/secret-file.js +72 -14
  77. package/dist/lib/skill-nudge.d.ts +6 -1
  78. package/dist/lib/skill-nudge.js +32 -5
  79. package/dist/lib/target-url-preflight.d.ts +6 -4
  80. package/dist/lib/target-url-preflight.js +64 -51
  81. package/dist/lib/target-url.js +11 -11
  82. package/dist/lib/telemetry.d.ts +10 -8
  83. package/dist/lib/telemetry.js +24 -17
  84. package/dist/lib/testlist.types.d.ts +1 -0
  85. package/dist/lib/ticker.d.ts +9 -0
  86. package/dist/lib/ticker.js +111 -4
  87. package/dist/lib/tunnel-session.d.ts +16 -4
  88. package/dist/lib/tunnel-session.js +7 -5
  89. package/dist/lib/tunnel.types.d.ts +12 -2
  90. package/dist/lib/tunnel.types.js +2 -2
  91. package/dist/lib/v3-advisory.js +0 -1
  92. package/dist/lib/wait-exit.d.ts +8 -0
  93. package/dist/lib/wait-exit.js +76 -4
  94. package/dist/lib/workspace-status.d.ts +23 -0
  95. package/dist/lib/workspace-status.js +15 -0
  96. package/dist/vendor/tunnel-client/client.d.ts +15 -8
  97. package/dist/vendor/tunnel-client/client.js +477 -407
  98. package/dist/vendor/tunnel-client/config.d.ts +5 -5
  99. package/dist/vendor/tunnel-client/config.js +5 -5
  100. package/dist/vendor/tunnel-client/index.d.ts +4 -4
  101. package/dist/vendor/tunnel-client/index.js +4 -4
  102. package/dist/vendor/tunnel-client/types.d.ts +19 -34
  103. package/dist/vendor/tunnel-client/types.js +1 -0
  104. package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
  105. package/dist/vendor/tunnel-client/ws-compat.js +70 -12
  106. package/dist/version-guard.d.ts +7 -1
  107. package/dist/version-guard.js +19 -1
  108. package/dist/version.d.ts +1 -1
  109. package/dist/version.js +1 -1
  110. package/package.json +4 -4
  111. package/skills/testsprite-onboard.skill.md +8 -8
  112. package/skills/testsprite-verify.codex.md +59 -57
  113. package/skills/testsprite-verify.skill.md +53 -38
package/README.md CHANGED
@@ -61,7 +61,7 @@ npm install -g @testsprite/testsprite-cli
61
61
  testsprite setup
62
62
  ```
63
63
 
64
- `testsprite setup` prompts for your [API key](https://www.testsprite.com), verifies it, and installs the verification-loop skill for the coding agents this project uses — one command, so your agent is wired to verify its own work.
64
+ `testsprite setup` prompts for your [API key](https://www.testsprite.com/dashboard/settings/apikey), verifies it, and installs the verification-loop skill for the coding agents this project uses — one command, so your agent is wired to verify its own work.
65
65
 
66
66
  **Which agent it installs for.** Each of the eight supported targets — `claude`, `cursor`, `cline`, `windsurf`, `antigravity`, `kiro`, `copilot`, `codex` — lands its skill in a different place, so `setup` works out which you use: the agent calling it, if it identifies itself, together with every agent whose config is already in the project. It installs for all of them and prints what it found — in a terminal it shows you that list first, so you can accept it or narrow it before anything is written. If nothing identifies an agent, it installs for `claude` and says so — that is the one case where you want `--agent <target>` to name one yourself. Check the result any time with `testsprite agent status`.
67
67
 
@@ -128,72 +128,82 @@ It only runs what the project is still missing, so a second call picks up where
128
128
 
129
129
  Prefer to configure each step by hand (or learn the surface offline with `--dry-run` first)? See [Manual setup](./DOCUMENTATION.md#manual-setup) and [Install & verify](./DOCUMENTATION.md#install--verify).
130
130
 
131
- ## Testing an app on your machine (--local)
131
+ ## Testing an environment on your machine
132
132
 
133
133
  Frontend tests can reach your running app through a TestSprite tunnel, including on the Free plan (ordinary run credits apply).
134
- Use an API key with `run:tunnel`: keys minted before that scope existed need to be replaced; the CLI names the missing scope.
134
+ Use an API key with `run:tunnel`; the CLI names the missing scope if the key cannot open a tunnel. Existing keys receive this scope on backend v0.18.0 or later unless deliberately narrowed.
135
135
 
136
136
  ```bash
137
137
  testsprite project create --type frontend --name "My local app" --local 3000
138
138
  testsprite test create --plan-from ./checkout.plan.json --project <project-id>
139
- testsprite test run <test-id> --local 3000 # per-run tunnel; waits up to 1200 seconds
139
+ testsprite test run <test-id> # the saved loopback URL opens a tunnel and waits
140
+ testsprite test run <id> <id> --max-concurrency 5
141
+ testsprite test run --all --project <project-id>
140
142
  # Or keep one tunnel open in terminal A (no port argument)
141
143
  testsprite tunnel start --ttl 3600
142
144
  # Terminal B: borrow the clientId printed above; keep terminal A running
143
- testsprite test run <test-id> --local 3000 --tunnel-client <client-uuid>
145
+ testsprite test run <test-id> --tunnel-client <client-uuid>
146
+ testsprite tunnel list
147
+ testsprite tunnel stop <client-uuid>
148
+ # Stop every live tunnel on this account only when you intend to revoke them all
149
+ testsprite tunnel stop --all --confirm
144
150
  ```
145
151
 
146
- Run one test per invocation; parallel invocations are fine (5 live tunnel bindings per user); `--all --local` is refused.
152
+ Run several local frontend tests in one invocation to share one tunnel binding. The batch runs up to 5 tests at once by default; `--max-concurrency` accepts 1–10. `--all --local` skips backend tests. An owned batch cancels unfinished runs on Ctrl-C or tunnel loss; JSON output lists every requested test in input order, including tests that did not start. The minted client id is printed before the tunnel connects.
153
+ Hit the tunnel limit? Run `testsprite tunnel list`, then `testsprite tunnel stop <client-uuid>` for an unused binding, or `testsprite tunnel stop --all --confirm` to revoke them all. An older server without listing returns exit 4; a key without `run:tunnel` returns exit 3.
147
154
  A second `tunnel start` or process using the same credential takes over, and the first exits **10**.
148
- The examples use `127.0.0.1`. For another loopback listener, pass the same `--local-host localhost` or `--local-host ::1` to project creation and every follow-up run. The selected host is stored in the project URL (`::1` becomes `http://[::1]:<port>`); `project get/list` exposes `originMode: 'local'` in JSON and shows `(Local)` in text output.
155
+ An environment is one origin (scheme, host and port) plus its sign-in configuration. Frontend runs automatically open a tunnel for a saved `localhost`, `127.0.0.1` or `[::1]` URL: `test run`, `test rerun`, `test create --run`, `test create-batch --run` and `testlist run` use this behavior. `--env <name>` selects the environment; omit it for the project default. `--no-wait` disables automatic tunnels; drop it to run through one. If environment reads are unavailable, the command keeps the previous server behavior. Several fresh-run IDs require a tunnel; public targets retain the exit-5 refusal. A named public environment used against a local origin prints a sign-in advisory on stderr. Reruns and test-list runs share one timeout including capacity waits and require the server to confirm tunnel support; an older server triggers a cancellation attempt and a clear error.
156
+
157
+ `--local <port>` remains a shorthand and defaults new project/environment URLs to `http://localhost:<port>`. On a test run it preserves the host of a selected loopback environment, or the one host agreed by saved non-temporary loopback environments on that port; otherwise it uses `localhost`. If environment reads fail, it retains the legacy `127.0.0.1` host. Saved URLs retain their exact spelling, and aliases are not merged. `--local-host` remains accepted but is deprecated and hidden from project/environment help; prefer `--url http://127.0.0.1:<port>` or `--url http://[::1]:<port>` when the host matters. Dev servers can take a minute per page through a tunnel; test a built server with `npm run build` and your framework's preview/start command for heavy apps.
149
158
  The control plane is WebSocket over TLS (`wss://control.tun.testsprite.com/ws`). The data plane, which carries the tunnel secret and proxied traffic, uses TLS at `data.tun.testsprite.com:443` and verifies the certificate with Node's default trust store: its bundled Mozilla roots, plus certificates supplied through `NODE_EXTRA_CA_CERTS` and the system CAs when Node is started with `--use-system-ca`. Node 20 is supported without losing `NODE_EXTRA_CA_CERTS`. Verification cannot be disabled, and the CLI never falls back from TLS to plaintext. On a network that re-signs TLS, export your organisation's root CA to a PEM file and set `NODE_EXTRA_CA_CERTS=/path/to/ca.pem` before running `testsprite`. Plaintext connects and TLS handshakes each time out after 10 seconds. The first failed attempt starts a **60-second** retry episode; writing `TunnelHello` is not enough to reset it. The episode ends only after the first inbound tunnel stream or after the socket remains open for 5 seconds following the hello. A real deadline timer stays armed across retries and destroys an in-flight socket when it expires. After that, an owned `test run --local` run is cancelled and refunded and the command exits **10**; `tunnel start` exits **10**. If a self-hosted or older TestSprite server does not advertise a TLS endpoint, the CLI prints a one-time warning and uses legacy plaintext port **7400** under the same timeout and retry rules. `tunnel start` prints `transport: tls` or `transport: plaintext`.
150
- An owned tunnel's timeout or Ctrl-C cancels the run by default. A borrowed run still detaches without cancellation on Ctrl-C/SIGTERM because its owner keeps the tunnel alive; if that owner disappears while the run is active, the borrower cancels its own run and reports `cancelled`, `already finished`, or `skipped`. A run cancelled before it finishes is refunded. `--no-cancel-on-interrupt` also skips this owner-gone cancellation. Keep the early `Run <runId>` receipt on stderr and read the reported run before re-running.
159
+ An owned tunnel's timeout or Ctrl-C cancels unfinished runs by default. A borrowed run still detaches without cancellation on Ctrl-C/SIGTERM because its owner keeps the tunnel alive; if that owner disappears while a run is active, the borrower cancels its own run and reports `cancelled`, `already finished`, or `skipped`. A run cancelled before it finishes is refunded. `--no-cancel-on-interrupt` also skips this owner-gone cancellation. Keep the early stderr run-id receipts (`Run <runId>` for one test, `[i/N] <testId> → run <runId>` for a batch) and read the reported runs before re-running.
151
160
  Local projects skip exploration/plan generation; author plans with `test create --plan-from`. Portal runs are blocked for free until you set a public project URL.
152
161
  See [the full local-testing reference](./DOCUMENTATION.md#local-frontend-testing-and-tunnels) for flags, login, billing/refunds, timeouts, and retargeting.
153
162
 
154
163
  ## Commands
155
164
 
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` |
165
+ | Group | Command | What it does |
166
+ | -------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
167
+ | **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
168
+ | | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
169
+ | **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
170
+ | | `auth remove` | Remove the active profile from the credentials file |
171
+ | | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
172
+ | **Read** | `project list` / `project get` | List projects / fetch one by id, including the default environment and environment count when the server reports them |
173
+ | | `test list` / `test get` | List tests under a project / fetch one by id; `test list --env <name>` selects frontend status and the ENV column names its source |
174
+ | | `test code get` | Print (or write) the generated test source |
175
+ | | `test steps` | List the latest run's steps with screenshot / DOM pointers |
176
+ | | `test result` | Latest result; `--history` lists a test's prior runs (ENV column; `--env <name>` filters by environment) |
177
+ | | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
178
+ | | `test failure summary` | One-screen triage card (no media download) |
179
+ | | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
180
+ | **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
181
+ | | `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 |
182
+ | | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
183
+ | | `test code put` | Replace generated code (etag-guarded) |
184
+ | | `test plan put` | Replace a frontend test's plan-steps |
185
+ | | `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) |
186
+ | | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
187
+ | | `project env list` / `get` / `create` / `update` / `delete` / `set-default` | Manage a project's named URL + login bundles. `get` shows safe login details and variables; `create` / `update` accept repeatable `--var KEY=VALUE` (plain text — not for secrets, use `--username`/`--password`), and `update --clear-credentials` disables account login. Use `--url http://localhost:<port>` or `--local <port>` for an app on this machine; runs open its tunnel automatically. `delete` refuses the default environment. |
188
+ | | `project sign-in get` / `set` | Inspect or change an environment's app sign-in mode; choose OTP with `project env create --sign-in otp`. SSO selection requires the per-account manual-login feature flag; capture the session in the Portal. |
189
+ | **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 |
190
+ | | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
191
+ | | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
192
+ | **Run** | `test run` | Trigger a fresh run; saved loopback environments open a tunnel and wait automatically; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order `--env <name>` runs against a named environment. |
193
+ | | `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; loopback URLs open a tunnel automatically when the server supports it. |
194
+ | | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
195
+ | | `test wait` | Block on one or more `runId`s until terminal |
196
+ | | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches, `cancel` is the real stop — except a run with an owned tunnel, which Ctrl-C cancels by default) |
197
+ | | `test artifact get` | Download the failure bundle for a specific `runId` |
198
+ | **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
199
+ | | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
200
+ | | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; loopback environments open a tunnel automatically; `--wait` polls all runs, `--report junit` writes a CI sidecar |
201
+ | **Schedule** | `schedule list` / `schedule get` | List schedules visible to the key / fetch one by id, including a project schedule's pinned or inherited environment (status is `ENABLED`, `PAUSED`, or `AUTO_PAUSED` after repeated failures) |
202
+ | | `schedule create` | Run a project or test list on a 5-field cron; `--env <name>` pins a project schedule, while omission inherits the live default; states frequency and estimated cost |
203
+ | | `schedule update` | Retime or rename a schedule, change recipients, pin a project schedule with `--env <name>`, or `--pause` / `--resume` it |
204
+ | | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
205
+ | | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
206
+ | **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` |
197
207
 
198
208
  > 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).
199
209
 
@@ -1,6 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'node:fs/promises';
3
3
  import { Command } from 'commander';
4
+ import { resolveProfileName } from '../lib/config.js';
4
5
  import { CLIError, localValidationError } from '../lib/errors.js';
5
6
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
6
7
  import { promptText } from '../lib/prompt.js';
@@ -215,7 +216,7 @@ function composeManagedFile(state, section) {
215
216
  }
216
217
  /**
217
218
  * Actions that mean bytes actually changed on disk — the trigger set for the
218
- * post-install reload hint (DEV-279). Covers both write modes: own-file
219
+ * post-install reload hint. Covers both write modes: own-file
219
220
  * (`written`/`updated`) and codex managed-section (`section-*`).
220
221
  */
221
222
  const CHANGED_ACTIONS = new Set([
@@ -231,7 +232,7 @@ const CHANGED_ACTIONS = new Set([
231
232
  * Per-invocation cache in front of {@link ownFileBodyFor}, so each (target, skill)
232
233
  * pair reads its asset once. `agent install` (which stamps the body's hash into the
233
234
  * marker) and `agent status` (which re-derives it) share this rather than keeping
234
- * private copies — they didn't, hence DEV-672.
235
+ * private copies that could silently disagree.
235
236
  */
236
237
  function makeOwnFileBodyResolver() {
237
238
  // Keyed on the pair: the same skill resolves to different bytes per target.
@@ -387,9 +388,9 @@ export async function runInstall(opts, deps = {}) {
387
388
  }
388
389
  // We DO read the existing file (if present) to compute the
389
390
  // would-be byte count and emit the 32 KiB budget warning — without
390
- // this the warning was silently absent on --dry-run runs (Fix 4).
391
+ // this the warning was silently absent on --dry-run runs.
391
392
  //
392
- // [P3 round-2] Measure the ACTUAL composed result via the same
393
+ // Measure the ACTUAL composed result via the same
393
394
  // classifySection + composeManagedFile pipeline the real install
394
395
  // uses — `existing + section` double-counts the old block on the
395
396
  // replace path and misses the append separator. Read failures other
@@ -605,7 +606,7 @@ export async function runInstall(opts, deps = {}) {
605
606
  const items = data;
606
607
  return items.map(r => `${r.target.padEnd(12)} ${r.action.padEnd(12)} ${r.path}`).join('\n');
607
608
  });
608
- // 8b. Reload hint (DEV-279). A coding agent reads its skill/rule files at
609
+ // 8b. Reload hint. A coding agent reads its skill/rule files at
609
610
  // session start, so a session already open when we wrote the file won't pick
610
611
  // it up. Fire only when something actually changed on disk — silent on
611
612
  // skipped/unchanged/blocked/dry-run and in --output json. Targets are
@@ -627,7 +628,7 @@ export async function runInstall(opts, deps = {}) {
627
628
  * Display name for the AGENT column. Experimental targets get an "(exp.)" tag so
628
629
  * support maturity stays visible without a dedicated STATUS column — a bare
629
630
  * `ga`/`experimental` column reads like install state, which is `agent status`'s
630
- * job, not this catalog's (DEV-279).
631
+ * job, not this catalog's.
631
632
  */
632
633
  function agentDisplayName(target, status) {
633
634
  return status === 'experimental' ? `${target} (exp.)` : target;
@@ -655,7 +656,7 @@ export async function runList(opts, deps = {}) {
655
656
  // (with an "(exp.)" maturity tag), the skill, and where it lands. STATUS and
656
657
  // MODE stay in the JSON shape for back-compat but are dropped from the human
657
658
  // table — MODE is an internal write strategy, and STATUS (ga/experimental)
658
- // reads like install state, which lives in `agent status` (DEV-279).
659
+ // reads like install state, which lives in `agent status`.
659
660
  out.print(results, data => {
660
661
  const items = data;
661
662
  const header = `${'AGENT'.padEnd(20)} ${'SKILL'.padEnd(20)} PATH`;
@@ -674,8 +675,9 @@ export async function runList(opts, deps = {}) {
674
675
  * comparison for own-file targets.
675
676
  *
676
677
  * `canonicalBody` is already bound to THIS target by the caller and takes no
677
- * arguments, so the per-skill-only lookup that caused DEV-672 cannot be expressed
678
- * here. It is called only once an artifact is known to exist and carry a marker,
678
+ * arguments, so a lookup keyed on skill alone — which let install and status
679
+ * resolve different bodies for the same target — cannot be expressed here. It
680
+ * is called only once an artifact is known to exist and carry a marker,
679
681
  * so a row with nothing installed never touches the skill assets.
680
682
  */
681
683
  async function classifyOwnFileState(agentFs, abs, target, skill, canonicalBody) {
@@ -773,7 +775,8 @@ export async function runStatus(opts, deps = {}) {
773
775
  }
774
776
  const dir = opts.dir !== undefined ? opts.dir.trim() : (deps.cwd ?? process.cwd());
775
777
  const root = path.resolve(dir);
776
- // The SAME resolver the installer stamps its marker hashes from (DEV-672).
778
+ // The SAME resolver the installer stamps its marker hashes from — a
779
+ // separate copy here is exactly how install and status end up disagreeing.
777
780
  const ownFileBodyFor = makeOwnFileBodyResolver();
778
781
  const results = [];
779
782
  for (const [target, spec] of Object.entries(TARGETS)) {
@@ -792,7 +795,7 @@ export async function runStatus(opts, deps = {}) {
792
795
  path: relPath,
793
796
  state: await classifyOwnFileState(agentFs, path.resolve(root, relPath), target, skill,
794
797
  // Deferred, not resolved here: an absent artifact must not need the
795
- // skill assets at all, as it didn't before DEV-672.
798
+ // skill assets at all.
796
799
  () => ownFileBodyFor(target, skill)),
797
800
  });
798
801
  }
@@ -865,10 +868,10 @@ export function createAgentCommand(deps = {}) {
865
868
  // ---------------------------------------------------------------------------
866
869
  // Per-file helpers (per convention: copy from auth.ts)
867
870
  // ---------------------------------------------------------------------------
868
- function resolveCommonOptions(command) {
871
+ function resolveCommonOptions(command, env) {
869
872
  const globals = command.optsWithGlobals();
870
873
  return {
871
- profile: globals.profile ?? 'default',
874
+ profile: resolveProfileName(globals.profile, env),
872
875
  output: resolveOutputMode(globals.output),
873
876
  endpointUrl: globals.endpointUrl,
874
877
  debug: globals.debug ?? false,
@@ -1,6 +1,9 @@
1
1
  import { Command } from 'commander';
2
+ import { type WorkspaceStatus } from '../lib/workspace-status.js';
2
3
  import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
4
+ import { ApiError } from '../lib/errors.js';
3
5
  import type { FetchImpl } from '../lib/http.js';
6
+ import { type ShutdownHandle } from '../lib/interrupt.js';
4
7
  import type { CliOrgBinding, CliOrgSummary } from '../lib/org-render.js';
5
8
  export interface MeResponse {
6
9
  userId: string;
@@ -41,6 +44,8 @@ export interface MeResponse {
41
44
  remaining: number;
42
45
  includedCredits: number;
43
46
  seats: number;
47
+ /** Billing standing (paused / pending / ok). Absent on an older backend. */
48
+ workspace?: WorkspaceStatus;
44
49
  };
45
50
  /**
46
51
  * Every organization the underlying user belongs to (account-wide
@@ -60,9 +65,13 @@ export interface AuthDeps {
60
65
  env?: NodeJS.ProcessEnv;
61
66
  credentialsPath?: string;
62
67
  fetchImpl?: FetchImpl;
68
+ shutdownSignal?: AbortSignal;
69
+ shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
63
70
  prompt?: {
64
71
  secret: (question: string) => Promise<string>;
65
72
  };
73
+ /** Setup passes a supplied --api-key through a synthetic prompt. */
74
+ suppliedApiKey?: boolean;
66
75
  stdout?: (line: string) => void;
67
76
  stderr?: (line: string) => void;
68
77
  preludeWrite?: (chunk: string) => void;
@@ -92,6 +101,16 @@ interface ConfigureOptions extends CommonOptions {
92
101
  */
93
102
  skipIfConfigured?: boolean;
94
103
  }
104
+ /**
105
+ * Exit-5 error for "no key arrived" on any path: the interactive prompt,
106
+ * `--from-env`, and non-interactive setup. The hint is appended to the message
107
+ * and to `nextAction`; a path-specific `nextAction` lead-in and `details` are
108
+ * kept so callers lose nothing by routing through here.
109
+ */
110
+ export declare function missingApiKeyError(message: string, apiUrl: string, opts?: {
111
+ nextAction?: string;
112
+ details?: Record<string, unknown>;
113
+ }): ApiError;
95
114
  export interface ConfigureResult {
96
115
  persisted: boolean;
97
116
  source: 'env' | 'prompt' | 'profile' | 'dry-run';
@@ -1,17 +1,49 @@
1
1
  import { Command } from 'commander';
2
+ import { formatWorkspaceStatus } from '../lib/workspace-status.js';
2
3
  import { assertValidApiKey, assertValidEndpointUrl, emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
3
- import { ApiError, CLIError } from '../lib/errors.js';
4
- import { facadeBaseUrl } from '../lib/facade.js';
4
+ import { ApiError, CLIError, InterruptError } from '../lib/errors.js';
5
+ import { facadeBaseUrl, resolvePortalBase } from '../lib/facade.js';
5
6
  import { HttpClient } from '../lib/http.js';
7
+ import { globalShutdown } from '../lib/interrupt.js';
6
8
  import { defaultCredentialsPath, deleteProfile, isCredentialsWritePermissionError, readProfile, writeProfile, } from '../lib/credentials.js';
7
- import { loadConfig, normalizeEnvVar } from '../lib/config.js';
9
+ import { loadConfig, normalizeEnvVar, resolveProfileName } from '../lib/config.js';
8
10
  import { emitDeprecationNotice } from '../lib/deprecate.js';
9
11
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
10
12
  import { promptSecret } from '../lib/prompt.js';
13
+ import { ME_RESPONSE_SCHEMA } from '../lib/response-schemas.js';
11
14
  import { formatOrgBinding, formatOrgsSummary, formatPersonalScopeHint } from '../lib/org-render.js';
12
15
  import { emitV3RoutingAdvisory, routingLabel } from '../lib/v3-advisory.js';
13
16
  const DEFAULT_API_URL = 'https://api.testsprite.com';
14
17
  const FROM_ENV_MISSING_KEY = 'TESTSPRITE_API_KEY is not set in the environment. Set it and re-run with --from-env, or omit --from-env to enter the key interactively.';
18
+ const API_KEY_PAGE_PATH = '/dashboard/settings/apikey';
19
+ /**
20
+ * Where a key comes from. Names the Portal origin that matches the API
21
+ * endpoint; for an endpoint the host map does not know, names the page by
22
+ * path only. `resolvePortalBase` returns undefined there on purpose — a
23
+ * confident link to the wrong environment's portal is worse than no origin.
24
+ */
25
+ function apiKeyHint(apiUrl) {
26
+ const portalBase = resolvePortalBase(apiUrl);
27
+ return portalBase === undefined
28
+ ? `Create or copy an API key on your TestSprite dashboard's API-keys page (${API_KEY_PAGE_PATH}).`
29
+ : `Create or copy an API key at ${portalBase}${API_KEY_PAGE_PATH}`;
30
+ }
31
+ /**
32
+ * Exit-5 error for "no key arrived" on any path: the interactive prompt,
33
+ * `--from-env`, and non-interactive setup. The hint is appended to the message
34
+ * and to `nextAction`; a path-specific `nextAction` lead-in and `details` are
35
+ * kept so callers lose nothing by routing through here.
36
+ */
37
+ export function missingApiKeyError(message, apiUrl, opts = {}) {
38
+ const hint = apiKeyHint(apiUrl);
39
+ return new ApiError({
40
+ code: 'VALIDATION_ERROR',
41
+ message: `${message} ${hint}`,
42
+ nextAction: opts.nextAction === undefined ? hint : `${opts.nextAction} ${hint}`,
43
+ requestId: 'local',
44
+ details: opts.details ?? {},
45
+ });
46
+ }
15
47
  export async function runConfigure(opts, deps = {}) {
16
48
  const env = deps.env ?? process.env;
17
49
  const credentialsPath = deps.credentialsPath ?? defaultCredentialsPath();
@@ -58,8 +90,12 @@ export async function runConfigure(opts, deps = {}) {
58
90
  assertValidEndpointUrl(apiUrl);
59
91
  if (opts.fromEnv) {
60
92
  apiKey = env.TESTSPRITE_API_KEY?.trim();
61
- if (!apiKey)
62
- throw validationError('TESTSPRITE_API_KEY', FROM_ENV_MISSING_KEY);
93
+ if (!apiKey) {
94
+ throw missingApiKeyError(FROM_ENV_MISSING_KEY, apiUrl, {
95
+ nextAction: 'Set TESTSPRITE_API_KEY and re-run.',
96
+ details: { field: 'TESTSPRITE_API_KEY', reason: 'missing' },
97
+ });
98
+ }
63
99
  }
64
100
  else {
65
101
  // --skip-if-configured: when a non-empty API key is already saved for
@@ -78,9 +114,11 @@ export async function runConfigure(opts, deps = {}) {
78
114
  const promptApi = deps.prompt ?? { secret: (q) => promptSecret(q) };
79
115
  prelude(`Configuring profile "${opts.profile}".\n`);
80
116
  // Only the API key is prompted -- the endpoint defaults to prod (see above).
117
+ if (!deps.suppliedApiKey)
118
+ stderr(apiKeyHint(apiUrl));
81
119
  apiKey = (await promptApi.secret('TestSprite API key: ')).trim();
82
120
  if (!apiKey)
83
- throw new CLIError('No API key provided.', 5);
121
+ throw missingApiKeyError('No API key provided.', apiUrl);
84
122
  }
85
123
  // Advisory: when the endpoint was silently inherited from an existing profile
86
124
  // (not an explicit flag/env), surface it before validating the key against it
@@ -103,6 +141,8 @@ export async function runConfigure(opts, deps = {}) {
103
141
  apiKey,
104
142
  fetchImpl: deps.fetchImpl,
105
143
  requestTimeoutMs: opts.requestTimeoutMs,
144
+ shutdownSignal: deps.shutdownSignal ?? globalShutdown.signal,
145
+ shutdown: deps.shutdown ?? globalShutdown,
106
146
  });
107
147
  try {
108
148
  // Tag the validation call with the originating command (when provided) so
@@ -112,6 +152,8 @@ export async function runConfigure(opts, deps = {}) {
112
152
  await pingClient.get('/me', deps.commandTag ? { headers: { 'x-cli-command': deps.commandTag } } : {});
113
153
  }
114
154
  catch (err) {
155
+ if (err instanceof InterruptError)
156
+ throw err;
115
157
  const message = err instanceof Error ? err.message : String(err);
116
158
  stderr(`API key rejected by ${apiUrl}: ${message} — profile NOT updated`);
117
159
  // When the verification call returned a typed API error (AUTH_INVALID,
@@ -181,7 +223,7 @@ export async function runWhoami(opts, deps = {}) {
181
223
  fetchImpl: deps.fetchImpl,
182
224
  stderr: deps.stderr,
183
225
  });
184
- const me = await client.get('/me');
226
+ const me = await client.get('/me', { schema: ME_RESPONSE_SCHEMA });
185
227
  out.print(me, data => {
186
228
  const m = data;
187
229
  const lines = [
@@ -202,6 +244,11 @@ export async function runWhoami(opts, deps = {}) {
202
244
  ...(m.v3Enabled === true && m.activeOrg
203
245
  ? [`org: ${m.activeOrg.name} (${m.activeOrg.plan}, ${m.activeOrg.role})`]
204
246
  : []),
247
+ // A paused (or payment-pending) workspace refuses every write, so say so
248
+ // next to the org it applies to instead of letting the next command find out.
249
+ ...(m.v3Enabled === true && formatWorkspaceStatus(m.activeOrg?.workspace)
250
+ ? [`workspace: ${formatWorkspaceStatus(m.activeOrg?.workspace)}`]
251
+ : []),
205
252
  // Authoritative routing mode, rendered only when the backend supplies it.
206
253
  ...(m.v3Enabled !== undefined ? [`routing: ${routingLabel(m.v3Enabled)}`] : []),
207
254
  // Org attribution — account-wide membership list, rendered only when
@@ -262,7 +309,7 @@ export function createAuthCommand(deps = {}) {
262
309
  .description('Show the user, API key, env, and scopes bound to the active profile')
263
310
  .addHelpText('after', GLOBAL_OPTS_HINT)
264
311
  .action(async (_cmdOpts, command) => {
265
- await runWhoami(resolveCommonOptions(command), deps);
312
+ await runWhoami(resolveCommonOptions(command, deps.env), deps);
266
313
  });
267
314
  // `whoami` — hidden, deprecated alias for `status` (kept so scripts/agents
268
315
  // on the old name keep working; invisible to --help).
@@ -271,14 +318,14 @@ export function createAuthCommand(deps = {}) {
271
318
  .addHelpText('after', GLOBAL_OPTS_HINT)
272
319
  .action(async (_cmdOpts, command) => {
273
320
  emitDeprecationNotice('auth whoami', 'auth status', deps.stderr);
274
- await runWhoami(resolveCommonOptions(command), deps);
321
+ await runWhoami(resolveCommonOptions(command, deps.env), deps);
275
322
  });
276
323
  auth
277
324
  .command('remove')
278
325
  .description('Remove credentials for the active profile')
279
326
  .addHelpText('after', GLOBAL_OPTS_HINT)
280
327
  .action(async (_cmdOpts, command) => {
281
- await runLogout(resolveCommonOptions(command), deps);
328
+ await runLogout(resolveCommonOptions(command, deps.env), deps);
282
329
  });
283
330
  // `logout` — hidden, deprecated alias for `remove`.
284
331
  auth
@@ -286,14 +333,14 @@ export function createAuthCommand(deps = {}) {
286
333
  .addHelpText('after', GLOBAL_OPTS_HINT)
287
334
  .action(async (_cmdOpts, command) => {
288
335
  emitDeprecationNotice('auth logout', 'auth remove', deps.stderr);
289
- await runLogout(resolveCommonOptions(command), deps);
336
+ await runLogout(resolveCommonOptions(command, deps.env), deps);
290
337
  });
291
338
  return auth;
292
339
  }
293
- function resolveCommonOptions(command) {
340
+ function resolveCommonOptions(command, env) {
294
341
  const globals = command.optsWithGlobals();
295
342
  return {
296
- profile: globals.profile ?? 'default',
343
+ profile: resolveProfileName(globals.profile, env),
297
344
  output: resolveOutputMode(globals.output),
298
345
  endpointUrl: globals.endpointUrl,
299
346
  debug: globals.debug ?? false,
@@ -305,15 +352,4 @@ function resolveCommonOptions(command) {
305
352
  function makeOutput(mode, deps) {
306
353
  return new Output(mode, { stdout: deps.stdout, stderr: deps.stderr });
307
354
  }
308
- function validationError(field, message) {
309
- return ApiError.fromEnvelope({
310
- error: {
311
- code: 'VALIDATION_ERROR',
312
- message,
313
- nextAction: `Set ${field} and re-run.`,
314
- requestId: 'local',
315
- details: { field, reason: 'missing' },
316
- },
317
- });
318
- }
319
355
  //# sourceMappingURL=auth.js.map