pr-shepherd 2.4.1 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/.claude-plugin/plugin.json +3 -3
  2. package/.grok-plugin/marketplace.json +1 -1
  3. package/README.md +7 -9
  4. package/bin/classify/apply.d.mts +8 -1
  5. package/bin/classify/apply.mjs +37 -47
  6. package/bin/classify/items.d.mts +7 -0
  7. package/bin/classify/items.mjs +57 -0
  8. package/bin/classify/standard/coderabbit-notices.d.mts +2 -1
  9. package/bin/classify/standard/coderabbit-notices.mjs +35 -3
  10. package/bin/classify/standard/index.d.mts +2 -1
  11. package/bin/classify/standard/index.mjs +2 -1
  12. package/bin/classify/types.d.mts +8 -3
  13. package/bin/cli/iterate-lean.mjs +3 -0
  14. package/bin/cli/list-formatters.d.mts +1 -0
  15. package/bin/cli/list-formatters.mjs +3 -1
  16. package/bin/cli/triage-formatter.mjs +6 -1
  17. package/bin/commands/check-activity.mjs +2 -1
  18. package/bin/commands/check-fingerprint.mjs +1 -0
  19. package/bin/commands/check.mjs +39 -9
  20. package/bin/commands/iterate/branch-update.d.mts +19 -0
  21. package/bin/commands/iterate/branch-update.mjs +39 -0
  22. package/bin/commands/iterate/check-instructions.d.mts +3 -1
  23. package/bin/commands/iterate/check-instructions.mjs +26 -6
  24. package/bin/commands/iterate/classify.d.mts +17 -3
  25. package/bin/commands/iterate/classify.mjs +105 -66
  26. package/bin/commands/iterate/escalate.mjs +6 -1
  27. package/bin/commands/iterate/index.mjs +16 -24
  28. package/bin/commands/iterate/native-stack-rebase.d.mts +5 -0
  29. package/bin/commands/iterate/native-stack-rebase.mjs +16 -8
  30. package/bin/commands/iterate/queue-recovery-instructions.mjs +7 -4
  31. package/bin/commands/iterate/queue-removal.mjs +2 -1
  32. package/bin/commands/iterate/render.d.mts +2 -11
  33. package/bin/commands/iterate/render.mjs +10 -19
  34. package/bin/commands/iterate/stall.mjs +3 -0
  35. package/bin/commands/iterate/triage.d.mts +1 -0
  36. package/bin/commands/iterate/triage.mjs +19 -14
  37. package/bin/commands/iterate/unreported-required.mjs +6 -4
  38. package/bin/commands/resolve-mutate.mjs +39 -4
  39. package/bin/commands/resolve-review-guard.d.mts +19 -0
  40. package/bin/commands/resolve-review-guard.mjs +61 -0
  41. package/bin/comments/resolve.mjs +4 -4
  42. package/bin/comments/review-thread-markers.d.mts +1 -1
  43. package/bin/comments/review-thread-markers.mjs +23 -9
  44. package/bin/comments/superseded-approvals.d.mts +28 -0
  45. package/bin/comments/superseded-approvals.mjs +99 -0
  46. package/bin/config/schema.d.mts +10 -0
  47. package/bin/config/schema.mjs +2 -0
  48. package/bin/github/batch-parsers.mjs +31 -0
  49. package/bin/github/batch-raw-types.d.mts +3 -0
  50. package/bin/github/batch-viewer.d.mts +2 -2
  51. package/bin/github/batch.mjs +1 -1
  52. package/bin/github/gql/batch-pr-page.gql +8 -2
  53. package/bin/github/gql/batch-pr.gql +4 -1
  54. package/bin/github/poll-summary-review-helpers.d.mts +20 -0
  55. package/bin/github/poll-summary-review-helpers.mjs +81 -0
  56. package/bin/github/poll-summary-review.mjs +37 -46
  57. package/bin/github/poll-summary-rule-auto-resolve.mjs +1 -0
  58. package/bin/github/poll-summary-rule-items.d.mts +1 -1
  59. package/bin/github/poll-summary-rule-items.mjs +3 -2
  60. package/bin/github/rest-batch-snapshot.mjs +25 -1
  61. package/bin/github/review-unresolved-threads.d.mts +13 -0
  62. package/bin/github/review-unresolved-threads.mjs +152 -0
  63. package/bin/github/stack-handoff-page.mjs +5 -1
  64. package/bin/state/seen-comments.d.mts +3 -1
  65. package/bin/state/seen-comments.mjs +28 -2
  66. package/bin/types/escalate.d.mts +1 -0
  67. package/bin/types/github.d.mts +7 -1
  68. package/bin/types/iterate.d.mts +4 -2
  69. package/bin/types/report.d.mts +8 -0
  70. package/package.json +5 -5
  71. package/plugins/pr-shepherd/.claude-plugin/plugin.json +3 -3
  72. package/plugins/pr-shepherd/.codex-plugin/plugin.json +6 -6
  73. package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +1 -1
  74. package/plugins/pr-shepherd/skills/pr-shepherd/references/merge-queue-ejection.md +2 -2
  75. package/plugins/pr-shepherd/skills/pr-shepherd/references/triage-loop.md +1 -1
  76. package/plugins/pr-shepherd/skills/setup-pr-shepherd/SKILL.md +1 -1
  77. package/plugins/pr-shepherd/skills/setup-pr-shepherd/references/classifiers.md +3 -3
  78. package/plugins/pr-shepherd/skills/setup-pr-shepherd/references/upstream-standard-rule.md +2 -2
  79. package/pr-shepherd.schema.json +12 -0
  80. package/src/classify/types.mts +9 -1
@@ -24,12 +24,17 @@ export declare const configSchema: z.ZodObject<{
24
24
  "stall-timeout-minutes": z.ZodDefault<z.ZodNumber>;
25
25
  "ready-delay-minutes": z.ZodDefault<z.ZodNumber>;
26
26
  "minimize-approvals": z.ZodDefault<z.ZodBoolean>;
27
+ "minimize-superseded-approvals": z.ZodDefault<z.ZodBoolean>;
27
28
  "minimize-comments": z.ZodDefault<z.ZodEnum<{
28
29
  all: "all";
29
30
  bots: "bots";
30
31
  none: "none";
31
32
  }>>;
32
33
  "behind-base-hint": z.ZodDefault<z.ZodString>;
34
+ "branch-update": z.ZodDefault<z.ZodEnum<{
35
+ merge: "merge";
36
+ rebase: "rebase";
37
+ }>>;
33
38
  "review-output-max-chars": z.ZodDefault<z.ZodNumber>;
34
39
  "resolve-other-human-threads": z.ZodDefault<z.ZodEnum<{
35
40
  always: "always";
@@ -114,12 +119,17 @@ export declare const configFileSchema: z.ZodObject<{
114
119
  "stall-timeout-minutes": z.ZodDefault<z.ZodNumber>;
115
120
  "ready-delay-minutes": z.ZodDefault<z.ZodNumber>;
116
121
  "minimize-approvals": z.ZodDefault<z.ZodBoolean>;
122
+ "minimize-superseded-approvals": z.ZodDefault<z.ZodBoolean>;
117
123
  "minimize-comments": z.ZodDefault<z.ZodEnum<{
118
124
  all: "all";
119
125
  bots: "bots";
120
126
  none: "none";
121
127
  }>>;
122
128
  "behind-base-hint": z.ZodDefault<z.ZodString>;
129
+ "branch-update": z.ZodDefault<z.ZodEnum<{
130
+ merge: "merge";
131
+ rebase: "rebase";
132
+ }>>;
123
133
  "review-output-max-chars": z.ZodDefault<z.ZodNumber>;
124
134
  "resolve-other-human-threads": z.ZodDefault<z.ZodEnum<{
125
135
  always: "always";
@@ -117,8 +117,10 @@ export const configSchema = z.strictObject({
117
117
  "stall-timeout-minutes": nonNegative().default(60),
118
118
  "ready-delay-minutes": nonNegative().default(0),
119
119
  "minimize-approvals": z.boolean().default(false),
120
+ "minimize-superseded-approvals": z.boolean().default(true),
120
121
  "minimize-comments": z.enum(["all", "bots", "none"]).default("bots"),
121
122
  "behind-base-hint": z.string().default(""),
123
+ "branch-update": z.enum(["rebase", "merge"]).default("rebase"),
122
124
  "review-output-max-chars": z.number().int().nonnegative().default(50000),
123
125
  "resolve-other-human-threads": z.enum(["none", "outdated", "always"]).default("none"),
124
126
  instructions: z.enum(["inline", "playbook"]).default("inline"),
@@ -4,6 +4,7 @@ import { headFreshAtUnix } from "./head-freshness.mjs";
4
4
  import { headPushUnixFromCheckNodes } from "./queue-removal-freshness.mjs";
5
5
  import { contextNodes } from "./batch-response.mjs";
6
6
  import { buildPrActivitySummary } from "./activity.mjs";
7
+ import { findSupersededApprovalIds } from "../comments/superseded-approvals.mjs";
7
8
  import { parseBranchProtection } from "./branch-protection.mjs";
8
9
  import { readAllowedMergeMethods } from "../config/merge-method.mjs";
9
10
  import { parseAutoMergeRequest, parseBranchRules, parseLatestMergeQueueRemoval, parseMergeQueueEntry, parseStack, } from "./batch-parsers-rules.mjs";
@@ -13,6 +14,7 @@ function parseReviewNode(r) {
13
14
  author: r.author?.login ?? "unknown",
14
15
  authorType: mapAuthorType(r.author?.__typename, r.author?.login),
15
16
  ...(r.authorAssociation !== undefined && { authorAssociation: r.authorAssociation }),
17
+ ...("isMinimized" in r && r.isMinimized === true && { isMinimized: true }),
16
18
  viewerCanMinimize: "viewerCanMinimize" in r && r.viewerCanMinimize === true,
17
19
  body: r.body,
18
20
  createdAtUnix: r.createdAt ? parseCreatedAt(r.createdAt) : 0,
@@ -107,6 +109,34 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
107
109
  const approvedReviews = rawApprovedReviewNodes
108
110
  .filter((r) => !r.isMinimized)
109
111
  .map((r) => parseReviewNode(r));
112
+ const supersededApprovalIds = [
113
+ ...findSupersededApprovalIds({
114
+ reviews: [
115
+ ...rawApprovedReviewNodes.map((r) => ({
116
+ id: r.id,
117
+ author: r.author?.login ?? "unknown",
118
+ state: "APPROVED",
119
+ body: r.body,
120
+ createdAtUnix: r.createdAt ? parseCreatedAt(r.createdAt) : 0,
121
+ })),
122
+ ...rawReviewNodes.map((r) => ({
123
+ id: r.id,
124
+ author: r.author?.login ?? "unknown",
125
+ state: "CHANGES_REQUESTED",
126
+ body: r.body,
127
+ createdAtUnix: r.createdAt ? parseCreatedAt(r.createdAt) : 0,
128
+ })),
129
+ ...rawReviewSummaryNodes.map((r) => ({
130
+ id: r.id,
131
+ author: r.author?.login ?? "unknown",
132
+ state: r.state === "DISMISSED" ? "DISMISSED" : "COMMENTED",
133
+ body: r.body,
134
+ createdAtUnix: r.createdAt ? parseCreatedAt(r.createdAt) : 0,
135
+ })),
136
+ ],
137
+ latestReviews,
138
+ }),
139
+ ].filter((id) => approvedReviews.some((review) => review.id === id));
110
140
  const checks = parseCheckNodes(rawCheckNodes);
111
141
  const queueHead = raw.mergeQueueEntry?.headCommit;
112
142
  const removedQueueHead = raw.mergeQueueRemovals?.nodes[0]?.beforeCommit;
@@ -164,6 +194,7 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
164
194
  changesRequestedReviews,
165
195
  reviewSummaries,
166
196
  approvedReviews,
197
+ ...(supersededApprovalIds.length > 0 && { supersededApprovalIds }),
167
198
  checks,
168
199
  branchProtection: parseBranchProtection(raw),
169
200
  ...(allowedMergeMethods && { allowedMergeMethods }),
@@ -216,6 +216,8 @@ export interface RawComment {
216
216
  }
217
217
  export interface RawReview {
218
218
  id: string;
219
+ isMinimized?: boolean;
220
+ viewerCanMinimize?: boolean;
219
221
  authorAssociation?: CommentAuthorAssociation;
220
222
  author: RawAuthor | null;
221
223
  body: string;
@@ -226,6 +228,7 @@ export interface RawReview {
226
228
  }
227
229
  export interface RawReviewSummary {
228
230
  id: string;
231
+ state?: string;
229
232
  isMinimized: boolean;
230
233
  viewerCanMinimize: boolean;
231
234
  authorAssociation?: CommentAuthorAssociation;
@@ -1,10 +1,10 @@
1
1
  import { type RateLimitInfo, type RepoInfo } from "./client.mts";
2
- import type { RawComment, RawPr, RawReviewSummary, RawThread } from "./batch-raw-types.mts";
2
+ import type { RawComment, RawPr, RawReview, RawReviewSummary, RawThread } from "./batch-raw-types.mts";
3
3
  /** The nodes of a viewer-free `BatchPr` read whose viewer fields are still missing. */
4
4
  export interface ViewerTargets {
5
5
  threads: RawThread[];
6
6
  comments: RawComment[];
7
- reviews: RawReviewSummary[];
7
+ reviews: Array<RawReview | RawReviewSummary>;
8
8
  }
9
9
  export interface BatchViewer {
10
10
  login: string | null;
@@ -44,7 +44,7 @@ async function fetchGraphqlPrBatch(pr, repo, opts = {}, reuse) {
44
44
  (await applyBatchViewer(repo, raw, {
45
45
  threads: threadPages.threads,
46
46
  comments: paged.comments,
47
- reviews: [...paged.reviewSummaries, ...paged.approvedReviews],
47
+ reviews: [...paged.changesRequested, ...paged.reviewSummaries, ...paged.approvedReviews],
48
48
  }));
49
49
  // The topology's viewer login and administer bit come from this snapshot's viewer read.
50
50
  if (viewer) {
@@ -99,6 +99,8 @@ query BatchPrPage(
99
99
  }
100
100
  nodes {
101
101
  id
102
+ isMinimized
103
+ viewerCanMinimize
102
104
  authorAssociation
103
105
  author {
104
106
  __typename
@@ -111,14 +113,18 @@ query BatchPrPage(
111
113
  }
112
114
  }
113
115
  }
114
- reviewSummaries: reviews(states: COMMENTED, last: 50, before: $reviewSummariesCursor)
115
- @include(if: $includeReviewSummaries) {
116
+ reviewSummaries: reviews(
117
+ states: [COMMENTED, DISMISSED]
118
+ last: 50
119
+ before: $reviewSummariesCursor
120
+ ) @include(if: $includeReviewSummaries) {
116
121
  pageInfo {
117
122
  hasPreviousPage
118
123
  startCursor
119
124
  }
120
125
  nodes {
121
126
  id
127
+ state
122
128
  isMinimized
123
129
  viewerCanMinimize
124
130
  authorAssociation
@@ -251,6 +251,8 @@ query BatchPr($owner: String!, $repo: String!, $pr: Int!) {
251
251
  }
252
252
  nodes {
253
253
  id
254
+ isMinimized
255
+ viewerCanMinimize
254
256
  authorAssociation
255
257
  author {
256
258
  __typename
@@ -263,13 +265,14 @@ query BatchPr($owner: String!, $repo: String!, $pr: Int!) {
263
265
  }
264
266
  }
265
267
  }
266
- reviewSummaries: reviews(states: COMMENTED, last: 50) {
268
+ reviewSummaries: reviews(states: [COMMENTED, DISMISSED], last: 50) {
267
269
  pageInfo {
268
270
  hasPreviousPage
269
271
  startCursor
270
272
  }
271
273
  nodes {
272
274
  id
275
+ state
273
276
  isMinimized
274
277
  viewerCanMinimize
275
278
  authorAssociation
@@ -0,0 +1,20 @@
1
+ import type { ClassifyAction } from "../classify/types.mts";
2
+ import type { LoadedRule } from "../classify/loader.mts";
3
+ import { type NormalizedBotUsernames } from "../comments/authors.mts";
4
+ import { type SeenMarker } from "../state/seen-comments.mts";
5
+ import type { MinimizeCommentsPolicy } from "../config/load.mts";
6
+ import type { RawSummaryPr } from "./poll-summary-raw.mts";
7
+ export declare function countActionableSummaryReviews(input: {
8
+ raw: RawSummaryPr;
9
+ summaryActions: ReadonlyMap<string, ClassifyAction>;
10
+ rules: LoadedRule[];
11
+ confirmed: ReadonlySet<string>;
12
+ unconfirmed: ReadonlySet<string>;
13
+ blockedReviewIds: ReadonlySet<string>;
14
+ seen: Map<string, SeenMarker>;
15
+ viewerCanAdminister: boolean | undefined;
16
+ minimizeApprovals: boolean;
17
+ minimizeSupersededApprovals: boolean;
18
+ minimizeComments: MinimizeCommentsPolicy;
19
+ bots: NormalizedBotUsernames;
20
+ }): number;
@@ -0,0 +1,81 @@
1
+ import { findSupersededApprovalIds } from "../comments/superseded-approvals.mjs";
2
+ import { shouldMinimizeAuthor } from "../comments/minimize-policy.mjs";
3
+ import { isConfiguredBotAuthor, isHumanAuthor, normalizeAuthorType, } from "../comments/authors.mjs";
4
+ import { classifyItem, mutationWasDenied } from "../state/seen-comments.mjs";
5
+ import { canGenerateGithubMutation } from "./mutation-policy.mjs";
6
+ import { parseCreatedAt } from "./batch-parser-helpers.mjs";
7
+ import { ruleHides, summaryRuleAction } from "./poll-summary-rule-items.mjs";
8
+ const authorOf = (author) => ({
9
+ login: author?.login ?? "",
10
+ authorType: normalizeAuthorType(author?.__typename, author?.login),
11
+ });
12
+ function summarySupersededApprovalIds(raw) {
13
+ return findSupersededApprovalIds({
14
+ reviews: raw.reviews.nodes
15
+ .filter((review) => review.state === "APPROVED" ||
16
+ review.state === "CHANGES_REQUESTED" ||
17
+ review.state === "DISMISSED" ||
18
+ review.state === "COMMENTED")
19
+ .map((review) => ({
20
+ id: review.id,
21
+ author: review.author?.login ?? "unknown",
22
+ state: review.state,
23
+ body: review.body,
24
+ createdAtUnix: review.createdAt ? parseCreatedAt(review.createdAt) : 0,
25
+ })),
26
+ latestReviews: (raw.latestReviews?.nodes ?? []).map((review) => ({
27
+ login: review.author?.login ?? "unknown",
28
+ state: review.state,
29
+ })),
30
+ });
31
+ }
32
+ function canMinimizeSummaryReview(review, blockedReviewIds, seen, minimizeComments, bots) {
33
+ const author = authorOf(review.author);
34
+ return (!review.isMinimized &&
35
+ !blockedReviewIds.has(review.id) &&
36
+ !mutationWasDenied(review.id, review.body, seen) &&
37
+ canGenerateGithubMutation(review.viewerCanMinimize, "minimize") &&
38
+ shouldMinimizeAuthor(author.authorType, minimizeComments, author.login, bots));
39
+ }
40
+ export function countActionableSummaryReviews(input) {
41
+ const { raw, summaryActions, rules, confirmed, unconfirmed, blockedReviewIds, seen, viewerCanAdminister, minimizeApprovals, minimizeSupersededApprovals, minimizeComments, bots, } = input;
42
+ const latestStateByAuthor = new Map((raw.latestReviews?.nodes ?? []).flatMap((review) => review.author ? [[review.author.login.toLowerCase(), review.state]] : []));
43
+ const supersededApprovalIds = summarySupersededApprovalIds(raw);
44
+ const canMinimize = (review) => canMinimizeSummaryReview(review, blockedReviewIds, seen, minimizeComments, bots);
45
+ let actionable = 0;
46
+ for (const review of raw.reviews.nodes) {
47
+ if (review.state === "COMMENTED" || review.state === "DISMISSED") {
48
+ const action = summaryActions.get(review.id);
49
+ if (!action || ruleHides(action, "review-summary", confirmed.has(review.id)))
50
+ continue;
51
+ if (unconfirmed.has(review.id) ||
52
+ classifyItem(review.id, review.body, seen) !== "unchanged" ||
53
+ canMinimize(review))
54
+ actionable += 1;
55
+ continue;
56
+ }
57
+ if (review.state === "APPROVED") {
58
+ if ((minimizeApprovals &&
59
+ !review.isMinimized &&
60
+ (classifyItem(review.id, review.body, seen) !== "unchanged" || canMinimize(review))) ||
61
+ (minimizeSupersededApprovals && supersededApprovalIds.has(review.id) && canMinimize(review)))
62
+ actionable += 1;
63
+ continue;
64
+ }
65
+ if (review.state !== "CHANGES_REQUESTED")
66
+ continue;
67
+ const login = review.author?.login.toLowerCase();
68
+ if (login && latestStateByAuthor.get(login) === "APPROVED")
69
+ continue;
70
+ if (ruleHides(summaryRuleAction(rules, "changes-requested", review), "changes-requested", false))
71
+ continue;
72
+ const author = authorOf(review.author);
73
+ const isBot = !isHumanAuthor(author) || isConfiguredBotAuthor(author, bots);
74
+ if (!isBot ||
75
+ (canGenerateGithubMutation(viewerCanAdminister, "dismiss") &&
76
+ !mutationWasDenied(review.id, review.body, seen)) ||
77
+ classifyItem(review.id, review.body, seen) !== "unchanged")
78
+ actionable += 1;
79
+ }
80
+ return actionable;
81
+ }
@@ -1,18 +1,14 @@
1
- import { isConfiguredBotAuthor, isHumanAuthor, normalizeAuthorType, normalizeBotUsernames, } from "../comments/authors.mjs";
1
+ import { normalizeBotUsernames } from "../comments/authors.mjs";
2
2
  import { loadClassifyRules } from "../classify/loader.mjs";
3
3
  import { loadConfig } from "../config/load.mjs";
4
4
  import { getEffectiveCwd } from "../execution-context.mjs";
5
- import { classifyItem, mutationWasDenied } from "../state/seen-comments.mjs";
5
+ import { classifyItem } from "../state/seen-comments.mjs";
6
6
  import { threadEndedByShepherd } from "../comments/marker.mjs";
7
7
  import { threadTranscriptBodies } from "../threads/transcript.mjs";
8
- import { canGenerateGithubMutation } from "./mutation-policy.mjs";
9
8
  import { applySummaryRuleAutoResolve, } from "./poll-summary-rule-auto-resolve.mjs";
10
9
  import { countCommentWork, repeatingThreadIds } from "./poll-summary-review-parity.mjs";
11
10
  import { ruleHides, summaryRuleAction } from "./poll-summary-rule-items.mjs";
12
- const authorOf = (author) => ({
13
- login: author?.login ?? "",
14
- authorType: normalizeAuthorType(author?.__typename, author?.login),
15
- });
11
+ import { countActionableSummaryReviews } from "./poll-summary-review-helpers.mjs";
16
12
  /**
17
13
  * Count the review work a compact row routes to the full check. With `autoResolveKey` and
18
14
  * `actions.auto-minimize-suppressed` on, rule-driven auto-resolve runs first, exactly as in the
@@ -37,21 +33,31 @@ export async function evaluatePollSummaryReview(raw, seen, viewerCanAdminister,
37
33
  if (!comment.isMinimized)
38
34
  actions.comments.set(comment.id, summaryRuleAction(rules, "pr-comment", comment));
39
35
  for (const review of raw.reviews.nodes)
40
- if (review.state === "COMMENTED" && review.body.trim() !== "" && !review.isMinimized)
36
+ if ((review.state === "COMMENTED" || review.state === "DISMISSED") &&
37
+ review.body.trim() !== "" &&
38
+ !review.isMinimized)
41
39
  actions.summaries.set(review.id, summaryRuleAction(rules, "review-summary", review));
42
40
  const threadView = raw.reviewThreads.nodes.map((thread) => {
43
41
  const truncated = thread.comments.pageInfo.hasPreviousPage;
44
42
  if (truncated)
45
43
  incomplete = true;
46
44
  const root = thread.comments.nodes[0];
47
- const transcript = threadTranscriptBodies(thread.comments.nodes.map((c) => c.body));
45
+ const path = thread.path ?? root?.path ?? null;
46
+ const replies = thread.comments.nodes
47
+ .slice(1)
48
+ .filter((reply) => !summaryRuleAction(rules, "review-thread-reply", reply, reply.id, path, reply.body, thread.id).suppress);
49
+ const visibleComments = root ? [root, ...replies] : [];
50
+ const filteredThread = visibleComments.length === thread.comments.nodes.length
51
+ ? thread
52
+ : { ...thread, comments: { ...thread.comments, nodes: visibleComments } };
53
+ const transcript = threadTranscriptBodies(visibleComments.map((c) => c.body));
48
54
  // The window's last comment is the thread's last only when nothing lies beyond it.
49
55
  const ended = thread.isResolved === true &&
50
56
  !truncated &&
51
- threadEndedByShepherd({ body: root?.body ?? "", comments: thread.comments.nodes });
57
+ threadEndedByShepherd({ body: root?.body ?? "", comments: visibleComments });
52
58
  if (!ended)
53
- actions.threads.set(thread.id, summaryRuleAction(rules, "review-thread", root, thread.id, thread.path ?? root?.path ?? null, root?.body ?? ""));
54
- return { thread, truncated, root, transcript, ended };
59
+ actions.threads.set(thread.id, summaryRuleAction(rules, "review-thread", root, thread.id, path, root?.body ?? ""));
60
+ return { thread: filteredThread, truncated, root, transcript, ended };
55
61
  });
56
62
  const handled = autoResolveKey && config.actions["auto-minimize-suppressed"]
57
63
  ? await applySummaryRuleAutoResolve({ raw, actions, seen, key: autoResolveKey })
@@ -61,40 +67,25 @@ export async function evaluatePollSummaryReview(raw, seen, viewerCanAdminister,
61
67
  const action = actions.comments.get(comment.id);
62
68
  return action !== undefined && !ruleHides(action, "pr-comment", confirmed.has(comment.id));
63
69
  }), unconfirmed, seen, config.iterate["minimize-comments"], bots);
64
- const latestStateByAuthor = new Map((raw.latestReviews?.nodes ?? []).flatMap((review) => review.author ? [[review.author.login.toLowerCase(), review.state]] : []));
65
- for (const review of raw.reviews.nodes) {
66
- if (review.state === "COMMENTED") {
67
- const action = actions.summaries.get(review.id);
68
- if (!action || ruleHides(action, "review-summary", confirmed.has(review.id)))
69
- continue;
70
- if (unconfirmed.has(review.id) || classifyItem(review.id, review.body, seen) !== "unchanged")
71
- actionable += 1;
72
- continue;
73
- }
74
- // An approval is surfaced once, as work, when iterate.minimize-approvals is on.
75
- if (review.state === "APPROVED") {
76
- if (config.iterate["minimize-approvals"] &&
77
- !review.isMinimized &&
78
- classifyItem(review.id, review.body, seen) !== "unchanged")
79
- actionable += 1;
80
- continue;
81
- }
82
- if (review.state !== "CHANGES_REQUESTED")
83
- continue;
84
- const login = review.author?.login.toLowerCase();
85
- if (login && latestStateByAuthor.get(login) === "APPROVED")
86
- continue;
87
- if (ruleHides(summaryRuleAction(rules, "changes-requested", review), "changes-requested", false))
88
- continue;
89
- const author = authorOf(review.author);
90
- const isBot = !isHumanAuthor(author) || isConfiguredBotAuthor(author, bots);
91
- // The full check counts a human changes-requested review whether or not it was seen.
92
- if (!isBot ||
93
- (canGenerateGithubMutation(viewerCanAdminister, "dismiss") &&
94
- !mutationWasDenied(review.id, review.body, seen)) ||
95
- classifyItem(review.id, review.body, seen) !== "unchanged")
96
- actionable += 1;
97
- }
70
+ const blockedReviewIds = new Set(threadView.flatMap(({ thread, root }) => thread.isResolved === false &&
71
+ !confirmed.has(thread.id) &&
72
+ root?.pullRequestReview?.id !== undefined
73
+ ? [root.pullRequestReview.id]
74
+ : []));
75
+ actionable += countActionableSummaryReviews({
76
+ raw,
77
+ summaryActions: actions.summaries,
78
+ rules,
79
+ confirmed,
80
+ unconfirmed,
81
+ blockedReviewIds,
82
+ seen,
83
+ viewerCanAdminister,
84
+ minimizeApprovals: config.iterate["minimize-approvals"],
85
+ minimizeSupersededApprovals: config.iterate["minimize-superseded-approvals"],
86
+ minimizeComments: config.iterate["minimize-comments"],
87
+ bots,
88
+ });
98
89
  const repeating = repeatingThreadIds(threadView, seen, bots, config.iterate["resolve-other-human-threads"]);
99
90
  for (const { thread, truncated, transcript, ended } of threadView) {
100
91
  const action = actions.threads.get(thread.id);
@@ -82,6 +82,7 @@ export async function applySummaryRuleAutoResolve(input) {
82
82
  const partition = {
83
83
  suppressedCommentIds: new Set(comments.map((item) => item.id)),
84
84
  suppressedThreadIds: new Set(threads.map((item) => item.id)),
85
+ suppressedThreadReplyIds: new Set(),
85
86
  suppressedReviewSummaryIds: new Set(summaries.map((item) => item.id)),
86
87
  suppressedChangesRequestedIds: new Set(),
87
88
  ruleAutoResolveCommentIds: comments.map((item) => item.id),
@@ -11,7 +11,7 @@ export interface RuleSource {
11
11
  path?: string | null;
12
12
  }
13
13
  /** The rule action for one compact item, built like the full check builds its rule items. */
14
- export declare function summaryRuleAction(rules: Rules, kind: ClassifyItem["kind"], raw: RuleSource | undefined, id?: string, path?: string | null, body?: string): ClassifyAction;
14
+ export declare function summaryRuleAction(rules: Rules, kind: ClassifyItem["kind"], raw: RuleSource | undefined, id?: string, path?: string | null, body?: string, threadId?: string): ClassifyAction;
15
15
  /**
16
16
  * An auto-resolve match is hidden only once its mutation is confirmed or the item is already
17
17
  * resolved; until then it stays visible so the full check can run or surface it.
@@ -1,7 +1,7 @@
1
1
  import { applyRules } from "../classify/apply.mjs";
2
2
  import { normalizeAuthorType } from "../comments/authors.mjs";
3
3
  /** The rule action for one compact item, built like the full check builds its rule items. */
4
- export function summaryRuleAction(rules, kind, raw, id = raw?.id ?? "unknown", path, body = raw?.body ?? "") {
4
+ export function summaryRuleAction(rules, kind, raw, id = raw?.id ?? "unknown", path, body = raw?.body ?? "", threadId) {
5
5
  const item = {
6
6
  kind,
7
7
  id,
@@ -14,7 +14,8 @@ export function summaryRuleAction(rules, kind, raw, id = raw?.id ?? "unknown", p
14
14
  ...(kind !== "review-thread" && kind !== "changes-requested" && raw?.url
15
15
  ? { url: raw.url }
16
16
  : {}),
17
- ...(kind === "review-thread" && { path }),
17
+ ...((kind === "review-thread" || kind === "review-thread-reply") && { path }),
18
+ ...(kind === "review-thread-reply" && threadId !== undefined && { threadId }),
18
19
  };
19
20
  return applyRules(rules, item);
20
21
  }
@@ -8,6 +8,7 @@ import { mergeStartupFailureChecks } from "../checks/startup-failures.mjs";
8
8
  import { parseCheckNodes } from "./batch-parse-checks.mjs";
9
9
  import { parseBranchRules } from "./batch-parsers-rules.mjs";
10
10
  import { isReviewStale } from "./batch-parser-helpers.mjs";
11
+ import { findSupersededApprovalIds } from "../comments/superseded-approvals.mjs";
11
12
  import { readRest as rest, restRepoPath, restObject, restString } from "./rest-reader-core.mjs";
12
13
  import { restLatestReviews, restPendingReviews } from "./rest-review-read.mjs";
13
14
  import { headFreshAtUnix } from "./head-freshness.mjs";
@@ -73,11 +74,34 @@ export async function readRestSnapshot(pull, repo, context, knownViewerLogin) {
73
74
  return mapped;
74
75
  }),
75
76
  reviewSummaries: feedback.reviews
76
- .filter((review) => review.state === "COMMENTED" && review.body?.trim())
77
+ .filter((review) => (review.state === "COMMENTED" || review.state === "DISMISSED") && review.body?.trim())
77
78
  .map(restReviewToReview),
78
79
  approvedReviews: feedback.reviews
79
80
  .filter((review) => review.state === "APPROVED")
80
81
  .map(restReviewToReview),
82
+ ...(() => {
83
+ const supersededApprovalIds = [
84
+ ...findSupersededApprovalIds({
85
+ reviews: feedback.reviews
86
+ .filter((review) => review.state === "APPROVED" ||
87
+ review.state === "CHANGES_REQUESTED" ||
88
+ review.state === "DISMISSED" ||
89
+ review.state === "COMMENTED")
90
+ .map((review) => {
91
+ const mapped = restReviewToReview(review);
92
+ return {
93
+ id: mapped.id,
94
+ author: mapped.author,
95
+ state: review.state,
96
+ body: mapped.body,
97
+ createdAtUnix: mapped.createdAtUnix,
98
+ };
99
+ }),
100
+ latestReviews: [...latestReviews.values()],
101
+ }),
102
+ ];
103
+ return supersededApprovalIds.length > 0 ? { supersededApprovalIds } : {};
104
+ })(),
81
105
  checks: mergeStartupFailureChecks(parseCheckNodes(checks.nodes), checks.suites.flatMap((suite) => {
82
106
  const run = checks.workflowRuns.find((run) => run.check_suite_id === suite.id);
83
107
  if (suite.conclusion?.toUpperCase() !== "STARTUP_FAILURE" || !run)
@@ -0,0 +1,13 @@
1
+ import { type RepoInfo } from "./client.mts";
2
+ /** True when a node ID identifies a GitHub PullRequestReview (next-gen `PRR_` or legacy base64). */
3
+ export declare function isReviewNodeId(id: string): boolean;
4
+ /**
5
+ * Re-check only the specific thread IDs that local state last saw as unresolved, in case a
6
+ * reviewer or human resolved them outside `pr-shepherd`. Returns the subset still unresolved.
7
+ */
8
+ export declare function checkThreadsStillUnresolved(pr: number, repo: RepoInfo, threadIds: readonly string[]): Promise<Set<string>>;
9
+ /**
10
+ * Cold-cache fallback when no local `unresolvedInlineThreadIds` record exists for a review:
11
+ * scan the PR's review threads and return `reviewId -> unresolvedThreadIds[]`.
12
+ */
13
+ export declare function findUnresolvedThreadsByReviewId(pr: number, repo: RepoInfo, reviewIds: readonly string[]): Promise<Map<string, string[]>>;