@testsprite/testsprite-cli 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +52 -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 +40 -56
  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 +741 -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 +434 -43
  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 +19 -186
  19. package/dist/commands/project.js +108 -926
  20. package/dist/commands/result.d.ts +10 -0
  21. package/dist/commands/result.js +216 -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 -1838
  25. package/dist/commands/test.js +1880 -13917
  26. package/dist/commands/testlist.d.ts +130 -5
  27. package/dist/commands/testlist.js +300 -342
  28. package/dist/commands/tunnel.d.ts +3 -3
  29. package/dist/commands/tunnel.js +23 -20
  30. package/dist/commands/usage.d.ts +12 -45
  31. package/dist/commands/usage.js +50 -131
  32. package/dist/index.js +191 -110
  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 +12 -4
  45. package/dist/lib/client-factory.js +41 -30
  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 +75 -0
  56. package/dist/lib/conversation/api.js +151 -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 +29 -0
  60. package/dist/lib/conversation/context.js +82 -0
  61. package/dist/lib/conversation/environment.d.ts +16 -0
  62. package/dist/lib/conversation/environment.js +21 -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 +318 -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 +158 -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 +100 -0
  77. package/dist/lib/download.js +408 -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 +19 -30
  83. package/dist/lib/environment-tunnel.js +168 -202
  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 +20 -30
  91. package/dist/lib/first-suite-hint.js +57 -72
  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 +354 -291
  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 +8 -7
  107. package/dist/lib/local-target.js +14 -13
  108. package/dist/lib/output.d.ts +2 -41
  109. package/dist/lib/output.js +13 -51
  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 +170 -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 +73 -0
  127. package/dist/lib/result/evidence.js +422 -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 +8 -8
  151. package/dist/lib/target-url.js +14 -24
  152. package/dist/lib/telemetry.d.ts +35 -15
  153. package/dist/lib/telemetry.js +38 -9
  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 +8 -2
  169. package/dist/lib/tunnel-session.js +24 -11
  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 +52 -23
  183. package/skills/testsprite-onboard.skill.md +70 -153
  184. package/skills/testsprite-verify.codex.md +54 -58
  185. package/skills/testsprite-verify.skill.md +189 -358
  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
@@ -5,7 +5,7 @@
5
5
  * endpoint, credentials, live connectivity + key validity, and whether the
6
6
  * verify skill is installed in the current project) and prints an OK/WARN/FAIL
7
7
  * report. Exits non-zero when any check FAILS so it can gate a CI step or an
8
- * agent preflight (`testsprite doctor && testsprite test run ...`). Warnings
8
+ * agent preflight (`testsprite doctor && testsprite run ...`). Warnings
9
9
  * (e.g. skill not installed) do not fail the process.
10
10
  *
11
11
  * Every check is reused from the same helpers the real commands use, so the
@@ -45,6 +45,10 @@ export interface DoctorDeps {
45
45
  nodeVersion?: string;
46
46
  existsSync?: (p: string) => boolean;
47
47
  readFileSync?: (p: string) => string;
48
+ /** lstat for the Git checks (tests); a symlinked .gitignore is not trusted. */
49
+ lstatSync?: (p: string) => {
50
+ isSymbolicLink: boolean;
51
+ } | null;
48
52
  /** Config resolver. Defaults to `loadConfig`; injectable for tests. */
49
53
  loadConfigFn?: typeof loadConfig;
50
54
  }
@@ -5,7 +5,7 @@
5
5
  * endpoint, credentials, live connectivity + key validity, and whether the
6
6
  * verify skill is installed in the current project) and prints an OK/WARN/FAIL
7
7
  * report. Exits non-zero when any check FAILS so it can gate a CI step or an
8
- * agent preflight (`testsprite doctor && testsprite test run ...`). Warnings
8
+ * agent preflight (`testsprite doctor && testsprite run ...`). Warnings
9
9
  * (e.g. skill not installed) do not fail the process.
10
10
  *
11
11
  * Every check is reused from the same helpers the real commands use, so the
@@ -14,18 +14,22 @@
14
14
  * `makeHttpClient` + `GET /me` for connectivity, and `isVerifySkillInstalled`
15
15
  * for the skill check.
16
16
  */
17
+ import { lstatSync, readFileSync } from 'node:fs';
17
18
  import { Command } from 'commander';
18
19
  import { assertValidEndpointUrl, makeHttpClient, } from '../lib/client-factory.js';
19
20
  import { loadConfig, resolveProfileName, DEFAULT_API_URL, normalizeEnvVar, } from '../lib/config.js';
21
+ import { readCredentialsFile } from '../lib/credentials.js';
20
22
  import { ApiError, CLIError, InterruptError, RequestTimeoutError, localValidationError, } from '../lib/errors.js';
21
23
  import { globalShutdown } from '../lib/interrupt.js';
22
24
  import { formatOrgBinding, formatOrgsSummary, formatPersonalScopeHint } from '../lib/org-render.js';
23
25
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
24
26
  import { ME_IDENTITY_SCHEMA } from '../lib/response-schemas.js';
25
27
  import { isVerifySkillInstalled } from '../lib/skill-nudge.js';
26
- import { emitV3RoutingAdvisory, routingLabel } from '../lib/v3-advisory.js';
28
+ import { skillStates } from './agent.js';
27
29
  import { VERSION } from '../version.js';
28
30
  import { SUPPORTED_NODE_RANGE, shouldRejectNodeVersion } from '../version-guard.js';
31
+ import { inspectTestspriteIgnore } from '../lib/git-utils.js';
32
+ import { terminalSafeLine } from '../lib/terminal-text.js';
29
33
  export async function runDoctor(opts, deps = {}) {
30
34
  const out = makeOutput(opts.output, deps);
31
35
  const env = deps.env ?? process.env;
@@ -54,9 +58,22 @@ export async function runDoctor(opts, deps = {}) {
54
58
  apiKey: normalizeEnvVar(env.TESTSPRITE_API_KEY),
55
59
  };
56
60
  }
61
+ // Complete overrides let loadConfig skip the store. Doctor still diagnoses
62
+ // the file itself, without making its permissions block those overrides.
63
+ if (!credentialsReadError) {
64
+ try {
65
+ readCredentialsFile({ path: deps.credentialsPath });
66
+ }
67
+ catch (error) {
68
+ if (!isFsPermissionError(error))
69
+ throw error;
70
+ credentialsReadError = error.code;
71
+ }
72
+ }
73
+ const hasCompleteOverrides = normalizeEnvVar(env.TESTSPRITE_API_KEY) !== undefined &&
74
+ (opts.endpointUrl ?? normalizeEnvVar(env.TESTSPRITE_API_URL)) !== undefined;
57
75
  const endpointCheck = checkEndpoint(config.apiUrl);
58
76
  const hasKey = Boolean(config.apiKey);
59
- const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
60
77
  const connectivity = await checkConnectivity(opts, deps, {
61
78
  hasKey,
62
79
  endpointOk: endpointCheck.status === 'ok',
@@ -65,25 +82,16 @@ export async function runDoctor(opts, deps = {}) {
65
82
  // same EPERM and surfaces as a bogus Connectivity failure.
66
83
  config,
67
84
  });
85
+ const gitChecks = checkGit(cwd, deps);
68
86
  const checks = [
69
87
  { name: 'CLI version', status: 'ok', detail: VERSION },
70
88
  checkNodeVersion(nodeVersion),
89
+ gitChecks[0],
71
90
  { name: 'Profile', status: 'ok', detail: config.profile },
72
91
  endpointCheck,
73
- checkCredentials(hasKey, config.profile, opts.dryRun ?? false, credentialsReadError),
92
+ checkCredentials(hasKey, config.profile, opts.dryRun ?? false, credentialsReadError, hasCompleteOverrides),
74
93
  connectivity.check,
75
94
  ];
76
- // Informational routing line, only when the backend reported it (no new call).
77
- if (connectivity.v3Enabled !== undefined) {
78
- const label = routingLabel(connectivity.v3Enabled);
79
- checks.push({
80
- name: 'Routing',
81
- status: 'ok',
82
- detail: connectivity.v3Enabled === true
83
- ? `${label} (V3 execution routing is ON)`
84
- : `${label} (default routing)`,
85
- });
86
- }
87
95
  // Org attribution lines — only when the backend reported them (no new call).
88
96
  const orgsSummary = formatOrgsSummary(connectivity.organizations);
89
97
  if (orgsSummary) {
@@ -104,14 +112,12 @@ export async function runDoctor(opts, deps = {}) {
104
112
  endpointOk: endpointCheck.status === 'ok',
105
113
  config,
106
114
  }));
107
- checks.push(checkSkill(cwd, deps));
115
+ checks.push(await checkSkill(cwd, deps));
116
+ checks.push(gitChecks[1]);
108
117
  const failures = checks.filter(check => check.status === 'fail').length;
109
118
  const warnings = checks.filter(check => check.status === 'warn').length;
110
119
  const report = { checks, failures, warnings };
111
120
  out.print(report, () => renderDoctor(report));
112
- if (connectivity.v3Enabled === true) {
113
- emitV3RoutingAdvisory(stderr);
114
- }
115
121
  if (failures > 0) {
116
122
  // Non-zero exit so `testsprite doctor && ...` gates a CI step or an agent
117
123
  // preflight. The full report already printed above; this line is the stderr
@@ -152,14 +158,14 @@ function checkEndpoint(apiUrl) {
152
158
  };
153
159
  }
154
160
  }
155
- function checkCredentials(hasKey, profile, dryRun, readError) {
161
+ function checkCredentials(hasKey, profile, dryRun, readError, hasCompleteOverrides = false) {
156
162
  if (readError) {
157
163
  return {
158
164
  name: 'Credentials',
159
- status: hasKey ? 'warn' : 'fail',
165
+ status: hasCompleteOverrides ? 'warn' : 'fail',
160
166
  detail: `credentials file exists but cannot be read (${readError}); its ACL may be locked out ` +
161
167
  'by an earlier CLI version — delete the file and re-run `testsprite setup`' +
162
- (hasKey ? ' (TESTSPRITE_API_KEY is set, so commands still work)' : ''),
168
+ (hasCompleteOverrides ? ' (TESTSPRITE_API_KEY is set, so commands still work)' : ''),
163
169
  };
164
170
  }
165
171
  if (hasKey) {
@@ -179,18 +185,107 @@ function checkCredentials(hasKey, profile, dryRun, readError) {
179
185
  : 'no API key found; run `testsprite setup` (or set TESTSPRITE_API_KEY)',
180
186
  };
181
187
  }
182
- function checkSkill(cwd, deps) {
188
+ /**
189
+ * The two reads `skillStates` makes, done synchronously, so the check ends in
190
+ * the same turn of the event loop as doctor's other local checks. Writes are
191
+ * refused: doctor only reads.
192
+ */
193
+ const readOnlySkillFs = {
194
+ async lstat(p) {
195
+ try {
196
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- a skill path under the project dir doctor checks.
197
+ const stats = lstatSync(p);
198
+ return { isFile: stats.isFile(), isSymbolicLink: stats.isSymbolicLink() };
199
+ }
200
+ catch (err) {
201
+ const code = err.code;
202
+ if (code === 'ENOENT' || code === 'ENOTDIR')
203
+ return null;
204
+ throw err;
205
+ }
206
+ },
207
+ async readFile(p) {
208
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- a skill file under the project dir doctor checks.
209
+ return readFileSync(p, 'utf8');
210
+ },
211
+ async writeFile() {
212
+ throw new Error('doctor does not write skill files');
213
+ },
214
+ async mkdir() {
215
+ throw new Error('doctor does not write skill files');
216
+ },
217
+ };
218
+ async function checkSkill(cwd, deps) {
183
219
  const installed = isVerifySkillInstalled(cwd, {
184
220
  existsSync: deps.existsSync,
185
221
  readFileSync: deps.readFileSync,
186
222
  });
187
- return {
188
- name: 'Verify skill',
189
- status: installed ? 'ok' : 'warn',
190
- detail: installed
191
- ? 'installed in this project'
192
- : 'not installed here; run `testsprite setup` so your agent verifies its changes',
193
- };
223
+ if (!installed) {
224
+ return {
225
+ name: 'Verify skill',
226
+ status: 'warn',
227
+ detail: 'not installed here; run `testsprite setup` so your agent verifies its changes',
228
+ };
229
+ }
230
+ // A skill an earlier CLI wrote names the commands of that release; the
231
+ // same check `agent status` makes. Best-effort: a read that fails says
232
+ // nothing more than "installed".
233
+ const stale = await skillStates(cwd, readOnlySkillFs)
234
+ .then(rows => rows.filter(row => row.skill === 'testsprite-verify' && row.state === 'stale'))
235
+ .catch(() => []);
236
+ if (stale.length > 0) {
237
+ return {
238
+ name: 'Verify skill',
239
+ status: 'warn',
240
+ detail: 'installed, but written by an earlier CLI and naming its commands; re-install it with ' +
241
+ stale.map(row => `\`testsprite agent install ${row.target} --force\``).join(', '),
242
+ };
243
+ }
244
+ return { name: 'Verify skill', status: 'ok', detail: 'installed in this project' };
245
+ }
246
+ /**
247
+ * Git repository + .gitignore safety, computed together from one pass over the
248
+ * project dir up to the repository root. Informational only: never fails doctor.
249
+ */
250
+ function checkGit(cwd, deps) {
251
+ try {
252
+ const { inRepo, ignored } = inspectTestspriteIgnore(cwd, {
253
+ existsSync: deps.existsSync,
254
+ readFileSync: deps.readFileSync,
255
+ lstatSync: deps.lstatSync,
256
+ });
257
+ if (!inRepo) {
258
+ return [
259
+ {
260
+ name: 'Git repository',
261
+ status: 'ok',
262
+ detail: 'not a Git repository; nothing to ignore',
263
+ },
264
+ {
265
+ name: 'Gitignore safety',
266
+ status: 'ok',
267
+ detail: 'not applicable outside a Git repository',
268
+ },
269
+ ];
270
+ }
271
+ return [
272
+ { name: 'Git repository', status: 'ok', detail: 'inside a Git repository' },
273
+ {
274
+ name: 'Gitignore safety',
275
+ status: ignored ? 'ok' : 'warn',
276
+ detail: ignored
277
+ ? '.testsprite/ is ignored'
278
+ : '.testsprite/ is not ignored; run `testsprite setup` or add `.testsprite/` to .gitignore to avoid committing artifacts',
279
+ },
280
+ ];
281
+ }
282
+ catch (err) {
283
+ const detail = `could not inspect Git state: ${err instanceof Error ? err.message : String(err)}`;
284
+ return [
285
+ { name: 'Git repository', status: 'warn', detail },
286
+ { name: 'Gitignore safety', status: 'ok', detail: 'skipped' },
287
+ ];
288
+ }
194
289
  }
195
290
  async function checkConnectivity(opts, deps, ctx) {
196
291
  const name = 'Connectivity';
@@ -213,7 +308,6 @@ async function checkConnectivity(opts, deps, ctx) {
213
308
  const who = me.userId ? ` (userId ${me.userId})` : '';
214
309
  return {
215
310
  check: { name, status: 'ok', detail: `reached GET /me, API key accepted${who}` },
216
- v3Enabled: me.v3Enabled,
217
311
  organizations: me.organizations,
218
312
  org: me.org,
219
313
  };
@@ -352,7 +446,8 @@ function renderDoctor(report) {
352
446
  const nameWidth = Math.max(...report.checks.map(check => check.name.length));
353
447
  const lines = ['TestSprite doctor', ''];
354
448
  for (const check of report.checks) {
355
- lines.push(` ${STATUS_LABEL[check.status]} ${check.name.padEnd(nameWidth)} ${check.detail}`);
449
+ // A detail can carry a server value (an org name, an error): one line, terminal-safe.
450
+ lines.push(` ${STATUS_LABEL[check.status]} ${check.name.padEnd(nameWidth)} ${terminalSafeLine(check.detail)}`);
356
451
  }
357
452
  lines.push('');
358
453
  lines.push(report.failures === 0 && report.warnings === 0
@@ -363,12 +458,12 @@ function renderDoctor(report) {
363
458
  export function createDoctorCommand(deps = {}) {
364
459
  const cmd = new Command('doctor')
365
460
  .summary('Diagnose CLI setup: credentials, connectivity, skill')
366
- .description('Diagnose CLI setup: version, Node, profile, endpoint, credentials, API connectivity, workspace routing, tunnel permission (run:tunnel) and the verify skill in this directory. Exit 1 if any check fails; warnings do not.')
461
+ .description('Diagnose CLI setup: version, Node, profile, endpoint, credentials, API connectivity, organizations and workspace scope, tunnel permission (run:tunnel) and the verify skill in this directory. Exit 1 if any check fails; warnings do not.')
367
462
  .addHelpText('after', GLOBAL_OPTS_HINT)
368
463
  .addHelpText('after', '\nExamples:\n' +
369
464
  ' testsprite doctor # run all checks (exit 1 if any fails)\n' +
370
465
  ' testsprite doctor --output json # machine-readable report\n' +
371
- ' testsprite doctor && testsprite test run <id> # gate a command on a healthy setup')
466
+ ' testsprite doctor && testsprite run <id> # gate a command on a healthy setup')
372
467
  .action(async (_cmdOpts, command) => {
373
468
  await runDoctor(resolveCommonOptions(command, deps.env), deps);
374
469
  });
@@ -1,11 +1,12 @@
1
1
  /**
2
- * `testsprite init` — one-shot onboarding orchestrator.
2
+ * `testsprite setup` — one-shot onboarding orchestrator.
3
3
  *
4
4
  * Chains, in order:
5
5
  * 0. Agent-target resolution + confirmation prompt — the chosen install
6
6
  * targets are settled here, before anything is written
7
7
  * 1. runConfigure — writes the API-key profile (validates via GET /me first)
8
8
  * 2. runWhoami — fetches identity for the post-configure banner
9
+ * 2.5 ensureTestspriteIgnored — appends .testsprite/ to .gitignore inside a Git repo (unless --no-gitignore)
9
10
  * 3. runInstall — installs the TestSprite verification-loop skill (unless --no-agent)
10
11
  * 4. Summary print — JSON object or human text block
11
12
  *
@@ -30,7 +31,7 @@ export interface InitDeps {
30
31
  stderr?: (line: string) => void;
31
32
  credentialsPath?: string;
32
33
  fetchImpl?: FetchImpl;
33
- /** Injected for auth configure: { secret: (q) => Promise<string> } */
34
+ /** Injected for the key prompt: { secret: (q) => Promise<string> } */
34
35
  prompt?: AuthDeps['prompt'];
35
36
  preludeWrite?: (chunk: string) => void;
36
37
  cwd?: string;
@@ -51,6 +52,7 @@ interface InitOptions extends CommonOptions {
51
52
  */
52
53
  agent?: AgentTarget;
53
54
  noAgent: boolean;
55
+ noGitignore?: boolean;
54
56
  force: boolean;
55
57
  dir?: string;
56
58
  yes: boolean;
@@ -115,48 +117,5 @@ export interface InitSummary {
115
117
  status: 'initialized';
116
118
  }
117
119
  export declare function runInit(opts: InitOptions, deps?: InitDeps): Promise<void>;
118
- /** Raw Commander options shared by `setup` and the deprecated `init`/`auth configure` aliases. */
119
- export interface SetupCmdOpts {
120
- apiKey?: string;
121
- fromEnv?: boolean;
122
- /**
123
- * Commander sets `agent: false` (boolean) when `--no-agent` is given,
124
- * because `--no-agent` negates the `--agent <target>` option. Handle both
125
- * string and false shapes.
126
- */
127
- agent: string | false;
128
- noAgent?: boolean;
129
- force?: boolean;
130
- dir?: string;
131
- yes?: boolean;
132
- skipIfConfigured?: boolean;
133
- }
134
- /**
135
- * Attach the onboarding flags shared by `setup` and the `init`/`auth configure`
136
- * aliases. `--agent` deliberately carries NO default: its absence is the signal
137
- * that setup should detect the agent, and a default value here is
138
- * indistinguishable from the caller naming that same target.
139
- */
140
- export declare function addSetupOptions(cmd: Command, validTargets: AgentTarget[], defaultAgent: AgentTarget): Command;
141
120
  export declare function createSetupCommand(deps?: InitDeps): Command;
142
- /**
143
- * Hidden, deprecated `init` alias → runs `setup`. Kept so existing scripts and
144
- * agents trained on the old command keep working; registered with
145
- * `{ hidden: true }` in index.ts (invisible to `--help`) and prints a
146
- * deprecation notice. (Setup consolidation.)
147
- */
148
- export declare function createDeprecatedInitCommand(deps?: InitDeps): Command;
149
- /**
150
- * Entry for the hidden, deprecated `auth configure` alias. Per the setup
151
- * consolidation, `auth configure` now runs FULL setup (configure + install)
152
- * so an agent that reaches for the old command still ends up with the skill.
153
- * `setup` is the ONLY path that writes credentials.
154
- *
155
- * Accepts the SAME `SetupCmdOpts` shape `setup` does — the alias previously
156
- * only wired up `--from-env`, so README's "runs the full setup" claim didn't
157
- * hold: `--yes`/`--agent`/`--api-key`/`--force`/`--dir`/`--no-agent` were all
158
- * rejected as unknown options. `index.ts` attaches the full flag set via
159
- * `addSetupOptions` before wiring this action.
160
- */
161
- export declare function runConfigureViaSetup(command: Command, deps: InitDeps, cmdOpts: SetupCmdOpts): Promise<void>;
162
121
  export {};