@testsprite/testsprite-cli 0.11.0 → 0.13.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 (99) hide show
  1. package/README.md +52 -44
  2. package/dist/commands/agent.js +16 -13
  3. package/dist/commands/auth.d.ts +19 -0
  4. package/dist/commands/auth.js +60 -24
  5. package/dist/commands/ci.d.ts +86 -1
  6. package/dist/commands/ci.js +470 -9
  7. package/dist/commands/doctor.d.ts +2 -0
  8. package/dist/commands/doctor.js +22 -9
  9. package/dist/commands/init.js +14 -11
  10. package/dist/commands/project-env.d.ts +90 -0
  11. package/dist/commands/project-env.js +486 -0
  12. package/dist/commands/project.d.ts +15 -5
  13. package/dist/commands/project.js +88 -92
  14. package/dist/commands/schedule.d.ts +2 -0
  15. package/dist/commands/schedule.js +18 -10
  16. package/dist/commands/test.d.ts +102 -30
  17. package/dist/commands/test.js +1949 -419
  18. package/dist/commands/testlist.js +77 -21
  19. package/dist/commands/tunnel.d.ts +26 -3
  20. package/dist/commands/tunnel.js +211 -14
  21. package/dist/commands/usage.d.ts +3 -0
  22. package/dist/commands/usage.js +12 -5
  23. package/dist/index.js +47 -23
  24. package/dist/lib/agent-targets.d.ts +3 -3
  25. package/dist/lib/agent-targets.js +2 -2
  26. package/dist/lib/billing-refusal.d.ts +43 -0
  27. package/dist/lib/billing-refusal.js +171 -0
  28. package/dist/lib/bundle.d.ts +5 -0
  29. package/dist/lib/bundle.js +43 -13
  30. package/dist/lib/ci-linkage.d.ts +90 -0
  31. package/dist/lib/ci-linkage.js +181 -0
  32. package/dist/lib/client-factory.d.ts +4 -1
  33. package/dist/lib/client-factory.js +25 -2
  34. package/dist/lib/client-tag.d.ts +13 -0
  35. package/dist/lib/client-tag.js +44 -0
  36. package/dist/lib/config.d.ts +17 -0
  37. package/dist/lib/config.js +20 -1
  38. package/dist/lib/conflict-reason.d.ts +67 -2
  39. package/dist/lib/conflict-reason.js +148 -13
  40. package/dist/lib/credentials.js +56 -14
  41. package/dist/lib/cron.js +8 -1
  42. package/dist/lib/dry-run/samples.d.ts +13 -1
  43. package/dist/lib/dry-run/samples.js +51 -7
  44. package/dist/lib/errors.d.ts +62 -12
  45. package/dist/lib/errors.js +180 -25
  46. package/dist/lib/failing-fe-resolver.d.ts +1 -1
  47. package/dist/lib/failing-fe-resolver.js +3 -3
  48. package/dist/lib/gh-output.d.ts +26 -11
  49. package/dist/lib/gh-output.js +47 -15
  50. package/dist/lib/history-retention.d.ts +8 -0
  51. package/dist/lib/history-retention.js +24 -0
  52. package/dist/lib/http.d.ts +44 -19
  53. package/dist/lib/http.js +53 -26
  54. package/dist/lib/interrupt.d.ts +21 -13
  55. package/dist/lib/interrupt.js +32 -21
  56. package/dist/lib/junit-report.d.ts +11 -1
  57. package/dist/lib/junit-report.js +15 -3
  58. package/dist/lib/local-target.d.ts +33 -1
  59. package/dist/lib/local-target.js +78 -1
  60. package/dist/lib/output.d.ts +27 -1
  61. package/dist/lib/output.js +22 -3
  62. package/dist/lib/plan-poll.d.ts +11 -11
  63. package/dist/lib/plan-poll.js +12 -12
  64. package/dist/lib/plans.types.d.ts +9 -9
  65. package/dist/lib/plans.types.js +3 -3
  66. package/dist/lib/poll.d.ts +2 -2
  67. package/dist/lib/poll.js +9 -3
  68. package/dist/lib/render-error.d.ts +2 -0
  69. package/dist/lib/render-error.js +13 -0
  70. package/dist/lib/response-schemas.d.ts +54 -12
  71. package/dist/lib/response-schemas.js +106 -7
  72. package/dist/lib/runs.types.d.ts +92 -6
  73. package/dist/lib/secret-file.js +72 -14
  74. package/dist/lib/skill-nudge.d.ts +6 -1
  75. package/dist/lib/skill-nudge.js +32 -5
  76. package/dist/lib/target-url-preflight.d.ts +6 -4
  77. package/dist/lib/target-url-preflight.js +64 -51
  78. package/dist/lib/target-url.js +31 -12
  79. package/dist/lib/telemetry.d.ts +172 -3
  80. package/dist/lib/telemetry.js +276 -15
  81. package/dist/lib/ticker.js +93 -4
  82. package/dist/lib/tunnel-session.d.ts +13 -0
  83. package/dist/lib/tunnel-session.js +4 -1
  84. package/dist/lib/tunnel.types.d.ts +12 -2
  85. package/dist/lib/tunnel.types.js +2 -2
  86. package/dist/lib/version-notice.d.ts +20 -1
  87. package/dist/lib/version-notice.js +59 -12
  88. package/dist/lib/wait-exit.d.ts +8 -0
  89. package/dist/lib/wait-exit.js +76 -4
  90. package/dist/lib/workspace-status.d.ts +23 -0
  91. package/dist/lib/workspace-status.js +15 -0
  92. package/dist/version-guard.d.ts +7 -1
  93. package/dist/version-guard.js +19 -1
  94. package/dist/version.d.ts +1 -1
  95. package/dist/version.js +1 -1
  96. package/package.json +4 -4
  97. package/skills/testsprite-onboard.skill.md +4 -4
  98. package/skills/testsprite-verify.codex.md +59 -57
  99. package/skills/testsprite-verify.skill.md +53 -36
@@ -19,17 +19,19 @@ duplicating.
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
21
21
  change, wait until it's live somewhere reachable (e.g. open the PR, let CI
22
- deploy the preview/staging environment) and pass that URL as `--target-url`.
23
- Running earlier verifies the previous build, not your change.
22
+ deploy the preview/staging environment). Create a named environment for its
23
+ public URL once, then select it with `--env <name>` on runs. Running earlier
24
+ verifies the previous build, not your change.
24
25
 
25
26
  For a change that is only running locally, don't wait for a deployment: run
26
27
  `testsprite test run <test-id> --local <port>` instead. It tunnels this
27
28
  machine's own loopback address (`localhost` / `127.0.0.1` / `::1` — not a LAN
28
29
  or RFC1918 address, and not a general local-network escape hatch) to the test
29
- runner. Two constraints: frontend tests only (a backend test's target is baked
30
- into its generated code, so run it normally), and it needs an API key with the
31
- `run:tunnel` scope. Keys minted before that scope existed must be replaced;
32
- the CLI names the missing scope (exit 3).
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).
33
35
 
34
36
  If the user explicitly named a tool (the CLI or the MCP), honor that choice
35
37
  regardless of which one the change's reachability would otherwise suggest.
@@ -100,7 +102,7 @@ If no project exists for an app running only locally, bootstrap a frontend proje
100
102
  ```bash
101
103
  testsprite project create --type frontend --name "<repo name>" --local <port> --local-host <host>
102
104
  testsprite test create --plan-from plan.json --project <projectId>
103
- testsprite test run <test-id> --local <port> --local-host <host> --output json
105
+ testsprite test run <id> <id> --local <port> --local-host <host> --output json
104
106
  ```
105
107
 
106
108
  Keep the app listening and use the same `--local-host` for creation and follow-up
@@ -110,8 +112,8 @@ The port probe fails with exit 5 if nothing listens (`--skip-preflight`
110
112
  bypasses it). Local projects skip exploration: `test plan generate` is refused
111
113
  before charge (exit 6), so use `test create --plan-from` without `--run`, then
112
114
  `test run --local`. V2-only local-project creation is unsupported (exit 7).
113
- Portal runs are blocked for free until `project update <id> --url https://…`
114
- sets a public URL. Keep the existing `--url` / `--target-url` flow for deployed apps.
115
+ The Portal shows local environments without a Run action. Create a public
116
+ environment for deployed apps and select it with `--env <name>`.
115
117
 
116
118
  ## 3. Decide what to test
117
119
 
@@ -366,73 +368,83 @@ Batch is **FE-only.** For 3 backend tests, run `test create --type backend
366
368
 
367
369
  ## 4. Run
368
370
 
369
- For a deployed target, use `--target-url <env-url> --wait --timeout 600` after
370
- that deployment contains the change. For a change running only on this machine,
371
+ For a deployed target, create its environment once, then use `--env <name>`
372
+ after that deployment contains the change. Omit `--env` for Default; an unknown
373
+ name fails with available names and never falls back. For a local change,
371
374
  use `testsprite test run <test-id> --local <port>` (frontend only); it implies
372
375
  waiting and defaults to 1200 seconds. Create a missing test from a plan first,
373
376
  without `--run`, then run its id with `--local`.
374
377
 
375
378
  ```bash
379
+ # One-time setup for a deployed target
380
+ testsprite project env create <projectId> --name staging --url https://staging.example.com
381
+
376
382
  # (a) existing test
377
- testsprite test run <test-id> --target-url <env-url> --wait --timeout 600 --output json
383
+ testsprite test run <test-id> --env staging --wait --timeout 600 --output json
378
384
 
379
385
  # (a-rerun) replay of a deployed test (V3 FE: 0.5 credit). Replays saved code (auto-heal on — more
380
386
  # lenient than a fresh run; for strict verification of a new change prefer `test run`).
381
387
  # BE: dispatches the WHOLE dependency closure — producers and teardowns run too, not just <test-id>,
382
388
  # so expect their side effects (fixtures re-created, teardown deletes) and extra runs in history.
383
- testsprite test rerun <test-id> --wait --timeout 600 --output json
389
+ testsprite test rerun <test-id> --env staging --wait --timeout 600 --output json
384
390
  testsprite test rerun <test-id> --skip-dependencies --wait --timeout 600 # BE: named test only
385
391
 
386
392
  # (b-FE) new FE test from plan
387
- testsprite test create --plan-from plan.json --run --wait --target-url <env-url> --timeout 600
393
+ testsprite test create --plan-from plan.json --run --wait --env staging --timeout 600
388
394
 
389
395
  # (b-BE) new BE test from Python (backend create needs --project)
390
- testsprite test create --type backend --name "..." --project <projectId> --code-file foo.py --run --wait --target-url <env-url> --timeout 600
396
+ testsprite test create --type backend --name "..." --project <projectId> --code-file foo.py --run --wait --timeout 600
391
397
 
392
398
  # (b-BE coverage set with dependencies) create each test without --run, then one wave-ordered batch
393
- testsprite test run --all --project <projectId> --wait --timeout 600 --output json
399
+ testsprite test run --all --project <projectId> --env staging --wait --timeout 600 --output json
394
400
  testsprite test run --all --project <projectId> --filter <name-substr> --wait --timeout 600 # subset by name
395
401
 
396
402
  # (c) FE coverage set — single-call create + run (FE-only)
397
403
  testsprite test create-batch --plans plans.jsonl --run --wait \
398
- --target-url <env-url> --max-concurrency 3 --timeout 600 --output json
404
+ --env staging --max-concurrency 3 --timeout 600 --output json
399
405
  # Two-step alternative (inspect before running):
400
406
  # testsprite test create-batch --plans plans.jsonl --output json
401
- # then trigger each id: testsprite test run <test-id> --wait --target-url <env-url> --timeout 600
407
+ # then trigger each id: testsprite test run <test-id> --env staging --wait --timeout 600
402
408
 
403
409
  # (d-FE) refine + re-run
404
410
  testsprite test plan put <test-id> --steps refined.json && \
405
- testsprite test run <test-id> --target-url <env-url> --wait --timeout 600
411
+ testsprite test run <test-id> --env staging --wait --timeout 600
406
412
 
407
413
  # (d-BE) refine BE code + re-run. NOTE: if you reach for `test rerun` here instead, a BE rerun
408
414
  # dispatches the full producer/teardown closure — use --skip-dependencies while iterating on one
409
415
  # script (producers already verified this round), then finish with a closure run before reporting.
410
416
  testsprite test code put <test-id> --code-file refined.py --expected-version <current-version> && \
411
- testsprite test run <test-id> --target-url <env-url> --wait --timeout 600
417
+ testsprite test run <test-id> --env staging --wait --timeout 600
412
418
  ```
413
419
 
414
420
  Key behaviors:
415
421
 
416
- - `--target-url` must be an allowed project/environment URL. The CLI rejects
417
- `localhost` / RFC1918 / link-local there. If the feature is only running
418
- locally, use `--local <port>` instead of `--target-url` (frontend tests
419
- only, see "When to run" above) — don't skip the run over this.
422
+ - Environment `--url` must be public; the CLI rejects localhost, RFC1918 and
423
+ link-local addresses. For an app on this machine, use `--local <port>`
424
+ (frontend only). If the CLI can list the project's environments, a named
425
+ public environment plus `--local` fails before a tunnel opens; otherwise the
426
+ server refuses the same combination before dispatch. A local environment
427
+ without `--local` is refused before dispatch and costs nothing.
420
428
  - `--wait` long-polls until terminal and handles its own backoff — don't wrap it
421
429
  in a retry loop.
422
- - `--local` implies `--wait`, with a default timeout of 1200 seconds (ordinary
423
- waits default to 600). Run one frontend test per invocation; parallel
424
- invocations are fine, but `--all --local` is refused (exit 5). There are
430
+ - `--local` implies `--wait`, with a default timeout of 1200 seconds per run (ordinary
431
+ 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
425
432
  5 live tunnel bindings per user; `tunnel_binding_limit` is exit 11 and is not
426
433
  auto-retried. Reuse a live tunnel with `--tunnel-client` or stop an unused one.
427
- - Keep the early `Run <runId>` line on **stderr**, emitted as soon as the trigger
428
- returns; `Dashboard: <url>` follows when supplied. Preserve the id even if
434
+ On a tunnel-limit error, run `testsprite tunnel list`, then `testsprite tunnel stop <id>`
435
+ or `testsprite tunnel stop --all --confirm` if every binding should be revoked.
436
+ - 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
429
437
  the wait later stops; stdout remains the normal JSON result channel.
430
- - An **owned** local run is cancelled by default when waiting stops (timeout,
438
+ - An **owned** local run requests cancellation by default when waiting stops (timeout,
431
439
  Ctrl-C, or a polling failure), then its tunnel closes. Read the reported
432
- cancellation outcome. A run cancelled before it finished is refunded.
440
+ cancellation outcome. For a V3 frontend run cancelled before a terminal verdict,
441
+ the backend attempts a refund. Inspect `refund.status`; cancellation does not
442
+ guarantee a refund.
433
443
  `--no-cancel-on-interrupt` detaches instead, but the owned tunnel still closes.
434
- A borrower using `--tunnel-client` never automatically cancels its run or
435
- closes the adopted tunnel; its owner must remain running.
444
+ An adopted run normally detaches without cancellation and never closes the
445
+ owner's tunnel. If the CLI confirms the owner has disappeared while the run is
446
+ active, it requests cancellation by default; `--no-cancel-on-interrupt` skips
447
+ that request.
436
448
  A second `tunnel start` or process using the same credential takes over, and the first exits **10**.
437
449
  - Exit codes: `0` = passed; `1` = failed / blocked / cancelled; `7` = timeout
438
450
  or unsupported. An owned local timeout is inconclusive: start a **new**
@@ -440,9 +452,14 @@ Key behaviors:
440
452
  `--local-host <host>` if used; do not suggest `test wait` for that closed tunnel. Resume **ordinary or adopted-tunnel**
441
453
  waits with `testsprite test wait <run-id>` only while the target is reachable
442
454
  (and the adopted tunnel's owner remains alive).
443
- - A case last run through a tunnel stays local: a later Portal Run, schedule,
444
- or bare CLI run is a free BLOCKED (`tunnel-required`, exit 6). Use `--local`
445
- again or explicitly retarget with a public `--target-url`. V3 local runs use
455
+ - 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.
456
+ - A local environment has a loopback URL and needs `--local <port>` from that
457
+ machine. A bare CLI run selecting it, explicitly or as Default, is refused
458
+ before dispatch without charge (`tunnel-required`, exit 6). The Portal shows
459
+ local environments but offers no Run; backend Portal requests are refused
460
+ without charge. Schedules and test lists targeting them get a free BLOCKED
461
+ result. A deployed environment selected with `--env <name>` or made Default
462
+ runs normally even if the test ran through a tunnel before. V3 local runs use
446
463
  the agent path, never saved-code replay, and preserve the test's saved code.
447
464
  - Batch: `create-batch --run --wait` creates the tests (FE-only) and fans
448
465
  out triggers in one call (bounded by `--max-concurrency`), emitting