@testsprite/testsprite-cli 0.3.0 → 0.5.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 (63) hide show
  1. package/README.md +55 -29
  2. package/dist/commands/agent.js +17 -6
  3. package/dist/commands/auth.d.ts +51 -0
  4. package/dist/commands/auth.js +46 -2
  5. package/dist/commands/completion.d.ts +36 -0
  6. package/dist/commands/completion.js +111 -0
  7. package/dist/commands/doctor.js +56 -16
  8. package/dist/commands/init.d.ts +32 -1
  9. package/dist/commands/init.js +40 -10
  10. package/dist/commands/project.d.ts +102 -4
  11. package/dist/commands/project.js +250 -47
  12. package/dist/commands/test.d.ts +253 -11
  13. package/dist/commands/test.js +1822 -390
  14. package/dist/commands/usage.d.ts +56 -17
  15. package/dist/commands/usage.js +144 -29
  16. package/dist/index.js +172 -29
  17. package/dist/lib/browser.d.ts +6 -0
  18. package/dist/lib/browser.js +54 -0
  19. package/dist/lib/bundle.d.ts +32 -31
  20. package/dist/lib/bundle.js +144 -84
  21. package/dist/lib/client-factory.d.ts +29 -0
  22. package/dist/lib/client-factory.js +49 -1
  23. package/dist/lib/config.js +7 -3
  24. package/dist/lib/credentials.d.ts +17 -1
  25. package/dist/lib/credentials.js +175 -16
  26. package/dist/lib/dry-run/samples.js +51 -1
  27. package/dist/lib/errors.d.ts +33 -1
  28. package/dist/lib/errors.js +110 -19
  29. package/dist/lib/failing-fe-resolver.d.ts +15 -0
  30. package/dist/lib/failing-fe-resolver.js +49 -1
  31. package/dist/lib/flaky.d.ts +12 -1
  32. package/dist/lib/flaky.js +7 -12
  33. package/dist/lib/gh-output.d.ts +62 -0
  34. package/dist/lib/gh-output.js +99 -0
  35. package/dist/lib/http.d.ts +86 -16
  36. package/dist/lib/http.js +181 -11
  37. package/dist/lib/interrupt.d.ts +65 -10
  38. package/dist/lib/interrupt.js +94 -9
  39. package/dist/lib/org-render.d.ts +52 -0
  40. package/dist/lib/org-render.js +59 -0
  41. package/dist/lib/poll.d.ts +11 -0
  42. package/dist/lib/poll.js +71 -6
  43. package/dist/lib/render-error.d.ts +14 -0
  44. package/dist/lib/render-error.js +30 -0
  45. package/dist/lib/response-schemas.d.ts +83 -0
  46. package/dist/lib/response-schemas.js +272 -0
  47. package/dist/lib/runs.types.d.ts +62 -8
  48. package/dist/lib/skill-nudge.d.ts +17 -0
  49. package/dist/lib/skill-nudge.js +19 -0
  50. package/dist/lib/telemetry.d.ts +90 -0
  51. package/dist/lib/telemetry.js +171 -0
  52. package/dist/lib/text-table.d.ts +14 -0
  53. package/dist/lib/text-table.js +45 -0
  54. package/dist/lib/v3-advisory.d.ts +22 -0
  55. package/dist/lib/v3-advisory.js +32 -0
  56. package/dist/lib/version-notice.d.ts +37 -0
  57. package/dist/lib/version-notice.js +87 -0
  58. package/dist/version.d.ts +1 -1
  59. package/dist/version.js +1 -1
  60. package/package.json +16 -5
  61. package/schemas/plan.schema.json +61 -0
  62. package/skills/testsprite-verify.codex.md +8 -2
  63. package/skills/testsprite-verify.skill.md +18 -7
@@ -5,6 +5,7 @@ import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../l
5
5
  import { ApiError } from '../lib/errors.js';
6
6
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
7
7
  import { assertNotLocal } from '../lib/target-url.js';
8
+ import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
8
9
  import { assertIdempotencyKey } from '../lib/validate.js';
9
10
  import { fetchSinglePage, paginate, validatePaginationFlags, } from '../lib/pagination.js';
10
11
  export async function runList(opts, deps = {}) {
@@ -14,6 +15,9 @@ export async function runList(opts, deps = {}) {
14
15
  startingToken: opts.startingToken,
15
16
  maxItems: opts.maxItems,
16
17
  });
18
+ if (opts.output === 'text') {
19
+ resolveTextColumns(opts.columns, PROJECT_LIST_COLUMNS);
20
+ }
17
21
  const client = makeClient(opts, deps);
18
22
  // When the user explicitly passed a page-size flag and did NOT ask
19
23
  // for --max-items, treat that as a "give me one page and the cursor"
@@ -30,7 +34,7 @@ export async function runList(opts, deps = {}) {
30
34
  }
31
35
  out.print(page, data => {
32
36
  const p = data;
33
- return renderProjectListText(p);
37
+ return renderProjectListText(p, { columns: opts.columns, noHeader: opts.noHeader });
34
38
  });
35
39
  return page;
36
40
  }
@@ -41,6 +45,10 @@ export async function runGet(opts, deps = {}) {
41
45
  out.print(project, data => renderProjectText(data));
42
46
  return project;
43
47
  }
48
+ /** Resolve the created project's id regardless of which field name the backend used. */
49
+ export function resolveCreatedProjectId(r) {
50
+ return r.projectId ?? r.id;
51
+ }
44
52
  export async function runCreate(opts, deps = {}) {
45
53
  const out = makeOutput(opts.output, deps);
46
54
  const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
@@ -60,8 +68,11 @@ export async function runCreate(opts, deps = {}) {
60
68
  if (opts.name.length > 200) {
61
69
  throw localValidationError('--name must be at most 200 characters');
62
70
  }
63
- if (opts.description !== undefined && opts.description.length > 2000) {
64
- throw localValidationError('--description must be at most 2000 characters');
71
+ // `--description` is not supported on projects — no project entity stores a
72
+ // description, and the backend rejects it with a 422. Fail fast client-side
73
+ // with an actionable message instead of a wasted round trip.
74
+ if (opts.description !== undefined) {
75
+ throw localValidationError('--description is not supported for projects; omit it (test-level descriptions are set on `test create`)');
65
76
  }
66
77
  // P2-7: guard --url against localhost/RFC1918/non-http(s) (same rules as
67
78
  // `test create --target-url`). Applies to both FE (required) and BE (optional).
@@ -83,7 +94,11 @@ export async function runCreate(opts, deps = {}) {
83
94
  (opts.output === 'json' || opts.verbose || opts.debug)) {
84
95
  stderr(`idempotency-key: ${idempotencyKey}`);
85
96
  }
97
+ // Teach both id field names — `projectId` is the field the
98
+ // live backend actually sends; `id` is kept so this sample still matches
99
+ // callers written against the pre-fix shape.
86
100
  const sample = {
101
+ projectId: 'p_dryrun_2026',
87
102
  id: 'p_dryrun_2026',
88
103
  type: opts.type,
89
104
  name: opts.name,
@@ -92,7 +107,7 @@ export async function runCreate(opts, deps = {}) {
92
107
  createdAt: '2026-05-16T00:00:00.000Z',
93
108
  updatedAt: '2026-05-16T00:00:00.000Z',
94
109
  };
95
- out.print(sample, data => renderProjectText(data));
110
+ out.print(sample, data => renderCreateProjectText(data));
96
111
  return sample;
97
112
  }
98
113
  // Resolve password: flag > file > none
@@ -108,19 +123,69 @@ export async function runCreate(opts, deps = {}) {
108
123
  type: opts.type,
109
124
  name: opts.name,
110
125
  ...(opts.targetUrl !== undefined ? { targetUrl: opts.targetUrl } : {}),
111
- ...(opts.description !== undefined ? { description: opts.description } : {}),
112
126
  ...(opts.username !== undefined ? { username: opts.username } : {}),
113
127
  ...(password !== undefined ? { password } : {}),
114
128
  ...(opts.instruction !== undefined ? { instruction: opts.instruction } : {}),
115
129
  };
116
130
  const client = makeClient(opts, deps);
117
- const created = await client.post('/projects', {
131
+ const rawCreated = await client.post('/projects', {
118
132
  body,
119
133
  headers: { 'idempotency-key': idempotencyKey },
120
134
  });
121
- out.print(created, data => renderProjectText(data));
135
+ // Normalize whichever id field name the backend actually
136
+ // sent onto BOTH `projectId` and `id`, so JSON consumers keyed on either
137
+ // name keep working regardless of which one the live response used.
138
+ const resolvedId = resolveCreatedProjectId(rawCreated);
139
+ const created = {
140
+ ...rawCreated,
141
+ ...(resolvedId !== undefined ? { projectId: resolvedId, id: resolvedId } : {}),
142
+ };
143
+ out.print(created, data => renderCreateProjectText(data));
144
+ // A backend project created without --url has no default environment URL.
145
+ // On the V3 execution path, the shared admission guard (`runProjectGuarded`
146
+ // -> `assertProjectEnvNotLocal`, called by every V3 run/rerun/batch entry
147
+ // point, including `backendRun`) rejects the FIRST run of any test in the
148
+ // project with 400 no-target-resolvable. On the V2 path (`cli-run.service.ts`
149
+ // -> `resolveRunPrereqsFE`), this URL resolution is frontend-only and is
150
+ // never applied to a backend run, so a V2-routed backend project without a
151
+ // URL runs fine — V2 is the only execution path live in production today
152
+ // (V3 is dev-only pending its own GA release), so the wording below is
153
+ // conditioned on V3 rather than stated as a universal consequence.
154
+ // `--url` is intentionally NOT made mandatory here (that would break the
155
+ // published --help contract: npm 0.4.0 already ships text saying the URL
156
+ // is frontend-only), so this stays advisory-only. The CLI does not call
157
+ // GET /me here to check the caller's actual v3Enabled routing before
158
+ // deciding whether to print this — an extra round-trip on every create is
159
+ // not worth it just to gate a hint — so it points the reader at `auth
160
+ // status` (which already renders the routing: v2|v3 line) instead.
161
+ // Emitted in EVERY output mode, including --output json: this goes to
162
+ // stderr, which never touches JSON stdout, so there is nothing to protect
163
+ // by suppressing it (unlike `emitV3RoutingAdvisory`, which withholds
164
+ // account-context advisory in JSON mode because a JSON caller can read
165
+ // `v3Enabled` directly instead — there is no equivalent structured signal
166
+ // for this one). And --output json is precisely the case that needs it
167
+ // most: a script or agent creating a project non-interactively has no one
168
+ // watching a terminal, so a silent dead-on-arrival project only surfaces
169
+ // later as an unexplained 400 on the first run. Same family as the C1
170
+ // `--target-url` advisory above (a flag/setup the caller just made has a
171
+ // structural consequence) rather than the routing-advisory family.
172
+ // Real path only — NOT duplicated into the dry-run branch above, because
173
+ // the remedy command below embeds the created project id, and under
174
+ // --dry-run that id is the canned `p_dryrun_2026` sample: emitting a
175
+ // live-looking fix-it command against a fake resource is exactly what the
176
+ // `dashboardUrl` convention (see CLAUDE.md) already decided to suppress.
177
+ if (opts.type === 'backend' && !opts.targetUrl) {
178
+ stderr(`[advisory] this backend project has no default environment URL. On the V3 execution ` +
179
+ `path (check with \`testsprite auth status\`), test runs are rejected with ` +
180
+ `no-target-resolvable until one is set. Fix: testsprite project update ` +
181
+ `${resolvedId ?? '<project-id>'} --url <url>`);
182
+ }
122
183
  return created;
123
184
  }
185
+ /** Resolve the updated project's id regardless of which field name the backend used. */
186
+ export function resolveUpdatedProjectId(r) {
187
+ return r.projectId ?? r.id;
188
+ }
124
189
  export async function runUpdate(opts, deps = {}) {
125
190
  const out = makeOutput(opts.output, deps);
126
191
  const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
@@ -164,7 +229,11 @@ export async function runUpdate(opts, deps = {}) {
164
229
  (opts.output === 'json' || opts.verbose || opts.debug)) {
165
230
  stderr(`idempotency-key: ${idempotencyKey}`);
166
231
  }
232
+ // Teach both id field names — `projectId` is the field the
233
+ // live backend actually sends; `id` is kept so this sample still matches
234
+ // callers written against the pre-fix shape.
167
235
  const sample = {
236
+ projectId: opts.projectId,
168
237
  id: opts.projectId,
169
238
  updatedFields: presentFieldNames,
170
239
  updatedAt: '2026-05-16T00:00:00.000Z',
@@ -191,13 +260,68 @@ export async function runUpdate(opts, deps = {}) {
191
260
  };
192
261
  const body = Object.fromEntries(Object.entries(bodyFields).filter(([, v]) => v !== undefined));
193
262
  const client = makeClient(opts, deps);
194
- const updated = await client.patch(`/projects/${encodeURIComponent(opts.projectId)}`, {
263
+ const rawUpdated = await client.patch(`/projects/${encodeURIComponent(opts.projectId)}`, {
195
264
  body,
196
265
  headers: { 'idempotency-key': idempotencyKey },
197
266
  });
267
+ // Normalize whichever id field name the backend actually
268
+ // sent onto BOTH `projectId` and `id`, so JSON consumers keyed on either
269
+ // name keep working regardless of which one the live response used.
270
+ const resolvedUpdatedId = resolveUpdatedProjectId(rawUpdated);
271
+ const updated = {
272
+ ...rawUpdated,
273
+ ...(resolvedUpdatedId !== undefined
274
+ ? { projectId: resolvedUpdatedId, id: resolvedUpdatedId }
275
+ : {}),
276
+ };
198
277
  out.print(updated, data => renderUpdateText(data));
199
278
  return updated;
200
279
  }
280
+ /**
281
+ * `project delete <project-id> --confirm` — permanent cascade delete via
282
+ * DELETE /projects/{id}.
283
+ *
284
+ * The server deletes the project together with everything under it — its
285
+ * frontend/backend sub-projects, all their tests, and backend fixtures —
286
+ * matching the Portal's own delete behavior. There is no restore window.
287
+ *
288
+ * **`--confirm` is required** (unless `--dry-run`). Without either, the CLI
289
+ * exits 5 `VALIDATION_ERROR` with a typed envelope explaining the convention.
290
+ * The CLI never prompts interactively (CI-friendly contract). Re-delete on an already-deleted (or missing) project returns 404 from
291
+ * the server; the CLI surfaces the envelope as-is (exit 4), no client branching.
292
+ */
293
+ export async function runDelete(opts, deps = {}) {
294
+ assertIdempotencyKey(opts.idempotencyKey);
295
+ if (opts.projectId === undefined || opts.projectId.trim().length === 0) {
296
+ throw localValidationError('<project-id> is required');
297
+ }
298
+ if (!opts.confirm && !opts.dryRun) {
299
+ throw ApiError.fromEnvelope({
300
+ error: {
301
+ code: 'VALIDATION_ERROR',
302
+ message: 'Refusing to delete without --confirm.',
303
+ nextAction: 'This permanently deletes the project and everything under it — its ' +
304
+ 'sub-projects, all their tests, and backend fixtures (no restore window). ' +
305
+ 'The CLI convention is explicit confirmation for destructive operations. ' +
306
+ 'Re-run with --confirm. (--dry-run also works without --confirm.)',
307
+ requestId: 'local',
308
+ details: { field: 'confirm', reason: 'required for destructive operation' },
309
+ },
310
+ });
311
+ }
312
+ const idempotencyKey = opts.idempotencyKey ?? `cli-delete-${randomUUID()}`;
313
+ if (opts.idempotencyKey === undefined && (opts.output === 'json' || opts.verbose || opts.debug)) {
314
+ const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
315
+ stderr(`idempotency-key: ${idempotencyKey}`);
316
+ }
317
+ const client = makeClient(opts, deps);
318
+ const out = makeOutput(opts.output, deps);
319
+ const response = await client.delete(`/projects/${encodeURIComponent(opts.projectId)}`, {
320
+ headers: { 'idempotency-key': idempotencyKey },
321
+ });
322
+ out.print(response, data => renderDeleteText(data));
323
+ return response;
324
+ }
201
325
  // ---------------------------------------------------------------------------
202
326
  // project credential — set the static backend credential
203
327
  // ---------------------------------------------------------------------------
@@ -341,6 +465,8 @@ export function createProjectCommand(deps = {}) {
341
465
  .option('--page-size <n>', 'service page-size hint (1-100, default 25)')
342
466
  .option('--starting-token <token>', 'opaque cursor from a previous list response')
343
467
  .option('--max-items <n>', 'stop after this many items across auto-paged pages')
468
+ .option('--columns <list>', 'select/reorder text table columns (comma-separated keys)')
469
+ .option('--no-header', 'suppress the text table header row')
344
470
  .addHelpText('after', GLOBAL_OPTS_HINT)
345
471
  .action(async (cmdOpts, command) => {
346
472
  // Don't parse numeric flags via Commander — its parser throws a
@@ -353,6 +479,8 @@ export function createProjectCommand(deps = {}) {
353
479
  pageSize: parseFlag(cmdOpts.pageSize, 'page-size'),
354
480
  startingToken: cmdOpts.startingToken,
355
481
  maxItems: parseFlag(cmdOpts.maxItems, 'max-items'),
482
+ columns: cmdOpts.columns,
483
+ noHeader: cmdOpts.header === false,
356
484
  }, deps);
357
485
  });
358
486
  project
@@ -367,8 +495,9 @@ export function createProjectCommand(deps = {}) {
367
495
  .description('Create a new project')
368
496
  .option('--type <frontend|backend>', 'project type (required)')
369
497
  .option('--name <name>', 'project name (required)')
370
- .option('--url <url>', 'target URL (required for frontend)')
371
- .option('--description <text>', 'optional human description')
498
+ .option('--url <url>', 'target URL (required for frontend; also required for backend on the V3 execution ' +
499
+ 'path — see `auth status` for your routing)')
500
+ .option('--description <text>', 'not supported — projects have no description (test-level descriptions are set on `test create`)')
372
501
  .option('--username <user>', 'optional auth username')
373
502
  .option('--password <pw>', 'optional auth password (use --password-file for non-interactive)')
374
503
  .option('--password-file <path>', 'read password from file instead of inline flag')
@@ -424,6 +553,26 @@ export function createProjectCommand(deps = {}) {
424
553
  idempotencyKey: cmdOpts.idempotencyKey,
425
554
  }, deps);
426
555
  });
556
+ project
557
+ .command('delete <project-id>')
558
+ .description('Permanently delete a project and everything under it (sub-projects,\n' +
559
+ 'their tests, and backend fixtures). Requires --confirm.\n' +
560
+ '\nExit codes:\n' +
561
+ ' 0 success\n' +
562
+ ' 3 auth error\n' +
563
+ ' 4 project not found (or already deleted)\n' +
564
+ ' 5 validation error (e.g., missing --confirm)')
565
+ .option('--confirm', 'required: explicit confirmation for the destructive operation', false)
566
+ .option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
567
+ .addHelpText('after', GLOBAL_OPTS_HINT)
568
+ .action(async (projectId, cmdOpts, command) => {
569
+ await runDelete({
570
+ ...resolveCommonOptions(command),
571
+ projectId,
572
+ confirm: cmdOpts.confirm === true,
573
+ idempotencyKey: cmdOpts.idempotencyKey,
574
+ }, deps);
575
+ });
427
576
  project
428
577
  .command('credential <project-id>')
429
578
  .description('Set the static backend credential injected into every backend test\n' +
@@ -542,63 +691,117 @@ function makeClient(opts, deps) {
542
691
  function makeOutput(mode, deps) {
543
692
  return new Output(mode, { stdout: deps.stdout, stderr: deps.stderr });
544
693
  }
545
- function renderProjectListText(page) {
694
+ /**
695
+ * Master column set — includes ORG so `--columns` validation and explicit
696
+ * `--columns ...,org` selection both work regardless of whether any row in
697
+ * THIS response happens to carry org attribution. The default (no
698
+ * `--columns` flag) rendering uses {@link defaultProjectListColumns} instead,
699
+ * which drops ORG unless at least one row carries it — this keeps the table
700
+ * unchanged for legacy (non-org-scoped) callers.
701
+ */
702
+ const PROJECT_LIST_COLUMNS = [
703
+ {
704
+ header: 'ID',
705
+ width: rows => Math.max(2, ...rows.map(project => project.id.length)),
706
+ render: project => project.id,
707
+ },
708
+ {
709
+ header: 'NAME',
710
+ width: rows => Math.max(4, ...rows.map(project => project.name.length)),
711
+ render: project => project.name,
712
+ },
713
+ { header: 'TYPE', width: 8, render: project => project.type },
714
+ { header: 'FROM', width: 6, render: project => project.createdFrom },
715
+ {
716
+ header: 'ORG',
717
+ width: rows => Math.max(3, ...rows.map(project => (project.orgName ?? project.orgId ?? '').length)),
718
+ render: project => project.orgName ?? project.orgId ?? '',
719
+ },
720
+ { header: 'CREATED', width: 0, render: project => project.createdAt },
721
+ ];
722
+ const PROJECT_LIST_ORG_COLUMN = PROJECT_LIST_COLUMNS.find(c => c.header === 'ORG');
723
+ /**
724
+ * Default (no explicit `--columns`) column set. ORG is included only when
725
+ * at least one row in this page carries `orgId` — avoids widening the table
726
+ * for callers whose projects have no org attribution at all.
727
+ */
728
+ function defaultProjectListColumns(rows) {
729
+ const hasOrgInfo = rows.some(project => project.orgId !== undefined);
730
+ return hasOrgInfo
731
+ ? PROJECT_LIST_COLUMNS
732
+ : PROJECT_LIST_COLUMNS.filter(c => c !== PROJECT_LIST_ORG_COLUMN);
733
+ }
734
+ function renderProjectListText(page, options = {}) {
546
735
  if (page.items.length === 0) {
547
736
  return page.nextToken
548
737
  ? `No projects on this page.\nnextToken: ${page.nextToken}`
549
738
  : 'No projects.';
550
739
  }
551
- // Compact, AWS-CLI-grade columnar output. Column widths are computed
552
- // per-call so a single absurdly long project name doesn't push the
553
- // whole table off-screen.
554
- const idWidth = Math.max(2, ...page.items.map(p => p.id.length));
555
- const nameWidth = Math.max(4, ...page.items.map(p => p.name.length));
556
- const typeWidth = 8;
557
- const fromWidth = 6;
558
- const header = pad('ID', idWidth) +
559
- ' ' +
560
- pad('NAME', nameWidth) +
561
- ' ' +
562
- pad('TYPE', typeWidth) +
563
- ' ' +
564
- pad('FROM', fromWidth) +
565
- ' ' +
566
- 'CREATED';
567
- const rows = page.items.map(p => pad(p.id, idWidth) +
568
- ' ' +
569
- pad(p.name, nameWidth) +
570
- ' ' +
571
- pad(p.type, typeWidth) +
572
- ' ' +
573
- pad(p.createdFrom, fromWidth) +
574
- ' ' +
575
- p.createdAt);
576
- const lines = [header, ...rows];
740
+ // Explicit --columns: resolve against the FULL master set (so `org` can be
741
+ // requested even when this page happens to have no org-scoped rows).
742
+ // Default: only include ORG when the data actually carries it.
743
+ const columns = options.columns !== undefined ? PROJECT_LIST_COLUMNS : defaultProjectListColumns(page.items);
744
+ const lines = [
745
+ renderTextTable(page.items, columns, {
746
+ columns: options.columns,
747
+ noHeader: options.noHeader,
748
+ }),
749
+ ];
577
750
  if (page.nextToken)
578
751
  lines.push('', `nextToken: ${page.nextToken}`);
579
752
  return lines.join('\n');
580
753
  }
581
754
  function renderProjectText(p) {
582
- return [
755
+ const lines = [
583
756
  `id: ${p.id}`,
584
757
  `name: ${p.name}`,
585
758
  `type: ${p.type}`,
586
759
  `createdFrom: ${p.createdFrom}`,
587
760
  `createdAt: ${p.createdAt}`,
588
761
  `updatedAt: ${p.updatedAt}`,
589
- ].join('\n');
762
+ ];
763
+ if (p.orgId !== undefined) {
764
+ lines.push(`org: ${p.orgName ?? '(name unknown)'} (${p.orgId})`);
765
+ }
766
+ // Presence, not truthiness — see the `targetUrl` docstring on `CliProject`.
767
+ // `'targetUrl' in p` distinguishes "the backend answered 'no URL'" (render the
768
+ // hint) from "this endpoint doesn't report it" (say nothing).
769
+ if ('targetUrl' in p) {
770
+ lines.push(p.targetUrl
771
+ ? `targetUrl: ${p.targetUrl}`
772
+ : `targetUrl: (not set — set one with: testsprite project update ${p.id} --url <url>)`);
773
+ }
774
+ return lines.join('\n');
590
775
  }
591
- function pad(s, width) {
592
- if (s.length >= width)
593
- return s;
594
- return s + ' '.repeat(width - s.length);
776
+ /**
777
+ * `project create`'s text renderer. Distinct from
778
+ * `renderProjectText` (used by `project get`/`list`, where the live `id`
779
+ * field is proven reliable) because the create response's id field name and
780
+ * `updatedAt` presence are not guaranteed — see `CliCreateProjectResponse`.
781
+ */
782
+ function renderCreateProjectText(p) {
783
+ const lines = [
784
+ `id: ${resolveCreatedProjectId(p) ?? '(unknown)'}`,
785
+ `name: ${p.name}`,
786
+ `type: ${p.type}`,
787
+ `createdFrom: ${p.createdFrom}`,
788
+ `createdAt: ${p.createdAt}`,
789
+ ];
790
+ if (p.updatedAt !== undefined)
791
+ lines.push(`updatedAt: ${p.updatedAt}`);
792
+ return lines.join('\n');
595
793
  }
596
794
  function renderUpdateText(r) {
597
- return [
598
- `id: ${r.id}`,
795
+ const lines = [
796
+ `id: ${resolveUpdatedProjectId(r) ?? '(unknown)'}`,
599
797
  `updatedFields: ${r.updatedFields?.join(', ') ?? '(none)'}`,
600
- `updatedAt: ${r.updatedAt}`,
601
- ].join('\n');
798
+ ];
799
+ if (r.updatedAt !== undefined)
800
+ lines.push(`updatedAt: ${r.updatedAt}`);
801
+ return lines.join('\n');
802
+ }
803
+ function renderDeleteText(r) {
804
+ return [`projectId ${r.projectId}`, `deletedAt ${r.deletedAt}`].join('\n');
602
805
  }
603
806
  function localValidationError(message) {
604
807
  return ApiError.fromEnvelope({