@testsprite/testsprite-cli 0.3.0 → 0.5.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/README.md +55 -29
  2. package/dist/commands/agent.js +17 -6
  3. package/dist/commands/auth.d.ts +51 -0
  4. package/dist/commands/auth.js +46 -2
  5. package/dist/commands/completion.d.ts +36 -0
  6. package/dist/commands/completion.js +111 -0
  7. package/dist/commands/doctor.js +56 -16
  8. package/dist/commands/init.d.ts +32 -1
  9. package/dist/commands/init.js +40 -10
  10. package/dist/commands/project.d.ts +102 -4
  11. package/dist/commands/project.js +250 -47
  12. package/dist/commands/test.d.ts +253 -11
  13. package/dist/commands/test.js +1822 -390
  14. package/dist/commands/usage.d.ts +56 -17
  15. package/dist/commands/usage.js +144 -29
  16. package/dist/index.js +172 -29
  17. package/dist/lib/browser.d.ts +6 -0
  18. package/dist/lib/browser.js +54 -0
  19. package/dist/lib/bundle.d.ts +32 -31
  20. package/dist/lib/bundle.js +144 -84
  21. package/dist/lib/client-factory.d.ts +29 -0
  22. package/dist/lib/client-factory.js +49 -1
  23. package/dist/lib/config.js +7 -3
  24. package/dist/lib/credentials.d.ts +17 -1
  25. package/dist/lib/credentials.js +175 -16
  26. package/dist/lib/dry-run/samples.js +51 -1
  27. package/dist/lib/errors.d.ts +33 -1
  28. package/dist/lib/errors.js +110 -19
  29. package/dist/lib/failing-fe-resolver.d.ts +15 -0
  30. package/dist/lib/failing-fe-resolver.js +49 -1
  31. package/dist/lib/flaky.d.ts +12 -1
  32. package/dist/lib/flaky.js +7 -12
  33. package/dist/lib/gh-output.d.ts +62 -0
  34. package/dist/lib/gh-output.js +99 -0
  35. package/dist/lib/http.d.ts +86 -16
  36. package/dist/lib/http.js +181 -11
  37. package/dist/lib/interrupt.d.ts +65 -10
  38. package/dist/lib/interrupt.js +94 -9
  39. package/dist/lib/org-render.d.ts +52 -0
  40. package/dist/lib/org-render.js +59 -0
  41. package/dist/lib/poll.d.ts +11 -0
  42. package/dist/lib/poll.js +71 -6
  43. package/dist/lib/render-error.d.ts +14 -0
  44. package/dist/lib/render-error.js +30 -0
  45. package/dist/lib/response-schemas.d.ts +83 -0
  46. package/dist/lib/response-schemas.js +272 -0
  47. package/dist/lib/runs.types.d.ts +62 -8
  48. package/dist/lib/skill-nudge.d.ts +17 -0
  49. package/dist/lib/skill-nudge.js +19 -0
  50. package/dist/lib/telemetry.d.ts +90 -0
  51. package/dist/lib/telemetry.js +171 -0
  52. package/dist/lib/text-table.d.ts +14 -0
  53. package/dist/lib/text-table.js +45 -0
  54. package/dist/lib/v3-advisory.d.ts +22 -0
  55. package/dist/lib/v3-advisory.js +32 -0
  56. package/dist/lib/version-notice.d.ts +37 -0
  57. package/dist/lib/version-notice.js +87 -0
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +1 -1
  60. package/package.json +16 -5
  61. package/schemas/plan.schema.json +61 -0
  62. package/skills/testsprite-verify.codex.md +8 -2
  63. package/skills/testsprite-verify.skill.md +18 -7
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Inline "your CLI is below the backend's minimum supported version" advisory.
3
+ *
4
+ * The backend advertises its supported floor on every `/api/cli/v1` response via
5
+ * the `X-TestSprite-CLI-Min-Version` header. Unlike the npm-registry update
6
+ * notice (`update-check.ts`, which runs in a Commander `preAction` hook before
7
+ * any HTTP request), this advisory reacts to a header observed *during* the
8
+ * request, so it is emitted from the HTTP layer's `onServerVersion` hook (wired
9
+ * in `client-factory.ts`) rather than the pre-request notifier — no cross-run
10
+ * cache needed.
11
+ *
12
+ * Distinct from the update notice on purpose, and non-redundant: this names the
13
+ * backend FLOOR and fires only when the running version is strictly below it (a
14
+ * serious "you will be rejected once enforcement is on" state); the update
15
+ * notice names the npm LATEST and fires whenever a newer release exists. Each
16
+ * owns its own number — the backend never advertises "latest".
17
+ *
18
+ * Reuses `compareSemver` and the `TESTSPRITE_NO_UPDATE_NOTIFIER` opt-out from
19
+ * `update-check.ts` so the gating and semver semantics stay consistent.
20
+ */
21
+ import { compareSemver, UPDATE_CHECK_OPT_OUT_ENV } from './update-check.js';
22
+ import { VERSION } from '../version.js';
23
+ /**
24
+ * True when every gate passes and the running version is strictly below the
25
+ * advertised floor. Gates mirror the update notice: opt-out env, JSON output,
26
+ * dry-run, and non-TTY all suppress. Pure — no side effects, no process state.
27
+ */
28
+ export function shouldWarnBelowFloor(info, deps = {}) {
29
+ const env = deps.env ?? process.env;
30
+ const currentVersion = deps.currentVersion ?? VERSION;
31
+ const isTTY = deps.isTTY ?? process.stderr.isTTY === true;
32
+ const optOut = env[UPDATE_CHECK_OPT_OUT_ENV];
33
+ if (optOut !== undefined && optOut !== '')
34
+ return false;
35
+ if (deps.outputMode === 'json')
36
+ return false;
37
+ if (deps.dryRun === true)
38
+ return false;
39
+ if (!isTTY)
40
+ return false;
41
+ const minVersion = info.minVersion;
42
+ if (!minVersion)
43
+ return false;
44
+ // compareSemver returns -1 when the first arg is OLDER than the second.
45
+ // Unparseable input on either side compares as 0, so garbage never warns.
46
+ return compareSemver(currentVersion, minVersion) === -1;
47
+ }
48
+ /**
49
+ * The single advisory line. Names the floor (the backend's authority) and the
50
+ * upgrade command — it deliberately does NOT name a target release; the npm
51
+ * update-notice is the single source of truth for the newest version.
52
+ */
53
+ export function formatBelowFloorNotice(currentVersion, minVersion) {
54
+ return (`Your testsprite-cli (${currentVersion}) is below the minimum supported version ${minVersion}. ` +
55
+ `Upgrade: npm install -g @testsprite/testsprite-cli ` +
56
+ `(disable this notice with ${UPDATE_CHECK_OPT_OUT_ENV}=1).`);
57
+ }
58
+ /** Module-level guard: at most one below-floor advisory per process. */
59
+ let warnedThisProcess = false;
60
+ /** Test-only: reset the once-per-process guard between cases. */
61
+ export function resetBelowFloorNoticeState() {
62
+ warnedThisProcess = false;
63
+ }
64
+ /**
65
+ * Emit the below-floor advisory at most once per process. Wired to the HTTP
66
+ * client's `onServerVersion` hook. Never throws — an advisory must not break or
67
+ * delay the command it rides along with.
68
+ */
69
+ export function noteServerVersion(info, deps = {}) {
70
+ try {
71
+ if (warnedThisProcess)
72
+ return;
73
+ if (!shouldWarnBelowFloor(info, deps))
74
+ return;
75
+ const minVersion = info.minVersion;
76
+ if (!minVersion)
77
+ return;
78
+ const currentVersion = deps.currentVersion ?? VERSION;
79
+ const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
80
+ stderr(formatBelowFloorNotice(currentVersion, minVersion));
81
+ warnedThisProcess = true;
82
+ }
83
+ catch {
84
+ // Advisory is best-effort; never surface its failures to the command.
85
+ }
86
+ }
87
+ //# sourceMappingURL=version-notice.js.map
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.3.0";
1
+ export declare const VERSION = "0.5.0";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED by scripts/generate-version.mjs — do not edit by hand.
2
2
  // Run `npm run build` (or `npm run generate:version`) to regenerate.
3
- export const VERSION = '0.3.0';
3
+ export const VERSION = '0.5.0';
4
4
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testsprite/testsprite-cli",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Official TestSprite command-line interface",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -10,6 +10,7 @@
10
10
  "files": [
11
11
  "dist",
12
12
  "skills",
13
+ "schemas",
13
14
  "!dist/**/*.map"
14
15
  ],
15
16
  "scripts": {
@@ -44,7 +45,16 @@
44
45
  "testsprite",
45
46
  "cli",
46
47
  "testing",
47
- "automation"
48
+ "automation",
49
+ "test-automation",
50
+ "ai-testing",
51
+ "e2e",
52
+ "qa",
53
+ "api-testing",
54
+ "playwright",
55
+ "mcp",
56
+ "claude-code",
57
+ "agent"
48
58
  ],
49
59
  "author": "TestSprite team",
50
60
  "license": "Apache-2.0",
@@ -54,12 +64,13 @@
54
64
  "valibot": "^1.4.1"
55
65
  },
56
66
  "devDependencies": {
57
- "@eslint/js": "^9.14.0",
67
+ "@eslint/js": "^10.0.1",
58
68
  "@types/node": "^22.9.0",
59
69
  "@vitest/coverage-v8": "^2.1.4",
60
- "eslint": "^9.14.0",
70
+ "ajv": "^8.20.0",
71
+ "eslint": "^10.7.0",
61
72
  "eslint-config-prettier": "^9.1.0",
62
- "globals": "^15.12.0",
73
+ "globals": "^17.7.0",
63
74
  "msw": "^2.14.3",
64
75
  "prettier": "^3.3.3",
65
76
  "typescript": "^5.6.3",
@@ -0,0 +1,61 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://raw.githubusercontent.com/TestSprite/testsprite-cli/main/schemas/plan.schema.json",
4
+ "title": "TestSprite CLI plan file",
5
+ "description": "Shape ingested by `testsprite test create --plan-from <file>` (and, per-line, by `test create-batch --plans <file.jsonl>` / `--plan-from-dir <dir>`). One plan file describes exactly ONE test — a top-level JSON array is rejected; use create-batch for many. This schema is the machine-readable ground truth for THIS command (`--plan-from`), not for `assertPlanShape`'s raw structural check in isolation — where the two diverge (see `type` below), this schema encodes what `--plan-from` actually accepts end-to-end. It is asserted in `src/lib/plan-schema.spec.ts` against the real validator; if the two ever disagree, the validator's actual acceptance behavior is authoritative and this file is out of date. Not enforced by this schema (checked separately by the CLI as a pre-flight guard, not a structural JSON constraint): a plan file must be <= 256 KB total.",
6
+ "type": "object",
7
+ "required": ["projectId", "type", "name", "planSteps"],
8
+ "properties": {
9
+ "$schema": {
10
+ "description": "Optional. Point your editor at this file (e.g. the raw URL in the plan template, or a local path to a copy shipped in node_modules/@testsprite/testsprite-cli/schemas/plan.schema.json) to get inline validation and completion while authoring. Ignored by the CLI — plan files are not restricted to a fixed property set (see `additionalProperties`, implicitly true throughout this schema), and this property is deliberately left type-unconstrained here to match: assertPlanShape does not inspect `$schema` at all, so a non-string value here is exactly as valid to the CLI as a string one."
11
+ },
12
+ "projectId": {
13
+ "type": "string",
14
+ "minLength": 1,
15
+ "pattern": "\\S",
16
+ "description": "Project id returned by `testsprite project list`. Must be non-empty and not whitespace-only."
17
+ },
18
+ "type": {
19
+ "type": "string",
20
+ "enum": ["frontend"],
21
+ "description": "Restricted to `frontend` — `--plan-from` rejects a `backend`-typed plan pre-flight with a `nextAction` pointing at `test create --type backend --code-file <path>` (backend tests are authored from a code file, not a plan). `assertPlanShape`'s own structural check is looser (it accepts `backend` as a bare shape check before that later rejection), but this schema is the ground truth for the `--plan-from` COMMAND as a whole, not for the isolated structural check — so it encodes the value that actually succeeds end-to-end."
22
+ },
23
+ "name": {
24
+ "type": "string",
25
+ "minLength": 1,
26
+ "pattern": "\\S",
27
+ "description": "Human-readable test name. Write it as an assertable behavior statement (subject + verb + outcome), not a noun fragment."
28
+ },
29
+ "description": {
30
+ "type": "string",
31
+ "description": "Optional one-sentence elaboration of `name` — the condition plus the expected outcome. Any string is accepted (including empty), unlike `name`/`projectId`."
32
+ },
33
+ "priority": {
34
+ "type": "string",
35
+ "enum": ["p0", "p1", "p2", "p3"],
36
+ "description": "Optional. p0 = must-pass, p1 = important paths, p2 = edge cases, p3 = cosmetic."
37
+ },
38
+ "planSteps": {
39
+ "type": "array",
40
+ "minItems": 1,
41
+ "maxItems": 200,
42
+ "description": "1-200 steps describing user intent in plain language, not selectors. `{{...}}`-style placeholders are NOT substituted by the CLI — a step containing one is structurally valid (passes this schema and assertPlanShape) but triggers a non-fatal `[advisory]` at `test create --plan-from` time; store login credentials on the project instead (`project update --username/--password`, or Portal -> Project Settings).",
43
+ "items": {
44
+ "type": "object",
45
+ "required": ["type", "description"],
46
+ "properties": {
47
+ "type": {
48
+ "type": "string",
49
+ "enum": ["action", "assertion"]
50
+ },
51
+ "description": {
52
+ "type": "string",
53
+ "minLength": 1,
54
+ "pattern": "\\S",
55
+ "description": "One verb per step. Describe the outcome/intent, not a CSS selector or literal button label."
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
@@ -10,17 +10,23 @@ docs/config and is about to be reported complete.
10
10
  Run after a feature or fix lands. Skip only for: docs-only edits, pure
11
11
  build/config changes, or when the repo has no TestSprite project linked.
12
12
 
13
+ The CLI only tests a reachable deployed URL (it rejects localhost). If the
14
+ change is only running locally, hand off to the TestSprite MCP when it's
15
+ available — it tunnels your local server; otherwise report the change as
16
+ unverified-because-undeployed and stop. If the user explicitly named a tool
17
+ (the CLI or the MCP), honor that over this reachability heuristic.
18
+
13
19
  ## Core loop
14
20
 
15
21
  ### 1. Preflight
16
22
 
17
23
  ```bash
18
24
  testsprite --version # CLI installed?
19
- testsprite auth whoami # credentials valid?
25
+ testsprite auth status # credentials valid?
20
26
  ```
21
27
 
22
28
  If `--version` fails, tell the user to install the CLI and stop.
23
- If `auth whoami` fails, tell the user to run `testsprite auth configure` and stop.
29
+ If `auth status` fails, tell the user to run `testsprite setup` and stop.
24
30
 
25
31
  ### 2. Find the project
26
32
 
@@ -21,6 +21,17 @@ Run the loop only once the change is live somewhere reachable (e.g. open the PR,
21
21
  let CI deploy the preview/staging environment) and pass that URL as
22
22
  `--target-url`. Running earlier verifies the previous build, not your change.
23
23
 
24
+ This CLI only tests a reachable deployed URL (it rejects localhost). If the
25
+ change is only running locally and isn't deployed anywhere reachable yet:
26
+
27
+ - if the TestSprite MCP is available in this environment, hand off to it — it
28
+ tunnels your local server and tests the running app;
29
+ - otherwise report the change as unverified-because-undeployed and stop — don't
30
+ run against a stale deployment to manufacture a verdict.
31
+
32
+ If the user explicitly named a tool (the CLI or the MCP), honor that over this
33
+ reachability heuristic.
34
+
24
35
  ## When to skip
25
36
 
26
37
  The skip list is narrow:
@@ -56,13 +67,13 @@ because <X>. Treat this as unverified until that's resolved." Don't claim done.
56
67
 
57
68
  ```bash
58
69
  testsprite --version # CLI installed?
59
- testsprite auth whoami # credentials configured?
70
+ testsprite auth status # credentials configured?
60
71
  ```
61
72
 
62
73
  - `--version` fails → the CLI isn't installed. Tell the user to install the
63
74
  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.
75
+ - `auth status` fails → no credentials. Tell the user they can run
76
+ `testsprite setup`, then stop.
66
77
 
67
78
  ## 2. Find the project
68
79
 
@@ -225,10 +236,10 @@ testsprite test create --type backend --project <projectId> --name "fixture user
225
236
  ordering: trigger the set with `test run --all` (§4) and producers run before
226
237
  consumers, `teardown` last. Chaining `run A --wait && run B --wait` yourself
227
238
  loses the engine's variable passing and conflicts with concurrent runs.
228
- - **Declarations are currently create-only.** `test update` cannot amend them and
229
- `test get` / `test list` don't echo them back, so note what each test
230
- produces/needs as you create it; changing the graph later means delete +
231
- recreate.
239
+ - **Declarations are editable.** `test update` amends them (`--produces` /
240
+ `--needs` / `--category`, repeatable) and `test get` echoes them back —
241
+ still declare the graph at create time when you can, so wave ordering is
242
+ right on the first run.
232
243
 
233
244
  **Show the user the drafted plan / code before creating it** — creating writes to
234
245
  their project. One short confirmation; let them edit the tempfile first.