@theholocron/cli 5.0.0-alpha.494 → 5.0.0-alpha.496

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
@@ -699,7 +699,7 @@ Channels fed by the error tracker add `feeds: { errors: true }` and a layout `re
699
699
 
700
700
  `holocron list secrets [--scope repo|environment|organization] [--env <name>] [--json]` prints the names (never the values; GitHub does not return them) of the secrets at each scope, sorted, under a heading per scope. With no `--scope` it lists the repository, plus the organization (`--org`, `HOLOCRON_ORG` or the config's `org`) and the `--env` environment when they are known; `--scope` lists one. A scope that cannot be listed is reported under its heading and the rest are still listed; the exit code is 1 if any fails. `--json` prints `[{ scope, names, error? }]`. It is read-only, so `--dry-run` does not apply. Comparing the names with what the config expects is `doctor secrets`, which also covers the keys of the vault environments declared in `repo.secrets.sync`.
701
701
 
702
- A channel with `kind: "forum"` is a forum, with `tags` (each a `name`, an `emoji` and whether it is `moderated`); `setup` adds and corrects the tags but never removes one, and a text channel of the same name must be deleted first, since neither kind can become the other. A forum takes no `webhook` and none of the webhook feeds (`monitoring`, `errors`); its one feed is `feeds: { prs: true }`, the pull-request feed, where Sentinel keeps one post per pull request tagged with its state. The object form `feeds: { prs: { exclude: { repos?: ["owner/name"], authors?: ["login"] } } }` leaves some pull requests out. `feeds.prs` belongs to a forum (a text channel with it is refused) and the forum's `tags` must hold all eight states, `draft`, `conflicts`, `failing`, `changes requested`, `ready`, `waiting`, `merged` and `closed`, or `setup` refuses the layout. `setup` does nothing more for it; `doctor notifications` checks that the forum exists, has those tags and that the bot can start posts and manage threads in it (`ServerInspection` `botThreads`, filled in by the Discord provider after the forum's own permission overwrites). `defaultReaction` is the emoji Discord offers on every post (its Get Started step "Set a default reaction for posts"); Discord allows only one, so `starterReactions` lists more (`["👍", "👎", "❓"]` for approve, disapprove, question) that the bot adds to the first message of each post `sync specs` makes. Existing posts are left alone, a reaction the bot cannot add is skipped, and `doctor notifications` checks `defaultReaction`. A reaction is a Unicode emoji (`"✅"`) or one of the server's own emoji written between colons (`":git_merge:"`, 2 to 32 letters, digits and underscores); the object form `{ emoji: ":git_merge:", image: ".holocron/media/emoji/git_merge.png" }` also names the file `setup` makes the emoji from when the server has none (PNG, JPEG, GIF, WebP or AVIF, at most 256 KiB, under `.holocron/media/`; checked by its bytes before anything is written; an emoji that exists is never replaced or deleted; `--dry-run` only previews; the bot then needs Create Guild Expressions, which the invite link asks for only when the layout gives an emoji an `image`). A word without colons (`git_merge`) is refused, not sent as text. `doctor notifications` has an `emoji` row that fails by name for each server emoji the server lacks, and its `channels` row compares the default reaction in the same spelling.
702
+ A channel with `kind: "forum"` is a forum, with `tags` (each a `name`, an `emoji` and whether it is `moderated`); `setup` adds and corrects the tags but never removes one, and a text channel of the same name must be deleted first, since neither kind can become the other. A forum takes no `webhook` and none of the webhook feeds (`monitoring`, `errors`); its one feed is `feeds: { prs: true }`, the pull-request feed, where Sentinel keeps one post per pull request tagged with its state. The object form `feeds: { prs: { exclude: { repos?: ["owner/name"], authors?: ["login"] } } }` leaves some pull requests out. `feeds.prs` belongs to a forum (a text channel with it is refused) and the forum's `tags` must hold all eight states, `draft`, `conflicts`, `failing`, `changes requested`, `ready`, `waiting`, `merged` and `closed`, or `setup` refuses the layout. `setup` does nothing more for it; `doctor notifications` checks that the forum exists, has those tags and that the bot can start posts and manage threads in it (`ServerInspection` `botThreads`, filled in by the Discord provider after the forum's own permission overwrites). `defaultReaction` is the emoji Discord offers on every post (its Get Started step "Set a default reaction for posts"); Discord allows only one, so `starterReactions` lists more (`["👍", "👎", "❓"]` for approve, disapprove, question) that the bot adds to the first message of each post `sync specs` makes. Existing posts are left alone, a reaction the bot cannot add is skipped, and `doctor notifications` checks `defaultReaction`. A reaction is a Unicode emoji (`"✅"`) or one of the server's own emoji written between colons (`":git_merge:"`, 2 to 32 letters, digits and underscores); the object form `{ emoji: ":git_merge:", image: ".holocron/media/emoji/git_merge.png" }` also names the file `setup` makes the emoji from when the server has none (PNG, JPEG, GIF, WebP or AVIF, at most 256 KiB, under `.holocron/media/`; checked by its bytes before anything is written; an emoji that exists is never replaced or deleted; `--dry-run` only previews; the bot then needs Create Guild Expressions, which the invite link asks for only when the layout gives an emoji an `image`). The layout's own `emojis: [{ emoji: ":git_commit:", image }]` declares server emoji no reaction names; `setup` makes them with the others and `doctor notifications` expects them on the server. A word without colons (`git_merge`) is refused, not sent as text. `doctor notifications` has an `emoji` row that fails by name for each server emoji the server lacks, and its `channels` row compares the default reaction in the same spelling.
703
703
 
704
704
  `holocron sync specs [--channel <forum>] [--files <paths...>] [--pr <number>] [--refresh] [--refresh-origin] [--refresh-titles] [--withdraw] [--notify]` keeps one forum post per ADR and spec in step with the files: it makes the post (titled with the document's own title, tagged with the file's status), writes its address into the file as `discussion.url`, and turns a gatekeeper's retag into an edit of the file's `status:` line in the working tree for a pull request. `--files` syncs only those files and `--pr` names a pull request on their posts, for a pull request that is still open. `--refresh-origin` is a one-off repair: it rewrites the `PR:` line of existing posts to the one the current rule names (the optional `prLine` of `DiscussionPatch`, and of `DiscussionPost`), and nothing else in them. `--refresh-titles` is the same kind of one-off repair for the title: it renames each existing post whose title differs from the current rule's (the optional `title` of `DiscussionPatch`, and of `DiscussionPost`) and changes nothing else; a rate limit stops it cleanly, reports how many documents are left, and the next run continues. The id that opens a post is a link to the file on the default branch (`repo.defaultBranch`, else `HEAD`) once the file is there, and plain text while `--pr` names an open pull request; the normal sync rewrites a post's id line (and only that line) whenever it is not the one the rule gives and no `--pr` is given, which covers a file that moved and a post made while its pull request was open, so it needs no extra request when every post is right and `--refresh` is no longer needed for it. `--refresh` runs the `PR:`, title and id-link repairs in one pass (the id link is the optional `idLine` of `DiscussionPatch`, and of `DiscussionPost`, which changes only the message's first line); `--refresh-origin` and `--refresh-titles` still do only their own. `--withdraw` (with `--files`, on the base branch) tags the posts of a pull request closed unmerged `withdrawn` and closes them; `withdrawn` is a tag only, never a file `status:`, and the next sync puts the file's own status back. It cannot be combined with `--refresh`, `--refresh-origin` or `--refresh-titles`. `--dry-run` previews it. The posts behind it are also usable for other keys, such as a pull request (`owner/repo#123`, the state a tag name): `DiscussionPatch.body` replaces the first message's text (the provider keeps its footer), and the optional `Notifications` methods `postDiscussionMessage(channel, key, content, { quiet })` (a closed post is unarchived, written to and closed again), `readDiscussionMessages(channel, key, limit)` (text, newest first, 50 by default) and `dedupeDiscussion(channel, key)` (keeps the oldest post of the key, deletes the rest, returns how many) append to, read and repair a post, and `duplicateDiscussions(channel)` lists the keys with more than one post without deleting: `holocron cleanup posts [channel] [--provider <name>] [--yes]` uses the two to clear duplicates that are already there (the forum with `feeds.prs` by default; `--dry-run` previews it). See the [`sync specs` page](https://docs.theholocron.dev/holocron/commands/sync-specs/).
705
705
 
package/dist/cli.mjs CHANGED
@@ -8765,6 +8765,20 @@ function botPermissionChecks(input) {
8765
8765
  const problems = missing.length === 0 ? [] : [`missing: ${missing.map((m) => sanitizeDetail(m)).join(", ")}`, ...inviteUrl ? [`invite the bot again with them (updates its role in place): ${inviteUrl}`] : []];
8766
8766
  return [resultRow("bot-permissions", TITLE$1, problems, "every permission it needs")];
8767
8767
  }
8768
+ // src/commands/notifications-reaction/layout-reactions/layout-reactions.ts
8769
+ /**
8770
+ * Every reaction a layout writes that can name a server emoji: each forum's default and starter reactions, then the
8771
+ * layout's own `emojis` (server emoji made with no reaction naming them), in that order.
8772
+ */
8773
+ function layoutReactions(layout) {
8774
+ const reactions = [];
8775
+ for (const channel of (layout?.categories ?? []).flatMap((c) => c.channels ?? [])) {
8776
+ if (channel.defaultReaction !== void 0) reactions.push(channel.defaultReaction);
8777
+ reactions.push(...channel.starterReactions ?? []);
8778
+ }
8779
+ reactions.push(...layout?.emojis ?? []);
8780
+ return reactions;
8781
+ }
8768
8782
  // src/commands/notifications-reaction/parse-reaction/parse-reaction.ts
8769
8783
  /** A server emoji written as Discord shows it: `:name:`, the name 2 to 32 letters, digits and underscores. */
8770
8784
  const CUSTOM_EMOJI = /^:([A-Za-z0-9_]{2,32}):$/;
@@ -8797,37 +8811,31 @@ function parseReaction(reaction) {
8797
8811
  */
8798
8812
  function emojiConflictProblem(layout) {
8799
8813
  const images = /* @__PURE__ */ new Map();
8800
- for (const channel of (layout.categories ?? []).flatMap((c) => c.channels ?? [])) {
8801
- const reactions = [...channel.defaultReaction === void 0 ? [] : [channel.defaultReaction], ...channel.starterReactions ?? []];
8802
- for (const reaction of reactions) {
8803
- const parsed = parseReaction(reaction);
8804
- if (parsed.kind !== "custom" || !parsed.image) continue;
8805
- const image = posix.normalize(parsed.image);
8806
- const have = images.get(parsed.name);
8807
- if (have !== void 0 && have !== image) return `emoji \`:${parsed.name}:\` is given two different images, \`${have}\` and \`${image}\``;
8808
- images.set(parsed.name, image);
8809
- }
8814
+ for (const reaction of layoutReactions(layout)) {
8815
+ const parsed = parseReaction(reaction);
8816
+ if (parsed.kind !== "custom" || !parsed.image) continue;
8817
+ const image = posix.normalize(parsed.image);
8818
+ const have = images.get(parsed.name);
8819
+ if (have !== void 0 && have !== image) return `emoji \`:${parsed.name}:\` is given two different images, \`${have}\` and \`${image}\``;
8820
+ images.set(parsed.name, image);
8810
8821
  }
8811
8822
  }
8812
8823
  // src/commands/notifications-reaction/layout-emojis/layout-emojis.ts
8813
8824
  /**
8814
- * The server emoji a layout's forum reactions name (default and starter), once each, in the order the layout first
8825
+ * The server emoji a layout's forum reactions name (default and starter) and its `emojis` list, once each, in the order the layout first
8815
8826
  * names them. A name that is given an `image` anywhere keeps it, so the picture can sit on any one of its uses.
8816
8827
  */
8817
8828
  function layoutEmojis(layout) {
8818
8829
  const found = /* @__PURE__ */ new Map();
8819
- for (const channel of (layout?.categories ?? []).flatMap((c) => c.channels ?? [])) {
8820
- const reactions = [...channel.defaultReaction === void 0 ? [] : [channel.defaultReaction], ...channel.starterReactions ?? []];
8821
- for (const reaction of reactions) {
8822
- const parsed = parseReaction(reaction);
8823
- if (parsed.kind !== "custom") continue;
8824
- const have = found.get(parsed.name);
8825
- if (!have) found.set(parsed.name, {
8826
- name: parsed.name,
8827
- ...parsed.image ? { image: parsed.image } : {}
8828
- });
8829
- else if (!have.image && parsed.image) have.image = parsed.image;
8830
- }
8830
+ for (const reaction of layoutReactions(layout)) {
8831
+ const parsed = parseReaction(reaction);
8832
+ if (parsed.kind !== "custom") continue;
8833
+ const have = found.get(parsed.name);
8834
+ if (!have) found.set(parsed.name, {
8835
+ name: parsed.name,
8836
+ ...parsed.image ? { image: parsed.image } : {}
8837
+ });
8838
+ else if (!have.image && parsed.image) have.image = parsed.image;
8831
8839
  }
8832
8840
  return [...found.values()];
8833
8841
  }
@@ -9238,6 +9246,11 @@ function forumLayoutProblem(layout) {
9238
9246
  if (missing.length > 0) return `${where}: \`feeds.prs\` needs the tags ${missing.map((t) => `\`${t}\``).join(", ")}; add them to \`tags\``;
9239
9247
  }
9240
9248
  }
9249
+ for (const emoji of layout.emojis ?? []) {
9250
+ const problem = reactionProblem("an `emojis` entry", emoji);
9251
+ if (problem) return problem;
9252
+ if (typeof emoji === "string" || !emoji.image) return "an `emojis` entry must be `{ emoji, image }`";
9253
+ }
9241
9254
  const emojiProblem = emojiConflictProblem(layout);
9242
9255
  if (emojiProblem) return emojiProblem;
9243
9256
  const forums = new Set(channels.filter((c) => c.kind === "forum").map((c) => c.name.toLowerCase()));