@theholocron/cli 5.0.0-alpha.589 → 5.0.0-alpha.590

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/README.md CHANGED
@@ -135,7 +135,7 @@ Every command is tagged with how much of a repo it needs:
135
135
  | ------------ | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
136
136
  | `global` | the CLI binary alone | `version`, `clone`, `new repo` / `plugin` / `token` / `github-app`, `upgrade …`, `check token` / `resolved`, `remove token` / `skill`, `list tokens` / `skills`, `publish …`, `install skills`, `update skills`, `run lint commit-msg` |
137
137
  | `repo-aware` | `./holocron.config`, walking up from cwd, no plugins | `run`, `run ci`, `show config`, `sync readme`, `deploy on-release` |
138
- | `workspace` | the `@theholocron/holocron-plugin-*` packages resolvable | `doctor`, `setup`, `sync`, `cleanup branches`, `sync secrets`, `deploy`, `sync github`, `sync issues`, `sync ideas`, `sync tooling`, `export requests`, `open requests`, `upload coverage` |
138
+ | `workspace` | the `@theholocron/holocron-plugin-*` packages resolvable | `doctor`, `setup`, `sync`, `cleanup branches`, `cleanup embeds`, `sync secrets`, `deploy`, `sync github`, `sync issues`, `sync ideas`, `sync tooling`, `export requests`, `open requests`, `upload coverage` |
139
139
 
140
140
  A `workspace` command run from a bare global install (no plugins next to the
141
141
  CLI) fails with one actionable line — install the plugins as devDependencies or
@@ -742,7 +742,7 @@ commands and the config are provider-neutral; Discord is the first provider.
742
742
  | `holocron doctor dns` | Do the DNS records the config makes setup write exist, pointing where they should? The preview domain's apex and wildcard CNAMEs (Cloudflare), the docs site a wiki provider asks for, and the relay Worker's proxied placeholder; one row per zone. A missing record, another target or a missing proxy fails; an extra record never does. A record `ensureCustomDomain()` returns is not checked, because asking for it creates the domain |
743
743
  | `holocron doctor monitoring` | Do the checks the `monitoring` provider declares exist in its account, matched by name, with the URL, method and (when stated) frequency, locations, tags (a declared tag the check lacks fails; an extra one does not), activated, should-fail, body and assertions the config sets? One row. A check in the account that is not declared is never a problem. A provider that cannot list its checks, could not load or has no token is a skip |
744
744
  | `holocron doctor secrets [--env <list>] [--only-secrets \| --only-variables] [--strict] [--name <name>] [--verify] [--shared [--allow NAME]...]` | Prints a matrix of every secret and variable by place (1Password Environments, GitHub, deployments; names only, cells `ok`, `n/a`, `MISSING`, `extra`, `?`) and checks the declared ones. `MISSING` fails; `extra` is info (`--strict` fails; `doctor.manualSecrets` is left out); `--name` explains one name and exits 0 (this and `extra` replace `doctor variable-owners`). `--shared` compares the layers named by `--env` (two or more of `local`, `dev`, `ci`, `prod`; all four by default) for a secret that holds the same value in two of them: it reads each Environment in memory, compares the concealed entries by a salted hash made fresh per run, and prints names only, one row per pair of layers (`info`, shown as skipped; `--strict` fails), plus `info` rows for `ci` variables missing from or different in `dev`; `doctor.sharedVariables` and `--allow` leave out names shared on purpose (the old `doctor secrets`). `--verify` also asks each vendor whether the tokens the plugins take are still accepted (online; fails a rejected token or one with 7 days or fewer left; the old `doctor tokens`). It also checks `repo.variables` (the old `doctor variables`). Do the secrets the config says must exist (`repo.secrets`, plus the notification layout's webhook and role secrets and the Chromatic token) exist? One row for the repository, the organization and each environment, each only when something is expected there. Names only; an undeclared secret is never a problem. `--env` takes a comma-separated or repeated list of `local`, `dev`, `ci`, `test`, `prod` and checks only those (`ci` the GitHub secrets, `prod` the deploy destinations; `local`, `dev` and `test` are a skipped row that says why). A scope that cannot be read is a skip |
745
- | `holocron doctor tokens` | Does every token a plugin declares for a layer carry the permissions the declaration says, and is it fresh? For each layer (`local`, `dev`, `ci`, `prod`) and each token a configured plugin declares for it (`PluginToken.expect`, read by `tokenExpectations()`), reads that layer's Environment in memory and runs the provider's `token` probe against the token it holds (`environmentTokens()`, `runProbe()`: the same flow as `probe <provider> token --environment <layer>`). One row per token per layer: fails for a permission it must not have, one it lacks, a token the layer should hold and does not, or a token past its rotation age or near its expiry. A provider with no declared layers or no `token` probe is a skip. Names, counts and dates only; never a token. Goes online. Read-only (not the old `doctor tokens`, which `doctor secrets --verify` replaced: that asked whether one resolved token is still accepted) |
745
+ | `holocron doctor tokens` | Does every token a plugin declares for a layer carry the permissions the declaration says, and is it fresh? For each layer (`local`, `dev`, `ci`, `prod`) and each token a configured plugin declares for it (`PluginToken.expect`, read by `tokenExpectations()`), reads that layer's Environment in memory and runs the provider's `token` probe against the token it holds (`environmentTokens()`, `runProbe()`: the same flow as `probe <provider> token --environment <layer>`). One row per token per layer: fails for a permission it must not have, one it lacks, a token the layer should hold and does not, or a token past its rotation age or near its expiry. A layer a token lists in `forbiddenLayers` (#2825) gets a row too: `ok` when its Environment does not hold the token, `fail` when it does, `skip` when it cannot be read. A provider with no declared layers or no `token` probe is a skip. Names, counts and dates only; never a token. Goes online. Read-only (not the old `doctor tokens`, which `doctor secrets --verify` replaced: that asked whether one resolved token is still accepted) |
746
746
  | `holocron doctor --all` | Runs every deep check (`doctor notifications`, `doctor secrets`, ...) and prints one row each, then `N ok, N fail, N skipped` counted in checks. Exits 1 when any check fails. A check that cannot run (no provider, no token) is a skip with the reason. Read-only: notifications runs as `--built-only`, so it posts nothing |
747
747
  | `holocron provider [<name> [setup\|doctor]] [--with <file or key=value>]... [--dry-run] [--yes]` | Set up or check what only one provider has (a Linear team's labels, project and auto-close/auto-archive), from that provider's own block of `holocron.config`, or, for a provider the config does not name, from `--with` (repeatable: `team=ENG`, or a `.json`/`.ts`/`.js` file holding the provider's options object; it goes over the config entry's options where there is one, never writes the config, and the token still comes from `--token` or the usual chain). A plugin offers it by returning `setup` / `doctor` from `createPlugin`; `doctor` is read-only, `setup` is idempotent, never deletes, supports `--dry-run` and asks first unless `--yes`. Rows are the shared `printCheckRows` ones; nothing secret is printed |
748
748
  | `holocron probe [<provider> [<probe>]] [--dry-run] [--yes] [--lcov <path>]` | Poke a live provider on purpose: list the probes, inspect something, or run a proof that cleans up after itself. Plugins offer the probes; nothing secret is printed; one that changes things asks first |
@@ -765,15 +765,16 @@ Pinned messages are declared under the provider's `layout` as `pinned: [{ channe
765
765
 
766
766
  Config shape added for role sync and sign-in (all under the provider's `layout`):
767
767
 
768
- | Field | Meaning |
769
- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
770
- | `testChannel` | The channel (it must declare a webhook) the doctor posts its one self-removing test message to. |
771
- | `roles[].team` | A GitHub team slug. The role follows that team: given to linked members, taken from linked people who left. Never touches holders nobody has linked. |
772
- | `links.hostedUrl` | A hosted sign-in service (Sentinel). `link` asks `<hostedUrl>/api/link` and uses it when it answers `{ "service": "link" }`; otherwise it signs in locally. |
773
- | `links.localPort` | The port of the local sign-in listener (default `53682`, bound to `127.0.0.1` only). |
774
- | `links.repo` / `links.path` | Where the links file lives (default `<org>/.github-private` and `notifications/<provider>-links.json`). |
775
- | `application.intents.members` | Switches the Server Members Intent on or off (needed to list who holds a role). |
776
- | `application.redirectUris` | Redirect URIs that must be registered. Check-only: the API cannot set them, so `setup` and the doctor say what to add in the developer portal. |
768
+ | Field | Meaning |
769
+ | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
770
+ | `testChannel` | The channel (it must declare a webhook) the doctor posts its one self-removing test message to. |
771
+ | `roles[].team` | A GitHub team slug. The role follows that team: given to linked members, taken from linked people who left. Never touches holders nobody has linked. |
772
+ | `links.hostedUrl` | A hosted sign-in service (Sentinel). `link` asks `<hostedUrl>/api/link` and uses it when it answers `{ "service": "link" }`; otherwise it signs in locally. |
773
+ | `links.localPort` | The port of the local sign-in listener (default `53682`, bound to `127.0.0.1` only). |
774
+ | `links.repo` / `links.path` | Where the links file lives (default `<org>/.github-private` and `notifications/<provider>-links.json`). |
775
+ | `application.intents.members` | Switches the Server Members Intent on or off (needed to list who holds a role). |
776
+ | `application.intents.messageContent` | Switches the Message Content Intent on or off (needed to read message text and embeds). |
777
+ | `application.redirectUris` | Redirect URIs that must be registered. Check-only: the API cannot set them, so `setup` and the doctor say what to add in the developer portal. |
777
778
 
778
779
  The links file is `{ "version": 1, "links": [{ "github": "<id>", "login": "<login>", "member": "<id>" }] }`: two public ids per person.
779
780
  It is read and written through the `source` capability with the `github.user-sync` token (fine-grained, **only** the
@@ -848,7 +849,7 @@ See the [command pages](https://theholocron.dev/holocron/commands/setup-notifica
848
849
 
849
850
  - **`holocron sync releases --from <sha> --to <sha> [--tag <tag>] [--channel releases] [--yes]`** — posts one message
850
851
  in `#releases` for the public packages whose `version` differs between the two commits (private packages and apps left
851
- out), ending with a `-# release [<id>]` marker, and a thread on it with a line per package. Idempotent: a rerun finds
852
+ out), ending with a `-# release [<id>]` marker, and a thread on it with a list item per package, each linking to its version on npm. Idempotent: a rerun finds
852
853
  the message by its marker, starts a thread only if it has none and posts only the missing lines. `--dry-run` prints
853
854
  the post. Needs a `notifications` provider with `sendWithId`, `findMessage`, `startThread`, `postToThread` and
854
855
  `readThread` (Discord); the release workflow's `announce` job runs it. See the
package/dist/cli.mjs CHANGED
@@ -105,6 +105,7 @@ const COMMAND_CONTEXTS = {
105
105
  "new server": "workspace",
106
106
  "sync roles": "workspace",
107
107
  "cleanup posts": "workspace",
108
+ "cleanup embeds": "workspace",
108
109
  "sync specs": "workspace",
109
110
  "reconcile ci": "workspace",
110
111
  "reconcile project": "workspace",
@@ -286,6 +287,20 @@ const authExportEntry = {
286
287
  ],
287
288
  supportsDryRun: false
288
289
  };
290
+ // src/commands/cleanup-embeds/cleanup-embeds.entry.ts
291
+ const cleanupEmbedsEntry = {
292
+ name: "cleanup embeds",
293
+ description: "Hide the link-preview cards under the messages already in a text channel, keeping the links",
294
+ positionals: [],
295
+ options: [{
296
+ key: "limit",
297
+ flag: "--limit",
298
+ type: "input",
299
+ message: "How many of the newest messages to read in each channel (1 to 1000, default 200):"
300
+ }],
301
+ skipOptions: ["yes", "provider"],
302
+ supportsDryRun: true
303
+ };
289
304
  // src/commands/cleanup-preview/cleanup-preview.entry.ts
290
305
  const cleanupPreviewEntry = {
291
306
  name: "deploy cleanup-preview",
@@ -2459,6 +2474,7 @@ const registry = createCommandRegistry([
2459
2474
  notificationsLinkEntry,
2460
2475
  notificationsSyncRolesEntry,
2461
2476
  notificationsDedupeEntry,
2477
+ cleanupEmbedsEntry,
2462
2478
  specsSyncEntry,
2463
2479
  deployEntry,
2464
2480
  cleanupPreviewEntry,
@@ -6101,6 +6117,285 @@ const checkCommand = {
6101
6117
  builder: (y) => y.command(authCheckCommand).command(monitoringCheckCommand).command(monitoringRunResolvedCommand).command(groupMenu("check")),
6102
6118
  handler: () => {}
6103
6119
  };
6120
+ // src/commands/cleanup-embeds/cleanup-embeds.args.ts
6121
+ const cleanupEmbedsArgs = (y) => y.positional("channel", {
6122
+ type: "string",
6123
+ array: true,
6124
+ describe: "The text channels to clean (default: alerts releases deploys sync)"
6125
+ }).option("limit", {
6126
+ type: "number",
6127
+ default: 200,
6128
+ describe: "How many of the newest messages to read in each channel (1 to 1000)"
6129
+ }).option("provider", {
6130
+ type: "string",
6131
+ describe: "Which notifications provider, when several can hide link previews"
6132
+ }).option("yes", {
6133
+ type: "boolean",
6134
+ describe: "Edit the messages without asking (required without a terminal)"
6135
+ });
6136
+ // src/commands/cleanup-embeds/cleanup-embeds.ts
6137
+ /**
6138
+ * `holocron cleanup embeds` — hide the link-preview cards under the messages already in a text channel.
6139
+ *
6140
+ * The posts in #alerts, #releases, #deploys and #sync are plain text with links, and the chat service drew a preview
6141
+ * card under each. New posts carry the suppress-embeds flag; this sets it on the messages that were already there, which
6142
+ * keeps the links and hides the cards. Which messages are touched is the provider's rule (`hideLinkPreviews`): only one
6143
+ * whose embeds are all link previews, never one carrying an embed a webhook or bot built on purpose. It reads every
6144
+ * channel first and says what it would edit, then asks (unless `--yes`; `--dry-run` stops after the reading), then edits.
6145
+ * Idempotent: a second run finds nothing. A channel that fails is reported and the rest are still done. It prints
6146
+ * channel names, counts and message ids, never a message's text, a URL or a token.
6147
+ */
6148
+ /** The text channels whose posts are plain text with links. */
6149
+ const DEFAULT_CHANNELS = [
6150
+ "alerts",
6151
+ "releases",
6152
+ "deploys",
6153
+ "sync"
6154
+ ];
6155
+ const DEFAULT_LIMIT = 200;
6156
+ const MAX_LIMIT = 1e3;
6157
+ /** The provider that can hide link previews on messages that are already posted. */
6158
+ function pickPreviewHider(providers, wanted) {
6159
+ return pickProvider(providers, wanted, (p) => typeof p.hideLinkPreviews === "function", {
6160
+ infinitive: "hide link previews",
6161
+ gerund: "hiding link previews"
6162
+ });
6163
+ }
6164
+ const plural$1 = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
6165
+ /** What a channel's run found or did, as the row's one line. */
6166
+ function describe(result, verb) {
6167
+ const parts = [`read ${plural$1(result.read, "message")}`, result.toHide === 0 ? "nothing to hide" : `${verb} ${plural$1(result.toHide, "message")}`];
6168
+ if (result.skipped > 0) parts.push(`${result.skipped} left alone (an embed built on purpose)`);
6169
+ return parts.join(", ");
6170
+ }
6171
+ /** Reads each channel, says what it would edit, asks, then hides the link previews; see the file header for the rules. */
6172
+ async function runCleanupEmbeds(input) {
6173
+ const print = input.print ?? ((line) => console.log(line));
6174
+ const logger = input.logger ?? getLogger();
6175
+ /* v8 ignore next -- the real loader is only built outside tests, which always inject one */
6176
+ const loader = input.loader ?? new PluginLoader(input.loaded.resolved, input.context);
6177
+ await loader.load();
6178
+ assertPluginsResolvable(loader, "cleanup embeds");
6179
+ const dryRun = input.context.dryRun ?? false;
6180
+ const report = {
6181
+ status: "ok",
6182
+ channels: [],
6183
+ hidden: 0
6184
+ };
6185
+ const refuse = (message) => {
6186
+ const rows = [{
6187
+ id: "embeds",
6188
+ title: "cleanup embeds",
6189
+ status: "fail",
6190
+ detail: message,
6191
+ problems: []
6192
+ }];
6193
+ printCheckRows(rows, print);
6194
+ printCheckSummary(summariseChecks(rows), print);
6195
+ logger.warn({ reason: message }, "cleanup embeds");
6196
+ return {
6197
+ ...report,
6198
+ status: "fail",
6199
+ message
6200
+ };
6201
+ };
6202
+ const limit = input.limit ?? DEFAULT_LIMIT;
6203
+ if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) return refuse(`--limit must be a whole number from 1 to ${MAX_LIMIT}`);
6204
+ let notifications;
6205
+ try {
6206
+ notifications = pickPreviewHider(notificationProviders(loader), input.provider);
6207
+ } catch (err) {
6208
+ return refuse(errorMessage(err));
6209
+ }
6210
+ const channels = [...new Set((input.channels?.length ? input.channels : DEFAULT_CHANNELS).map((name) => name.replace(/^#/, "")))];
6211
+ const hide = notifications.hideLinkPreviews.bind(notifications);
6212
+ const reads = [];
6213
+ const readRows = [];
6214
+ for (const channel of channels) {
6215
+ const row = {
6216
+ id: `embeds:${channel}`,
6217
+ title: `#${channel}`,
6218
+ problems: []
6219
+ };
6220
+ try {
6221
+ const result = await hide({
6222
+ channel,
6223
+ limit,
6224
+ dryRun: true
6225
+ });
6226
+ reads.push({
6227
+ channel,
6228
+ result
6229
+ });
6230
+ readRows.push({
6231
+ ...row,
6232
+ status: "skip",
6233
+ detail: describe(result, "would hide previews of")
6234
+ });
6235
+ } catch (err) {
6236
+ const message = errorMessage(err);
6237
+ reads.push({ channel });
6238
+ report.channels.push({
6239
+ channel,
6240
+ message
6241
+ });
6242
+ readRows.push({
6243
+ ...row,
6244
+ status: "fail",
6245
+ detail: `could not read: ${message}`
6246
+ });
6247
+ }
6248
+ }
6249
+ const todo = reads.flatMap((r) => r.result && r.result.toHide > 0 ? [{
6250
+ channel: r.channel,
6251
+ result: r.result
6252
+ }] : []);
6253
+ const total = todo.reduce((sum, r) => sum + r.result.toHide, 0);
6254
+ const unreadable = readRows.some((r) => r.status === "fail");
6255
+ if (dryRun) {
6256
+ printCheckRows(readRows, print);
6257
+ const summary = summariseChecks(readRows);
6258
+ printCheckSummary(summary, print);
6259
+ print(` would hide the previews of ${plural$1(total, "message")}; nothing was edited`);
6260
+ for (const r of reads) if (r.result) report.channels.push({
6261
+ channel: r.channel,
6262
+ result: r.result
6263
+ });
6264
+ return {
6265
+ ...report,
6266
+ status: "dry-run"
6267
+ };
6268
+ }
6269
+ if (total === 0) {
6270
+ for (const r of reads) if (r.result) report.channels.push({
6271
+ channel: r.channel,
6272
+ result: r.result
6273
+ });
6274
+ const rows = readRows.map((row) => row.status === "skip" ? {
6275
+ ...row,
6276
+ status: "ok"
6277
+ } : row);
6278
+ printCheckRows(rows, print);
6279
+ printCheckSummary(summariseChecks(rows), print);
6280
+ return {
6281
+ ...report,
6282
+ status: unreadable ? "fail" : "ok"
6283
+ };
6284
+ }
6285
+ printCheckRows(readRows, print);
6286
+ print("");
6287
+ if (!input.yes) {
6288
+ const interactive = input.interactive ?? Boolean(process.stdin.isTTY);
6289
+ const where = todo.map((r) => `#${r.channel}`).join(", ");
6290
+ if (!interactive) throw new NonInteractiveError(`\`cleanup embeds\` edits ${plural$1(total, "message")} in ${where}; pass --yes to run it without asking, or --dry-run to preview`);
6291
+ if (!await (input.confirm ?? ((message) => confirm({
6292
+ message,
6293
+ default: false
6294
+ })))(`Hide the link previews of ${plural$1(total, "message")} in ${where}? The links stay; the cards go.`)) {
6295
+ print(` nothing was edited`);
6296
+ return {
6297
+ ...report,
6298
+ status: "cancelled"
6299
+ };
6300
+ }
6301
+ }
6302
+ const doneRows = [];
6303
+ for (const { channel } of todo) {
6304
+ const title = `#${channel}`;
6305
+ const id = `embeds:${channel}`;
6306
+ try {
6307
+ const result = await hide({
6308
+ channel,
6309
+ limit
6310
+ });
6311
+ report.channels.push({
6312
+ channel,
6313
+ result
6314
+ });
6315
+ report.hidden += result.hidden;
6316
+ const detail = `hid the previews of ${plural$1(result.hidden, "message")}`;
6317
+ const failed = result.stopped || result.failed > 0 ? [
6318
+ ...result.problem ? [result.problem] : [],
6319
+ ...result.left > 0 ? [`${plural$1(result.left, "message")} left; run the command again`] : [],
6320
+ ...result.failed > 0 ? [`${plural$1(result.failed, "message")} could not be edited`] : []
6321
+ ] : [];
6322
+ doneRows.push(failed.length > 0 ? {
6323
+ id,
6324
+ title,
6325
+ status: "fail",
6326
+ detail,
6327
+ problems: failed
6328
+ } : {
6329
+ id,
6330
+ title,
6331
+ status: "ok",
6332
+ detail,
6333
+ problems: []
6334
+ });
6335
+ if (result.ids.length > 0) logger.info({
6336
+ channel,
6337
+ ids: result.ids
6338
+ }, "cleanup embeds hid previews");
6339
+ } catch (err) {
6340
+ const message = errorMessage(err);
6341
+ report.channels.push({
6342
+ channel,
6343
+ message
6344
+ });
6345
+ doneRows.push({
6346
+ id,
6347
+ title,
6348
+ status: "fail",
6349
+ detail: `could not hide: ${message}`,
6350
+ problems: []
6351
+ });
6352
+ }
6353
+ }
6354
+ const untouched = readRows.filter((row) => !todo.some((t) => `embeds:${t.channel}` === row.id)).map((row) => row.status === "skip" ? {
6355
+ ...row,
6356
+ status: "ok"
6357
+ } : row);
6358
+ for (const r of reads) if (r.result && !todo.some((t) => t.channel === r.channel)) report.channels.push({
6359
+ channel: r.channel,
6360
+ result: r.result
6361
+ });
6362
+ const rows = [...untouched, ...doneRows];
6363
+ printCheckRows(rows, print);
6364
+ printCheckSummary(summariseChecks(rows), print);
6365
+ if (rows.some((row) => row.status === "fail")) report.status = "fail";
6366
+ logger.info({
6367
+ provider: notifications.providerName,
6368
+ channels: channels.length,
6369
+ hidden: report.hidden,
6370
+ status: report.status
6371
+ }, "cleanup embeds");
6372
+ return report;
6373
+ }
6374
+ // src/commands/cleanup-embeds/cleanup-embeds.command.ts
6375
+ const cleanupEmbedsCommand = {
6376
+ command: "embeds [channel..]",
6377
+ describe: "Hide the link-preview cards under the messages already in a text channel, keeping the links",
6378
+ builder: cleanupEmbedsArgs,
6379
+ handler: async (argv) => {
6380
+ const tokens = tokenContext(argv.token);
6381
+ if (!tokens) return;
6382
+ const loaded = await loadConfig(argv.cwd);
6383
+ applyResolvedConfig(argv, loaded.resolved);
6384
+ if ((await runCleanupEmbeds({
6385
+ loaded,
6386
+ context: {
6387
+ repoRoot: argv.cwd,
6388
+ dryRun: argv.dryRun,
6389
+ ...tokens,
6390
+ org: resolveOrg(argv, loaded.resolved)
6391
+ },
6392
+ limit: argv.limit,
6393
+ ...argv.channel && argv.channel.length > 0 ? { channels: argv.channel } : {},
6394
+ ...argv.provider ? { provider: argv.provider } : {},
6395
+ ...argv.yes ? { yes: true } : {}
6396
+ })).status === "fail") process.exitCode = 1;
6397
+ }
6398
+ };
6104
6399
  // src/commands/notifications-dedupe/notifications-dedupe.ts
6105
6400
  /**
6106
6401
  * `holocron cleanup posts` — delete the extra posts of a forum that has more than one post for the same key.
@@ -6609,8 +6904,8 @@ const repoCleanupBranchesCommand = {
6609
6904
  // src/commands/cleanup/cleanup.command.ts
6610
6905
  const cleanupCommand = {
6611
6906
  command: "cleanup",
6612
- describe: "Clean up what a repo or a forum accumulates (merged branches, duplicate posts)",
6613
- builder: (y) => y.command(repoCleanupBranchesCommand).command(notificationsDedupeCommand).command(groupMenu("cleanup")),
6907
+ describe: "Clean up what a repo or a forum accumulates (merged branches, duplicate posts, link previews)",
6908
+ builder: (y) => y.command(repoCleanupBranchesCommand).command(notificationsDedupeCommand).command(cleanupEmbedsCommand).command(groupMenu("cleanup")),
6614
6909
  handler: () => {}
6615
6910
  };
6616
6911
  // src/commands/clone/clone.args.ts
@@ -17924,6 +18219,7 @@ async function runDoctorNotifications(input) {
17924
18219
  if (wantApp.description !== void 0 && (have.description ?? "") !== wantApp.description) appProblems.push("description differs from the layout");
17925
18220
  if (wantApp.tags !== void 0 && set(have.tags ?? []) !== set(wantApp.tags)) appProblems.push(`tags are ${(have.tags ?? []).map(shown).join(", ") || "none"} but the layout says ${wantApp.tags.map(shown).join(", ") || "none"}`);
17926
18221
  if (wantApp.intents?.members !== void 0 && (have.intents?.members ?? false) !== wantApp.intents.members) appProblems.push(`the Server Members Intent is ${have.intents?.members ? "on" : "off"} but the layout says ${wantApp.intents.members ? "on" : "off"} (\`holocron setup notifications\` changes it)`);
18222
+ if (wantApp.intents?.messageContent !== void 0 && (have.intents?.messageContent ?? false) !== wantApp.intents.messageContent) appProblems.push(`the Message Content Intent is ${have.intents?.messageContent ? "on" : "off"} but the layout says ${wantApp.intents.messageContent ? "on" : "off"} (\`holocron setup notifications\` changes it)`);
17927
18223
  const needsLink = (layout.roles ?? []).some((r) => r.team);
17928
18224
  const wantRedirects = wantApp.redirectUris ?? (needsLink ? [(await resolveCallback({
17929
18225
  ...layout.links?.hostedUrl ? { hostedUrl: layout.links.hostedUrl } : {},
@@ -21629,6 +21925,38 @@ const doctorSecretsCommand = {
21629
21925
  })).status === "fail") process.exitCode = 1;
21630
21926
  }
21631
21927
  };
21928
+ // src/commands/forbidden-token-layers/forbidden-token-layers.ts
21929
+ /**
21930
+ * Reads the layers a plugin's tokens forbid (`TokenExpectation.forbiddenLayers`, #2825) as one entry per token and
21931
+ * layer, in the order of `ENVIRONMENT_LAYERS`: the Environments that must not hold the token at all. A separate reader
21932
+ * from `tokenExpectations()`, which lists only the layers that hold a token, so the probes, the rotation readers and the
21933
+ * docs check never see a forbidden layer. A token with no `forbiddenLayers` yields nothing.
21934
+ *
21935
+ * @throws {ConfigError} For a layer that is not one of `ENVIRONMENT_LAYERS` (every layer word reads a vault
21936
+ * Environment, so none is left out), and for a layer a token is both declared for (`layers`, or a key of
21937
+ * `permissions`) and forbids: the declaration contradicts itself.
21938
+ */
21939
+ function forbiddenTokenLayers(tokens, filter = {}) {
21940
+ const found = [];
21941
+ for (const token of tokens) {
21942
+ const { forbiddenLayers: forbidden, layers = [], permissions = {} } = token.expect ?? {};
21943
+ if (!forbidden || filter.envName !== void 0 && token.envName !== filter.envName) continue;
21944
+ const unknown = forbidden.find((layer) => !isEnvironmentLayer(layer));
21945
+ if (unknown !== void 0) throw new ConfigError$1(`${token.envName} forbids the layer ${JSON.stringify(unknown)}: use one of ${ENVIRONMENT_LAYERS.join(", ")}`);
21946
+ const declaredFor = ENVIRONMENT_LAYERS.filter((layer) => layers.includes(layer) || permissions[layer]);
21947
+ const both = declaredFor.find((layer) => forbidden.includes(layer));
21948
+ if (both !== void 0) throw new ConfigError$1(`${token.envName} is both declared for and forbidden in the ${both} layer`);
21949
+ for (const layer of ENVIRONMENT_LAYERS) {
21950
+ if (!forbidden.includes(layer) || filter.layer !== void 0 && filter.layer !== layer) continue;
21951
+ found.push({
21952
+ envName: token.envName,
21953
+ layer,
21954
+ declaredFor
21955
+ });
21956
+ }
21957
+ }
21958
+ return found;
21959
+ }
21632
21960
  // src/commands/owner-environments/owner-environments.ts
21633
21961
  /**
21634
21962
  * The Environments the config names: each `credentials` provider's, `githubApps[].environment`, `dev.environment`
@@ -21864,27 +22192,31 @@ async function runDoctorTokens(input) {
21864
22192
  const providerTokens = input.providerTokens ?? defaultProviderTokens(input.loaded);
21865
22193
  for (const provider of providersOf(input.loaded.resolved.providers, extras)) {
21866
22194
  let tokens;
22195
+ let expectations;
22196
+ let forbidden;
21867
22197
  try {
21868
22198
  tokens = await providerTokens(provider);
22199
+ expectations = tokenExpectations(tokens);
22200
+ forbidden = forbiddenTokenLayers(tokens);
21869
22201
  } catch (err) {
21870
22202
  rows.push(row$20(`tokens:${provider}`, provider, "skip", `could not read its tokens: ${describeError(err)}`));
21871
22203
  continue;
21872
22204
  }
21873
- const expectations = tokenExpectations(tokens);
21874
- if (expectations.length === 0) rows.push(row$20(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
21875
- else if (!usableProbe(probes.get(provider))) rows.push(row$20(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
22205
+ if (expectations.length === 0 && forbidden.length === 0) rows.push(row$20(`tokens:${provider}`, provider, "skip", "info: declares no token layers, nothing to check"));
22206
+ else if (expectations.length > 0 && !usableProbe(probes.get(provider))) rows.push(row$20(`tokens:${provider}`, provider, "skip", `info: has no \`${PROBE}\` probe loaded, so its tokens are not checked`));
21876
22207
  else declared.push({
21877
22208
  provider,
21878
22209
  tokens,
21879
- expectations
22210
+ expectations,
22211
+ forbidden
21880
22212
  });
21881
22213
  }
21882
22214
  if (declared.length > 0) {
21883
22215
  const vault = loader.has("vault") ? memoVault(loader.get("vault")) : void 0;
21884
22216
  for (const layer of ENVIRONMENT_LAYERS) for (const entry of declared) {
21885
22217
  const wanted = entry.expectations.filter((e) => e.layer === layer);
21886
- if (wanted.length === 0) continue;
21887
- rows.push(...await checkLayer({
22218
+ const banned = entry.forbidden.filter((f) => f.layer === layer);
22219
+ const check = {
21888
22220
  input,
21889
22221
  makeLoader,
21890
22222
  probes,
@@ -21892,7 +22224,9 @@ async function runDoctorTokens(input) {
21892
22224
  entry,
21893
22225
  layer,
21894
22226
  wanted
21895
- }));
22227
+ };
22228
+ if (wanted.length > 0) rows.push(...await checkLayer(check));
22229
+ if (banned.length > 0) rows.push(...await checkForbidden(check, banned));
21896
22230
  }
21897
22231
  }
21898
22232
  printCheckRows(rows, print);
@@ -21948,6 +22282,36 @@ async function checkLayer(c) {
21948
22282
  }
21949
22283
  return rows;
21950
22284
  }
22285
+ /**
22286
+ * One row per token a layer must not hold at all (`forbiddenLayers`): read the layer's Environment the same way and
22287
+ * pass when the token is not in it, fail when it is (naming the layers it is declared for), skip when it cannot be read.
22288
+ * No probe runs against it and its value never reaches a row.
22289
+ */
22290
+ async function checkForbidden(c, banned) {
22291
+ const { provider, tokens } = c.entry;
22292
+ let held;
22293
+ let failure;
22294
+ try {
22295
+ held = await environmentTokens({
22296
+ provider,
22297
+ environment: c.layer,
22298
+ repoRoot: c.input.context.repoRoot,
22299
+ gitExec: c.input.gitExec,
22300
+ configured: ownerEnvironments(c.input.loaded.resolved).names,
22301
+ vault: c.vault,
22302
+ tokens
22303
+ });
22304
+ } catch (err) {
22305
+ if (!(err instanceof HoldsNoTokenError)) failure = err;
22306
+ }
22307
+ return banned.map((f) => {
22308
+ const id = rowId(c.layer, provider, f.envName);
22309
+ const title = rowTitle(c.layer, provider, f.envName);
22310
+ if (failure !== void 0) return row$20(id, title, "skip", `could not read the Environment: ${describeError(failure)}`);
22311
+ if (!held?.held.some((h) => h.envName === f.envName)) return row$20(id, title, "ok", "not held, as declared");
22312
+ return row$20(id, title, "fail", `held in ${held.environment}, a layer it is not declared for`, [`${f.envName} is held in ${held.environment} but is declared only for ${f.declaredFor.join(", ") || "no layer"}`]);
22313
+ });
22314
+ }
21951
22315
  /** Runs the provider's token probe against one token, as `probe <provider> token --environment <layer>` does. */
21952
22316
  async function probeToken(c, e, token, plain) {
21953
22317
  const provider = c.entry.provider;
@@ -41631,13 +41995,27 @@ function releasedPackages(cwd, from, to) {
41631
41995
  }
41632
41996
  return released.sort((a, b) => a.name.localeCompare(b.name));
41633
41997
  }
41998
+ // src/commands/sync-releases/package-line/package-line.ts
41999
+ /** The page of one version of a package on npm. */
42000
+ function npmVersionUrl(pkg) {
42001
+ return `https://www.npmjs.com/package/${pkg.name}/v/${pkg.version}`;
42002
+ }
42003
+ /** Markdown characters in a name or version, written so they cannot change the formatting of the link text. */
42004
+ const MARKDOWN = /[\\`*_~|<>[\]]/g;
42005
+ /**
42006
+ * One package of a release as a list item that links to its version on npm: `- [name version](url)`. Consecutive lines
42007
+ * make one list in Discord, and a line is one whole item, so a message is never cut inside a link.
42008
+ */
42009
+ function packageLine(pkg) {
42010
+ return `- [${`${pkg.name} ${pkg.version}`.replace(MARKDOWN, "\\$&")}](${npmVersionUrl(pkg)})`;
42011
+ }
41634
42012
  // src/commands/sync-releases/render-release/render-release.ts
41635
42013
  /** Discord's limit on a thread's name. */
41636
42014
  const THREAD_NAME_LIMIT = 100;
41637
42015
  /**
41638
42016
  * The text of a release's announcement: a message with the headline, the link to the GitHub release (when a tag and
41639
- * the repository are known) and the marker last, a thread name, and one line per package. Chunking the lines to the
41640
- * provider's limit is the provider's job.
42017
+ * the repository are known) and the marker last, a thread name, and one list item per package that links to the
42018
+ * version's page on npm. Chunking the lines to the provider's limit is the provider's job.
41641
42019
  */
41642
42020
  function renderRelease(input) {
41643
42021
  const { id, tag, repo, packages } = input;
@@ -41650,7 +42028,7 @@ function renderRelease(input) {
41650
42028
  releaseMarker(id)
41651
42029
  ].join("\n"),
41652
42030
  threadName: (tag ?? id).slice(0, THREAD_NAME_LIMIT),
41653
- lines: packages.map((p) => `${p.name} ${p.version}`)
42031
+ lines: packages.map(packageLine)
41654
42032
  };
41655
42033
  }
41656
42034
  // src/commands/sync-releases/run-sync-releases/run-sync-releases.ts