@testsprite/testsprite-cli 0.1.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 (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +190 -0
  3. package/dist/assets/agent-skill/testsprite-verify.codex.md +119 -0
  4. package/dist/assets/agent-skill/testsprite-verify.skill.md +423 -0
  5. package/dist/commands/agent.d.ts +51 -0
  6. package/dist/commands/agent.js +552 -0
  7. package/dist/commands/auth.d.ts +38 -0
  8. package/dist/commands/auth.js +247 -0
  9. package/dist/commands/init.d.ts +63 -0
  10. package/dist/commands/init.js +350 -0
  11. package/dist/commands/project.d.ts +72 -0
  12. package/dist/commands/project.js +400 -0
  13. package/dist/commands/test.d.ts +1245 -0
  14. package/dist/commands/test.js +6214 -0
  15. package/dist/commands/usage.d.ts +63 -0
  16. package/dist/commands/usage.js +156 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.js +146 -0
  19. package/dist/lib/agent-targets.d.ts +50 -0
  20. package/dist/lib/agent-targets.js +99 -0
  21. package/dist/lib/bundle.d.ts +178 -0
  22. package/dist/lib/bundle.js +600 -0
  23. package/dist/lib/client-factory.d.ts +72 -0
  24. package/dist/lib/client-factory.js +120 -0
  25. package/dist/lib/config.d.ts +24 -0
  26. package/dist/lib/config.js +30 -0
  27. package/dist/lib/credentials.d.ts +17 -0
  28. package/dist/lib/credentials.js +122 -0
  29. package/dist/lib/dry-run/fetch.d.ts +18 -0
  30. package/dist/lib/dry-run/fetch.js +52 -0
  31. package/dist/lib/dry-run/samples.d.ts +50 -0
  32. package/dist/lib/dry-run/samples.js +676 -0
  33. package/dist/lib/errors.d.ts +118 -0
  34. package/dist/lib/errors.js +388 -0
  35. package/dist/lib/facade.d.ts +48 -0
  36. package/dist/lib/facade.js +104 -0
  37. package/dist/lib/failing-fe-resolver.d.ts +60 -0
  38. package/dist/lib/failing-fe-resolver.js +103 -0
  39. package/dist/lib/http.d.ts +255 -0
  40. package/dist/lib/http.js +608 -0
  41. package/dist/lib/output.d.ts +55 -0
  42. package/dist/lib/output.js +70 -0
  43. package/dist/lib/pagination.d.ts +56 -0
  44. package/dist/lib/pagination.js +81 -0
  45. package/dist/lib/poll.d.ts +88 -0
  46. package/dist/lib/poll.js +221 -0
  47. package/dist/lib/prompt.d.ts +8 -0
  48. package/dist/lib/prompt.js +97 -0
  49. package/dist/lib/rate-throttle.d.ts +49 -0
  50. package/dist/lib/rate-throttle.js +75 -0
  51. package/dist/lib/render-error.d.ts +15 -0
  52. package/dist/lib/render-error.js +44 -0
  53. package/dist/lib/runs.types.d.ts +344 -0
  54. package/dist/lib/runs.types.js +25 -0
  55. package/dist/lib/target-url.d.ts +25 -0
  56. package/dist/lib/target-url.js +127 -0
  57. package/dist/lib/ticker.d.ts +37 -0
  58. package/dist/lib/ticker.js +63 -0
  59. package/dist/lib/validate.d.ts +82 -0
  60. package/dist/lib/validate.js +165 -0
  61. package/dist/version.d.ts +1 -0
  62. package/dist/version.js +2 -0
  63. package/package.json +65 -0
@@ -0,0 +1,423 @@
1
+ # TestSprite Verification Loop
2
+
3
+ The verification loop that flies your just-shipped feature through the
4
+ TestSprite CLI and reports back.
5
+
6
+ You just finished a piece of work in a TestSprite-tested repo. Before you report
7
+ it done, **actually run the relevant TestSprite test(s)** through the `testsprite`
8
+ CLI and read the result. Spec review and unit tests catch correctness; only
9
+ running the test catches what breaks for a real user.
10
+
11
+ ## When to run
12
+
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.
18
+
19
+ The CLI tests a **deployed** URL — it doesn't build or host your environment.
20
+ Run the loop only once the change is live somewhere reachable (e.g. open the PR,
21
+ let CI deploy the preview/staging environment) and pass that URL as
22
+ `--target-url`. Running earlier verifies the previous build, not your change.
23
+
24
+ ## When to skip
25
+
26
+ The skip list is narrow:
27
+
28
+ - Docs-only edits (`docs/**`, `*.md`, comments).
29
+ - Pure build/config edits (`tsconfig*`, lint/prettier config, lockfile bumps with
30
+ no behavior change).
31
+ - This repo isn't actually wired to TestSprite (no project linked, no creds).
32
+ Don't pull the user into a setup flow they didn't ask for — say so and stop.
33
+
34
+ Otherwise, run it.
35
+
36
+ ## The one-test minimum
37
+
38
+ Every shipped feature gets **at least one** TestSprite run to a terminal verdict
39
+ (`passed` / `failed` / `blocked` / `inconclusive`) before you call it done. What
40
+ counts:
41
+
42
+ - `testsprite test create … --run --wait` returning a terminal verdict, **or**
43
+ - `testsprite test run <id> --wait` against an existing test, **or**
44
+ - `testsprite test create-batch --plans plans.jsonl --run --wait` (or
45
+ two-step: create-batch, then `test run <id> --wait`) on at least one
46
+ test returning a terminal verdict.
47
+
48
+ What does **not** count: unit tests / typecheck / lint; drafting a plan without
49
+ `--run`; asking the user to run it for you.
50
+
51
+ If you can't satisfy this — no creds, no valid target URL, repo not linked —
52
+ **say so explicitly**: "Feature shipped but I could not run any TestSprite test
53
+ because <X>. Treat this as unverified until that's resolved." Don't claim done.
54
+
55
+ ## 1. Preflight
56
+
57
+ ```bash
58
+ testsprite --version # CLI installed?
59
+ testsprite auth whoami # credentials configured?
60
+ ```
61
+
62
+ - `--version` fails → the CLI isn't installed. Tell the user to install the
63
+ TestSprite CLI (see the TestSprite docs) and stop; don't install it for them.
64
+ - `auth whoami` fails → no credentials. Tell the user they can run
65
+ `testsprite auth configure`, then stop.
66
+
67
+ ## 2. Find the project
68
+
69
+ In priority order:
70
+
71
+ 1. `$TESTSPRITE_PROJECT_ID` if set.
72
+ 2. `.testsprite/config.json` in the repo root, if it has a `projectId`.
73
+ 3. `testsprite project list --output json` → match a project whose `name` looks
74
+ like this repo (e.g. a `Portal` repo → the `Portal` project).
75
+ 4. Still ambiguous → list the candidates and ask the user which to use (one short
76
+ question; picking the wrong project wastes a run).
77
+
78
+ ## 3. Decide what to test
79
+
80
+ Look at the diff (`git diff --stat`, then the changed files) to understand what
81
+ user-facing behavior changed. Pick one sub-mode. For a brand-new feature the
82
+ right default is almost always (b) or (c); (a) is for tweaks to behavior an
83
+ existing test already covers.
84
+
85
+ ### (a) An existing test covers the change
86
+
87
+ ```bash
88
+ testsprite test list --project <projectId> --output json
89
+ testsprite test list --project <projectId> --status failed --output json # what's already red
90
+ ```
91
+
92
+ Heuristic: a change to `src/components/CheckoutForm.tsx` is more likely covered
93
+ by "Checkout happy path" than "Login flow." Frontend change → `type: frontend`;
94
+ backend → `type: backend`.
95
+
96
+ ### (b) A new test for the change (most common)
97
+
98
+ **Frontend — draft a `plan.json`.** You name the behavior and list steps in plain
99
+ language; you don't write browser code.
100
+
101
+ ```jsonc
102
+ {
103
+ "projectId": "prj_abc",
104
+ "type": "frontend",
105
+ "name": "Booking date range change updates the estimated total",
106
+ "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.",
107
+ "priority": "p1",
108
+ "planSteps": [
109
+ { "type": "action", "description": "Navigate to the homepage" },
110
+ { "type": "action", "description": "Search for stays with a valid destination and date range" },
111
+ { "type": "action", "description": "Open a listing from the search results" },
112
+ {
113
+ "type": "action",
114
+ "description": "Select an initial short date range to view the estimated total",
115
+ },
116
+ { "type": "action", "description": "Change the date range to a longer stay" },
117
+ {
118
+ "type": "assertion",
119
+ "description": "Verify the estimated total on the booking panel updates from the initial value to reflect the new longer dates",
120
+ },
121
+ ],
122
+ }
123
+ ```
124
+
125
+ - `name` — an assertable behavior statement (subject + verb + outcome), not a noun
126
+ fragment — e.g. "Booking date range change updates the estimated total" tells
127
+ the testing agent what to verify; "date range" tells it nothing.
128
+ - `description` — the condition + expected outcome in one sentence; disambiguates
129
+ a short name.
130
+ - `priority` — `p0` (must-pass) / `p1` (important paths) / `p2` (edge) / `p3`
131
+ (cosmetic). Pick honestly.
132
+ - `planSteps` — `Array<{ type: 'action' | 'assertion', description: string }>`,
133
+ max 200 steps / 256 KB. Describe user intent, not selectors.
134
+
135
+ **Backend — write the Python yourself and use `--code-file`.** There is no
136
+ server-side codegen on the CLI. Read the API surface that changed (OpenAPI, the
137
+ route handler, request/response shapes) and write a pytest-style assertion script
138
+ to a tempfile:
139
+
140
+ ```python
141
+ # /tmp/login-empty-password.py — runs against the project's target URL, creds injected.
142
+ import requests
143
+
144
+ def test_login_rejects_empty_password():
145
+ r = requests.post(f"{TARGET_URL}/login", json={"email": "a@b.c", "password": ""})
146
+ assert r.status_code == 400
147
+ assert r.json().get("error") == "invalid password"
148
+ ```
149
+
150
+ **Backend tests that share state declare dependencies at create time.** For a
151
+ one-off verification, prefer a single self-contained script (log in inside the
152
+ same file). But when the coverage set splits naturally into producer → consumer
153
+ → cleanup — one test captures an auth token or created-resource id that others
154
+ reuse — declare the graph with the dependency flags instead of duplicating setup
155
+ in every file:
156
+
157
+ ```bash
158
+ # producer — captures a variable for later waves
159
+ testsprite test create --type backend --project <projectId> --name "login issues an auth token" \
160
+ --code-file /tmp/login.py --produces auth_token
161
+
162
+ # consumer — scheduled in a wave after every producer it names
163
+ testsprite test create --type backend --project <projectId> --name "profile update accepts the issued token" \
164
+ --code-file /tmp/profile.py --needs auth_token
165
+
166
+ # cleanup — always scheduled in the final wave
167
+ testsprite test create --type backend --project <projectId> --name "fixture user is deleted" \
168
+ --code-file /tmp/cleanup.py --category teardown
169
+ ```
170
+
171
+ - `--produces <var>` / `--needs <var>` are repeatable. All three flags are
172
+ **backend-only** — combined with `--type frontend` the CLI exits 5.
173
+ - **Don't hand-sequence `test run` calls to fake ordering.** The wave engine owns
174
+ ordering: trigger the set with `test run --all` (§4) and producers run before
175
+ consumers, `teardown` last. Chaining `run A --wait && run B --wait` yourself
176
+ loses the engine's variable passing and conflicts with concurrent runs.
177
+ - **Declarations are currently create-only.** `test update` cannot amend them and
178
+ `test get` / `test list` don't echo them back, so note what each test
179
+ produces/needs as you create it; changing the graph later means delete +
180
+ recreate.
181
+
182
+ **Show the user the drafted plan / code before creating it** — creating writes to
183
+ their project. One short confirmation; let them edit the tempfile first.
184
+
185
+ #### Authoring planSteps the testing agent will execute reliably
186
+
187
+ Execution reliability tracks plan wording. A loose plan produces a
188
+ confidently-wrong `passed` (bare visibility assertions) or a thrashing
189
+ `blocked`. Write to these rules first:
190
+
191
+ - **One verb per step.** `and` / `then` between two verbs → split — e.g.
192
+ "Search for stays and open the first result" becomes two steps.
193
+ - **Describe outcomes, not selectors.** The testing agent locates targets
194
+ semantically — describe the intent and the match stays robust across copy
195
+ changes; a guessed literal label defeats that. E.g. write `"Submit the form"`,
196
+ not `"Click the blue 'Submit' button"`.
197
+ - **`Navigate to` only on step 1** (or a login page). Use clicks for every later
198
+ transition — direct URLs break SPA routing.
199
+ - **FE plans narrate a user journey through their actions.** Each action is
200
+ what a real user does (click, type, navigate, hover, scroll), forming a
201
+ sequence that exercises what gives the feature its value. The final assertion
202
+ verifies what the journey produced — the state the user arrived at, a
203
+ comparison against an earlier state, a derived count — not just that the
204
+ starting page rendered.
205
+ - **Name the target entity type, not a fuzzy noun.** If a page has several
206
+ look-alike row kinds, "open a thing" lets the testing agent pick the wrong
207
+ kind. Name the type and the page/view you expect to land on.
208
+ - **1–2 assertions, at the end, on whether the content is present _and actually
209
+ works_** (see _presence ≠ working_ below) rather than UI copy / formatting.
210
+ (Quoting a literal you submitted earlier in the same plan, to verify it
211
+ round-trips, is fine.)
212
+ - **Presence ≠ working.** A node can exist yet be broken or wrong — e.g. an
213
+ `<img>` whose `src` 404s renders a broken-image box but still passes "element
214
+ present / has alt." Assert the thing actually **works and is correct**, not
215
+ just that the tag exists; trust the testing agent to judge correctness rather
216
+ than hard-coding the expected answer into the assertion.
217
+ - **Assertion targets name the specific page region** (panel / tab / output area).
218
+ Otherwise the testing agent settles for "some element with that text is
219
+ visible anywhere," which passes for wrong reasons.
220
+ - **For visual / CSS / layout-sensitive features, content-presence-only
221
+ assertions are dangerous.** "Verify the methodology section is visible" passes
222
+ even when the stylesheet is missing and three cards render as flat unstyled
223
+ text stacked vertically — the strings exist on the page, and a content-presence
224
+ assertion constrains nothing about layout. For any feature whose value depends on
225
+ layout, include at least one assertion that names geometry or relative
226
+ position (row, column, side-by-side, stacked, grid, above/below, span, card
227
+ background, border), not just content existence:
228
+
229
+ ```jsonc
230
+ // BEFORE — content-presence-only (passes even on broken CSS)
231
+ { "type": "assertion", "description": "Verify the methodology section with three sub-score formulas is visible" }
232
+
233
+ // AFTER — content + layout
234
+ { "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" }
235
+ ```
236
+
237
+ - **Keep `description` and `planSteps` in scope agreement** — the testing agent
238
+ reads `description` as the test's purpose and shrinks execution to match. If
239
+ you change the steps, re-align the description.
240
+ - **Keep flows that depend on state outside the test's control out of scope:**
241
+ third-party auth (OAuth/SSO/2FA), OS-native surfaces (file upload/download,
242
+ drag-and-drop, native dialogs), cross-context state (iframes, multi-tab,
243
+ external services). Pick a different verification.
244
+ - **Test data must be self-contained** — create what you need within the plan, or
245
+ don't write the plan.
246
+
247
+ ### (c) A coverage set — multiple FE plans as a batch
248
+
249
+ When a FE feature has distinct paths (happy + error + edge), draft a
250
+ `plans.jsonl`, one spec per line. Aim for 2–5 plans; more only with explicit user
251
+ confirmation. Max 50 plans / 5 MB per batch.
252
+
253
+ ```jsonc
254
+ // plans.jsonl — FE only
255
+ {"projectId":"prj_abc","type":"frontend","name":"login happy path","planSteps":[...]}
256
+ {"projectId":"prj_abc","type":"frontend","name":"login wrong password","planSteps":[...]}
257
+ {"projectId":"prj_abc","type":"frontend","name":"login empty email","planSteps":[...]}
258
+ ```
259
+
260
+ Batch is **FE-only.** For 3 backend tests, run `test create --type backend
261
+ --project <projectId> --code-file <file>` three times with three Python files.
262
+
263
+ ### (d) Refine an existing test
264
+
265
+ - **FE** — replace the steps, then re-run:
266
+ ```bash
267
+ testsprite test plan put <test-id> --steps refined.json
268
+ ```
269
+ - **BE** — write updated Python and replace the code (optimistic concurrency):
270
+ ```bash
271
+ testsprite test code put <test-id> --code-file refined.py --expected-version <current-version>
272
+ ```
273
+
274
+ ## 4. Run
275
+
276
+ All variants use `--wait` for a synchronous verdict, `--target-url <env-url>` for
277
+ the deployment under test, and `--timeout 600` as a sane default.
278
+
279
+ ```bash
280
+ # (a) existing test
281
+ testsprite test run <test-id> --target-url <env-url> --wait --timeout 600 --output json
282
+
283
+ # (a-rerun) cheap replay of an existing test. FE: replays the saved script (auto-heal on — more
284
+ # lenient than a fresh run; for strict verification of a new change prefer `test run`).
285
+ # BE: dispatches the WHOLE dependency closure — producers and teardowns run too, not just <test-id>,
286
+ # so expect their side effects (fixtures re-created, teardown deletes) and extra runs in history.
287
+ testsprite test rerun <test-id> --wait --timeout 600 --output json
288
+ testsprite test rerun <test-id> --skip-dependencies --wait --timeout 600 # BE: named test only
289
+
290
+ # (b-FE) new FE test from plan
291
+ testsprite test create --plan-from plan.json --run --wait --target-url <env-url> --timeout 600
292
+
293
+ # (b-BE) new BE test from Python (backend create needs --project)
294
+ testsprite test create --type backend --name "..." --project <projectId> --code-file foo.py --run --wait --target-url <env-url> --timeout 600
295
+
296
+ # (b-BE coverage set with dependencies) create each test without --run, then one wave-ordered batch
297
+ testsprite test run --all --project <projectId> --wait --timeout 600 --output json
298
+ testsprite test run --all --project <projectId> --filter <name-substr> --wait --timeout 600 # subset by name
299
+
300
+ # (c) FE coverage set — single-call create + run (FE-only)
301
+ testsprite test create-batch --plans plans.jsonl --run --wait \
302
+ --target-url <env-url> --max-concurrency 3 --timeout 600 --output json
303
+ # Two-step alternative (inspect before running):
304
+ # testsprite test create-batch --plans plans.jsonl --output json
305
+ # then trigger each id: testsprite test run <test-id> --wait --target-url <env-url> --timeout 600
306
+
307
+ # (d-FE) refine + re-run
308
+ testsprite test plan put <test-id> --steps refined.json && \
309
+ testsprite test run <test-id> --target-url <env-url> --wait --timeout 600
310
+
311
+ # (d-BE) refine BE code + re-run. NOTE: if you reach for `test rerun` here instead, a BE rerun
312
+ # dispatches the full producer/teardown closure — use --skip-dependencies while iterating on one
313
+ # script (producers already verified this round), then finish with a closure run before reporting.
314
+ testsprite test code put <test-id> --code-file refined.py --expected-version <current-version> && \
315
+ testsprite test run <test-id> --target-url <env-url> --wait --timeout 600
316
+ ```
317
+
318
+ Key behaviors:
319
+
320
+ - `--target-url` must be an allowed project/environment URL. The CLI rejects
321
+ `localhost` / RFC1918 / link-local — local-only changes can't be run here. If
322
+ the feature is deployed only locally, say so and skip the run.
323
+ - `--wait` long-polls until terminal and handles its own backoff — don't wrap it
324
+ in a retry loop.
325
+ - Exit codes: `0` = passed; `1` = failed / blocked / cancelled; `7` = timeout.
326
+ Treat `7` as inconclusive (resume with `testsprite test wait <run-id>`), not a
327
+ regression.
328
+ - Batch: `create-batch --run --wait` creates the tests (FE-only) and fans
329
+ out triggers in one call (bounded by `--max-concurrency`), emitting
330
+ `{ results: [...] }` that mirrors the single-test `test run --wait`
331
+ envelope. Exit `0` if every run passed; `1` for any failed/blocked/
332
+ cancelled or trigger error; `7` only when EVERY run timed out. Drop
333
+ `--run` if you want to inspect the created tests before triggering.
334
+ - Run-trigger rate limit is 60/min/key, server-enforced; the CLI self-throttles
335
+ to 50/min. `--max-concurrency` (default 50) does NOT raise the server cap —
336
+ excess triggers return `RATE_LIMITED` (per-spec in batch JSON; exit 11 for
337
+ single `test run`). The test row stays created, the run never started. A full
338
+ `create-batch` (≤50 specs) fires all at once under the cap. The 50/min throttle
339
+ is per-invocation — separate batches/processes don't share it — so for >50 specs
340
+ in a minute you lean on the server's 60/min cap + `RATE_LIMITED` retries, not
341
+ client queuing. Re-list and check `draft` rows — "tests created" is
342
+ not the same as "runs triggered".
343
+ - **Backend execution is dependency-aware; frontend is not.** `test run --all
344
+ --project <id>` triggers a fresh wave-ordered batch over the project's backend
345
+ tests (producers → consumers → `teardown` last); FE tests in the project are
346
+ skipped with an advisory, and everything not dispatched is enumerated
347
+ (`conflicts` / `deferred` / `skippedFrontend`) so don't count `accepted[]`
348
+ alone. `test rerun <be-id>` expands the producer/teardown closure by default —
349
+ stderr summarizes `Reran N tests: 1 selected + P producer(s) + T teardown(s)`,
350
+ and failed members surface as `closureFailures[]` without flipping the exit
351
+ code. Pass `--skip-dependencies` only when this round already verified the
352
+ producers and you're iterating fast on one script.
353
+ - `test code put` needs `--expected-version <codeVersion>`; stale etag → exit 6,
354
+ re-fetch via `test get <id>` and retry. `--force` bypasses but is audit-logged.
355
+ - Idempotency: the CLI auto-mints an `Idempotency-Key`; replays within 24h return
356
+ the original test/run.
357
+
358
+ ## 4a. Read the result — plan, or product?
359
+
360
+ Don't take the verdict at face value. After a run, pull the steps
361
+ (`testsprite test steps <test-id> --output json`) and ask: **plan quality, or
362
+ actual product behavior?**
363
+
364
+ The plan is the problem (most common — check first) when:
365
+
366
+ - recorded action count < plan action count → steps the plan left ambiguous were
367
+ skipped;
368
+ - assertions degraded to bare "Verify element is visible" with no subject;
369
+ - 5+ consecutive click attempts on similar targets with no progress.
370
+
371
+ The product/environment is the problem (believe these) when:
372
+
373
+ - `cause` / `error` names a concrete app observation ("the panel renders
374
+ read-only", "page 404s");
375
+ - the trace blames infra (deploy lag, auth gate, missing fixture).
376
+
377
+ Scope step counts to the **current run** — `test steps` is cumulative across runs;
378
+ filter on the run-id before counting.
379
+
380
+ **Read the testing agent's failure summary skeptically — it can conflate two
381
+ failure phases.** When a flow produces an artifact that then runs against an external
382
+ target, "the backend returned an error" may mean the action endpoint itself
383
+ failed (feature broken) **or** the action succeeded and the produced artifact
384
+ failed later at runtime (orthogonal to your feature). Cross-check the step trace
385
+ and runtime output: if the runtime output references a literal you submitted
386
+ earlier in the plan, the action succeeded and the error is runtime-phase.
387
+
388
+ **BE closure runs: root-cause the earliest failed wave, not the selected test.**
389
+ When a rerun or `run --all` expanded a dependency closure and a **producer**
390
+ failed, every consumer downstream of it fails or blocks by starvation (missing
391
+ token / missing fixture). The selected test's red verdict does not implicate
392
+ your feature — report it as failed-downstream, pull the producer's artifact
393
+ first, and only blame the consumer once its producers pass in the same run.
394
+
395
+ If it's the plan: tighten via `test plan put` and re-run **once** (two runs total),
396
+ then stop. Don't grind. If it's the product/env: report the verdict with the
397
+ testing agent's observation; don't auto-fix on the recommendation alone. If you
398
+ genuinely can't tell: report `inconclusive` with the signal that triggered the
399
+ call and ask.
400
+
401
+ ## 5. On failure → download the artifact
402
+
403
+ ```bash
404
+ testsprite test artifact get <run-id> --out ./.testsprite/runs/<run-id>/
405
+ ```
406
+
407
+ Inspect the failure bundle (result, failed step + neighbors, video, root-cause
408
+ hypothesis, recommended fix target) before deciding whether your change caused it.
409
+
410
+ ## 6. Report
411
+
412
+ When you tell the user the feature is done, include:
413
+
414
+ - Which test(s) you ran — one line each: id, name, verdict. At least one terminal
415
+ verdict is required; zero means the feature is **not** done — surface that.
416
+ - The verdict. Don't report `passed` if §4a's sanity check tripped — surface as
417
+ `inconclusive` with the specific signal.
418
+ - If the user wants to inspect a test or run themselves, point them at the
419
+ dashboard link from the CLI output (`dashboardUrl` in JSON; a `Dashboard:` line
420
+ in text mode) — `test create` and `--wait` terminal output carry one.
421
+ - If failed, a one-line summary of the bundle's root-cause hypothesis and
422
+ recommended fix target. **Don't auto-fix** on that alone — the recommendation
423
+ can be wrong; the human should look.
@@ -0,0 +1,51 @@
1
+ import { Command } from 'commander';
2
+ import type { CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
3
+ import { type AgentTarget } from '../lib/agent-targets.js';
4
+ /**
5
+ * Codex loads AGENTS.md files lazily and has a documented 32 KiB load budget
6
+ * per file. Content beyond that offset is silently truncated. We warn (but do
7
+ * not refuse to write) when a managed-section write would produce a file larger
8
+ * than this threshold so operators have early visibility.
9
+ */
10
+ export declare const AGENTS_MD_CODEX_BUDGET_BYTES = 32768;
11
+ export interface AgentFs {
12
+ lstat(p: string): Promise<{
13
+ isFile: boolean;
14
+ isSymbolicLink: boolean;
15
+ } | null>;
16
+ readFile(p: string): Promise<string>;
17
+ writeFile(p: string, data: string, opts?: {
18
+ exclusive?: boolean;
19
+ }): Promise<void>;
20
+ mkdir(p: string): Promise<void>;
21
+ }
22
+ export interface AgentDeps {
23
+ cwd?: string;
24
+ fs?: AgentFs;
25
+ stdout?: (line: string) => void;
26
+ stderr?: (line: string) => void;
27
+ isTTY?: boolean;
28
+ prompt?: (question: string) => Promise<string>;
29
+ }
30
+ export type InstallAction = 'written' | 'skipped' | 'blocked' | 'updated' | 'dry-run' | 'section-installed' | 'section-updated' | 'section-unchanged';
31
+ export interface InstallResult {
32
+ target: AgentTarget;
33
+ path: string;
34
+ action: InstallAction;
35
+ }
36
+ type CommonOptions = FactoryCommonOptions;
37
+ interface InstallOptions extends CommonOptions {
38
+ target: string[];
39
+ dir?: string;
40
+ force: boolean;
41
+ }
42
+ export declare function runInstall(opts: InstallOptions, deps?: AgentDeps): Promise<void>;
43
+ export interface ListResult {
44
+ target: AgentTarget;
45
+ status: string;
46
+ mode: string;
47
+ path: string;
48
+ }
49
+ export declare function runList(opts: CommonOptions, deps?: AgentDeps): Promise<void>;
50
+ export declare function createAgentCommand(deps?: AgentDeps): Command;
51
+ export {};