@testsprite/testsprite-cli 0.17.0 → 0.18.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 +5 -4
- package/dist/commands/auth.js +2 -2
- package/dist/commands/conversation.js +52 -13
- package/dist/commands/project-env.js +48 -8
- package/dist/commands/project.d.ts +4 -0
- package/dist/commands/project.js +19 -2
- package/dist/commands/result.js +2 -1
- package/dist/commands/test.d.ts +9 -31
- package/dist/commands/test.js +73 -159
- package/dist/commands/testlist.d.ts +4 -2
- package/dist/commands/testlist.js +32 -4
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +3 -4
- package/dist/index.js +9 -6
- package/dist/lib/client-factory.d.ts +2 -2
- package/dist/lib/client-factory.js +3 -4
- package/dist/lib/conversation/api.d.ts +4 -0
- package/dist/lib/conversation/api.js +1 -0
- package/dist/lib/conversation/context.d.ts +10 -0
- package/dist/lib/conversation/context.js +17 -5
- package/dist/lib/conversation/environment.d.ts +3 -2
- package/dist/lib/conversation/environment.js +5 -17
- package/dist/lib/conversation/render.js +3 -0
- package/dist/lib/conversation/types.d.ts +2 -0
- package/dist/lib/download.d.ts +30 -1
- package/dist/lib/download.js +205 -71
- package/dist/lib/environment-tunnel.d.ts +3 -3
- package/dist/lib/environment-tunnel.js +9 -50
- package/dist/lib/first-suite-hint.d.ts +9 -13
- package/dist/lib/first-suite-hint.js +29 -35
- package/dist/lib/http.d.ts +1 -1
- package/dist/lib/http.js +5 -5
- package/dist/lib/local-target.d.ts +5 -4
- package/dist/lib/local-target.js +11 -10
- package/dist/lib/output.d.ts +1 -1
- package/dist/lib/output.js +2 -2
- package/dist/lib/presigned-url.js +2 -2
- package/dist/lib/removed-commands.js +17 -1
- package/dist/lib/result/evidence.d.ts +2 -0
- package/dist/lib/result/evidence.js +2 -0
- package/dist/lib/run-output.d.ts +3 -3
- package/dist/lib/target-url.d.ts +7 -7
- package/dist/lib/target-url.js +8 -8
- package/dist/lib/telemetry.d.ts +4 -4
- package/dist/lib/telemetry.js +1 -1
- package/dist/lib/transport-failure.js +2 -2
- package/dist/lib/tunnel-session.d.ts +1 -1
- package/dist/lib/tunnel-session.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/skills/testsprite-ci.skill.md +4 -5
- package/skills/testsprite-onboard.skill.md +14 -12
- package/skills/testsprite-verify.codex.md +12 -14
- package/skills/testsprite-verify.skill.md +19 -21
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ PROJECT_ID=your-project-id
|
|
|
73
73
|
testsprite project env create "$PROJECT_ID" --name staging --url https://staging.example.com
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
**Get your first test.** Ask the project's agent to propose coverage. If it asks a question in a text message, answer with `testsprite reply "your answer"`. Review the proposed steps in the terminal and apply the plan when they match what you want to verify. For a backend project, attach the API specification with `--file ./openapi.yaml`.
|
|
76
|
+
**Get your first test.** Ask the project's agent to propose coverage. If it asks a question in a text message, answer with `testsprite reply "your answer"`. For a question card, submit all the numbered answers together with `testsprite apply --answer 1=b --answer 2=a,c`. Review the proposed steps in the terminal and apply the plan when they match what you want to verify. For a backend project, attach the API specification with `--file ./openapi.yaml`.
|
|
77
77
|
|
|
78
78
|
```bash
|
|
79
79
|
testsprite plan "Verify that a guest can place an order with a test card" --project "$PROJECT_ID" --steps
|
|
@@ -99,13 +99,14 @@ After deploying a fix, run the affected test again with `testsprite run "$TEST_I
|
|
|
99
99
|
|
|
100
100
|
## Testing an environment on your machine
|
|
101
101
|
|
|
102
|
-
Start your frontend app on port 3000
|
|
102
|
+
Start your frontend app on port 3000 and save it as the project's environment. A run on that environment opens a tunnel from this machine and waits for the cloud runner.
|
|
103
103
|
|
|
104
104
|
```bash
|
|
105
|
-
testsprite
|
|
105
|
+
testsprite project env create "$PROJECT_ID" --name local --url http://localhost:3000
|
|
106
|
+
testsprite run --project "$PROJECT_ID" --env local
|
|
106
107
|
```
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
The project's agent explores the app through the same kind of tunnel: ask it with `testsprite plan`, and when it asks for a tunnel, run `testsprite tunnel start` in another terminal and `testsprite reply "The tunnel is running."`. Review and apply the test plan, then run with `--env local`. An ordinary Ctrl-C detaches a public run. With a tunnel this command opened, Ctrl-C cancels unfinished work by default and closes the tunnel. [Local frontend testing and tunnels](./DOCUMENTATION.md#local-frontend-testing-and-tunnels)
|
|
109
110
|
|
|
110
111
|
## Commands
|
|
111
112
|
|
package/dist/commands/auth.js
CHANGED
|
@@ -173,12 +173,12 @@ export async function runConfigure(opts, deps = {}) {
|
|
|
173
173
|
// Augment the message with the endpoint context so text-mode users still
|
|
174
174
|
// see which host rejected the key.
|
|
175
175
|
if (err instanceof ApiError) {
|
|
176
|
-
err.message = `API key rejected by ${apiUrl}: ${message}
|
|
176
|
+
err.message = `API key rejected by ${apiUrl}: ${message}`;
|
|
177
177
|
throw err;
|
|
178
178
|
}
|
|
179
179
|
// Anything else (truly unexpected throws like a TypeError from a
|
|
180
180
|
// misconfigured fetchImpl). Exit 3 (auth family).
|
|
181
|
-
throw new CLIError(`API key rejected by ${apiUrl}: ${message}
|
|
181
|
+
throw new CLIError(`API key rejected by ${apiUrl}: ${message}`, 3);
|
|
182
182
|
}
|
|
183
183
|
let persisted = true;
|
|
184
184
|
try {
|
|
@@ -12,8 +12,9 @@ import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
|
12
12
|
import { promptSecret } from '../lib/prompt.js';
|
|
13
13
|
import { conversationApi } from '../lib/conversation/api.js';
|
|
14
14
|
import { readChange, readRepository, runGit } from '../lib/conversation/change.js';
|
|
15
|
-
import { rememberCard, rememberConversation, resolveConversationId, resolveProjectId, shownCard, } from '../lib/conversation/context.js';
|
|
15
|
+
import { rememberCard, rememberConversation, resolveConversationId, resolveProject, resolveProjectId, shownCard, } from '../lib/conversation/context.js';
|
|
16
16
|
import { environmentNotes } from '../lib/conversation/environment.js';
|
|
17
|
+
import { quoteEnvironmentName } from '../lib/environment-tunnel.js';
|
|
17
18
|
import { followConversation } from '../lib/conversation/follow.js';
|
|
18
19
|
import { titleFrom } from '../lib/conversation/title.js';
|
|
19
20
|
import { nextSteps, prSummary, renderApplied, renderConversation, renderConversationList, renderEvent, waitingNotes, } from '../lib/conversation/render.js';
|
|
@@ -227,12 +228,41 @@ const contentTypeOf = (path) => CONTENT_TYPES[extname(path).toLowerCase()] ?? 'a
|
|
|
227
228
|
function caller(env, interactive) {
|
|
228
229
|
return detectCallerFromEnv(env).length > 0 || !interactive ? 'agent' : 'person';
|
|
229
230
|
}
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Say which project a command took from this folder rather than from
|
|
233
|
+
* `--project`: the one last worked on here is easy to mistake for the one just
|
|
234
|
+
* meant. By name when the server gives it, unless `byName` is false for a
|
|
235
|
+
* command that must not wait on the lookup. Text mode only: a JSON caller reads
|
|
236
|
+
* the project id from the result.
|
|
237
|
+
*/
|
|
238
|
+
async function announceRemembered(ctx, projectId, byName = true) {
|
|
239
|
+
if (ctx.opts.output === 'json')
|
|
240
|
+
return;
|
|
241
|
+
let name;
|
|
242
|
+
if (byName && !ctx.opts.dryRun) {
|
|
243
|
+
try {
|
|
244
|
+
name = (await ctx.api.project(projectId)).name;
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
if (err instanceof InterruptError)
|
|
248
|
+
throw err;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const id = terminalSafeLine(projectId);
|
|
252
|
+
ctx.stderr(`Project: ${name ? `${terminalSafeLine(name)} (${id})` : id}, the one last used in this folder; ` +
|
|
253
|
+
'pass --project for another.');
|
|
254
|
+
}
|
|
255
|
+
async function current(ctx, flags, { announce } = {}) {
|
|
256
|
+
const { projectId, remembered } = resolveProject(flags.project, {
|
|
257
|
+
env: ctx.deps.env,
|
|
258
|
+
root: ctx.root,
|
|
259
|
+
});
|
|
232
260
|
const id = resolveConversationId(flags.conversation, projectId, {
|
|
233
261
|
env: ctx.deps.env,
|
|
234
262
|
root: ctx.root,
|
|
235
263
|
});
|
|
264
|
+
if (remembered && announce)
|
|
265
|
+
await announceRemembered(ctx, projectId, announce === 'name');
|
|
236
266
|
return { projectId, id };
|
|
237
267
|
}
|
|
238
268
|
const CARD_HELP = 'the card to decide, by the id the conversation showed (default: the one last shown in this folder); one decided meanwhile is refused';
|
|
@@ -337,10 +367,12 @@ export function createPlanCommand(deps = {}) {
|
|
|
337
367
|
.action(async (words, flags, command) => {
|
|
338
368
|
const ctx = context(command, deps);
|
|
339
369
|
const deadlineMs = timeoutMs(ctx, flags);
|
|
340
|
-
const projectId =
|
|
370
|
+
const { projectId, remembered } = resolveProject(flags.project, {
|
|
341
371
|
env: ctx.deps.env,
|
|
342
372
|
root: ctx.root,
|
|
343
373
|
});
|
|
374
|
+
if (remembered)
|
|
375
|
+
await announceRemembered(ctx, projectId);
|
|
344
376
|
const { attachments, brief, notes: attached, } = readAttachments(ctx, flags.file ?? [], flags.diff);
|
|
345
377
|
const notes = await planNotes(ctx, projectId);
|
|
346
378
|
const text = words.join(' ').trim() ||
|
|
@@ -386,7 +418,7 @@ export function createReplyCommand(deps = {}) {
|
|
|
386
418
|
.action(async (words, flags, command) => {
|
|
387
419
|
const ctx = context(command, deps);
|
|
388
420
|
const deadlineMs = timeoutMs(ctx, flags);
|
|
389
|
-
const { projectId, id } = await current(ctx, flags);
|
|
421
|
+
const { projectId, id } = await current(ctx, flags, { announce: 'name' });
|
|
390
422
|
const { attachments, notes } = readAttachments(ctx, flags.file ?? [], flags.diff);
|
|
391
423
|
const now = await ctx.api.get(projectId, id);
|
|
392
424
|
if (now.state === 'ended') {
|
|
@@ -467,7 +499,7 @@ export function createApplyCommand(deps = {}) {
|
|
|
467
499
|
const ctx = context(command, deps);
|
|
468
500
|
const deadlineMs = timeoutMs(ctx, flags);
|
|
469
501
|
const startedAt = (deps.now ?? Date.now)();
|
|
470
|
-
const { projectId, id } = await current(ctx, flags);
|
|
502
|
+
const { projectId, id } = await current(ctx, flags, { announce: 'name' });
|
|
471
503
|
const now = await ctx.api.get(projectId, id);
|
|
472
504
|
// A card shown here that no longer waits goes to the server, which says how it was decided.
|
|
473
505
|
const card = cardToDecide(ctx, now, flags.card);
|
|
@@ -476,6 +508,8 @@ export function createApplyCommand(deps = {}) {
|
|
|
476
508
|
}
|
|
477
509
|
const answers = answersOn(now, card, flags.answer);
|
|
478
510
|
const environment = environmentOn(now, card, flags.env);
|
|
511
|
+
// Read before applying: the card is gone once it is decided.
|
|
512
|
+
const explored = now.proposal?.id === card ? now.proposal.plan?.environment : undefined;
|
|
479
513
|
const secret = await secretFor(ctx, now, card, flags.secretStdin === true);
|
|
480
514
|
const applied = await ctx.api.apply(projectId, id, {
|
|
481
515
|
card,
|
|
@@ -514,10 +548,15 @@ export function createApplyCommand(deps = {}) {
|
|
|
514
548
|
const saved = applied.tests ?? [];
|
|
515
549
|
const run = saved.length
|
|
516
550
|
? [
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
551
|
+
explored
|
|
552
|
+
? {
|
|
553
|
+
command: `testsprite run ${saved.join(' ')}${explored.isDefault ? '' : ` --env ${quoteEnvironmentName(explored.name)}`} --wait`,
|
|
554
|
+
why: `run what it saved on ${terminalSafeLine(explored.name)}, where it explored them; a local environment opens its tunnel`,
|
|
555
|
+
}
|
|
556
|
+
: {
|
|
557
|
+
command: `testsprite run ${saved.join(' ')} --wait`,
|
|
558
|
+
why: 'run what it saved; a local environment opens its tunnel (--env <name> when it is not the default)',
|
|
559
|
+
},
|
|
521
560
|
]
|
|
522
561
|
: [];
|
|
523
562
|
await finishTurn(ctx, projectId, id, now.lastSeq, { ...flags, deadlineMs }, { applied: printed, ...(forPr ? { prSummary: forPr } : {}) }, run);
|
|
@@ -646,7 +685,7 @@ export function createRejectCommand(deps = {}) {
|
|
|
646
685
|
.action(async (words, flags, command) => {
|
|
647
686
|
const ctx = context(command, deps);
|
|
648
687
|
const deadlineMs = timeoutMs(ctx, flags);
|
|
649
|
-
const { projectId, id } = await current(ctx, flags);
|
|
688
|
+
const { projectId, id } = await current(ctx, flags, { announce: 'name' });
|
|
650
689
|
const now = await ctx.api.get(projectId, id);
|
|
651
690
|
const card = cardToDecide(ctx, now, flags.card);
|
|
652
691
|
if (!card) {
|
|
@@ -663,7 +702,7 @@ export function createStopCommand(deps = {}) {
|
|
|
663
702
|
addTarget(cmd);
|
|
664
703
|
return cmd.addHelpText('after', GLOBAL_OPTS_HINT).action(async (flags, command) => {
|
|
665
704
|
const ctx = context(command, deps);
|
|
666
|
-
const { projectId, id } = await current(ctx, flags);
|
|
705
|
+
const { projectId, id } = await current(ctx, flags, { announce: 'id' });
|
|
667
706
|
const { stopped } = await ctx.api.stop(projectId, id);
|
|
668
707
|
ctx.out.print({ stopped: id, ...(stopped === false ? { nothingToStop: true } : {}) }, () => stopped === false
|
|
669
708
|
? 'Nothing to stop: the agent was not working.'
|
|
@@ -681,7 +720,7 @@ export function createDiscardCommand(deps = {}) {
|
|
|
681
720
|
.addHelpText('after', GLOBAL_OPTS_HINT)
|
|
682
721
|
.action(async (flags, command) => {
|
|
683
722
|
const ctx = context(command, deps);
|
|
684
|
-
const { projectId, id } = await current(ctx, flags);
|
|
723
|
+
const { projectId, id } = await current(ctx, flags, { announce: 'name' });
|
|
685
724
|
const { released } = await ctx.api.discard(projectId, id);
|
|
686
725
|
ctx.out.print({ discarded: id, released }, () => released.length
|
|
687
726
|
? `Discarded. Put back ${released.length} unsaved ${released.length === 1 ? 'file' : 'files'}: ${terminalSafeLine(released.join(', '))}`
|
|
@@ -712,7 +712,7 @@ export async function runEnvCreate(opts, deps = {}) {
|
|
|
712
712
|
const localTarget = parseStoredLocalTarget(opts);
|
|
713
713
|
if (localTarget === undefined && (opts.url === undefined || opts.url.trim().length === 0)) {
|
|
714
714
|
throw localValidationError('--url is required: it names the address runs against this environment open. ' +
|
|
715
|
-
'For
|
|
715
|
+
'For a web app on this machine, pass --url http://localhost:<port>, then run it ' +
|
|
716
716
|
'with `run <id> --env <name>`; the CLI opens a tunnel automatically.');
|
|
717
717
|
}
|
|
718
718
|
if (opts.url !== undefined && !localTarget) {
|
|
@@ -727,7 +727,7 @@ export async function runEnvCreate(opts, deps = {}) {
|
|
|
727
727
|
const signIn = opts.signIn === undefined ? undefined : parseSignInMode(opts.signIn, '--sign-in');
|
|
728
728
|
validateSignInFlags(signIn, opts, true);
|
|
729
729
|
if (localTarget && (signIn === 'otp' || signIn === 'manual')) {
|
|
730
|
-
throw signInValidationError('--sign-in otp and --sign-in manual are not available for
|
|
730
|
+
throw signInValidationError('--sign-in otp and --sign-in manual are not available for local environments (runs through the tunnel sign in inline); use --sign-in public or account.', 'local-environment-sign-in-unsupported');
|
|
731
731
|
}
|
|
732
732
|
const otpChannels = opts.otpChannel?.flatMap(value => value.split(',').map(channel => channel.trim()));
|
|
733
733
|
if (otpChannels &&
|
|
@@ -767,7 +767,9 @@ export async function runEnvCreate(opts, deps = {}) {
|
|
|
767
767
|
out.print(envForPrint(sample), data => renderEnvText(data.environment));
|
|
768
768
|
return sample;
|
|
769
769
|
}
|
|
770
|
+
const client = makeClient(opts, deps);
|
|
770
771
|
if (localTarget) {
|
|
772
|
+
await assertLocalEnvironmentAllowed(client, opts);
|
|
771
773
|
await assertStoredLocalTargetListening(localTarget, opts, deps.localPortProbeDeps);
|
|
772
774
|
}
|
|
773
775
|
// Secrets are read only on the real path — never for a dry run.
|
|
@@ -793,7 +795,6 @@ export async function runEnvCreate(opts, deps = {}) {
|
|
|
793
795
|
body.sessionReuseTtlSeconds = parseSessionTtl(opts.sessionTtl);
|
|
794
796
|
Object.assign(body, resolveApiAuthBody(opts));
|
|
795
797
|
const idempotencyKey = mintIdempotencyKey('create', opts, stderr);
|
|
796
|
-
const client = makeClient(opts, deps);
|
|
797
798
|
if (variables !== undefined)
|
|
798
799
|
await assertEnvironmentWriteSupport(client, opts.projectId, name, '--var');
|
|
799
800
|
const res = await client.post(envPath(opts.projectId), {
|
|
@@ -814,8 +815,44 @@ export async function runEnvCreate(opts, deps = {}) {
|
|
|
814
815
|
stderr(`SSO selected: runs will NOT be signed in until someone logs in once ${inPortal(res.environment, 'Log in')}.`);
|
|
815
816
|
if (opts.output === 'text' && signIn === 'otp')
|
|
816
817
|
stderr(`OTP selected: see the provisioned inbox/phone ${inPortal(res.environment)}.`);
|
|
818
|
+
// Said once, when the address is stored: the agent can only open an app on
|
|
819
|
+
// this machine through a tunnel the user starts, and `plan` has no flag for it.
|
|
820
|
+
if (opts.output === 'text' && localTarget)
|
|
821
|
+
stderr(LOCAL_ENVIRONMENT_HINT);
|
|
817
822
|
return res;
|
|
818
823
|
}
|
|
824
|
+
const LOCAL_ENVIRONMENT_HINT = 'This app is on your machine: before `testsprite plan`, run `testsprite tunnel start` in another terminal so the agent can open it (`testsprite run` opens its own tunnel).';
|
|
825
|
+
/**
|
|
826
|
+
* A local environment is a web app the tunnel reaches; a backend project's
|
|
827
|
+
* tests never use one. Asked before the port check, so the answer does not
|
|
828
|
+
* depend on whether anything listens there. A key that cannot read the
|
|
829
|
+
* project keeps the old path: the server refuses it too.
|
|
830
|
+
*/
|
|
831
|
+
async function assertLocalEnvironmentAllowed(client, opts) {
|
|
832
|
+
let type;
|
|
833
|
+
try {
|
|
834
|
+
({ type } = await client.get(`/projects/${encodeURIComponent(opts.projectId)}`));
|
|
835
|
+
}
|
|
836
|
+
catch (err) {
|
|
837
|
+
if (err instanceof ApiError && err.httpStatus === 403)
|
|
838
|
+
return;
|
|
839
|
+
throw err;
|
|
840
|
+
}
|
|
841
|
+
if (type !== 'backend')
|
|
842
|
+
return;
|
|
843
|
+
throw ApiError.fromEnvelope({
|
|
844
|
+
error: {
|
|
845
|
+
code: 'VALIDATION_ERROR',
|
|
846
|
+
message: 'Invalid request.',
|
|
847
|
+
nextAction: "A backend project's environment must point at a publicly deployed API; local environments are for frontend projects only.",
|
|
848
|
+
requestId: 'local',
|
|
849
|
+
details: {
|
|
850
|
+
field: opts.local !== undefined ? 'local' : 'url',
|
|
851
|
+
reason: 'backend-local-environment',
|
|
852
|
+
},
|
|
853
|
+
},
|
|
854
|
+
});
|
|
855
|
+
}
|
|
819
856
|
export async function runEnvUpdate(opts, deps = {}) {
|
|
820
857
|
const out = makeOutput(opts.output, deps);
|
|
821
858
|
const stderr = stderrOf(deps);
|
|
@@ -881,7 +918,9 @@ export async function runEnvUpdate(opts, deps = {}) {
|
|
|
881
918
|
out.print(envForPrint(sample), data => renderEnvText(data.environment));
|
|
882
919
|
return sample;
|
|
883
920
|
}
|
|
921
|
+
const client = makeClient(opts, deps);
|
|
884
922
|
if (localTarget) {
|
|
923
|
+
await assertLocalEnvironmentAllowed(client, opts);
|
|
885
924
|
await assertStoredLocalTargetListening(localTarget, opts, deps.localPortProbeDeps);
|
|
886
925
|
}
|
|
887
926
|
const password = resolvePassword(opts);
|
|
@@ -902,7 +941,6 @@ export async function runEnvUpdate(opts, deps = {}) {
|
|
|
902
941
|
body.variables = variables;
|
|
903
942
|
Object.assign(body, resolveApiAuthBody(opts));
|
|
904
943
|
const idempotencyKey = mintIdempotencyKey('update', opts, stderr);
|
|
905
|
-
const client = makeClient(opts, deps);
|
|
906
944
|
if (variables !== undefined || opts.clearCredentials) {
|
|
907
945
|
await assertEnvironmentWriteSupport(client, opts.projectId, name, [opts.clearCredentials ? '--clear-credentials' : '', variables !== undefined ? '--var' : '']
|
|
908
946
|
.filter(Boolean)
|
|
@@ -937,6 +975,8 @@ export async function runEnvUpdate(opts, deps = {}) {
|
|
|
937
975
|
warnIfSignInFailed(res.environment, body, opts.projectId, stderr);
|
|
938
976
|
if (opts.output === 'text' && url !== undefined && res.environment.authMode === 'manual')
|
|
939
977
|
stderr(`This environment signs in with an SSO session captured on its previous address; if the site changed, log in again ${inPortal(res.environment, 'Log in')}.`);
|
|
978
|
+
if (opts.output === 'text' && localTarget)
|
|
979
|
+
stderr(LOCAL_ENVIRONMENT_HINT);
|
|
940
980
|
return res;
|
|
941
981
|
}
|
|
942
982
|
export async function runEnvDelete(opts, deps = {}) {
|
|
@@ -1024,7 +1064,7 @@ const UPDATE_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
|
1024
1064
|
' 3 auth error\n' +
|
|
1025
1065
|
' 4 project (or environment) not found\n' +
|
|
1026
1066
|
' 5 validation error\n' +
|
|
1027
|
-
' 6 conflict (name already exists) / precondition (credentials or
|
|
1067
|
+
' 6 conflict (name already exists) / precondition (credentials or a local address on an SSO or OTP environment; change its sign-in in the Portal)';
|
|
1028
1068
|
const CREATE_EXIT_CODE_NOTE = '\nExit codes:\n' +
|
|
1029
1069
|
' 0 success\n' +
|
|
1030
1070
|
' 3 auth error\n' +
|
|
@@ -1040,8 +1080,8 @@ export function createProjectEnvCommand(deps = {}) {
|
|
|
1040
1080
|
const env = new Command('env')
|
|
1041
1081
|
.summary("Manage a project's environments")
|
|
1042
1082
|
.description("Manage a project's environments — named URL + test-account bundles that `run --env <name>` selects")
|
|
1043
|
-
.addHelpText('after', '\nFor
|
|
1044
|
-
'`--url http://localhost:<port
|
|
1083
|
+
.addHelpText('after', '\nFor a web app that only runs on this machine (frontend projects), create or update the environment\n' +
|
|
1084
|
+
'with `--url http://localhost:<port>`; `run <id> --env <name>` opens a tunnel automatically.');
|
|
1045
1085
|
env
|
|
1046
1086
|
.command('list <project-id>')
|
|
1047
1087
|
.summary("List a project's environments")
|
|
@@ -1061,7 +1101,7 @@ export function createProjectEnvCommand(deps = {}) {
|
|
|
1061
1101
|
env
|
|
1062
1102
|
.command('create <project-id>')
|
|
1063
1103
|
.summary('Create an environment')
|
|
1064
|
-
.description('Create an environment (--name and
|
|
1104
|
+
.description('Create an environment (--name and --url are required; --local <port> is shorthand for --url http://localhost:<port>).' +
|
|
1065
1105
|
CREATE_EXIT_CODE_NOTE)
|
|
1066
1106
|
.option('--name <name>', 'environment name, unique within the project (required)')
|
|
1067
1107
|
.option('--url <url>', 'address runs open (public http/https, or a loopback http origin with an explicit port)')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
3
|
+
import { type Git } from '../lib/conversation/change.js';
|
|
3
4
|
import type { FetchImpl } from '../lib/http.js';
|
|
4
5
|
import { type ShutdownHandle } from '../lib/interrupt.js';
|
|
5
6
|
import { type LocalPortProbeDeps } from '../lib/local-target.js';
|
|
@@ -51,6 +52,9 @@ export interface ProjectDeps {
|
|
|
51
52
|
localPortProbeDeps?: LocalPortProbeDeps;
|
|
52
53
|
/** Graceful-detach coordinator; tests inject their own. */
|
|
53
54
|
shutdown?: ShutdownHandle;
|
|
55
|
+
/** Where `project create` remembers the project it makes: this folder's repository, else the folder. */
|
|
56
|
+
cwd?: string;
|
|
57
|
+
git?: Git;
|
|
54
58
|
}
|
|
55
59
|
type CommonOptions = FactoryCommonOptions;
|
|
56
60
|
interface ListOptions extends CommonOptions {
|
package/dist/commands/project.js
CHANGED
|
@@ -2,6 +2,8 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
|
|
4
4
|
import { resolveProfileName } from '../lib/config.js';
|
|
5
|
+
import { readRepository, runGit } from '../lib/conversation/change.js';
|
|
6
|
+
import { rememberProject } from '../lib/conversation/context.js';
|
|
5
7
|
import { ApiError } from '../lib/errors.js';
|
|
6
8
|
import { firstSuiteNextSteps } from '../lib/first-suite-hint.js';
|
|
7
9
|
import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
|
|
@@ -358,8 +360,9 @@ export function createProjectCommand(deps = {}) {
|
|
|
358
360
|
if (type !== 'frontend' && type !== 'backend') {
|
|
359
361
|
throw localValidationError('--type must be frontend or backend');
|
|
360
362
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
const common = resolveCommonOptions(command, deps.env);
|
|
364
|
+
const created = await runCreate({
|
|
365
|
+
...common,
|
|
363
366
|
type,
|
|
364
367
|
name: cmdOpts.name,
|
|
365
368
|
instruction: cmdOpts.instruction,
|
|
@@ -368,6 +371,11 @@ export function createProjectCommand(deps = {}) {
|
|
|
368
371
|
: undefined,
|
|
369
372
|
idempotencyKey: cmdOpts.idempotencyKey,
|
|
370
373
|
}, deps);
|
|
374
|
+
// The project just made is the one the next agent command here works on
|
|
375
|
+
// (`plan` without --project), as a plan started here makes its project
|
|
376
|
+
// this folder's. --dry-run made none.
|
|
377
|
+
if (!common.dryRun && created.projectId)
|
|
378
|
+
rememberCreated(created.projectId, deps);
|
|
371
379
|
});
|
|
372
380
|
project
|
|
373
381
|
.command('update <project-id>')
|
|
@@ -435,6 +443,15 @@ function parseFlag(raw, flagName) {
|
|
|
435
443
|
}
|
|
436
444
|
return n;
|
|
437
445
|
}
|
|
446
|
+
function rememberCreated(projectId, deps) {
|
|
447
|
+
const cwd = deps.cwd ?? process.cwd();
|
|
448
|
+
try {
|
|
449
|
+
rememberProject(readRepository(cwd, deps.git ?? runGit)?.root ?? cwd, projectId);
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
// A folder the CLI can't write to keeps no state; the next command then needs --project.
|
|
453
|
+
}
|
|
454
|
+
}
|
|
438
455
|
function resolveCommonOptions(command, env) {
|
|
439
456
|
const globals = command.optsWithGlobals();
|
|
440
457
|
// P2-8: validate --output before allowing silent fallback to 'text'.
|
package/dist/commands/result.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { makeHttpClient, resolveCommonOptions } from '../lib/client-factory.js';
|
|
2
|
+
import { makeHttpClient, resolveCommonOptions, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
|
|
3
3
|
import { assertOutDirParentExists, resolveOutDir } from '../lib/download.js';
|
|
4
4
|
import { ApiError, localValidationError } from '../lib/errors.js';
|
|
5
5
|
import { historyRetentionNote } from '../lib/history-retention.js';
|
|
@@ -120,6 +120,7 @@ async function runResultGet(opts, resultId, flags, deps) {
|
|
|
120
120
|
warn: stderrOf(deps),
|
|
121
121
|
failedOnly: flags.failedOnly,
|
|
122
122
|
fetchImpl: deps.fetchImpl,
|
|
123
|
+
stallTimeoutMs: resolveRequestTimeoutMs(opts, deps.env ?? process.env),
|
|
123
124
|
});
|
|
124
125
|
output.print(evidence, data => renderEvidence(data));
|
|
125
126
|
// With no step at all there is nothing to say "every step" of.
|
package/dist/commands/test.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { type Page } from '../lib/pagination.js';
|
|
|
9
9
|
import { type WaitTimeoutTelemetry } from '../lib/telemetry.js';
|
|
10
10
|
import { type RunCounts, type RunReceipt, type RunResult } from '../lib/run-output.js';
|
|
11
11
|
import type { ProjectRunResponse, RunStatus, CancelRunResponse, CiGithubTrigger } from '../lib/runs.types.js';
|
|
12
|
-
import { type LoopbackHost } from '../lib/local-target.js';
|
|
13
12
|
import { type TunnelClientHandle } from '../lib/tunnel-session.js';
|
|
14
13
|
import { type TunnelClientOptions } from '../vendor/tunnel-client/index.js';
|
|
15
14
|
/**
|
|
@@ -81,7 +80,7 @@ export interface TestDeps {
|
|
|
81
80
|
*/
|
|
82
81
|
shutdown?: ShutdownHandle;
|
|
83
82
|
/**
|
|
84
|
-
* Tunnel-client factory for
|
|
83
|
+
* Tunnel-client factory for a run on a local environment. Defaults
|
|
85
84
|
* to the vendored `TunnelClient`; tests inject a fake so the command's
|
|
86
85
|
* contract can be exercised without a real control plane — same pattern as
|
|
87
86
|
* `sleep` / `fetchImpl` / `shutdown`.
|
|
@@ -89,7 +88,7 @@ export interface TestDeps {
|
|
|
89
88
|
createTunnelClient?: (options: TunnelClientOptions) => TunnelClientHandle;
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
92
|
-
* How a
|
|
91
|
+
* How a tunnel run's wait ended while the run was still non-terminal.
|
|
93
92
|
* `tunnel-lost` is the one that is not a detach at all — it is the tunnel
|
|
94
93
|
* dying under a run that is otherwise fine.
|
|
95
94
|
*/
|
|
@@ -102,8 +101,6 @@ export interface TunnelDetach {
|
|
|
102
101
|
/** The launch the result belongs to (wire name); absent on an older backend. */
|
|
103
102
|
runId?: string;
|
|
104
103
|
testId: string;
|
|
105
|
-
localPort: number;
|
|
106
|
-
localHost: LoopbackHost;
|
|
107
104
|
automatic?: boolean;
|
|
108
105
|
environment?: string;
|
|
109
106
|
reason: TunnelDetachReason;
|
|
@@ -214,10 +211,9 @@ interface RunTestRunOptions extends CommonOptions {
|
|
|
214
211
|
knownTest?: RunTargetTest;
|
|
215
212
|
noWait?: boolean;
|
|
216
213
|
testId: string;
|
|
217
|
-
targetUrl?: string;
|
|
218
214
|
/** BE only: run just the named test without expanding the producer/teardown closure. */
|
|
219
215
|
skipDependencies?: boolean;
|
|
220
|
-
/** Skip
|
|
216
|
+
/** Skip a local environment's port check before its tunnel opens (zero network calls). */
|
|
221
217
|
skipPreflight?: boolean;
|
|
222
218
|
wait: boolean;
|
|
223
219
|
timeoutSeconds: number;
|
|
@@ -237,18 +233,6 @@ interface RunTestRunOptions extends CommonOptions {
|
|
|
237
233
|
ghOutput?: boolean;
|
|
238
234
|
/** --summary-file: also write the reduced machine summary JSON to this path. */
|
|
239
235
|
summaryFile?: string;
|
|
240
|
-
/**
|
|
241
|
-
* `--local <port>` — run against an app on THIS machine, reached through a
|
|
242
|
-
* TestSprite tunnel. Implies `--wait` (the tunnel's lifetime is this
|
|
243
|
-
* process's lifetime) and is mutually exclusive with `--target-url`.
|
|
244
|
-
*/
|
|
245
|
-
localPort?: number;
|
|
246
|
-
/**
|
|
247
|
-
* `--local-host` — which loopback spelling to name in the run's target URL.
|
|
248
|
-
* Already normalised and validated by the command wiring; the accepted set
|
|
249
|
-
* is `lib/local-target.ts::LOOPBACK_HOSTS`, which mirrors the server's.
|
|
250
|
-
*/
|
|
251
|
-
localHost?: LoopbackHost;
|
|
252
236
|
/**
|
|
253
237
|
* `--tunnel-client <id>` — attach to a tunnel someone else already started
|
|
254
238
|
* (`testsprite tunnel start`) instead of minting one. The client id is a
|
|
@@ -265,11 +249,10 @@ interface RunTestRunOptions extends CommonOptions {
|
|
|
265
249
|
*/
|
|
266
250
|
cancelOnInterrupt?: boolean;
|
|
267
251
|
/**
|
|
268
|
-
* `--env <name>` — the project environment
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* per workspace: checked client-side before anything is minted or billed.
|
|
252
|
+
* `--env <name>` — the project environment this run uses: its address,
|
|
253
|
+
* credentials, auto-auth and OTP settings. Absent → the project's default
|
|
254
|
+
* environment. Feature-gated per workspace: checked client-side before
|
|
255
|
+
* anything is minted or billed.
|
|
273
256
|
*/
|
|
274
257
|
environment?: string;
|
|
275
258
|
}
|
|
@@ -329,9 +312,9 @@ export declare function runTestWait(opts: RunTestWaitOptions, deps?: TestDeps):
|
|
|
329
312
|
message?: string;
|
|
330
313
|
}[] | undefined;
|
|
331
314
|
environment?: import("../lib/runs.types.js").RunEnvironmentRef | null | undefined;
|
|
332
|
-
enqueuedAt?: string | undefined;
|
|
333
315
|
total?: number | undefined;
|
|
334
316
|
autoHeal?: boolean | undefined;
|
|
317
|
+
enqueuedAt?: string | undefined;
|
|
335
318
|
maxConcurrency?: number | undefined;
|
|
336
319
|
tunnelClientId?: string | undefined;
|
|
337
320
|
held?: {
|
|
@@ -381,9 +364,9 @@ export declare function runTestWait(opts: RunTestWaitOptions, deps?: TestDeps):
|
|
|
381
364
|
message?: string;
|
|
382
365
|
}[] | undefined;
|
|
383
366
|
environment?: import("../lib/runs.types.js").RunEnvironmentRef | null | undefined;
|
|
384
|
-
enqueuedAt?: string | undefined;
|
|
385
367
|
total?: number | undefined;
|
|
386
368
|
autoHeal?: boolean | undefined;
|
|
369
|
+
enqueuedAt?: string | undefined;
|
|
387
370
|
maxConcurrency?: number | undefined;
|
|
388
371
|
tunnelClientId?: string | undefined;
|
|
389
372
|
held?: {
|
|
@@ -534,15 +517,12 @@ export interface ProjectLaunchOutput {
|
|
|
534
517
|
}
|
|
535
518
|
/** Launch once per project; the server owns membership expansion and pacing. */
|
|
536
519
|
export declare function runTestRunAll(opts: RunTestRunAllOptions & {
|
|
537
|
-
localPort?: number;
|
|
538
|
-
localHost?: LoopbackHost;
|
|
539
520
|
tunnelClientId?: string;
|
|
540
521
|
resolvedTarget?: ResolvedRunTarget;
|
|
541
522
|
single?: boolean;
|
|
542
523
|
}, deps?: TestDeps): Promise<ProjectLaunchOutput>;
|
|
543
524
|
interface RunTestRunLocalBatchOptions extends CommonOptions {
|
|
544
525
|
wait?: boolean;
|
|
545
|
-
targetUrl?: string;
|
|
546
526
|
noWait?: boolean;
|
|
547
527
|
concurrencyIsDefault?: boolean;
|
|
548
528
|
resolvedTarget?: ResolvedRunTarget;
|
|
@@ -550,8 +530,6 @@ interface RunTestRunLocalBatchOptions extends CommonOptions {
|
|
|
550
530
|
all: boolean;
|
|
551
531
|
projectId?: string;
|
|
552
532
|
nameFilter?: string;
|
|
553
|
-
localPort?: number;
|
|
554
|
-
localHost?: LoopbackHost;
|
|
555
533
|
skipPreflight: boolean;
|
|
556
534
|
tunnelClientId?: string;
|
|
557
535
|
cancelOnInterrupt: boolean;
|