@testsprite/testsprite-cli 0.16.0 → 0.18.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 (206) hide show
  1. package/README.md +52 -147
  2. package/dist/commands/agent.d.ts +12 -4
  3. package/dist/commands/agent.js +48 -63
  4. package/dist/commands/auth.d.ts +6 -10
  5. package/dist/commands/auth.js +40 -56
  6. package/dist/commands/ci.d.ts +23 -100
  7. package/dist/commands/ci.js +293 -487
  8. package/dist/commands/conversation.d.ts +27 -0
  9. package/dist/commands/conversation.js +741 -0
  10. package/dist/commands/doctor.d.ts +5 -1
  11. package/dist/commands/doctor.js +129 -34
  12. package/dist/commands/init.d.ts +4 -45
  13. package/dist/commands/init.js +108 -66
  14. package/dist/commands/project-env.d.ts +62 -2
  15. package/dist/commands/project-env.js +434 -43
  16. package/dist/commands/project-sign-in.d.ts +0 -48
  17. package/dist/commands/project-sign-in.js +1 -229
  18. package/dist/commands/project.d.ts +19 -186
  19. package/dist/commands/project.js +108 -926
  20. package/dist/commands/result.d.ts +10 -0
  21. package/dist/commands/result.js +216 -0
  22. package/dist/commands/schedule.d.ts +0 -29
  23. package/dist/commands/schedule.js +28 -87
  24. package/dist/commands/test.d.ts +301 -1838
  25. package/dist/commands/test.js +1880 -13917
  26. package/dist/commands/testlist.d.ts +130 -5
  27. package/dist/commands/testlist.js +300 -342
  28. package/dist/commands/tunnel.d.ts +3 -3
  29. package/dist/commands/tunnel.js +23 -20
  30. package/dist/commands/usage.d.ts +12 -45
  31. package/dist/commands/usage.js +50 -131
  32. package/dist/index.js +191 -110
  33. package/dist/lib/agent-detect.js +9 -5
  34. package/dist/lib/agent-targets.d.ts +21 -2
  35. package/dist/lib/agent-targets.js +88 -11
  36. package/dist/lib/args.d.ts +13 -0
  37. package/dist/lib/args.js +49 -0
  38. package/dist/lib/basic-auth.d.ts +3 -0
  39. package/dist/lib/basic-auth.js +15 -0
  40. package/dist/lib/billing-refusal.js +4 -3
  41. package/dist/lib/ci-linkage.d.ts +4 -82
  42. package/dist/lib/ci-linkage.js +4 -157
  43. package/dist/lib/ci-run.js +1 -1
  44. package/dist/lib/client-factory.d.ts +12 -4
  45. package/dist/lib/client-factory.js +41 -30
  46. package/dist/lib/commit-signal.d.ts +65 -0
  47. package/dist/lib/commit-signal.js +305 -0
  48. package/dist/lib/concurrency-limiter.d.ts +6 -0
  49. package/dist/lib/concurrency-limiter.js +29 -0
  50. package/dist/lib/config.js +10 -5
  51. package/dist/lib/conflict-reason.d.ts +9 -3
  52. package/dist/lib/conflict-reason.js +6 -3
  53. package/dist/lib/conversation/answers.d.ts +9 -0
  54. package/dist/lib/conversation/answers.js +49 -0
  55. package/dist/lib/conversation/api.d.ts +75 -0
  56. package/dist/lib/conversation/api.js +151 -0
  57. package/dist/lib/conversation/change.d.ts +31 -0
  58. package/dist/lib/conversation/change.js +124 -0
  59. package/dist/lib/conversation/context.d.ts +29 -0
  60. package/dist/lib/conversation/context.js +82 -0
  61. package/dist/lib/conversation/environment.d.ts +16 -0
  62. package/dist/lib/conversation/environment.js +21 -0
  63. package/dist/lib/conversation/follow.d.ts +24 -0
  64. package/dist/lib/conversation/follow.js +42 -0
  65. package/dist/lib/conversation/render.d.ts +33 -0
  66. package/dist/lib/conversation/render.js +318 -0
  67. package/dist/lib/conversation/title.d.ts +2 -0
  68. package/dist/lib/conversation/title.js +18 -0
  69. package/dist/lib/conversation/types.d.ts +158 -0
  70. package/dist/lib/conversation/types.js +6 -0
  71. package/dist/lib/credentials.js +67 -11
  72. package/dist/lib/cron.d.ts +1 -1
  73. package/dist/lib/cron.js +2 -2
  74. package/dist/lib/dispatch-stop.d.ts +20 -0
  75. package/dist/lib/dispatch-stop.js +30 -0
  76. package/dist/lib/download.d.ts +100 -0
  77. package/dist/lib/download.js +408 -0
  78. package/dist/lib/dry-run/fetch.d.ts +10 -0
  79. package/dist/lib/dry-run/fetch.js +20 -0
  80. package/dist/lib/dry-run/samples.d.ts +6 -34
  81. package/dist/lib/dry-run/samples.js +375 -747
  82. package/dist/lib/environment-tunnel.d.ts +19 -30
  83. package/dist/lib/environment-tunnel.js +168 -202
  84. package/dist/lib/errors.d.ts +20 -4
  85. package/dist/lib/errors.js +36 -16
  86. package/dist/lib/facade.d.ts +7 -29
  87. package/dist/lib/facade.js +7 -36
  88. package/dist/lib/failing-fe-resolver.d.ts +13 -58
  89. package/dist/lib/failing-fe-resolver.js +47 -132
  90. package/dist/lib/first-suite-hint.d.ts +20 -30
  91. package/dist/lib/first-suite-hint.js +57 -72
  92. package/dist/lib/gh-output.d.ts +76 -21
  93. package/dist/lib/gh-output.js +171 -90
  94. package/dist/lib/git-utils.d.ts +56 -0
  95. package/dist/lib/git-utils.js +212 -0
  96. package/dist/lib/github-context.d.ts +2 -0
  97. package/dist/lib/github-context.js +40 -8
  98. package/dist/lib/history-retention.d.ts +6 -2
  99. package/dist/lib/history-retention.js +10 -7
  100. package/dist/lib/http.d.ts +58 -134
  101. package/dist/lib/http.js +354 -291
  102. package/dist/lib/interrupt.d.ts +14 -8
  103. package/dist/lib/interrupt.js +28 -10
  104. package/dist/lib/junit-report.d.ts +57 -4
  105. package/dist/lib/junit-report.js +202 -32
  106. package/dist/lib/local-target.d.ts +8 -7
  107. package/dist/lib/local-target.js +14 -13
  108. package/dist/lib/output.d.ts +2 -41
  109. package/dist/lib/output.js +13 -51
  110. package/dist/lib/pagination.d.ts +2 -5
  111. package/dist/lib/pagination.js +2 -5
  112. package/dist/lib/presigned-url.d.ts +22 -0
  113. package/dist/lib/presigned-url.js +90 -0
  114. package/dist/lib/prompt.js +36 -2
  115. package/dist/lib/proxy.js +2 -1
  116. package/dist/lib/redact.d.ts +2 -2
  117. package/dist/lib/redact.js +3 -4
  118. package/dist/lib/removed-commands.d.ts +18 -0
  119. package/dist/lib/removed-commands.js +170 -0
  120. package/dist/lib/render-error.d.ts +31 -6
  121. package/dist/lib/render-error.js +88 -25
  122. package/dist/lib/response-schemas.d.ts +38 -30
  123. package/dist/lib/response-schemas.js +207 -207
  124. package/dist/lib/result/api.d.ts +24 -0
  125. package/dist/lib/result/api.js +28 -0
  126. package/dist/lib/result/evidence.d.ts +73 -0
  127. package/dist/lib/result/evidence.js +422 -0
  128. package/dist/lib/result/render.d.ts +20 -0
  129. package/dist/lib/result/render.js +194 -0
  130. package/dist/lib/result/types.d.ts +122 -0
  131. package/dist/lib/result/types.js +19 -0
  132. package/dist/lib/run-output.d.ts +275 -0
  133. package/dist/lib/run-output.js +227 -0
  134. package/dist/lib/run-render.d.ts +101 -0
  135. package/dist/lib/run-render.js +183 -0
  136. package/dist/lib/run-wait.d.ts +192 -0
  137. package/dist/lib/run-wait.js +452 -0
  138. package/dist/lib/runs.types.d.ts +118 -367
  139. package/dist/lib/runs.types.js +0 -14
  140. package/dist/lib/secret-file.d.ts +1 -1
  141. package/dist/lib/secret-file.js +11 -2
  142. package/dist/lib/skill-nudge.d.ts +7 -27
  143. package/dist/lib/skill-nudge.js +9 -37
  144. package/dist/lib/target-path.d.ts +15 -0
  145. package/dist/lib/target-path.js +35 -0
  146. package/dist/lib/target-url-advisory.d.ts +19 -0
  147. package/dist/lib/target-url-advisory.js +31 -0
  148. package/dist/lib/target-url-preflight.d.ts +9 -0
  149. package/dist/lib/target-url-preflight.js +214 -106
  150. package/dist/lib/target-url.d.ts +8 -8
  151. package/dist/lib/target-url.js +14 -24
  152. package/dist/lib/telemetry.d.ts +35 -15
  153. package/dist/lib/telemetry.js +38 -9
  154. package/dist/lib/terminal-text.d.ts +41 -0
  155. package/dist/lib/terminal-text.js +127 -0
  156. package/dist/lib/testlist.types.d.ts +16 -8
  157. package/dist/lib/testlist.types.js +1 -1
  158. package/dist/lib/text-equality.d.ts +2 -0
  159. package/dist/lib/text-equality.js +5 -0
  160. package/dist/lib/text-file.d.ts +16 -0
  161. package/dist/lib/text-file.js +41 -0
  162. package/dist/lib/text-table.d.ts +46 -0
  163. package/dist/lib/text-table.js +72 -4
  164. package/dist/lib/ticker.d.ts +9 -2
  165. package/dist/lib/ticker.js +16 -3
  166. package/dist/lib/transport-failure.d.ts +22 -0
  167. package/dist/lib/transport-failure.js +126 -0
  168. package/dist/lib/tunnel-session.d.ts +8 -2
  169. package/dist/lib/tunnel-session.js +24 -11
  170. package/dist/lib/update-check.js +3 -2
  171. package/dist/lib/url-template.d.ts +43 -0
  172. package/dist/lib/url-template.js +151 -0
  173. package/dist/lib/validate.d.ts +0 -64
  174. package/dist/lib/validate.js +2 -131
  175. package/dist/lib/version-notice.js +4 -3
  176. package/dist/lib/wait-exit.d.ts +37 -2
  177. package/dist/lib/wait-exit.js +88 -30
  178. package/dist/lib/workspace-status.js +10 -2
  179. package/dist/version.d.ts +1 -1
  180. package/dist/version.js +1 -1
  181. package/package.json +2 -3
  182. package/skills/testsprite-ci.skill.md +52 -23
  183. package/skills/testsprite-onboard.skill.md +70 -153
  184. package/skills/testsprite-verify.codex.md +54 -58
  185. package/skills/testsprite-verify.skill.md +189 -358
  186. package/dist/lib/browser.d.ts +0 -6
  187. package/dist/lib/browser.js +0 -54
  188. package/dist/lib/bundle.d.ts +0 -234
  189. package/dist/lib/bundle.js +0 -781
  190. package/dist/lib/deprecate.d.ts +0 -32
  191. package/dist/lib/deprecate.js +0 -39
  192. package/dist/lib/flaky.d.ts +0 -91
  193. package/dist/lib/flaky.js +0 -71
  194. package/dist/lib/plan-poll.d.ts +0 -171
  195. package/dist/lib/plan-poll.js +0 -441
  196. package/dist/lib/plans.types.d.ts +0 -130
  197. package/dist/lib/plans.types.js +0 -31
  198. package/dist/lib/poll.d.ts +0 -100
  199. package/dist/lib/poll.js +0 -290
  200. package/dist/lib/rate-throttle.d.ts +0 -49
  201. package/dist/lib/rate-throttle.js +0 -75
  202. package/dist/lib/run-progress.d.ts +0 -41
  203. package/dist/lib/run-progress.js +0 -56
  204. package/dist/lib/v3-advisory.d.ts +0 -55
  205. package/dist/lib/v3-advisory.js +0 -74
  206. package/schemas/plan.schema.json +0 -61
@@ -11,10 +11,10 @@ running the test catches what breaks for a real user.
11
11
  ## When to run
12
12
 
13
13
  Run after a feature or fix lands — one feature → one test run, at the moment it
14
- lands, not batched at the end. Tests you create this way accumulate into the
15
- project's TestSprite suite; before writing a new one, check `testsprite test list`
16
- for an existing test that already covers the behavior and extend it instead of
17
- duplicating.
14
+ lands, not batched at the end. You don't write or edit TestSprite tests yourself:
15
+ the project's agent does (`testsprite plan` → `testsprite apply`), and what it
16
+ saves accumulates into the project's suite. Before asking for a new test, check
17
+ `testsprite test list` for an existing one that already covers the behavior.
18
18
 
19
19
  The CLI tests either a **deployed** URL or a frontend test running on this
20
20
  machine — it doesn't build or host your environment either way. For a deployed
@@ -23,15 +23,15 @@ deploy the preview/staging environment). Create a named environment for its
23
23
  public URL once, then select it with `--env <name>` on runs. Running earlier
24
24
  verifies the previous build, not your change.
25
25
 
26
- For a change that is only running locally, don't wait for a deployment: run
27
- `testsprite test run <test-id> --local <port>` instead. It tunnels this
26
+ For a change that is only running locally, don't wait for a deployment: save the
27
+ app on this machine as an environment (`testsprite project env create <projectId> --name local --url http://localhost:<port>`)
28
+ and run on it with `testsprite run <test-id> --env local`. The run tunnels this
28
29
  machine's own loopback address (`localhost` / `127.0.0.1` / `::1` — not a LAN
29
30
  or RFC1918 address, and not a general local-network escape hatch) to the test
30
- runner. It is for frontend tests only (a backend test's target is baked into
31
- its generated code, so run it normally). Existing API keys work for local runs; no replacement key is
32
- needed. `--local <port>` selects or creates the
33
- project's `local-<port>` environment. With `--env <name> --local <port>`, that
34
- named environment must also be local (`project env list <projectId>` shows names).
31
+ runner. It is for frontend tests only (a backend test reaches its API over HTTP from
32
+ the runner, so run it normally against a deployed environment). Existing API keys work for local runs; no replacement key is
33
+ needed. The environment's sign-in settings apply to the local app. Check the name with
34
+ `testsprite project env list <projectId>`.
35
35
 
36
36
  If the user explicitly named a tool (the CLI or the MCP), honor that choice
37
37
  regardless of which one the change's reachability would otherwise suggest.
@@ -55,19 +55,17 @@ Every shipped feature gets **at least one** TestSprite run to a terminal verdict
55
55
  (`passed` / `failed` / `blocked` / `inconclusive`) before you call it done. What
56
56
  counts:
57
57
 
58
- - `testsprite test create … --run --wait` returning a terminal verdict, **or**
59
- - `testsprite test run <id> --wait` against an existing test, **or**
60
- - `testsprite test create-batch --plans plans.jsonl --run --wait` (or
61
- two-step: create-batch, then `test run <id> --wait`) on at least one
62
- test returning a terminal verdict.
58
+ - `testsprite run --project <projectId> --wait` for the project suite, **or**
59
+ - `testsprite run <id> --wait` against an existing test, **or**
60
+ - `testsprite run <id...> --wait` on the tests `testsprite apply` just
61
+ saved, with at least one returning a terminal verdict.
63
62
 
64
- What does **not** count: unit tests / typecheck / lint; drafting a plan without
65
- `--run`; asking the user to run it for you.
63
+ What does **not** count: unit tests / typecheck / lint; a plan the agent
64
+ proposed but nobody ran; asking the user to run it for you.
66
65
 
67
66
  If the project has **no tests at all**, that's the `testsprite-onboard` skill's
68
- job, not this one — seed a suite first (it can generate the proposals for you
69
- with `testsprite test plan generate` / `test plan accept` for a deployed target;
70
- local projects require authored plans and `test create --plan-from`). Seeding is a deliberate setup pass, not part of the verify loop.
67
+ job, not this one — seed a suite first with the project's agent (`testsprite plan`
68
+ → `testsprite apply`). Seeding is a deliberate setup pass, not part of the verify loop.
71
69
 
72
70
  If you can't satisfy this — no creds, no valid target URL, repo not linked —
73
71
  **say so explicitly**: "Feature shipped but I could not run any TestSprite test
@@ -96,22 +94,23 @@ In priority order:
96
94
  4. Still ambiguous → list the candidates and ask the user which to use (one short
97
95
  question; picking the wrong project wastes a run).
98
96
 
99
- If no project exists for an app running only locally, bootstrap a frontend project
100
- (V3 required), author a plan, and run the returned test id:
97
+ If no project exists for an app running only locally, bootstrap a frontend project,
98
+ ask the agent for tests, and run the ids `apply` saved:
101
99
 
102
100
  ```bash
103
- testsprite project create --type frontend --name "<repo name>" --local <port> --local-host <host>
104
- testsprite test create --plan-from plan.json --project <projectId>
105
- testsprite test run <id> <id> --local <port> --local-host <host> --output json
101
+ testsprite project create --type frontend --name "<repo name>"
102
+ testsprite project env create <projectId> --name local --url http://localhost:<port>
103
+ testsprite plan "<what you built>" --diff --project <projectId> --output json
104
+ testsprite apply --output json
105
+ testsprite run <id> <id> --env local --output json
106
106
  ```
107
107
 
108
- Keep the app listening and use the same `--local-host` for creation and follow-up
109
- runs. It selects both the probe and stored URL host: `localhost`, `127.0.0.1`
110
- (default), or `::1`; omit it in both commands to use the default.
108
+ Keep the app listening: a run on the `local` environment opens a tunnel from this
109
+ machine, and the agent explores the app through one too — when it asks for a
110
+ tunnel, run `testsprite tunnel start` in another terminal and
111
+ `testsprite reply "The tunnel is running."`.
111
112
  The port probe fails with exit 5 if nothing listens (`--skip-preflight`
112
- bypasses it). Local projects skip exploration: `test plan generate` is refused
113
- before charge (exit 6), so use `test create --plan-from` without `--run`, then
114
- `test run --local`. V2-only local-project creation is unsupported (exit 7).
113
+ bypasses it).
115
114
  The Portal shows local environments without a Run action. Create a public
116
115
  environment for deployed apps and select it with `--env <name>`.
117
116
 
@@ -119,15 +118,13 @@ environment for deployed apps and select it with `--env <name>`.
119
118
 
120
119
  Look at the diff (`git diff --stat`, then the changed files) to understand what
121
120
  user-facing behavior changed. Pick one sub-mode. For a brand-new feature the
122
- right default is almost always (b) or (c); (a) is for tweaks to behavior an
123
- existing test already covers.
121
+ right default is almost always (b); (a) is for tweaks to behavior an existing
122
+ test already covers; (c) is for a test that is itself wrong.
124
123
 
125
124
  ### (a) An existing test covers the change
126
125
 
127
126
  ```bash
128
- testsprite test list --project <projectId> --output json
129
- testsprite test list --project <projectId> --status failed --output json # what's already red
130
- testsprite test run --all --project <projectId> --status failed,blocked --wait --timeout 600 --output json # re-run what did not pass
127
+ testsprite test list --project <projectId> --output json # the cases, as they are written
131
128
  ```
132
129
 
133
130
  Heuristic: a change to `src/components/CheckoutForm.tsx` is more likely covered
@@ -136,307 +133,153 @@ backend → `type: backend`.
136
133
 
137
134
  ### (b) A new test for the change (most common)
138
135
 
139
- **Frontend — draft a `plan.json`.** You name the behavior and list steps in plain
140
- language; you don't write browser code.
141
-
142
- ```jsonc
143
- {
144
- "projectId": "prj_abc",
145
- "type": "frontend",
146
- "name": "Booking date range change updates the estimated total",
147
- "description": "When a user opens a listing and extends the booking date range, the booking-panel estimated total updates to reflect the new dates before payment.",
148
- "priority": "p1",
149
- "planSteps": [
150
- { "type": "action", "description": "Navigate to the homepage" },
151
- { "type": "action", "description": "Search for stays with a valid destination and date range" },
152
- { "type": "action", "description": "Open a listing from the search results" },
153
- {
154
- "type": "action",
155
- "description": "Select an initial short date range to view the estimated total",
156
- },
157
- { "type": "action", "description": "Change the date range to a longer stay" },
158
- {
159
- "type": "assertion",
160
- "description": "Verify the estimated total on the booking panel updates from the initial value to reflect the new longer dates",
161
- },
162
- ],
163
- }
164
- ```
165
-
166
- - `name` — an assertable behavior statement (subject + verb + outcome), not a noun
167
- fragment — e.g. "Booking date range change updates the estimated total" tells
168
- the testing agent what to verify; "date range" tells it nothing.
169
- - `description` — the condition + expected outcome in one sentence; disambiguates
170
- a short name.
171
- - `priority` — `p0` (must-pass) / `p1` (important paths) / `p2` (edge) / `p3`
172
- (cosmetic). Pick honestly.
173
- - `planSteps` — `Array<{ type: 'action' | 'assertion', description: string }>`,
174
- max 200 steps / 256 KB. Describe user intent, not selectors.
175
-
176
- **Backend — write the Python yourself and use `--code-file`.** There is no
177
- server-side codegen on the CLI. Read the API surface that changed (OpenAPI, the
178
- route handler, request/response shapes) and write a pytest-style assertion script
179
- to a tempfile. **End the file by calling your `test_*` function(s)** — the runner
180
- executes the file top-to-bottom and does NOT auto-discover/collect test functions
181
- the way `pytest` does, so a test that is only _defined_ (never called) silently
182
- passes regardless of its assertions:
183
-
184
- ```python
185
- # /tmp/login-empty-password.py — runs against the project's target URL, creds injected.
186
- import requests
187
-
188
- def test_login_rejects_empty_password():
189
- r = requests.post(f"{TARGET_URL}/login", json={"email": "a@b.c", "password": ""})
190
- assert r.status_code == 400
191
- assert r.json().get("error") == "invalid password"
192
-
193
- # Required: actually invoke the test so its assertions run.
194
- test_login_rejects_empty_password()
195
- ```
196
-
197
- **Execution environment (backend).** The code runs in a locked-down sandbox with
198
- only the Python **standard library + `requests` + `pytest` + `numpy` + `scipy`**
199
- (plus `requests`' own deps like `urllib3`). So:
200
-
201
- - **Test the API over HTTP** with `requests` against the target URL — that's what a
202
- backend test verifies.
203
- - **Do NOT `import` the project's own source modules** (e.g. `from app.services import …`,
204
- `import core`, `import model`) or other third-party/ML packages (e.g. `torch`,
205
- `pandas`, `django`). They are not installed, so the test fails to even run.
206
- - Get values from the API's responses (and captured variables), not by importing and
207
- calling the app's internals.
208
-
209
- **Authentication — read the injected credential, NEVER hardcode any credential.** This
210
- applies to **every** secret the API needs — Bearer/JWT tokens **and** API keys, basic-auth
211
- blobs, session cookies. Do not paste a literal `Bearer …`, `sk-…`, `x-api-key` value, or any
212
- other credential into the test. Before your script runs, TestSprite prepends a managed
213
- credential block built from the project's Authentication settings, and `__AUTH_HEADERS__`
214
- already contains the right header(s) for the configured auth type:
215
-
216
- ```python
217
- # Auto-injected credentials — do not modify
218
- __AUTH_CREDENTIAL__ = "..."
219
- __AUTH_TYPE__ = "Bearer token" # or "API key" / "basic token" / "public"
220
- __AUTH_HEADERS__ = {"Authorization": "Bearer ..."} # API key → {"X-API-Key": "..."}; basic → {"Authorization": "Basic ..."}
221
- ```
222
-
223
- Spread `__AUTH_HEADERS__` into every authenticated request — it adapts to whatever auth type
224
- the project is configured for, so the same line works for Bearer, API-key, or basic auth:
136
+ **Ask the project's agent.** It is the agent the user has in the TestSprite
137
+ portal: it explores the app in a real browser (frontend) or calls the API
138
+ (backend), reads your change, and writes the tests against what the app is
139
+ supposed to do. You review its plan and apply it; you don't write the tests
140
+ yourself, so they don't share your blind spots.
225
141
 
226
- ```python
227
- r = requests.get(f"{TARGET_URL}/profile", headers={**__AUTH_HEADERS__})
142
+ ```bash
143
+ testsprite plan "<what you built, and the rules the user gave for it>" --diff \
144
+ [--file <prd-ticket-or-api-spec>] --project <projectId> --output json
145
+ # "state": "proposed" → show the user the plan, then:
146
+ testsprite apply # or: apply --exclude <ref>; reject "<what to change>"
147
+ # "proposal.kind": "question" → show the user its questions and options, then answer by letter:
148
+ testsprite apply --answer 1=b --answer 2=a,c # or your own words: --answer 1="…"
149
+ testsprite run <test-id...> --wait --output json # the ids apply saved, in "applied.tests"
228
150
  ```
229
151
 
230
- Configure the credential **once on the project** (ask the user for the value — never invent
231
- or reuse a key you happened to see), and the block stays correct + refreshable:
152
+ - Put the rules the user told you in the request. Don't invent expectations: a
153
+ test whose description says its expectation is only what the app does today is
154
+ the user's call, so ask them before you apply it.
155
+ - For distinct paths (happy + error + edge), ask for them in the same request;
156
+ 2–5 tests, more only with the user's confirmation.
157
+ - `"state": "replied"` → read `reply`. Answer from the code what you can with
158
+ `testsprite reply "..."`; ask the user only what only they know.
159
+ - Exit 7: the agent is still working; `testsprite status --wait` follows it.
160
+ Exit 13: the agent isn't enabled for this account; tell the user and stop —
161
+ the CLI has no other way to write tests.
162
+ - For an app only on this machine, the agent explores it through a tunnel: when it
163
+ asks for one, run `testsprite tunnel start` in another terminal and reply. Run
164
+ what it saved with `--env <name>`.
165
+ - When you open the pull request, put `prSummary` from the `apply` output in its
166
+ description, so reviewers see the tests that now guard the change.
167
+
168
+ **Review the plan before you apply it.** A loose plan produces a
169
+ confidently-wrong `passed` or a thrashing `blocked`. Reject (`testsprite reject
170
+ "<what to change>"`) a test that:
171
+
172
+ - asserts only that something is visible — presence ≠ working (an `<img>` whose
173
+ `src` 404s still "renders"); the assertion must say the thing works and is correct;
174
+ - for a visual / layout feature, asserts content only — at least one assertion
175
+ should name geometry or position (side-by-side, stacked, above/below, grid);
176
+ - names no specific page region for its assertion, or a fuzzy target ("open a thing");
177
+ - depends on state outside the test's control: third-party auth (OAuth/SSO/2FA),
178
+ OS-native surfaces (file upload/download, native dialogs), multi-tab or iframes.
179
+
180
+ **Backend credentials.** The agent's backend tests read the project's injected
181
+ credential (`__AUTH_HEADERS__`); they never hardcode a token. Configure it **once on
182
+ the project's environment** (ask the user for the value — never invent or reuse a key
183
+ you happened to see):
232
184
 
233
185
  - **Bearer / API key / basic (static):**
234
- `testsprite project credential <projectId> --type "Bearer token"|"API key"|"basic token" --credential <value>`
235
- - **Auto-refreshing login (recurring token):** `testsprite project auto-auth <projectId> …`
186
+ `testsprite project env update <projectId> <env> --auth bearer|basic|apikey --credential-file <path>`
187
+ (extra headers: `--header "Name: value"`, secret ones in `--header-file <path>`)
188
+ - **Auto-refreshing login (recurring token):**
189
+ `testsprite project env update <projectId> <env> --auto-auth-file <path>` (format: `project env update --help`)
236
190
 
237
- A hardcoded token expires within hours (and a hardcoded key can't be rotated centrally), so
238
- the test breaks on later runs; the managed block is rewritten with a fresh value each run.
239
- `test create` emits a `[warn]` when it detects an inlined credential literal — treat that as
240
- a must-fix, not a nuisance.
191
+ ### (c) A test that is wrong
241
192
 
242
- **Backend tests that share state declare dependencies at create time.** For a
243
- one-off verification, prefer a single self-contained script (log in inside the
244
- same file). But when the coverage set splits naturally into producer → consumer
245
- → cleanup — one test captures an auth token or created-resource id that others
246
- reuse — declare the graph with the dependency flags instead of duplicating setup
247
- in every file:
193
+ You don't edit tests. If a test fails because the test itself is wrong (stale
194
+ steps, a wrong expectation), tell the agent and apply its fix:
248
195
 
249
196
  ```bash
250
- # producer — captures a variable for later waves
251
- testsprite test create --type backend --project <projectId> --name "login issues an auth token" \
252
- --code-file /tmp/login.py --produces auth_token
253
-
254
- # consumer — scheduled in a wave after every producer it names
255
- testsprite test create --type backend --project <projectId> --name "profile update accepts the issued token" \
256
- --code-file /tmp/profile.py --needs auth_token
257
-
258
- # cleanup — always scheduled in the final wave
259
- testsprite test create --type backend --project <projectId> --name "fixture user is deleted" \
260
- --code-file /tmp/cleanup.py --category teardown
261
- ```
262
-
263
- - `--produces <var>` / `--needs <var>` are repeatable. All three flags are
264
- **backend-only** — combined with `--type frontend` the CLI exits 5.
265
- - **Don't hand-sequence `test run` calls to fake ordering.** The wave engine owns
266
- ordering: trigger the set with `test run --all` (§4) and producers run before
267
- consumers, `teardown` last. Chaining `run A --wait && run B --wait` yourself
268
- loses the engine's variable passing and conflicts with concurrent runs.
269
- - **Declarations are editable.** `test update` amends them (`--produces` /
270
- `--needs` / `--category`, repeatable) and `test get` echoes them back —
271
- still declare the graph at create time when you can, so wave ordering is
272
- right on the first run.
273
-
274
- **Show the user the drafted plan / code before creating it** — creating writes to
275
- their project. One short confirmation; let them edit the tempfile first.
276
-
277
- #### Authoring planSteps the testing agent will execute reliably
278
-
279
- Execution reliability tracks plan wording. A loose plan produces a
280
- confidently-wrong `passed` (bare visibility assertions) or a thrashing
281
- `blocked`. Write to these rules first:
282
-
283
- - **One verb per step.** `and` / `then` between two verbs → split — e.g.
284
- "Search for stays and open the first result" becomes two steps.
285
- - **Describe outcomes, not selectors.** The testing agent locates targets
286
- semantically — describe the intent and the match stays robust across copy
287
- changes; a guessed literal label defeats that. E.g. write `"Submit the form"`,
288
- not `"Click the blue 'Submit' button"`. If the app tags elements with its own
289
- attribute (`data-element`, `data-cy`, …), make sure the project knows —
290
- `testsprite project get <projectId>` shows `testIdAttrs:`; set it once with
291
- `project update <projectId> --test-id-attributes <attr>,data-testid` — and the
292
- exported code will locate tagged elements by that attribute instead of text.
293
- - **`Navigate to` only on step 1** (or a login page). Use clicks for every later
294
- transition — direct URLs break SPA routing.
295
- - **FE plans narrate a user journey through their actions.** Each action is
296
- what a real user does (click, type, navigate, hover, scroll), forming a
297
- sequence that exercises what gives the feature its value. The final assertion
298
- verifies what the journey produced — the state the user arrived at, a
299
- comparison against an earlier state, a derived count — not just that the
300
- starting page rendered.
301
- - **Name the target entity type, not a fuzzy noun.** If a page has several
302
- look-alike row kinds, "open a thing" lets the testing agent pick the wrong
303
- kind. Name the type and the page/view you expect to land on.
304
- - **1–2 assertions, at the end, on whether the content is present _and actually
305
- works_** (see _presence ≠ working_ below) rather than UI copy / formatting.
306
- (Quoting a literal you submitted earlier in the same plan, to verify it
307
- round-trips, is fine.)
308
- - **Presence ≠ working.** A node can exist yet be broken or wrong — e.g. an
309
- `<img>` whose `src` 404s renders a broken-image box but still passes "element
310
- present / has alt." Assert the thing actually **works and is correct**, not
311
- just that the tag exists; trust the testing agent to judge correctness rather
312
- than hard-coding the expected answer into the assertion.
313
- - **Assertion targets name the specific page region** (panel / tab / output area).
314
- Otherwise the testing agent settles for "some element with that text is
315
- visible anywhere," which passes for wrong reasons.
316
- - **For visual / CSS / layout-sensitive features, content-presence-only
317
- assertions are dangerous.** "Verify the methodology section is visible" passes
318
- even when the stylesheet is missing and three cards render as flat unstyled
319
- text stacked vertically — the strings exist on the page, and a content-presence
320
- assertion constrains nothing about layout. For any feature whose value depends on
321
- layout, include at least one assertion that names geometry or relative
322
- position (row, column, side-by-side, stacked, grid, above/below, span, card
323
- background, border), not just content existence:
324
-
325
- ```jsonc
326
- // BEFORE — content-presence-only (passes even on broken CSS)
327
- { "type": "assertion", "description": "Verify the methodology section with three sub-score formulas is visible" }
328
-
329
- // AFTER — content + layout
330
- { "type": "assertion", "description": "Verify the methodology section shows three card cells laid out side-by-side in a single horizontal row, each with a distinct card background and a heading; the three cards together span the full content width" }
331
- ```
332
-
333
- - **Keep `description` and `planSteps` in scope agreement** — the testing agent
334
- reads `description` as the test's purpose and shrinks execution to match. If
335
- you change the steps, re-align the description.
336
- - **Keep flows that depend on state outside the test's control out of scope:**
337
- third-party auth (OAuth/SSO/2FA), OS-native surfaces (file upload/download,
338
- drag-and-drop, native dialogs), cross-context state (iframes, multi-tab,
339
- external services). Pick a different verification.
340
- - **Test data must be self-contained** — create what you need within the plan, or
341
- don't write the plan.
342
-
343
- ### (c) A coverage set — multiple FE plans as a batch
344
-
345
- When a FE feature has distinct paths (happy + error + edge), draft a
346
- `plans.jsonl`, one spec per line. Aim for 2–5 plans; more only with explicit user
347
- confirmation. Max 50 plans / 5 MB per batch.
348
-
349
- ```jsonc
350
- // plans.jsonl — FE only
351
- {"projectId":"prj_abc","type":"frontend","name":"login happy path","planSteps":[...]}
352
- {"projectId":"prj_abc","type":"frontend","name":"login wrong password","planSteps":[...]}
353
- {"projectId":"prj_abc","type":"frontend","name":"login empty email","planSteps":[...]}
197
+ testsprite plan "the <test name> test should <correct behavior>: <why>" --project <projectId>
198
+ testsprite apply
354
199
  ```
355
200
 
356
- Batch is **FE-only.** For 3 backend tests, run `test create --type backend
357
- --project <projectId> --code-file <file>` three times with three Python files.
358
-
359
- ### (d) Refine an existing test
360
-
361
- - **FE** — replace the steps, then re-run:
362
- ```bash
363
- testsprite test plan put <test-id> --steps refined.json
364
- ```
365
- - **BE** — write updated Python and replace the code (optimistic concurrency):
366
- ```bash
367
- testsprite test code put <test-id> --code-file refined.py --expected-version <current-version>
368
- ```
201
+ Drifted steps are healed during a run; a wrong expectation needs the agent.
369
202
 
370
203
  ## 4. Run
371
204
 
372
205
  For a deployed target, create its environment once, then use `--env <name>`
373
206
  after that deployment contains the change. Omit `--env` for Default; an unknown
374
207
  name fails with available names and never falls back. For a local change,
375
- use `testsprite test run <test-id> --local <port>` (frontend only); it implies
376
- waiting and defaults to 1200 seconds. Create a missing test from a plan first,
377
- without `--run`, then run its id with `--local`.
208
+ run on the local environment, `testsprite run <test-id> --env <name>` (frontend only); it implies
209
+ waiting and defaults to 1200 seconds.
210
+
211
+ For a long `--wait` or a local run, start the CLI as a background task in your
212
+ agent tool (for example, `run_in_background: true` in Claude Code) and poll
213
+ that same task for its output and exit code. If running in the foreground,
214
+ set the tool's wall-clock timeout longer than the CLI wait budget, including
215
+ time for setup and cleanup. A tool timeout can terminate the CLI. After an
216
+ ordinary cloud run detaches, resume with `testsprite run wait <run-id>`.
217
+ Terminating the process that owns a local tunnel closes it and requests
218
+ cancellation by default.
378
219
 
379
220
  ```bash
380
221
  # One-time setup for a deployed target
381
222
  testsprite project env create <projectId> --name staging --url https://staging.example.com
382
223
 
224
+ # Run the project suite and wait
225
+ testsprite run --project <projectId> --env staging --wait --timeout 600 --output json
226
+
383
227
  # (a) existing test
384
- testsprite test run <test-id> --env staging --wait --timeout 600 --output json
228
+ testsprite run <test-id> --env staging --wait --timeout 600 --output json
385
229
 
386
230
  # (a-several) several tests in one batch; --skip-dependencies (BE) runs only the named tests
387
- testsprite test run <test-id> <test-id> --env staging --wait --timeout 600 --output json
388
- testsprite test run <test-id> --skip-dependencies --wait --timeout 600
389
-
390
- # (b-FE) new FE test from plan
391
- testsprite test create --plan-from plan.json --run --wait --env staging --timeout 600
392
-
393
- # (b-BE) new BE test from Python (backend create needs --project)
394
- testsprite test create --type backend --name "..." --project <projectId> --code-file foo.py --run --wait --timeout 600
395
-
396
- # (b-BE coverage set with dependencies) create each test without --run, then one wave-ordered batch
397
- testsprite test run --all --project <projectId> --env staging --wait --timeout 600 --output json
398
- testsprite test run --all --project <projectId> --filter <name-substr> --wait --timeout 600 # subset by name
399
- testsprite test run --all --project <projectId> --status failed,blocked --wait --timeout 600 # only what did not pass
400
-
401
- # (c) FE coverage set — single-call create + run (FE-only)
402
- testsprite test create-batch --plans plans.jsonl --run --wait \
403
- --env staging --max-concurrency 3 --timeout 600 --output json
404
- # Two-step alternative (inspect before running):
405
- # testsprite test create-batch --plans plans.jsonl --output json
406
- # then trigger each id: testsprite test run <test-id> --env staging --wait --timeout 600
407
-
408
- # (d-FE) refine + re-run
409
- testsprite test plan put <test-id> --steps refined.json && \
410
- testsprite test run <test-id> --env staging --wait --timeout 600
411
-
412
- # (d-BE) refine BE code + re-run. A BE run dispatches the producer/teardown closure by default —
413
- # use --skip-dependencies while iterating on one script (producers already verified this round),
414
- # then finish with a closure run before reporting.
415
- testsprite test code put <test-id> --code-file refined.py --expected-version <current-version> && \
416
- testsprite test run <test-id> --env staging --wait --timeout 600
231
+ testsprite run <test-id> <test-id> --env staging --wait --timeout 600 --output json
232
+ testsprite run <test-id> --skip-dependencies --wait --timeout 600
233
+
234
+ # (b) the tests `apply` saved
235
+ testsprite run <test-id> <test-id> --env staging --wait --timeout 600 --output json
236
+
237
+ # Narrow a project selection by title
238
+ testsprite run --project <projectId> --filter <name-substr> --wait --timeout 600 # subset by name
417
239
  ```
418
240
 
241
+ Saved lists retain their pinned project/environment mappings:
242
+
243
+ ```bash
244
+ testsprite run --testlist <listId> --wait --output json
245
+ testsprite run <test-id> <test-id> --testlist <listId> --wait --output json
246
+ # Resume or cancel whole executions; these IDs are runId, not testId/resultId
247
+ testsprite run wait <run-id...> --timeout 600 --output json
248
+ testsprite run cancel <run-id...> --output json
249
+ ```
250
+
251
+ Choose a project, named tests, or a saved list. `--project` cannot combine with
252
+ positional IDs or `--testlist`; named IDs and list selection ignore
253
+ `TESTSPRITE_PROJECT_ID`. Without IDs or a list, that variable supplies the default
254
+ project. Lists reject environment/target overrides and use positional members
255
+ for subsets. `--filter` narrows only project selection. Use `run wait R --timeout
256
+ 600` with lifecycle flags after the child; launch flags before a child are errors.
257
+
419
258
  Key behaviors:
420
259
 
421
260
  - Environment `--url` takes a public http/https URL or a loopback http origin
422
261
  with an explicit port (frontend only); private and link-local addresses are
423
262
  refused. Running against a loopback environment opens a tunnel automatically
424
- and waits, like `--local <port>`. `--env <name> --local <port>` sends that
425
- environment's sign-in to your local app; the server applies it or refuses
426
- before dispatch.
427
- - `--wait` long-polls until terminal and handles its own backoff — don't wrap it
263
+ and waits. `run` takes no `--target-url`: a run's address is its environment's.
264
+ - `--wait` reads execution status until terminal and handles its own backoff — don't wrap it
428
265
  in a retry loop.
429
- - `--local` implies `--wait`, with a default timeout of 1200 seconds per run (ordinary
430
- waits default to 600). Run several local frontend tests in ONE command (`test run <id> <id> … --local <port>`) instead of starting one process per test. `--all --project <id> --local <port>` runs frontend tests and reports backend tests as skipped. One tunnel serves the invocation; `--max-concurrency` defaults to 5 and caps at 10. There are
266
+ - A tunnel run implies `--wait`, with a default timeout of 1200 seconds for the command (ordinary
267
+ waits default to 600). Run several local frontend tests in ONE command (`run <id> <id> … --env <name>`) instead of starting one process per test. `run --project <id> --env <name>` runs frontend tests and reports backend tests as skipped. They start one run per project (up to 5000 named test IDs per request) through one tunnel; `--max-concurrency` sets the server dispatch limit per execution, default 5 and maximum 15. Each execution is waited on independently; this limit never queues polling. There are
431
268
  5 live tunnel bindings per user; `tunnel_binding_limit` is exit 11 and is not
432
269
  auto-retried. Reuse a live tunnel with `--tunnel-client` or stop an unused one.
433
270
  On a tunnel-limit error, run `testsprite tunnel list`, then `testsprite tunnel stop <id>`
434
271
  or `testsprite tunnel stop --all --confirm` if every binding should be revoked.
435
- - Keep the early **stderr** run-id receipts (`Run <runId>` for one test, `[i/N] <testId> → run <runId>` for a batch); `Dashboard: <url>` follows when supplied. Preserve each id even if
436
- the wait later stops; stdout remains the normal JSON result channel.
272
+ - Keep the ids the run prints. A run is one launch (`runId`); each test in it has a
273
+ result (`resultId`). A project or named launch prints `Run <run-id>` on **stderr** at
274
+ once, and so does a saved list (`--testlist`) under `--wait`; the card on stdout lists
275
+ each run (`Run <run-id>`) with its results and, when the server supplies one, a
276
+ `Dashboard: <url>` line (that run's page in the Portal).
277
+ Parse `runs[].runId`, `results[].resultId` and the outcome counts in `summary` for
278
+ any selection or resumed wait. `partial: true` marks an incomplete timeout or
279
+ interruption. A completed failure can be inspected immediately with `result get`.
437
280
  - An **owned** local run requests cancellation by default when waiting stops (timeout,
438
281
  Ctrl-C, or a polling failure), then its tunnel closes. Read the reported
439
- cancellation outcome. For a V3 frontend run cancelled before a terminal verdict,
282
+ cancellation outcome. For a frontend run cancelled before a terminal verdict,
440
283
  the backend attempts a refund. Inspect `refund.status`; cancellation does not
441
284
  guarantee a refund.
442
285
  `--no-cancel-on-interrupt` detaches instead, but the owned tunnel still closes.
@@ -447,58 +290,38 @@ Key behaviors:
447
290
  A second `tunnel start` or process using the same credential takes over, and the first exits **10**.
448
291
  - Exit codes: `0` = passed; `1` = failed / blocked / cancelled; `7` = timeout
449
292
  or unsupported. An owned local timeout is inconclusive: start a **new**
450
- `testsprite test run <test-id> --local <port> --timeout 1800`, keeping the same
451
- `--local-host <host>` if used; do not suggest `test wait` for that closed tunnel. Resume **ordinary or adopted-tunnel**
452
- waits with `testsprite test wait <run-id>` only while the target is reachable
293
+ `testsprite run <test-id> --env <name> --timeout 1800`; do not suggest `run wait` for that closed tunnel. Resume **ordinary or adopted-tunnel**
294
+ waits with `testsprite run wait <run-id>` only while the target is reachable
453
295
  (and the adopted tunnel's owner remains alive).
454
296
  - Exit `13` (`FEATURE_GATED`) and exit `12` (`INSUFFICIENT_CREDITS`) are not retriable: show the user the server's message and the link from `nextAction` or JSON `links`, then stop.
455
- - A local environment has a loopback URL and needs `--local <port>` from that
456
- machine. A bare CLI run selecting it, explicitly or as Default, is refused
457
- before dispatch without charge (`tunnel-required`, exit 6). The Portal shows
297
+ - When `run` selects a saved loopback environment by name or as Default, run
298
+ it on the machine hosting the app. The CLI opens a tunnel and waits. An
299
+ explicit `--no-wait` suppresses automatic tunneling. Without a live tunnel
300
+ the server refuses dispatch (`tunnel-required`, exit 6). The Portal shows
458
301
  local environments but offers no Run; backend Portal requests are refused
459
- without charge. Schedules and test lists targeting them get a free BLOCKED
460
- result. A deployed environment selected with `--env <name>` or made Default
461
- runs normally even if the test ran through a tunnel before. V3 local runs use
302
+ without charge. A CLI test-list launch can tunnel to its pinned local
303
+ environment. Scheduled runs cannot start a tunnel on your machine. A deployed environment selected with `--env <name>` or made Default
304
+ runs normally even if the test ran through a tunnel before. Local runs use
462
305
  the agent path, never saved-code replay, and preserve the test's saved code.
463
- - Batch: `create-batch --run --wait` creates the tests (FE-only) and fans
464
- out triggers in one call (bounded by `--max-concurrency`), emitting
465
- `{ results: [...] }` that mirrors the single-test `test run --wait`
466
- envelope. Exit `0` if every run passed; `1` for any failed/blocked/
467
- cancelled or trigger error; `7` only when EVERY run timed out. Drop
468
- `--run` if you want to inspect the created tests before triggering.
469
- - Run-trigger rate limit is 60/min/key, server-enforced; the CLI self-throttles
470
- to 50/min. `--max-concurrency` (default 50) does NOT raise the server cap —
471
- excess triggers return `RATE_LIMITED` (per-spec in batch JSON; exit 11 for
472
- single `test run`). The test row stays created, the run never started. A full
473
- `create-batch` (≤50 specs) fires all at once under the cap. The 50/min throttle
474
- is per-invocation — separate batches/processes don't share it — so for >50 specs
475
- in a minute you lean on the server's 60/min cap + `RATE_LIMITED` retries, not
476
- client queuing. Re-list and check `draft` rows — "tests created" is
477
- not the same as "runs triggered".
478
- - **Backend execution is dependency-aware; frontend is not.** `test run --all
479
- --project <id>` triggers a fresh wave-ordered batch over the project's backend
480
- tests (producers → consumers → `teardown` last); FE tests in the project are
481
- skipped with an advisory, and everything not dispatched is enumerated
482
- (`conflicts` / `deferred` / `skippedFrontend`) so don't count `accepted[]`
483
- alone. A big batch is accepted whole and its runs show `queued` until they
306
+ - Run-trigger rate limit is 60/min/key, server-enforced; excess triggers return
307
+ `RATE_LIMITED` (exit 11 for a single `run`).
308
+ - **Backend execution is dependency-aware; frontend is not.** `run
309
+ --project <id>` triggers a fresh batch over every test in the project: backend
310
+ tests in wave order (producers → consumers → `teardown` last), frontend tests
311
+ alongside. Check dispatch diagnostics and `summary.skipped` for tests that did not start. A big batch is accepted whole and its tests show `queued` until they
484
312
  start; `deferred` is rare (a project's lock stayed busy, or a test went in
485
313
  flight during dispatch) and is never resent (exit 7). A BE run expands the
486
- producer/teardown closure by default; failed
487
- members surface as `closureFailures[]` without flipping the exit
488
- code. Pass `--skip-dependencies` only when this round already verified the
489
- producers and you're iterating fast on one script.
490
- - `test code put`: `--expected-version <codeVersion>` is optional (the CLI
491
- fetches the current version, which races with concurrent edits); stale etag → exit 6,
492
- re-fetch via
493
- `test get <id>` and retry. `--force` bypasses but is audit-logged.
314
+ producer/teardown closure by default. Pass `--skip-dependencies` (`run <test-id> --skip-dependencies`)
315
+ only when this round already verified the producers.
494
316
  - Idempotency: the CLI auto-mints an `Idempotency-Key`; replays within 24h return
495
- the original test/run.
317
+ the original run.
496
318
 
497
319
  ## 4a. Read the result — plan, or product?
498
320
 
499
- Don't take the verdict at face value. After a run, pull the steps
500
- (`testsprite test steps <test-id> --output json`) and ask: **plan quality, or
501
- actual product behavior?**
321
+ Don't take the verdict at face value. After a run, read the result
322
+ (`testsprite result get <result-id> --output json`: `error`, `cause`, `fix`,
323
+ `failedStep` and every step; a backend test adds its traceback `trace` and its
324
+ output `apiOutput`) and ask: **plan quality, or actual product behavior?**
502
325
 
503
326
  The plan is the problem (most common — check first) when:
504
327
 
@@ -513,11 +336,10 @@ The product/environment is the problem (believe these) when:
513
336
  read-only", "page 404s");
514
337
  - the trace blames infra (deploy lag, auth gate, missing fixture).
515
338
 
516
- `test steps <test-id>` shows the **latest run's steps**. For the run you are
517
- verifying, use `testsprite test steps <test-id> --run-id <run-id> --output json`
518
- with the id from the early stderr receipt. An empty latest run is not evidence
519
- from an earlier run; use `test result <test-id> --history` to choose one explicitly.
520
- Older backends may return cumulative bare steps; pin `--run-id` before counting.
339
+ Read the result of the run you are verifying, by the `resultId` that run printed.
340
+ `testsprite result list --run <run-id> --status failed,blocked` lists what did not
341
+ pass in a run; `testsprite result list --test <test-id> --limit 5` lists a test's
342
+ recent results, newest first. A result of an earlier run is not evidence for this one.
521
343
 
522
344
  **Read the testing agent's failure summary skeptically — it can conflate two
523
345
  failure phases.** When a flow produces an artifact that then runs against an external
@@ -528,26 +350,34 @@ and runtime output: if the runtime output references a literal you submitted
528
350
  earlier in the plan, the action succeeded and the error is runtime-phase.
529
351
 
530
352
  **BE closure runs: root-cause the earliest failed wave, not the selected test.**
531
- When a `run` or `run --all` expanded a dependency closure and a **producer**
353
+ When `run` expanded a dependency closure and a **producer**
532
354
  failed, every consumer downstream of it fails or blocks by starvation (missing
533
355
  token / missing fixture). The selected test's red verdict does not implicate
534
- your feature — report it as failed-downstream, pull the producer's artifact
356
+ your feature — report it as failed-downstream, read the producer's result
535
357
  first, and only blame the consumer once its producers pass in the same run.
536
358
 
537
- If it's the plan: tighten via `test plan put` and re-run **once** (two runs total),
538
- then stop. Don't grind. If it's the product/env: report the verdict with the
359
+ If it's the plan: tell the agent what is wrong with it (§3c), apply its fix and
360
+ re-run **once** (two runs total), then stop. Don't grind. If it's the product/env: report the verdict with the
539
361
  testing agent's observation; don't auto-fix on the recommendation alone. If you
540
362
  genuinely can't tell: report `inconclusive` with the signal that triggered the
541
363
  call and ask.
542
364
 
543
- ## 5. On failure → download the artifact
365
+ ## 5. On failure → download the evidence
544
366
 
545
367
  ```bash
546
- testsprite test artifact get <run-id> --out ./.testsprite/runs/<run-id>/
368
+ testsprite result get <result-id> --out .testsprite/results/<result-id>
369
+ testsprite result get <result-id> --out .testsprite/results/<result-id> --failed-only # failed step ±1
547
370
  ```
548
371
 
549
- Inspect the failure bundle (result, failed step + neighbors, video, root-cause
550
- hypothesis, recommended fix target) before deciding whether your change caused it.
372
+ It writes `result.json` (the result, each link replaced by its file), the video and
373
+ each step's `steps/001.png` / `steps/001.html`. Give each result its own directory:
374
+ in an existing one, `result.json`, `video.*`, `steps/` and `sign-in/` are replaced.
375
+ Read `cause`, `fix` and the failed step in `result.json` first. Raw HTML
376
+ snapshots may contain credentials in form values. Use the neighboring screenshots
377
+ and the video for visual context. Keep the export private and
378
+ use a redacted excerpt when sharing evidence. The CLI creates
379
+ `.testsprite/.gitignore` on first export there and preserves existing rules.
380
+ Check Git's ignore rules when using a custom output directory.
551
381
 
552
382
  ## 6. Report
553
383
 
@@ -558,8 +388,9 @@ When you tell the user the feature is done, include:
558
388
  - The verdict. Don't report `passed` if §4a's sanity check tripped — surface as
559
389
  `inconclusive` with the specific signal.
560
390
  - If the user wants to inspect a test or run themselves, point them at the
561
- dashboard link from the CLI output (`dashboardUrl` in JSON; a `Dashboard:` line
562
- in text mode) — `test create` and `--wait` terminal output carry one.
563
- - If failed, a one-line summary of the bundle's root-cause hypothesis and
564
- recommended fix target. **Don't auto-fix** on that alone — the recommendation
391
+ dashboard link from the CLI output (`runs[].dashboardUrl` in JSON; a `Dashboard:` line
392
+ under each run in text mode) — `run`, `run --wait` and `run wait` all carry one when
393
+ the server supplies it (a saved list launched without `--wait` has none until
394
+ `run wait`). It opens that run's page in the Portal.
395
+ - If failed, a one-line summary of the result's `cause` and `fix`. **Don't auto-fix** on that alone — the recommendation
565
396
  can be wrong; the human should look.