@testsprite/testsprite-cli 0.1.2 → 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/dist/commands/agent.d.ts +9 -0
- package/dist/commands/agent.js +145 -79
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.js +42 -12
- package/dist/commands/project.js +6 -1
- package/dist/commands/test.d.ts +26 -11
- package/dist/commands/test.js +226 -97
- package/dist/index.js +38 -16
- package/dist/lib/agent-targets.d.ts +102 -21
- package/dist/lib/agent-targets.js +153 -34
- package/dist/lib/bundle.d.ts +17 -1
- package/dist/lib/bundle.js +110 -53
- package/dist/lib/client-factory.d.ts +18 -0
- package/dist/lib/client-factory.js +42 -2
- package/dist/lib/credentials.d.ts +7 -0
- package/dist/lib/credentials.js +30 -0
- package/dist/lib/dry-run/samples.js +26 -9
- package/dist/lib/render-error.d.ts +13 -0
- package/dist/lib/render-error.js +27 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-onboard.skill.md +162 -0
- package/skills/testsprite-verify.codex.md +2 -0
- package/skills/testsprite-verify.skill.md +19 -1
package/dist/commands/agent.d.ts
CHANGED
|
@@ -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;
|
package/dist/commands/agent.js
CHANGED
|
@@ -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,
|
|
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.
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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({
|
|
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({
|
|
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({
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
|
|
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
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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
|
-
|
|
446
|
-
//
|
|
447
|
-
|
|
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
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
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
|
|
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);
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -52,9 +52,15 @@ 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
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -15,7 +15,7 @@ import { CLIError } from '../lib/errors.js';
|
|
|
15
15
|
import { GLOBAL_OPTS_HINT, Output } from '../lib/output.js';
|
|
16
16
|
import { runConfigure, runWhoami } from './auth.js';
|
|
17
17
|
import { runInstall } from './agent.js';
|
|
18
|
-
import { TARGETS } from '../lib/agent-targets.js';
|
|
18
|
+
import { TARGETS, DEFAULT_SKILLS } from '../lib/agent-targets.js';
|
|
19
19
|
import { readProfile } from '../lib/credentials.js';
|
|
20
20
|
/** Mirrors auth.ts's DEFAULT_API_URL (kept in sync; auth.ts owns the canonical value). */
|
|
21
21
|
const DEFAULT_API_URL = 'https://api.testsprite.com';
|
|
@@ -39,6 +39,20 @@ function resolveReportedEndpoint(opts, deps) {
|
|
|
39
39
|
}
|
|
40
40
|
return opts.endpointUrl ?? envApiUrl ?? existing ?? DEFAULT_API_URL;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Collapse the per-skill install actions into one representative action for the
|
|
44
|
+
* init summary. Precedence: a real change (updated) outranks a fresh install,
|
|
45
|
+
* which outranks a no-op. `blocked` never reaches here — runInstall throws first.
|
|
46
|
+
*/
|
|
47
|
+
function aggregateInstallAction(actions) {
|
|
48
|
+
if (actions.some(a => a === 'updated' || a === 'section-updated'))
|
|
49
|
+
return 'updated';
|
|
50
|
+
if (actions.some(a => a === 'written' || a === 'section-installed'))
|
|
51
|
+
return 'installed';
|
|
52
|
+
if (actions.some(a => a === 'dry-run'))
|
|
53
|
+
return 'dry-run';
|
|
54
|
+
return 'skipped'; // all skipped / section-unchanged
|
|
55
|
+
}
|
|
42
56
|
// ---------------------------------------------------------------------------
|
|
43
57
|
// Helpers to split deps into the two primitive shapes
|
|
44
58
|
// ---------------------------------------------------------------------------
|
|
@@ -140,7 +154,9 @@ export async function runInit(opts, deps = {}) {
|
|
|
140
154
|
apiUrl: resolveReportedEndpoint(opts, deps),
|
|
141
155
|
env: 'development',
|
|
142
156
|
scopes: [],
|
|
143
|
-
agent: agentTarget
|
|
157
|
+
agent: agentTarget
|
|
158
|
+
? { target: agentTarget, action: 'dry-run', skills: [...DEFAULT_SKILLS] }
|
|
159
|
+
: null,
|
|
144
160
|
status: 'initialized',
|
|
145
161
|
};
|
|
146
162
|
out.print(summary, renderInitText);
|
|
@@ -187,16 +203,19 @@ export async function runInit(opts, deps = {}) {
|
|
|
187
203
|
// -------------------------------------------------------------------------
|
|
188
204
|
let installedTarget = null;
|
|
189
205
|
let installedAction = null;
|
|
206
|
+
let installedSkills = [];
|
|
190
207
|
if (!opts.noAgent) {
|
|
191
|
-
// Run install in JSON mode internally so we can reliably parse the
|
|
208
|
+
// Run install in JSON mode internally so we can reliably parse the result
|
|
192
209
|
// regardless of the outer --output flag. The stdout is captured here and
|
|
193
|
-
// NOT forwarded — runInit owns the output surface.
|
|
194
|
-
|
|
210
|
+
// NOT forwarded — runInit owns the output surface. setup installs the full
|
|
211
|
+
// DEFAULT_SKILLS set (runInstall's default), so several InstallResults come
|
|
212
|
+
// back (one per own-file skill; one aggregate for codex).
|
|
213
|
+
let capturedInstallResults = [];
|
|
195
214
|
const captureStdout = (line) => {
|
|
196
215
|
try {
|
|
197
216
|
const parsed = JSON.parse(line);
|
|
198
|
-
if (Array.isArray(parsed) && parsed.length > 0
|
|
199
|
-
|
|
217
|
+
if (Array.isArray(parsed) && parsed.length > 0) {
|
|
218
|
+
capturedInstallResults = parsed;
|
|
200
219
|
}
|
|
201
220
|
}
|
|
202
221
|
catch {
|
|
@@ -208,13 +227,17 @@ export async function runInit(opts, deps = {}) {
|
|
|
208
227
|
...opts,
|
|
209
228
|
output: 'json', // parse the result; final summary is ours to print
|
|
210
229
|
target: [opts.agent],
|
|
230
|
+
// skills omitted → runInstall installs DEFAULT_SKILLS (verify + onboard)
|
|
211
231
|
force: opts.force,
|
|
212
232
|
dir: opts.dir,
|
|
213
233
|
}, toAgentDeps(deps, captureStdout));
|
|
214
234
|
installedTarget = opts.agent;
|
|
215
|
-
installedAction =
|
|
216
|
-
|
|
217
|
-
|
|
235
|
+
installedAction =
|
|
236
|
+
capturedInstallResults.length > 0
|
|
237
|
+
? aggregateInstallAction(capturedInstallResults.map(r => r.action))
|
|
238
|
+
: 'installed';
|
|
239
|
+
// De-dupe skills across results, preserving first-seen order.
|
|
240
|
+
installedSkills = [...new Set(capturedInstallResults.flatMap(r => r.skills ?? []))];
|
|
218
241
|
}
|
|
219
242
|
catch (installErr) {
|
|
220
243
|
// Fix 6: credentials were already saved (Step 1+2 above succeeded).
|
|
@@ -230,7 +253,11 @@ export async function runInit(opts, deps = {}) {
|
|
|
230
253
|
// -------------------------------------------------------------------------
|
|
231
254
|
const agentSummary = opts.noAgent || installedTarget === null
|
|
232
255
|
? null
|
|
233
|
-
: {
|
|
256
|
+
: {
|
|
257
|
+
target: installedTarget,
|
|
258
|
+
action: installedAction ?? 'installed',
|
|
259
|
+
skills: installedSkills.length > 0 ? installedSkills : [...DEFAULT_SKILLS],
|
|
260
|
+
};
|
|
234
261
|
const summary = {
|
|
235
262
|
profile: opts.profile,
|
|
236
263
|
// Resolved AFTER configure persists the profile → reflects the real endpoint
|
|
@@ -262,6 +289,9 @@ function renderInitText(data) {
|
|
|
262
289
|
lines.push('');
|
|
263
290
|
if (s.agent) {
|
|
264
291
|
lines.push(` agent: ${s.agent.target} (${s.agent.action})`);
|
|
292
|
+
if (s.agent.skills && s.agent.skills.length > 0) {
|
|
293
|
+
lines.push(` skills: ${s.agent.skills.join(', ')}`);
|
|
294
|
+
}
|
|
265
295
|
}
|
|
266
296
|
else {
|
|
267
297
|
lines.push(' agent: skipped (--no-agent)');
|
|
@@ -298,7 +328,7 @@ function parseRequestTimeoutFlag(raw) {
|
|
|
298
328
|
return undefined;
|
|
299
329
|
return Math.round(n * 1000);
|
|
300
330
|
}
|
|
301
|
-
const SETUP_DESCRIPTION = 'Set up TestSprite: configure your API key and install the
|
|
331
|
+
const SETUP_DESCRIPTION = 'Set up TestSprite: configure your API key and install the TestSprite agent skills for your coding agent';
|
|
302
332
|
/** Attach the onboarding flags shared by `setup` and the `init` alias. */
|
|
303
333
|
function addSetupOptions(cmd, validTargets, defaultAgent) {
|
|
304
334
|
return cmd
|
package/dist/commands/project.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import { makeHttpClient, } from '../lib/client-factory.js';
|
|
4
|
+
import { emitDryRunBanner, makeHttpClient, } from '../lib/client-factory.js';
|
|
5
5
|
import { ApiError } from '../lib/errors.js';
|
|
6
6
|
import { GLOBAL_OPTS_HINT, Output } from '../lib/output.js';
|
|
7
7
|
import { assertNotLocal } from '../lib/target-url.js';
|
|
@@ -64,6 +64,9 @@ export async function runCreate(opts, deps = {}) {
|
|
|
64
64
|
throw localValidationError('--url is required for --type frontend');
|
|
65
65
|
}
|
|
66
66
|
if (opts.dryRun) {
|
|
67
|
+
// DEV-247: this path returns before makeClient() fires the banner, so emit it
|
|
68
|
+
// here — otherwise the canned sample can be mistaken for a live response.
|
|
69
|
+
emitDryRunBanner(stderr);
|
|
67
70
|
const idempotencyKey = opts.idempotencyKey ?? `cli-proj-create-${randomUUID()}`;
|
|
68
71
|
// P2-6: gate idempotency-key output behind --verbose/--debug/json (matches
|
|
69
72
|
// test create convention). Suppress in plain text interactive mode to reduce
|
|
@@ -144,6 +147,8 @@ export async function runUpdate(opts, deps = {}) {
|
|
|
144
147
|
throw localValidationError('At least one mutable flag is required: --name, --url, --username, --password/--password-file, --description, or --instruction.');
|
|
145
148
|
}
|
|
146
149
|
if (opts.dryRun) {
|
|
150
|
+
// DEV-247: emit the banner here (this path returns before makeClient() does).
|
|
151
|
+
emitDryRunBanner(stderr);
|
|
147
152
|
const idempotencyKey = opts.idempotencyKey ?? `cli-proj-update-${randomUUID()}`;
|
|
148
153
|
if (opts.idempotencyKey === undefined &&
|
|
149
154
|
(opts.output === 'json' || opts.verbose || opts.debug)) {
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -110,11 +110,10 @@ export interface CliTestStep {
|
|
|
110
110
|
* — agents must not switch on raw strings outside the enumerated set.
|
|
111
111
|
*/
|
|
112
112
|
export type CliFailureKind = 'assertion' | 'assertion_blocked' | 'routing_404' | 'network_timeout' | 'network' | 'timeout' | 'browser_crash' | 'infra' | 'unknown' | null;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
113
|
+
/** test VERDICT (the outcome of a completed run). */
|
|
114
|
+
export type CliVerdict = 'passed' | 'failed' | 'blocked';
|
|
115
|
+
/** execution LIFECYCLE (where the test is in its run lifecycle). */
|
|
116
|
+
export type CliExecutionStatus = 'draft' | 'ready' | 'queued' | 'running' | 'completed' | 'cancelled' | 'unknown';
|
|
118
117
|
/** §6.5 LatestResult wire shape. All correlation fields are required. */
|
|
119
118
|
export interface CliLatestResult {
|
|
120
119
|
testId: string;
|
|
@@ -146,7 +145,20 @@ export interface CliLatestResult {
|
|
|
146
145
|
targetUrlSource?: 'run' | 'project-default' | 'unresolved' | null;
|
|
147
146
|
failedStepIndex: number | null;
|
|
148
147
|
failureKind: CliFailureKind;
|
|
149
|
-
|
|
148
|
+
/**
|
|
149
|
+
* the test VERDICT only (`passed | failed | blocked`), or `null`
|
|
150
|
+
* when the latest run produced no verdict yet (never run / queued / running /
|
|
151
|
+
* cancelled). Lifecycle lives in `executionStatus`; `status` above is the
|
|
152
|
+
* legacy conflated field, retained for back-compat.
|
|
153
|
+
*/
|
|
154
|
+
verdict: CliVerdict | null;
|
|
155
|
+
/** the execution LIFECYCLE (terminal runs collapse to `completed`). */
|
|
156
|
+
executionStatus: CliExecutionStatus;
|
|
157
|
+
/**
|
|
158
|
+
* a human/agent-readable description of the latest run (replaces the
|
|
159
|
+
* former `{passed,failed,skipped}` count object).
|
|
160
|
+
*/
|
|
161
|
+
summary: string;
|
|
150
162
|
/**
|
|
151
163
|
* §6.5.1 (M2.1 piece 3) — inline failure analysis. Present when the
|
|
152
164
|
* caller passed `--include-analysis` (`?includeAnalysis=true` on
|
|
@@ -815,11 +827,14 @@ interface CodeGetOptions extends CommonOptions {
|
|
|
815
827
|
* directly; presigned URLs are dereferenced via the same fetch impl
|
|
816
828
|
* (without API-key headers — the URL is the bearer of authority).
|
|
817
829
|
*
|
|
818
|
-
* `--out <path>` redirects the same bytes into a file. We
|
|
819
|
-
* before issuing the network request
|
|
820
|
-
* fast (exit 5 / VALIDATION_ERROR)
|
|
821
|
-
*
|
|
822
|
-
*
|
|
830
|
+
* `--out <path>` redirects the same bytes into a file. We validate the
|
|
831
|
+
* path and open a sibling temp file before issuing the network request
|
|
832
|
+
* so a permission/dir error fails fast (exit 5 / VALIDATION_ERROR)
|
|
833
|
+
* without spending an API call. The temp file is renamed onto the real
|
|
834
|
+
* `--out` path only after a successful, complete write; on any error
|
|
835
|
+
* (or the "no code generated yet" branch, which writes nothing) the
|
|
836
|
+
* temp file is discarded and the user's pre-existing `--out` file, if
|
|
837
|
+
* any, is left untouched.
|
|
823
838
|
*/
|
|
824
839
|
export declare function runCodeGet(opts: CodeGetOptions, deps?: TestDeps): Promise<CliTestCode>;
|
|
825
840
|
/**
|