@theholocron/cli 5.0.0-alpha.523 → 5.0.0-alpha.524

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.
package/dist/cli.mjs CHANGED
@@ -139,6 +139,7 @@ const COMMAND_CONTEXTS = {
139
139
  "cleanup branches": "workspace",
140
140
  "sync github": "workspace",
141
141
  "sync issues": "workspace",
142
+ "sync incidents": "workspace",
142
143
  "sync ideas": "workspace",
143
144
  "sync tooling": "workspace",
144
145
  "sync requests": "workspace",
@@ -1973,6 +1974,20 @@ const syncGithubEntry = {
1973
1974
  ],
1974
1975
  supportsDryRun: true
1975
1976
  };
1977
+ // src/commands/sync-incidents/sync-incidents.entry.ts
1978
+ const syncIncidentsEntry = {
1979
+ name: "sync incidents",
1980
+ description: "Mirror a status page's incidents into a Discord forum, one post each",
1981
+ positionals: [],
1982
+ options: [{
1983
+ key: "since",
1984
+ flag: "--since",
1985
+ type: "input",
1986
+ message: "Also read incidents resolved since (2d, 2026-03-01):"
1987
+ }],
1988
+ skipOptions: ["provider", "yes"],
1989
+ supportsDryRun: true
1990
+ };
1976
1991
  // src/commands/sync-issues/sync-issues.entry.ts
1977
1992
  const syncIssuesEntry = {
1978
1993
  name: "sync issues",
@@ -2219,6 +2234,7 @@ const registry = createCommandRegistry([
2219
2234
  runCiEntry,
2220
2235
  syncGithubEntry,
2221
2236
  syncIssuesEntry,
2237
+ syncIncidentsEntry,
2222
2238
  ideasSyncEntry,
2223
2239
  syncToolingEntry,
2224
2240
  syncRequestsEntry,
@@ -8511,7 +8527,7 @@ function forumChannel(layout, wanted) {
8511
8527
  const found = forums.find((c) => c.name.toLowerCase() === wanted.toLowerCase());
8512
8528
  return found ? { channel: found.name } : { problem: `the layout declares no forum named \`${wanted}\` -- add it with \`kind: "forum"\`` };
8513
8529
  }
8514
- const documents = forums.filter((c) => !c.feeds?.prs);
8530
+ const documents = forums.filter((c) => !c.feeds?.prs && !c.feeds?.incidents);
8515
8531
  if (documents.length === 1) return { channel: documents[0].name };
8516
8532
  return { problem: documents.length === 0 ? "the layout declares no forum channel -- add one with `kind: \"forum\"`" : `the layout declares several forums (${documents.map((c) => `\`${c.name}\``).join(", ")}) -- pass --channel` };
8517
8533
  }
@@ -13032,6 +13048,61 @@ function emojiChecks(input) {
13032
13048
  });
13033
13049
  return [resultRow("emoji", TITLE, problems, `${wanted.length} of ${wanted.length} on the server`)];
13034
13050
  }
13051
+ // src/commands/forum-feed-checks/forum-feed-checks.ts
13052
+ const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
13053
+ const shown$6 = (s) => sanitizeDetail(s);
13054
+ /**
13055
+ * The steps of `doctor notifications` for a forum feed (`feeds.prs`, `feeds.incidents`): the forum is there (in its
13056
+ * category, as a forum), it holds a tag for every state a post can be in, and the bot can start posts and manage their
13057
+ * threads in it (read from `inspect`, after the channel's own overwrites). Read-only. No rows when no channel has the
13058
+ * feed.
13059
+ */
13060
+ function forumFeedChecks(input, spec) {
13061
+ const { layout, found } = input;
13062
+ const forumTitle = `${spec.label} forum exists`;
13063
+ const tagsTitle = `${spec.label} forum has the tags of every state`;
13064
+ const botTitle = `bot can post in the ${spec.label} forum and manage its threads`;
13065
+ const fed = (layout.categories ?? []).flatMap((cat) => (cat.channels ?? []).map((channel) => ({
13066
+ cat: cat.name,
13067
+ channel
13068
+ }))).filter(({ channel }) => channel.feeds?.[spec.feed]);
13069
+ if (fed.length === 0) return [];
13070
+ if (!found) {
13071
+ const reason = "not checked: could not read the server";
13072
+ return [
13073
+ skipRow$1(spec.ids.forum, forumTitle, reason),
13074
+ skipRow$1(spec.ids.tags, tagsTitle, reason),
13075
+ skipRow$1(spec.ids.bot, botTitle, reason)
13076
+ ];
13077
+ }
13078
+ const forumProblems = [];
13079
+ const tagProblems = [];
13080
+ const botProblems = [];
13081
+ for (const { cat, channel } of fed) {
13082
+ const name = shown$6(channel.name);
13083
+ const have = found.channels.find((c) => same$5(c.name, channel.name) && c.category !== void 0 && same$5(c.category, cat));
13084
+ if (!have) {
13085
+ forumProblems.push(`#${name}: missing from ${shown$6(cat)}`);
13086
+ continue;
13087
+ }
13088
+ if (have.kind !== "forum") {
13089
+ forumProblems.push(`#${name}: is a text channel, not a forum; delete it so \`setup\` can make it again`);
13090
+ continue;
13091
+ }
13092
+ for (const tag of spec.tags) if (!have.tags?.some((t) => same$5(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
13093
+ if (have.botThreadsError) botProblems.push(`#${name}: could not read the bot's permissions (${shown$6(have.botThreadsError)})`);
13094
+ else if (have.botThreads) {
13095
+ if (!have.botThreads.post) botProblems.push(`#${name}: the bot cannot start posts or reply in it`);
13096
+ if (!have.botThreads.manage) botProblems.push(`#${name}: the bot cannot manage threads in it (Manage Threads)`);
13097
+ } else botProblems.push(`#${name}: the provider did not report the bot's permissions`);
13098
+ }
13099
+ const ok = `${fed.length} of ${fed.length} as declared`;
13100
+ return [
13101
+ resultRow(spec.ids.forum, forumTitle, forumProblems, ok),
13102
+ resultRow(spec.ids.tags, tagsTitle, tagProblems, ok),
13103
+ resultRow(spec.ids.bot, botTitle, botProblems, ok)
13104
+ ];
13105
+ }
13035
13106
  // src/commands/notifications-setup/layout-picture-problem/layout-picture-problem.ts
13036
13107
  /** The first reason a picture in the layout (`webhookAvatar`, a channel's `webhook.avatar`) cannot work, or undefined. */
13037
13108
  function layoutPictureProblem(layout) {
@@ -13152,7 +13223,7 @@ function newRelaySecret() {
13152
13223
  return randomBytes(32).toString("hex");
13153
13224
  }
13154
13225
  // src/commands/relay-sources/relay-source-checks.ts
13155
- const shown$6 = (s) => sanitizeDetail(s);
13226
+ const shown$5 = (s) => sanitizeDetail(s);
13156
13227
  const missingFrom = (wanted, held) => wanted && held ? wanted.filter((w) => !held.includes(w)) : [];
13157
13228
  /**
13158
13229
  * The steps of `doctor notifications` that check each relay source's webhook at the vendor (`relay-source:<id>`): it
@@ -13167,7 +13238,7 @@ async function relaySourceChecks(input) {
13167
13238
  for (const source of declaredRelaySources(layout)) {
13168
13239
  const { id, spec } = source;
13169
13240
  const rowId = `relay-source:${id}`;
13170
- const title = `${shown$6(id)} webhook at the vendor posts to the relay`;
13241
+ const title = `${shown$5(id)} webhook at the vendor posts to the relay`;
13171
13242
  if (!host) {
13172
13243
  rows.push(skipRow$1(rowId, title, "no `relay.host` is declared"));
13173
13244
  continue;
@@ -13192,19 +13263,19 @@ async function relaySourceChecks(input) {
13192
13263
  ...spec.options ? { options: spec.options } : {}
13193
13264
  });
13194
13265
  const problems = [];
13195
- if (!state.exists) problems.push(`no ${shown$6(provider.providerName)} webhook posts to ${shown$6(url)}`);
13266
+ if (!state.exists) problems.push(`no ${shown$5(provider.providerName)} webhook posts to ${shown$5(url)}`);
13196
13267
  else {
13197
13268
  if (state.enabled === false) problems.push("the webhook is switched off");
13198
13269
  const events = missingFrom(spec.events, state.events);
13199
- if (events.length > 0) problems.push(`not subscribed to ${events.map(shown$6).join(", ")}`);
13270
+ if (events.length > 0) problems.push(`not subscribed to ${events.map(shown$5).join(", ")}`);
13200
13271
  const scope = missingFrom(spec.scope, state.scope);
13201
- if (scope.length > 0) problems.push(`does not cover ${scope.map(shown$6).join(", ")}`);
13272
+ if (scope.length > 0) problems.push(`does not cover ${scope.map(shown$5).join(", ")}`);
13202
13273
  if (state.hasSecret === false) problems.push("the webhook has no signing secret");
13203
13274
  }
13204
- rows.push(resultRow(rowId, title, problems, `${shown$6(provider.providerName)} posts to ${shown$6(url)}`));
13275
+ rows.push(resultRow(rowId, title, problems, `${shown$5(provider.providerName)} posts to ${shown$5(url)}`));
13205
13276
  } catch (err) {
13206
13277
  const noToken = missingTokenReason(err);
13207
- rows.push(noToken !== void 0 ? skipRow$1(rowId, title, noToken) : resultRow(rowId, title, [shown$6(describeError(err))], ""));
13278
+ rows.push(noToken !== void 0 ? skipRow$1(rowId, title, noToken) : resultRow(rowId, title, [shown$5(describeError(err))], ""));
13208
13279
  }
13209
13280
  }
13210
13281
  return rows;
@@ -13550,6 +13621,14 @@ const PR_FEED_TAGS = [
13550
13621
  "merged",
13551
13622
  "closed"
13552
13623
  ];
13624
+ /** The states an incident's post can be tagged with, so a forum with `feeds.incidents` must have all of them (lower case). */
13625
+ const INCIDENT_FEED_TAGS = [
13626
+ "investigating",
13627
+ "identified",
13628
+ "monitoring",
13629
+ "resolved",
13630
+ "maintenance"
13631
+ ];
13553
13632
  /**
13554
13633
  * The first reason a channel's `kind` and `tags` cannot work, or undefined. A forum takes no webhook or webhook feed (its
13555
13634
  * conversations are posts, which a plain webhook post cannot start); `feeds.prs` is the one feed a forum takes, and only
@@ -13567,6 +13646,7 @@ function forumLayoutProblem(layout) {
13567
13646
  if (channel.tags) return `${where}: \`tags\` belong to a forum -- set \`kind: "forum"\` or remove them`;
13568
13647
  if (channel.defaultReaction || channel.starterReactions) return `${where}: reactions belong to a forum -- set \`kind: "forum"\` or remove them`;
13569
13648
  if (channel.feeds?.prs) return `${where}: \`feeds.prs\` belongs to a forum, where each pull request is a post -- set \`kind: "forum"\` or remove it`;
13649
+ if (channel.feeds?.incidents) return `${where}: \`feeds.incidents\` belongs to a forum, where each incident is a post -- set \`kind: "forum"\` or remove it`;
13570
13650
  continue;
13571
13651
  }
13572
13652
  if (channel.webhook || channel.feeds?.monitoring || channel.feeds?.errors || Object.values(channel.feeds?.relay ?? {}).some(Boolean)) return `${where}: a forum takes no \`webhook\` or the \`monitoring\` and \`errors\` feeds (nor \`relay\` ones); its conversations are posts`;
@@ -13587,10 +13667,15 @@ function forumLayoutProblem(layout) {
13587
13667
  const emojiProblem = tagEmojiProblem(tag.name, tag.emoji, pictured);
13588
13668
  if (emojiProblem) return `${where}: ${emojiProblem}`;
13589
13669
  }
13670
+ if (channel.feeds?.prs && channel.feeds.incidents) return `${where}: a forum carries one feed; \`feeds.prs\` and \`feeds.incidents\` need separate forums`;
13590
13671
  if (channel.feeds?.prs) {
13591
13672
  const missing = PR_FEED_TAGS.filter((tag) => !seen.has(tag));
13592
13673
  if (missing.length > 0) return `${where}: \`feeds.prs\` needs the tags ${missing.map((t) => `\`${t}\``).join(", ")}; add them to \`tags\``;
13593
13674
  }
13675
+ if (channel.feeds?.incidents) {
13676
+ const missing = INCIDENT_FEED_TAGS.filter((tag) => !seen.has(tag));
13677
+ if (missing.length > 0) return `${where}: \`feeds.incidents\` needs the tags ${missing.map((t) => `\`${t}\``).join(", ")}; add them to \`tags\``;
13678
+ }
13594
13679
  }
13595
13680
  for (const emoji of layout.emojis ?? []) {
13596
13681
  const problem = reactionProblem("an `emojis` entry", emoji);
@@ -14214,6 +14299,24 @@ async function runNotificationsSetup(input$1) {
14214
14299
  }, "setup notifications");
14215
14300
  return report;
14216
14301
  }
14302
+ // src/commands/incident-feed-checks/incident-feed-checks.ts
14303
+ /**
14304
+ * The steps of `doctor notifications` for the status page incident feed (`feeds.incidents`): the forum is there, it holds
14305
+ * a tag for every state an incident's post can be in, and the bot can start posts and manage their threads in it.
14306
+ * Read-only. No rows when no channel has `feeds.incidents`.
14307
+ */
14308
+ function incidentFeedChecks(input) {
14309
+ return forumFeedChecks(input, {
14310
+ feed: "incidents",
14311
+ ids: {
14312
+ forum: "incident-feed-forum",
14313
+ tags: "incident-feed-tags",
14314
+ bot: "incident-feed-bot"
14315
+ },
14316
+ label: "incident feed",
14317
+ tags: INCIDENT_FEED_TAGS
14318
+ });
14319
+ }
14217
14320
  // src/commands/monitoring-feed-checks/monitoring-feed-checks.ts
14218
14321
  const WEBHOOK_ID$1 = "monitoring-feed-webhook";
14219
14322
  const WEBHOOK_TITLE$1 = "monitoring feed webhook exists and has a picture";
@@ -14221,8 +14324,8 @@ const CHANNEL_ID = "monitoring-alert-channel";
14221
14324
  const CHANNEL_TITLE = "monitoring alert channel posts through the feed webhook";
14222
14325
  const SUBSCRIPTIONS_ID = "monitoring-subscriptions";
14223
14326
  const SUBSCRIPTIONS_TITLE = "monitoring alert channel is subscribed to the checks routed to it";
14224
- const same$5 = (a, b) => a.toLowerCase() === b.toLowerCase();
14225
- const shown$5 = (s) => sanitizeDetail(s);
14327
+ const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
14328
+ const shown$4 = (s) => sanitizeDetail(s);
14226
14329
  const skipAll = (reason) => [
14227
14330
  skipRow$1(WEBHOOK_ID$1, WEBHOOK_TITLE$1, reason),
14228
14331
  skipRow$1(CHANNEL_ID, CHANNEL_TITLE, reason),
@@ -14249,14 +14352,14 @@ async function monitoringFeedChecks(input) {
14249
14352
  let channelSkip;
14250
14353
  for (const { channel, feed } of fed) {
14251
14354
  const names = monitoringFeed(channel.name, feed, monitoring);
14252
- const where = found.channels.find((c) => same$5(c.name, channel.name));
14355
+ const where = found.channels.find((c) => same$4(c.name, channel.name));
14253
14356
  const hookId = where?.webhookIds?.[names.webhook.toLowerCase()];
14254
- const named = where?.webhooks.some((w) => same$5(w, names.webhook)) ?? false;
14255
- const label = `#${shown$5(channel.name)}`;
14357
+ const named = where?.webhooks.some((w) => same$4(w, names.webhook)) ?? false;
14358
+ const label = `#${shown$4(channel.name)}`;
14256
14359
  if (!where) webhookProblems.push(`${label}: no channel to hold the feed webhook`);
14257
- else if (where.webhooksError) webhookProblems.push(`${label}: could not list its webhooks (${shown$5(where.webhooksError)})`);
14258
- else if (!named) webhookProblems.push(`${label}: no webhook named ${shown$5(names.webhook)}`);
14259
- else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$5(w, names.webhook))) webhookProblems.push(`${label}: webhook ${shown$5(names.webhook)} has no picture`);
14360
+ else if (where.webhooksError) webhookProblems.push(`${label}: could not list its webhooks (${shown$4(where.webhooksError)})`);
14361
+ else if (!named) webhookProblems.push(`${label}: no webhook named ${shown$4(names.webhook)}`);
14362
+ else if (feedAvatarOf(layout, feed, monitoring).length > 0 && !where.webhookAvatars?.some((w) => same$4(w, names.webhook))) webhookProblems.push(`${label}: webhook ${shown$4(names.webhook)} has no picture`);
14260
14363
  if (channelSkip !== void 0) continue;
14261
14364
  if (!monitoring.inspectAlertChannel) {
14262
14365
  channelSkip = `the \`${monitoring.providerName}\` provider cannot read its alert channels`;
@@ -14271,24 +14374,24 @@ async function monitoringFeedChecks(input) {
14271
14374
  channelSkip = noToken;
14272
14375
  continue;
14273
14376
  }
14274
- channelProblems.push(`${label}: ${shown$5(describeError(err))}`);
14377
+ channelProblems.push(`${label}: ${shown$4(describeError(err))}`);
14275
14378
  continue;
14276
14379
  }
14277
14380
  if (!state.exists) {
14278
- channelProblems.push(`${label}: missing alert channel ${shown$5(names.name)}`);
14381
+ channelProblems.push(`${label}: missing alert channel ${shown$4(names.name)}`);
14279
14382
  continue;
14280
14383
  }
14281
- if (!state.discord) channelProblems.push(`${label}: ${shown$5(names.name)} is not formatted for Discord`);
14282
- if (!state.webhookId) channelProblems.push(`${label}: ${shown$5(names.name)} does not post to a Discord webhook URL`);
14283
- else if (hookId !== void 0 && state.webhookId !== hookId) channelProblems.push(`${label}: ${shown$5(names.name)} posts through a different webhook than ${shown$5(names.webhook)}`);
14384
+ if (!state.discord) channelProblems.push(`${label}: ${shown$4(names.name)} is not formatted for Discord`);
14385
+ if (!state.webhookId) channelProblems.push(`${label}: ${shown$4(names.name)} does not post to a Discord webhook URL`);
14386
+ else if (hookId !== void 0 && state.webhookId !== hookId) channelProblems.push(`${label}: ${shown$4(names.name)} posts through a different webhook than ${shown$4(names.webhook)}`);
14284
14387
  for (const [key, want] of Object.entries(names.alerts ?? {})) {
14285
14388
  const have = state.alerts?.[key];
14286
- if (have !== want) channelProblems.push(`${label}: ${shown$5(names.name)} ${key} is ${String(have)}, declared ${String(want)}`);
14389
+ if (have !== want) channelProblems.push(`${label}: ${shown$4(names.name)} ${key} is ${String(have)}, declared ${String(want)}`);
14287
14390
  }
14288
- for (const check of state.unsubscribed) subscriptionProblems.push(`${label}: ${shown$5(names.name)} is not subscribed to ${shown$5(check)}`);
14289
- for (const check of state.misrouted) subscriptionProblems.push(`${label}: ${shown$5(names.name)} is still subscribed to ${shown$5(check)}, which is routed elsewhere`);
14290
- if (state.groupSubscriptions) subscriptionProblems.push(`${label}: ${shown$5(names.name)} is subscribed to ${state.groupSubscriptions} check group(s), which alert for every check in them, including any routed elsewhere; which checks a group holds cannot be read, so check them in ${shown$5(monitoring.providerName)}`);
14291
- for (const check of state.deactivated) subscriptionProblems.push(`${label}: ${shown$5(names.name)} has ${shown$5(check)} switched off`);
14391
+ for (const check of state.unsubscribed) subscriptionProblems.push(`${label}: ${shown$4(names.name)} is not subscribed to ${shown$4(check)}`);
14392
+ for (const check of state.misrouted) subscriptionProblems.push(`${label}: ${shown$4(names.name)} is still subscribed to ${shown$4(check)}, which is routed elsewhere`);
14393
+ if (state.groupSubscriptions) subscriptionProblems.push(`${label}: ${shown$4(names.name)} is subscribed to ${state.groupSubscriptions} check group(s), which alert for every check in them, including any routed elsewhere; which checks a group holds cannot be read, so check them in ${shown$4(monitoring.providerName)}`);
14394
+ for (const check of state.deactivated) subscriptionProblems.push(`${label}: ${shown$4(names.name)} has ${shown$4(check)} switched off`);
14292
14395
  }
14293
14396
  const n = fed.length;
14294
14397
  return [resultRow(WEBHOOK_ID$1, WEBHOOK_TITLE$1, webhookProblems, `${n} of ${n} as declared`), ...channelSkip === void 0 ? [resultRow(CHANNEL_ID, CHANNEL_TITLE, channelProblems, `${n} of ${n} as declared`), resultRow(SUBSCRIPTIONS_ID, SUBSCRIPTIONS_TITLE, subscriptionProblems, `${n} of ${n} subscribed`)] : [skipRow$1(CHANNEL_ID, CHANNEL_TITLE, channelSkip), skipRow$1(SUBSCRIPTIONS_ID, SUBSCRIPTIONS_TITLE, channelSkip)]];
@@ -14871,7 +14974,7 @@ const WIRED_ID = "notifications-workflow-wiring";
14871
14974
  const WIRED_TITLE = "Notifications workflow posts through the layout's webhooks";
14872
14975
  const NAMES_ID = "notifications-workflow-names";
14873
14976
  const NAMES_TITLE = "Notifications workflow lists only task ids";
14874
- const shown$4 = (s) => sanitizeDetail(s);
14977
+ const shown$3 = (s) => sanitizeDetail(s);
14875
14978
  const upper = (names) => new Set(names.map((n) => n.toUpperCase()));
14876
14979
  /**
14877
14980
  * The steps of `doctor notifications` that check the workflow which posts failed runs and releases: the file is on
@@ -14896,7 +14999,7 @@ async function notificationsWorkflowChecks(input) {
14896
14999
  try {
14897
15000
  text = (await source.readFile(NOTIFICATIONS_WORKFLOW_PATH))?.content;
14898
15001
  } catch (err) {
14899
- const reason = shown$4(describeError(err));
15002
+ const reason = shown$3(describeError(err));
14900
15003
  return [
14901
15004
  {
14902
15005
  id: PRESENT_ID,
@@ -14916,7 +15019,7 @@ async function notificationsWorkflowChecks(input) {
14916
15019
  ];
14917
15020
  const read = [...text.matchAll(/secrets\.(HOLOCRON_NOTIFY_[A-Z0-9_]+)/g)].map((m) => m[1]);
14918
15021
  const readSet = upper(read);
14919
- const problems = [...[...new Set(read)].filter((name) => !filled.has(name.toUpperCase())).map((name) => `${shown$4(name)}: the workflow reads it but the layout fills no such secret`), ...wired.filter((name) => !readSet.has(name)).map((name) => `${name}: the layout fills it but the workflow never posts through it`)];
15022
+ const problems = [...[...new Set(read)].filter((name) => !filled.has(name.toUpperCase())).map((name) => `${shown$3(name)}: the workflow reads it but the layout fills no such secret`), ...wired.filter((name) => !readSet.has(name)).map((name) => `${name}: the layout fills it but the workflow never posts through it`)];
14920
15023
  return [
14921
15024
  resultRow(PRESENT_ID, PRESENT_TITLE, [], "found"),
14922
15025
  resultRow(WIRED_ID, WIRED_TITLE, problems, `${wired.length} of ${wired.length} wired`),
@@ -14957,11 +15060,6 @@ async function postDoctorReport(notifications, channel, report, name = "notifica
14957
15060
  }
14958
15061
  }
14959
15062
  // src/commands/pr-feed-checks/pr-feed-checks.ts
14960
- const FORUM_TITLE = "pull request feed forum exists";
14961
- const TAGS_TITLE = "pull request feed forum has the tags of every state";
14962
- const BOT_TITLE = "bot can post in the pull request feed forum and manage its threads";
14963
- const same$4 = (a, b) => a.toLowerCase() === b.toLowerCase();
14964
- const shown$3 = (s) => sanitizeDetail(s);
14965
15063
  /**
14966
15064
  * The steps of `doctor notifications` for the pull-request feed (`feeds.prs`): the forum is there (in its category, as a
14967
15065
  * forum), it holds a tag for every state a pull request's post can be in, and the bot can start posts and manage their
@@ -14969,47 +15067,16 @@ const shown$3 = (s) => sanitizeDetail(s);
14969
15067
  * `feeds.prs`.
14970
15068
  */
14971
15069
  function prFeedChecks(input) {
14972
- const { layout, found } = input;
14973
- const fed = (layout.categories ?? []).flatMap((cat) => (cat.channels ?? []).map((channel) => ({
14974
- cat: cat.name,
14975
- channel
14976
- }))).filter(({ channel }) => channel.feeds?.prs);
14977
- if (fed.length === 0) return [];
14978
- if (!found) {
14979
- const reason = "not checked: could not read the server";
14980
- return [
14981
- skipRow$1("pr-feed-forum", FORUM_TITLE, reason),
14982
- skipRow$1("pr-feed-tags", TAGS_TITLE, reason),
14983
- skipRow$1("pr-feed-bot", BOT_TITLE, reason)
14984
- ];
14985
- }
14986
- const forumProblems = [];
14987
- const tagProblems = [];
14988
- const botProblems = [];
14989
- for (const { cat, channel } of fed) {
14990
- const name = shown$3(channel.name);
14991
- const have = found.channels.find((c) => same$4(c.name, channel.name) && c.category !== void 0 && same$4(c.category, cat));
14992
- if (!have) {
14993
- forumProblems.push(`#${name}: missing from ${shown$3(cat)}`);
14994
- continue;
14995
- }
14996
- if (have.kind !== "forum") {
14997
- forumProblems.push(`#${name}: is a text channel, not a forum; delete it so \`setup\` can make it again`);
14998
- continue;
14999
- }
15000
- for (const tag of PR_FEED_TAGS) if (!have.tags?.some((t) => same$4(t.name, tag))) tagProblems.push(`#${name}: tag "${tag}" is missing`);
15001
- if (have.botThreadsError) botProblems.push(`#${name}: could not read the bot's permissions (${shown$3(have.botThreadsError)})`);
15002
- else if (have.botThreads) {
15003
- if (!have.botThreads.post) botProblems.push(`#${name}: the bot cannot start posts or reply in it`);
15004
- if (!have.botThreads.manage) botProblems.push(`#${name}: the bot cannot manage threads in it (Manage Threads)`);
15005
- } else botProblems.push(`#${name}: the provider did not report the bot's permissions`);
15006
- }
15007
- const ok = `${fed.length} of ${fed.length} as declared`;
15008
- return [
15009
- resultRow("pr-feed-forum", FORUM_TITLE, forumProblems, ok),
15010
- resultRow("pr-feed-tags", TAGS_TITLE, tagProblems, ok),
15011
- resultRow("pr-feed-bot", BOT_TITLE, botProblems, ok)
15012
- ];
15070
+ return forumFeedChecks(input, {
15071
+ feed: "prs",
15072
+ ids: {
15073
+ forum: "pr-feed-forum",
15074
+ tags: "pr-feed-tags",
15075
+ bot: "pr-feed-bot"
15076
+ },
15077
+ label: "pull request feed",
15078
+ tags: PR_FEED_TAGS
15079
+ });
15013
15080
  }
15014
15081
  // src/commands/relay-checks/relay-checks.ts
15015
15082
  /** How long to wait for the Worker before calling it unreachable. */
@@ -15675,6 +15742,10 @@ async function runDoctorNotifications(input) {
15675
15742
  layout,
15676
15743
  found
15677
15744
  }));
15745
+ checks.push(...incidentFeedChecks({
15746
+ layout,
15747
+ found
15748
+ }));
15678
15749
  checks.push(...await notificationsWorkflowChecks({
15679
15750
  layout,
15680
15751
  source: loader.has("source") ? loader.get("source") : void 0,
@@ -33073,7 +33144,7 @@ function parseSince(value, now = Date.now()) {
33073
33144
  * printed. It asks once before redelivering unless `--yes`; without a terminal that is a `NonInteractiveError`, except on
33074
33145
  * `--dry-run`, which lists what it would redeliver and calls nothing that writes.
33075
33146
  */
33076
- const DEFAULT_SINCE = "1d";
33147
+ const DEFAULT_SINCE$1 = "1d";
33077
33148
  const defaultApi = {
33078
33149
  listAppDeliveries,
33079
33150
  redeliverAppDelivery
@@ -33116,7 +33187,7 @@ async function runRedeliverWebhooks(input) {
33116
33187
  print("");
33117
33188
  let since;
33118
33189
  try {
33119
- since = parseSince(input.since ?? DEFAULT_SINCE, (input.now ?? Date.now)());
33190
+ since = parseSince(input.since ?? DEFAULT_SINCE$1, (input.now ?? Date.now)());
33120
33191
  } catch (error) {
33121
33192
  return fail("since", describeError(error).replace(/^sync issues: /, ""));
33122
33193
  }
@@ -34894,6 +34965,354 @@ const syncGithubCommand = {
34894
34965
  })).status === "fail") process.exitCode = 1;
34895
34966
  }
34896
34967
  };
34968
+ // src/commands/incident-markers/incident-markers.ts
34969
+ /** The key of an incident's post in the forum: the status page's name and the incident's id. */
34970
+ function incidentKey(statusPage, incidentId) {
34971
+ return `${statusPage}#${incidentId}`;
34972
+ }
34973
+ /** The footer line that ends an incident's first message, so the incident can be recognised in its post. */
34974
+ function incidentMarker(incidentId) {
34975
+ return `-# incident: ${incidentId}`;
34976
+ }
34977
+ /** The footer line that ends the message an update produced, so a rerun does not post it again. */
34978
+ function updateMarker(updateId) {
34979
+ return `-# update: ${updateId}`;
34980
+ }
34981
+ /** The ids of the updates already posted, read from a post's messages (any order). */
34982
+ function postedUpdateIds(messages) {
34983
+ const ids = /* @__PURE__ */ new Set();
34984
+ for (const message of messages) for (const line of message.split("\n")) {
34985
+ const match = /^-# update: (\S+)\s*$/.exec(line);
34986
+ if (match?.[1]) ids.add(match[1]);
34987
+ }
34988
+ return ids;
34989
+ }
34990
+ // src/commands/plan-incident-feed/plan-incident-feed.ts
34991
+ /**
34992
+ * What a run does for one incident (spec `tech-incidents-to-discord`): make the post if there is none, append each
34993
+ * update whose marker is not in the post, rewrite the summary, title and tag when the incident changed, and close the
34994
+ * post once it is resolved (or open it again when a resolved incident is reopened). Pure: a rerun with nothing new plans
34995
+ * nothing. An update already posted is never rewritten, even when its text was edited on the page; only the summary,
34996
+ * which is rebuilt from the current data, follows an edit.
34997
+ */
34998
+ function planIncidentFeed(input) {
34999
+ const { incident, rendered, post, messages } = input;
35000
+ const resolved = incident.status === "resolved";
35001
+ if (!post) {
35002
+ const steps = ["create post", ...incident.updates.map((u) => `append update ${u.id}`)];
35003
+ if (resolved) steps.push("close");
35004
+ return {
35005
+ id: incident.id,
35006
+ create: true,
35007
+ rewrite: false,
35008
+ append: [...incident.updates],
35009
+ ...resolved ? { close: true } : {},
35010
+ steps
35011
+ };
35012
+ }
35013
+ const posted = postedUpdateIds(messages);
35014
+ const append = incident.updates.filter((u) => !posted.has(u.id));
35015
+ const first = messages.at(-1);
35016
+ const summaryChanged = first === void 0 || !first.startsWith(rendered.body.trimEnd());
35017
+ const rewrite = append.length > 0 || summaryChanged || post.title !== rendered.title;
35018
+ const retag = post.state !== rendered.tag ? rendered.tag : void 0;
35019
+ const close = resolved && !post.closed ? true : !resolved && post.closed ? false : void 0;
35020
+ const steps = [
35021
+ ...rewrite ? ["rewrite summary"] : [],
35022
+ ...append.map((u) => `append update ${u.id}`),
35023
+ ...retag ? [`retag ${retag}`] : [],
35024
+ ...close === true ? ["close"] : close === false ? ["reopen"] : []
35025
+ ];
35026
+ return {
35027
+ id: incident.id,
35028
+ create: false,
35029
+ rewrite,
35030
+ append,
35031
+ ...retag ? { retag } : {},
35032
+ ...close !== void 0 ? { close } : {},
35033
+ steps
35034
+ };
35035
+ }
35036
+ // src/commands/render-incident/render-incident.ts
35037
+ /** Discord's message limit is 2000; an update's text is cut well short of it, leaving room for its heading and marker. */
35038
+ const UPDATE_TEXT_LIMIT = 1500;
35039
+ const TITLE_LIMIT = 100;
35040
+ const IMPACT_WORDS = {
35041
+ maintenance: "under maintenance",
35042
+ degraded: "degraded",
35043
+ partial: "partial outage",
35044
+ major: "major outage"
35045
+ };
35046
+ const clip = (text, limit) => text.length > limit ? `${text.slice(0, limit - 1).trimEnd()}…` : text;
35047
+ /** `2026-11-20T10:05:00Z` as `2026-11-20 10:05 UTC`; a bare date (Checkly may send no time) stays as it is. */
35048
+ function shownTime(at) {
35049
+ const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(at);
35050
+ return match ? `${match[1]} ${match[2]} UTC` : at;
35051
+ }
35052
+ /** `1h 5m`, `45m` or `30s` for a length of time in seconds. */
35053
+ function shownDuration(seconds) {
35054
+ const s = Math.max(0, Math.round(seconds));
35055
+ if (s < 60) return `${s}s`;
35056
+ const hours = Math.floor(s / 3600);
35057
+ const minutes = Math.floor(s % 3600 / 60);
35058
+ return hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
35059
+ }
35060
+ /** The tag of an incident's post: its status, except `maintenance` while it is open and marks nothing else. */
35061
+ function incidentTag(incident) {
35062
+ const onlyMaintenance = incident.impacts.length > 0 && incident.impacts.every((i) => i.impact === "maintenance");
35063
+ return incident.status !== "resolved" && onlyMaintenance ? "maintenance" : incident.status;
35064
+ }
35065
+ /** The message one update is posted as: its status and time, the text, and the marker that says it was posted. */
35066
+ function renderIncidentUpdate(update) {
35067
+ const text = clip(update.text.trim() || "(no text)", UPDATE_TEXT_LIMIT);
35068
+ return `**${update.status.toUpperCase()}**, ${shownTime(update.at)}\n${text}\n${updateMarker(update.id)}`;
35069
+ }
35070
+ /**
35071
+ * The post for an incident (spec `tech-incidents-to-discord`): the title, a summary as the first message (status,
35072
+ * what is affected, when it started, how long it lasted once resolved, a link to the status page) ending with the
35073
+ * incident's marker, and the tag. Pure. The incident has no URL of its own that is known, so the message links the page.
35074
+ */
35075
+ function renderIncident(incident, statusPage) {
35076
+ const tag = incidentTag(incident);
35077
+ const lines = [`**Status:** ${tag}`];
35078
+ if (incident.impacts.length > 0) lines.push(`**Affected:** ${incident.impacts.map((i) => `${i.component} (${IMPACT_WORDS[i.impact]})`).join(", ")}`);
35079
+ lines.push(`**Started:** ${shownTime(incident.startedAt)}`);
35080
+ if (incident.status === "resolved") {
35081
+ if (incident.resolvedAt) lines.push(`**Resolved:** ${shownTime(incident.resolvedAt)}`);
35082
+ if (incident.durationSeconds !== void 0) lines.push(`**Lasted:** ${shownDuration(incident.durationSeconds)}`);
35083
+ }
35084
+ lines.push(statusPage.url ? `Status page: [${statusPage.name}](<${statusPage.url}>)` : `Status page: ${statusPage.name}`);
35085
+ lines.push(incidentMarker(incident.id));
35086
+ return {
35087
+ title: clip(incident.title, TITLE_LIMIT),
35088
+ body: lines.join("\n"),
35089
+ tag
35090
+ };
35091
+ }
35092
+ // src/commands/sync-incidents/run-sync-incidents/run-sync-incidents.ts
35093
+ /**
35094
+ * `holocron sync incidents` -- mirror a status page's incidents into a forum (spec `tech-incidents-to-discord`, #2366).
35095
+ *
35096
+ * The forum is the layout's channel with `feeds.incidents`, and the status page is the one that feed names (or the only
35097
+ * one declared). The run reads state, not events: every incident still open and those resolved since `--since`, from the
35098
+ * `monitoring` provider's `listIncidents`, and compares each with its post (found by key, with its messages) through
35099
+ * `planIncidentFeed()`. A missing post is made quietly, a new update is appended once (its marker is looked for first),
35100
+ * and the summary, the tag and whether the post is closed follow the incident. Nothing is ever deleted and an update
35101
+ * already posted is not rewritten. A rate limit (429) stops the run and the next one continues. It writes, so it asks
35102
+ * first; `--yes` skips the question and, without a terminal, a run with neither `--yes` nor `--dry-run` refuses.
35103
+ */
35104
+ const DEFAULT_SINCE = "2d";
35105
+ /** How many of a post's messages are read to find the markers of its updates (Discord's limit per read). */
35106
+ const MESSAGES = 100;
35107
+ /** The channel carrying the feed, and the name of the status page it follows. */
35108
+ function feedOf(notifications, pages) {
35109
+ const fed = (notifications.layout?.categories ?? []).flatMap((c) => c.channels ?? []).filter((c) => c.feeds?.incidents);
35110
+ if (fed.length === 0) return { problem: "no forum in the layout has `feeds.incidents`" };
35111
+ if (fed.length > 1) return { problem: `several forums have \`feeds.incidents\` (${fed.map((c) => `\`${c.name}\``).join(", ")})` };
35112
+ const channel = fed[0];
35113
+ const named = channel.feeds.incidents;
35114
+ if (typeof named === "string") {
35115
+ const page = pages.find((p) => p.name === named);
35116
+ return page ? {
35117
+ channel: channel.name,
35118
+ page
35119
+ } : { problem: `\`feeds.incidents\` names the status page "${named}", which the monitoring provider does not declare` };
35120
+ }
35121
+ if (pages.length !== 1) return { problem: pages.length === 0 ? "`feeds.incidents` is `true` but no status page is declared; name one" : `\`feeds.incidents\` is \`true\` but ${pages.length} status pages are declared; name one` };
35122
+ return {
35123
+ channel: channel.name,
35124
+ page: pages[0]
35125
+ };
35126
+ }
35127
+ async function runSyncIncidents(input) {
35128
+ const print = input.print ?? ((line) => console.log(line));
35129
+ const row = (status, ...parts) => print(statusRow(status, ["sync incidents", ...parts]));
35130
+ const stop = (status, reason) => {
35131
+ row(status, reason);
35132
+ return {
35133
+ status,
35134
+ reason
35135
+ };
35136
+ };
35137
+ const dryRun = Boolean(input.context.dryRun);
35138
+ /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
35139
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
35140
+ await loader.load();
35141
+ assertPluginsResolvable(loader, "sync incidents");
35142
+ let notifications;
35143
+ try {
35144
+ notifications = pickDiscussionProvider(notificationProviders(loader), input.provider);
35145
+ } catch (err) {
35146
+ return stop("skip", errorMessage(err));
35147
+ }
35148
+ const monitoring = loader.has("monitoring") ? loader.get("monitoring") : void 0;
35149
+ if (!monitoring?.listIncidents) return stop("skip", "no `monitoring` provider that lists status page incidents");
35150
+ const feed = feedOf(notifications, monitoring.statusPages ?? []);
35151
+ if ("problem" in feed) return stop(feed.problem.startsWith("no forum") ? "skip" : "fail", feed.problem);
35152
+ const { channel, page } = feed;
35153
+ const statusPage = {
35154
+ name: page.name,
35155
+ ...page.domain ? { url: `https://${page.domain}` } : {}
35156
+ };
35157
+ let incidents;
35158
+ try {
35159
+ const since = input.since ?? parseSince(DEFAULT_SINCE, (input.now ?? /* @__PURE__ */ new Date()).getTime());
35160
+ incidents = await monitoring.listIncidents({
35161
+ statusPage: page.name,
35162
+ since
35163
+ });
35164
+ } catch (err) {
35165
+ return stop(err instanceof ProviderApiError && err.status === 403 ? "skip" : "fail", `reading incidents of "${page.name}": ${describeError(err)}`);
35166
+ }
35167
+ const counts = {
35168
+ created: 0,
35169
+ updated: 0,
35170
+ unchanged: 0,
35171
+ failed: 0,
35172
+ left: 0
35173
+ };
35174
+ if (incidents.length === 0) {
35175
+ row("skip", `no incident of "${page.name}" is open or recent`);
35176
+ return {
35177
+ status: "ok",
35178
+ counts,
35179
+ plans: []
35180
+ };
35181
+ }
35182
+ const work = [];
35183
+ const plans = [];
35184
+ for (const incident of incidents) {
35185
+ const key = incidentKey(page.name, incident.id);
35186
+ const rendered = renderIncident(incident, statusPage);
35187
+ try {
35188
+ const post = await notifications.readDiscussion(channel, key);
35189
+ const plan = planIncidentFeed({
35190
+ incident,
35191
+ rendered,
35192
+ post,
35193
+ messages: post ? await notifications.readDiscussionMessages(channel, key, MESSAGES) : []
35194
+ });
35195
+ plans.push(plan);
35196
+ if (plan.steps.length === 0) {
35197
+ counts.unchanged++;
35198
+ row("skip", incident.title, "in step");
35199
+ } else work.push({
35200
+ incident,
35201
+ key,
35202
+ plan
35203
+ });
35204
+ } catch (err) {
35205
+ counts.failed++;
35206
+ row("fail", incident.title, `reading its post: ${describeError(err)}`);
35207
+ }
35208
+ }
35209
+ if (dryRun) {
35210
+ for (const { incident, plan } of work) row("skip", incident.title, `would ${plan.steps.join("; ")}`);
35211
+ row("skip", `dry run, nothing written; ${work.length} incident(s) would change, ${counts.unchanged} in step`);
35212
+ return {
35213
+ status: counts.failed > 0 ? "fail" : "ok",
35214
+ counts,
35215
+ plans
35216
+ };
35217
+ }
35218
+ if (work.length > 0 && !input.yes) {
35219
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`sync incidents\` posts to #${channel}; pass --yes to run it without asking, or --dry-run to look`);
35220
+ if (!await (input.confirm ?? ((message) => confirm({
35221
+ message,
35222
+ default: false
35223
+ })))(`Post ${work.length} incident(s) of "${page.name}" to #${channel}?`)) {
35224
+ row("skip", "cancelled; nothing was changed");
35225
+ return {
35226
+ status: "cancelled",
35227
+ counts,
35228
+ plans
35229
+ };
35230
+ }
35231
+ }
35232
+ for (const [index, { incident, key, plan }] of work.entries()) try {
35233
+ await apply(notifications, channel, key, renderIncident(incident, statusPage), plan);
35234
+ if (plan.create) counts.created++;
35235
+ else counts.updated++;
35236
+ row("ok", incident.title, plan.steps.join("; "));
35237
+ } catch (err) {
35238
+ if (rateLimitedFor(err) !== void 0) {
35239
+ counts.left = work.length - index;
35240
+ row("skip", `stopped: the provider is rate limiting; ${counts.left} incident(s) are left for the next run`);
35241
+ break;
35242
+ }
35243
+ counts.failed++;
35244
+ row("fail", incident.title, describeError(err));
35245
+ }
35246
+ row(counts.failed > 0 ? "fail" : "ok", `"${page.name}" to #${channel}: created ${counts.created}, updated ${counts.updated}, unchanged ${counts.unchanged}, failed ${counts.failed}, left ${counts.left}`);
35247
+ return {
35248
+ status: counts.failed > 0 ? "fail" : "ok",
35249
+ counts,
35250
+ plans
35251
+ };
35252
+ }
35253
+ /** Writes one incident's plan: the post, then each update, then whether the post is closed. */
35254
+ async function apply(notifications, channel, key, rendered, plan) {
35255
+ let append = plan.append;
35256
+ if (plan.create) {
35257
+ if ((await notifications.ensureDiscussion({
35258
+ channel,
35259
+ key,
35260
+ title: rendered.title,
35261
+ body: rendered.body,
35262
+ state: rendered.tag,
35263
+ quiet: true
35264
+ })).created) {
35265
+ if (await notifications.dedupeDiscussion(channel, key, { refresh: true }) > 0) {
35266
+ const posted = postedUpdateIds(await notifications.readDiscussionMessages(channel, key, MESSAGES));
35267
+ append = append.filter((u) => !posted.has(u.id));
35268
+ }
35269
+ } else {
35270
+ const posted = postedUpdateIds(await notifications.readDiscussionMessages(channel, key, MESSAGES));
35271
+ append = append.filter((u) => !posted.has(u.id));
35272
+ }
35273
+ } else if (plan.rewrite || plan.retag || plan.close === false) await notifications.updateDiscussion(channel, key, {
35274
+ title: rendered.title,
35275
+ body: rendered.body,
35276
+ state: rendered.tag,
35277
+ ...plan.close === false ? { closed: false } : {}
35278
+ });
35279
+ for (const update of append) await notifications.postDiscussionMessage(channel, key, renderIncidentUpdate(update), { quiet: true });
35280
+ if (plan.close === true) await notifications.updateDiscussion(channel, key, { closed: true });
35281
+ }
35282
+ // src/commands/sync-incidents/sync-incidents.command.ts
35283
+ const syncIncidentsCommand = {
35284
+ command: "incidents",
35285
+ describe: "Mirror a status page's incidents into the forum that has `feeds.incidents`: one post each, updates appended",
35286
+ builder: (y) => y.option("since", {
35287
+ type: "string",
35288
+ describe: "Also read incidents resolved since this date or span back from now (default 2d: 2026-03-01, 7d, 12h)"
35289
+ }).option("provider", {
35290
+ type: "string",
35291
+ describe: "The `notifications` provider to post through, when several are configured"
35292
+ }).option("yes", {
35293
+ type: "boolean",
35294
+ describe: "Post without asking (a scheduled run needs it)"
35295
+ }),
35296
+ handler: async (argv) => {
35297
+ const since = argv.since ? parseSince(argv.since) : void 0;
35298
+ const tokens = tokenContext(argv.token);
35299
+ if (!tokens) return;
35300
+ const loaded = await loadConfig(argv.cwd);
35301
+ applyResolvedConfig(argv, loaded.resolved);
35302
+ if ((await runSyncIncidents({
35303
+ loaded,
35304
+ context: {
35305
+ repoRoot: argv.cwd,
35306
+ dryRun: argv.dryRun,
35307
+ ...tokens,
35308
+ org: resolveOrg(argv, loaded.resolved)
35309
+ },
35310
+ ...since ? { since } : {},
35311
+ ...argv.provider ? { provider: argv.provider } : {},
35312
+ ...argv.yes ? { yes: true } : {}
35313
+ })).status === "fail") process.exitCode = 1;
35314
+ }
35315
+ };
34897
35316
  // src/commands/sync-issues/assignees-location/assignees-location.ts
34898
35317
  /** Where the assignees file is: the org's private config repo, as the Discord links file is. */
34899
35318
  function assigneesLocation(org) {
@@ -36646,7 +37065,7 @@ const syncArgs = (y) => y.positional("steps", {
36646
37065
  const syncCommand = {
36647
37066
  command: "sync [steps..]",
36648
37067
  describe: "Sync state from config to the provider and local files (labels, properties, teams, topics, keywords, description, homepage, readme, workflows, scripts, wiki)",
36649
- builder: (y) => syncArgs(y).command(syncGithubCommand).command(syncIssuesCommand).command(syncReadmeCommand).command(ideasSyncCommand).command(syncToolingCommand).command(syncRequestsCommand).command(specsSyncCommand).command(secretsSyncCommand).command(notificationsSyncRolesCommand),
37068
+ builder: (y) => syncArgs(y).command(syncGithubCommand).command(syncIssuesCommand).command(syncIncidentsCommand).command(syncReadmeCommand).command(ideasSyncCommand).command(syncToolingCommand).command(syncRequestsCommand).command(specsSyncCommand).command(secretsSyncCommand).command(notificationsSyncRolesCommand),
36650
37069
  handler: async (argv) => {
36651
37070
  const tokens = tokenContext(argv.token);
36652
37071
  if (!tokens) return;