@testsprite/testsprite-cli 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +11 -4
  2. package/dist/commands/agent.js +16 -13
  3. package/dist/commands/auth.d.ts +19 -0
  4. package/dist/commands/auth.js +60 -24
  5. package/dist/commands/ci.d.ts +86 -1
  6. package/dist/commands/ci.js +436 -5
  7. package/dist/commands/doctor.d.ts +2 -0
  8. package/dist/commands/doctor.js +22 -9
  9. package/dist/commands/init.js +14 -11
  10. package/dist/commands/project-env.js +9 -9
  11. package/dist/commands/project.d.ts +5 -5
  12. package/dist/commands/project.js +42 -42
  13. package/dist/commands/schedule.d.ts +2 -0
  14. package/dist/commands/schedule.js +18 -10
  15. package/dist/commands/test.d.ts +73 -27
  16. package/dist/commands/test.js +1756 -413
  17. package/dist/commands/testlist.js +49 -19
  18. package/dist/commands/tunnel.d.ts +26 -3
  19. package/dist/commands/tunnel.js +211 -14
  20. package/dist/commands/usage.d.ts +3 -0
  21. package/dist/commands/usage.js +12 -5
  22. package/dist/index.js +34 -20
  23. package/dist/lib/agent-targets.d.ts +3 -3
  24. package/dist/lib/agent-targets.js +2 -2
  25. package/dist/lib/billing-refusal.d.ts +43 -0
  26. package/dist/lib/billing-refusal.js +171 -0
  27. package/dist/lib/bundle.d.ts +5 -0
  28. package/dist/lib/bundle.js +43 -13
  29. package/dist/lib/ci-linkage.d.ts +90 -0
  30. package/dist/lib/ci-linkage.js +181 -0
  31. package/dist/lib/client-factory.d.ts +4 -1
  32. package/dist/lib/client-factory.js +23 -2
  33. package/dist/lib/config.d.ts +17 -0
  34. package/dist/lib/config.js +20 -1
  35. package/dist/lib/conflict-reason.d.ts +27 -3
  36. package/dist/lib/conflict-reason.js +53 -4
  37. package/dist/lib/credentials.js +56 -14
  38. package/dist/lib/dry-run/samples.d.ts +13 -1
  39. package/dist/lib/dry-run/samples.js +51 -7
  40. package/dist/lib/errors.d.ts +18 -11
  41. package/dist/lib/errors.js +111 -13
  42. package/dist/lib/failing-fe-resolver.d.ts +1 -1
  43. package/dist/lib/failing-fe-resolver.js +3 -3
  44. package/dist/lib/gh-output.d.ts +1 -0
  45. package/dist/lib/gh-output.js +13 -4
  46. package/dist/lib/history-retention.d.ts +8 -0
  47. package/dist/lib/history-retention.js +24 -0
  48. package/dist/lib/http.d.ts +37 -19
  49. package/dist/lib/http.js +46 -24
  50. package/dist/lib/interrupt.d.ts +21 -13
  51. package/dist/lib/interrupt.js +32 -21
  52. package/dist/lib/junit-report.d.ts +11 -1
  53. package/dist/lib/junit-report.js +15 -3
  54. package/dist/lib/local-target.d.ts +1 -1
  55. package/dist/lib/local-target.js +1 -1
  56. package/dist/lib/plan-poll.d.ts +11 -11
  57. package/dist/lib/plan-poll.js +12 -12
  58. package/dist/lib/plans.types.d.ts +9 -9
  59. package/dist/lib/plans.types.js +3 -3
  60. package/dist/lib/poll.d.ts +2 -2
  61. package/dist/lib/poll.js +9 -3
  62. package/dist/lib/render-error.d.ts +2 -0
  63. package/dist/lib/render-error.js +13 -0
  64. package/dist/lib/response-schemas.d.ts +54 -12
  65. package/dist/lib/response-schemas.js +88 -7
  66. package/dist/lib/runs.types.d.ts +59 -10
  67. package/dist/lib/secret-file.js +72 -14
  68. package/dist/lib/skill-nudge.d.ts +6 -1
  69. package/dist/lib/skill-nudge.js +32 -5
  70. package/dist/lib/target-url-preflight.d.ts +6 -4
  71. package/dist/lib/target-url-preflight.js +64 -51
  72. package/dist/lib/target-url.js +6 -6
  73. package/dist/lib/telemetry.d.ts +4 -1
  74. package/dist/lib/telemetry.js +13 -13
  75. package/dist/lib/ticker.js +93 -4
  76. package/dist/lib/tunnel-session.d.ts +13 -0
  77. package/dist/lib/tunnel-session.js +4 -1
  78. package/dist/lib/tunnel.types.d.ts +12 -2
  79. package/dist/lib/tunnel.types.js +2 -2
  80. package/dist/lib/wait-exit.d.ts +8 -0
  81. package/dist/lib/wait-exit.js +76 -4
  82. package/dist/lib/workspace-status.d.ts +23 -0
  83. package/dist/lib/workspace-status.js +15 -0
  84. package/dist/version-guard.d.ts +7 -1
  85. package/dist/version-guard.js +19 -1
  86. package/dist/version.d.ts +1 -1
  87. package/dist/version.js +1 -1
  88. package/package.json +4 -4
  89. package/skills/testsprite-onboard.skill.md +4 -4
  90. package/skills/testsprite-verify.codex.md +59 -57
  91. package/skills/testsprite-verify.skill.md +53 -38
@@ -1,6 +1,5 @@
1
1
  /**
2
- * `testsprite project env <verb>` — the per-project environment surface
3
- * (DEV-1305, Phase 1 of DEV-793).
2
+ * `testsprite project env <verb>` — the per-project environment surface.
4
3
  *
5
4
  * An environment is a named bundle of "how to reach and log in to the app": a
6
5
  * URL and a login method. `test run --env <name>`
@@ -30,6 +29,7 @@
30
29
  import { randomUUID } from 'node:crypto';
31
30
  import { Command } from 'commander';
32
31
  import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
32
+ import { resolveProfileName } from '../lib/config.js';
33
33
  import { ApiError } from '../lib/errors.js';
34
34
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
35
35
  import { readSecretFileGuarded } from '../lib/secret-file.js';
@@ -41,10 +41,10 @@ import { assertIdempotencyKey } from '../lib/validate.js';
41
41
  // Shared plumbing (same shape as `project.ts`; kept local so this module does
42
42
  // not import `project.ts` at runtime — that file imports this one).
43
43
  // ---------------------------------------------------------------------------
44
- function resolveCommonOptions(command) {
44
+ function resolveCommonOptions(command, env) {
45
45
  const globals = command.optsWithGlobals();
46
46
  return {
47
- profile: globals.profile ?? 'default',
47
+ profile: resolveProfileName(globals.profile, env),
48
48
  output: resolveOutputMode(globals.output),
49
49
  endpointUrl: globals.endpointUrl,
50
50
  debug: globals.debug ?? false,
@@ -388,7 +388,7 @@ export function createProjectEnvCommand(deps = {}) {
388
388
  .description("List a project's environments (name, default, URL, auth)." + EXIT_CODE_NOTE)
389
389
  .addHelpText('after', GLOBAL_OPTS_HINT)
390
390
  .action(async (projectId, _cmdOpts, command) => {
391
- await runEnvList({ ...resolveCommonOptions(command), projectId }, deps);
391
+ await runEnvList({ ...resolveCommonOptions(command, deps.env), projectId }, deps);
392
392
  });
393
393
  env
394
394
  .command('create <project-id>')
@@ -406,7 +406,7 @@ export function createProjectEnvCommand(deps = {}) {
406
406
  .addHelpText('after', GLOBAL_OPTS_HINT)
407
407
  .action(async (projectId, cmdOpts, command) => {
408
408
  await runEnvCreate({
409
- ...resolveCommonOptions(command),
409
+ ...resolveCommonOptions(command, deps.env),
410
410
  projectId,
411
411
  name: cmdOpts.name,
412
412
  url: cmdOpts.url,
@@ -435,7 +435,7 @@ export function createProjectEnvCommand(deps = {}) {
435
435
  .addHelpText('after', GLOBAL_OPTS_HINT)
436
436
  .action(async (projectId, name, cmdOpts, command) => {
437
437
  await runEnvUpdate({
438
- ...resolveCommonOptions(command),
438
+ ...resolveCommonOptions(command, deps.env),
439
439
  projectId,
440
440
  name,
441
441
  url: cmdOpts.url,
@@ -459,7 +459,7 @@ export function createProjectEnvCommand(deps = {}) {
459
459
  .addHelpText('after', GLOBAL_OPTS_HINT)
460
460
  .action(async (projectId, name, cmdOpts, command) => {
461
461
  await runEnvDelete({
462
- ...resolveCommonOptions(command),
462
+ ...resolveCommonOptions(command, deps.env),
463
463
  projectId,
464
464
  name,
465
465
  confirm: cmdOpts.confirm === true,
@@ -475,7 +475,7 @@ export function createProjectEnvCommand(deps = {}) {
475
475
  .addHelpText('after', GLOBAL_OPTS_HINT)
476
476
  .action(async (projectId, name, cmdOpts, command) => {
477
477
  await runEnvSetDefault({
478
- ...resolveCommonOptions(command),
478
+ ...resolveCommonOptions(command, deps.env),
479
479
  projectId,
480
480
  name,
481
481
  idempotencyKey: cmdOpts.idempotencyKey,
@@ -68,7 +68,7 @@ export interface ProjectDeps {
68
68
  stdout?: (line: string) => void;
69
69
  stderr?: (line: string) => void;
70
70
  localPortProbeDeps?: LocalPortProbeDeps;
71
- /** Graceful-detach coordinator (DEV-331); tests inject their own. */
71
+ /** Graceful-detach coordinator; tests inject their own. */
72
72
  shutdown?: ShutdownHandle;
73
73
  }
74
74
  type CommonOptions = FactoryCommonOptions;
@@ -268,20 +268,20 @@ declare const DOC_ROLES: {
268
268
  };
269
269
  type DocRoleFlag = keyof typeof DOC_ROLES;
270
270
  type DocRoleWire = (typeof DOC_ROLES)[DocRoleFlag];
271
- /** `POST /projects/{id}/docs/upload-url` response (V3-A facade). */
271
+ /** `POST /projects/{id}/docs/upload-url` response (docs facade). */
272
272
  export interface CliDocsUploadUrlResponse {
273
273
  uploadUrl: string;
274
274
  s3Key: string;
275
275
  expiresInSeconds: number;
276
276
  }
277
- /** `POST /projects/{id}/docs` (register) response (V3-A facade). */
277
+ /** `POST /projects/{id}/docs` (register) response (docs facade). */
278
278
  export interface CliDocsRegisterResponse {
279
279
  resourceId: string;
280
280
  displayName: string;
281
281
  docRole: DocRoleWire | null;
282
282
  processStatus: string;
283
283
  }
284
- /** Success result — the JSON-mode stdout shape (piece V3-D scope item 3). */
284
+ /** Success result — the JSON-mode stdout shape. */
285
285
  export interface CliDocsUploadResult {
286
286
  resourceId: string;
287
287
  displayName: string;
@@ -313,7 +313,7 @@ interface DocsUploadOptions extends CommonOptions {
313
313
  * source so plan generation has inputs to feed on (closes the API-project
314
314
  * cold start at `no_processed_inputs`).
315
315
  *
316
- * Three-step flow against the V3-A facade routes:
316
+ * Three-step flow against the docs facade routes:
317
317
  *
318
318
  * 1. `POST /projects/{id}/docs/upload-url` — mints a one-hour presigned
319
319
  * S3 PUT URL plus the S3 key to register afterwards.
@@ -4,6 +4,7 @@ import { basename, extname } from 'node:path';
4
4
  import { Readable } from 'node:stream';
5
5
  import { Command } from 'commander';
6
6
  import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
7
+ import { resolveProfileName } from '../lib/config.js';
7
8
  import { ApiError, InterruptError, RequestTimeoutError } from '../lib/errors.js';
8
9
  import { globalShutdown } from '../lib/interrupt.js';
9
10
  import { assertStoredLocalTargetListening, buildLocalTargetUrl, DEFAULT_LOCAL_HOST, parseStoredLocalTarget, } from '../lib/local-target.js';
@@ -135,8 +136,8 @@ export async function runCreate(opts, deps = {}) {
135
136
  throw localValidationError('--url is required for --type frontend');
136
137
  }
137
138
  if (opts.dryRun) {
138
- // DEV-247: this path returns before makeClient() fires the banner, so emit it
139
- // here — otherwise the canned sample can be mistaken for a live response.
139
+ // This path returns before makeClient() fires the banner, so emit it here
140
+ // — otherwise the canned sample can be mistaken for a live response.
140
141
  emitDryRunBanner(stderr);
141
142
  const idempotencyKey = opts.idempotencyKey ?? `cli-proj-create-${randomUUID()}`;
142
143
  // P2-6: gate idempotency-key output behind --verbose/--debug/json (matches
@@ -307,7 +308,7 @@ export async function runUpdate(opts, deps = {}) {
307
308
  '--instruction, --test-id-attributes, or --clear-test-id-attributes.');
308
309
  }
309
310
  if (opts.dryRun) {
310
- // DEV-247: emit the banner here (this path returns before makeClient() does).
311
+ // Emit the banner here (this path returns before makeClient() does).
311
312
  emitDryRunBanner(stderr);
312
313
  const idempotencyKey = opts.idempotencyKey ?? `cli-proj-update-${randomUUID()}`;
313
314
  if (opts.idempotencyKey === undefined &&
@@ -550,7 +551,7 @@ function renderAutoAuthText(r) {
550
551
  return lines.join('\n');
551
552
  }
552
553
  // ---------------------------------------------------------------------------
553
- // project docs upload — DEV-384 piece V3-D
554
+ // project docs upload
554
555
  // ---------------------------------------------------------------------------
555
556
  /**
556
557
  * CLI-facing role flags → wire enum. Default is `api-doc` (stated in help);
@@ -578,7 +579,7 @@ const DEFAULT_DOC_CONTENT_TYPE = 'application/octet-stream';
578
579
  * source so plan generation has inputs to feed on (closes the API-project
579
580
  * cold start at `no_processed_inputs`).
580
581
  *
581
- * Three-step flow against the V3-A facade routes:
582
+ * Three-step flow against the docs facade routes:
582
583
  *
583
584
  * 1. `POST /projects/{id}/docs/upload-url` — mints a one-hour presigned
584
585
  * S3 PUT URL plus the S3 key to register afterwards.
@@ -683,17 +684,17 @@ export async function runDocsUpload(opts, deps = {}) {
683
684
  // transfer-encoding on presigned PUTs, and Node's fetch uses the explicit
684
685
  // header to keep identity framing with a streamed body.
685
686
  const fetchImpl = deps.fetchImpl ?? globalThis.fetch.bind(globalThis);
686
- // DEV-384 review F3: a remote facade must mint a non-local https URL.
687
+ // A remote facade must mint a non-local https URL.
687
688
  assertSafePresignedUploadUrl(minted.uploadUrl, client.resolvedBaseUrl);
688
689
  // Same flag > TESTSPRITE_REQUEST_TIMEOUT_MS > default resolution (and 1-600s
689
690
  // clamp) as makeHttpClient — this leg bypasses HttpClient, so resolve here.
690
691
  const requestTimeoutMs = resolveRequestTimeoutMs(opts, deps.env ?? process.env);
691
692
  const controller = new AbortController();
692
693
  const timer = setTimeout(() => controller.abort(), requestTimeoutMs);
693
- // DEV-384 review F14b: compose the shutdown signal into the PUT abort
694
- // (manual listeners, house style — no AbortSignal.any) and arm the
695
- // graceful scope for the upload's duration, so Ctrl-C during a long PUT
696
- // takes the honest DEV-331 detach path instead of being unabortable.
694
+ // Compose the shutdown signal into the PUT abort (manual listeners, house
695
+ // style — no AbortSignal.any) and arm the graceful scope for the upload's
696
+ // duration, so Ctrl-C during a long PUT takes the honest detach path
697
+ // instead of being unabortable.
697
698
  const shutdown = deps.shutdown ?? globalShutdown;
698
699
  const shutdownSignal = shutdown.signal;
699
700
  const onShutdownAbort = () => controller.abort(shutdownSignal.reason);
@@ -709,7 +710,7 @@ export async function runDocsUpload(opts, deps = {}) {
709
710
  headers: { 'content-type': contentType, 'content-length': String(stat.size) },
710
711
  body: Readable.toWeb(createReadStream(opts.file)),
711
712
  duplex: 'half',
712
- // #342 review: assertSafePresignedUploadUrl vets the MINTED url, but a
713
+ // assertSafePresignedUploadUrl vets the MINTED url, but a
713
714
  // default `redirect: 'follow'` would let a 3xx from that host resend
714
715
  // the request to an unvetted Location (e.g. a 303 → 169.254.169.254) —
715
716
  // an SSRF-shaped hop the guard never sees. A real S3 presigned PUT never
@@ -753,10 +754,10 @@ export async function runDocsUpload(opts, deps = {}) {
753
754
  catch (cause) {
754
755
  if (cause instanceof ApiError)
755
756
  throw registerStepError(cause);
756
- // DEV-384 review F4: a register timeout needs the same step-3 context —
757
- // it is precisely the case where the caller can't tell whether the
758
- // register landed. Class and exit 7 are preserved; only the text gains
759
- // the upload-succeeded / safe-to-re-run explanation.
757
+ // A register timeout needs the same step-3 context — it is precisely the
758
+ // case where the caller can't tell whether the register landed. Class and
759
+ // exit 7 are preserved; only the text gains the upload-succeeded /
760
+ // safe-to-re-run explanation.
760
761
  if (cause instanceof RequestTimeoutError) {
761
762
  cause.message =
762
763
  `Document register timed out (step 3 of 3) — the S3 upload succeeded, and the ` +
@@ -789,7 +790,7 @@ function describeCause(cause) {
789
790
  return `${cause.message}${nestedMsg}`;
790
791
  }
791
792
  /**
792
- * DEV-384 review F3 — defense-in-depth on the server-minted presigned URL.
793
+ * Defense-in-depth on the server-minted presigned URL.
793
794
  *
794
795
  * A REMOTE facade must mint a non-local `https:` URL; a localhost/private or
795
796
  * plain-http mint from a remote facade is exactly the anomaly to reject
@@ -797,18 +798,17 @@ function describeCause(cause) {
797
798
  * otherwise send the user's file wherever that URL points, before any bytes
798
799
  * leave the machine. A facade that is ITSELF loopback (dev rig, localhost
799
800
  * e2e) is a deliberate operator configuration and is trusted to mint local
800
- * URLs — and ONLY loopback qualifies (#342 review): the gate is a positive,
801
- * fail-closed check, because gating on "anything `assertNotLocal` dislikes"
802
- * would silently disable the guard for an unparsable base URL or a
803
- * user-settable private-range endpoint (`--endpoint-url https://10.1.2.3`).
804
- * Literal checks only (same scope as `assertNotLocal`); no host
805
- * allow-listing by design.
801
+ * URLs — and ONLY loopback qualifies: the gate is a positive, fail-closed
802
+ * check, because gating on "anything `assertNotLocal` dislikes" would
803
+ * silently disable the guard for an unparsable base URL or a user-settable
804
+ * private-range endpoint (`--endpoint-url https://10.1.2.3`). Literal checks
805
+ * only (same scope as `assertNotLocal`); no host allow-listing by design.
806
806
  *
807
- * Known residual (#342 review): a loopback facade that is really a TUNNEL to a
808
- * remote backend (`ssh -L`, a localhost corporate proxy) is trusted here even
809
- * though the real conversation is remote and MITM-able upstream. This is
810
- * inherent to "loopback facade = trusted dev rig" and accepted — the CLI
811
- * cannot tell a dev rig from a tunnel by the base URL alone.
807
+ * Known residual: a loopback facade that is really a TUNNEL to a remote
808
+ * backend (`ssh -L`, a localhost corporate proxy) is trusted here even though
809
+ * the real conversation is remote and MITM-able upstream. This is inherent to
810
+ * "loopback facade = trusted dev rig" and accepted — the CLI cannot tell a
811
+ * dev rig from a tunnel by the base URL alone.
812
812
  */
813
813
  function assertSafePresignedUploadUrl(uploadUrl, facadeBaseUrl) {
814
814
  if (isLoopbackFacade(facadeBaseUrl))
@@ -854,7 +854,7 @@ function isLocalUrl(url) {
854
854
  }
855
855
  }
856
856
  /**
857
- * #342 review: the facade-trust gate for `assertSafePresignedUploadUrl`.
857
+ * The facade-trust gate for `assertSafePresignedUploadUrl`.
858
858
  * Positive and narrow — only an explicitly-loopback facade (`localhost`,
859
859
  * a `127.0.0.0/8` literal, or `[::1]`) is trusted to mint local upload URLs.
860
860
  * Anything else — including an unparsable base URL or a private-range
@@ -951,7 +951,7 @@ export function createProjectCommand(deps = {}) {
951
951
  // raises a typed `ApiError(VALIDATION_ERROR)` and surfaces with
952
952
  // the contract-mandated exit code 5.
953
953
  await runList({
954
- ...resolveCommonOptions(command),
954
+ ...resolveCommonOptions(command, deps.env),
955
955
  pageSize: parseFlag(cmdOpts.pageSize, 'page-size'),
956
956
  startingToken: cmdOpts.startingToken,
957
957
  maxItems: parseFlag(cmdOpts.maxItems, 'max-items'),
@@ -964,7 +964,7 @@ export function createProjectCommand(deps = {}) {
964
964
  .description('Get a project by id')
965
965
  .addHelpText('after', GLOBAL_OPTS_HINT)
966
966
  .action(async (projectId, _cmdOpts, command) => {
967
- await runGet({ ...resolveCommonOptions(command), projectId }, deps);
967
+ await runGet({ ...resolveCommonOptions(command, deps.env), projectId }, deps);
968
968
  });
969
969
  project
970
970
  .command('create')
@@ -995,7 +995,7 @@ export function createProjectCommand(deps = {}) {
995
995
  throw localValidationError('--type must be frontend or backend');
996
996
  }
997
997
  await runCreate({
998
- ...resolveCommonOptions(command),
998
+ ...resolveCommonOptions(command, deps.env),
999
999
  type,
1000
1000
  name: cmdOpts.name,
1001
1001
  targetUrl: cmdOpts.url,
@@ -1032,7 +1032,7 @@ export function createProjectCommand(deps = {}) {
1032
1032
  .addHelpText('after', GLOBAL_OPTS_HINT)
1033
1033
  .action(async (projectId, cmdOpts, command) => {
1034
1034
  await runUpdate({
1035
- ...resolveCommonOptions(command),
1035
+ ...resolveCommonOptions(command, deps.env),
1036
1036
  projectId,
1037
1037
  name: cmdOpts.name,
1038
1038
  targetUrl: cmdOpts.url,
@@ -1064,7 +1064,7 @@ export function createProjectCommand(deps = {}) {
1064
1064
  .addHelpText('after', GLOBAL_OPTS_HINT)
1065
1065
  .action(async (projectId, cmdOpts, command) => {
1066
1066
  await runDelete({
1067
- ...resolveCommonOptions(command),
1067
+ ...resolveCommonOptions(command, deps.env),
1068
1068
  projectId,
1069
1069
  confirm: cmdOpts.confirm === true,
1070
1070
  idempotencyKey: cmdOpts.idempotencyKey,
@@ -1081,7 +1081,7 @@ export function createProjectCommand(deps = {}) {
1081
1081
  .addHelpText('after', GLOBAL_OPTS_HINT)
1082
1082
  .action(async (projectId, cmdOpts, command) => {
1083
1083
  await runCredential({
1084
- ...resolveCommonOptions(command),
1084
+ ...resolveCommonOptions(command, deps.env),
1085
1085
  projectId,
1086
1086
  authType: cmdOpts.type,
1087
1087
  credential: cmdOpts.credential,
@@ -1120,7 +1120,7 @@ export function createProjectCommand(deps = {}) {
1120
1120
  .addHelpText('after', GLOBAL_OPTS_HINT)
1121
1121
  .action(async (projectId, cmdOpts, command) => {
1122
1122
  await runAutoAuth({
1123
- ...resolveCommonOptions(command),
1123
+ ...resolveCommonOptions(command, deps.env),
1124
1124
  projectId,
1125
1125
  disable: cmdOpts.disable,
1126
1126
  method: cmdOpts.method,
@@ -1148,7 +1148,7 @@ export function createProjectCommand(deps = {}) {
1148
1148
  const docs = new Command('docs').description('Manage project documents — the sources plan generation feeds on');
1149
1149
  docs
1150
1150
  .command('upload <file>')
1151
- .description('Upload an API spec or PRD as a project source (DEV-384). Three steps:\n' +
1151
+ .description('Upload an API spec or PRD as a project source. Three steps:\n' +
1152
1152
  'mint a presigned S3 URL, stream the file bytes to it, register the\n' +
1153
1153
  'document — which starts processing + embedding. The local file is\n' +
1154
1154
  'only read; nothing is written back to disk.\n' +
@@ -1166,7 +1166,7 @@ export function createProjectCommand(deps = {}) {
1166
1166
  .addHelpText('after', GLOBAL_OPTS_HINT)
1167
1167
  .action(async (file, cmdOpts, command) => {
1168
1168
  await runDocsUpload({
1169
- ...resolveCommonOptions(command),
1169
+ ...resolveCommonOptions(command, deps.env),
1170
1170
  file,
1171
1171
  projectId: cmdOpts.project,
1172
1172
  role: cmdOpts.role,
@@ -1175,8 +1175,8 @@ export function createProjectCommand(deps = {}) {
1175
1175
  }, deps);
1176
1176
  });
1177
1177
  project.addCommand(docs);
1178
- // DEV-1305: `project env <verb>` — the per-project environment surface
1179
- // (credentials, URL, default). Own module; `deps` threaded so tests inject.
1178
+ // `project env <verb>` — the per-project environment surface (credentials,
1179
+ // URL, default). Own module; `deps` threaded so tests inject.
1180
1180
  project.addCommand(createProjectEnvCommand(deps));
1181
1181
  return project;
1182
1182
  }
@@ -1197,11 +1197,11 @@ function parseFlag(raw, flagName) {
1197
1197
  }
1198
1198
  return n;
1199
1199
  }
1200
- function resolveCommonOptions(command) {
1200
+ function resolveCommonOptions(command, env) {
1201
1201
  const globals = command.optsWithGlobals();
1202
1202
  // P2-8: validate --output before allowing silent fallback to 'text'.
1203
1203
  return {
1204
- profile: globals.profile ?? 'default',
1204
+ profile: resolveProfileName(globals.profile, env),
1205
1205
  output: resolveOutputMode(globals.output),
1206
1206
  endpointUrl: globals.endpointUrl,
1207
1207
  debug: globals.debug ?? false,
@@ -1363,7 +1363,7 @@ function renderDeleteText(r) {
1363
1363
  /**
1364
1364
  * `--project` resolution for `project docs upload` — mirrors test.ts's
1365
1365
  * resolveProjectId/requireProjectId so `TESTSPRITE_PROJECT_ID` works here the
1366
- * same as on every other command (DEV-384 review F5). Flag wins over env.
1366
+ * same as on every other command. Flag wins over env.
1367
1367
  */
1368
1368
  function requireDocsProjectId(projectId, deps) {
1369
1369
  const explicit = projectId?.trim();
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
3
3
  import type { FetchImpl } from '../lib/http.js';
4
+ import { type HistoryRetentionMeta } from '../lib/history-retention.js';
4
5
  /** A schedule as returned by the API. */
5
6
  export interface CliSchedule {
6
7
  scheduleId: string;
@@ -109,6 +110,7 @@ export interface CliScheduleRun {
109
110
  /** `GET /schedules/{id}/runs` response. Not paginated. */
110
111
  interface ScheduleRunListResponse {
111
112
  runs: CliScheduleRun[];
113
+ meta?: HistoryRetentionMeta;
112
114
  }
113
115
  export declare function runList(opts: ListOptions, deps?: ScheduleDeps): Promise<ScheduleListResponse>;
114
116
  export declare function runGet(opts: GetOptions, deps?: ScheduleDeps): Promise<CliSchedule>;
@@ -1,11 +1,13 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { Command } from 'commander';
3
3
  import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
4
+ import { resolveProfileName } from '../lib/config.js';
4
5
  import { ApiError } from '../lib/errors.js';
5
6
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
6
7
  import { formatScheduleFrequencyAdvisory, runsPerMonth } from '../lib/cron.js';
7
8
  import { renderTextTable } from '../lib/text-table.js';
8
9
  import { assertIdempotencyKey } from '../lib/validate.js';
10
+ import { historyRetentionNote } from '../lib/history-retention.js';
9
11
  // ---------------------------------------------------------------------------
10
12
  // schedule list
11
13
  // ---------------------------------------------------------------------------
@@ -191,8 +193,14 @@ export async function runRunList(opts, deps = {}) {
191
193
  const client = makeClient(opts, deps);
192
194
  const response = await client.get(`/schedules/${encodeURIComponent(opts.scheduleId)}/runs`);
193
195
  const runs = response.runs ?? [];
194
- out.print({ runs }, () => renderRunListText(runs, { columns: opts.columns, noHeader: opts.noHeader }));
195
- return { runs };
196
+ const outputResponse = { ...response, runs };
197
+ out.print(outputResponse, () => renderRunListText(runs, { columns: opts.columns, noHeader: opts.noHeader }));
198
+ if (opts.output === 'text') {
199
+ const note = historyRetentionNote(response.meta, client.resolvedBaseUrl);
200
+ if (note)
201
+ (deps.stderr ?? ((line) => process.stderr.write(`${line}\n`)))(note);
202
+ }
203
+ return outputResponse;
196
204
  }
197
205
  // ---------------------------------------------------------------------------
198
206
  // Rendering
@@ -315,7 +323,7 @@ export function createScheduleCommand(deps = {}) {
315
323
  .addHelpText('after', GLOBAL_OPTS_HINT)
316
324
  .action(async (cmdOpts, command) => {
317
325
  await runList({
318
- ...resolveCommonOptions(command),
326
+ ...resolveCommonOptions(command, deps.env),
319
327
  columns: cmdOpts.columns,
320
328
  noHeader: cmdOpts.header === false,
321
329
  }, deps);
@@ -332,7 +340,7 @@ export function createScheduleCommand(deps = {}) {
332
340
  ' 13 not available on your plan')
333
341
  .addHelpText('after', GLOBAL_OPTS_HINT)
334
342
  .action(async (scheduleId, _cmdOpts, command) => {
335
- await runGet({ ...resolveCommonOptions(command), scheduleId }, deps);
343
+ await runGet({ ...resolveCommonOptions(command, deps.env), scheduleId }, deps);
336
344
  });
337
345
  schedule
338
346
  .command('create')
@@ -361,7 +369,7 @@ export function createScheduleCommand(deps = {}) {
361
369
  .addHelpText('after', GLOBAL_OPTS_HINT)
362
370
  .action(async (cmdOpts, command) => {
363
371
  await runCreate({
364
- ...resolveCommonOptions(command),
372
+ ...resolveCommonOptions(command, deps.env),
365
373
  name: cmdOpts.name,
366
374
  targetType: cmdOpts.targetType,
367
375
  targetId: cmdOpts.targetId,
@@ -398,7 +406,7 @@ export function createScheduleCommand(deps = {}) {
398
406
  .addHelpText('after', GLOBAL_OPTS_HINT)
399
407
  .action(async (scheduleId, cmdOpts, command) => {
400
408
  await runUpdate({
401
- ...resolveCommonOptions(command),
409
+ ...resolveCommonOptions(command, deps.env),
402
410
  scheduleId,
403
411
  name: cmdOpts.name,
404
412
  cron: cmdOpts.cron,
@@ -428,7 +436,7 @@ export function createScheduleCommand(deps = {}) {
428
436
  .addHelpText('after', GLOBAL_OPTS_HINT)
429
437
  .action(async (scheduleId, cmdOpts, command) => {
430
438
  await runDelete({
431
- ...resolveCommonOptions(command),
439
+ ...resolveCommonOptions(command, deps.env),
432
440
  scheduleId,
433
441
  confirm: cmdOpts.confirm === true,
434
442
  idempotencyKey: cmdOpts.idempotencyKey,
@@ -450,7 +458,7 @@ export function createScheduleCommand(deps = {}) {
450
458
  .addHelpText('after', GLOBAL_OPTS_HINT)
451
459
  .action(async (scheduleId, cmdOpts, command) => {
452
460
  await runRunList({
453
- ...resolveCommonOptions(command),
461
+ ...resolveCommonOptions(command, deps.env),
454
462
  scheduleId,
455
463
  columns: cmdOpts.columns,
456
464
  noHeader: cmdOpts.header === false,
@@ -461,10 +469,10 @@ export function createScheduleCommand(deps = {}) {
461
469
  // ---------------------------------------------------------------------------
462
470
  // Helpers
463
471
  // ---------------------------------------------------------------------------
464
- function resolveCommonOptions(command) {
472
+ function resolveCommonOptions(command, env) {
465
473
  const globals = command.optsWithGlobals();
466
474
  return {
467
- profile: globals.profile ?? 'default',
475
+ profile: resolveProfileName(globals.profile, env),
468
476
  output: resolveOutputMode(globals.output),
469
477
  endpointUrl: globals.endpointUrl,
470
478
  debug: globals.debug ?? false,