ultra11y 5.2.1 → 5.3.2

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/src/pr-comment.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // A CI run that appends a new comment every push turns a busy PR into a wall of stale
4
4
  // audits. This posts ONE comment and EDITS it on every subsequent run, keyed by an invisible
5
- // marker. The marker is per-standard, so a WCAG run and an RGAA run coexist instead of
5
+ // marker. The marker is per-standard AND per-kind, so a WCAG run and an RGAA run coexist —
6
+ // and so do the code digest and the page-by-page grid of one standard — instead of
6
7
  // overwriting one another (the same reason SARIF runs carry distinct automationDetails ids).
7
8
  //
8
9
  // It deliberately lives outside src/tickets/: it has no title, no de-dupe key, no labels and
@@ -11,13 +12,41 @@
11
12
  import type { StandardId } from "./standards/index.js";
12
13
  import { ghExec, ghErrorReason } from "./gh-cli.js";
13
14
 
14
- /** The hidden key identifying this tool's comment for a given standard. */
15
- export function COMMENT_MARKER(standard: StandardId): string {
16
- return `<!-- ultra11y:report standard="${standard}" -->`;
15
+ /** WHICH document a sticky carries.
16
+ *
17
+ * One workflow can run two tiers against the same pull request — a code gate and a page
18
+ * sweep — and they do not write the same document: the digest names the distinct defects a
19
+ * reviewer can act on in the diff, the page grid names what conforms page by page. They
20
+ * shared one marker, and the sweep (337 files, 684 occurrences) overwrote the four
21
+ * actionable findings of the gate on every run. The actionable half is the one that
22
+ * disappeared, so the kind is part of the key.
23
+ *
24
+ * `digest` renders the historical marker BYTE FOR BYTE. A sticky already posted must keep
25
+ * being edited in place; re-keying it would leave the old comment orphaned on the PR and
26
+ * post a duplicate beside it. */
27
+ export type CommentKind = "digest" | "pages";
28
+
29
+ /** The hidden key identifying this tool's comment for a given standard and kind.
30
+ *
31
+ * The kinds cannot collide as substrings of one another: the digest key ends in `" -->"`
32
+ * right after the standard, which the pages key never contains. That matters because
33
+ * `pickExistingComment` matches with `includes` — a prefix relationship there would make one
34
+ * tier adopt and overwrite the other's comment, which is the bug this parameter exists for. */
35
+ export function COMMENT_MARKER(standard: StandardId, kind: CommentKind = "digest"): string {
36
+ return `<!-- ultra11y:report standard="${standard}"${kind === "digest" ? "" : ` kind="${kind}"`} -->`;
37
+ }
38
+
39
+ export function stickyBody(markdown: string, standard: StandardId, kind: CommentKind = "digest"): string {
40
+ return `${COMMENT_MARKER(standard, kind)}\n${markdown}`;
17
41
  }
18
42
 
19
- export function stickyBody(markdown: string, standard: StandardId): string {
20
- return `${COMMENT_MARKER(standard)}\n${markdown}`;
43
+ /** The kind a caller asked for, from an untrusted string (a workflow input, an env var).
44
+ *
45
+ * Fails to `digest`, never to nothing: an unset or misspelled value must degrade to the
46
+ * document every existing workflow already posts. A typo that silenced the comment entirely
47
+ * would look exactly like a clean run. */
48
+ export function commentKindFrom(value: string | undefined): CommentKind {
49
+ return value === "pages" ? "pages" : "digest";
21
50
  }
22
51
 
23
52
  /** The pull request to comment on: an explicit override, else the number GitHub Actions puts
@@ -51,11 +80,11 @@ export interface CommentResult {
51
80
  /** Post (or update) the audit summary on the current pull request. Best-effort: with no `gh`,
52
81
  * no auth or no PR, it reports `skipped` and the caller carries on — a comment is never
53
82
  * worth failing a build over. */
54
- export function pushPrComment(markdown: string, standard: StandardId = "wcag"): CommentResult {
83
+ export function pushPrComment(markdown: string, standard: StandardId = "wcag", kind: CommentKind = "digest"): CommentResult {
55
84
  const pr = prNumberFromEnv();
56
85
  if (pr === undefined) return { ok: true, action: "skipped", reason: "not a pull-request run" };
57
- const marker = COMMENT_MARKER(standard);
58
- const body = stickyBody(markdown, standard);
86
+ const marker = COMMENT_MARKER(standard, kind);
87
+ const body = stickyBody(markdown, standard, kind);
59
88
  try {
60
89
  const repo = ghExec(["repo", "view", "--json", "nameWithOwner", "-q", ".nameWithOwner"]).trim();
61
90
  let existing: IssueComment | undefined;
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Single source of truth for shared types + the embedded version. sync-version.mjs
2
2
  // rewrites VERSION at release time (kept in lockstep with package.json + SKILL.md).
3
- export const VERSION = "5.2.1";
3
+ export const VERSION = "5.3.2";
4
4
  export const SCHEMA_VERSION = 2;
5
5
 
6
6
  // Lang = the UI FRAME's language — the `L` localization tables each module (report,