@testsprite/testsprite-cli 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +51 -147
  2. package/dist/commands/agent.d.ts +12 -4
  3. package/dist/commands/agent.js +48 -63
  4. package/dist/commands/auth.d.ts +6 -10
  5. package/dist/commands/auth.js +38 -54
  6. package/dist/commands/ci.d.ts +23 -100
  7. package/dist/commands/ci.js +293 -487
  8. package/dist/commands/conversation.d.ts +27 -0
  9. package/dist/commands/conversation.js +702 -0
  10. package/dist/commands/doctor.d.ts +5 -1
  11. package/dist/commands/doctor.js +129 -34
  12. package/dist/commands/init.d.ts +4 -45
  13. package/dist/commands/init.js +108 -66
  14. package/dist/commands/project-env.d.ts +62 -2
  15. package/dist/commands/project-env.js +388 -37
  16. package/dist/commands/project-sign-in.d.ts +0 -48
  17. package/dist/commands/project-sign-in.js +1 -229
  18. package/dist/commands/project.d.ts +15 -186
  19. package/dist/commands/project.js +89 -924
  20. package/dist/commands/result.d.ts +10 -0
  21. package/dist/commands/result.js +215 -0
  22. package/dist/commands/schedule.d.ts +0 -29
  23. package/dist/commands/schedule.js +28 -87
  24. package/dist/commands/test.d.ts +301 -1816
  25. package/dist/commands/test.js +1951 -13902
  26. package/dist/commands/testlist.d.ts +128 -5
  27. package/dist/commands/testlist.js +269 -339
  28. package/dist/commands/tunnel.d.ts +2 -2
  29. package/dist/commands/tunnel.js +23 -19
  30. package/dist/commands/usage.d.ts +12 -45
  31. package/dist/commands/usage.js +50 -131
  32. package/dist/index.js +182 -104
  33. package/dist/lib/agent-detect.js +9 -5
  34. package/dist/lib/agent-targets.d.ts +21 -2
  35. package/dist/lib/agent-targets.js +88 -11
  36. package/dist/lib/args.d.ts +13 -0
  37. package/dist/lib/args.js +49 -0
  38. package/dist/lib/basic-auth.d.ts +3 -0
  39. package/dist/lib/basic-auth.js +15 -0
  40. package/dist/lib/billing-refusal.js +4 -3
  41. package/dist/lib/ci-linkage.d.ts +4 -82
  42. package/dist/lib/ci-linkage.js +4 -157
  43. package/dist/lib/ci-run.js +1 -1
  44. package/dist/lib/client-factory.d.ts +10 -2
  45. package/dist/lib/client-factory.js +38 -26
  46. package/dist/lib/commit-signal.d.ts +65 -0
  47. package/dist/lib/commit-signal.js +305 -0
  48. package/dist/lib/concurrency-limiter.d.ts +6 -0
  49. package/dist/lib/concurrency-limiter.js +29 -0
  50. package/dist/lib/config.js +10 -5
  51. package/dist/lib/conflict-reason.d.ts +9 -3
  52. package/dist/lib/conflict-reason.js +6 -3
  53. package/dist/lib/conversation/answers.d.ts +9 -0
  54. package/dist/lib/conversation/answers.js +49 -0
  55. package/dist/lib/conversation/api.d.ts +71 -0
  56. package/dist/lib/conversation/api.js +150 -0
  57. package/dist/lib/conversation/change.d.ts +31 -0
  58. package/dist/lib/conversation/change.js +124 -0
  59. package/dist/lib/conversation/context.d.ts +19 -0
  60. package/dist/lib/conversation/context.js +70 -0
  61. package/dist/lib/conversation/environment.d.ts +15 -0
  62. package/dist/lib/conversation/environment.js +33 -0
  63. package/dist/lib/conversation/follow.d.ts +24 -0
  64. package/dist/lib/conversation/follow.js +42 -0
  65. package/dist/lib/conversation/render.d.ts +33 -0
  66. package/dist/lib/conversation/render.js +315 -0
  67. package/dist/lib/conversation/title.d.ts +2 -0
  68. package/dist/lib/conversation/title.js +18 -0
  69. package/dist/lib/conversation/types.d.ts +156 -0
  70. package/dist/lib/conversation/types.js +6 -0
  71. package/dist/lib/credentials.js +67 -11
  72. package/dist/lib/cron.d.ts +1 -1
  73. package/dist/lib/cron.js +2 -2
  74. package/dist/lib/dispatch-stop.d.ts +20 -0
  75. package/dist/lib/dispatch-stop.js +30 -0
  76. package/dist/lib/download.d.ts +71 -0
  77. package/dist/lib/download.js +274 -0
  78. package/dist/lib/dry-run/fetch.d.ts +10 -0
  79. package/dist/lib/dry-run/fetch.js +20 -0
  80. package/dist/lib/dry-run/samples.d.ts +6 -34
  81. package/dist/lib/dry-run/samples.js +375 -747
  82. package/dist/lib/environment-tunnel.d.ts +16 -27
  83. package/dist/lib/environment-tunnel.js +161 -154
  84. package/dist/lib/errors.d.ts +20 -4
  85. package/dist/lib/errors.js +36 -16
  86. package/dist/lib/facade.d.ts +7 -29
  87. package/dist/lib/facade.js +7 -36
  88. package/dist/lib/failing-fe-resolver.d.ts +13 -58
  89. package/dist/lib/failing-fe-resolver.js +47 -132
  90. package/dist/lib/first-suite-hint.d.ts +16 -22
  91. package/dist/lib/first-suite-hint.js +38 -47
  92. package/dist/lib/gh-output.d.ts +76 -21
  93. package/dist/lib/gh-output.js +171 -90
  94. package/dist/lib/git-utils.d.ts +56 -0
  95. package/dist/lib/git-utils.js +212 -0
  96. package/dist/lib/github-context.d.ts +2 -0
  97. package/dist/lib/github-context.js +40 -8
  98. package/dist/lib/history-retention.d.ts +6 -2
  99. package/dist/lib/history-retention.js +10 -7
  100. package/dist/lib/http.d.ts +58 -134
  101. package/dist/lib/http.js +352 -289
  102. package/dist/lib/interrupt.d.ts +14 -8
  103. package/dist/lib/interrupt.js +28 -10
  104. package/dist/lib/junit-report.d.ts +57 -4
  105. package/dist/lib/junit-report.js +202 -32
  106. package/dist/lib/local-target.d.ts +3 -3
  107. package/dist/lib/local-target.js +3 -3
  108. package/dist/lib/output.d.ts +1 -40
  109. package/dist/lib/output.js +11 -49
  110. package/dist/lib/pagination.d.ts +2 -5
  111. package/dist/lib/pagination.js +2 -5
  112. package/dist/lib/presigned-url.d.ts +22 -0
  113. package/dist/lib/presigned-url.js +90 -0
  114. package/dist/lib/prompt.js +36 -2
  115. package/dist/lib/proxy.js +2 -1
  116. package/dist/lib/redact.d.ts +2 -2
  117. package/dist/lib/redact.js +3 -4
  118. package/dist/lib/removed-commands.d.ts +18 -0
  119. package/dist/lib/removed-commands.js +154 -0
  120. package/dist/lib/render-error.d.ts +31 -6
  121. package/dist/lib/render-error.js +88 -25
  122. package/dist/lib/response-schemas.d.ts +38 -30
  123. package/dist/lib/response-schemas.js +207 -207
  124. package/dist/lib/result/api.d.ts +24 -0
  125. package/dist/lib/result/api.js +28 -0
  126. package/dist/lib/result/evidence.d.ts +71 -0
  127. package/dist/lib/result/evidence.js +420 -0
  128. package/dist/lib/result/render.d.ts +20 -0
  129. package/dist/lib/result/render.js +194 -0
  130. package/dist/lib/result/types.d.ts +122 -0
  131. package/dist/lib/result/types.js +19 -0
  132. package/dist/lib/run-output.d.ts +275 -0
  133. package/dist/lib/run-output.js +227 -0
  134. package/dist/lib/run-render.d.ts +101 -0
  135. package/dist/lib/run-render.js +183 -0
  136. package/dist/lib/run-wait.d.ts +192 -0
  137. package/dist/lib/run-wait.js +452 -0
  138. package/dist/lib/runs.types.d.ts +118 -367
  139. package/dist/lib/runs.types.js +0 -14
  140. package/dist/lib/secret-file.d.ts +1 -1
  141. package/dist/lib/secret-file.js +11 -2
  142. package/dist/lib/skill-nudge.d.ts +7 -27
  143. package/dist/lib/skill-nudge.js +9 -37
  144. package/dist/lib/target-path.d.ts +15 -0
  145. package/dist/lib/target-path.js +35 -0
  146. package/dist/lib/target-url-advisory.d.ts +19 -0
  147. package/dist/lib/target-url-advisory.js +31 -0
  148. package/dist/lib/target-url-preflight.d.ts +9 -0
  149. package/dist/lib/target-url-preflight.js +214 -106
  150. package/dist/lib/target-url.d.ts +1 -1
  151. package/dist/lib/target-url.js +6 -16
  152. package/dist/lib/telemetry.d.ts +31 -11
  153. package/dist/lib/telemetry.js +37 -8
  154. package/dist/lib/terminal-text.d.ts +41 -0
  155. package/dist/lib/terminal-text.js +127 -0
  156. package/dist/lib/testlist.types.d.ts +16 -8
  157. package/dist/lib/testlist.types.js +1 -1
  158. package/dist/lib/text-equality.d.ts +2 -0
  159. package/dist/lib/text-equality.js +5 -0
  160. package/dist/lib/text-file.d.ts +16 -0
  161. package/dist/lib/text-file.js +41 -0
  162. package/dist/lib/text-table.d.ts +46 -0
  163. package/dist/lib/text-table.js +72 -4
  164. package/dist/lib/ticker.d.ts +9 -2
  165. package/dist/lib/ticker.js +16 -3
  166. package/dist/lib/transport-failure.d.ts +22 -0
  167. package/dist/lib/transport-failure.js +126 -0
  168. package/dist/lib/tunnel-session.d.ts +7 -1
  169. package/dist/lib/tunnel-session.js +22 -9
  170. package/dist/lib/update-check.js +3 -2
  171. package/dist/lib/url-template.d.ts +43 -0
  172. package/dist/lib/url-template.js +151 -0
  173. package/dist/lib/validate.d.ts +0 -64
  174. package/dist/lib/validate.js +2 -131
  175. package/dist/lib/version-notice.js +4 -3
  176. package/dist/lib/wait-exit.d.ts +37 -2
  177. package/dist/lib/wait-exit.js +88 -30
  178. package/dist/lib/workspace-status.js +10 -2
  179. package/dist/version.d.ts +1 -1
  180. package/dist/version.js +1 -1
  181. package/package.json +2 -3
  182. package/skills/testsprite-ci.skill.md +48 -18
  183. package/skills/testsprite-onboard.skill.md +66 -151
  184. package/skills/testsprite-verify.codex.md +50 -52
  185. package/skills/testsprite-verify.skill.md +184 -351
  186. package/dist/lib/browser.d.ts +0 -6
  187. package/dist/lib/browser.js +0 -54
  188. package/dist/lib/bundle.d.ts +0 -234
  189. package/dist/lib/bundle.js +0 -781
  190. package/dist/lib/deprecate.d.ts +0 -32
  191. package/dist/lib/deprecate.js +0 -39
  192. package/dist/lib/flaky.d.ts +0 -91
  193. package/dist/lib/flaky.js +0 -71
  194. package/dist/lib/plan-poll.d.ts +0 -171
  195. package/dist/lib/plan-poll.js +0 -441
  196. package/dist/lib/plans.types.d.ts +0 -130
  197. package/dist/lib/plans.types.js +0 -31
  198. package/dist/lib/poll.d.ts +0 -100
  199. package/dist/lib/poll.js +0 -290
  200. package/dist/lib/rate-throttle.d.ts +0 -49
  201. package/dist/lib/rate-throttle.js +0 -75
  202. package/dist/lib/run-progress.d.ts +0 -41
  203. package/dist/lib/run-progress.js +0 -56
  204. package/dist/lib/v3-advisory.d.ts +0 -55
  205. package/dist/lib/v3-advisory.js +0 -74
  206. package/schemas/plan.schema.json +0 -61
@@ -1,21 +1,20 @@
1
1
  import { Command } from 'commander';
2
2
  import { formatWorkspaceStatus } from '../lib/workspace-status.js';
3
- import { assertValidApiKey, assertValidEndpointUrl, emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
4
- import { ApiError, CLIError, InterruptError } from '../lib/errors.js';
3
+ import { assertValidApiKey, assertValidEndpointUrl, emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
4
+ import { ApiError, CLIError, InterruptError, RequestTimeoutError } from '../lib/errors.js';
5
5
  import { facadeBaseUrl, resolvePortalBase } from '../lib/facade.js';
6
6
  import { HttpClient } from '../lib/http.js';
7
7
  import { globalShutdown } from '../lib/interrupt.js';
8
8
  import { defaultCredentialsPath, deleteProfile, isCredentialsWritePermissionError, readProfile, writeProfile, } from '../lib/credentials.js';
9
9
  import { loadConfig, normalizeEnvVar, resolveProfileName } from '../lib/config.js';
10
- import { emitDeprecationNotice } from '../lib/deprecate.js';
11
10
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
12
11
  import { promptSecret } from '../lib/prompt.js';
13
12
  import { ME_RESPONSE_SCHEMA } from '../lib/response-schemas.js';
14
13
  import { formatOrgBinding, formatOrgsSummary, formatPersonalScopeHint } from '../lib/org-render.js';
15
- import { emitV3RoutingAdvisory, routingLabel } from '../lib/v3-advisory.js';
14
+ import { terminalSafeLine, terminalSafeWriter } from '../lib/terminal-text.js';
16
15
  const DEFAULT_API_URL = 'https://api.testsprite.com';
17
16
  const FROM_ENV_MISSING_KEY = 'TESTSPRITE_API_KEY is not set in the environment. Set it and re-run with --from-env, or omit --from-env to enter the key interactively.';
18
- const API_KEY_PAGE_PATH = '/dashboard/settings/apikey';
17
+ const API_KEY_PAGE_PATH = '/dashboard-v3/settings/apikey';
19
18
  /**
20
19
  * Where a key comes from. Names the Portal origin that matches the API
21
20
  * endpoint; for an endpoint the host map does not know, names the page by
@@ -52,7 +51,7 @@ export async function runConfigure(opts, deps = {}) {
52
51
  // it defaults to stderr — stdout stays a pure result stream (the configured
53
52
  // JSON/text), which matters under `--output json` (§8.1 stdout purity).
54
53
  const prelude = deps.preludeWrite ?? ((chunk) => process.stderr.write(chunk));
55
- const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
54
+ const stderr = terminalSafeWriter(deps.stderr);
56
55
  // Normalize the env endpoint: an empty / whitespace-only TESTSPRITE_API_URL is
57
56
  // treated as unset. Without this, `''` (e.g. `export TESTSPRITE_API_URL=` in a
58
57
  // shell profile) is non-nullish and would short-circuit the `??` chains below to
@@ -140,7 +139,10 @@ export async function runConfigure(opts, deps = {}) {
140
139
  baseUrl: facadeBaseUrl(apiUrl),
141
140
  apiKey,
142
141
  fetchImpl: deps.fetchImpl,
143
- requestTimeoutMs: opts.requestTimeoutMs,
142
+ // Same precedence as every other command's client (flag > env > default,
143
+ // same clamping): `setup --from-env` previously read the flag only, so a
144
+ // TESTSPRITE_REQUEST_TIMEOUT_MS deadline was silently ignored here.
145
+ requestTimeoutMs: resolveRequestTimeoutMs(opts, env),
144
146
  shutdownSignal: deps.shutdownSignal ?? globalShutdown.signal,
145
147
  shutdown: deps.shutdown ?? globalShutdown,
146
148
  });
@@ -155,7 +157,14 @@ export async function runConfigure(opts, deps = {}) {
155
157
  if (err instanceof InterruptError)
156
158
  throw err;
157
159
  const message = err instanceof Error ? err.message : String(err);
158
- stderr(`API key rejected by ${apiUrl}: ${message} — profile NOT updated`);
160
+ // A client-side timeout says nothing about the key. Rethrow it unchanged so
161
+ // it keeps its REQUEST_TIMEOUT code, exit 7 and request id, instead of the
162
+ // exit-3 "rejected" wrapper below that sends the user to rotate a good key.
163
+ if (err instanceof RequestTimeoutError) {
164
+ stderr(`API key check against ${apiUrl} timed out, profile NOT updated: ${terminalSafeLine(message)}`);
165
+ throw err;
166
+ }
167
+ stderr(`API key rejected by ${apiUrl}: ${terminalSafeLine(message)} — profile NOT updated`);
159
168
  // When the verification call returned a typed API error (AUTH_INVALID,
160
169
  // AUTH_FORBIDDEN, etc.), re-throw it directly so `index.ts` renders the
161
170
  // full typed envelope under `--output json` (code, nextAction, requestId,
@@ -167,7 +176,7 @@ export async function runConfigure(opts, deps = {}) {
167
176
  err.message = `API key rejected by ${apiUrl}: ${message} — did you mean to set TESTSPRITE_API_URL?`;
168
177
  throw err;
169
178
  }
170
- // Non-ApiError (truly unexpected throws like a TypeError from a
179
+ // Anything else (truly unexpected throws like a TypeError from a
171
180
  // misconfigured fetchImpl). Exit 3 (auth family).
172
181
  throw new CLIError(`API key rejected by ${apiUrl}: ${message} — did you mean to set TESTSPRITE_API_URL?`, 3);
173
182
  }
@@ -196,7 +205,6 @@ export async function runConfigure(opts, deps = {}) {
196
205
  export async function runWhoami(opts, deps = {}) {
197
206
  const out = makeOutput(opts.output, deps);
198
207
  const env = deps.env ?? process.env;
199
- const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
200
208
  // Resolve the endpoint URL so it can be surfaced in text output.
201
209
  // Dry-run uses the flag/env/default chain without touching credentials.
202
210
  // Real path uses the same loadConfig the HttpClient factory uses so the
@@ -227,41 +235,41 @@ export async function runWhoami(opts, deps = {}) {
227
235
  out.print(me, data => {
228
236
  const m = data;
229
237
  const lines = [
230
- `userId: ${m.userId}`,
238
+ `userId: ${terminalSafeLine(m.userId)}`,
231
239
  // Human-readable identity, rendered only when the backend supplies it
232
240
  // (dogfood L1866) — confirm the account at a glance before a billable run.
233
- ...(m.displayName ? [`name: ${m.displayName}`] : []),
234
- ...(m.email ? [`email: ${m.email}`] : []),
235
- `keyId: ${m.keyId}`,
241
+ ...(m.displayName ? [`name: ${terminalSafeLine(m.displayName)}`] : []),
242
+ ...(m.email ? [`email: ${terminalSafeLine(m.email)}`] : []),
243
+ `keyId: ${terminalSafeLine(m.keyId)}`,
236
244
  // Show the resolved endpoint so the user knows which env they are bound to
237
245
  // without having to infer from the `env` field alone (dogfood L1788).
238
246
  `endpoint: ${resolvedEndpoint}`,
239
- `env: ${m.env}`,
240
- `scopes: ${m.scopes.join(', ')}`,
241
- // Org context — confirms whose wallet a billable command will draw
242
- // from, so it renders only for V3-routed callers (`v3Enabled` is the
243
- // authoritative routing bit; field presence alone is not trusted).
244
- ...(m.v3Enabled === true && m.activeOrg
245
- ? [`org: ${m.activeOrg.name} (${m.activeOrg.plan}, ${m.activeOrg.role})`]
247
+ `env: ${terminalSafeLine(m.env)}`,
248
+ `scopes: ${terminalSafeLine(m.scopes.join(', '))}`,
249
+ // Org context — confirms whose wallet a billable command will draw from.
250
+ ...(m.activeOrg
251
+ ? [
252
+ `org: ${terminalSafeLine(m.activeOrg.name)} (${terminalSafeLine(m.activeOrg.plan)}, ${terminalSafeLine(m.activeOrg.role)})`,
253
+ ]
246
254
  : []),
247
255
  // A paused (or payment-pending) workspace refuses every write, so say so
248
256
  // next to the org it applies to instead of letting the next command find out.
249
- ...(m.v3Enabled === true && formatWorkspaceStatus(m.activeOrg?.workspace)
257
+ ...(formatWorkspaceStatus(m.activeOrg?.workspace)
250
258
  ? [`workspace: ${formatWorkspaceStatus(m.activeOrg?.workspace)}`]
251
259
  : []),
252
- // Authoritative routing mode, rendered only when the backend supplies it.
253
- ...(m.v3Enabled !== undefined ? [`routing: ${routingLabel(m.v3Enabled)}`] : []),
254
260
  // Org attribution — account-wide membership list, rendered only when
255
261
  // the backend supplies a non-empty list.
256
262
  ...(formatOrgsSummary(m.organizations)
257
- ? [`orgs: ${formatOrgsSummary(m.organizations)}`]
263
+ ? [`orgs: ${terminalSafeLine(String(formatOrgsSummary(m.organizations)))}`]
258
264
  : []),
259
265
  // The calling key's own org binding — membership keys only.
260
- ...(formatOrgBinding(m.org) ? [`org binding: ${formatOrgBinding(m.org)}`] : []),
266
+ ...(formatOrgBinding(m.org)
267
+ ? [`org binding: ${terminalSafeLine(String(formatOrgBinding(m.org)))}`]
268
+ : []),
261
269
  // A personal-scoped key held by someone who is also in a team: say so
262
270
  // here rather than letting the team's projects just not show up.
263
271
  ...(formatPersonalScopeHint(m.organizations, m.org)
264
- ? [`note: ${formatPersonalScopeHint(m.organizations, m.org)}`]
272
+ ? [`note: ${terminalSafeLine(String(formatPersonalScopeHint(m.organizations, m.org)))}`]
265
273
  : []),
266
274
  ];
267
275
  // C2: warn in text mode when key cannot write/run
@@ -271,17 +279,12 @@ export async function runWhoami(opts, deps = {}) {
271
279
  }
272
280
  return lines.join('\n');
273
281
  });
274
- // When V3 routing is on, warn (text mode only) about the still-open behavior
275
- // gaps. JSON consumers read `v3Enabled` directly; stdout stays pure.
276
- if (opts.output !== 'json' && me.v3Enabled === true) {
277
- emitV3RoutingAdvisory(stderr);
278
- }
279
282
  return me;
280
283
  }
281
284
  export async function runLogout(opts, deps = {}) {
282
285
  const credentialsPath = deps.credentialsPath ?? defaultCredentialsPath();
283
286
  const out = makeOutput(opts.output, deps);
284
- const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
287
+ const stderr = terminalSafeWriter(deps.stderr);
285
288
  if (opts.dryRun) {
286
289
  emitDryRunBanner(stderr);
287
290
  stderr(`[dry-run] would remove credentials for profile="${opts.profile}" from ${credentialsPath}`);
@@ -303,24 +306,13 @@ export function createAuthCommand(deps = {}) {
303
306
  const auth = new Command('auth')
304
307
  .description('Manage TestSprite credentials')
305
308
  .addHelpText('after', '\nTo add credentials, run: testsprite setup');
306
- // `status` (primary; formerly `whoami`). Credential WRITES no longer live
307
- // here — `auth configure` is a hidden, deprecated alias for `setup` (attached
308
- // in index.ts), and `setup` is the only command that writes credentials.
309
+ // Credential writes live in `setup`, the only command that writes credentials.
309
310
  auth
310
311
  .command('status')
311
312
  .summary('Show the active profile and its credentials')
312
- .description('Show the active profile: user, API key id, endpoint, env, scopes and, when available, org, workspace and routing')
313
- .addHelpText('after', GLOBAL_OPTS_HINT)
314
- .action(async (_cmdOpts, command) => {
315
- await runWhoami(resolveCommonOptions(command, deps.env), deps);
316
- });
317
- // `whoami` — hidden, deprecated alias for `status` (kept so scripts/agents
318
- // on the old name keep working; invisible to --help).
319
- auth
320
- .command('whoami', { hidden: true })
313
+ .description('Show the active profile: user, API key id, endpoint, env, scopes and, when available, org and workspace')
321
314
  .addHelpText('after', GLOBAL_OPTS_HINT)
322
315
  .action(async (_cmdOpts, command) => {
323
- emitDeprecationNotice('auth whoami', 'auth status', deps.stderr);
324
316
  await runWhoami(resolveCommonOptions(command, deps.env), deps);
325
317
  });
326
318
  auth
@@ -331,14 +323,6 @@ export function createAuthCommand(deps = {}) {
331
323
  .action(async (_cmdOpts, command) => {
332
324
  await runLogout(resolveCommonOptions(command, deps.env), deps);
333
325
  });
334
- // `logout` — hidden, deprecated alias for `remove`.
335
- auth
336
- .command('logout', { hidden: true })
337
- .addHelpText('after', GLOBAL_OPTS_HINT)
338
- .action(async (_cmdOpts, command) => {
339
- emitDeprecationNotice('auth logout', 'auth remove', deps.stderr);
340
- await runLogout(resolveCommonOptions(command, deps.env), deps);
341
- });
342
326
  return auth;
343
327
  }
344
328
  function resolveCommonOptions(command, env) {
@@ -2,17 +2,18 @@ import { type SpawnSyncReturns } from 'node:child_process';
2
2
  import { Command } from 'commander';
3
3
  import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
4
4
  import { type FetchImpl } from '../lib/http.js';
5
- import { type DeploymentRecord, type LinkageStatus } from '../lib/ci-linkage.js';
5
+ import { type TargetPathFs } from '../lib/target-path.js';
6
6
  import { type RunTestRunAllOptions, type TestDeps } from './test.js';
7
7
  /** Platforms `ci init` can scaffold. One today; the positional arg leaves room. */
8
8
  declare const SUPPORTED_PLATFORMS: readonly ["github"];
9
9
  type Platform = (typeof SUPPORTED_PLATFORMS)[number];
10
10
  /**
11
11
  * Minimal fs seam (mirrors `agent.ts`'s `AgentFs` semantics: exclusive writes to
12
- * refuse clobbering, recursive mkdir to create parent dirs). Kept local so `ci`
13
- * doesn't couple to the agent-install internals.
12
+ * refuse clobbering, recursive mkdir to create parent dirs). Path inspection
13
+ * shares the agent installer's component walk.
14
14
  */
15
- export interface CiFs {
15
+ export interface CiFs extends TargetPathFs {
16
+ realpath(target: string): Promise<string>;
16
17
  writeFile(target: string, data: string, opts?: {
17
18
  exclusive?: boolean;
18
19
  }): Promise<void>;
@@ -22,12 +23,10 @@ export interface CiFs {
22
23
  readdir(dir: string): Promise<string[]>;
23
24
  }
24
25
  /** Injectable subprocess runner (defaults to a real `spawnSync`), so tests never
25
- * shell out. Runs `git` (repo slug), `gh` (optional secret set, deployment
26
- * history) and `npx vercel` (`ci connect`). */
26
+ * shell out. Runs `gh` (optional secret set). */
27
27
  export type SpawnImpl = (cmd: string, args: string[], opts: {
28
28
  input?: string;
29
29
  cwd?: string;
30
- shell?: boolean;
31
30
  }) => SpawnSyncReturns<string>;
32
31
  export interface CiDeps extends Pick<TestDeps, 'shutdown' | 'onWaitTimeout'> {
33
32
  env?: NodeJS.ProcessEnv;
@@ -38,10 +37,8 @@ export interface CiDeps extends Pick<TestDeps, 'shutdown' | 'onWaitTimeout'> {
38
37
  cwd?: string;
39
38
  fs?: CiFs;
40
39
  spawn?: SpawnImpl;
41
- /** Injected by `ci doctor --wait` tests so polling never really sleeps. */
40
+ /** Injected by tests so polling never really sleeps. */
42
41
  sleep?: (ms: number) => Promise<void>;
43
- /** OS seam for the Windows `npx` shim handling (defaults to `process.platform`). */
44
- platform?: NodeJS.Platform;
45
42
  }
46
43
  type CommonOptions = FactoryCommonOptions;
47
44
  export interface CiInitOptions extends CommonOptions {
@@ -105,84 +102,6 @@ export declare function buildGithubWorkflow(input: {
105
102
  workflowPath: string;
106
103
  }): string;
107
104
  export declare function runCiInit(opts: CiInitOptions, deps?: CiDeps): Promise<void>;
108
- export interface CiDoctorOptions extends CommonOptions {
109
- repo?: string;
110
- /** Poll until a NEW deployment record arrives (the post-connect check). */
111
- wait: boolean;
112
- /** Bound for `--wait`, in seconds; undefined = `--timeout` was not given. */
113
- waitTimeoutSeconds?: number;
114
- }
115
- export interface CiDoctorSummary {
116
- repo: string;
117
- status: LinkageStatus;
118
- ok: boolean;
119
- detail: string;
120
- lastDeployAt: string | null;
121
- creators: string[];
122
- hasPreview: boolean;
123
- /** Whether this run watched for a new record (`--wait`). */
124
- waited: boolean;
125
- /** `--wait` only: the record whose arrival ended the wait, or null. */
126
- newDeployment: DeploymentRecord | null;
127
- /** Set when history could not be read at all — then the rest is not a verdict. */
128
- error: string | null;
129
- }
130
- /**
131
- * `owner/repo` for the check: the explicit `--repo`, else the `origin` remote.
132
- * Returns null when neither resolves — the caller turns that into guidance
133
- * rather than an opaque failure.
134
- */
135
- export declare function resolveRepoSlug(explicit: string | undefined, cwd: string, spawn: SpawnImpl): string | null;
136
- /**
137
- * Diagnose whether deployment events reach this repo — the precondition every
138
- * deployment-gated workflow rests on, and the only one that fails *silently*.
139
- *
140
- * Exits non-zero when the chain is not live, so a script (or `ci init`) can
141
- * gate on it. `--wait` makes the post-connect verification one command instead
142
- * of "go watch GitHub yourself": it baselines the history on the first read and
143
- * succeeds when a NEW record arrives. That success condition is a hard fact,
144
- * deliberately independent of the preview/production heuristic — pushing to a
145
- * default branch produces a *production* deployment, and that still proves the
146
- * link is live.
147
- */
148
- export declare function runCiDoctor(opts: CiDoctorOptions, deps?: CiDeps): Promise<void>;
149
- export declare function renderCiDoctorText(s: CiDoctorSummary): string;
150
- export interface CiConnectOptions extends CommonOptions {
151
- /** Vercel project to link when this directory is not linked yet. */
152
- project?: string;
153
- }
154
- export interface CiConnectSummary {
155
- platform: 'vercel';
156
- /** The commands that were actually spawned, in order — no secrets in them. */
157
- ran: string[];
158
- connected: boolean;
159
- alreadyConnected: boolean;
160
- reason: string | null;
161
- }
162
- /**
163
- * Link the deploy platform to the repo — the fix for `ci doctor`'s `none`.
164
- *
165
- * Runs the platform's OWN CLI as a subprocess (`npx vercel …`, so nothing needs
166
- * pre-installing) rather than calling Vercel's API ourselves. That is a
167
- * deliberate boundary: any other approach would require the user to hand us a
168
- * Vercel token, and a third-party credential should never pass through this
169
- * CLI. Vercel's CLI keeps its own credentials; we only read exit codes.
170
- *
171
- * Every step runs `--non-interactive`, and `--yes` is NEVER passed to the
172
- * Vercel CLI on any path. `--yes` does not mean "skip confirmations": on an
173
- * unlinked directory `vercel link --yes` answers the new-project questions
174
- * with the default scope and the current directory name — creating a project
175
- * nobody asked for, which `git connect` then wires the repo to and starts
176
- * deploying. `ci doctor` would report that as `linked`: the exact silent
177
- * false-green this command exists to prevent. When Vercel needs a decision it
178
- * refuses with a structured reason instead, and that is relayed.
179
- *
180
- * `vercel git connect` is effectively idempotent — an already-connected repo
181
- * says so, which also resolves the one ambiguity `ci doctor` cannot see from
182
- * GitHub: "never linked" vs "linked but never deployed".
183
- */
184
- export declare function runCiConnect(opts: CiConnectOptions, deps?: CiDeps): Promise<void>;
185
- export declare function renderCiConnectText(s: CiConnectSummary): string;
186
105
  export declare function renderCiInitText(s: CiInitSummary): string;
187
106
  export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission' | 'previewName' | 'githubTrigger'> & {
188
107
  failOnSkipped?: boolean;
@@ -190,9 +109,22 @@ export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission
190
109
  executionReportTimeoutSeconds?: number;
191
110
  /** `--no-execution-report`: job summary stays the local table; nothing is read or written for the report. */
192
111
  executionReport?: boolean;
112
+ /**
113
+ * `--target-url-template`: the preview address as a pattern (`{pr}`,
114
+ * `{branch-slug}`, `{sha}`, …), filled on the runner from the pull request's
115
+ * facts; mutually exclusive with `--target-url`.
116
+ */
117
+ targetUrlTemplate?: string;
118
+ /** `--wait-for-status`: the commit status context / check-run name that says the preview exists. */
119
+ waitForStatus?: string;
120
+ /** `--status-timeout`: how long `--wait-for-status` waits (seconds; default 900). */
121
+ statusTimeoutSeconds?: number;
193
122
  };
123
+ /** How long `--wait-for-status` waits by default — a preview build is minutes, so its own budget, not `--timeout`'s. */
124
+ export declare const DEFAULT_STATUS_TIMEOUT_SECONDS = 900;
125
+ export declare function parseStatusTimeoutSeconds(raw: unknown): number;
194
126
  /**
195
- * `ci run` = `test run --all --wait` with CI's defaults, plus what only a CI
127
+ * `ci run` = `run --project --wait` with CI's defaults, plus what only a CI
196
128
  * job can add:
197
129
  *
198
130
  * - `admission: 'all'` — one request, one execution, server-side pacing (as
@@ -204,19 +136,10 @@ export type CiRunOptions = Omit<RunTestRunAllOptions, 'wait' | 'ci' | 'admission
204
136
  * deployment's commit), `--env X --target-url U` runs in a temporary clone
205
137
  * of X at U named `github-pr-<N>`, and the run is stamped with the PR so
206
138
  * the Portal links back to it — the GitHub App's own mechanism.
207
- * - Outside a pull request the run keeps `test run`'s semantics: X's sign-in
139
+ * - Outside a pull request the run keeps `run`'s semantics: X's sign-in
208
140
  * against U, recorded under X.
209
141
  */
210
142
  export declare function runCiRun(opts: CiRunOptions, deps?: TestDeps): Promise<void>;
143
+ /** Build CI run and workflow scaffolding commands with injectable runtime dependencies. */
211
144
  export declare function createCiCommand(deps?: CiDeps): Command;
212
- /**
213
- * One stderr line per run of a deprecated `ci` subcommand, naming the
214
- * equivalent commands (stdout stays clean for JSON pipelines). The
215
- * replacements are not `testsprite` commands, so this does not reuse
216
- * `emitDeprecationNotice`.
217
- */
218
- export declare const CI_DEPRECATION_NOTICES: {
219
- readonly doctor: string;
220
- readonly connect: string;
221
- };
222
145
  export {};