@argos-ci/cli 6.11.0 → 6.12.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 (2) hide show
  1. package/dist/index.mjs +366 -284
  2. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -10,11 +10,11 @@ import { createWriteStream } from "node:fs";
10
10
  import { Readable } from "node:stream";
11
11
  import { pipeline } from "node:stream/promises";
12
12
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
13
- import { homedir } from "node:os";
14
13
  import { createHash, randomBytes } from "node:crypto";
14
+ import { homedir } from "node:os";
15
15
  import { createServer } from "node:http";
16
16
  import open from "open";
17
- //#region src/lib/cli-error.ts
17
+ // src/lib/cli-error.ts
18
18
  /**
19
19
  * Error whose message is meant to be shown to the user verbatim (prefixed with
20
20
  * `Error: `) before the CLI exits with a non-zero code. Throw it — via
@@ -33,37 +33,46 @@ var CliError = class extends Error {
33
33
  function fail(message) {
34
34
  throw new CliError(message);
35
35
  }
36
- //#endregion
37
- //#region src/options.ts
36
+ // src/options.ts
38
37
  const parallelNonceOption = new Option("--parallel-nonce <string>", "A unique ID for this parallel build");
39
38
  const tokenOption = new Option("--token <token>", "Repository token");
40
- const projectOption = new Option("--project <slug>", "Argos project slug (account/project), used to disambiguate tokenless authentication when multiple projects are linked to the same repository");
39
+ const projectOption = new Option("--project <slug>", "Project in owner/project format. Also ARGOS_PROJECT. Required when the token is linked to several projects; also disambiguates tokenless authentication when several projects are linked to the same repository");
41
40
  const buildNameOption = new Option("--build-name <string>", "Name of the build, in case you want to run multiple Argos builds in a single CI job");
42
41
  const accountOption = new Option("--account <slug>", "Slug of the account (personal or team) that will own the project");
43
42
  const accountSlugOption = new Option("--account <slug>", "Slug of the account (personal or team) to act on. Also ARGOS_ACCOUNT");
44
43
  const jsonOption = new Option("--json", "Output machine-readable JSON instead of human-readable text");
45
44
  const projectPathOption = new Option("--project <owner/project>", "Project path in owner/project format. Required for build-number references on review and comment commands");
46
45
  const changeProjectPathOption = new Option("--project <owner/project>", "Project the change belongs to, in owner/project format. Also ARGOS_PROJECT");
47
- const testProjectPathOption = new Option("--project <owner/project>", "Project the test belongs to, in owner/project format. Also ARGOS_PROJECT. Optional with a project token, which already identifies its project");
48
- const buildProjectPathOption = new Option("--project <owner/project>", "Project the builds belong to, in owner/project format. Also ARGOS_PROJECT. Optional with a project token, which already identifies its project");
49
- const mediaProjectPathOption = new Option("--project <owner/project>", "Project the media belongs to, in owner/project format. Also ARGOS_PROJECT. Optional with a project token, which already identifies its project");
46
+ const testProjectPathOption = new Option("--project <owner/project>", "Project the test belongs to, in owner/project format. Also ARGOS_PROJECT. Optional with a project token linked to a single project, which already identifies it");
47
+ const buildProjectPathOption = new Option("--project <owner/project>", "Project the builds belong to, in owner/project format. Also ARGOS_PROJECT. Optional with a project token linked to a single project, which already identifies it");
48
+ const mediaProjectPathOption = new Option("--project <owner/project>", "Project the media belongs to, in owner/project format. Also ARGOS_PROJECT. Optional with a project token linked to a single project, which already identifies it");
50
49
  const managedProjectPathOption = new Option("--project <owner/project>", "Project to act on, in owner/project format. Also ARGOS_PROJECT");
51
50
  const limitOption = new Option("--limit <number>", "Maximum number of items to fetch, following pagination as needed").default(String(100));
51
+ const DAY_MS = 864e5;
52
+ /** Parse the value of `--<option>` into a positive integer, or abort. */
53
+ function toPositiveInteger(value, option) {
54
+ const number = Number(value);
55
+ if (!Number.isInteger(number) || number < 1) fail(`--${option} must be a positive integer, received "${value}".`);
56
+ return number;
57
+ }
58
+ /** Coerce the value of `--<option>` into an ISO 8601 datetime, or abort. */
59
+ function toIsoOrFail(value, option) {
60
+ const date = new Date(value);
61
+ if (Number.isNaN(date.getTime())) fail(`Invalid --${option} value: "${value}". Use an ISO 8601 datetime.`);
62
+ return date.toISOString();
63
+ }
52
64
  /**
53
65
  * Parse a `--limit` value into a positive integer, or abort. Pass `max` when
54
66
  * the source caps how many items it can return.
55
67
  */
56
- function toLimit(value, { max = Infinity } = {}) {
57
- const limit = Number(value);
58
- if (!Number.isInteger(limit) || limit < 1) fail(`--limit must be a positive integer, received "${value}".`);
68
+ function toLimit(value, { max = 1e400 } = {}) {
69
+ const limit = toPositiveInteger(value, "limit");
59
70
  if (limit > max) fail(`--limit must be at most ${max}, received "${value}".`);
60
71
  return limit;
61
72
  }
62
73
  /** Parse a `--pr` value into a pull request number, or abort. */
63
74
  function toPrNumber(value) {
64
- const prNumber = Number(value);
65
- if (!Number.isInteger(prNumber) || prNumber < 1) fail(`--pr must be a positive integer, received "${value}".`);
66
- return prNumber;
75
+ return toPositiveInteger(value, "pr");
67
76
  }
68
77
  const METRICS_PERIOD_BY_CHOICE = {
69
78
  "24h": "LAST_24_HOURS",
@@ -77,8 +86,7 @@ const metricsPeriodOption = new Option("--metrics-period <period>", "Window over
77
86
  function toMetricsPeriod(choice) {
78
87
  return METRICS_PERIOD_BY_CHOICE[choice] ?? "LAST_7_DAYS";
79
88
  }
80
- //#endregion
81
- //#region src/commands/upload.ts
89
+ // src/commands/upload.ts
82
90
  function uploadCommand(program) {
83
91
  program.command("upload").argument("<directory>", "Directory to upload").description("Upload screenshots to Argos").option("-f, --files <patterns...>", "One or more globs matching image file paths to upload", "**/*.{png,jpg,jpeg}").option("-i, --ignore <patterns...>", "One or more globs matching image file paths to ignore (ex: \"**/*.png **/diff.jpg\")").addOption(tokenOption).addOption(projectOption).addOption(buildNameOption).addOption(new Option("--mode <string>", "Mode of comparison applied. CI for visual regression testing, monitoring for visual monitoring.").default("ci").choices(["ci", "monitoring"])).addOption(new Option("--parallel", "Enable parallel mode. Run multiple Argos builds and combine them at the end.\nCan also be set via the ARGOS_PARALLEL environment variable.")).addOption(new Option("--parallel-total <number>", "The number of parallel nodes being ran")).addOption(parallelNonceOption).addOption(new Option("--parallel-index <number>", "The index of the parallel node being ran (must be at least 1)")).addOption(new Option("--reference-branch <string>", "Branch used as baseline for screenshot comparison")).addOption(new Option("--reference-commit <string>", "Commit used as baseline for screenshot comparison")).addOption(new Option("--threshold <number>", "Sensitivity threshold between 0 and 1. The higher the threshold, the less sensitive the diff will be. Default to 0.5")).addOption(new Option("--subset", "Whether this build contains only a subset of screenshots.\nThis is useful when a build is created from an incomplete test suite where some tests are skipped.\nCan also be set via the ARGOS_SUBSET environment variable.")).action(async (directory, options) => {
84
92
  const spinner = ora("Uploading screenshots").start();
@@ -123,15 +131,15 @@ function uploadCommand(program) {
123
131
  }
124
132
  });
125
133
  }
126
- //#endregion
127
- //#region src/commands/finalize.ts
134
+ // src/commands/finalize.ts
128
135
  const skipIfEmptyOption = new Option("--skip-if-empty", "Create a skipped build when no parallel build matches the nonce.\nUseful when uploads are conditional (e.g. skipped by a CI cache) and Argos is a required status check: the skipped build reports a success status even though nothing was uploaded.");
129
136
  function finalizeCommand(program) {
130
- program.command("finalize").description("Finalize pending parallel builds").addOption(parallelNonceOption).addOption(tokenOption).addOption(skipIfEmptyOption).addOption(buildNameOption).action(async (options) => {
137
+ program.command("finalize").description("Finalize pending parallel builds").addOption(parallelNonceOption).addOption(tokenOption).addOption(projectOption).addOption(skipIfEmptyOption).addOption(buildNameOption).action(async (options) => {
131
138
  const spinner = ora("Finalizing builds").start();
132
139
  try {
133
140
  const result = await finalize({
134
141
  token: options.token,
142
+ project: options.project,
135
143
  parallel: options.parallelNonce ? { nonce: options.parallelNonce } : void 0,
136
144
  skipIfEmpty: options.skipIfEmpty,
137
145
  buildName: options.buildName
@@ -146,14 +154,14 @@ function finalizeCommand(program) {
146
154
  }
147
155
  });
148
156
  }
149
- //#endregion
150
- //#region src/commands/skip.ts
157
+ // src/commands/skip.ts
151
158
  function skipCommand(program) {
152
- program.command("skip").description("Mark a build as skipped").addOption(tokenOption).addOption(buildNameOption).action(async (options) => {
159
+ program.command("skip").description("Mark a build as skipped").addOption(tokenOption).addOption(projectOption).addOption(buildNameOption).action(async (options) => {
153
160
  const spinner = ora("Creating skipped build").start();
154
161
  try {
155
162
  const result = await skip({
156
163
  token: options.token,
164
+ project: options.project,
157
165
  buildName: options.buildName
158
166
  });
159
167
  spinner.succeed(`Build created: ${result.build.url}`);
@@ -166,8 +174,7 @@ function skipCommand(program) {
166
174
  }
167
175
  });
168
176
  }
169
- //#endregion
170
- //#region src/lib/user-agent.ts
177
+ // src/lib/user-agent.ts
171
178
  /**
172
179
  * The `User-Agent` the CLI sends on every API request.
173
180
  *
@@ -226,8 +233,7 @@ async function initUserAgent(version) {
226
233
  function getUserAgent() {
227
234
  return userAgent;
228
235
  }
229
- //#endregion
230
- //#region src/lib/api.ts
236
+ // src/lib/api.ts
231
237
  /** Optional override for the API base URL (used in tests and dev). */
232
238
  function getApiBaseUrl() {
233
239
  return process.env["ARGOS_API_BASE_URL"];
@@ -256,8 +262,7 @@ function unwrap(result) {
256
262
  function unwrapEmpty(result) {
257
263
  if (!result.response.ok) throwAPIError(result.error, result.response);
258
264
  }
259
- //#endregion
260
- //#region src/lib/build.ts
265
+ // src/lib/build.ts
261
266
  const PER_PAGE$1 = 100;
262
267
  /** Whether Argos is still processing the build, so its diffs are not final. */
263
268
  function isBuildPending(build) {
@@ -294,8 +299,7 @@ async function fetchAllDiffs(target, options = {}) {
294
299
  }
295
300
  return results;
296
301
  }
297
- //#endregion
298
- //#region src/lib/download.ts
302
+ // src/lib/download.ts
299
303
  /** Files downloaded at the same time. */
300
304
  const CONCURRENCY = 8;
301
305
  /** Attempts per file before giving up, for failures that may not last. */
@@ -455,8 +459,7 @@ async function downloadBuildSnapshots(args) {
455
459
  spinner?.stop();
456
460
  }
457
461
  }
458
- //#endregion
459
- //#region src/lib/terminal.ts
462
+ // src/lib/terminal.ts
460
463
  /**
461
464
  * Printing text the CLI did not author — an OAuth error description chosen by
462
465
  * the authorization server, for instance.
@@ -504,8 +507,7 @@ function sanitizeTerminalText(text) {
504
507
  const sanitized = String(text).replace(ESCAPE_SEQUENCE_REGEX, "").replace(DIRECTIONAL_FORMATTING_REGEX, "").replace(CONTROL_CHARACTER_REGEX, " ").replace(/\s+/g, " ").trim();
505
508
  return sanitized.length > MAX_LENGTH ? `${sanitized.slice(0, MAX_LENGTH)}…` : sanitized;
506
509
  }
507
- //#endregion
508
- //#region src/lib/format.ts
510
+ // src/lib/format.ts
509
511
  /** Render a scalar, using `-` for empty values. */
510
512
  function formatValue(value) {
511
513
  if (value === null || value === void 0 || value === "") return "-";
@@ -541,7 +543,7 @@ function formatProject(project) {
541
543
  `ID: ${project.id}`,
542
544
  `Visibility: ${project.private ? "private" : "public"}`,
543
545
  `Default base branch: ${formatValue(project.defaultBaseBranch)}`,
544
- `Auto-approved branches: ${formatValue(project.autoApprovedBranchGlob)}`,
546
+ `Auto-approved branches: ${project.autoApprovalEnabled ? formatValue(project.autoApprovedBranchGlob) : "none"}`,
545
547
  `Summary check: ${project.summaryCheck}`,
546
548
  `PR comment: ${formatBoolean(project.prCommentEnabled)}`,
547
549
  `Default user level: ${formatValue(project.defaultUserLevel)}`,
@@ -895,6 +897,42 @@ function formatDeployments(deployments) {
895
897
  function formatProjectDomain(domain) {
896
898
  return `Deployment domain: ${formatValue(domain.domain)}`;
897
899
  }
900
+ function formatTokenExpiration(expireAt) {
901
+ if (!expireAt) return "never";
902
+ return Date.parse(expireAt) <= Date.now() ? `${expireAt} (expired)` : expireAt;
903
+ }
904
+ /** The details of a project token, under its title line. */
905
+ function formatProjectTokenDetails(token) {
906
+ return [
907
+ ` Projects: ${formatValue(token.projects.join(", "))}`,
908
+ ` Permissions: ${token.permissions.join(", ")}`,
909
+ ` Created: ${token.createdAt}`,
910
+ ` Expires: ${formatTokenExpiration(token.expireAt)}`,
911
+ ` Last used: ${token.lastUsedAt ?? "never"}`
912
+ ];
913
+ }
914
+ function formatProjectTokens(tokens) {
915
+ if (tokens.length === 0) return "No tokens found.";
916
+ return [
917
+ `Tokens (${tokens.length})`,
918
+ "",
919
+ ...tokens.flatMap((token) => [
920
+ `${sanitizeTerminalText(token.name)} · ${token.id}`,
921
+ ...formatProjectTokenDetails(token),
922
+ ""
923
+ ])
924
+ ].slice(0, -1).join("\n");
925
+ }
926
+ function formatCreatedProjectToken(token) {
927
+ return [
928
+ `Created token ${sanitizeTerminalText(token.name)} · ${token.id}`,
929
+ ...formatProjectTokenDetails(token),
930
+ "",
931
+ token.token,
932
+ "",
933
+ "Save this token now: Argos does not store it and will not show it again."
934
+ ].join("\n");
935
+ }
898
936
  function formatIgnoredChanges(changes) {
899
937
  if (changes.length === 0) return "No ignored changes found.";
900
938
  return [
@@ -1058,8 +1096,7 @@ function formatDocsSearchResults(results, query) {
1058
1096
  ""
1059
1097
  ]).filter((line) => line !== null).slice(0, -1).join("\n");
1060
1098
  }
1061
- //#endregion
1062
- //#region src/lib/oauth.ts
1099
+ // src/lib/oauth.ts
1063
1100
  /**
1064
1101
  * OAuth 2.1 client configuration and helpers for the `argos login` flow
1065
1102
  * (Authorization Code + PKCE with a loopback redirect, RFC 8252).
@@ -1071,7 +1108,8 @@ function formatDocsSearchResults(results, query) {
1071
1108
  const OAUTH_CLIENT_ID = "argos-cli";
1072
1109
  /**
1073
1110
  * Scopes requested by `argos login`, covering the CLI's user actions (identity,
1074
- * projects, reviews, comments, media). Build upload keeps using a project token.
1111
+ * projects, reviews, comments, media, team administration). Build upload keeps
1112
+ * using a project token.
1075
1113
  *
1076
1114
  * Every scope a CLI command needs has to be listed here: the consent screen
1077
1115
  * only offers what the client asks for, so a missing entry is not something the
@@ -1085,8 +1123,19 @@ const OAUTH_SCOPES = [
1085
1123
  "comments:read",
1086
1124
  "comments:write",
1087
1125
  "media:read",
1088
- "media:write"
1126
+ "media:write",
1127
+ "account:admin"
1089
1128
  ];
1129
+ /**
1130
+ * Requested scopes that the consent screen grants only with "Admin" access
1131
+ * (`level: "admin"` in the Argos backend's `apps/backend/src/oauth/scopes.ts`).
1132
+ * The default, "Read and write", leaves them out, so a session can lack them
1133
+ * even when it was granted after the CLI started asking for them.
1134
+ */
1135
+ const OAUTH_ADMIN_SCOPES = /* @__PURE__ */ new Set(["projects:write", "account:admin"]);
1136
+ function isRequestedOAuthScope(value) {
1137
+ return OAUTH_SCOPES.includes(value);
1138
+ }
1090
1139
  /** Refresh a bit early so a token never expires mid-request. */
1091
1140
  const EXPIRY_SKEW_MS = 6e4;
1092
1141
  function getAppBaseUrl() {
@@ -1176,8 +1225,7 @@ async function revokeToken(token) {
1176
1225
  }).toString()
1177
1226
  }).catch(() => {});
1178
1227
  }
1179
- //#endregion
1180
- //#region src/auth.ts
1228
+ // src/auth.ts
1181
1229
  function getConfigPaths() {
1182
1230
  const configDir = resolve(homedir(), ".config", "argos-ci");
1183
1231
  return {
@@ -1278,8 +1326,7 @@ async function getStoredCredentials() {
1278
1326
  async function clearStoredCredentials() {
1279
1327
  await writeConfig({});
1280
1328
  }
1281
- //#endregion
1282
- //#region src/lib/build-reference.ts
1329
+ // src/lib/build-reference.ts
1283
1330
  const BUILD_URL_REGEXP = /^https:\/\/app\.argos-ci\.(?:com|dev(?::\d+)?)\/(?<owner>[^/?#]+)\/(?<project>[^/?#]+)\/builds\/(?<buildNumber>\d+)(?:[/?#]|$)/;
1284
1331
  /**
1285
1332
  * Parse a build reference, accepting either a bare build number (`"1234"`) or a
@@ -1305,8 +1352,7 @@ function parseBuildReferenceOrFail(reference) {
1305
1352
  if (!parsed) fail(`Build reference must be a valid build number or Argos build URL (https://app.argos-ci.com/.../builds/<number>), got "${reference}".`);
1306
1353
  return parsed;
1307
1354
  }
1308
- //#endregion
1309
- //#region src/lib/project.ts
1355
+ // src/lib/project.ts
1310
1356
  /**
1311
1357
  * Parse a `owner/project` slug. Returns `null` when it is not exactly two
1312
1358
  * non-empty segments.
@@ -1327,8 +1373,7 @@ function parseProjectPathOrFail(slug) {
1327
1373
  if (!parsed) fail("--project must be in the format 'owner/project'.");
1328
1374
  return parsed;
1329
1375
  }
1330
- //#endregion
1331
- //#region src/lib/target.ts
1376
+ // src/lib/target.ts
1332
1377
  /**
1333
1378
  * Resolve the API token if there is one, preferring an explicit token
1334
1379
  * (`--token` / `ARGOS_TOKEN`) over the one stored by `argos login`.
@@ -1349,14 +1394,20 @@ async function resolveToken(options) {
1349
1394
  if (!token) fail("No Argos token found. Use --token, set ARGOS_TOKEN, or run `argos login`.");
1350
1395
  return token;
1351
1396
  }
1397
+ /**
1398
+ * The project named by `--project` or the `ARGOS_PROJECT` environment variable,
1399
+ * or `null` when neither is set. Aborts on a value that is not `owner/project`.
1400
+ */
1401
+ function resolveProjectPath(options) {
1402
+ const slug = options.project || process.env["ARGOS_PROJECT"];
1403
+ return slug ? parseProjectPathOrFail(slug) : null;
1404
+ }
1352
1405
  function explicitProjectPath(reference, options) {
1353
1406
  if (reference.owner && reference.project) return {
1354
1407
  owner: reference.owner,
1355
1408
  project: reference.project
1356
1409
  };
1357
- const project = options.project || process.env["ARGOS_PROJECT"];
1358
- if (project) return parseProjectPathOrFail(project);
1359
- return null;
1410
+ return resolveProjectPath(options);
1360
1411
  }
1361
1412
  /**
1362
1413
  * Resolve a build reference into a ready-to-use {@link BuildTarget}: an
@@ -1402,10 +1453,10 @@ async function resolveBuildTarget(reference, options, { auth }) {
1402
1453
  */
1403
1454
  async function resolveProjectTarget(options, { auth }) {
1404
1455
  const client = createApiClient(await resolveToken(options));
1405
- const projectPath = options.project || process.env["ARGOS_PROJECT"];
1456
+ const projectPath = resolveProjectPath(options);
1406
1457
  if (projectPath) return {
1407
1458
  client,
1408
- ...parseProjectPathOrFail(projectPath)
1459
+ ...projectPath
1409
1460
  };
1410
1461
  if (auth === "user") fail("--project <owner/project> is required. Pass it or set ARGOS_PROJECT.");
1411
1462
  const project = unwrap(await client.GET("/project"));
@@ -1429,10 +1480,8 @@ async function resolveAccountTarget(options) {
1429
1480
  accountSlug
1430
1481
  };
1431
1482
  }
1432
- //#endregion
1433
- //#region src/lib/run.ts
1483
+ // src/lib/run.ts
1434
1484
  const USER_AUTH_HINT = "Ensure your token is a personal access token with access to this project. Project tokens (ARGOS_TOKEN in CI) can read build data but cannot perform review or comment actions.";
1435
- const SCOPE_HINT = "Your `argos login` session was granted before the CLI asked for this permission. Run `argos login` again to grant it.";
1436
1485
  /**
1437
1486
  * A scope rejection, as opposed to any other 403: the token is valid and the
1438
1487
  * user is allowed, it was simply issued without the permission this endpoint
@@ -1443,6 +1492,34 @@ function isInsufficientScope(error) {
1443
1492
  return error.status === 403 && /insufficient scope/i.test(error.message);
1444
1493
  }
1445
1494
  /**
1495
+ * The scopes named by a scope rejection ("Insufficient scope. This endpoint
1496
+ * requires: account:admin."). Anything not shaped like a scope is dropped, so
1497
+ * the hint never echoes arbitrary server text.
1498
+ */
1499
+ function parseRequiredScopes(message) {
1500
+ const match = /requires:\s*([^.]*)/i.exec(message);
1501
+ if (!match?.[1]) return [];
1502
+ return match[1].split(",").map((scope) => scope.trim()).filter((scope) => /^[a-z]+(?::[a-z]+)?$/.test(scope));
1503
+ }
1504
+ function formatScopes(scopes) {
1505
+ return scopes.map((scope) => `\`${scope}\``).join(", ");
1506
+ }
1507
+ /**
1508
+ * How to get the scopes an `argos login` session is missing. A session lacks a
1509
+ * scope for one of three reasons, each with its own fix: the CLI never asks for
1510
+ * it (only a personal access token helps), it is an admin scope left out by the
1511
+ * consent screen's default access level, or the session was granted before the
1512
+ * CLI asked for it.
1513
+ */
1514
+ function getScopeHint(message) {
1515
+ const required = parseRequiredScopes(message);
1516
+ if (required.length === 0) return "Run `argos login` again to grant the permission this command needs.";
1517
+ const ungrantable = required.filter((scope) => !isRequestedOAuthScope(scope));
1518
+ if (ungrantable.length > 0) return `\`argos login\` cannot grant ${formatScopes(ungrantable)}. Use a personal access token instead (\`--token\` or \`ARGOS_TOKEN\`).`;
1519
+ if (required.some((scope) => isRequestedOAuthScope(scope) && OAUTH_ADMIN_SCOPES.has(scope))) return `Your \`argos login\` session does not include ${formatScopes(required)}. Run \`argos login\` again and choose "Admin" access on the consent screen to grant it.`;
1520
+ return `Your \`argos login\` session does not include ${formatScopes(required)}. Run \`argos login\` again to grant it.`;
1521
+ }
1522
+ /**
1446
1523
  * Print an error and exit. {@link CliError} and {@link APIError} messages are
1447
1524
  * shown as-is; permission failures get an extra hint — how to grant a missing
1448
1525
  * scope, or which token type the command needs.
@@ -1451,7 +1528,7 @@ function handleCliError(error, auth) {
1451
1528
  let message;
1452
1529
  if (error instanceof CliError || error instanceof APIError) {
1453
1530
  message = error.message;
1454
- if (error instanceof APIError && isInsufficientScope(error)) message += `\n${SCOPE_HINT}`;
1531
+ if (error instanceof APIError && isInsufficientScope(error)) message += `\n${getScopeHint(error.message)}`;
1455
1532
  else if (auth === "user" && error instanceof APIError && (error.status === 401 || error.status === 403)) message += `\n${USER_AUTH_HINT}`;
1456
1533
  } else if (error instanceof Error) message = error.message;
1457
1534
  else message = String(error);
@@ -1474,8 +1551,7 @@ async function runBuildAction(opts) {
1474
1551
  handleCliError(error, opts.auth);
1475
1552
  }
1476
1553
  }
1477
- //#endregion
1478
- //#region src/commands/build/download.ts
1554
+ // src/commands/build/download.ts
1479
1555
  function registerBuildDownload(build) {
1480
1556
  build.command("download").description("Download the screenshots of a build to a directory, laid out by snapshot name").argument("<buildReference>", "Build number or Argos build URL").option("-o, --output <directory>", "Directory to write the screenshots to. Must be empty or not exist yet. Defaults to ./argos-build-<number>").addOption(tokenOption).addOption(buildProjectPathOption).addOption(jsonOption).action(async (reference, options) => {
1481
1557
  try {
@@ -1495,8 +1571,7 @@ function registerBuildDownload(build) {
1495
1571
  }
1496
1572
  });
1497
1573
  }
1498
- //#endregion
1499
- //#region src/commands/build/get.ts
1574
+ // src/commands/build/get.ts
1500
1575
  function registerBuildGet(build) {
1501
1576
  build.command("get").description("Fetch build metadata").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(jsonOption).action((reference, options) => runBuildAction({
1502
1577
  reference,
@@ -1510,8 +1585,7 @@ function registerBuildGet(build) {
1510
1585
  format: formatBuild
1511
1586
  }));
1512
1587
  }
1513
- //#endregion
1514
- //#region src/lib/pagination.ts
1588
+ // src/lib/pagination.ts
1515
1589
  /** Largest page the API serves. */
1516
1590
  const MAX_PER_PAGE = 100;
1517
1591
  /**
@@ -1534,8 +1608,7 @@ async function fetchPages(limit, fetchPage) {
1534
1608
  }
1535
1609
  return results.slice(0, limit);
1536
1610
  }
1537
- //#endregion
1538
- //#region src/commands/build/list.ts
1611
+ // src/commands/build/list.ts
1539
1612
  function registerBuildList(build) {
1540
1613
  build.command("list").description("List a project's builds, most recent first").option("--branch <name>", "Only list the builds of this branch").option("--commit <sha>", "Only list the builds of this commit, given as a full 40-character SHA. Use --search to match a prefix").option("--search <query>", "Match builds on their name, branch (substring) or commit (prefix)").addOption(limitOption).addOption(tokenOption).addOption(buildProjectPathOption).addOption(jsonOption).action(async (options) => {
1541
1614
  try {
@@ -1557,8 +1630,7 @@ function registerBuildList(build) {
1557
1630
  }
1558
1631
  });
1559
1632
  }
1560
- //#endregion
1561
- //#region src/commands/build/snapshots.ts
1633
+ // src/commands/build/snapshots.ts
1562
1634
  function registerBuildSnapshots(build) {
1563
1635
  build.command("snapshots").description("Fetch snapshot diffs for a build").argument("<buildReference>", "Build number or Argos build URL").addOption(new Option("--needs-review", "Only include snapshot diffs that require review")).addOption(metricsPeriodOption).addOption(tokenOption).addOption(jsonOption).action(async (reference, options) => {
1564
1636
  try {
@@ -1582,8 +1654,7 @@ function registerBuildSnapshots(build) {
1582
1654
  }
1583
1655
  });
1584
1656
  }
1585
- //#endregion
1586
- //#region src/commands/build/subscription.ts
1657
+ // src/commands/build/subscription.ts
1587
1658
  /** Register `build subscribe` / `build unsubscribe`; both act as a user. */
1588
1659
  function defineBuildSubscription(opts) {
1589
1660
  return (build) => {
@@ -1614,8 +1685,7 @@ const registerBuildUnsubscribe = defineBuildSubscription({
1614
1685
  buildNumber
1615
1686
  } } }))
1616
1687
  });
1617
- //#endregion
1618
- //#region src/commands/build/index.ts
1688
+ // src/commands/build/index.ts
1619
1689
  function buildCommand(program) {
1620
1690
  const build = program.command("build").description("Inspect and download Argos builds");
1621
1691
  registerBuildList(build);
@@ -1650,27 +1720,28 @@ async function findLatestBaseline(api, { maxPages = 10 } = {}) {
1650
1720
  }
1651
1721
  return null;
1652
1722
  }
1653
- //#endregion
1654
- //#region src/commands/baseline/download.ts
1723
+ // src/commands/baseline/download.ts
1655
1724
  const PROJECT_TOKEN_HINT = "Finding the baseline takes the project's token: pass it with --token or set ARGOS_TOKEN. The token stored by `argos login` cannot be used.";
1656
1725
  const FAILURE_STATUSES = /* @__PURE__ */ new Set(["failure", "retryFailure"]);
1657
- async function fetchTokenProject(client) {
1726
+ async function fetchTokenProject(client, project) {
1658
1727
  try {
1659
- return unwrap(await client.GET("/project"));
1728
+ return unwrap(await client.GET("/project", { params: { query: { project } } }));
1660
1729
  } catch (error) {
1661
1730
  if (error instanceof APIError && (error.status === 401 || error.status === 403)) fail(`${error.message}\n${PROJECT_TOKEN_HINT}`);
1662
1731
  throw error;
1663
1732
  }
1664
1733
  }
1665
1734
  function registerBaselineDownload(baseline) {
1666
- baseline.command("download").description("Download a project's latest baseline: the screenshots of the newest build of its default branch that Argos can use as a baseline").option("-o, --output <directory>", "Directory to write the screenshots to, laid out by snapshot name. Must be empty or not exist yet. Defaults to ./argos-baseline").option("--branch <name>", "Branch to take the baseline from. Defaults to the project's default base branch").addOption(new Option("--build-name <name>", "Name of the build to take the baseline of, as given to `argos upload --build-name`").default("default")).addOption(new Option("--mode <mode>", "Mode of the build to take the baseline of: ci for visual regression testing, monitoring for visual monitoring").choices(["ci", "monitoring"]).default("ci")).addOption(tokenOption).addOption(jsonOption).action(async (options) => {
1735
+ baseline.command("download").description("Download a project's latest baseline: the screenshots of the newest build of its default branch that Argos can use as a baseline").option("-o, --output <directory>", "Directory to write the screenshots to, laid out by snapshot name. Must be empty or not exist yet. Defaults to ./argos-baseline").option("--branch <name>", "Branch to take the baseline from. Defaults to the project's default base branch").addOption(new Option("--build-name <name>", "Name of the build to take the baseline of, as given to `argos upload --build-name`").default("default")).addOption(new Option("--mode <mode>", "Mode of the build to take the baseline of: ci for visual regression testing, monitoring for visual monitoring").choices(["ci", "monitoring"]).default("ci")).addOption(buildProjectPathOption).addOption(tokenOption).addOption(jsonOption).action(async (options) => {
1667
1736
  try {
1668
1737
  const directory = resolve(options.output ?? "argos-baseline");
1669
1738
  await assertEmptyDirectory(directory);
1670
1739
  const token = await resolveOptionalToken(options);
1671
1740
  if (!token) fail("No Argos token found. Pass the project's token with --token or set ARGOS_TOKEN.");
1672
1741
  const client = createApiClient(token);
1673
- const project = await fetchTokenProject(client);
1742
+ const projectPath = resolveProjectPath(options);
1743
+ const projectSlug = projectPath ? `${projectPath.owner}/${projectPath.project}` : void 0;
1744
+ const project = await fetchTokenProject(client, projectSlug);
1674
1745
  const path = {
1675
1746
  owner: project.account.slug,
1676
1747
  project: project.name
@@ -1686,6 +1757,7 @@ function registerBaselineDownload(baseline) {
1686
1757
  }
1687
1758
  } })),
1688
1759
  findBaseline: async (commits) => unwrap(await client.POST("/baseline", { body: {
1760
+ project: projectSlug,
1689
1761
  commits,
1690
1762
  name: options.buildName,
1691
1763
  mode: options.mode
@@ -1707,13 +1779,11 @@ function registerBaselineDownload(baseline) {
1707
1779
  }
1708
1780
  });
1709
1781
  }
1710
- //#endregion
1711
- //#region src/commands/baseline/index.ts
1782
+ // src/commands/baseline/index.ts
1712
1783
  function baselineCommand(program) {
1713
1784
  registerBaselineDownload(program.command("baseline").description("Export a project's baseline screenshots"));
1714
1785
  }
1715
- //#endregion
1716
- //#region src/lib/body.ts
1786
+ // src/lib/body.ts
1717
1787
  /**
1718
1788
  * Resolve the Markdown body of a comment or review from the mutually-exclusive
1719
1789
  * `--body` (inline) and `--body-file` (path) options.
@@ -1733,8 +1803,7 @@ async function resolveBody(options, { required = false } = {}) {
1733
1803
  }
1734
1804
  if (required) fail("A comment body is required. Use --body <markdown> or --body-file <path>.");
1735
1805
  }
1736
- //#endregion
1737
- //#region src/commands/review/create.ts
1806
+ // src/commands/review/create.ts
1738
1807
  const events = {
1739
1808
  approve: "APPROVE",
1740
1809
  reject: "REJECT",
@@ -1762,8 +1831,7 @@ function registerReviewCreate(review) {
1762
1831
  format: formatReview
1763
1832
  }));
1764
1833
  }
1765
- //#endregion
1766
- //#region src/commands/review/dismiss.ts
1834
+ // src/commands/review/dismiss.ts
1767
1835
  function registerReviewDismiss(review) {
1768
1836
  review.command("dismiss").description("Dismiss a submitted review on a build").argument("<buildReference>", "Build number or Argos build URL").argument("<reviewId>", "ID of the review to dismiss").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, reviewId, options) => runBuildAction({
1769
1837
  reference,
@@ -1778,8 +1846,7 @@ function registerReviewDismiss(review) {
1778
1846
  format: formatReview
1779
1847
  }));
1780
1848
  }
1781
- //#endregion
1782
- //#region src/commands/review/list.ts
1849
+ // src/commands/review/list.ts
1783
1850
  function registerReviewList(review) {
1784
1851
  review.command("list").description("List the reviews submitted on a build").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
1785
1852
  reference,
@@ -1793,8 +1860,7 @@ function registerReviewList(review) {
1793
1860
  format: formatReviews
1794
1861
  }));
1795
1862
  }
1796
- //#endregion
1797
- //#region src/commands/review/reviewer.ts
1863
+ // src/commands/review/reviewer.ts
1798
1864
  function registerReviewReviewer(review) {
1799
1865
  const reviewer = review.command("reviewer").description("List, request, and cancel review requests on a build");
1800
1866
  reviewer.command("list").description("List the users currently requested to review a build").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
@@ -1837,8 +1903,7 @@ function registerReviewReviewer(review) {
1837
1903
  format: formatReviewers
1838
1904
  }));
1839
1905
  }
1840
- //#endregion
1841
- //#region src/commands/review/index.ts
1906
+ // src/commands/review/index.ts
1842
1907
  function reviewCommand(program) {
1843
1908
  const review = program.command("review").description("List, submit, and dismiss build reviews");
1844
1909
  registerReviewList(review);
@@ -1846,8 +1911,7 @@ function reviewCommand(program) {
1846
1911
  registerReviewDismiss(review);
1847
1912
  registerReviewReviewer(review);
1848
1913
  }
1849
- //#endregion
1850
- //#region src/lib/anchor.ts
1914
+ // src/lib/anchor.ts
1851
1915
  function parsePair(value) {
1852
1916
  const parts = value.split(",").map((part) => Number(part.trim()));
1853
1917
  if (parts.length !== 2 || parts.some((part) => Number.isNaN(part))) return null;
@@ -1883,8 +1947,7 @@ function parseAnchor(options) {
1883
1947
  };
1884
1948
  }
1885
1949
  }
1886
- //#endregion
1887
- //#region src/commands/comment/create.ts
1950
+ // src/commands/comment/create.ts
1888
1951
  function registerCommentCreate(comment) {
1889
1952
  comment.command("create").description("Post a comment (or reply) on a build").argument("<buildReference>", "Build number or Argos build URL").option("--body <markdown>", "Markdown body of the comment").option("--body-file <path>", "Read the comment body from a Markdown file").option("--reply-to <threadId>", "Reply to an existing thread (its root comment ID)").option("--diff <screenshotDiffId>", "Anchor the comment to a screenshot diff").option("--anchor-point <x,y>", "Point on the diff in normalized 0-1 coordinates (requires --diff)").option("--anchor-lines <from,to>", "1-based inclusive line range on the diff (requires --diff)").option("--draft", "Attach to your pending review instead of posting immediately").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
1890
1953
  reference,
@@ -1912,8 +1975,7 @@ function registerCommentCreate(comment) {
1912
1975
  format: formatComment
1913
1976
  }));
1914
1977
  }
1915
- //#endregion
1916
- //#region src/commands/comment/_action.ts
1978
+ // src/commands/comment/_action.ts
1917
1979
  /**
1918
1980
  * Register a `comment <name> <buildReference> <commentId>` command that runs
1919
1981
  * `perform` and prints the returned comment. Used for the single-comment
@@ -1936,8 +1998,7 @@ function defineCommentAction(opts) {
1936
1998
  }));
1937
1999
  };
1938
2000
  }
1939
- //#endregion
1940
- //#region src/commands/comment/delete.ts
2001
+ // src/commands/comment/delete.ts
1941
2002
  const registerCommentDelete = defineCommentAction({
1942
2003
  name: "delete",
1943
2004
  description: "Delete a comment on a build (author only)",
@@ -1948,8 +2009,7 @@ const registerCommentDelete = defineCommentAction({
1948
2009
  commentId
1949
2010
  } } }))
1950
2011
  });
1951
- //#endregion
1952
- //#region src/commands/comment/edit.ts
2012
+ // src/commands/comment/edit.ts
1953
2013
  function registerCommentEdit(comment) {
1954
2014
  comment.command("edit").description("Update the body of a comment (author only)").argument("<buildReference>", "Build number or Argos build URL").argument("<commentId>", "ID of the comment").option("--body <markdown>", "New Markdown body of the comment").option("--body-file <path>", "Read the new body from a Markdown file").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, commentId, options) => runBuildAction({
1955
2015
  reference,
@@ -1970,8 +2030,7 @@ function registerCommentEdit(comment) {
1970
2030
  format: formatComment
1971
2031
  }));
1972
2032
  }
1973
- //#endregion
1974
- //#region src/commands/comment/get.ts
2033
+ // src/commands/comment/get.ts
1975
2034
  const registerCommentGet = defineCommentAction({
1976
2035
  name: "get",
1977
2036
  description: "Fetch a single comment on a build",
@@ -1982,8 +2041,7 @@ const registerCommentGet = defineCommentAction({
1982
2041
  commentId
1983
2042
  } } }))
1984
2043
  });
1985
- //#endregion
1986
- //#region src/commands/comment/list.ts
2044
+ // src/commands/comment/list.ts
1987
2045
  function registerCommentList(comment) {
1988
2046
  comment.command("list").description("List the comments on a build").argument("<buildReference>", "Build number or Argos build URL").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, options) => runBuildAction({
1989
2047
  reference,
@@ -1997,8 +2055,7 @@ function registerCommentList(comment) {
1997
2055
  format: formatComments
1998
2056
  }));
1999
2057
  }
2000
- //#endregion
2001
- //#region src/commands/comment/react.ts
2058
+ // src/commands/comment/react.ts
2002
2059
  function registerCommentReact(comment) {
2003
2060
  comment.command("react").description("Add an emoji reaction to a comment").argument("<buildReference>", "Build number or Argos build URL").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji to react with").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, commentId, emoji, options) => runBuildAction({
2004
2061
  reference,
@@ -2016,8 +2073,7 @@ function registerCommentReact(comment) {
2016
2073
  format: formatComment
2017
2074
  }));
2018
2075
  }
2019
- //#endregion
2020
- //#region src/commands/comment/resolve.ts
2076
+ // src/commands/comment/resolve.ts
2021
2077
  const registerCommentResolve = defineCommentAction({
2022
2078
  name: "resolve",
2023
2079
  description: "Mark a comment thread as resolved",
@@ -2028,8 +2084,7 @@ const registerCommentResolve = defineCommentAction({
2028
2084
  commentId
2029
2085
  } } }))
2030
2086
  });
2031
- //#endregion
2032
- //#region src/commands/comment/subscribe.ts
2087
+ // src/commands/comment/subscribe.ts
2033
2088
  const registerCommentSubscribe = defineCommentAction({
2034
2089
  name: "subscribe",
2035
2090
  description: "Subscribe to a comment thread's notifications",
@@ -2040,8 +2095,7 @@ const registerCommentSubscribe = defineCommentAction({
2040
2095
  commentId
2041
2096
  } } }))
2042
2097
  });
2043
- //#endregion
2044
- //#region src/commands/comment/unreact.ts
2098
+ // src/commands/comment/unreact.ts
2045
2099
  function registerCommentUnreact(comment) {
2046
2100
  comment.command("unreact").description("Remove one of your emoji reactions from a comment").argument("<buildReference>", "Build number or Argos build URL").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji reaction to remove").addOption(tokenOption).addOption(projectPathOption).addOption(jsonOption).action((reference, commentId, emoji, options) => runBuildAction({
2047
2101
  reference,
@@ -2059,8 +2113,7 @@ function registerCommentUnreact(comment) {
2059
2113
  format: formatComment
2060
2114
  }));
2061
2115
  }
2062
- //#endregion
2063
- //#region src/commands/comment/unresolve.ts
2116
+ // src/commands/comment/unresolve.ts
2064
2117
  const registerCommentUnresolve = defineCommentAction({
2065
2118
  name: "unresolve",
2066
2119
  description: "Reopen a resolved comment thread",
@@ -2071,8 +2124,7 @@ const registerCommentUnresolve = defineCommentAction({
2071
2124
  commentId
2072
2125
  } } }))
2073
2126
  });
2074
- //#endregion
2075
- //#region src/commands/comment/unsubscribe.ts
2127
+ // src/commands/comment/unsubscribe.ts
2076
2128
  const registerCommentUnsubscribe = defineCommentAction({
2077
2129
  name: "unsubscribe",
2078
2130
  description: "Unsubscribe from a comment thread's notifications",
@@ -2083,8 +2135,7 @@ const registerCommentUnsubscribe = defineCommentAction({
2083
2135
  commentId
2084
2136
  } } }))
2085
2137
  });
2086
- //#endregion
2087
- //#region src/commands/comment/index.ts
2138
+ // src/commands/comment/index.ts
2088
2139
  function commentCommand(program) {
2089
2140
  const comment = program.command("comment").description("List, post, and act on build comments");
2090
2141
  registerCommentList(comment);
@@ -2099,8 +2150,7 @@ function commentCommand(program) {
2099
2150
  registerCommentSubscribe(comment);
2100
2151
  registerCommentUnsubscribe(comment);
2101
2152
  }
2102
- //#endregion
2103
- //#region src/commands/login.ts
2153
+ // src/commands/login.ts
2104
2154
  const LOGIN_CLI_SUCCESS_ROUTE = `/auth/cli/success`;
2105
2155
  const LOGIN_TIMEOUT_MS = 3e5;
2106
2156
  const CALLBACK_ERROR_HTML = `<!DOCTYPE html><html lang="en">
@@ -2247,8 +2297,7 @@ function loginCommand(program) {
2247
2297
  console.log(successColor("Logged in to Argos successfully."));
2248
2298
  });
2249
2299
  }
2250
- //#endregion
2251
- //#region src/commands/logout.ts
2300
+ // src/commands/logout.ts
2252
2301
  function logoutCommand(program) {
2253
2302
  program.command("logout").description("Log out from Argos").action(async () => {
2254
2303
  const { legacyToken, oauth } = await getStoredCredentials();
@@ -2261,14 +2310,14 @@ function logoutCommand(program) {
2261
2310
  console.log("Logged out from Argos.");
2262
2311
  });
2263
2312
  }
2264
- //#endregion
2265
- //#region src/commands/deploy.ts
2313
+ // src/commands/deploy.ts
2266
2314
  function deployCommand(program) {
2267
- program.command("deploy").argument("<directory>", "Directory of the static build to deploy").description("Deploy a static build (Storybook or any static site) to Argos").addOption(tokenOption).addOption(new Option("--prod", "Deploy as a production deployment").default(false)).action(async (directory, options) => {
2315
+ program.command("deploy").argument("<directory>", "Directory of the static build to deploy").description("Deploy a static build (Storybook or any static site) to Argos").addOption(tokenOption).addOption(projectOption).addOption(new Option("--prod", "Deploy as a production deployment").default(false)).action(async (directory, options) => {
2268
2316
  const spinner = ora("Deploying").start();
2269
2317
  try {
2270
2318
  const result = await deploy({
2271
2319
  token: options.token,
2320
+ project: options.project,
2272
2321
  root: resolve(directory),
2273
2322
  environment: options.prod ? "production" : void 0
2274
2323
  });
@@ -2282,8 +2331,7 @@ function deployCommand(program) {
2282
2331
  }
2283
2332
  });
2284
2333
  }
2285
- //#endregion
2286
- //#region src/commands/whoami.ts
2334
+ // src/commands/whoami.ts
2287
2335
  function whoamiCommand(program) {
2288
2336
  program.command("whoami").description("Display the user authenticated with the current Argos token").addOption(tokenOption).addOption(jsonOption).action(async (options) => {
2289
2337
  try {
@@ -2293,8 +2341,7 @@ function whoamiCommand(program) {
2293
2341
  }
2294
2342
  });
2295
2343
  }
2296
- //#endregion
2297
- //#region src/commands/create-project.ts
2344
+ // src/commands/create-project.ts
2298
2345
  function createProjectCommand(program) {
2299
2346
  program.command("create-project").argument("<name>", "Name of the project to create").description("Create a new project in an account you administer").addOption(accountOption).addOption(tokenOption).addOption(jsonOption).action(async (name, options) => {
2300
2347
  try {
@@ -2309,16 +2356,8 @@ function createProjectCommand(program) {
2309
2356
  }
2310
2357
  });
2311
2358
  }
2312
- //#endregion
2313
- //#region src/commands/analytics.ts
2359
+ // src/commands/analytics.ts
2314
2360
  const DEFAULT_PERIOD_DAYS = 30;
2315
- const DAY_MS = 864e5;
2316
- /** Coerce a user-supplied date into an ISO 8601 datetime, or fail cleanly. */
2317
- function toIsoOrFail(value, option) {
2318
- const date = new Date(value);
2319
- if (Number.isNaN(date.getTime())) fail(`Invalid --${option} value: "${value}". Use an ISO 8601 datetime.`);
2320
- return date.toISOString();
2321
- }
2322
2361
  /** Collect a repeatable `--project` flag into an array of project names. */
2323
2362
  function collectProject(value, previous = []) {
2324
2363
  return [...previous, value];
@@ -2353,8 +2392,7 @@ function analyticsCommand(program) {
2353
2392
  }
2354
2393
  });
2355
2394
  }
2356
- //#endregion
2357
- //#region src/commands/change/_action.ts
2395
+ // src/commands/change/_action.ts
2358
2396
  /**
2359
2397
  * Register a `change <name> <changeId>` command that runs `perform` and prints
2360
2398
  * the updated change. Both change actions (ignore, unignore) share the same
@@ -2380,8 +2418,7 @@ function defineChangeAction(opts) {
2380
2418
  });
2381
2419
  };
2382
2420
  }
2383
- //#endregion
2384
- //#region src/commands/change/ignore.ts
2421
+ // src/commands/change/ignore.ts
2385
2422
  const registerChangeIgnore = defineChangeAction({
2386
2423
  name: "ignore",
2387
2424
  description: "Ignore a flaky test change so its diffs stop requiring review and are auto-approved on future builds",
@@ -2394,8 +2431,7 @@ const registerChangeIgnore = defineChangeAction({
2394
2431
  query: { metricsPeriod }
2395
2432
  } }))
2396
2433
  });
2397
- //#endregion
2398
- //#region src/commands/change/list.ts
2434
+ // src/commands/change/list.ts
2399
2435
  function registerChangeList(change) {
2400
2436
  change.command("list").description("List the changes currently ignored in a project, most recently ignored first").addOption(limitOption).addOption(tokenOption).addOption(changeProjectPathOption).addOption(jsonOption).action(async (options) => {
2401
2437
  try {
@@ -2412,8 +2448,7 @@ function registerChangeList(change) {
2412
2448
  }
2413
2449
  });
2414
2450
  }
2415
- //#endregion
2416
- //#region src/commands/change/unignore.ts
2451
+ // src/commands/change/unignore.ts
2417
2452
  const registerChangeUnignore = defineChangeAction({
2418
2453
  name: "unignore",
2419
2454
  description: "Stop ignoring a test change so its diffs require review again on future builds",
@@ -2426,16 +2461,14 @@ const registerChangeUnignore = defineChangeAction({
2426
2461
  query: { metricsPeriod }
2427
2462
  } }))
2428
2463
  });
2429
- //#endregion
2430
- //#region src/commands/change/index.ts
2464
+ // src/commands/change/index.ts
2431
2465
  function changeCommand(program) {
2432
2466
  const change = program.command("change").description("Ignore or unignore flaky test changes");
2433
2467
  registerChangeList(change);
2434
2468
  registerChangeIgnore(change);
2435
2469
  registerChangeUnignore(change);
2436
2470
  }
2437
- //#endregion
2438
- //#region src/commands/media/comment/create.ts
2471
+ // src/commands/media/comment/create.ts
2439
2472
  function registerMediaCommentCreate(comment) {
2440
2473
  comment.command("create").description("Post a comment (or reply) on a media").argument("<mediaId>", "ID of the media").option("--body <markdown>", "Markdown body of the comment").option("--body-file <path>", "Read the comment body from a Markdown file").option("--reply-to <threadId>", "Reply to an existing thread (its root comment ID)").option("--anchor-point <x,y>", "Pin the comment to a spot on the media, in normalized 0-1 coordinates").addOption(tokenOption).addOption(jsonOption).action(async (mediaId, options) => {
2441
2474
  try {
@@ -2455,8 +2488,7 @@ function registerMediaCommentCreate(comment) {
2455
2488
  }
2456
2489
  });
2457
2490
  }
2458
- //#endregion
2459
- //#region src/commands/media/comment/_action.ts
2491
+ // src/commands/media/comment/_action.ts
2460
2492
  /**
2461
2493
  * Register a `media comment <name> <mediaId> <commentId>` command that runs
2462
2494
  * `perform` and prints the returned comment.
@@ -2481,8 +2513,7 @@ function defineMediaCommentAction(opts) {
2481
2513
  });
2482
2514
  };
2483
2515
  }
2484
- //#endregion
2485
- //#region src/commands/media/comment/delete.ts
2516
+ // src/commands/media/comment/delete.ts
2486
2517
  const registerMediaCommentDelete = defineMediaCommentAction({
2487
2518
  name: "delete",
2488
2519
  description: "Delete a comment on a media (author only)",
@@ -2491,8 +2522,7 @@ const registerMediaCommentDelete = defineMediaCommentAction({
2491
2522
  commentId
2492
2523
  } } }))
2493
2524
  });
2494
- //#endregion
2495
- //#region src/commands/media/comment/edit.ts
2525
+ // src/commands/media/comment/edit.ts
2496
2526
  function registerMediaCommentEdit(comment) {
2497
2527
  comment.command("edit").description("Update the body of a comment on a media (author only)").argument("<mediaId>", "ID of the media").argument("<commentId>", "ID of the comment").option("--body <markdown>", "New Markdown body of the comment").option("--body-file <path>", "Read the new body from a Markdown file").addOption(tokenOption).addOption(jsonOption).action(async (mediaId, commentId, options) => {
2498
2528
  try {
@@ -2509,8 +2539,7 @@ function registerMediaCommentEdit(comment) {
2509
2539
  }
2510
2540
  });
2511
2541
  }
2512
- //#endregion
2513
- //#region src/commands/media/comment/get.ts
2542
+ // src/commands/media/comment/get.ts
2514
2543
  const registerMediaCommentGet = defineMediaCommentAction({
2515
2544
  name: "get",
2516
2545
  description: "Show a single comment on a media",
@@ -2519,8 +2548,7 @@ const registerMediaCommentGet = defineMediaCommentAction({
2519
2548
  commentId
2520
2549
  } } }))
2521
2550
  });
2522
- //#endregion
2523
- //#region src/commands/media/comment/list.ts
2551
+ // src/commands/media/comment/list.ts
2524
2552
  function registerMediaCommentList(comment) {
2525
2553
  comment.command("list").description("List the open comment threads on a media — the feedback still to act on").argument("<mediaId>", "ID of the media").addOption(new Option("--all", "Include threads that are already resolved (by default only open ones are listed)")).addOption(tokenOption).addOption(jsonOption).action(async (mediaId, options) => {
2526
2554
  try {
@@ -2542,8 +2570,7 @@ function selectOpenThreads(comments) {
2542
2570
  const resolved = new Set(comments.filter((comment) => comment.resolvedAt !== null).map((comment) => comment.id));
2543
2571
  return comments.filter((comment) => comment.resolvedAt === null && !(comment.threadId !== null && resolved.has(comment.threadId)));
2544
2572
  }
2545
- //#endregion
2546
- //#region src/commands/media/comment/react.ts
2573
+ // src/commands/media/comment/react.ts
2547
2574
  function registerMediaCommentReact(comment) {
2548
2575
  comment.command("react").description("Add an emoji reaction to a comment on a media").argument("<mediaId>", "ID of the media").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji to react with").addOption(tokenOption).addOption(jsonOption).action(async (mediaId, commentId, emoji, options) => {
2549
2576
  try {
@@ -2559,8 +2586,7 @@ function registerMediaCommentReact(comment) {
2559
2586
  }
2560
2587
  });
2561
2588
  }
2562
- //#endregion
2563
- //#region src/commands/media/comment/resolve.ts
2589
+ // src/commands/media/comment/resolve.ts
2564
2590
  const registerMediaCommentResolve = defineMediaCommentAction({
2565
2591
  name: "resolve",
2566
2592
  description: "Mark a comment thread as resolved — what to call once you have acted on the feedback",
@@ -2569,8 +2595,7 @@ const registerMediaCommentResolve = defineMediaCommentAction({
2569
2595
  commentId
2570
2596
  } } }))
2571
2597
  });
2572
- //#endregion
2573
- //#region src/commands/media/comment/subscribe.ts
2598
+ // src/commands/media/comment/subscribe.ts
2574
2599
  const registerMediaCommentSubscribe = defineMediaCommentAction({
2575
2600
  name: "subscribe",
2576
2601
  description: "Subscribe to a comment thread's notifications",
@@ -2579,8 +2604,7 @@ const registerMediaCommentSubscribe = defineMediaCommentAction({
2579
2604
  commentId
2580
2605
  } } }))
2581
2606
  });
2582
- //#endregion
2583
- //#region src/commands/media/comment/unreact.ts
2607
+ // src/commands/media/comment/unreact.ts
2584
2608
  function registerMediaCommentUnreact(comment) {
2585
2609
  comment.command("unreact").description("Remove one of your emoji reactions from a comment on a media").argument("<mediaId>", "ID of the media").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji reaction to remove").addOption(tokenOption).addOption(jsonOption).action(async (mediaId, commentId, emoji, options) => {
2586
2610
  try {
@@ -2596,8 +2620,7 @@ function registerMediaCommentUnreact(comment) {
2596
2620
  }
2597
2621
  });
2598
2622
  }
2599
- //#endregion
2600
- //#region src/commands/media/comment/unresolve.ts
2623
+ // src/commands/media/comment/unresolve.ts
2601
2624
  const registerMediaCommentUnresolve = defineMediaCommentAction({
2602
2625
  name: "unresolve",
2603
2626
  description: "Reopen a resolved comment thread",
@@ -2606,8 +2629,7 @@ const registerMediaCommentUnresolve = defineMediaCommentAction({
2606
2629
  commentId
2607
2630
  } } }))
2608
2631
  });
2609
- //#endregion
2610
- //#region src/commands/media/comment/unsubscribe.ts
2632
+ // src/commands/media/comment/unsubscribe.ts
2611
2633
  const registerMediaCommentUnsubscribe = defineMediaCommentAction({
2612
2634
  name: "unsubscribe",
2613
2635
  description: "Stop receiving notifications for a comment thread",
@@ -2616,8 +2638,7 @@ const registerMediaCommentUnsubscribe = defineMediaCommentAction({
2616
2638
  commentId
2617
2639
  } } }))
2618
2640
  });
2619
- //#endregion
2620
- //#region src/commands/media/comment/index.ts
2641
+ // src/commands/media/comment/index.ts
2621
2642
  function registerMediaComment(media) {
2622
2643
  const comment = media.command("comment").description("List, post, and act on the comments left on a media — the feedback a human pinned to a spot on your screenshot");
2623
2644
  registerMediaCommentList(comment);
@@ -2632,8 +2653,7 @@ function registerMediaComment(media) {
2632
2653
  registerMediaCommentSubscribe(comment);
2633
2654
  registerMediaCommentUnsubscribe(comment);
2634
2655
  }
2635
- //#endregion
2636
- //#region src/commands/media/delete.ts
2656
+ // src/commands/media/delete.ts
2637
2657
  function registerMediaDelete(media) {
2638
2658
  media.command("delete").argument("<mediaId>", "ID of the media").description("Delete a media. Any share link or pull request embed pointing at it stops working").addOption(tokenOption).action(async (mediaId, options) => {
2639
2659
  try {
@@ -2644,8 +2664,7 @@ function registerMediaDelete(media) {
2644
2664
  }
2645
2665
  });
2646
2666
  }
2647
- //#endregion
2648
- //#region src/commands/media/get.ts
2667
+ // src/commands/media/get.ts
2649
2668
  function registerMediaGet(media) {
2650
2669
  media.command("get").argument("<mediaId>", "ID of the media").description("Show a media's share URL, Markdown embed and details").addOption(tokenOption).addOption(jsonOption).action(async (mediaId, options) => {
2651
2670
  try {
@@ -2655,8 +2674,7 @@ function registerMediaGet(media) {
2655
2674
  }
2656
2675
  });
2657
2676
  }
2658
- //#endregion
2659
- //#region src/commands/media/list.ts
2677
+ // src/commands/media/list.ts
2660
2678
  function registerMediaList(media) {
2661
2679
  media.command("list").description("List a project's uploaded media, most recent first. A project token lists its own project").addOption(new Option("--branch <branch>", "Only media uploaded for this branch, staged and published alike. The way to find everything uploaded for the work in hand")).addOption(new Option("--pr <number>", "Only media published to this pull request")).addOption(new Option("--stage <stage>", "Restrict to media with no pull request yet, or to media published to one").choices(["staged", "published"])).addOption(new Option("--search <query>", "Match media on their name")).addOption(new Option("--type <type>", "Restrict to images or videos").choices(["image", "video"])).addOption(limitOption).addOption(tokenOption).addOption(mediaProjectPathOption).addOption(jsonOption).action(async (options) => {
2662
2680
  try {
@@ -2681,8 +2699,7 @@ function registerMediaList(media) {
2681
2699
  }
2682
2700
  });
2683
2701
  }
2684
- //#endregion
2685
- //#region src/commands/media/update.ts
2702
+ // src/commands/media/update.ts
2686
2703
  function registerMediaUpdate(media) {
2687
2704
  media.command("update").argument("<mediaId>", "ID of the media").description("Change a staged media's name, description or branch. Fixed once the media is published to a pull request").addOption(new Option("--name <name>", "Rename the media")).addOption(new Option("--description <text>", "Prose shown under the media in the pull request comment")).addOption(new Option("--no-description", "Remove the description")).addOption(new Option("--branch <branch>", "Branch to publish the media from, once a pull request opens for it")).addOption(new Option("--no-branch", "Detach the media from its branch, so no pull request will publish it")).addOption(tokenOption).addOption(jsonOption).action(async (mediaId, options) => {
2688
2705
  try {
@@ -2701,8 +2718,7 @@ function registerMediaUpdate(media) {
2701
2718
  }
2702
2719
  });
2703
2720
  }
2704
- //#endregion
2705
- //#region src/commands/media/upload.ts
2721
+ // src/commands/media/upload.ts
2706
2722
  function registerMediaUpload(media) {
2707
2723
  media.command("upload").argument("<files...>", "Image or video files to upload").description("Upload images or videos and print their share URLs and Markdown embeds").addOption(tokenOption).addOption(mediaProjectPathOption).addOption(new Option("--branch <branch>", "Branch the media belongs to. Use this when the pull request does not exist yet: Argos publishes the media and comments on the pull request by itself once one opens for that branch")).addOption(new Option("--pr <number>", "Pull request to publish the media to. Argos keeps one comment on it listing every media uploaded, edited in place")).addOption(new Option("--state <state>", "Which half of a before/after pair these files are. Inferred from a file name ending in -before or -after").choices(["before", "after"])).addOption(new Option("--description <text>", "Prose shown under the media in the pull request comment")).addOption(new Option("--visibility <visibility>", "Who can open the share page. Defaults to your project's visibility in Argos: public for a public project, team for a private one").choices(["team", "public"])).addOption(new Option("--no-compress", "Upload images exactly as they are instead of converting them to WebP")).addOption(jsonOption).action(async (files, options) => {
2708
2724
  const spinner = options.json ? null : ora(files.length === 1 ? "Uploading media" : `Uploading ${files.length} files`).start();
@@ -2727,8 +2743,7 @@ function registerMediaUpload(media) {
2727
2743
  }
2728
2744
  });
2729
2745
  }
2730
- //#endregion
2731
- //#region src/commands/media/versions.ts
2746
+ // src/commands/media/versions.ts
2732
2747
  function registerMediaVersions(media) {
2733
2748
  media.command("versions").argument("<mediaId>", "ID of the media").description("List a media's uploaded versions, newest first. Use it to resolve the version a comment was written against").addOption(tokenOption).addOption(jsonOption).action(async (mediaId, options) => {
2734
2749
  try {
@@ -2738,8 +2753,7 @@ function registerMediaVersions(media) {
2738
2753
  }
2739
2754
  });
2740
2755
  }
2741
- //#endregion
2742
- //#region src/commands/media/index.ts
2756
+ // src/commands/media/index.ts
2743
2757
  function mediaCommand(program) {
2744
2758
  const media = program.command("media").description("Upload standalone images and videos to Argos and get shareable links to paste into pull requests");
2745
2759
  registerMediaUpload(media);
@@ -2750,8 +2764,7 @@ function mediaCommand(program) {
2750
2764
  registerMediaVersions(media);
2751
2765
  registerMediaComment(media);
2752
2766
  }
2753
- //#endregion
2754
- //#region src/commands/test/changes.ts
2767
+ // src/commands/test/changes.ts
2755
2768
  const PER_PAGE = 100;
2756
2769
  const ignoredOption = new Option("--ignored <boolean>", "Only the changes currently ignored (`true`) or only the ones still under review (`false`)").choices(["true", "false"]);
2757
2770
  /** Fetch every change of a test, following pagination. */
@@ -2789,8 +2802,7 @@ function registerTestChanges(test) {
2789
2802
  }
2790
2803
  });
2791
2804
  }
2792
- //#endregion
2793
- //#region src/commands/test/comment/create.ts
2805
+ // src/commands/test/comment/create.ts
2794
2806
  function registerTestCommentCreate(comment) {
2795
2807
  comment.command("create").description("Post a comment (or reply) on a test").argument("<testId>", "Test ID, taken from a diff's `test.id`").option("--body <markdown>", "Markdown body of the comment").option("--body-file <path>", "Read the comment body from a Markdown file").option("--reply-to <threadId>", "Reply to an existing thread (its root comment ID)").addOption(tokenOption).addOption(testProjectPathOption).addOption(jsonOption).action(async (testId, options) => {
2796
2808
  try {
@@ -2812,8 +2824,7 @@ function registerTestCommentCreate(comment) {
2812
2824
  }
2813
2825
  });
2814
2826
  }
2815
- //#endregion
2816
- //#region src/commands/test/comment/_action.ts
2827
+ // src/commands/test/comment/_action.ts
2817
2828
  /**
2818
2829
  * Register a `test comment <name> <testId> <commentId>` command that runs
2819
2830
  * `perform` and prints the returned comment. Used for the single-comment actions
@@ -2838,8 +2849,7 @@ function defineTestCommentAction(opts) {
2838
2849
  });
2839
2850
  };
2840
2851
  }
2841
- //#endregion
2842
- //#region src/commands/test/comment/delete.ts
2852
+ // src/commands/test/comment/delete.ts
2843
2853
  const registerTestCommentDelete = defineTestCommentAction({
2844
2854
  name: "delete",
2845
2855
  description: "Delete a comment on a test (author or project admin)",
@@ -2850,8 +2860,7 @@ const registerTestCommentDelete = defineTestCommentAction({
2850
2860
  commentId
2851
2861
  } } }))
2852
2862
  });
2853
- //#endregion
2854
- //#region src/commands/test/comment/edit.ts
2863
+ // src/commands/test/comment/edit.ts
2855
2864
  function registerTestCommentEdit(comment) {
2856
2865
  comment.command("edit").description("Update the body of a comment on a test (author only)").argument("<testId>", "Test ID, taken from a diff's `test.id`").argument("<commentId>", "ID of the comment").option("--body <markdown>", "New Markdown body of the comment").option("--body-file <path>", "Read the new body from a Markdown file").addOption(tokenOption).addOption(testProjectPathOption).addOption(jsonOption).action(async (testId, commentId, options) => {
2857
2866
  try {
@@ -2871,8 +2880,7 @@ function registerTestCommentEdit(comment) {
2871
2880
  }
2872
2881
  });
2873
2882
  }
2874
- //#endregion
2875
- //#region src/commands/test/comment/get.ts
2883
+ // src/commands/test/comment/get.ts
2876
2884
  const registerTestCommentGet = defineTestCommentAction({
2877
2885
  name: "get",
2878
2886
  description: "Fetch a single comment on a test",
@@ -2883,8 +2891,7 @@ const registerTestCommentGet = defineTestCommentAction({
2883
2891
  commentId
2884
2892
  } } }))
2885
2893
  });
2886
- //#endregion
2887
- //#region src/commands/test/comment/list.ts
2894
+ // src/commands/test/comment/list.ts
2888
2895
  function registerTestCommentList(comment) {
2889
2896
  comment.command("list").description("List the comments on a test").argument("<testId>", "Test ID, taken from a diff's `test.id`").addOption(tokenOption).addOption(testProjectPathOption).addOption(jsonOption).action(async (testId, options) => {
2890
2897
  try {
@@ -2899,8 +2906,7 @@ function registerTestCommentList(comment) {
2899
2906
  }
2900
2907
  });
2901
2908
  }
2902
- //#endregion
2903
- //#region src/commands/test/comment/react.ts
2909
+ // src/commands/test/comment/react.ts
2904
2910
  function registerTestCommentReact(comment) {
2905
2911
  comment.command("react").description("Add an emoji reaction to a comment on a test").argument("<testId>", "Test ID, taken from a diff's `test.id`").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji to react with").addOption(tokenOption).addOption(testProjectPathOption).addOption(jsonOption).action(async (testId, commentId, emoji, options) => {
2906
2912
  try {
@@ -2919,8 +2925,7 @@ function registerTestCommentReact(comment) {
2919
2925
  }
2920
2926
  });
2921
2927
  }
2922
- //#endregion
2923
- //#region src/commands/test/comment/resolve.ts
2928
+ // src/commands/test/comment/resolve.ts
2924
2929
  const registerTestCommentResolve = defineTestCommentAction({
2925
2930
  name: "resolve",
2926
2931
  description: "Mark a comment thread on a test as resolved",
@@ -2931,8 +2936,7 @@ const registerTestCommentResolve = defineTestCommentAction({
2931
2936
  commentId
2932
2937
  } } }))
2933
2938
  });
2934
- //#endregion
2935
- //#region src/commands/test/comment/subscribe.ts
2939
+ // src/commands/test/comment/subscribe.ts
2936
2940
  const registerTestCommentSubscribe = defineTestCommentAction({
2937
2941
  name: "subscribe",
2938
2942
  description: "Follow a comment thread on a test to get notified of replies",
@@ -2943,8 +2947,7 @@ const registerTestCommentSubscribe = defineTestCommentAction({
2943
2947
  commentId
2944
2948
  } } }))
2945
2949
  });
2946
- //#endregion
2947
- //#region src/commands/test/comment/unreact.ts
2950
+ // src/commands/test/comment/unreact.ts
2948
2951
  function registerTestCommentUnreact(comment) {
2949
2952
  comment.command("unreact").description("Remove your emoji reaction from a comment on a test").argument("<testId>", "Test ID, taken from a diff's `test.id`").argument("<commentId>", "ID of the comment").argument("<emoji>", "Emoji to react with").addOption(tokenOption).addOption(testProjectPathOption).addOption(jsonOption).action(async (testId, commentId, emoji, options) => {
2950
2953
  try {
@@ -2963,8 +2966,7 @@ function registerTestCommentUnreact(comment) {
2963
2966
  }
2964
2967
  });
2965
2968
  }
2966
- //#endregion
2967
- //#region src/commands/test/comment/unresolve.ts
2969
+ // src/commands/test/comment/unresolve.ts
2968
2970
  const registerTestCommentUnresolve = defineTestCommentAction({
2969
2971
  name: "unresolve",
2970
2972
  description: "Reopen a resolved comment thread on a test",
@@ -2975,8 +2977,7 @@ const registerTestCommentUnresolve = defineTestCommentAction({
2975
2977
  commentId
2976
2978
  } } }))
2977
2979
  });
2978
- //#endregion
2979
- //#region src/commands/test/comment/unsubscribe.ts
2980
+ // src/commands/test/comment/unsubscribe.ts
2980
2981
  const registerTestCommentUnsubscribe = defineTestCommentAction({
2981
2982
  name: "unsubscribe",
2982
2983
  description: "Stop following a comment thread on a test",
@@ -2987,8 +2988,7 @@ const registerTestCommentUnsubscribe = defineTestCommentAction({
2987
2988
  commentId
2988
2989
  } } }))
2989
2990
  });
2990
- //#endregion
2991
- //#region src/commands/test/comment/index.ts
2991
+ // src/commands/test/comment/index.ts
2992
2992
  function registerTestComment(test) {
2993
2993
  const comment = test.command("comment").description("List, post, and act on comments left on a test");
2994
2994
  registerTestCommentList(comment);
@@ -3003,8 +3003,7 @@ function registerTestComment(test) {
3003
3003
  registerTestCommentSubscribe(comment);
3004
3004
  registerTestCommentUnsubscribe(comment);
3005
3005
  }
3006
- //#endregion
3007
- //#region src/commands/test/get.ts
3006
+ // src/commands/test/get.ts
3008
3007
  function registerTestGet(test) {
3009
3008
  test.command("get").description("Fetch a test and its flakiness metrics").argument("<testId>", "Test ID, taken from a diff's `test.id` (see `argos build snapshots`)").addOption(tokenOption).addOption(testProjectPathOption).addOption(metricsPeriodOption).addOption(jsonOption).action(async (testId, options) => {
3010
3009
  try {
@@ -3022,8 +3021,7 @@ function registerTestGet(test) {
3022
3021
  }
3023
3022
  });
3024
3023
  }
3025
- //#endregion
3026
- //#region src/commands/test/list.ts
3024
+ // src/commands/test/list.ts
3027
3025
  function registerTestList(test) {
3028
3026
  test.command("list").description("List the tests currently running in a project, flakiest first — the project's flakiness backlog").option("--build-name <name>", "Restrict to the tests of a single build name").option("--search <query>", "Match tests on their name").addOption(limitOption).addOption(tokenOption).addOption(testProjectPathOption).addOption(metricsPeriodOption).addOption(jsonOption).action(async (options) => {
3029
3027
  try {
@@ -3045,8 +3043,7 @@ function registerTestList(test) {
3045
3043
  }
3046
3044
  });
3047
3045
  }
3048
- //#endregion
3049
- //#region src/commands/test/subscription.ts
3046
+ // src/commands/test/subscription.ts
3050
3047
  /**
3051
3048
  * Register `test subscribe` / `test unsubscribe`. Both act as a user, so they
3052
3049
  * need a personal access token, and the project comes from `--project` or
@@ -3087,8 +3084,7 @@ const registerTestUnsubscribe = defineTestSubscription({
3087
3084
  testId
3088
3085
  } } }))
3089
3086
  });
3090
- //#endregion
3091
- //#region src/commands/test/index.ts
3087
+ // src/commands/test/index.ts
3092
3088
  function testCommand(program) {
3093
3089
  const test = program.command("test").description("Inspect a test's flakiness and the changes that keep coming back");
3094
3090
  registerTestList(test);
@@ -3098,8 +3094,7 @@ function testCommand(program) {
3098
3094
  registerTestSubscribe(test);
3099
3095
  registerTestUnsubscribe(test);
3100
3096
  }
3101
- //#endregion
3102
- //#region src/commands/account/_run.ts
3097
+ // src/commands/account/_run.ts
3103
3098
  /**
3104
3099
  * Run an account-scoped command end to end: resolve the account target, run the
3105
3100
  * handler, print the result, and turn any failure into a clean CLI error.
@@ -3115,8 +3110,7 @@ async function runAccountAction(opts) {
3115
3110
  handleCliError(error, "user");
3116
3111
  }
3117
3112
  }
3118
- //#endregion
3119
- //#region src/commands/account/domain/index.ts
3113
+ // src/commands/account/domain/index.ts
3120
3114
  function registerAccountDomain(account) {
3121
3115
  const domain = account.command("domain").description("Manage the email domains a team is open to: anyone signing up with a verified address on one joins automatically");
3122
3116
  domain.command("list").description("List the email domains a team is open to").addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((options) => runAccountAction({
@@ -3147,8 +3141,7 @@ function registerAccountDomain(account) {
3147
3141
  format: ({ domain: removed }) => `Closed the team to ${removed}. Existing members keep their access.`
3148
3142
  }));
3149
3143
  }
3150
- //#endregion
3151
- //#region src/commands/account/get.ts
3144
+ // src/commands/account/get.ts
3152
3145
  function registerAccountGet(account) {
3153
3146
  account.command("get").description("Fetch an account with its plan and current-period usage").addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((options) => runAccountAction({
3154
3147
  options,
@@ -3156,8 +3149,7 @@ function registerAccountGet(account) {
3156
3149
  format: formatAccount
3157
3150
  }));
3158
3151
  }
3159
- //#endregion
3160
- //#region src/commands/account/invite/cancel.ts
3152
+ // src/commands/account/invite/cancel.ts
3161
3153
  function registerInviteCancel(invite) {
3162
3154
  invite.command("cancel").description("Cancel a pending invite, invalidating its link").argument("<inviteId>", "Invite ID, taken from `argos account invite list`").addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((inviteId, options) => runAccountAction({
3163
3155
  options,
@@ -3174,8 +3166,7 @@ function registerInviteCancel(invite) {
3174
3166
  format: ({ inviteId }) => `Cancelled invite ${inviteId}.`
3175
3167
  }));
3176
3168
  }
3177
- //#endregion
3178
- //#region src/commands/account/invite/create.ts
3169
+ // src/commands/account/invite/create.ts
3179
3170
  const TEAM_USER_LEVELS$1 = [
3180
3171
  "owner",
3181
3172
  "member",
@@ -3194,8 +3185,7 @@ function registerInviteCreate(invite) {
3194
3185
  format: formatInvites
3195
3186
  }));
3196
3187
  }
3197
- //#endregion
3198
- //#region src/commands/account/invite/list.ts
3188
+ // src/commands/account/invite/list.ts
3199
3189
  function registerInviteList(invite) {
3200
3190
  invite.command("list").description("List a team's pending invites, most recent first").option("--search <query>", "Match invites on their email address").addOption(limitOption).addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((options) => runAccountAction({
3201
3191
  options,
@@ -3209,8 +3199,7 @@ function registerInviteList(invite) {
3209
3199
  format: formatInvites
3210
3200
  }));
3211
3201
  }
3212
- //#endregion
3213
- //#region src/commands/account/invite/reset-link.ts
3202
+ // src/commands/account/invite/reset-link.ts
3214
3203
  function registerInviteResetLink(invite) {
3215
3204
  invite.command("reset-link").description("Rotate the team's shared invite link, invalidating the previous one").addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((options) => runAccountAction({
3216
3205
  options,
@@ -3218,8 +3207,7 @@ function registerInviteResetLink(invite) {
3218
3207
  format: formatInviteLink
3219
3208
  }));
3220
3209
  }
3221
- //#endregion
3222
- //#region src/commands/account/invite/index.ts
3210
+ // src/commands/account/invite/index.ts
3223
3211
  function registerAccountInvite(account) {
3224
3212
  const invite = account.command("invite").description("Invite people to a team and manage pending invitations");
3225
3213
  registerInviteList(invite);
@@ -3227,8 +3215,7 @@ function registerAccountInvite(account) {
3227
3215
  registerInviteCancel(invite);
3228
3216
  registerInviteResetLink(invite);
3229
3217
  }
3230
- //#endregion
3231
- //#region src/commands/account/member/list.ts
3218
+ // src/commands/account/member/list.ts
3232
3219
  const ORDER_BY_CHOICES = [
3233
3220
  "date",
3234
3221
  "name-asc",
@@ -3249,8 +3236,7 @@ function registerMemberList(member) {
3249
3236
  format: formatMembers
3250
3237
  }));
3251
3238
  }
3252
- //#endregion
3253
- //#region src/commands/account/member/remove.ts
3239
+ // src/commands/account/member/remove.ts
3254
3240
  function registerMemberRemove(member) {
3255
3241
  member.command("remove").description("Remove a member from a team. The last member cannot be removed; removing the second-to-last one promotes the survivor to owner").argument("<userId>", "User ID, taken from `argos account member list`").addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((userId, options) => runAccountAction({
3256
3242
  options,
@@ -3267,8 +3253,7 @@ function registerMemberRemove(member) {
3267
3253
  format: ({ userId }) => `Removed user ${userId} from the team.`
3268
3254
  }));
3269
3255
  }
3270
- //#endregion
3271
- //#region src/commands/account/member/set-level.ts
3256
+ // src/commands/account/member/set-level.ts
3272
3257
  const TEAM_USER_LEVELS = [
3273
3258
  "owner",
3274
3259
  "member",
@@ -3287,16 +3272,85 @@ function registerMemberSetLevel(member) {
3287
3272
  format: formatMember
3288
3273
  }));
3289
3274
  }
3290
- //#endregion
3291
- //#region src/commands/account/member/index.ts
3275
+ // src/commands/account/member/index.ts
3292
3276
  function registerAccountMember(account) {
3293
3277
  const member = account.command("member").description("List a team's members, change their role, or remove them");
3294
3278
  registerMemberList(member);
3295
3279
  registerMemberSetLevel(member);
3296
3280
  registerMemberRemove(member);
3297
3281
  }
3298
- //#endregion
3299
- //#region src/commands/account/update.ts
3282
+ // src/lib/project-token.ts
3283
+ /** Every permission a project token can hold, in the order Argos lists them. */
3284
+ const PROJECT_TOKEN_PERMISSIONS = [
3285
+ "builds:write",
3286
+ "deployments:write",
3287
+ "projects:read",
3288
+ "media:read",
3289
+ "media:write"
3290
+ ];
3291
+ const tokenNameOption = new Option("--name <name>", "Name to recognize the token by, e.g. the CI it is set in").makeOptionMandatory();
3292
+ const tokenPermissionsOption = new Option("--permissions <permissions...>", "What the token can do. Defaults to every permission").choices(PROJECT_TOKEN_PERMISSIONS);
3293
+ const tokenExpireAtOption = new Option("--expire-at <date>", "When the token stops working, as an ISO 8601 date (e.g. 2027-01-31 or 2027-01-31T12:00:00Z). Never, by default").conflicts("expiresIn");
3294
+ const tokenExpiresInOption = new Option("--expires-in <days>", "Number of days the token works for, from now. Never expires, by default");
3295
+ /**
3296
+ * Resolve `--expire-at` or `--expires-in` into the UTC ISO date the API takes,
3297
+ * or `null` for a token that never expires.
3298
+ */
3299
+ function resolveExpireAt(options, now = /* @__PURE__ */ new Date()) {
3300
+ if (options.expiresIn !== void 0) {
3301
+ const days = toPositiveInteger(options.expiresIn, "expires-in");
3302
+ return new Date(now.getTime() + days * DAY_MS).toISOString();
3303
+ }
3304
+ if (options.expireAt !== void 0) {
3305
+ const expireAt = toIsoOrFail(options.expireAt, "expire-at");
3306
+ if (Date.parse(expireAt) <= now.getTime()) fail(`--expire-at must be in the future, received "${options.expireAt}".`);
3307
+ return expireAt;
3308
+ }
3309
+ return null;
3310
+ }
3311
+ /** Build the body shared by both token creation endpoints. */
3312
+ function buildCreateTokenBody(options) {
3313
+ return {
3314
+ name: options.name,
3315
+ permissions: options.permissions,
3316
+ expireAt: resolveExpireAt(options)
3317
+ };
3318
+ }
3319
+ // src/commands/account/project-token/index.ts
3320
+ function registerAccountProjectToken(account) {
3321
+ const projectToken = account.command("project-token").description("Manage every project token of an account, including the ones linked to several projects. Requires administrator access to the account");
3322
+ projectToken.command("list").description("List an account's project tokens, whatever projects they are linked to").addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((options) => runAccountAction({
3323
+ options,
3324
+ handler: async ({ client, accountSlug }) => unwrap(await client.GET("/accounts/{accountSlug}/project-tokens", { params: { path: { accountSlug } } })),
3325
+ format: formatProjectTokens
3326
+ }));
3327
+ projectToken.command("create").description("Create a project token linked to one or more projects of the account and print it. It is shown only once: store it right away. CI using a token linked to several projects must set ARGOS_PROJECT").addOption(new Option("--projects <names...>", "Names of the account's projects to link, e.g. web docs").makeOptionMandatory()).addOption(tokenNameOption).addOption(tokenPermissionsOption).addOption(tokenExpireAtOption).addOption(tokenExpiresInOption).addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((options) => runAccountAction({
3328
+ options,
3329
+ handler: async ({ client, accountSlug }) => unwrap(await client.POST("/accounts/{accountSlug}/project-tokens", {
3330
+ params: { path: { accountSlug } },
3331
+ body: {
3332
+ ...buildCreateTokenBody(options),
3333
+ projects: options.projects
3334
+ }
3335
+ })),
3336
+ format: formatCreatedProjectToken
3337
+ }));
3338
+ projectToken.command("revoke").description("Revoke a project token of the account. CI using it is rejected from its next request").argument("<tokenId>", "Token ID, taken from `argos account project-token list`").addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((tokenId, options) => runAccountAction({
3339
+ options,
3340
+ handler: async ({ client, accountSlug }) => {
3341
+ unwrapEmpty(await client.DELETE("/accounts/{accountSlug}/project-tokens/{tokenId}", { params: { path: {
3342
+ accountSlug,
3343
+ tokenId
3344
+ } } }));
3345
+ return {
3346
+ revoked: true,
3347
+ tokenId
3348
+ };
3349
+ },
3350
+ format: ({ tokenId: revoked }) => `Revoked token ${revoked}.`
3351
+ }));
3352
+ }
3353
+ // src/commands/account/update.ts
3300
3354
  const DEFAULT_USER_LEVELS = ["member", "contributor"];
3301
3355
  function registerAccountUpdate(account) {
3302
3356
  account.command("update").description("Change the role given to users joining a team through its invite link or a verified email domain").addOption(new Option("--default-user-level <level>", "Role given to users that join the team automatically").choices(DEFAULT_USER_LEVELS).makeOptionMandatory()).addOption(accountSlugOption).addOption(tokenOption).addOption(jsonOption).action((options) => runAccountAction({
@@ -3308,18 +3362,17 @@ function registerAccountUpdate(account) {
3308
3362
  format: formatAccount
3309
3363
  }));
3310
3364
  }
3311
- //#endregion
3312
- //#region src/commands/account/index.ts
3365
+ // src/commands/account/index.ts
3313
3366
  function accountCommand(program) {
3314
- const account = program.command("account").description("Inspect an account's plan and usage, and manage a team's members, invites, and email domains");
3367
+ const account = program.command("account").description("Inspect an account's plan and usage, manage its project tokens, and a team's members, invites, and email domains");
3315
3368
  registerAccountGet(account);
3316
3369
  registerAccountUpdate(account);
3317
3370
  registerAccountMember(account);
3318
3371
  registerAccountInvite(account);
3319
3372
  registerAccountDomain(account);
3373
+ registerAccountProjectToken(account);
3320
3374
  }
3321
- //#endregion
3322
- //#region src/commands/project/_run.ts
3375
+ // src/commands/project/_run.ts
3323
3376
  /**
3324
3377
  * Run a project-scoped command end to end: resolve the project target, run the
3325
3378
  * handler, print the result, and turn any failure into a clean CLI error.
@@ -3335,8 +3388,7 @@ async function runProjectAction(opts) {
3335
3388
  handleCliError(error, opts.auth);
3336
3389
  }
3337
3390
  }
3338
- //#endregion
3339
- //#region src/commands/project/contributor.ts
3391
+ // src/commands/project/contributor.ts
3340
3392
  const PROJECT_USER_LEVELS$1 = [
3341
3393
  "admin",
3342
3394
  "reviewer",
@@ -3386,8 +3438,7 @@ function registerProjectContributor(project) {
3386
3438
  format: ({ userId: removed }) => `Revoked access for user ${removed}.`
3387
3439
  }));
3388
3440
  }
3389
- //#endregion
3390
- //#region src/commands/project/deployments.ts
3441
+ // src/commands/project/deployments.ts
3391
3442
  const ENVIRONMENTS = ["preview", "production"];
3392
3443
  function registerProjectDeployments(project) {
3393
3444
  project.command("deployments").description("List a project's deployments, most recent first").addOption(new Option("--environment <environment>", "Restrict to one environment. Use production to see what is live right now").choices(ENVIRONMENTS)).addOption(limitOption).addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
@@ -3406,8 +3457,7 @@ function registerProjectDeployments(project) {
3406
3457
  format: formatDeployments
3407
3458
  }));
3408
3459
  }
3409
- //#endregion
3410
- //#region src/commands/project/domain.ts
3460
+ // src/commands/project/domain.ts
3411
3461
  function registerProjectDomain(project) {
3412
3462
  const domain = project.command("domain").description("Read or set the domain a project's production deployments are served on");
3413
3463
  domain.command("get").description("Get a project's production deployment domain").addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
@@ -3432,8 +3482,7 @@ function registerProjectDomain(project) {
3432
3482
  format: formatProjectDomain
3433
3483
  }));
3434
3484
  }
3435
- //#endregion
3436
- //#region src/commands/project/get.ts
3485
+ // src/commands/project/get.ts
3437
3486
  function registerProjectGet(project) {
3438
3487
  project.command("get").description("Fetch a project and its settings").addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
3439
3488
  options,
@@ -3445,8 +3494,48 @@ function registerProjectGet(project) {
3445
3494
  format: formatProject
3446
3495
  }));
3447
3496
  }
3448
- //#endregion
3449
- //#region src/commands/project/transfer.ts
3497
+ // src/commands/project/token.ts
3498
+ function registerProjectToken(project) {
3499
+ const token = project.command("token").description("Manage the tokens CI authenticates with (ARGOS_TOKEN). To rotate one without downtime: create its replacement, update the CI secret, then revoke the old token");
3500
+ token.command("list").description("List a project's tokens, including the ones linked to other projects too").addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
3501
+ options,
3502
+ auth: "user",
3503
+ handler: async ({ client, owner, project: name }) => unwrap(await client.GET("/projects/{owner}/{project}/tokens", { params: { path: {
3504
+ owner,
3505
+ project: name
3506
+ } } })),
3507
+ format: formatProjectTokens
3508
+ }));
3509
+ token.command("create").description("Create a token for a project and print it. It is shown only once: store it right away, e.g. as the ARGOS_TOKEN secret of your CI").addOption(tokenNameOption).addOption(tokenPermissionsOption).addOption(tokenExpireAtOption).addOption(tokenExpiresInOption).addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
3510
+ options,
3511
+ auth: "user",
3512
+ handler: async ({ client, owner, project: name }) => unwrap(await client.POST("/projects/{owner}/{project}/tokens", {
3513
+ params: { path: {
3514
+ owner,
3515
+ project: name
3516
+ } },
3517
+ body: buildCreateTokenBody(options)
3518
+ })),
3519
+ format: formatCreatedProjectToken
3520
+ }));
3521
+ token.command("revoke").description("Revoke a project token. CI using it is rejected from its next request").argument("<tokenId>", "Token ID, taken from `argos project token list`").addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((tokenId, options) => runProjectAction({
3522
+ options,
3523
+ auth: "user",
3524
+ handler: async ({ client, owner, project: name }) => {
3525
+ unwrapEmpty(await client.DELETE("/projects/{owner}/{project}/tokens/{tokenId}", { params: { path: {
3526
+ owner,
3527
+ project: name,
3528
+ tokenId
3529
+ } } }));
3530
+ return {
3531
+ revoked: true,
3532
+ tokenId
3533
+ };
3534
+ },
3535
+ format: ({ tokenId: revoked }) => `Revoked token ${revoked}.`
3536
+ }));
3537
+ }
3538
+ // src/commands/project/transfer.ts
3450
3539
  function registerProjectTransfer(project) {
3451
3540
  project.command("transfer").description("Move a project to another account. You must administer the project and the account receiving it").addOption(new Option("--to <slug>", "Slug of the account that will own the project").makeOptionMandatory()).option("--name <name>", "Name to give the project on the target account. Defaults to its current name, which must be free there").addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
3452
3541
  options,
@@ -3464,8 +3553,7 @@ function registerProjectTransfer(project) {
3464
3553
  format: formatProject
3465
3554
  }));
3466
3555
  }
3467
- //#endregion
3468
- //#region src/commands/project/update.ts
3556
+ // src/commands/project/update.ts
3469
3557
  const BOOLEAN_CHOICES = ["true", "false"];
3470
3558
  const SUMMARY_CHECKS = [
3471
3559
  "always",
@@ -3519,6 +3607,7 @@ async function buildBody(options, load) {
3519
3607
  if (options.name !== void 0) body.name = options.name;
3520
3608
  if (options.defaultBaseBranch !== void 0) body.defaultBaseBranch = toNullable(options.defaultBaseBranch);
3521
3609
  if (options.autoApprovedBranchGlob !== void 0) body.autoApprovedBranchGlob = toNullable(options.autoApprovedBranchGlob);
3610
+ if (options.autoApproval !== void 0) body.autoApprovalEnabled = toBoolean(options.autoApproval);
3522
3611
  if (options.deploymentProductionBranchGlob !== void 0) body.deploymentProductionBranchGlob = toNullable(options.deploymentProductionBranchGlob);
3523
3612
  if (options.private !== void 0) body.private = options.private === "inherit" ? null : toBoolean(options.private);
3524
3613
  if (options.summaryCheck !== void 0) body.summaryCheck = options.summaryCheck;
@@ -3539,7 +3628,7 @@ async function loadIgnoreConfig(client, owner, project) {
3539
3628
  } } })).ignoreConfig;
3540
3629
  }
3541
3630
  function registerProjectUpdate(project) {
3542
- project.command("update").description("Update a project's settings. Only the settings you pass are changed").option("--name <name>", "Rename the project").option("--default-base-branch <branch>", "Branch used as the baseline when no better one applies. Pass an empty string to fall back to the repository default").option("--auto-approved-branch-glob <glob>", "Glob matching the branches whose builds are approved automatically. Pass an empty string to fall back to the default base branch").option("--deployment-production-branch-glob <glob>", "Glob matching the branches whose deployments count as production. Pass an empty string to fall back to the repository default").addOption(new Option("--private <value>", "Force the project's privacy, or inherit it from the linked repository").choices([...BOOLEAN_CHOICES, "inherit"])).addOption(new Option("--summary-check <mode>", "When to post the summary check on a pull request").choices(SUMMARY_CHECKS)).addOption(new Option("--default-user-level <level>", "Access given to team members that are not contributors on this project").choices([...PROJECT_USER_LEVELS, "none"])).addOption(new Option("--ignore-changes <value>", "Whether changes can be ignored on this project").choices(BOOLEAN_CHOICES)).option("--auto-ignore-after <changes>", "Ignore a change automatically once it has reappeared this many times, or \"off\"").addOption(new Option("--deployments <value>", "Whether deployments are served for this project").choices(BOOLEAN_CHOICES)).addOption(new Option("--deployment-auth <mode>", "Who can reach the project's deployments").choices(DEPLOYMENT_AUTHS)).addOption(new Option("--github-actions-oidc <value>", "Whether builds can authenticate with a GitHub Actions OIDC token").choices(BOOLEAN_CHOICES)).addOption(new Option("--tokenless-auth <value>", "Whether builds from forked pull requests can be uploaded without a token").choices(BOOLEAN_CHOICES)).addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
3631
+ project.command("update").description("Update a project's settings. Only the settings you pass are changed").option("--name <name>", "Rename the project").option("--default-base-branch <branch>", "Branch used as the baseline when no better one applies. Pass an empty string to fall back to the repository default").option("--auto-approved-branch-glob <glob>", "Glob matching the branches whose builds are approved automatically. Pass an empty string to fall back to the default base branch").addOption(new Option("--auto-approval <value>", "Whether builds on branches matching the auto-approved glob are approved automatically. Pass false to review every build, base branch included; the glob is kept").choices(BOOLEAN_CHOICES)).option("--deployment-production-branch-glob <glob>", "Glob matching the branches whose deployments count as production. Pass an empty string to fall back to the repository default").addOption(new Option("--private <value>", "Force the project's privacy, or inherit it from the linked repository").choices([...BOOLEAN_CHOICES, "inherit"])).addOption(new Option("--summary-check <mode>", "When to post the summary check on a pull request").choices(SUMMARY_CHECKS)).addOption(new Option("--default-user-level <level>", "Access given to team members that are not contributors on this project").choices([...PROJECT_USER_LEVELS, "none"])).addOption(new Option("--ignore-changes <value>", "Whether changes can be ignored on this project").choices(BOOLEAN_CHOICES)).option("--auto-ignore-after <changes>", "Ignore a change automatically once it has reappeared this many times, or \"off\"").addOption(new Option("--deployments <value>", "Whether deployments are served for this project").choices(BOOLEAN_CHOICES)).addOption(new Option("--deployment-auth <mode>", "Who can reach the project's deployments").choices(DEPLOYMENT_AUTHS)).addOption(new Option("--github-actions-oidc <value>", "Whether builds can authenticate with a GitHub Actions OIDC token").choices(BOOLEAN_CHOICES)).addOption(new Option("--tokenless-auth <value>", "Whether builds from forked pull requests can be uploaded without a token").choices(BOOLEAN_CHOICES)).addOption(managedProjectPathOption).addOption(tokenOption).addOption(jsonOption).action((options) => runProjectAction({
3543
3632
  options,
3544
3633
  auth: "user",
3545
3634
  handler: async ({ client, owner, project: name }) => {
@@ -3556,19 +3645,18 @@ function registerProjectUpdate(project) {
3556
3645
  format: formatProject
3557
3646
  }));
3558
3647
  }
3559
- //#endregion
3560
- //#region src/commands/project/index.ts
3648
+ // src/commands/project/index.ts
3561
3649
  function projectCommand(program) {
3562
- const project = program.command("project").description("Inspect and configure a project: settings, contributors, deployments, and its deployment domain");
3650
+ const project = program.command("project").description("Inspect and configure a project: settings, contributors, tokens, deployments, and its deployment domain");
3563
3651
  registerProjectGet(project);
3564
3652
  registerProjectUpdate(project);
3565
3653
  registerProjectTransfer(project);
3566
3654
  registerProjectContributor(project);
3655
+ registerProjectToken(project);
3567
3656
  registerProjectDeployments(project);
3568
3657
  registerProjectDomain(project);
3569
3658
  }
3570
- //#endregion
3571
- //#region src/commands/automation/_definition.ts
3659
+ // src/commands/automation/_definition.ts
3572
3660
  /**
3573
3661
  * Resolve an automation rule definition from the mutually-exclusive
3574
3662
  * `--definition` (inline JSON) and `--definition-file` (path) options.
@@ -3593,8 +3681,7 @@ async function resolveDefinition(options) {
3593
3681
  fail(`Invalid rule definition JSON: ${error instanceof Error ? error.message : String(error)}`);
3594
3682
  }
3595
3683
  }
3596
- //#endregion
3597
- //#region src/commands/automation/index.ts
3684
+ // src/commands/automation/index.ts
3598
3685
  const ACTIVE_CHOICES = ["true", "false"];
3599
3686
  const definitionOption = new Option("--definition <json>", "Rule definition as JSON: name, events, conditions, actions");
3600
3687
  const definitionFileOption = new Option("--definition-file <path>", "Read the rule definition from a JSON file");
@@ -3674,8 +3761,7 @@ function automationCommand(program) {
3674
3761
  format: formatAutomationRule
3675
3762
  }));
3676
3763
  }
3677
- //#endregion
3678
- //#region src/lib/docs.ts
3764
+ // src/lib/docs.ts
3679
3765
  /**
3680
3766
  * Searching the Argos documentation.
3681
3767
  *
@@ -3777,8 +3863,7 @@ async function searchDocs(query, options) {
3777
3863
  if (message.error || message.result?.isError) fail(`The documentation search failed: ${sanitizeTerminalText(message.error ? message.error.message : content.map((block) => block.text ?? "").join(" ")) || "unknown error"}`);
3778
3864
  return parseDocsSearchContent(content).slice(0, options.limit);
3779
3865
  }
3780
- //#endregion
3781
- //#region src/commands/docs/search.ts
3866
+ // src/commands/docs/search.ts
3782
3867
  const DEFAULT_DOCS_LIMIT = 5;
3783
3868
  function registerDocsSearch(docs) {
3784
3869
  docs.command("search").description(`Search the Argos documentation (${DOCS_URL})`).argument("<query...>", "What to look for, e.g. \"parallel builds\"").addOption(new Option("--limit <number>", `Maximum number of results, up to 10`).default(String(DEFAULT_DOCS_LIMIT))).addOption(jsonOption).addHelpText("after", [
@@ -3798,13 +3883,11 @@ function registerDocsSearch(docs) {
3798
3883
  }
3799
3884
  });
3800
3885
  }
3801
- //#endregion
3802
- //#region src/commands/docs/index.ts
3886
+ // src/commands/docs/index.ts
3803
3887
  function docsCommand(program) {
3804
3888
  registerDocsSearch(program.command("docs").description("Search the Argos documentation from the terminal"));
3805
3889
  }
3806
- //#endregion
3807
- //#region src/index.ts
3890
+ // src/index.ts
3808
3891
  const __dirname = fileURLToPath(new URL(".", import.meta.url));
3809
3892
  const rawPkg = await readFile(resolve(__dirname, "..", "package.json"), "utf8");
3810
3893
  const pkg = JSON.parse(rawPkg);
@@ -3832,5 +3915,4 @@ automationCommand(program);
3832
3915
  docsCommand(program);
3833
3916
  if (!process.argv.slice(2).length) program.outputHelp();
3834
3917
  else program.parse(process.argv);
3835
- //#endregion
3836
3918
  export {};