@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,5 +1,6 @@
1
1
  import type { InterruptError } from './errors.js';
2
2
  import type { OutputMode } from './output.js';
3
+ import { type RunRef } from './run-render.js';
3
4
  /** The JSON-mode stderr envelope for a signal detach (errors.md §8.1). */
4
5
  export interface InterruptEnvelope {
5
6
  error: {
@@ -10,13 +11,20 @@ export interface InterruptEnvelope {
10
11
  details: Record<string, unknown>;
11
12
  };
12
13
  }
14
+ /**
15
+ * Record on an interrupt that it cut a run wait short, and which results the
16
+ * wait was still following. The envelope's hint is built from them, so it
17
+ * names the same launches as the stderr line the command prints, and says what
18
+ * cancelling stops where the command only joined a run.
19
+ */
20
+ export declare function markRunWaitInterrupt(err: InterruptError, waitedRuns: ReadonlyArray<RunRef>): void;
13
21
  /**
14
22
  * Build the `INTERRUPTED` envelope from whatever the interrupted command
15
- * attached to the error. A tunnel run attaches `tunnelDetach` and
16
- * `test plan generate` attaches `planDetach`; each carries its own
17
- * `nextAction` so the envelope never contradicts the text line the catch
18
- * block already printed. Otherwise a run wait gets the run-detach story
19
- * (`test wait`) and any other request gets the generic check-state hint.
23
+ * attached to the error. A tunnel run attaches `tunnelDetach`, which carries
24
+ * its own `nextAction` so the envelope never contradicts the text line the
25
+ * catch block already printed. Otherwise a run wait gets the run-detach story
26
+ * (`run wait` / `run cancel`, naming the launches when they are known) and
27
+ * any other request gets the generic check-state hint.
20
28
  */
21
29
  export declare function buildInterruptEnvelope(err: InterruptError): InterruptEnvelope;
22
30
  /**
@@ -37,8 +45,12 @@ export declare function buildInterruptEnvelope(err: InterruptError): InterruptEn
37
45
  * first calling outputError (should not happen for parse errors).
38
46
  * fallbackMsg: err.message from CommanderError, used when pendingMsg is null.
39
47
  * mode: the output mode resolved from --output (or argv fallback).
48
+ * removedPointer: where a removed command or option went: a line after the
49
+ * message in text, the `nextAction` in JSON. It takes the place
50
+ * of Commander's "(Did you mean …?)" line, which names a
51
+ * similarly spelled command that is not the replacement.
40
52
  */
41
- export declare function renderCommanderError(pendingMsg: string | null, fallbackMsg: string, mode: OutputMode): string;
53
+ export declare function renderCommanderError(pendingMsg: string | null, fallbackMsg: string, mode: OutputMode, removedPointer?: string): string;
42
54
  /**
43
55
  * Text-mode rendering for the `AMBIGUOUS_ORG` conflict (`details.candidates[]`
44
56
  * — an array of `{ projectId, orgId }` pairs the same testId resolved to,
@@ -55,4 +67,17 @@ export declare function renderCommanderError(pendingMsg: string | null, fallback
55
67
  export declare function renderAmbiguousOrgCandidates(candidates: unknown): string[];
56
68
  /** Text-mode recovery handles for the account's tunnel binding limit. */
57
69
  export declare function renderTunnelBindingLimitIds(details: unknown): string[];
70
+ /**
71
+ * Commander quotes the whole token in "unknown option '--password=hunter2'".
72
+ * A flag this CLI no longer registers can still arrive with a secret from an
73
+ * older script, so the value is hidden before the message is buffered. So is
74
+ * a URL that carries credentials (`https://user:password@host`), whatever the
75
+ * flag is called.
76
+ *
77
+ * The value runs to the quote Commander closes the token with, which is the
78
+ * last `'` in the message: all Commander adds after it is its "(Did you mean
79
+ * …?)" line, and an option name holds no quote. A quote or a line break
80
+ * inside the value therefore never ends what is hidden.
81
+ */
82
+ export declare function redactUnknownOptionValue(raw: string): string;
58
83
  export declare function rephraseUnknownOption(raw: string): string | null;
@@ -1,30 +1,48 @@
1
+ import { isSecretKey, REDACTED } from './redact.js';
2
+ import { cancelCommand, waitCommand } from './run-render.js';
3
+ import { jsonForTerminal, terminalSafe, terminalSafeLine } from './terminal-text.js';
4
+ /**
5
+ * Record on an interrupt that it cut a run wait short, and which results the
6
+ * wait was still following. The envelope's hint is built from them, so it
7
+ * names the same launches as the stderr line the command prints, and says what
8
+ * cancelling stops where the command only joined a run.
9
+ */
10
+ export function markRunWaitInterrupt(err, waitedRuns) {
11
+ err.runWaitContext = true;
12
+ err.waitedRuns = waitedRuns;
13
+ }
1
14
  /**
2
15
  * Build the `INTERRUPTED` envelope from whatever the interrupted command
3
- * attached to the error. A tunnel run attaches `tunnelDetach` and
4
- * `test plan generate` attaches `planDetach`; each carries its own
5
- * `nextAction` so the envelope never contradicts the text line the catch
6
- * block already printed. Otherwise a run wait gets the run-detach story
7
- * (`test wait`) and any other request gets the generic check-state hint.
16
+ * attached to the error. A tunnel run attaches `tunnelDetach`, which carries
17
+ * its own `nextAction` so the envelope never contradicts the text line the
18
+ * catch block already printed. Otherwise a run wait gets the run-detach story
19
+ * (`run wait` / `run cancel`, naming the launches when they are known) and
20
+ * any other request gets the generic check-state hint.
8
21
  */
9
22
  export function buildInterruptEnvelope(err) {
10
- const { tunnelDetach, planDetach } = err;
23
+ const { tunnelDetach } = err;
24
+ const waitedRuns = err.waitedRuns ?? [];
25
+ const wait = waitCommand(waitedRuns);
26
+ const cancel = cancelCommand(waitedRuns);
11
27
  const nextAction = tunnelDetach?.nextAction ??
12
- planDetach?.nextAction ??
13
28
  (err.runWaitContext
14
- ? 'The server-side run (if any) keeps executing and billing. ' +
15
- 'Re-attach with: testsprite test wait <runId>, or stop it with: testsprite test cancel <runId> ' +
16
- '(runId is in the partial JSON on stdout).'
29
+ ? wait && cancel
30
+ ? 'The server-side run keeps executing and billing. ' +
31
+ `Re-attach with: ${wait}, or stop it with: ${cancel}.`
32
+ : 'The server-side run (if any) keeps executing and billing. ' +
33
+ 'Re-attach with: testsprite run wait <run-id>, or stop it with: testsprite run cancel <run-id> ' +
34
+ '(the partial JSON on stdout carries the runId when the backend reports one).'
17
35
  : 'The request was interrupted. Check the current state before retrying; ' +
18
36
  'a multi-item command may have processed some items.');
19
37
  const details = { signal: err.signal };
20
38
  if (tunnelDetach) {
21
- details.runId = tunnelDetach.runId;
39
+ // Keep native execution and result IDs when the command knows them.
40
+ Object.assign(details, {
41
+ ...(tunnelDetach.runId ? { runId: tunnelDetach.runId } : {}),
42
+ ...(tunnelDetach.resultId ? { resultId: tunnelDetach.resultId } : {}),
43
+ });
22
44
  details.cancelOutcome = tunnelDetach.cancel;
23
45
  }
24
- else if (planDetach) {
25
- details.projectId = planDetach.projectId;
26
- details.stagesRemaining = planDetach.stagesRemaining;
27
- }
28
46
  return {
29
47
  error: { code: 'INTERRUPTED', message: err.message, nextAction, requestId: 'local', details },
30
48
  };
@@ -64,22 +82,40 @@ const GLOBAL_FLAG_ARITY = {
64
82
  * first calling outputError (should not happen for parse errors).
65
83
  * fallbackMsg: err.message from CommanderError, used when pendingMsg is null.
66
84
  * mode: the output mode resolved from --output (or argv fallback).
85
+ * removedPointer: where a removed command or option went: a line after the
86
+ * message in text, the `nextAction` in JSON. It takes the place
87
+ * of Commander's "(Did you mean …?)" line, which names a
88
+ * similarly spelled command that is not the replacement.
67
89
  */
68
- export function renderCommanderError(pendingMsg, fallbackMsg, mode) {
69
- const rawMsg = (pendingMsg ?? fallbackMsg).trim();
90
+ export function renderCommanderError(pendingMsg, fallbackMsg, mode, removedPointer) {
91
+ const rawMsg = withoutSuggestion((pendingMsg ?? fallbackMsg).trim(), removedPointer);
70
92
  if (mode === 'json') {
71
- return (JSON.stringify({
93
+ return (jsonForTerminal({
72
94
  error: {
73
95
  code: 'VALIDATION_ERROR',
74
96
  message: rawMsg,
75
- nextAction: 'Run testsprite --help or testsprite <command> --help for usage.',
97
+ nextAction: removedPointer ?? 'Run testsprite --help or testsprite <command> --help for usage.',
76
98
  requestId: 'local',
77
99
  },
78
- }, null, 2) + '\n');
100
+ }, 2) + '\n');
79
101
  }
80
- // Text mode: emit the buffered message as-is (already formatted by Commander
81
- // or rephrased by rephraseUnknownOption). Synthesize when null.
82
- return pendingMsg ?? `${rawMsg}\n`;
102
+ // Text mode: emit the buffered message as formatted by Commander (or
103
+ // rephrased by rephraseUnknownOption), its lines kept and any control
104
+ // character an argument carried removed. Synthesize when null. A removed
105
+ // command's pointer follows on a line of its own.
106
+ if (removedPointer === undefined)
107
+ return terminalSafe(pendingMsg ?? `${rawMsg}\n`);
108
+ return `${terminalSafe(rawMsg)}\n${removedPointer}\n`;
109
+ }
110
+ /**
111
+ * The message without the suggestion line Commander ends it with, when a
112
+ * removal pointer follows. Only a line that ends the message is dropped, so
113
+ * the same text inside a quoted argument stays.
114
+ */
115
+ function withoutSuggestion(message, removedPointer) {
116
+ return removedPointer === undefined
117
+ ? message
118
+ : message.replace(/\n\(Did you mean [^\n]*\?\)$/, '');
83
119
  }
84
120
  /**
85
121
  * Text-mode rendering for the `AMBIGUOUS_ORG` conflict (`details.candidates[]`
@@ -104,7 +140,7 @@ export function renderAmbiguousOrgCandidates(candidates) {
104
140
  const { projectId, orgId } = candidate;
105
141
  if (typeof projectId !== 'string' || typeof orgId !== 'string')
106
142
  continue;
107
- lines.push(` candidate: project ${projectId} (org ${orgId})`);
143
+ lines.push(` candidate: project ${terminalSafeLine(projectId)} (org ${terminalSafeLine(orgId)})`);
108
144
  }
109
145
  if (lines.length === 0)
110
146
  return [];
@@ -118,12 +154,39 @@ export function renderTunnelBindingLimitIds(details) {
118
154
  const ids = details.filter((value) => typeof value === 'string');
119
155
  if (ids.length === 0)
120
156
  return [];
121
- const lines = ids.slice(0, 20).map(id => ` tunnel: ${id}`);
157
+ const lines = ids.slice(0, 20).map(id => ` tunnel: ${terminalSafeLine(id)}`);
122
158
  if (ids.length > 20)
123
159
  lines.push(` … and ${ids.length - 20} more`);
124
160
  lines.push(' hint: testsprite tunnel list · testsprite tunnel stop <client-id> · testsprite tunnel stop --all --confirm');
125
161
  return lines;
126
162
  }
163
+ /** A URL with a user or password before its host. */
164
+ const URL_WITH_CREDENTIALS_RE = /^[a-z][a-z0-9+.-]*:\/\/[^/?#]*@/i;
165
+ /**
166
+ * Commander quotes the whole token in "unknown option '--password=hunter2'".
167
+ * A flag this CLI no longer registers can still arrive with a secret from an
168
+ * older script, so the value is hidden before the message is buffered. So is
169
+ * a URL that carries credentials (`https://user:password@host`), whatever the
170
+ * flag is called.
171
+ *
172
+ * The value runs to the quote Commander closes the token with, which is the
173
+ * last `'` in the message: all Commander adds after it is its "(Did you mean
174
+ * …?)" line, and an option name holds no quote. A quote or a line break
175
+ * inside the value therefore never ends what is hidden.
176
+ */
177
+ export function redactUnknownOptionValue(raw) {
178
+ const token = /unknown option '(--[^='\s]+)=/.exec(raw);
179
+ if (token === null)
180
+ return raw;
181
+ const valueStart = token.index + token[0].length;
182
+ const closingQuote = raw.lastIndexOf("'");
183
+ if (closingQuote <= valueStart)
184
+ return raw;
185
+ if (!isSecretKey(token[1].slice(2)) &&
186
+ !URL_WITH_CREDENTIALS_RE.test(raw.slice(valueStart, closingQuote)))
187
+ return raw;
188
+ return `${raw.slice(0, valueStart)}${REDACTED}${raw.slice(closingQuote)}`;
189
+ }
127
190
  export function rephraseUnknownOption(raw) {
128
191
  // Commander emits: "error: unknown option '--foo'"
129
192
  const match = /unknown option\s+'--([^']+)'/.exec(raw);
@@ -5,11 +5,12 @@
5
5
  * runtime validation, so a drifted or partial server response surfaced as
6
6
  * `undefined` output or an opaque TypeError deep inside a command. These
7
7
  * schemas are wired (opt-in, via `RequestOptions.schema`) into the typed
8
- * HttpClient helpers `triggerRun`, `triggerRunWithMeta`, `triggerRerun`,
9
- * `triggerBatchRerun`, `triggerBatchRunFresh`, `getRun`, `listTestRuns`,
10
- * `cancelRun`, and — for the account surfaces below — the `client.get` call
11
- * sites that own a `/me` or usage read. Every other generic
12
- * `get`/`post`/`put`/`patch`/`delete` caller stays schema-free and opt-in.
8
+ * HttpClient helpers (the run, test-list, tunnel and execution-report calls), and —
9
+ * for the account surfaces below — the `client.get` call sites that own a
10
+ * `/me` or usage read, plus the `client.get` call sites that
11
+ * own the `project get` / `project list` reads. Every other generic
12
+ * `get`/`post`/`put`/`patch`/`delete` caller stays
13
+ * schema-free and opt-in.
13
14
  *
14
15
  * Resilience rules (additive server changes must never hard-fail the CLI):
15
16
  *
@@ -22,12 +23,12 @@
22
23
  * the poll continues; renderers print the raw value), so a new server enum
23
24
  * member must degrade gracefully, never reject the whole response.
24
25
  * 3. REQUIRED-nullable interface fields use `v.nullish(inner, null)`: the wire
25
- * may omit a nullable field entirely (real fixture evidence: the chained
26
- * `test create --run` poll bodies in `test.test.ts` omit `error`), and
26
+ * may omit a nullable field entirely (real fixture evidence: poll bodies
27
+ * that omit `error`), and
27
28
  * every consumer already null-checks these, so absence normalizes to
28
29
  * `null` instead of failing. OPTIONAL interface fields (`?`) use
29
30
  * `v.optional` with NO default so presence/absence semantics that commands
30
- * branch on (e.g. `RerunResponse.closure`, `RunResponse.steps`) survive
31
+ * branch on (e.g. `RunResponse.runId`) survive
31
32
  * validation byte-identically.
32
33
  *
33
34
  * Each schema is annotated `v.GenericSchema<unknown, T>` against the
@@ -36,29 +37,36 @@
36
37
  import * as v from 'valibot';
37
38
  import type { MeResponse } from '../commands/auth.js';
38
39
  import type { UsageResponse } from '../commands/usage.js';
39
- import type { BatchRerunResponse, BatchRunFreshResponse, CancelRunResponse, ListRunsResponse, RerunResponse, RunResponse, TriggerRunResponse, ExecutionReport, ExecutionReportResponse } from './runs.types.js';
40
+ import type { BatchRunFreshResponse, ProjectRunResponse, CancelRunResponse, RunResponse, TriggerRunResponse, ExecutionReport, ExecutionReportResponse } from './runs.types.js';
40
41
  import type { CliTestListRunResponse } from './testlist.types.js';
42
+ import type { ResultDetail, ResultList } from './result/types.js';
41
43
  import type { TunnelListResponse, TunnelMintResponse, TunnelStatusResponse } from './tunnel.types.js';
44
+ import type { CliProject } from '../commands/project.js';
45
+ import type { Page } from './pagination.js';
46
+ /**
47
+ * GET /projects/{id} and the rows of GET /projects. Optional fields stay
48
+ * absent when omitted. The renderer-consumed environment fields are typed so
49
+ * a drifted value cannot throw in the text renderer.
50
+ */
51
+ export declare const CLI_PROJECT_SCHEMA: v.GenericSchema<unknown, CliProject>;
52
+ /** GET /projects page; an omitted `nextToken` normalizes to the terminal `null` cursor. */
53
+ export declare const CLI_PROJECT_LIST_SCHEMA: v.GenericSchema<unknown, Page<CliProject>>;
42
54
  /** Mirrors `RunResponse` (runs.types.ts): `GET /api/cli/v1/runs/{runId}`. */
43
55
  export declare const RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, RunResponse>;
44
56
  /** Mirrors `CancelRunResponse` (runs.types.ts): the run envelope plus cancel metadata. */
45
57
  export declare const CANCEL_RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, CancelRunResponse>;
46
58
  /** Mirrors `TriggerRunResponse` (runs.types.ts): `POST /tests/{testId}/runs`. */
47
59
  export declare const TRIGGER_RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, TriggerRunResponse>;
48
- /** Mirrors `RerunResponse` (runs.types.ts): `POST /tests/{testId}/runs/rerun`. */
49
- export declare const RERUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, RerunResponse>;
50
- /** Mirrors `BatchRerunResponse` (runs.types.ts): `POST /tests/batch/rerun`. */
51
- export declare const BATCH_RERUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, BatchRerunResponse>;
60
+ /** Modern project launch; never accept a legacy batch envelope. */
61
+ export declare const PROJECT_RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, ProjectRunResponse>;
52
62
  /** Mirrors `BatchRunFreshResponse` (runs.types.ts): `POST /tests/batch/run`. */
53
63
  export declare const BATCH_RUN_FRESH_RESPONSE_SCHEMA: v.GenericSchema<unknown, BatchRunFreshResponse>;
54
64
  /**
55
65
  * `POST /api/cli/v1/testlist/{listId}/run`. Mirrors the batch-run-fresh shape so
56
- * the `--wait` fan-out reuses the same poll tail; `conflicts[]` additionally
57
- * carry the in-flight `currentRunId`, and `reason` marks a nothing-dispatched run.
66
+ * the `--wait` path uses whole-execution result listings; `conflicts[]` additionally
67
+ * carry the in-flight `currentResultId`, and `reason` marks a nothing-dispatched run.
58
68
  */
59
69
  export declare const TESTLIST_RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, CliTestListRunResponse>;
60
- /** Mirrors `ListRunsResponse` (runs.types.ts): `GET /tests/{testId}/runs`. */
61
- export declare const LIST_RUNS_RESPONSE_SCHEMA: v.GenericSchema<unknown, ListRunsResponse>;
62
70
  /**
63
71
  * Minimal `/me` identity core, as read by `doctor`'s connectivity check.
64
72
  *
@@ -70,13 +78,11 @@ export declare const LIST_RUNS_RESPONSE_SCHEMA: v.GenericSchema<unknown, ListRun
70
78
  * a connectivity probe must not fail on a partial identity projection.
71
79
  *
72
80
  * `commands/doctor.ts` aliases its `MeIdentity` to this type so the two cannot
73
- * drift (they already had: `v3Enabled` existed on the command side only).
81
+ * drift.
74
82
  */
75
83
  export interface MeIdentityWire {
76
84
  userId?: string;
77
85
  keyId?: string;
78
- /** Authoritative per-user V3 routing bit; older backends omit it. */
79
- v3Enabled?: boolean;
80
86
  /**
81
87
  * Account-wide organization membership list (mirrors `CliOrgSummary` in
82
88
  * `lib/org-render.ts`). Optional/absent-safe: omitted on a server-side
@@ -103,7 +109,7 @@ export interface MeIdentityWire {
103
109
  export declare const ME_IDENTITY_SCHEMA: v.GenericSchema<unknown, MeIdentityWire>;
104
110
  /**
105
111
  * Mirrors `MeResponse` (commands/auth.ts): the full `GET /me` projection read
106
- * by `auth whoami` (and, through it, `init`).
112
+ * by `auth status` (and, through it, `setup`).
107
113
  *
108
114
  * `scopes` is required and array-typed on purpose — this is the shape drift
109
115
  * that actually bites today. `runWhoami` renders `m.scopes.join(', ')` and
@@ -112,24 +118,22 @@ export declare const ME_IDENTITY_SCHEMA: v.GenericSchema<unknown, MeIdentityWire
112
118
  * of a typed envelope. Every `/me` fixture in the suite supplies it
113
119
  * (`auth.test.ts`, `init.test.ts`, `usage.test.ts`, `cli.subprocess.test.ts`,
114
120
  * `test/mock-backend/fixtures.ts`), so requiring it matches observed wire
115
- * reality; `email` / `displayName` / `v3Enabled` are the genuinely absent-safe
121
+ * reality; `email` / `displayName` are the genuinely absent-safe
116
122
  * ones and stay `v.optional` with no default (rule 3, optional branch).
117
123
  *
118
- * `init` calls this through `runWhoami` inside a try/catch that falls back to
124
+ * `setup` calls this through `runWhoami` inside a try/catch that falls back to
119
125
  * a placeholder identity, so a drifted `/me` degrades the setup summary
120
- * instead of failing the whole `init`.
126
+ * instead of failing the whole `setup`.
121
127
  */
122
128
  export declare const ME_RESPONSE_SCHEMA: v.GenericSchema<unknown, MeResponse>;
123
129
  /**
124
- * Mirrors `UsageResponse` (commands/usage.ts): the credits/plan projection the
130
+ * Mirrors `UsageResponse` (commands/usage.ts): the wallet projection the
125
131
  * `usage` command reads off the same `GET /me` body.
126
132
  *
127
133
  * `renderUsage` prints `userId`/`keyId`/`env` unconditionally as its "identity
128
- * block", so those three are required; `credits`, `subPlan` and
129
- * `creditsPerRun` are forward-compat fields the backend does not send today
130
- * (see the BACKEND FOLLOW-UP note in usage.ts) and every renderer branch is
131
- * gated on `!== undefined`, so they stay optional with no default. `scopes`
132
- * rides along as an unknown extra key and is preserved by `looseObject`.
134
+ * block", so those three are required. `activeOrg`, `organizations` and `org`
135
+ * are best-effort enrichments every renderer branch gates on `!== undefined`,
136
+ * and ride along (with `scopes`) as extra keys preserved by `looseObject`.
133
137
  */
134
138
  export declare const USAGE_RESPONSE_SCHEMA: v.GenericSchema<unknown, UsageResponse>;
135
139
  /**
@@ -150,3 +154,7 @@ export declare const TUNNEL_LIST_RESPONSE_SCHEMA: v.GenericSchema<unknown, Tunne
150
154
  export declare const EXECUTION_REPORT_SCHEMA: v.GenericSchema<unknown, ExecutionReport>;
151
155
  /** Mirrors `ExecutionReportResponse`: `report`/`markdown` only travel with `ready: true`. */
152
156
  export declare const EXECUTION_REPORT_RESPONSE_SCHEMA: v.GenericSchema<unknown, ExecutionReportResponse>;
157
+ /** Mirrors `ResultList` (result/types.ts): `GET /results?run=…` or `?test=…`. */
158
+ export declare const RESULT_LIST_SCHEMA: v.GenericSchema<unknown, ResultList>;
159
+ /** Mirrors `ResultDetail` (result/types.ts): `GET /results/{resultId}`. */
160
+ export declare const RESULT_DETAIL_SCHEMA: v.GenericSchema<unknown, ResultDetail>;