@testsprite/testsprite-cli 0.3.0 → 0.4.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.
- package/README.md +30 -29
- package/dist/commands/auth.d.ts +5 -0
- package/dist/commands/auth.js +9 -0
- package/dist/commands/doctor.js +36 -14
- package/dist/commands/project.d.ts +25 -1
- package/dist/commands/project.js +74 -4
- package/dist/commands/test.d.ts +93 -1
- package/dist/commands/test.js +568 -94
- package/dist/index.js +41 -4
- package/dist/lib/bundle.js +19 -1
- package/dist/lib/client-factory.d.ts +6 -0
- package/dist/lib/client-factory.js +16 -0
- package/dist/lib/dry-run/samples.js +36 -0
- package/dist/lib/errors.d.ts +28 -1
- package/dist/lib/errors.js +40 -0
- package/dist/lib/failing-fe-resolver.d.ts +15 -0
- package/dist/lib/failing-fe-resolver.js +49 -1
- package/dist/lib/http.d.ts +53 -1
- package/dist/lib/http.js +113 -5
- package/dist/lib/interrupt.d.ts +65 -10
- package/dist/lib/interrupt.js +94 -9
- package/dist/lib/poll.d.ts +11 -0
- package/dist/lib/poll.js +70 -5
- package/dist/lib/runs.types.d.ts +9 -0
- package/dist/lib/v3-advisory.d.ts +13 -0
- package/dist/lib/v3-advisory.js +24 -0
- package/dist/lib/version-notice.d.ts +37 -0
- package/dist/lib/version-notice.js +87 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-verify.codex.md +6 -0
- package/skills/testsprite-verify.skill.md +15 -4
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yes --agent claude
|
|
|
69
69
|
|
|
70
70
|
> **Pointing a coding agent (Claude Code, Cursor, Codex, Cline, …) at TestSprite?** Have it run `testsprite setup` first — that installs the verification skill, so the agent knows how to create, run, and triage tests on its own (instead of guessing from this README). New here? Start with the **[getting-started overview](https://docs.testsprite.com/cli/getting-started/overview)**.
|
|
71
71
|
|
|
72
|
-
> **Privacy note:** interactive runs check the npm registry at most once per 24 h to offer a "new version available" notice — package name only, never your key or data; `TESTSPRITE_NO_UPDATE_NOTIFIER=1` disables it. Details in [DOCUMENTATION.md → Update notice](./DOCUMENTATION.md#update-notice).
|
|
72
|
+
> **Privacy note:** interactive runs check the npm registry at most once per 24 h to offer a "new version available" notice — package name only, never your key or data; `TESTSPRITE_NO_UPDATE_NOTIFIER=1` disables it. The backend also advertises its minimum supported CLI version — a below-floor CLI prints a one-line upgrade advisory on stderr, and a too-old client may be rejected with exit 14 (`CLIENT_TOO_OLD`). Details in [DOCUMENTATION.md → Update notice](./DOCUMENTATION.md#update-notice).
|
|
73
73
|
|
|
74
74
|
From there, the loop runs on its own — an example session, typed by the coding agent:
|
|
75
75
|
|
|
@@ -91,34 +91,35 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
|
|
|
91
91
|
|
|
92
92
|
## Commands
|
|
93
93
|
|
|
94
|
-
| Group | Command
|
|
95
|
-
| --------- |
|
|
96
|
-
| **Setup** | `setup`
|
|
97
|
-
| | `doctor`
|
|
98
|
-
| **Auth** | `auth status`
|
|
99
|
-
| | `auth remove`
|
|
100
|
-
| | `usage` (alias `credits`)
|
|
101
|
-
| **Read** | `project list` / `project get`
|
|
102
|
-
| | `test list` / `test get`
|
|
103
|
-
| | `test code get`
|
|
104
|
-
| | `test steps`
|
|
105
|
-
| | `test result`
|
|
106
|
-
| | `test failure get`
|
|
107
|
-
| | `test failure summary`
|
|
108
|
-
| | `test diff`
|
|
109
|
-
| **Write** | `test scaffold` / `test lint`
|
|
110
|
-
| | `test create` / `test create-batch`
|
|
111
|
-
| | `test update` / `test delete` / `test delete-batch`
|
|
112
|
-
| | `test code put`
|
|
113
|
-
| | `test plan put`
|
|
114
|
-
| | `project create` / `project update`
|
|
115
|
-
| | `project credential` / `project auto-auth`
|
|
116
|
-
| **Run** | `test run`
|
|
117
|
-
| | `test rerun`
|
|
118
|
-
| | `test flaky`
|
|
119
|
-
| | `test wait`
|
|
120
|
-
| | `test
|
|
121
|
-
|
|
|
94
|
+
| Group | Command | What it does |
|
|
95
|
+
| --------- | ------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
|
|
97
|
+
| | `doctor` | Environment diagnostic — CLI/Node versions, profile, endpoint, credentials, connectivity, agent skill; exits non-zero on failure |
|
|
98
|
+
| **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
|
|
99
|
+
| | `auth remove` | Remove the active profile from the credentials file |
|
|
100
|
+
| | `usage` (alias `credits`) | Account pre-flight: identity, plus credit balance / plan info when the backend supplies them |
|
|
101
|
+
| **Read** | `project list` / `project get` | List projects / fetch one by id |
|
|
102
|
+
| | `test list` / `test get` | List tests under a project / fetch one by id |
|
|
103
|
+
| | `test code get` | Print (or write) the generated test source |
|
|
104
|
+
| | `test steps` | List the latest run's steps with screenshot / DOM pointers |
|
|
105
|
+
| | `test result` | Latest result; `--history` lists a test's prior runs |
|
|
106
|
+
| | `test failure get` | The agent entry point: one self-contained latest-failure bundle |
|
|
107
|
+
| | `test failure summary` | One-screen triage card (no media download) |
|
|
108
|
+
| | `test diff` | Compare two runs — verdict, failure kind, per-step status flips, code-version drift |
|
|
109
|
+
| **Write** | `test scaffold` / `test lint` | Author plans locally: emit a schema-correct starter, validate plan files offline — no network, no credentials |
|
|
110
|
+
| | `test create` / `test create-batch` | Create a test (or bulk-create from a plan file); `--produces` / `--needs` / `--category` wire BE dependency metadata |
|
|
111
|
+
| | `test update` / `test delete` / `test delete-batch` | Edit metadata and BE dependency declarations (`--produces` / `--needs` / `--category`) / permanently delete (no restore window; `--confirm` required) |
|
|
112
|
+
| | `test code put` | Replace generated code (etag-guarded) |
|
|
113
|
+
| | `test plan put` | Replace a frontend test's plan-steps |
|
|
114
|
+
| | `project create` / `project update` / `project delete` | Manage projects; `delete` removes a project and everything under it (`--confirm` required, no restore window) |
|
|
115
|
+
| | `project credential` / `project auto-auth` | Configure backend-test auth: a static injected credential, or auto-refresh login (Pro) |
|
|
116
|
+
| **Run** | `test run` | Trigger a fresh run; `--wait` blocks until terminal; `--all --project <id>` runs all tests in a project in wave order |
|
|
117
|
+
| | `test rerun` | Cheap replay of one/many tests (FE verbatim; BE with deps); `--all --project <id>` reruns all tests |
|
|
118
|
+
| | `test flaky` | Replay a test several times (auto-heal off) and report a stability score |
|
|
119
|
+
| | `test wait` | Block on one or more `runId`s until terminal |
|
|
120
|
+
| | `test cancel` | Cancel one or more in-flight runs (Ctrl-C during `--wait` only detaches — `cancel` is the real stop) |
|
|
121
|
+
| | `test artifact get` | Download the failure bundle for a specific `runId` |
|
|
122
|
+
| **Agent** | `agent install` / `agent list` / `agent status` | Add, list, or health-check coding-agent skills (pure-local): `claude`, `codex`, `cursor`, `cline`, `antigravity`, `kiro`, `windsurf`, `copilot` |
|
|
122
123
|
|
|
123
124
|
> The earlier command names — `init`, `auth configure`, `auth whoami`, `auth logout` — still work as hidden, deprecated aliases (each prints a one-line notice pointing at the new name), so existing scripts keep running. `auth configure` now runs the full `setup` (it also installs the skill).
|
|
124
125
|
|
package/dist/commands/auth.d.ts
CHANGED
|
@@ -15,6 +15,11 @@ export interface MeResponse {
|
|
|
15
15
|
email?: string;
|
|
16
16
|
/** Human-readable display name for the bound account. Absent-safe (dogfood L1866). */
|
|
17
17
|
displayName?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Authoritative per-user V3 routing bit. Absent-safe: older backends omit it,
|
|
20
|
+
* so it is only rendered when present.
|
|
21
|
+
*/
|
|
22
|
+
v3Enabled?: boolean;
|
|
18
23
|
}
|
|
19
24
|
export interface AuthDeps {
|
|
20
25
|
env?: NodeJS.ProcessEnv;
|
package/dist/commands/auth.js
CHANGED
|
@@ -8,6 +8,7 @@ import { loadConfig, normalizeEnvVar } from '../lib/config.js';
|
|
|
8
8
|
import { emitDeprecationNotice } from '../lib/deprecate.js';
|
|
9
9
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
10
10
|
import { promptSecret } from '../lib/prompt.js';
|
|
11
|
+
import { emitV3RoutingAdvisory, routingLabel } from '../lib/v3-advisory.js';
|
|
11
12
|
const DEFAULT_API_URL = 'https://api.testsprite.com';
|
|
12
13
|
const FROM_ENV_MISSING_KEY = 'TESTSPRITE_API_KEY is not set in the environment. Set it and re-run with --from-env, or omit --from-env to enter the key interactively.';
|
|
13
14
|
export async function runConfigure(opts, deps = {}) {
|
|
@@ -124,6 +125,7 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
124
125
|
export async function runWhoami(opts, deps = {}) {
|
|
125
126
|
const out = makeOutput(opts.output, deps);
|
|
126
127
|
const env = deps.env ?? process.env;
|
|
128
|
+
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
127
129
|
// Resolve the endpoint URL so it can be surfaced in text output.
|
|
128
130
|
// Dry-run uses the flag/env/default chain without touching credentials.
|
|
129
131
|
// Real path uses the same loadConfig the HttpClient factory uses so the
|
|
@@ -165,6 +167,8 @@ export async function runWhoami(opts, deps = {}) {
|
|
|
165
167
|
`endpoint: ${resolvedEndpoint}`,
|
|
166
168
|
`env: ${m.env}`,
|
|
167
169
|
`scopes: ${m.scopes.join(', ')}`,
|
|
170
|
+
// Authoritative routing mode, rendered only when the backend supplies it.
|
|
171
|
+
...(m.v3Enabled !== undefined ? [`routing: ${routingLabel(m.v3Enabled)}`] : []),
|
|
168
172
|
];
|
|
169
173
|
// C2: warn in text mode when key cannot write/run
|
|
170
174
|
const missingScopes = ['write:tests', 'run:tests'].filter(s => !m.scopes.includes(s));
|
|
@@ -173,6 +177,11 @@ export async function runWhoami(opts, deps = {}) {
|
|
|
173
177
|
}
|
|
174
178
|
return lines.join('\n');
|
|
175
179
|
});
|
|
180
|
+
// When V3 routing is on, warn (text mode only) about the still-open behavior
|
|
181
|
+
// gaps. JSON consumers read `v3Enabled` directly; stdout stays pure.
|
|
182
|
+
if (opts.output !== 'json' && me.v3Enabled === true) {
|
|
183
|
+
emitV3RoutingAdvisory(stderr);
|
|
184
|
+
}
|
|
176
185
|
return me;
|
|
177
186
|
}
|
|
178
187
|
export async function runLogout(opts, deps = {}) {
|
package/dist/commands/doctor.js
CHANGED
|
@@ -20,6 +20,7 @@ import { loadConfig } from '../lib/config.js';
|
|
|
20
20
|
import { ApiError, CLIError, localValidationError } from '../lib/errors.js';
|
|
21
21
|
import { GLOBAL_OPTS_HINT, Output } from '../lib/output.js';
|
|
22
22
|
import { isVerifySkillInstalled } from '../lib/skill-nudge.js';
|
|
23
|
+
import { emitV3RoutingAdvisory, routingLabel } from '../lib/v3-advisory.js';
|
|
23
24
|
import { VERSION } from '../version.js';
|
|
24
25
|
import { MIN_SUPPORTED_NODE_MAJOR, shouldRejectNodeVersion } from '../version-guard.js';
|
|
25
26
|
export async function runDoctor(opts, deps = {}) {
|
|
@@ -35,22 +36,38 @@ export async function runDoctor(opts, deps = {}) {
|
|
|
35
36
|
});
|
|
36
37
|
const endpointCheck = checkEndpoint(config.apiUrl);
|
|
37
38
|
const hasKey = Boolean(config.apiKey);
|
|
39
|
+
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
40
|
+
const connectivity = await checkConnectivity(opts, deps, {
|
|
41
|
+
hasKey,
|
|
42
|
+
endpointOk: endpointCheck.status === 'ok',
|
|
43
|
+
});
|
|
38
44
|
const checks = [
|
|
39
45
|
{ name: 'CLI version', status: 'ok', detail: VERSION },
|
|
40
46
|
checkNodeVersion(nodeVersion),
|
|
41
47
|
{ name: 'Profile', status: 'ok', detail: config.profile },
|
|
42
48
|
endpointCheck,
|
|
43
49
|
checkCredentials(hasKey, config.profile, opts.dryRun ?? false),
|
|
44
|
-
|
|
45
|
-
hasKey,
|
|
46
|
-
endpointOk: endpointCheck.status === 'ok',
|
|
47
|
-
}),
|
|
48
|
-
checkSkill(cwd, deps),
|
|
50
|
+
connectivity.check,
|
|
49
51
|
];
|
|
52
|
+
// Informational routing line, only when the backend reported it (no new call).
|
|
53
|
+
if (connectivity.v3Enabled !== undefined) {
|
|
54
|
+
const label = routingLabel(connectivity.v3Enabled);
|
|
55
|
+
checks.push({
|
|
56
|
+
name: 'Routing',
|
|
57
|
+
status: 'ok',
|
|
58
|
+
detail: connectivity.v3Enabled === true
|
|
59
|
+
? `${label} (V3 execution routing is ON)`
|
|
60
|
+
: `${label} (default routing)`,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
checks.push(checkSkill(cwd, deps));
|
|
50
64
|
const failures = checks.filter(check => check.status === 'fail').length;
|
|
51
65
|
const warnings = checks.filter(check => check.status === 'warn').length;
|
|
52
66
|
const report = { checks, failures, warnings };
|
|
53
67
|
out.print(report, () => renderDoctor(report));
|
|
68
|
+
if (connectivity.v3Enabled === true) {
|
|
69
|
+
emitV3RoutingAdvisory(stderr);
|
|
70
|
+
}
|
|
54
71
|
if (failures > 0) {
|
|
55
72
|
// Non-zero exit so `testsprite doctor && ...` gates a CI step or an agent
|
|
56
73
|
// preflight. The full report already printed above; this line is the stderr
|
|
@@ -120,11 +137,11 @@ function checkSkill(cwd, deps) {
|
|
|
120
137
|
async function checkConnectivity(opts, deps, ctx) {
|
|
121
138
|
const name = 'Connectivity';
|
|
122
139
|
if (opts.dryRun)
|
|
123
|
-
return { name, status: 'warn', detail: 'skipped under --dry-run' };
|
|
140
|
+
return { check: { name, status: 'warn', detail: 'skipped under --dry-run' } };
|
|
124
141
|
if (!ctx.hasKey)
|
|
125
|
-
return { name, status: 'warn', detail: 'skipped; no API key to test with' };
|
|
142
|
+
return { check: { name, status: 'warn', detail: 'skipped; no API key to test with' } };
|
|
126
143
|
if (!ctx.endpointOk)
|
|
127
|
-
return { name, status: 'warn', detail: 'skipped; endpoint URL is invalid' };
|
|
144
|
+
return { check: { name, status: 'warn', detail: 'skipped; endpoint URL is invalid' } };
|
|
128
145
|
try {
|
|
129
146
|
const client = makeHttpClient(opts, {
|
|
130
147
|
env: deps.env,
|
|
@@ -134,21 +151,26 @@ async function checkConnectivity(opts, deps, ctx) {
|
|
|
134
151
|
});
|
|
135
152
|
const me = await client.get('/me');
|
|
136
153
|
const who = me.userId ? ` (userId ${me.userId})` : '';
|
|
137
|
-
return {
|
|
154
|
+
return {
|
|
155
|
+
check: { name, status: 'ok', detail: `reached GET /me, API key accepted${who}` },
|
|
156
|
+
v3Enabled: me.v3Enabled,
|
|
157
|
+
};
|
|
138
158
|
}
|
|
139
159
|
catch (error) {
|
|
140
160
|
if (error instanceof ApiError) {
|
|
141
161
|
if (error.code === 'AUTH_REQUIRED' ||
|
|
142
162
|
error.code === 'AUTH_INVALID' ||
|
|
143
163
|
error.code === 'AUTH_FORBIDDEN') {
|
|
144
|
-
return { name, status: 'fail', detail: `API key rejected (${error.code})` };
|
|
164
|
+
return { check: { name, status: 'fail', detail: `API key rejected (${error.code})` } };
|
|
145
165
|
}
|
|
146
|
-
return { name, status: 'fail', detail: `GET /me failed (${error.code})` };
|
|
166
|
+
return { check: { name, status: 'fail', detail: `GET /me failed (${error.code})` } };
|
|
147
167
|
}
|
|
148
168
|
return {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
169
|
+
check: {
|
|
170
|
+
name,
|
|
171
|
+
status: 'fail',
|
|
172
|
+
detail: `GET /me failed (${error instanceof Error ? error.message : String(error)})`,
|
|
173
|
+
},
|
|
152
174
|
};
|
|
153
175
|
}
|
|
154
176
|
}
|
|
@@ -32,7 +32,6 @@ export interface CliCreateProjectRequest {
|
|
|
32
32
|
type: 'frontend' | 'backend';
|
|
33
33
|
name: string;
|
|
34
34
|
targetUrl?: string;
|
|
35
|
-
description?: string;
|
|
36
35
|
username?: string;
|
|
37
36
|
password?: string;
|
|
38
37
|
instruction?: string;
|
|
@@ -67,6 +66,31 @@ interface UpdateOptions extends CommonOptions {
|
|
|
67
66
|
idempotencyKey?: string;
|
|
68
67
|
}
|
|
69
68
|
export declare function runUpdate(opts: UpdateOptions, deps?: ProjectDeps): Promise<CliUpdateProjectResponse>;
|
|
69
|
+
export interface CliDeleteProjectResponse {
|
|
70
|
+
projectId: string;
|
|
71
|
+
deletedAt: string;
|
|
72
|
+
}
|
|
73
|
+
interface DeleteOptions extends CommonOptions {
|
|
74
|
+
projectId: string;
|
|
75
|
+
/** Hard gate — required (unless `--dry-run` is set). No interactive prompts. */
|
|
76
|
+
confirm: boolean;
|
|
77
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
78
|
+
idempotencyKey?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* `project delete <project-id> --confirm` — permanent cascade delete via
|
|
82
|
+
* DELETE /projects/{id}.
|
|
83
|
+
*
|
|
84
|
+
* The server deletes the project together with everything under it — its
|
|
85
|
+
* frontend/backend sub-projects, all their tests, and backend fixtures —
|
|
86
|
+
* matching the Portal's own delete behavior. There is no restore window.
|
|
87
|
+
*
|
|
88
|
+
* **`--confirm` is required** (unless `--dry-run`). Without either, the CLI
|
|
89
|
+
* exits 5 `VALIDATION_ERROR` with a typed envelope explaining the convention.
|
|
90
|
+
* The CLI never prompts interactively (CI-friendly contract). Re-delete on an already-deleted (or missing) project returns 404 from
|
|
91
|
+
* the server; the CLI surfaces the envelope as-is (exit 4), no client branching.
|
|
92
|
+
*/
|
|
93
|
+
export declare function runDelete(opts: DeleteOptions, deps?: ProjectDeps): Promise<CliDeleteProjectResponse>;
|
|
70
94
|
export interface CliProjectCredentialResponse {
|
|
71
95
|
projectId: string;
|
|
72
96
|
authType: string;
|
package/dist/commands/project.js
CHANGED
|
@@ -60,8 +60,11 @@ export async function runCreate(opts, deps = {}) {
|
|
|
60
60
|
if (opts.name.length > 200) {
|
|
61
61
|
throw localValidationError('--name must be at most 200 characters');
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
// `--description` is not supported on projects — no project entity stores a
|
|
64
|
+
// description, and the backend rejects it with a 422. Fail fast client-side
|
|
65
|
+
// with an actionable message instead of a wasted round trip.
|
|
66
|
+
if (opts.description !== undefined) {
|
|
67
|
+
throw localValidationError('--description is not supported for projects; omit it (test-level descriptions are set on `test create`)');
|
|
65
68
|
}
|
|
66
69
|
// P2-7: guard --url against localhost/RFC1918/non-http(s) (same rules as
|
|
67
70
|
// `test create --target-url`). Applies to both FE (required) and BE (optional).
|
|
@@ -108,7 +111,6 @@ export async function runCreate(opts, deps = {}) {
|
|
|
108
111
|
type: opts.type,
|
|
109
112
|
name: opts.name,
|
|
110
113
|
...(opts.targetUrl !== undefined ? { targetUrl: opts.targetUrl } : {}),
|
|
111
|
-
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
112
114
|
...(opts.username !== undefined ? { username: opts.username } : {}),
|
|
113
115
|
...(password !== undefined ? { password } : {}),
|
|
114
116
|
...(opts.instruction !== undefined ? { instruction: opts.instruction } : {}),
|
|
@@ -198,6 +200,51 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
198
200
|
out.print(updated, data => renderUpdateText(data));
|
|
199
201
|
return updated;
|
|
200
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* `project delete <project-id> --confirm` — permanent cascade delete via
|
|
205
|
+
* DELETE /projects/{id}.
|
|
206
|
+
*
|
|
207
|
+
* The server deletes the project together with everything under it — its
|
|
208
|
+
* frontend/backend sub-projects, all their tests, and backend fixtures —
|
|
209
|
+
* matching the Portal's own delete behavior. There is no restore window.
|
|
210
|
+
*
|
|
211
|
+
* **`--confirm` is required** (unless `--dry-run`). Without either, the CLI
|
|
212
|
+
* exits 5 `VALIDATION_ERROR` with a typed envelope explaining the convention.
|
|
213
|
+
* The CLI never prompts interactively (CI-friendly contract). Re-delete on an already-deleted (or missing) project returns 404 from
|
|
214
|
+
* the server; the CLI surfaces the envelope as-is (exit 4), no client branching.
|
|
215
|
+
*/
|
|
216
|
+
export async function runDelete(opts, deps = {}) {
|
|
217
|
+
assertIdempotencyKey(opts.idempotencyKey);
|
|
218
|
+
if (opts.projectId === undefined || opts.projectId.trim().length === 0) {
|
|
219
|
+
throw localValidationError('<project-id> is required');
|
|
220
|
+
}
|
|
221
|
+
if (!opts.confirm && !opts.dryRun) {
|
|
222
|
+
throw ApiError.fromEnvelope({
|
|
223
|
+
error: {
|
|
224
|
+
code: 'VALIDATION_ERROR',
|
|
225
|
+
message: 'Refusing to delete without --confirm.',
|
|
226
|
+
nextAction: 'This permanently deletes the project and everything under it — its ' +
|
|
227
|
+
'sub-projects, all their tests, and backend fixtures (no restore window). ' +
|
|
228
|
+
'The CLI convention is explicit confirmation for destructive operations. ' +
|
|
229
|
+
'Re-run with --confirm. (--dry-run also works without --confirm.)',
|
|
230
|
+
requestId: 'local',
|
|
231
|
+
details: { field: 'confirm', reason: 'required for destructive operation' },
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const idempotencyKey = opts.idempotencyKey ?? `cli-delete-${randomUUID()}`;
|
|
236
|
+
if (opts.idempotencyKey === undefined && (opts.output === 'json' || opts.verbose || opts.debug)) {
|
|
237
|
+
const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
238
|
+
stderr(`idempotency-key: ${idempotencyKey}`);
|
|
239
|
+
}
|
|
240
|
+
const client = makeClient(opts, deps);
|
|
241
|
+
const out = makeOutput(opts.output, deps);
|
|
242
|
+
const response = await client.delete(`/projects/${encodeURIComponent(opts.projectId)}`, {
|
|
243
|
+
headers: { 'idempotency-key': idempotencyKey },
|
|
244
|
+
});
|
|
245
|
+
out.print(response, data => renderDeleteText(data));
|
|
246
|
+
return response;
|
|
247
|
+
}
|
|
201
248
|
// ---------------------------------------------------------------------------
|
|
202
249
|
// project credential — set the static backend credential
|
|
203
250
|
// ---------------------------------------------------------------------------
|
|
@@ -368,7 +415,7 @@ export function createProjectCommand(deps = {}) {
|
|
|
368
415
|
.option('--type <frontend|backend>', 'project type (required)')
|
|
369
416
|
.option('--name <name>', 'project name (required)')
|
|
370
417
|
.option('--url <url>', 'target URL (required for frontend)')
|
|
371
|
-
.option('--description <text>', '
|
|
418
|
+
.option('--description <text>', 'not supported — projects have no description (test-level descriptions are set on `test create`)')
|
|
372
419
|
.option('--username <user>', 'optional auth username')
|
|
373
420
|
.option('--password <pw>', 'optional auth password (use --password-file for non-interactive)')
|
|
374
421
|
.option('--password-file <path>', 'read password from file instead of inline flag')
|
|
@@ -424,6 +471,26 @@ export function createProjectCommand(deps = {}) {
|
|
|
424
471
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
425
472
|
}, deps);
|
|
426
473
|
});
|
|
474
|
+
project
|
|
475
|
+
.command('delete <project-id>')
|
|
476
|
+
.description('Permanently delete a project and everything under it (sub-projects,\n' +
|
|
477
|
+
'their tests, and backend fixtures). Requires --confirm.\n' +
|
|
478
|
+
'\nExit codes:\n' +
|
|
479
|
+
' 0 success\n' +
|
|
480
|
+
' 3 auth error\n' +
|
|
481
|
+
' 4 project not found (or already deleted)\n' +
|
|
482
|
+
' 5 validation error (e.g., missing --confirm)')
|
|
483
|
+
.option('--confirm', 'required: explicit confirmation for the destructive operation', false)
|
|
484
|
+
.option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
|
|
485
|
+
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
486
|
+
.action(async (projectId, cmdOpts, command) => {
|
|
487
|
+
await runDelete({
|
|
488
|
+
...resolveCommonOptions(command),
|
|
489
|
+
projectId,
|
|
490
|
+
confirm: cmdOpts.confirm === true,
|
|
491
|
+
idempotencyKey: cmdOpts.idempotencyKey,
|
|
492
|
+
}, deps);
|
|
493
|
+
});
|
|
427
494
|
project
|
|
428
495
|
.command('credential <project-id>')
|
|
429
496
|
.description('Set the static backend credential injected into every backend test\n' +
|
|
@@ -600,6 +667,9 @@ function renderUpdateText(r) {
|
|
|
600
667
|
`updatedAt: ${r.updatedAt}`,
|
|
601
668
|
].join('\n');
|
|
602
669
|
}
|
|
670
|
+
function renderDeleteText(r) {
|
|
671
|
+
return [`projectId ${r.projectId}`, `deletedAt ${r.deletedAt}`].join('\n');
|
|
672
|
+
}
|
|
603
673
|
function localValidationError(message) {
|
|
604
674
|
return ApiError.fromEnvelope({
|
|
605
675
|
error: {
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factor
|
|
|
3
3
|
import { type WriteBundleResult } from '../lib/bundle.js';
|
|
4
4
|
import { type JUnitReportFormat } from '../lib/junit-report.js';
|
|
5
5
|
import { ApiError } from '../lib/errors.js';
|
|
6
|
+
import { type ShutdownHandle } from '../lib/interrupt.js';
|
|
6
7
|
import type { FetchImpl } from '../lib/http.js';
|
|
7
8
|
import { type Page } from '../lib/pagination.js';
|
|
8
|
-
import type { RunResponse, TriggerRunResponse, RerunResponse, BatchRerunResponse, ListRunsResponse, RunSource, BatchRunFreshResponse } from '../lib/runs.types.js';
|
|
9
|
+
import type { RunResponse, TriggerRunResponse, RerunResponse, BatchRerunResponse, ListRunsResponse, RunSource, BatchRunFreshResponse, CancelRunResponse } from '../lib/runs.types.js';
|
|
9
10
|
import { type FlakyReport } from '../lib/flaky.js';
|
|
10
11
|
/**
|
|
11
12
|
* `details` debug block per the CLI OpenAPI `Test` schema
|
|
@@ -68,6 +69,14 @@ export interface CliTest {
|
|
|
68
69
|
* no priority has been set. Text mode surfaces it only when truthy.
|
|
69
70
|
*/
|
|
70
71
|
priority?: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Backend-only dependency declarations that drive wave ordering.
|
|
74
|
+
* Optional on the wire so older facades that don't ship them still
|
|
75
|
+
* type-check; text mode surfaces them only when present/non-empty.
|
|
76
|
+
*/
|
|
77
|
+
produces?: string[] | null;
|
|
78
|
+
consumes?: string[] | null;
|
|
79
|
+
category?: string | null;
|
|
71
80
|
}
|
|
72
81
|
export type CliPublicStatus = 'draft' | 'ready' | 'queued' | 'running' | 'passed' | 'failed' | 'blocked' | 'cancelled' | 'unknown';
|
|
73
82
|
/**
|
|
@@ -174,6 +183,18 @@ export interface CliLatestResult {
|
|
|
174
183
|
* former `{passed,failed,skipped}` count object).
|
|
175
184
|
*/
|
|
176
185
|
summary: string;
|
|
186
|
+
/**
|
|
187
|
+
* Captured stdout (`api_output`) from a backend-test execution.
|
|
188
|
+
* Present (possibly null) only for backend tests; omitted for FE/MCP and on
|
|
189
|
+
* older backends that omit them. Capped at 50 KB UTF-8 by the server.
|
|
190
|
+
*/
|
|
191
|
+
apiOutput?: string | null;
|
|
192
|
+
/**
|
|
193
|
+
* Python traceback from a backend-test execution (ends with the
|
|
194
|
+
* `ExceptionType: message` line). Present (possibly null) only for backend
|
|
195
|
+
* tests; omitted for FE/MCP and on older backends.
|
|
196
|
+
*/
|
|
197
|
+
trace?: string | null;
|
|
177
198
|
/**
|
|
178
199
|
* §6.5.1 (M2.1 piece 3) — inline failure analysis. Present when the
|
|
179
200
|
* caller passed `--include-analysis` (`?includeAnalysis=true` on
|
|
@@ -258,6 +279,14 @@ export interface CliFailureBlock {
|
|
|
258
279
|
*/
|
|
259
280
|
recommendedFixTarget: CliFixTarget | null;
|
|
260
281
|
evidence: CliEvidence[];
|
|
282
|
+
/**
|
|
283
|
+
* Backend-test execution artifacts, surfaced on the failure block
|
|
284
|
+
* so triage has stdout + traceback next to the hypothesis (mirrors
|
|
285
|
+
* `result.apiOutput` / `result.trace`). Present (possibly null) only for
|
|
286
|
+
* backend failures; omitted for FE and on older backends.
|
|
287
|
+
*/
|
|
288
|
+
apiOutput?: string | null;
|
|
289
|
+
trace?: string | null;
|
|
261
290
|
}
|
|
262
291
|
/** §6.7 wire shape — one atomic snapshot of the latest failing run. */
|
|
263
292
|
export interface CliFailureContext {
|
|
@@ -287,6 +316,13 @@ export interface TestDeps {
|
|
|
287
316
|
* no-op in tests to avoid real delays.
|
|
288
317
|
*/
|
|
289
318
|
sleep?: (ms: number) => Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Graceful-detach coordinator for the `--wait` paths (DEV-331 piece 1).
|
|
321
|
+
* Defaults to the process-wide `globalShutdown`; tests inject their own
|
|
322
|
+
* controller and abort it to simulate Ctrl-C deterministically (same
|
|
323
|
+
* pattern as `sleep` / `fetchImpl`).
|
|
324
|
+
*/
|
|
325
|
+
shutdown?: ShutdownHandle;
|
|
290
326
|
}
|
|
291
327
|
type CommonOptions = FactoryCommonOptions;
|
|
292
328
|
interface ListOptions extends CommonOptions {
|
|
@@ -457,6 +493,12 @@ interface UpdateOptions extends CommonOptions {
|
|
|
457
493
|
description?: string;
|
|
458
494
|
/** Optional new priority. Enum-validated CLI-side. */
|
|
459
495
|
priority?: CliCreatePriority;
|
|
496
|
+
/** Backend-only: variable names this test produces (repeatable --produces). */
|
|
497
|
+
produces?: string[];
|
|
498
|
+
/** Backend-only: variable names this test consumes (repeatable --needs); wire field `consumes`. */
|
|
499
|
+
needs?: string[];
|
|
500
|
+
/** Backend-only: free-text wave category (--category). */
|
|
501
|
+
category?: string;
|
|
460
502
|
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
461
503
|
idempotencyKey?: string;
|
|
462
504
|
}
|
|
@@ -1312,6 +1354,56 @@ export declare function runTestWaitMany(opts: RunTestWaitManyOptions, deps?: Tes
|
|
|
1312
1354
|
results: CliMultiWaitResult[];
|
|
1313
1355
|
summary: Record<string, number>;
|
|
1314
1356
|
}>;
|
|
1357
|
+
export interface RunTestCancelOptions extends CommonOptions {
|
|
1358
|
+
runIds: string[];
|
|
1359
|
+
}
|
|
1360
|
+
/** One run's outcome in a multi-id `test cancel` summary. */
|
|
1361
|
+
export interface CliCancelResultRow {
|
|
1362
|
+
runId: string;
|
|
1363
|
+
status: 'cancelled' | 'alreadyCancelled' | 'conflict' | 'notFound' | 'error';
|
|
1364
|
+
/** Terminal status the run was already in, for a `conflict` row. */
|
|
1365
|
+
conflictStatus?: string;
|
|
1366
|
+
error?: string;
|
|
1367
|
+
}
|
|
1368
|
+
/** JSON payload for a multi-id `test cancel` — per piece-3 CXL-11. */
|
|
1369
|
+
export interface CliCancelSummary {
|
|
1370
|
+
cancelled: string[];
|
|
1371
|
+
alreadyCancelled: string[];
|
|
1372
|
+
conflicts: Array<{
|
|
1373
|
+
runId: string;
|
|
1374
|
+
status: string;
|
|
1375
|
+
}>;
|
|
1376
|
+
notFound: string[];
|
|
1377
|
+
/**
|
|
1378
|
+
* Runs that errored for a reason other than 404/409 (e.g. auth, transport).
|
|
1379
|
+
* Always present — an empty array on full success — so machine consumers
|
|
1380
|
+
* can rely on a stable shape (DEV-331 codex finding 2).
|
|
1381
|
+
*/
|
|
1382
|
+
errors: Array<{
|
|
1383
|
+
runId: string;
|
|
1384
|
+
message: string;
|
|
1385
|
+
}>;
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* `test cancel <run-id...>` — DEV-331 piece 3.
|
|
1389
|
+
*
|
|
1390
|
+
* User-initiated cancel of one or more queued/running runs via
|
|
1391
|
+
* `POST /api/cli/v1/runs/{runId}/cancel`. Naturally idempotent (D10): a
|
|
1392
|
+
* repeat cancel of the same run is a 200 `alreadyCancelled` success, not an
|
|
1393
|
+
* error. Dispatches serially (per-id volume is tiny — no batch endpoint,
|
|
1394
|
+
* D8 "Batch-level cancel endpoint... YAGNI").
|
|
1395
|
+
*
|
|
1396
|
+
* Single id: renders the returned run card (`status cancelled`); an
|
|
1397
|
+
* `alreadyCancelled` response adds an `[advisory]` line. Exit code mirrors
|
|
1398
|
+
* the server response directly — 0 on success (fresh or already-cancelled),
|
|
1399
|
+
* 4 on 404 (unknown/cross-tenant), 6 on 409 (already terminal).
|
|
1400
|
+
*
|
|
1401
|
+
* Multi-id: prints a `{cancelled, alreadyCancelled, conflicts, notFound}`
|
|
1402
|
+
* summary. Exit precedence (CXL-11): any `notFound` → 4 (outranks conflict —
|
|
1403
|
+
* it signals a caller bug, wrong id/tenant); else any `conflicts` → 6; else 0.
|
|
1404
|
+
*/
|
|
1405
|
+
export declare function runTestCancel(opts: RunTestCancelOptions, deps?: TestDeps): Promise<CancelRunResponse | CliCancelSummary>;
|
|
1406
|
+
export declare function createTestCancelCommand(deps: TestDeps): Command;
|
|
1315
1407
|
/**
|
|
1316
1408
|
* `test wait <run-id>` — M3.3 piece-3.
|
|
1317
1409
|
*
|