@testsprite/testsprite-cli 0.1.1 → 0.2.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 CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  <a href="https://www.testsprite.com">
4
4
  <picture>
5
- <source media="(prefers-color-scheme: dark)" srcset="assets/testsprite-logo-dark.svg">
6
- <source media="(prefers-color-scheme: light)" srcset="assets/testsprite-logo-light.svg">
7
- <img src="assets/testsprite-logo-dark.svg" alt="TestSprite" width="420">
5
+ <source media="(prefers-color-scheme: dark)" srcset="assets/testsprite-logo-dark.png">
6
+ <source media="(prefers-color-scheme: light)" srcset="assets/testsprite-logo-light.png">
7
+ <img src="assets/testsprite-logo-light.png" alt="TestSprite" width="420">
8
8
  </picture>
9
9
  </a>
10
10
 
@@ -34,9 +34,9 @@ AI ships code in minutes — verifying it hasn't. `testsprite` opens your live a
34
34
 
35
35
  </div>
36
36
 
37
- https://github.com/user-attachments/assets/eca90a91-93ef-49f6-8d13-86b4eb25f4cf
37
+ <video src="https://github.com/user-attachments/assets/eca90a91-93ef-49f6-8d13-86b4eb25f4cf" controls muted></video>
38
38
 
39
- <p align="center"><sub><b>▶ Watch the launch video</b> — the three hard limits every coding agent hits, and the loop that breaks them (4 min).</sub></p>
39
+ <p align="center"><sub><b><a href="https://github.com/user-attachments/assets/eca90a91-93ef-49f6-8d13-86b4eb25f4cf">▶ Watch the launch video</a></b> — the three hard limits every coding agent hits, and the loop that breaks them (4 min).</sub></p>
40
40
 
41
41
  ---
42
42
 
@@ -58,15 +58,17 @@ Requires **Node.js ≥ 20**. (No global install? `npx @testsprite/testsprite-cli
58
58
 
59
59
  ```bash
60
60
  npm install -g @testsprite/testsprite-cli
61
- testsprite init
61
+ testsprite setup
62
62
  ```
63
63
 
64
- `testsprite init` prompts for your [API key](https://www.testsprite.com), verifies it, and installs the verification-loop skill for your coding agent (`claude`, `cursor`, `cline`, `antigravity`, `codex`, etc.). Non-interactive (CI / onboarding scripts):
64
+ `testsprite setup` prompts for your [API key](https://www.testsprite.com), verifies it, and installs the verification-loop skill for your coding agent (`claude`, `cursor`, `cline`, `antigravity`, `codex`, etc.) — one command, so your agent is wired to verify its own work. Non-interactive (CI / onboarding scripts):
65
65
 
66
66
  ```bash
67
- TESTSPRITE_API_KEY=sk-... testsprite init --from-env --yes --agent claude
67
+ TESTSPRITE_API_KEY=sk-... testsprite setup --from-env --yes --agent claude
68
68
  ```
69
69
 
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
+
70
72
  From there, the loop runs on its own — an example session, typed by the coding agent:
71
73
 
72
74
  ```bash
@@ -89,10 +91,9 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
89
91
 
90
92
  | Group | Command | What it does |
91
93
  | --------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
92
- | **Init** | `init` | One-shot onboarding: auth configure + whoami + agent install |
93
- | **Auth** | `auth configure` | Store an API key at `~/.testsprite/credentials` |
94
- | | `auth whoami` _(alias `status`)_ | Resolve the active profile to its user, key, env, and scopes |
95
- | | `auth logout` | Remove the active profile from the credentials file |
94
+ | **Setup** | `setup` | **Start here** — one command: configure your API key, verify it, and install the agent verification skill |
95
+ | **Auth** | `auth status` | Resolve the active profile to its user, key, env, and scopes |
96
+ | | `auth remove` | Remove the active profile from the credentials file |
96
97
  | **Read** | `project list` / `project get` | List projects / fetch one by id |
97
98
  | | `test list` / `test get` | List tests under a project / fetch one by id |
98
99
  | | `test code get` | Print (or write) the generated test source |
@@ -109,7 +110,9 @@ Prefer to configure each step by hand (or learn the surface offline with `--dry-
109
110
  | | `test rerun` | Cheap replay of one/many tests (FE verbatim; BE with deps); `--all --project <id>` reruns all tests |
110
111
  | | `test wait` | Block on a `runId` until terminal |
111
112
  | | `test artifact get` | Download the failure bundle for a specific `runId` |
112
- | **Agent** | `agent install` / `agent list` | Onboard a coding agent (pure-local); targets: `claude`, `codex`, `cursor`, `cline`, `antigravity` |
113
+ | **Agent** | `agent install` / `agent list` | Add or list coding-agent targets (pure-local): `claude`, `codex`, `cursor`, `cline`, `antigravity` |
114
+
115
+ > 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).
113
116
 
114
117
  📚 **Full reference — every command, flag, and example:** [DOCUMENTATION.md](./DOCUMENTATION.md), including [configuration & profiles](./DOCUMENTATION.md#configuration), [scripting](./DOCUMENTATION.md#output--scripting), and [exit codes](./DOCUMENTATION.md#exit-codes).
115
118
 
@@ -32,16 +32,25 @@ export interface InstallResult {
32
32
  target: AgentTarget;
33
33
  path: string;
34
34
  action: InstallAction;
35
+ /**
36
+ * Skill(s) this result covers. Own-file targets produce one result per skill
37
+ * (`[skill]`); the codex managed-section target produces ONE result whose
38
+ * section aggregates every installed skill (`[...skills]`).
39
+ */
40
+ skills: string[];
35
41
  }
36
42
  type CommonOptions = FactoryCommonOptions;
37
43
  interface InstallOptions extends CommonOptions {
38
44
  target: string[];
45
+ /** Skill subset to install; empty/absent → {@link DEFAULT_SKILLS}. */
46
+ skills?: string[];
39
47
  dir?: string;
40
48
  force: boolean;
41
49
  }
42
50
  export declare function runInstall(opts: InstallOptions, deps?: AgentDeps): Promise<void>;
43
51
  export interface ListResult {
44
52
  target: AgentTarget;
53
+ skill: string;
45
54
  status: string;
46
55
  mode: string;
47
56
  path: string;
@@ -4,7 +4,7 @@ import { Command } from 'commander';
4
4
  import { CLIError, localValidationError } from '../lib/errors.js';
5
5
  import { GLOBAL_OPTS_HINT, Output } from '../lib/output.js';
6
6
  import { promptText } from '../lib/prompt.js';
7
- import { TARGETS, loadSkillBody, loadCodexSkillBody, renderForTarget, MANAGED_SECTION_BEGIN, MANAGED_SECTION_END, } from '../lib/agent-targets.js';
7
+ import { TARGETS, SKILLS, DEFAULT_SKILLS, pathFor, loadSkillBodyFor, buildCodexAggregate, renderForTarget, MANAGED_SECTION_BEGIN, MANAGED_SECTION_END, } from '../lib/agent-targets.js';
8
8
  // ---------------------------------------------------------------------------
9
9
  // Constants
10
10
  // ---------------------------------------------------------------------------
@@ -252,31 +252,64 @@ export async function runInstall(opts, deps = {}) {
252
252
  seen.add(t);
253
253
  return true;
254
254
  });
255
+ // 2b. Resolve + validate the skill set (empty/absent → DEFAULT_SKILLS).
256
+ // Accepts comma-separated or repeated --skill values, same shape as --target.
257
+ const rawSkills = (opts.skills ?? [])
258
+ .flatMap(s => s.split(','))
259
+ .map(s => s.trim())
260
+ .filter(Boolean);
261
+ const validSkills = Object.keys(SKILLS);
262
+ for (const s of rawSkills) {
263
+ if (!validSkills.includes(s)) {
264
+ throw localValidationError('skill', `unknown skill "${s}"; supported: ${validSkills.join(', ')}`);
265
+ }
266
+ }
267
+ const seenSkill = new Set();
268
+ const skills = (rawSkills.length > 0 ? rawSkills : [...DEFAULT_SKILLS]).filter(s => {
269
+ if (seenSkill.has(s))
270
+ return false;
271
+ seenSkill.add(s);
272
+ return true;
273
+ });
255
274
  // 3. Resolve dir
256
275
  const dir = opts.dir ?? deps.cwd ?? process.cwd();
257
276
  const root = path.resolve(dir);
258
- // 4. Load skill bodies (lazy — only touch disk if a target actually needs it)
259
- let ownFileBody;
260
- let codexBody;
277
+ // 4. Lazy asset loaders — only touch disk if a target actually needs it.
278
+ // own-file bodies are per-skill (cached); the codex section aggregates EVERY
279
+ // installed skill's contribution into ONE managed section.
280
+ const skillBodyCache = new Map();
281
+ const bodyForSkill = (skill) => {
282
+ let b = skillBodyCache.get(skill);
283
+ if (b === undefined) {
284
+ b = loadSkillBodyFor(skill);
285
+ skillBodyCache.set(skill, b);
286
+ }
287
+ return b;
288
+ };
289
+ let codexSectionCache;
290
+ const getCodexSection = () => {
291
+ if (codexSectionCache === undefined) {
292
+ codexSectionCache = buildSection(buildCodexAggregate(skills));
293
+ }
294
+ return codexSectionCache;
295
+ };
261
296
  const results = [];
262
297
  // Track bytes for dry-run output
263
298
  const dryRunLines = [];
264
299
  // 5. Process each target
265
300
  for (const t of targets) {
266
301
  const spec = TARGETS[t];
267
- const relPath = spec.path;
268
- const abs = path.resolve(root, relPath);
269
- // Path safety: ensure abs is inside root (defense against .. in relPath or dir)
270
- if (abs !== root && !abs.startsWith(root + path.sep)) {
271
- throw new CLIError(`refusing to write outside --dir: ${relPath}`, 5);
272
- }
273
302
  // -----------------------------------------------------------------------
274
- // managed-section mode (codex target)
303
+ // managed-section mode (codex target) — ONE section aggregating all skills
275
304
  // -----------------------------------------------------------------------
276
305
  if (spec.mode === 'managed-section') {
277
- if (codexBody === undefined)
278
- codexBody = loadCodexSkillBody();
279
- const section = buildSection(codexBody);
306
+ const relPath = spec.path; // 'AGENTS.md' — skill-independent (all skills merge here)
307
+ const abs = path.resolve(root, relPath);
308
+ // Path safety: ensure abs is inside root (defense against .. in relPath or dir)
309
+ if (abs !== root && !abs.startsWith(root + path.sep)) {
310
+ throw new CLIError(`refusing to write outside --dir: ${relPath}`, 5);
311
+ }
312
+ const section = getCodexSection();
280
313
  if (opts.dryRun) {
281
314
  // Dry-run: report what would happen without writing disk.
282
315
  //
@@ -334,7 +367,7 @@ export async function runInstall(opts, deps = {}) {
334
367
  stderrFn(`[warn] ${relPath} will be ${wouldBeBytes} bytes after this write — Codex may not load content beyond its 32 KiB (${AGENTS_MD_CODEX_BUDGET_BYTES} byte) budget. Trim AGENTS.md to stay within the limit.`);
335
368
  }
336
369
  dryRunLines.push({ abs, bytes, note: 'managed section' });
337
- results.push({ target: t, path: relPath, action: 'dry-run' });
370
+ results.push({ target: t, path: relPath, action: 'dry-run', skills: [...skills] });
338
371
  continue;
339
372
  }
340
373
  // Inspect the target path via lstat walk (symlink-safe, same as own-file).
@@ -366,7 +399,12 @@ export async function runInstall(opts, deps = {}) {
366
399
  }
367
400
  throw err;
368
401
  }
369
- results.push({ target: t, path: relPath, action: 'section-installed' });
402
+ results.push({
403
+ target: t,
404
+ path: relPath,
405
+ action: 'section-installed',
406
+ skills: [...skills],
407
+ });
370
408
  }
371
409
  else {
372
410
  const existing = await agentFs.readFile(abs);
@@ -377,13 +415,23 @@ export async function runInstall(opts, deps = {}) {
377
415
  `Manually remove the partial sentinel block and re-run.`, 5);
378
416
  }
379
417
  if (state.kind === 'unchanged') {
380
- results.push({ target: t, path: relPath, action: 'section-unchanged' });
418
+ results.push({
419
+ target: t,
420
+ path: relPath,
421
+ action: 'section-unchanged',
422
+ skills: [...skills],
423
+ });
381
424
  }
382
425
  else if (state.kind === 'create') {
383
426
  // Shouldn't happen (st !== null means file exists), but guard anyway.
384
427
  warnIfOverBudget(section);
385
428
  await agentFs.writeFile(abs, section);
386
- results.push({ target: t, path: relPath, action: 'section-installed' });
429
+ results.push({
430
+ target: t,
431
+ path: relPath,
432
+ action: 'section-installed',
433
+ skills: [...skills],
434
+ });
387
435
  }
388
436
  else {
389
437
  // 'append' or 'replace' — write the new content.
@@ -394,69 +442,75 @@ export async function runInstall(opts, deps = {}) {
394
442
  warnIfOverBudget(newContent);
395
443
  await agentFs.writeFile(abs, newContent);
396
444
  const action = state.kind === 'append' ? 'section-installed' : 'section-updated';
397
- results.push({ target: t, path: relPath, action });
445
+ results.push({ target: t, path: relPath, action, skills: [...skills] });
398
446
  }
399
447
  }
400
448
  continue;
401
449
  }
402
450
  // -----------------------------------------------------------------------
403
- // own-file mode (all other targets)
451
+ // own-file mode (all other targets) — one file per skill
404
452
  // -----------------------------------------------------------------------
405
- if (ownFileBody === undefined)
406
- ownFileBody = loadSkillBody();
407
- const content = renderForTarget(t, ownFileBody).content;
408
- if (opts.dryRun) {
409
- const bytes = Buffer.byteLength(content, 'utf8');
410
- dryRunLines.push({ abs, bytes, note: '' });
411
- results.push({ target: t, path: relPath, action: 'dry-run' });
412
- continue;
413
- }
414
- // Inspect the target path: refuse to traverse or write through a symlink
415
- // (fs writes follow symlinks, which would let a planted symlink escape
416
- // --dir), and reject a non-regular-file landing path. The lexical guard
417
- // above is necessary but not sufficient — it cannot see symlinks.
418
- const st = await inspectTargetPath(agentFs, root, relPath);
419
- if (st !== null && !st.isFile) {
420
- throw new CLIError(`${relPath} exists but is not a regular file — remove it and re-run.`, 5);
421
- }
422
- if (st === null) {
423
- // Path does not exist — create it. inspectTargetPath verified every
424
- // existing ancestor is a real directory; exclusive create (wx) then
425
- // ensures a file or symlink that races in after the check is not followed
426
- // or silently overwritten.
427
- await agentFs.mkdir(path.dirname(abs));
428
- try {
429
- await agentFs.writeFile(abs, content, { exclusive: true });
453
+ for (const skill of skills) {
454
+ const relPath = pathFor(t, skill);
455
+ const abs = path.resolve(root, relPath);
456
+ // Path safety: ensure abs is inside root (defense against .. in relPath or dir)
457
+ if (abs !== root && !abs.startsWith(root + path.sep)) {
458
+ throw new CLIError(`refusing to write outside --dir: ${relPath}`, 5);
430
459
  }
431
- catch (err) {
432
- if (err instanceof Error && err.code === 'EEXIST') {
433
- throw new CLIError(`${relPath} appeared after the path check — re-run, or pass --force to overwrite.`, 6);
434
- }
435
- throw err;
460
+ const content = renderForTarget(t, skill, bodyForSkill(skill)).content;
461
+ if (opts.dryRun) {
462
+ const bytes = Buffer.byteLength(content, 'utf8');
463
+ dryRunLines.push({ abs, bytes, note: '' });
464
+ results.push({ target: t, path: relPath, action: 'dry-run', skills: [skill] });
465
+ continue;
436
466
  }
437
- results.push({ target: t, path: relPath, action: 'written' });
438
- }
439
- else {
440
- const existing = await agentFs.readFile(abs);
441
- if (existing === content) {
442
- // Byte-identical — skip
443
- results.push({ target: t, path: relPath, action: 'skipped' });
467
+ // Inspect the target path: refuse to traverse or write through a symlink
468
+ // (fs writes follow symlinks, which would let a planted symlink escape
469
+ // --dir), and reject a non-regular-file landing path. The lexical guard
470
+ // above is necessary but not sufficient — it cannot see symlinks.
471
+ const st = await inspectTargetPath(agentFs, root, relPath);
472
+ if (st !== null && !st.isFile) {
473
+ throw new CLIError(`${relPath} exists but is not a regular file — remove it and re-run.`, 5);
444
474
  }
445
- else if (!opts.force) {
446
- // Differs and no --force → blocked
447
- results.push({ target: t, path: relPath, action: 'blocked' });
475
+ if (st === null) {
476
+ // Path does not exist — create it. inspectTargetPath verified every
477
+ // existing ancestor is a real directory; exclusive create (wx) then
478
+ // ensures a file or symlink that races in after the check is not followed
479
+ // or silently overwritten.
480
+ await agentFs.mkdir(path.dirname(abs));
481
+ try {
482
+ await agentFs.writeFile(abs, content, { exclusive: true });
483
+ }
484
+ catch (err) {
485
+ if (err instanceof Error && err.code === 'EEXIST') {
486
+ throw new CLIError(`${relPath} appeared after the path check — re-run, or pass --force to overwrite.`, 6);
487
+ }
488
+ throw err;
489
+ }
490
+ results.push({ target: t, path: relPath, action: 'written', skills: [skill] });
448
491
  }
449
492
  else {
450
- // Differs and --force → back up the current bytes to a fresh slot
451
- // (never clobbering an existing backup or following a symlink), then
452
- // overwrite. The overwrite itself can follow a symlink swapped in after
453
- // the check — an accepted TOCTOU residual for a local, single-user CLI.
454
- const backupPath = await writeBackup(agentFs, abs, existing);
455
- await agentFs.writeFile(abs, content);
456
- if (opts.output === 'text') {
457
- stderrFn(`backed up ${relPath} to ${path.relative(root, backupPath)}`);
493
+ const existing = await agentFs.readFile(abs);
494
+ if (existing === content) {
495
+ // Byte-identical — skip
496
+ results.push({ target: t, path: relPath, action: 'skipped', skills: [skill] });
497
+ }
498
+ else if (!opts.force) {
499
+ // Differs and no --force → blocked
500
+ results.push({ target: t, path: relPath, action: 'blocked', skills: [skill] });
501
+ }
502
+ else {
503
+ // Differs and --force → back up the current bytes to a fresh slot
504
+ // (never clobbering an existing backup or following a symlink), then
505
+ // overwrite. The overwrite itself can follow a symlink swapped in after
506
+ // the check — an accepted TOCTOU residual for a local, single-user CLI.
507
+ const backupPath = await writeBackup(agentFs, abs, existing);
508
+ await agentFs.writeFile(abs, content);
509
+ if (opts.output === 'text') {
510
+ stderrFn(`backed up ${relPath} to ${path.relative(root, backupPath)}`);
511
+ }
512
+ results.push({ target: t, path: relPath, action: 'updated', skills: [skill] });
458
513
  }
459
- results.push({ target: t, path: relPath, action: 'updated' });
460
514
  }
461
515
  }
462
516
  }
@@ -486,16 +540,26 @@ export async function runInstall(opts, deps = {}) {
486
540
  }
487
541
  export async function runList(opts, deps = {}) {
488
542
  const out = makeOutput(opts.output, deps);
489
- const results = Object.entries(TARGETS).map(([t, spec]) => ({
490
- target: t,
491
- status: spec.status,
492
- mode: spec.mode,
493
- path: spec.path,
494
- }));
543
+ // One row per (target × default skill). Own-file targets land each skill at a
544
+ // distinct path; the codex managed-section target merges all skills into the
545
+ // single AGENTS.md (so every codex row shares that path — truthful, since both
546
+ // skills' content lands there).
547
+ const results = [];
548
+ for (const [t, spec] of Object.entries(TARGETS)) {
549
+ for (const skill of DEFAULT_SKILLS) {
550
+ results.push({
551
+ target: t,
552
+ skill,
553
+ status: spec.status,
554
+ mode: spec.mode,
555
+ path: pathFor(t, skill),
556
+ });
557
+ }
558
+ }
495
559
  out.print(results, data => {
496
560
  const items = data;
497
- const header = `${'TARGET'.padEnd(14)} ${'STATUS'.padEnd(12)} ${'MODE'.padEnd(18)} PATH`;
498
- const rows = items.map(r => `${r.target.padEnd(14)} ${r.status.padEnd(12)} ${r.mode.padEnd(18)} ${r.path}`);
561
+ const header = `${'TARGET'.padEnd(14)} ${'SKILL'.padEnd(20)} ${'STATUS'.padEnd(12)} ${'MODE'.padEnd(18)} PATH`;
562
+ const rows = items.map(r => `${r.target.padEnd(14)} ${r.skill.padEnd(20)} ${r.status.padEnd(12)} ${r.mode.padEnd(18)} ${r.path}`);
499
563
  return [header, ...rows].join('\n');
500
564
  });
501
565
  }
@@ -509,8 +573,9 @@ export function createAgentCommand(deps = {}) {
509
573
  const agent = new Command('agent').description('Install TestSprite guidance into coding-agent config (Claude Code, Cursor, Cline, Antigravity, Codex)');
510
574
  agent
511
575
  .command('install')
512
- .description('Write the TestSprite verification-loop skill file into a project for a coding agent')
576
+ .description('Write the TestSprite agent skills (verification loop + first-run onboarding) into a project for a coding agent')
513
577
  .option('--target <t>', 'Agent target(s): claude, cursor, cline, antigravity, codex (comma-separated or repeated)', collect, [])
578
+ .option('--skill <name>', `Skill(s) to install: ${Object.keys(SKILLS).join(', ')} (comma-separated or repeated; default: all)`, collect, [])
514
579
  .option('--dir <path>', 'Project root to write into (default: cwd)')
515
580
  .option('--force', 'For own-file targets: overwrite existing file (a .bak backup is kept). ' +
516
581
  'For codex (managed-section): replaces the section unconditionally; user content outside the section is never destroyed.')
@@ -519,13 +584,14 @@ export function createAgentCommand(deps = {}) {
519
584
  await runInstall({
520
585
  ...resolveCommonOptions(command),
521
586
  target: cmdOpts.target,
587
+ skills: cmdOpts.skill,
522
588
  dir: cmdOpts.dir,
523
589
  force: Boolean(cmdOpts.force),
524
590
  }, deps);
525
591
  });
526
592
  agent
527
593
  .command('list')
528
- .description('List supported agent targets, their status, and landing paths')
594
+ .description('List supported agent targets and skills, their status, and landing paths')
529
595
  .addHelpText('after', GLOBAL_OPTS_HINT)
530
596
  .action(async (_o, command) => {
531
597
  await runList(resolveCommonOptions(command), deps);
@@ -26,6 +26,16 @@ export interface AuthDeps {
26
26
  stdout?: (line: string) => void;
27
27
  stderr?: (line: string) => void;
28
28
  preludeWrite?: (chunk: string) => void;
29
+ /**
30
+ * Identifies the higher-level command that invoked `runConfigure`. When set,
31
+ * it is sent as the `X-CLI-Command` request header on the key-validation
32
+ * `GET /me` so the backend can attribute the call for product analytics —
33
+ * e.g. `init` is counted as `cli.initialized` instead of the generic
34
+ * `cli.session_started`. `auth configure` run directly leaves it unset.
35
+ * Advisory only: it never changes behavior, and the backend honors only a
36
+ * known allowlist value.
37
+ */
38
+ commandTag?: string;
29
39
  }
30
40
  type CommonOptions = FactoryCommonOptions;
31
41
  interface ConfigureOptions extends CommonOptions {
@@ -5,6 +5,7 @@ import { facadeBaseUrl } from '../lib/facade.js';
5
5
  import { HttpClient } from '../lib/http.js';
6
6
  import { defaultCredentialsPath, deleteProfile, readProfile, writeProfile, } from '../lib/credentials.js';
7
7
  import { loadConfig } from '../lib/config.js';
8
+ import { emitDeprecationNotice } from '../lib/deprecate.js';
8
9
  import { GLOBAL_OPTS_HINT, Output } from '../lib/output.js';
9
10
  import { promptSecret } from '../lib/prompt.js';
10
11
  const DEFAULT_API_URL = 'https://api.testsprite.com';
@@ -80,7 +81,11 @@ export async function runConfigure(opts, deps = {}) {
80
81
  fetchImpl: deps.fetchImpl,
81
82
  });
82
83
  try {
83
- await pingClient.get('/me');
84
+ // Tag the validation call with the originating command (when provided) so
85
+ // the backend attributes it for product analytics — e.g. `init` → the
86
+ // cli.initialized event instead of the generic cli.session_started. The
87
+ // header is advisory; omitting it changes nothing.
88
+ await pingClient.get('/me', deps.commandTag ? { headers: { 'x-cli-command': deps.commandTag } } : {});
84
89
  }
85
90
  catch (err) {
86
91
  const message = err instanceof Error ? err.message : String(err);
@@ -96,12 +101,10 @@ export async function runConfigure(opts, deps = {}) {
96
101
  const d = data;
97
102
  return `Profile "${d.profile}" configured. Endpoint: ${d.apiUrl}`;
98
103
  });
99
- // Self-bootstrap: nudge the user toward wiring their coding agent to TestSprite.
100
- // stderr + text-only + real-run-only so JSON consumers and dry-run previews stay clean.
101
- if (opts.output === 'text' && !opts.dryRun) {
102
- stderr('Tip: run `testsprite agent install --target=claude` to let your coding ' +
103
- 'agent run TestSprite tests automatically (also: cursor, cline, antigravity).');
104
- }
104
+ // Note: the old "run `testsprite agent install`" self-bootstrap tip was
105
+ // removed with the setup consolidation. `runConfigure` now only runs as part
106
+ // of `setup` (the sole credential-writing path), which installs the skill
107
+ // itself (unless --no-agent) — so the tip would be redundant or misleading.
105
108
  }
106
109
  export async function runWhoami(opts, deps = {}) {
107
110
  const out = makeOutput(opts.output, deps);
@@ -179,29 +182,40 @@ export async function runLogout(opts, deps = {}) {
179
182
  }
180
183
  export function createAuthCommand(deps = {}) {
181
184
  const auth = new Command('auth').description('Manage TestSprite credentials');
185
+ // `status` (primary; formerly `whoami`). Credential WRITES no longer live
186
+ // here — `auth configure` is a hidden, deprecated alias for `setup` (attached
187
+ // in index.ts), and `setup` is the only command that writes credentials.
182
188
  auth
183
- .command('configure')
184
- .description('Configure an API key for the active profile')
185
- .option('--from-env', 'Read TESTSPRITE_API_KEY (and optionally TESTSPRITE_API_URL) from the environment instead of prompting', false)
189
+ .command('status')
190
+ .description('Show the user, API key, env, and scopes bound to the active profile')
186
191
  .addHelpText('after', GLOBAL_OPTS_HINT)
187
- .action(async (cmdOpts, command) => {
188
- await runConfigure({ ...resolveCommonOptions(command), fromEnv: Boolean(cmdOpts.fromEnv) }, deps);
192
+ .action(async (_cmdOpts, command) => {
193
+ await runWhoami(resolveCommonOptions(command), deps);
189
194
  });
195
+ // `whoami` — hidden, deprecated alias for `status` (kept so scripts/agents
196
+ // on the old name keep working; invisible to --help).
190
197
  auth
191
- .command('whoami')
192
- .alias('status') // muscle-memory alias; `auth status` resolves to `auth whoami` (dogfood L1802)
193
- .description('Show the user, API key, and scopes bound to the active profile')
198
+ .command('whoami', { hidden: true })
194
199
  .addHelpText('after', GLOBAL_OPTS_HINT)
195
200
  .action(async (_cmdOpts, command) => {
201
+ emitDeprecationNotice('auth whoami', 'auth status', deps.stderr);
196
202
  await runWhoami(resolveCommonOptions(command), deps);
197
203
  });
198
204
  auth
199
- .command('logout')
205
+ .command('remove')
200
206
  .description('Remove credentials for the active profile')
201
207
  .addHelpText('after', GLOBAL_OPTS_HINT)
202
208
  .action(async (_cmdOpts, command) => {
203
209
  await runLogout(resolveCommonOptions(command), deps);
204
210
  });
211
+ // `logout` — hidden, deprecated alias for `remove`.
212
+ auth
213
+ .command('logout', { hidden: true })
214
+ .addHelpText('after', GLOBAL_OPTS_HINT)
215
+ .action(async (_cmdOpts, command) => {
216
+ emitDeprecationNotice('auth logout', 'auth remove', deps.stderr);
217
+ await runLogout(resolveCommonOptions(command), deps);
218
+ });
205
219
  return auth;
206
220
  }
207
221
  function resolveCommonOptions(command) {
@@ -52,12 +52,32 @@ export interface InitSummary {
52
52
  env: string;
53
53
  email?: string;
54
54
  scopes: string[];
55
+ /**
56
+ * Agent skill install outcome. `action` is an AGGREGATE across the installed
57
+ * skills (setup installs {@link DEFAULT_SKILLS}); `skills` lists which skills
58
+ * landed. `null` when --no-agent.
59
+ */
55
60
  agent: {
56
61
  target: string;
57
62
  action: string;
63
+ skills?: string[];
58
64
  } | null;
59
65
  status: 'initialized';
60
66
  }
61
67
  export declare function runInit(opts: InitOptions, deps?: InitDeps): Promise<void>;
62
- export declare function createInitCommand(deps?: InitDeps): Command;
68
+ export declare function createSetupCommand(deps?: InitDeps): Command;
69
+ /**
70
+ * Hidden, deprecated `init` alias → runs `setup`. Kept so existing scripts and
71
+ * agents trained on the old command keep working; registered with
72
+ * `{ hidden: true }` in index.ts (invisible to `--help`) and prints a
73
+ * deprecation notice. (Setup consolidation.)
74
+ */
75
+ export declare function createDeprecatedInitCommand(deps?: InitDeps): Command;
76
+ /**
77
+ * Entry for the hidden, deprecated `auth configure` alias. Per the setup
78
+ * consolidation, `auth configure` now runs FULL setup (configure + install)
79
+ * so an agent that reaches for the old command still ends up with the skill.
80
+ * `setup` is the ONLY path that writes credentials.
81
+ */
82
+ export declare function runConfigureViaSetup(command: Command, deps: InitDeps, fromEnv: boolean): Promise<void>;
63
83
  export {};