@testsprite/testsprite-cli 0.15.0 → 0.17.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 +53 -141
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +55 -65
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +44 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +297 -489
- package/dist/commands/completion.js +2 -1
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +702 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +130 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +116 -68
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +426 -53
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -224
- package/dist/commands/project.d.ts +15 -186
- package/dist/commands/project.js +93 -921
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +215 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +47 -97
- package/dist/commands/test.d.ts +315 -1824
- package/dist/commands/test.js +1962 -13733
- package/dist/commands/testlist.d.ts +128 -5
- package/dist/commands/testlist.js +269 -329
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +43 -41
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +51 -131
- package/dist/index.js +189 -108
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +10 -2
- package/dist/lib/client-factory.js +38 -26
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +31 -4
- package/dist/lib/conflict-reason.js +38 -4
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +71 -0
- package/dist/lib/conversation/api.js +150 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +19 -0
- package/dist/lib/conversation/context.js +70 -0
- package/dist/lib/conversation/environment.d.ts +15 -0
- package/dist/lib/conversation/environment.js +33 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +315 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +156 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +71 -0
- package/dist/lib/download.js +274 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +389 -751
- package/dist/lib/environment-tunnel.d.ts +16 -26
- package/dist/lib/environment-tunnel.js +161 -157
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +16 -22
- package/dist/lib/first-suite-hint.js +38 -47
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +352 -271
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +60 -4
- package/dist/lib/junit-report.js +209 -32
- package/dist/lib/local-target.d.ts +3 -3
- package/dist/lib/local-target.js +3 -3
- package/dist/lib/output.d.ts +0 -29
- package/dist/lib/output.js +10 -33
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +154 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +210 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +71 -0
- package/dist/lib/result/evidence.js +420 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +134 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +1 -1
- package/dist/lib/target-url.js +6 -16
- package/dist/lib/telemetry.d.ts +32 -12
- package/dist/lib/telemetry.js +39 -8
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +7 -1
- package/dist/lib/tunnel-session.js +22 -9
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -4
- package/skills/testsprite-ci.skill.md +48 -18
- package/skills/testsprite-onboard.skill.md +66 -151
- package/skills/testsprite-verify.codex.md +54 -56
- package/skills/testsprite-verify.skill.md +194 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -10
- package/dist/lib/deprecate.js +0 -13
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/commands/init.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `testsprite
|
|
2
|
+
* `testsprite setup` — one-shot onboarding orchestrator.
|
|
3
3
|
*
|
|
4
4
|
* Chains, in order:
|
|
5
5
|
* 0. Agent-target resolution + confirmation prompt — the chosen install
|
|
6
6
|
* targets are settled here, before anything is written
|
|
7
7
|
* 1. runConfigure — writes the API-key profile (validates via GET /me first)
|
|
8
8
|
* 2. runWhoami — fetches identity for the post-configure banner
|
|
9
|
+
* 2.5 ensureTestspriteIgnored — appends .testsprite/ to .gitignore inside a Git repo (unless --no-gitignore)
|
|
9
10
|
* 3. runInstall — installs the TestSprite verification-loop skill (unless --no-agent)
|
|
10
11
|
* 4. Summary print — JSON object or human text block
|
|
11
12
|
*
|
|
12
13
|
* Hard constraint: orchestrate existing exported primitives; never fork them.
|
|
13
14
|
*/
|
|
15
|
+
import path from 'node:path';
|
|
14
16
|
import { Command } from 'commander';
|
|
15
17
|
import { parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
16
18
|
import { normalizeEnvVar, resolveProfileName } from '../lib/config.js';
|
|
17
|
-
import {
|
|
18
|
-
import { CLIError, InterruptError, localValidationError } from '../lib/errors.js';
|
|
19
|
+
import { ApiError, CLIError, InterruptError, localValidationError } from '../lib/errors.js';
|
|
19
20
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
20
21
|
import { missingApiKeyError, runConfigure, runWhoami } from './auth.js';
|
|
21
22
|
import { runInstall } from './agent.js';
|
|
@@ -23,6 +24,8 @@ import { TARGETS, DEFAULT_SKILLS } from '../lib/agent-targets.js';
|
|
|
23
24
|
import { FALLBACK_TARGET, resolveAgentTargets, } from '../lib/agent-detect.js';
|
|
24
25
|
import { promptText } from '../lib/prompt.js';
|
|
25
26
|
import { readProfile } from '../lib/credentials.js';
|
|
27
|
+
import { ensureTestspriteIgnored, checkTestspriteIgnored, isInsideGitRepoAsync, } from '../lib/git-utils.js';
|
|
28
|
+
import { terminalSafeLine, terminalSafeWriter } from '../lib/terminal-text.js';
|
|
26
29
|
/** Mirrors auth.ts's DEFAULT_API_URL (kept in sync; auth.ts owns the canonical value). */
|
|
27
30
|
const DEFAULT_API_URL = 'https://api.testsprite.com';
|
|
28
31
|
/**
|
|
@@ -33,14 +36,18 @@ const DEFAULT_API_URL = 'https://api.testsprite.com';
|
|
|
33
36
|
* configuring staging/dev (codex). On the real path this runs AFTER the profile
|
|
34
37
|
* is written, so the persisted apiUrl is reflected faithfully.
|
|
35
38
|
*/
|
|
36
|
-
function resolveReportedEndpoint(opts, deps) {
|
|
39
|
+
function resolveReportedEndpoint(opts, deps, stderrFn) {
|
|
37
40
|
const env = deps.env ?? process.env;
|
|
38
41
|
const envApiUrl = normalizeEnvVar(env.TESTSPRITE_API_URL);
|
|
39
42
|
let existing;
|
|
40
43
|
try {
|
|
41
44
|
existing = readProfile(opts.profile, { path: deps.credentialsPath })?.apiUrl;
|
|
42
45
|
}
|
|
43
|
-
catch {
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (opts.debug && stderrFn) {
|
|
48
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
49
|
+
stderrFn(`[debug] resolve endpoint profile read failed: ${reason}`);
|
|
50
|
+
}
|
|
44
51
|
existing = undefined;
|
|
45
52
|
}
|
|
46
53
|
return opts.endpointUrl ?? envApiUrl ?? existing ?? DEFAULT_API_URL;
|
|
@@ -153,6 +160,28 @@ function shouldConfirmTargets(resolution, opts, isTTY) {
|
|
|
153
160
|
return fromDetection && isTTY && !opts.yes && !opts.dryRun && opts.output !== 'json';
|
|
154
161
|
}
|
|
155
162
|
const CONFIRM_TARGETS_MAX_ATTEMPTS = 3;
|
|
163
|
+
/** Resolve the project root used for the .git walk and .gitignore (relative --dir is resolved against cwd). */
|
|
164
|
+
function resolveProjectDir(opts, deps) {
|
|
165
|
+
return path.resolve(opts.dir ?? deps.cwd ?? process.cwd());
|
|
166
|
+
}
|
|
167
|
+
/** Route .gitignore access through the injected agent fs when present (tests); real fs otherwise. */
|
|
168
|
+
function buildGitignoreDeps(deps) {
|
|
169
|
+
const agentFs = deps.fs;
|
|
170
|
+
if (!agentFs)
|
|
171
|
+
return {};
|
|
172
|
+
return {
|
|
173
|
+
exists: async (p) => (await agentFs.lstat(p)) !== null,
|
|
174
|
+
lstat: async (p) => {
|
|
175
|
+
const st = await agentFs.lstat(p);
|
|
176
|
+
return st === null ? null : { isSymbolicLink: st.isSymbolicLink };
|
|
177
|
+
},
|
|
178
|
+
readFile: p => agentFs.readFile(p),
|
|
179
|
+
appendFile: async (p, text) => {
|
|
180
|
+
const current = (await agentFs.lstat(p)) === null ? '' : await agentFs.readFile(p);
|
|
181
|
+
await agentFs.writeFile(p, current + text);
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
156
185
|
/**
|
|
157
186
|
* Let an operator see and edit the detected set before anything is written.
|
|
158
187
|
*
|
|
@@ -209,7 +238,7 @@ async function confirmDetectedTargets(resolution, opts, isTTY, stderrFn, promptF
|
|
|
209
238
|
// runInit
|
|
210
239
|
// ---------------------------------------------------------------------------
|
|
211
240
|
export async function runInit(opts, deps = {}) {
|
|
212
|
-
const stderrFn = deps.stderr
|
|
241
|
+
const stderrFn = terminalSafeWriter(deps.stderr);
|
|
213
242
|
const out = new Output(opts.output, { stdout: deps.stdout, stderr: deps.stderr });
|
|
214
243
|
// An unknown --agent is refused here, before credentials are written. Left
|
|
215
244
|
// to runInstall it surfaced as a `--target` error — a flag this command does
|
|
@@ -255,7 +284,7 @@ export async function runInit(opts, deps = {}) {
|
|
|
255
284
|
// --dry-run, which is documented to work without credentials or network.
|
|
256
285
|
if (!isTTY && !hasKeySource && !skipWillApply && !opts.dryRun) {
|
|
257
286
|
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));
|
|
287
|
+
'Pass --api-key <key>, --from-env (reads TESTSPRITE_API_KEY), or run interactively.', resolveReportedEndpoint(opts, deps, stderrFn));
|
|
259
288
|
}
|
|
260
289
|
// JSON-output guard: an interactive secret prompt writes to stdout and would
|
|
261
290
|
// corrupt init's single-JSON-object output contract. In --output json mode
|
|
@@ -308,9 +337,19 @@ export async function runInit(opts, deps = {}) {
|
|
|
308
337
|
dir: opts.dir,
|
|
309
338
|
}, toAgentDeps(deps));
|
|
310
339
|
}
|
|
340
|
+
if (!opts.noGitignore) {
|
|
341
|
+
const projectDir = resolveProjectDir(opts, deps);
|
|
342
|
+
const gitignoreDeps = buildGitignoreDeps(deps);
|
|
343
|
+
if (await isInsideGitRepoAsync(projectDir, gitignoreDeps)) {
|
|
344
|
+
const isIgnored = await checkTestspriteIgnored(projectDir, gitignoreDeps);
|
|
345
|
+
if (!isIgnored) {
|
|
346
|
+
stderrFn('[dry-run] would ignore .testsprite/ in .gitignore');
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
311
350
|
const summary = {
|
|
312
351
|
profile: opts.profile,
|
|
313
|
-
apiUrl: resolveReportedEndpoint(opts, deps),
|
|
352
|
+
apiUrl: resolveReportedEndpoint(opts, deps, stderrFn),
|
|
314
353
|
env: 'development',
|
|
315
354
|
scopes: [],
|
|
316
355
|
agent: resolution
|
|
@@ -366,6 +405,21 @@ export async function runInit(opts, deps = {}) {
|
|
|
366
405
|
catch (err) {
|
|
367
406
|
if (err instanceof InterruptError)
|
|
368
407
|
throw err;
|
|
408
|
+
// `--skip-if-configured` skipped the configure-time validation, so whoami is
|
|
409
|
+
// the only call that ever reaches the server on this path. Swallowing its
|
|
410
|
+
// auth failure made `setup --skip-if-configured` print an "initialized"
|
|
411
|
+
// summary with exit 0 for a key that had since been revoked, and the first
|
|
412
|
+
// real command failed afterwards with a much less obvious error. Let the
|
|
413
|
+
// typed envelop through instead (AUTH_INVALID / AUTH_FORBIDDEN, exit 3).
|
|
414
|
+
// Scoped to the two auth codes on purpose: a malformed saved key reports
|
|
415
|
+
// VALIDATION_ERROR from the client factory, and that stays display-only so
|
|
416
|
+
// a cosmetic format complaint cannot fail an otherwise valid setup.
|
|
417
|
+
// Every other path still treats whoami as display-only.
|
|
418
|
+
if (skipWillApply &&
|
|
419
|
+
err instanceof ApiError &&
|
|
420
|
+
(err.code === 'AUTH_INVALID' || err.code === 'AUTH_FORBIDDEN')) {
|
|
421
|
+
throw err;
|
|
422
|
+
}
|
|
369
423
|
// Whoami is display-only. If it fails after a successful configure,
|
|
370
424
|
// continue with a minimal placeholder so the summary still prints.
|
|
371
425
|
if (opts.debug) {
|
|
@@ -375,6 +429,22 @@ export async function runInit(opts, deps = {}) {
|
|
|
375
429
|
me = { userId: '', keyId: '', scopes: [], env: 'production' };
|
|
376
430
|
}
|
|
377
431
|
// -------------------------------------------------------------------------
|
|
432
|
+
// Step 2.5: Ensure .testsprite/ is ignored in .gitignore
|
|
433
|
+
// -------------------------------------------------------------------------
|
|
434
|
+
// Runs before the agent install so a failing skill install (which re-throws)
|
|
435
|
+
// cannot skip it after credentials were already saved. Never blocks setup.
|
|
436
|
+
if (!opts.noGitignore) {
|
|
437
|
+
try {
|
|
438
|
+
const appended = await ensureTestspriteIgnored(resolveProjectDir(opts, deps), buildGitignoreDeps(deps));
|
|
439
|
+
if (appended) {
|
|
440
|
+
stderrFn('[info] Added .testsprite/ to .gitignore (failure artifacts stay local; pass --no-gitignore to skip)');
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
catch (err) {
|
|
444
|
+
stderrFn(`[warn] Failed to update .gitignore: ${err instanceof Error ? err.message : String(err)}`);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
// -------------------------------------------------------------------------
|
|
378
448
|
// Step 3: Agent skill install (unless --no-agent)
|
|
379
449
|
// -------------------------------------------------------------------------
|
|
380
450
|
let installedTargets = null;
|
|
@@ -394,7 +464,11 @@ export async function runInit(opts, deps = {}) {
|
|
|
394
464
|
capturedInstallResults = parsed;
|
|
395
465
|
}
|
|
396
466
|
}
|
|
397
|
-
catch {
|
|
467
|
+
catch (err) {
|
|
468
|
+
if (opts.debug) {
|
|
469
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
470
|
+
stderrFn(`[debug] setup agent install output parse non-JSON: ${reason}`);
|
|
471
|
+
}
|
|
398
472
|
// ignore non-JSON lines (shouldn't happen in json mode, but be safe)
|
|
399
473
|
}
|
|
400
474
|
};
|
|
@@ -441,7 +515,7 @@ export async function runInit(opts, deps = {}) {
|
|
|
441
515
|
profile: opts.profile,
|
|
442
516
|
// Resolved AFTER configure persists the profile → reflects the real endpoint
|
|
443
517
|
// (staging/dev/prod), not a flat prod default (codex).
|
|
444
|
-
apiUrl: resolveReportedEndpoint(opts, deps),
|
|
518
|
+
apiUrl: resolveReportedEndpoint(opts, deps, stderrFn),
|
|
445
519
|
env: me.env,
|
|
446
520
|
email: me.email,
|
|
447
521
|
scopes: me.scopes,
|
|
@@ -465,11 +539,11 @@ function renderInitText(data) {
|
|
|
465
539
|
lines.push('');
|
|
466
540
|
lines.push(` profile: ${s.profile}`);
|
|
467
541
|
lines.push(` endpoint: ${s.apiUrl}`);
|
|
468
|
-
lines.push(` env: ${s.env}`);
|
|
542
|
+
lines.push(` env: ${terminalSafeLine(s.env)}`);
|
|
469
543
|
if (s.email)
|
|
470
|
-
lines.push(` email: ${s.email}`);
|
|
544
|
+
lines.push(` email: ${terminalSafeLine(s.email)}`);
|
|
471
545
|
if (s.scopes.length > 0)
|
|
472
|
-
lines.push(` scopes: ${s.scopes.join(', ')}`);
|
|
546
|
+
lines.push(` scopes: ${terminalSafeLine(s.scopes.join(', '))}`);
|
|
473
547
|
if (s.credentials?.persisted === false) {
|
|
474
548
|
lines.push(' credentials: session-only (TESTSPRITE_API_KEY; not saved)');
|
|
475
549
|
}
|
|
@@ -496,36 +570,33 @@ function renderInitText(data) {
|
|
|
496
570
|
lines.push('');
|
|
497
571
|
}
|
|
498
572
|
lines.push('Next steps:');
|
|
499
|
-
lines.push(' # 1. Create your first project
|
|
500
|
-
lines.push(' testsprite project create --type frontend --name "My App"
|
|
573
|
+
lines.push(' # 1. Create your first project and say where it runs — prints a projectId');
|
|
574
|
+
lines.push(' testsprite project create --type frontend --name "My App"');
|
|
575
|
+
lines.push(' testsprite project env create <projectId> --name default --url https://your-app.com');
|
|
501
576
|
lines.push('');
|
|
502
577
|
if (s.agent) {
|
|
503
|
-
lines.push(' # 2.
|
|
504
|
-
lines.push(
|
|
505
|
-
lines.push(' testsprite
|
|
506
|
-
lines.push(' testsprite
|
|
578
|
+
lines.push(' # 2. Get tests: ask your coding agent (the testsprite-onboard skill is installed),');
|
|
579
|
+
lines.push(" # or ask the project's agent directly, review what it proposes, then apply it:");
|
|
580
|
+
lines.push(' testsprite plan --project <projectId>');
|
|
581
|
+
lines.push(' testsprite apply');
|
|
507
582
|
lines.push('');
|
|
508
583
|
lines.push(' # 3. Run them (use the projectId from step 1):');
|
|
509
|
-
lines.push(' testsprite
|
|
584
|
+
lines.push(' testsprite run --project <projectId>');
|
|
510
585
|
lines.push('');
|
|
511
586
|
lines.push(' # Manage installed agent skills');
|
|
512
587
|
lines.push(' testsprite agent list');
|
|
513
588
|
lines.push(' testsprite agent install --target=<t> # re-install or install additional targets');
|
|
514
589
|
}
|
|
515
590
|
else {
|
|
516
|
-
// Without
|
|
517
|
-
//
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
lines.push('
|
|
521
|
-
lines.push('
|
|
522
|
-
lines.push(' # testsprite project docs upload ./openapi.yaml --project <projectId>');
|
|
523
|
-
lines.push(' testsprite test plan generate --project <projectId>');
|
|
524
|
-
lines.push(' testsprite test plan accept --project <projectId>');
|
|
525
|
-
lines.push(' # Prefer to write one yourself: testsprite test create --plan-template');
|
|
591
|
+
// Without a coding agent, this is the only place a new user learns that
|
|
592
|
+
// the project's agent writes the first suite.
|
|
593
|
+
lines.push(" # 2. Ask the project's agent for your first tests, review what it proposes, then apply it:");
|
|
594
|
+
lines.push(' # Backend project? Attach your API spec: --file ./openapi.yaml');
|
|
595
|
+
lines.push(' testsprite plan --project <projectId>');
|
|
596
|
+
lines.push(' testsprite apply');
|
|
526
597
|
lines.push('');
|
|
527
598
|
lines.push(' # 3. Run them (use the projectId from step 1):');
|
|
528
|
-
lines.push(' testsprite
|
|
599
|
+
lines.push(' testsprite run --project <projectId>');
|
|
529
600
|
lines.push(' # Tip: `testsprite agent install` sets up the onboarding skill for your coding agent');
|
|
530
601
|
lines.push('');
|
|
531
602
|
lines.push(' # Manage installed agent skills');
|
|
@@ -550,21 +621,21 @@ function resolveCommonOptions(command, env) {
|
|
|
550
621
|
}
|
|
551
622
|
const SETUP_DESCRIPTION = 'Set up TestSprite: configure your API key and install the TestSprite agent skills for your coding agent';
|
|
552
623
|
/**
|
|
553
|
-
* Attach the onboarding flags
|
|
554
|
-
* aliases. `--agent` deliberately carries NO default: its absence is the signal
|
|
624
|
+
* Attach the onboarding flags of `setup`. `--agent` deliberately carries NO default: its absence is the signal
|
|
555
625
|
* that setup should detect the agent, and a default value here is
|
|
556
626
|
* indistinguishable from the caller naming that same target.
|
|
557
627
|
*/
|
|
558
|
-
|
|
628
|
+
function addSetupOptions(cmd, validTargets, defaultAgent) {
|
|
559
629
|
return cmd
|
|
560
630
|
.option('--api-key <key>', 'API key to configure (skips the interactive prompt)')
|
|
561
631
|
.option('--from-env', 'Read TESTSPRITE_API_KEY from the environment instead of prompting', false)
|
|
562
632
|
.option('--agent <target>', `Coding-agent target to install: ${validTargets.join(', ')} ` +
|
|
563
633
|
`(default: every agent detected in this project, or ${defaultAgent} if none)`)
|
|
564
634
|
.option('--no-agent', 'Skip the agent skill install (configure credentials only)')
|
|
635
|
+
.option('--no-gitignore', 'Skip adding .testsprite/ to .gitignore')
|
|
565
636
|
.option('--force', 'Overwrite an existing skill file (a .bak backup is kept)')
|
|
566
637
|
.option('--dir <path>', 'Project root for the skill install (default: current directory)')
|
|
567
|
-
.option('-y, --yes', 'Non-interactive: accept
|
|
638
|
+
.option('-y, --yes', 'Non-interactive: accept defaults, never prompt (needs --from-env or --api-key)')
|
|
568
639
|
.option('--skip-if-configured', 'Skip the API key prompt when credentials already exist for this profile (CI-safe idempotent re-run)');
|
|
569
640
|
}
|
|
570
641
|
/** Build {@link InitOptions} from raw Commander opts + globals. */
|
|
@@ -573,6 +644,7 @@ function buildSetupOptions(cmdOpts, command, env) {
|
|
|
573
644
|
// Commander sets `agent: false` (boolean) when `--no-agent` is passed,
|
|
574
645
|
// because `--no-agent` is the negation of `--agent <target>`.
|
|
575
646
|
const isNoAgent = cmdOpts.noAgent === true || cmdOpts.agent === false;
|
|
647
|
+
const isNoGitignore = cmdOpts.noGitignore === true || cmdOpts.gitignore === false;
|
|
576
648
|
// Detect conflict when both --no-agent and --agent <target> appear in the raw
|
|
577
649
|
// args. Commander only populates `rawArgs` on the ROOT command passed to
|
|
578
650
|
// parseAsync; subcommands have an empty array. Walk up to the root so we
|
|
@@ -594,6 +666,7 @@ function buildSetupOptions(cmdOpts, command, env) {
|
|
|
594
666
|
fromEnv: Boolean(cmdOpts.fromEnv),
|
|
595
667
|
agent: chosenAgent,
|
|
596
668
|
noAgent: isNoAgent,
|
|
669
|
+
noGitignore: isNoGitignore,
|
|
597
670
|
force: Boolean(cmdOpts.force),
|
|
598
671
|
dir: cmdOpts.dir,
|
|
599
672
|
yes: Boolean(cmdOpts.yes),
|
|
@@ -601,7 +674,7 @@ function buildSetupOptions(cmdOpts, command, env) {
|
|
|
601
674
|
rawArgConflict,
|
|
602
675
|
};
|
|
603
676
|
}
|
|
604
|
-
/**
|
|
677
|
+
/** The `setup` action. */
|
|
605
678
|
async function runSetupAction(cmdOpts, command, deps) {
|
|
606
679
|
const opts = buildSetupOptions(cmdOpts, command, deps.env);
|
|
607
680
|
// When --yes is supplied without a key source, force isTTY=false so runInit
|
|
@@ -617,41 +690,16 @@ export function createSetupCommand(deps = {}) {
|
|
|
617
690
|
const validTargets = Object.keys(TARGETS);
|
|
618
691
|
const defaultAgent = 'claude';
|
|
619
692
|
return addSetupOptions(new Command('setup'), validTargets, defaultAgent)
|
|
693
|
+
.summary('Configure your API key and install the agent skills')
|
|
620
694
|
.description(SETUP_DESCRIPTION)
|
|
621
|
-
.addHelpText('after',
|
|
695
|
+
.addHelpText('after', '\nValidates the key (GET /me), saves it to your profile and writes the skills into the project\n' +
|
|
696
|
+
'directory. With --yes or no terminal (CI) the key must come from --from-env or --api-key\n' +
|
|
697
|
+
'(or --skip-if-configured with a saved key); otherwise setup exits 5.\n' +
|
|
698
|
+
'\nExample:\n' +
|
|
699
|
+
' TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yes --agent claude\n' +
|
|
700
|
+
GLOBAL_OPTS_HINT)
|
|
622
701
|
.action(async (cmdOpts, command) => {
|
|
623
702
|
await runSetupAction(cmdOpts, command, deps);
|
|
624
703
|
});
|
|
625
704
|
}
|
|
626
|
-
/**
|
|
627
|
-
* Hidden, deprecated `init` alias → runs `setup`. Kept so existing scripts and
|
|
628
|
-
* agents trained on the old command keep working; registered with
|
|
629
|
-
* `{ hidden: true }` in index.ts (invisible to `--help`) and prints a
|
|
630
|
-
* deprecation notice. (Setup consolidation.)
|
|
631
|
-
*/
|
|
632
|
-
export function createDeprecatedInitCommand(deps = {}) {
|
|
633
|
-
const validTargets = Object.keys(TARGETS);
|
|
634
|
-
const defaultAgent = 'claude';
|
|
635
|
-
return addSetupOptions(new Command('init'), validTargets, defaultAgent)
|
|
636
|
-
.description('(deprecated) alias for `setup`')
|
|
637
|
-
.action(async (cmdOpts, command) => {
|
|
638
|
-
emitDeprecationNotice('init', 'setup', deps.stderr);
|
|
639
|
-
await runSetupAction(cmdOpts, command, deps);
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Entry for the hidden, deprecated `auth configure` alias. Per the setup
|
|
644
|
-
* consolidation, `auth configure` now runs FULL setup (configure + install)
|
|
645
|
-
* so an agent that reaches for the old command still ends up with the skill.
|
|
646
|
-
* `setup` is the ONLY path that writes credentials.
|
|
647
|
-
*
|
|
648
|
-
* Accepts the SAME `SetupCmdOpts` shape `setup` does — the alias previously
|
|
649
|
-
* only wired up `--from-env`, so README's "runs the full setup" claim didn't
|
|
650
|
-
* hold: `--yes`/`--agent`/`--api-key`/`--force`/`--dir`/`--no-agent` were all
|
|
651
|
-
* rejected as unknown options. `index.ts` attaches the full flag set via
|
|
652
|
-
* `addSetupOptions` before wiring this action.
|
|
653
|
-
*/
|
|
654
|
-
export async function runConfigureViaSetup(command, deps, cmdOpts) {
|
|
655
|
-
await runSetupAction(cmdOpts, command, deps);
|
|
656
|
-
}
|
|
657
705
|
//# sourceMappingURL=init.js.map
|
|
@@ -25,6 +25,58 @@ export interface CliProjectEnvironment {
|
|
|
25
25
|
enableOtp: boolean;
|
|
26
26
|
updatedAt: string;
|
|
27
27
|
variables?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* Backend projects only: the environment as the project's agent reads it in
|
|
30
|
+
* `environments/<name>.md`. Reports what is set; never a credential, password
|
|
31
|
+
* or secret header value.
|
|
32
|
+
*/
|
|
33
|
+
api?: CliApiEnvironment;
|
|
34
|
+
/**
|
|
35
|
+
* The environment's settings in the Portal: the page opens its dialog, where a
|
|
36
|
+
* manual login is captured. Absent from older servers; `null` when none resolves.
|
|
37
|
+
*/
|
|
38
|
+
portalUrl?: string | null;
|
|
39
|
+
/** Manual environments only: the login a run would use now. Absent from older servers. */
|
|
40
|
+
manualLogin?: CliManualLogin;
|
|
41
|
+
}
|
|
42
|
+
/** A manual environment's captured login, by the rule a run applies before it starts. */
|
|
43
|
+
export interface CliManualLogin {
|
|
44
|
+
/** `valid`, `never` (nobody has logged in yet) or `expired`. Open string, rendered verbatim. */
|
|
45
|
+
session: string;
|
|
46
|
+
capturedAt: string | null;
|
|
47
|
+
/** `null` until a login is captured, and for a login that never expires. */
|
|
48
|
+
expiresAt: string | null;
|
|
49
|
+
/** How long a captured login is reused, counted from the capture; `-1` never expires. */
|
|
50
|
+
sessionReuseTtlSeconds: number;
|
|
51
|
+
}
|
|
52
|
+
/** How runs on a backend environment sign in to the API under test, as the agent's doc says it. */
|
|
53
|
+
export interface CliApiEnvironment {
|
|
54
|
+
url: string;
|
|
55
|
+
/**
|
|
56
|
+
* `none`, a static credential's type (`bearer`, `basic`, `apikey`) or a
|
|
57
|
+
* sign-in (`login`, `refresh-token`, `cognito`). Open string, rendered
|
|
58
|
+
* verbatim.
|
|
59
|
+
*/
|
|
60
|
+
auth: string;
|
|
61
|
+
loginUrl: string;
|
|
62
|
+
loginMethod: string;
|
|
63
|
+
loginContentType: string;
|
|
64
|
+
loginBody: string;
|
|
65
|
+
username: string;
|
|
66
|
+
tokenPath: string;
|
|
67
|
+
tokenUrl: string;
|
|
68
|
+
clientId: string;
|
|
69
|
+
scope: string;
|
|
70
|
+
region: string;
|
|
71
|
+
inject: string;
|
|
72
|
+
/** Header name to value; `null` when the value is a secret: set, not shown. */
|
|
73
|
+
headers: Record<string, string | null>;
|
|
74
|
+
credentialSet: boolean;
|
|
75
|
+
passwordSet: boolean;
|
|
76
|
+
clientSecretSet: boolean;
|
|
77
|
+
refreshTokenSet: boolean;
|
|
78
|
+
/** Why the last sign-in failed; empty while it signs in, or does not sign in. */
|
|
79
|
+
authError: string;
|
|
28
80
|
}
|
|
29
81
|
export interface CliProjectEnvListResponse {
|
|
30
82
|
environments: CliProjectEnvironment[];
|
|
@@ -40,6 +92,14 @@ export interface CliProjectEnvDeleteResponse {
|
|
|
40
92
|
deleted: true;
|
|
41
93
|
name: string;
|
|
42
94
|
}
|
|
95
|
+
interface ApiAuthFlags {
|
|
96
|
+
auth?: string;
|
|
97
|
+
credential?: string;
|
|
98
|
+
credentialFile?: string;
|
|
99
|
+
header?: string[];
|
|
100
|
+
headerFile?: string;
|
|
101
|
+
autoAuthFile?: string;
|
|
102
|
+
}
|
|
43
103
|
interface EnvListOptions extends CommonOptions {
|
|
44
104
|
projectId: string;
|
|
45
105
|
}
|
|
@@ -47,7 +107,7 @@ export declare function runEnvList(opts: EnvListOptions, deps?: ProjectDeps): Pr
|
|
|
47
107
|
export declare function runEnvGet(opts: EnvListOptions & {
|
|
48
108
|
name: string;
|
|
49
109
|
}, deps?: ProjectDeps): Promise<CliProjectEnvUpdateResponse>;
|
|
50
|
-
interface EnvCreateOptions extends CommonOptions {
|
|
110
|
+
interface EnvCreateOptions extends CommonOptions, ApiAuthFlags {
|
|
51
111
|
projectId: string;
|
|
52
112
|
name?: string;
|
|
53
113
|
url?: string;
|
|
@@ -66,7 +126,7 @@ interface EnvCreateOptions extends CommonOptions {
|
|
|
66
126
|
sessionTtl?: string;
|
|
67
127
|
}
|
|
68
128
|
export declare function runEnvCreate(opts: EnvCreateOptions, deps?: ProjectDeps): Promise<CliProjectEnvCreateResponse>;
|
|
69
|
-
interface EnvUpdateOptions extends CommonOptions {
|
|
129
|
+
interface EnvUpdateOptions extends CommonOptions, ApiAuthFlags {
|
|
70
130
|
projectId: string;
|
|
71
131
|
name: string;
|
|
72
132
|
url?: string;
|