@testsprite/testsprite-cli 0.13.0 → 0.15.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 (81) hide show
  1. package/README.md +54 -49
  2. package/dist/commands/ci.d.ts +66 -17
  3. package/dist/commands/ci.js +466 -104
  4. package/dist/commands/doctor.d.ts +3 -0
  5. package/dist/commands/doctor.js +62 -20
  6. package/dist/commands/init.js +17 -3
  7. package/dist/commands/project-env.d.ts +11 -1
  8. package/dist/commands/project-env.js +399 -61
  9. package/dist/commands/project-sign-in.d.ts +60 -0
  10. package/dist/commands/project-sign-in.js +289 -0
  11. package/dist/commands/project.d.ts +9 -0
  12. package/dist/commands/project.js +82 -28
  13. package/dist/commands/schedule.d.ts +12 -0
  14. package/dist/commands/schedule.js +175 -5
  15. package/dist/commands/test.d.ts +126 -30
  16. package/dist/commands/test.js +1928 -447
  17. package/dist/commands/testlist.d.ts +10 -5
  18. package/dist/commands/testlist.js +170 -30
  19. package/dist/commands/tunnel.js +11 -5
  20. package/dist/index.js +17 -38
  21. package/dist/lib/agent-targets.d.ts +8 -3
  22. package/dist/lib/agent-targets.js +15 -4
  23. package/dist/lib/ci-run.d.ts +11 -0
  24. package/dist/lib/ci-run.js +34 -0
  25. package/dist/lib/client-factory.d.ts +35 -1
  26. package/dist/lib/client-factory.js +21 -10
  27. package/dist/lib/config.d.ts +1 -0
  28. package/dist/lib/config.js +1 -1
  29. package/dist/lib/credentials.d.ts +0 -1
  30. package/dist/lib/credentials.js +51 -14
  31. package/dist/lib/dry-run/samples.js +95 -1
  32. package/dist/lib/environment-tunnel.d.ts +109 -0
  33. package/dist/lib/environment-tunnel.js +465 -0
  34. package/dist/lib/errors.js +12 -1
  35. package/dist/lib/first-suite-hint.d.ts +55 -0
  36. package/dist/lib/first-suite-hint.js +101 -0
  37. package/dist/lib/gh-output.d.ts +62 -4
  38. package/dist/lib/gh-output.js +152 -7
  39. package/dist/lib/github-context.d.ts +21 -0
  40. package/dist/lib/github-context.js +153 -0
  41. package/dist/lib/http.d.ts +12 -1
  42. package/dist/lib/http.js +9 -1
  43. package/dist/lib/junit-report.d.ts +11 -7
  44. package/dist/lib/junit-report.js +13 -7
  45. package/dist/lib/local-target.d.ts +13 -3
  46. package/dist/lib/local-target.js +47 -12
  47. package/dist/lib/output.js +15 -1
  48. package/dist/lib/plan-poll.js +3 -4
  49. package/dist/lib/plans.types.d.ts +1 -1
  50. package/dist/lib/redact.d.ts +38 -0
  51. package/dist/lib/redact.js +140 -0
  52. package/dist/lib/render-error.d.ts +19 -5
  53. package/dist/lib/render-error.js +31 -0
  54. package/dist/lib/response-schemas.d.ts +5 -1
  55. package/dist/lib/response-schemas.js +54 -0
  56. package/dist/lib/runs.types.d.ts +115 -1
  57. package/dist/lib/target-url.js +5 -5
  58. package/dist/lib/telemetry.d.ts +31 -8
  59. package/dist/lib/telemetry.js +55 -7
  60. package/dist/lib/testlist.types.d.ts +1 -0
  61. package/dist/lib/ticker.d.ts +9 -0
  62. package/dist/lib/ticker.js +18 -0
  63. package/dist/lib/tunnel-session.d.ts +3 -4
  64. package/dist/lib/tunnel-session.js +3 -4
  65. package/dist/lib/v3-advisory.js +0 -1
  66. package/dist/vendor/tunnel-client/client.d.ts +15 -8
  67. package/dist/vendor/tunnel-client/client.js +477 -407
  68. package/dist/vendor/tunnel-client/config.d.ts +5 -5
  69. package/dist/vendor/tunnel-client/config.js +5 -5
  70. package/dist/vendor/tunnel-client/index.d.ts +4 -4
  71. package/dist/vendor/tunnel-client/index.js +4 -4
  72. package/dist/vendor/tunnel-client/types.d.ts +19 -34
  73. package/dist/vendor/tunnel-client/types.js +1 -0
  74. package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
  75. package/dist/vendor/tunnel-client/ws-compat.js +70 -12
  76. package/dist/version.d.ts +1 -1
  77. package/dist/version.js +1 -1
  78. package/package.json +1 -1
  79. package/schemas/plan.schema.json +2 -2
  80. package/skills/testsprite-ci.skill.md +154 -0
  81. package/skills/testsprite-onboard.skill.md +4 -4
package/README.md CHANGED
@@ -128,21 +128,21 @@ 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 # waits up to 1200 seconds
140
- testsprite test run <id> <id> --local 3000 --max-concurrency 5
141
- testsprite test run --all --project <project-id> --local 3000
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>
142
142
  # Or keep one tunnel open in terminal A (no port argument)
143
143
  testsprite tunnel start --ttl 3600
144
144
  # Terminal B: borrow the clientId printed above; keep terminal A running
145
- testsprite test run <test-id> --local 3000 --tunnel-client <client-uuid>
145
+ testsprite test run <test-id> --tunnel-client <client-uuid>
146
146
  testsprite tunnel list
147
147
  testsprite tunnel stop <client-uuid>
148
148
  # Stop every live tunnel on this account only when you intend to revoke them all
@@ -152,7 +152,9 @@ testsprite tunnel stop --all --confirm
152
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
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.
154
154
  A second `tunnel start` or process using the same credential takes over, and the first exits **10**.
155
- 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.
156
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`.
157
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.
158
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.
@@ -160,47 +162,50 @@ See [the full local-testing reference](./DOCUMENTATION.md#local-frontend-testing
160
162
 
161
163
  ## Commands
162
164
 
163
- | Group | Command | What it does |
164
- | -------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
165
- | **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
166
- | | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
167
- | **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
168
- | | `auth remove` | Remove the active profile from the credentials file |
169
- | | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
170
- | **Read** | `project list` / `project get` | List projects / fetch one by id |
171
- | | `test list` / `test get` | List tests under a project / fetch one by id |
172
- | | `test code get` | Print (or write) the generated test source |
173
- | | `test steps` | List the latest run's steps with screenshot / DOM pointers |
174
- | | `test result` | Latest result; `--history` lists a test's prior runs (ENV column; `--env <name>` filters by environment) |
175
- | | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
176
- | | `test failure summary` | One-screen triage card (no media download) |
177
- | | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
178
- | **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
179
- | | `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 |
180
- | | `test update` / `test delete` / `test delete-batch` | Edit metadata, set/clear the step timeout (`--step-timeout` / `--clear-step-timeout`), or permanently delete (`--confirm` required) |
181
- | | `test code put` | Replace generated code (etag-guarded) |
182
- | | `test plan put` | Replace a frontend test's plan-steps |
183
- | | `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) |
184
- | | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
185
- | | `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 |
186
- | **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 |
187
- | | `test plan accept` | Turn staged proposals into real tests — all of them, or a subset with `--only` |
188
- | | `project docs upload` | Upload an API spec or PRD as a project source, so generation has something to read |
189
- | **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. |
190
- | | `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. |
191
- | | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
192
- | | `test wait` | Block on one or more `runId`s until terminal |
193
- | | `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) |
194
- | | `test artifact get` | Download the failure bundle for a specific `runId` |
195
- | **Test lists** | `testlist list` / `testlist get` | Inspect saved test lists — named, cross-project collections with per-project environment pins (V3-only) |
196
- | | `testlist create` / `update` / `add` / `remove` / `delete` | Manage a list and its cases; `--project-env <id>:<env>` pins environments; `delete` requires `--confirm` |
197
- | | `testlist run` | Run every case (or a `--case` subset) through its pinned environment; `--wait` polls all runs, `--report junit` writes a CI sidecar |
198
- | **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) |
199
- | | `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 |
200
- | | `schedule update` | Retime or rename a schedule, change its recipients, `--pause` / `--resume` it |
201
- | | `schedule delete` | Remove a schedule and its run history, stopping future triggers (`--confirm` required, no restore window) |
202
- | | `schedule run list` | A schedule's past runs, with per-run pass / fail / blocked counts |
203
- | **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
+ | **CI** | `ci init github` | Write a GitHub Actions PR gate that runs `ci run` against each pull request's preview deployment — one placeholder step to fill in: your platform deploys every PR (`on: deployment_status`) or the workflow deploys |
207
+ | | `ci run` | The CI gate in one command: every project test (or `--filter`) against `--target-url`, signed in as `--env`, in a temporary `github-pr-<N>` environment, one execution; waits and exits with the verdict. Job summary = the execution report (the GitHub App comment); `--summary-file`, `--report junit`, step outputs |
208
+ | **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` |
204
209
 
205
210
  > 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).
206
211
 
@@ -212,7 +217,7 @@ See [the full local-testing reference](./DOCUMENTATION.md#local-frontend-testing
212
217
  - 🤖 **Agent-shaped output.** `test failure get` returns **one bundle** — the failing step, its neighbors, screenshots, DOM snapshots, the test source, a root-cause hypothesis, and a recommended fix target — all sharing a single `snapshotId`. The CLI _refuses_ to stitch data from two different runs, so an agent never reasons over a frankenstein context.
213
218
  - ♻️ **A loop, not a one-shot.** `create → run → failure get → fix → rerun` — every pass is banked, not thrown away.
214
219
  - 📐 **Scriptable & deterministic.** Stable `--output json` contract, predictable [exit codes](./DOCUMENTATION.md#exit-codes), and a `--dry-run` that exercises the full code path offline with canned data.
215
- - 🚦 **CI-native.** On GitHub Actions, `--wait` runs annotate the PR checks tab with one `::error::` per failure and append a results table to the job summary — automatically. Add `--report junit` for a JUnit XML sidecar, `--summary-file` for a machine summary, or `--gh-output` to preview the annotations locally. Runs in any CI, not just GitHub. [Details →](./DOCUMENTATION.md#continuous-integration)
220
+ - 🚦 **CI-native.** `testsprite ci init github` writes a PR gate; `testsprite ci run --env <name> --target-url "$PREVIEW_URL"` tests each pull request's preview deployment as one execution and exits with the verdict. The job summary is the execution report — the same content as the GitHub App's PR comment — plus `::error::` annotations on the checks tab, step outputs, `--summary-file` for a machine summary and `--report junit` for a JUnit sidecar. In any other CI, `testsprite ci run --project <id> --env <name> --target-url <url>` still runs the suite as one execution and makes the exit code the verdict — the pull-request context, draft skip and job summary are GitHub Actions only. [Details →](./DOCUMENTATION.md#continuous-integration)
216
221
  - 🔌 **One command to onboard your agent.** `testsprite setup` drops ready-made skill files into your repo — for the agents it detects you using — so your coding agent knows how to drive the loop on its own.
217
222
 
218
223
  ## How it works
@@ -3,6 +3,7 @@ import { Command } from 'commander';
3
3
  import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
4
4
  import { type FetchImpl } from '../lib/http.js';
5
5
  import { type DeploymentRecord, type LinkageStatus } from '../lib/ci-linkage.js';
6
+ import { type RunTestRunAllOptions, type TestDeps } from './test.js';
6
7
  /** Platforms `ci init` can scaffold. One today; the positional arg leaves room. */
7
8
  declare const SUPPORTED_PLATFORMS: readonly ["github"];
8
9
  type Platform = (typeof SUPPORTED_PLATFORMS)[number];
@@ -17,16 +18,18 @@ export interface CiFs {
17
18
  }): Promise<void>;
18
19
  mkdir(dir: string): Promise<void>;
19
20
  readFile(target: string): Promise<string>;
21
+ /** Entry names in `dir`; rejects with ENOENT when the directory is absent. */
22
+ readdir(dir: string): Promise<string[]>;
20
23
  }
21
24
  /** Injectable subprocess runner (defaults to a real `spawnSync`), so tests never
22
- * shell out. Runs `git` (default-branch detection), `gh` (optional secret set,
23
- * deployment history) and `npx vercel` (`ci connect`). */
25
+ * shell out. Runs `git` (repo slug), `gh` (optional secret set, deployment
26
+ * history) and `npx vercel` (`ci connect`). */
24
27
  export type SpawnImpl = (cmd: string, args: string[], opts: {
25
28
  input?: string;
26
29
  cwd?: string;
27
30
  shell?: boolean;
28
31
  }) => SpawnSyncReturns<string>;
29
- export interface CiDeps {
32
+ export interface CiDeps extends Pick<TestDeps, 'shutdown' | 'onWaitTimeout'> {
30
33
  env?: NodeJS.ProcessEnv;
31
34
  credentialsPath?: string;
32
35
  fetchImpl?: FetchImpl;
@@ -44,8 +47,10 @@ type CommonOptions = FactoryCommonOptions;
44
47
  export interface CiInitOptions extends CommonOptions {
45
48
  platform: string;
46
49
  project?: string;
47
- filter?: string;
48
- timeoutSeconds: number;
50
+ /** `--env`: the environment whose sign-in each PR run uses (default: the project's default). */
51
+ env?: string;
52
+ /** `--timeout`, written into the `ci run` line only when given. */
53
+ timeoutSeconds?: number;
49
54
  workflowPath: string;
50
55
  force: boolean;
51
56
  setSecret: boolean;
@@ -55,18 +60,22 @@ export interface CiInitOptions extends CommonOptions {
55
60
  export interface CiInitSummary {
56
61
  platform: Platform;
57
62
  path: string;
58
- action: string;
59
63
  projectId: string;
64
+ /** The environment written into `ci run --env`. */
65
+ environment: string;
60
66
  wrote: boolean;
61
67
  /** Distinguishes the two `wrote: false` cases a scripted caller can't otherwise
62
68
  * tell apart: `preview` (a --dry-run) vs `unchanged` (the file was already
63
69
  * byte-identical). `written` is the wrote-true case. */
64
70
  status: 'written' | 'unchanged' | 'preview';
65
- backupPath: string | null;
66
- filter: string | null;
67
71
  endpointUrl: string | null;
68
72
  endpointWarning: string | null;
69
- timeoutSeconds: number;
73
+ /** `--timeout` as written into the workflow; null when `ci run`'s default applies. */
74
+ timeoutSeconds: number | null;
75
+ /** Other workflows in `.github/workflows/` that already mention TestSprite. */
76
+ otherTestspriteWorkflows: string[];
77
+ /** `--force` over an edited file: where the previous file was kept. */
78
+ backupPath?: string;
70
79
  secret: {
71
80
  name: string;
72
81
  attempted: boolean;
@@ -75,19 +84,25 @@ export interface CiInitSummary {
75
84
  };
76
85
  }
77
86
  export declare function parseTimeoutSeconds(raw: unknown): number;
87
+ /** `--execution-report-timeout <s>`: same bounds as `--timeout`, its own default. */
88
+ export declare function parseExecutionReportTimeoutSeconds(raw: unknown): number;
78
89
  /**
79
- * Build the GitHub Actions workflow. It delegates to the published
80
- * `TestSprite/testsprite-action` (design A) rather than inlining the CLI, so the
81
- * partial-run guard (`allow-partial: false` by default), the JUnit upload, the
82
- * annotations, and the CLI-version pin all come from one maintained place.
90
+ * Build the GitHub Actions workflow. It calls the CLI directly (`ci run`), which
91
+ * owns every judgement — waiting, skipped counts, the exit code, the PR
92
+ * context — so the yml only moves data.
93
+ *
94
+ * One template covers both ways a PR gets a preview, because they differ only
95
+ * in where the URL comes from. The trigger, `if:` and concurrency already accept
96
+ * both events; the single placeholder step is the part only the repo owner can
97
+ * write, and it fails loudly until replaced so the gate can never run against a
98
+ * URL nobody chose.
83
99
  */
84
100
  export declare function buildGithubWorkflow(input: {
85
101
  projectId: string;
86
- filter?: string;
87
- timeoutSeconds: number;
102
+ environment: string;
103
+ timeoutSeconds?: number;
88
104
  endpointUrl?: string;
89
- cliVersion: string;
90
- defaultBranch: string;
105
+ workflowPath: string;
91
106
  }): string;
92
107
  export declare function runCiInit(opts: CiInitOptions, deps?: CiDeps): Promise<void>;
93
108
  export interface CiDoctorOptions extends CommonOptions {
@@ -169,5 +184,39 @@ export interface CiConnectSummary {
169
184
  export declare function runCiConnect(opts: CiConnectOptions, deps?: CiDeps): Promise<void>;
170
185
  export declare function renderCiConnectText(s: CiConnectSummary): string;
171
186
  export declare function renderCiInitText(s: CiInitSummary): string;
187
+ export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission' | 'previewName' | 'githubTrigger'> & {
188
+ failOnSkipped?: boolean;
189
+ /** `--execution-report-timeout`: how long to wait for the execution report (default 60). */
190
+ executionReportTimeoutSeconds?: number;
191
+ /** `--no-execution-report`: job summary stays the local table; nothing is read or written for the report. */
192
+ executionReport?: boolean;
193
+ };
194
+ /**
195
+ * `ci run` = `test run --all --wait` with CI's defaults, plus what only a CI
196
+ * job can add:
197
+ *
198
+ * - `admission: 'all'` — one request, one execution, server-side pacing (as
199
+ * for a GitHub App run), so a PR run is one row in the Portal and, in a
200
+ * pull request, one `github-pr-<N>` environment. The backend echoes the
201
+ * field; a backend that cannot honour it is refused (exit 7), never
202
+ * silently cut to the per-key budget and retried.
203
+ * - In a pull request (read off the Actions event, or looked up from the
204
+ * deployment's commit), `--env X --target-url U` runs in a temporary clone
205
+ * of X at U named `github-pr-<N>`, and the run is stamped with the PR so
206
+ * the Portal links back to it — the GitHub App's own mechanism.
207
+ * - Outside a pull request the run keeps `test run`'s semantics: X's sign-in
208
+ * against U, recorded under X.
209
+ */
210
+ export declare function runCiRun(opts: CiRunOptions, deps?: TestDeps): Promise<void>;
172
211
  export declare function createCiCommand(deps?: CiDeps): Command;
212
+ /**
213
+ * One stderr line per run of a deprecated `ci` subcommand, naming the
214
+ * equivalent commands (stdout stays clean for JSON pipelines). The
215
+ * replacements are not `testsprite` commands, so this does not reuse
216
+ * `emitDeprecationNotice`.
217
+ */
218
+ export declare const CI_DEPRECATION_NOTICES: {
219
+ readonly doctor: string;
220
+ readonly connect: string;
221
+ };
173
222
  export {};