@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.
- package/README.md +52 -44
- package/dist/commands/agent.js +16 -13
- package/dist/commands/auth.d.ts +19 -0
- package/dist/commands/auth.js +60 -24
- package/dist/commands/ci.d.ts +86 -1
- package/dist/commands/ci.js +470 -9
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +22 -9
- package/dist/commands/init.js +14 -11
- package/dist/commands/project-env.d.ts +90 -0
- package/dist/commands/project-env.js +486 -0
- package/dist/commands/project.d.ts +15 -5
- package/dist/commands/project.js +88 -92
- package/dist/commands/schedule.d.ts +2 -0
- package/dist/commands/schedule.js +18 -10
- package/dist/commands/test.d.ts +102 -30
- package/dist/commands/test.js +1949 -419
- package/dist/commands/testlist.js +77 -21
- package/dist/commands/tunnel.d.ts +26 -3
- package/dist/commands/tunnel.js +211 -14
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.js +12 -5
- package/dist/index.js +47 -23
- package/dist/lib/agent-targets.d.ts +3 -3
- package/dist/lib/agent-targets.js +2 -2
- package/dist/lib/billing-refusal.d.ts +43 -0
- package/dist/lib/billing-refusal.js +171 -0
- package/dist/lib/bundle.d.ts +5 -0
- package/dist/lib/bundle.js +43 -13
- package/dist/lib/ci-linkage.d.ts +90 -0
- package/dist/lib/ci-linkage.js +181 -0
- package/dist/lib/client-factory.d.ts +4 -1
- package/dist/lib/client-factory.js +25 -2
- package/dist/lib/client-tag.d.ts +13 -0
- package/dist/lib/client-tag.js +44 -0
- package/dist/lib/config.d.ts +17 -0
- package/dist/lib/config.js +20 -1
- package/dist/lib/conflict-reason.d.ts +67 -2
- package/dist/lib/conflict-reason.js +148 -13
- package/dist/lib/credentials.js +56 -14
- package/dist/lib/cron.js +8 -1
- package/dist/lib/dry-run/samples.d.ts +13 -1
- package/dist/lib/dry-run/samples.js +51 -7
- package/dist/lib/errors.d.ts +62 -12
- package/dist/lib/errors.js +180 -25
- package/dist/lib/failing-fe-resolver.d.ts +1 -1
- package/dist/lib/failing-fe-resolver.js +3 -3
- package/dist/lib/gh-output.d.ts +26 -11
- package/dist/lib/gh-output.js +47 -15
- package/dist/lib/history-retention.d.ts +8 -0
- package/dist/lib/history-retention.js +24 -0
- package/dist/lib/http.d.ts +44 -19
- package/dist/lib/http.js +53 -26
- package/dist/lib/interrupt.d.ts +21 -13
- package/dist/lib/interrupt.js +32 -21
- package/dist/lib/junit-report.d.ts +11 -1
- package/dist/lib/junit-report.js +15 -3
- package/dist/lib/local-target.d.ts +33 -1
- package/dist/lib/local-target.js +78 -1
- package/dist/lib/output.d.ts +27 -1
- package/dist/lib/output.js +22 -3
- package/dist/lib/plan-poll.d.ts +11 -11
- package/dist/lib/plan-poll.js +12 -12
- package/dist/lib/plans.types.d.ts +9 -9
- package/dist/lib/plans.types.js +3 -3
- package/dist/lib/poll.d.ts +2 -2
- package/dist/lib/poll.js +9 -3
- package/dist/lib/render-error.d.ts +2 -0
- package/dist/lib/render-error.js +13 -0
- package/dist/lib/response-schemas.d.ts +54 -12
- package/dist/lib/response-schemas.js +106 -7
- package/dist/lib/runs.types.d.ts +92 -6
- package/dist/lib/secret-file.js +72 -14
- package/dist/lib/skill-nudge.d.ts +6 -1
- package/dist/lib/skill-nudge.js +32 -5
- package/dist/lib/target-url-preflight.d.ts +6 -4
- package/dist/lib/target-url-preflight.js +64 -51
- package/dist/lib/target-url.js +31 -12
- package/dist/lib/telemetry.d.ts +172 -3
- package/dist/lib/telemetry.js +276 -15
- package/dist/lib/ticker.js +93 -4
- package/dist/lib/tunnel-session.d.ts +13 -0
- package/dist/lib/tunnel-session.js +4 -1
- package/dist/lib/tunnel.types.d.ts +12 -2
- package/dist/lib/tunnel.types.js +2 -2
- package/dist/lib/version-notice.d.ts +20 -1
- package/dist/lib/version-notice.js +59 -12
- package/dist/lib/wait-exit.d.ts +8 -0
- package/dist/lib/wait-exit.js +76 -4
- package/dist/lib/workspace-status.d.ts +23 -0
- package/dist/lib/workspace-status.js +15 -0
- package/dist/version-guard.d.ts +7 -1
- package/dist/version-guard.js +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/testsprite-onboard.skill.md +4 -4
- package/skills/testsprite-verify.codex.md +59 -57
- package/skills/testsprite-verify.skill.md +53 -36
package/dist/commands/doctor.js
CHANGED
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Command } from 'commander';
|
|
18
18
|
import { assertValidEndpointUrl, makeHttpClient, } from '../lib/client-factory.js';
|
|
19
|
-
import { loadConfig } from '../lib/config.js';
|
|
20
|
-
import { ApiError, CLIError, RequestTimeoutError, localValidationError } from '../lib/errors.js';
|
|
19
|
+
import { loadConfig, resolveProfileName } from '../lib/config.js';
|
|
20
|
+
import { ApiError, CLIError, InterruptError, RequestTimeoutError, localValidationError, } from '../lib/errors.js';
|
|
21
|
+
import { globalShutdown } from '../lib/interrupt.js';
|
|
21
22
|
import { formatOrgBinding, formatOrgsSummary, formatPersonalScopeHint } from '../lib/org-render.js';
|
|
22
23
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
24
|
+
import { ME_IDENTITY_SCHEMA } from '../lib/response-schemas.js';
|
|
23
25
|
import { isVerifySkillInstalled } from '../lib/skill-nudge.js';
|
|
24
26
|
import { emitV3RoutingAdvisory, routingLabel } from '../lib/v3-advisory.js';
|
|
25
27
|
import { VERSION } from '../version.js';
|
|
@@ -165,8 +167,9 @@ async function checkConnectivity(opts, deps, ctx) {
|
|
|
165
167
|
credentialsPath: deps.credentialsPath,
|
|
166
168
|
fetchImpl: deps.fetchImpl,
|
|
167
169
|
stderr: deps.stderr,
|
|
170
|
+
shutdownSignal: deps.shutdownSignal,
|
|
168
171
|
});
|
|
169
|
-
const me = await client.get('/me');
|
|
172
|
+
const me = await client.get('/me', { schema: ME_IDENTITY_SCHEMA });
|
|
170
173
|
const who = me.userId ? ` (userId ${me.userId})` : '';
|
|
171
174
|
return {
|
|
172
175
|
check: { name, status: 'ok', detail: `reached GET /me, API key accepted${who}` },
|
|
@@ -176,6 +179,8 @@ async function checkConnectivity(opts, deps, ctx) {
|
|
|
176
179
|
};
|
|
177
180
|
}
|
|
178
181
|
catch (error) {
|
|
182
|
+
if (error instanceof InterruptError)
|
|
183
|
+
throw error;
|
|
179
184
|
if (error instanceof ApiError) {
|
|
180
185
|
if (error.code === 'AUTH_REQUIRED' ||
|
|
181
186
|
error.code === 'AUTH_INVALID' ||
|
|
@@ -220,6 +225,12 @@ async function checkLocalTunnel(opts, deps, ctx) {
|
|
|
220
225
|
if (!ctx.endpointOk)
|
|
221
226
|
return { name, status: 'warn', detail: 'skipped; endpoint URL is invalid' };
|
|
222
227
|
const controller = new AbortController();
|
|
228
|
+
const shutdownSignal = deps.shutdownSignal ?? globalShutdown.signal;
|
|
229
|
+
const onShutdown = () => controller.abort(shutdownSignal.reason);
|
|
230
|
+
if (shutdownSignal.aborted)
|
|
231
|
+
onShutdown();
|
|
232
|
+
else
|
|
233
|
+
shutdownSignal.addEventListener('abort', onShutdown, { once: true });
|
|
223
234
|
const probeTimer = setTimeout(() => {
|
|
224
235
|
controller.abort(new RequestTimeoutError(DOCTOR_TUNNEL_PROBE_TIMEOUT_MS));
|
|
225
236
|
}, DOCTOR_TUNNEL_PROBE_TIMEOUT_MS);
|
|
@@ -230,9 +241,8 @@ async function checkLocalTunnel(opts, deps, ctx) {
|
|
|
230
241
|
credentialsPath: deps.credentialsPath,
|
|
231
242
|
fetchImpl: deps.fetchImpl,
|
|
232
243
|
stderr: deps.stderr,
|
|
233
|
-
// The retry sleeper listens to the client shutdown signal
|
|
234
|
-
// the probe deadline
|
|
235
|
-
// one operation rather than timing each fetch independently.
|
|
244
|
+
// The retry sleeper listens to the client shutdown signal. Compose
|
|
245
|
+
// the probe deadline with process shutdown so either aborts the fetch.
|
|
236
246
|
shutdownSignal: controller.signal,
|
|
237
247
|
});
|
|
238
248
|
// A well-formed id that cannot name anyone's binding. A 200 here would
|
|
@@ -246,6 +256,8 @@ async function checkLocalTunnel(opts, deps, ctx) {
|
|
|
246
256
|
};
|
|
247
257
|
}
|
|
248
258
|
catch (error) {
|
|
259
|
+
if (error instanceof InterruptError)
|
|
260
|
+
throw error;
|
|
249
261
|
if (!(error instanceof ApiError)) {
|
|
250
262
|
return {
|
|
251
263
|
name,
|
|
@@ -275,6 +287,7 @@ async function checkLocalTunnel(opts, deps, ctx) {
|
|
|
275
287
|
}
|
|
276
288
|
finally {
|
|
277
289
|
clearTimeout(probeTimer);
|
|
290
|
+
shutdownSignal.removeEventListener('abort', onShutdown);
|
|
278
291
|
}
|
|
279
292
|
}
|
|
280
293
|
/**
|
|
@@ -314,14 +327,14 @@ export function createDoctorCommand(deps = {}) {
|
|
|
314
327
|
' testsprite doctor --output json # machine-readable report\n' +
|
|
315
328
|
' testsprite doctor && testsprite test run <id> # gate a command on a healthy setup')
|
|
316
329
|
.action(async (_cmdOpts, command) => {
|
|
317
|
-
await runDoctor(resolveCommonOptions(command), deps);
|
|
330
|
+
await runDoctor(resolveCommonOptions(command, deps.env), deps);
|
|
318
331
|
});
|
|
319
332
|
return cmd;
|
|
320
333
|
}
|
|
321
|
-
function resolveCommonOptions(command) {
|
|
334
|
+
function resolveCommonOptions(command, env) {
|
|
322
335
|
const globals = command.optsWithGlobals();
|
|
323
336
|
return {
|
|
324
|
-
profile: globals.profile
|
|
337
|
+
profile: resolveProfileName(globals.profile, env),
|
|
325
338
|
output: resolveOutputMode(globals.output),
|
|
326
339
|
endpointUrl: globals.endpointUrl,
|
|
327
340
|
debug: globals.debug ?? false,
|
package/dist/commands/init.js
CHANGED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { Command } from 'commander';
|
|
15
15
|
import { parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
16
|
-
import { normalizeEnvVar } from '../lib/config.js';
|
|
16
|
+
import { normalizeEnvVar, resolveProfileName } from '../lib/config.js';
|
|
17
17
|
import { emitDeprecationNotice } from '../lib/deprecate.js';
|
|
18
|
-
import { CLIError, localValidationError } from '../lib/errors.js';
|
|
18
|
+
import { CLIError, InterruptError, localValidationError } from '../lib/errors.js';
|
|
19
19
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
20
|
-
import { runConfigure, runWhoami } from './auth.js';
|
|
20
|
+
import { missingApiKeyError, runConfigure, runWhoami } from './auth.js';
|
|
21
21
|
import { runInstall } from './agent.js';
|
|
22
22
|
import { TARGETS, DEFAULT_SKILLS } from '../lib/agent-targets.js';
|
|
23
23
|
import { FALLBACK_TARGET, resolveAgentTargets, } from '../lib/agent-detect.js';
|
|
@@ -98,6 +98,7 @@ function toAuthDeps(deps, apiKey, commandTag) {
|
|
|
98
98
|
// If an explicit API key was provided, override the prompt so configure
|
|
99
99
|
// never actually prompts the user.
|
|
100
100
|
prompt: apiKey ? { secret: async (_q) => apiKey } : deps.prompt,
|
|
101
|
+
suppliedApiKey: Boolean(apiKey),
|
|
101
102
|
// Telemetry attribution for the configure-validate GET /me. Passed only for
|
|
102
103
|
// the configure step (see runInit) — never whoami — so each init run emits
|
|
103
104
|
// exactly one cli.initialized event on the backend.
|
|
@@ -253,8 +254,8 @@ export async function runInit(opts, deps = {}) {
|
|
|
253
254
|
// Non-interactive guard: no TTY + no key source → exit 5. Skipped under
|
|
254
255
|
// --dry-run, which is documented to work without credentials or network.
|
|
255
256
|
if (!isTTY && !hasKeySource && !skipWillApply && !opts.dryRun) {
|
|
256
|
-
throw
|
|
257
|
-
'Pass --api-key <key>, --from-env (reads TESTSPRITE_API_KEY), or run interactively.',
|
|
257
|
+
throw missingApiKeyError('No API key available in non-interactive mode. ' +
|
|
258
|
+
'Pass --api-key <key>, --from-env (reads TESTSPRITE_API_KEY), or run interactively.', resolveReportedEndpoint(opts, deps));
|
|
258
259
|
}
|
|
259
260
|
// JSON-output guard: an interactive secret prompt writes to stdout and would
|
|
260
261
|
// corrupt init's single-JSON-object output contract. In --output json mode
|
|
@@ -363,6 +364,8 @@ export async function runInit(opts, deps = {}) {
|
|
|
363
364
|
me = await runWhoami(opts, whoamiDeps);
|
|
364
365
|
}
|
|
365
366
|
catch (err) {
|
|
367
|
+
if (err instanceof InterruptError)
|
|
368
|
+
throw err;
|
|
366
369
|
// Whoami is display-only. If it fails after a successful configure,
|
|
367
370
|
// continue with a minimal placeholder so the summary still prints.
|
|
368
371
|
if (opts.debug) {
|
|
@@ -484,7 +487,7 @@ function renderInitText(data) {
|
|
|
484
487
|
: ' agent: skipped (--no-agent)');
|
|
485
488
|
}
|
|
486
489
|
lines.push('');
|
|
487
|
-
//
|
|
490
|
+
// An agent session already open when the skills landed won't re-read
|
|
488
491
|
// them. `agent install` emits the same line on stderr; setup owns its summary,
|
|
489
492
|
// so it goes here. Only when bytes actually changed — `aggregateInstallAction`
|
|
490
493
|
// reports 'installed'/'updated' for that, 'dry-run'/'skipped' otherwise.
|
|
@@ -519,10 +522,10 @@ function renderInitText(data) {
|
|
|
519
522
|
// ---------------------------------------------------------------------------
|
|
520
523
|
// Command factory
|
|
521
524
|
// ---------------------------------------------------------------------------
|
|
522
|
-
function resolveCommonOptions(command) {
|
|
525
|
+
function resolveCommonOptions(command, env) {
|
|
523
526
|
const globals = command.optsWithGlobals();
|
|
524
527
|
return {
|
|
525
|
-
profile: globals.profile
|
|
528
|
+
profile: resolveProfileName(globals.profile, env),
|
|
526
529
|
output: resolveOutputMode(globals.output),
|
|
527
530
|
endpointUrl: globals.endpointUrl,
|
|
528
531
|
debug: globals.debug ?? false,
|
|
@@ -551,8 +554,8 @@ export function addSetupOptions(cmd, validTargets, defaultAgent) {
|
|
|
551
554
|
.option('--skip-if-configured', 'Skip the API key prompt when credentials already exist for this profile (CI-safe idempotent re-run)');
|
|
552
555
|
}
|
|
553
556
|
/** Build {@link InitOptions} from raw Commander opts + globals. */
|
|
554
|
-
function buildSetupOptions(cmdOpts, command) {
|
|
555
|
-
const common = resolveCommonOptions(command);
|
|
557
|
+
function buildSetupOptions(cmdOpts, command, env) {
|
|
558
|
+
const common = resolveCommonOptions(command, env);
|
|
556
559
|
// Commander sets `agent: false` (boolean) when `--no-agent` is passed,
|
|
557
560
|
// because `--no-agent` is the negation of `--agent <target>`.
|
|
558
561
|
const isNoAgent = cmdOpts.noAgent === true || cmdOpts.agent === false;
|
|
@@ -586,7 +589,7 @@ function buildSetupOptions(cmdOpts, command) {
|
|
|
586
589
|
}
|
|
587
590
|
/** Shared action for `setup` and the deprecated `init` alias. */
|
|
588
591
|
async function runSetupAction(cmdOpts, command, deps) {
|
|
589
|
-
const opts = buildSetupOptions(cmdOpts, command);
|
|
592
|
+
const opts = buildSetupOptions(cmdOpts, command, deps.env);
|
|
590
593
|
// When --yes is supplied without a key source, force isTTY=false so runInit
|
|
591
594
|
// emits exit 5 with a clear message rather than hanging on a prompt in a
|
|
592
595
|
// headless CI environment where a TTY fd happens to be open.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { type CommonOptions } from '../lib/client-factory.js';
|
|
3
|
+
import type { ProjectDeps } from './project.js';
|
|
4
|
+
/** One environment row as the facade returns it. Never carries a password. */
|
|
5
|
+
export interface CliProjectEnvironment {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* The address runs against this environment open. May be a loopback URL for
|
|
10
|
+
* an app that only runs on your own machine — pair it with `--local`.
|
|
11
|
+
*/
|
|
12
|
+
url: string;
|
|
13
|
+
isDefault: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* How a run signs in: `account` (the stored test account), `otp` (a one-time
|
|
16
|
+
* code account), `manual` (a human-captured Google/SSO session, set up in the
|
|
17
|
+
* Portal) or `public` (no sign-in). Open string, rendered verbatim, so a mode
|
|
18
|
+
* added server-side shows up without a CLI release.
|
|
19
|
+
*/
|
|
20
|
+
authMode: string;
|
|
21
|
+
/** Whether a test-account username/password is stored. The password is never returned. */
|
|
22
|
+
hasCredentials: boolean;
|
|
23
|
+
/** The test-account username this environment signs in with; `null` when none is stored. */
|
|
24
|
+
username: string | null;
|
|
25
|
+
enableOtp: boolean;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CliProjectEnvListResponse {
|
|
29
|
+
environments: CliProjectEnvironment[];
|
|
30
|
+
}
|
|
31
|
+
export interface CliProjectEnvCreateResponse {
|
|
32
|
+
environment: CliProjectEnvironment;
|
|
33
|
+
created: true;
|
|
34
|
+
}
|
|
35
|
+
export interface CliProjectEnvUpdateResponse {
|
|
36
|
+
environment: CliProjectEnvironment;
|
|
37
|
+
}
|
|
38
|
+
export interface CliProjectEnvDeleteResponse {
|
|
39
|
+
deleted: true;
|
|
40
|
+
name: string;
|
|
41
|
+
}
|
|
42
|
+
interface EnvListOptions extends CommonOptions {
|
|
43
|
+
projectId: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function runEnvList(opts: EnvListOptions, deps?: ProjectDeps): Promise<CliProjectEnvListResponse>;
|
|
46
|
+
interface EnvCreateOptions extends CommonOptions {
|
|
47
|
+
projectId: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
url?: string;
|
|
50
|
+
/** `--local <port>`: an app on this machine; builds the loopback URL and sends the marker. */
|
|
51
|
+
local?: string;
|
|
52
|
+
localHost?: string;
|
|
53
|
+
skipPreflight?: boolean;
|
|
54
|
+
username?: string;
|
|
55
|
+
password?: string;
|
|
56
|
+
passwordFile?: string;
|
|
57
|
+
setDefault?: boolean;
|
|
58
|
+
idempotencyKey?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare function runEnvCreate(opts: EnvCreateOptions, deps?: ProjectDeps): Promise<CliProjectEnvCreateResponse>;
|
|
61
|
+
interface EnvUpdateOptions extends CommonOptions {
|
|
62
|
+
projectId: string;
|
|
63
|
+
name: string;
|
|
64
|
+
url?: string;
|
|
65
|
+
/** `--local <port>`: repoint at an app on this machine (see `runEnvCreate`). */
|
|
66
|
+
local?: string;
|
|
67
|
+
localHost?: string;
|
|
68
|
+
skipPreflight?: boolean;
|
|
69
|
+
username?: string;
|
|
70
|
+
password?: string;
|
|
71
|
+
passwordFile?: string;
|
|
72
|
+
rename?: string;
|
|
73
|
+
idempotencyKey?: string;
|
|
74
|
+
}
|
|
75
|
+
export declare function runEnvUpdate(opts: EnvUpdateOptions, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
|
|
76
|
+
interface EnvDeleteOptions extends CommonOptions {
|
|
77
|
+
projectId: string;
|
|
78
|
+
name: string;
|
|
79
|
+
confirm: boolean;
|
|
80
|
+
idempotencyKey?: string;
|
|
81
|
+
}
|
|
82
|
+
export declare function runEnvDelete(opts: EnvDeleteOptions, deps?: ProjectDeps): Promise<CliProjectEnvDeleteResponse>;
|
|
83
|
+
interface EnvSetDefaultOptions extends CommonOptions {
|
|
84
|
+
projectId: string;
|
|
85
|
+
name: string;
|
|
86
|
+
idempotencyKey?: string;
|
|
87
|
+
}
|
|
88
|
+
export declare function runEnvSetDefault(opts: EnvSetDefaultOptions, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
|
|
89
|
+
export declare function createProjectEnvCommand(deps?: ProjectDeps): Command;
|
|
90
|
+
export {};
|