pr-shepherd 2.4.0 → 2.5.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 (76) 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 +33 -1
  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/check-instructions.d.mts +2 -0
  21. package/bin/commands/iterate/check-instructions.mjs +14 -0
  22. package/bin/commands/iterate/classify.d.mts +17 -3
  23. package/bin/commands/iterate/classify.mjs +105 -66
  24. package/bin/commands/iterate/escalate.mjs +6 -1
  25. package/bin/commands/iterate/index.mjs +16 -24
  26. package/bin/commands/iterate/render.d.mts +2 -11
  27. package/bin/commands/iterate/render.mjs +10 -19
  28. package/bin/commands/iterate/stall.mjs +3 -0
  29. package/bin/commands/iterate/triage.d.mts +1 -0
  30. package/bin/commands/iterate/triage.mjs +18 -13
  31. package/bin/commands/poll-summary-instructions.d.mts +1 -1
  32. package/bin/commands/poll-summary-instructions.mjs +2 -2
  33. package/bin/commands/poll-summary.mjs +1 -1
  34. package/bin/commands/resolve-mutate.mjs +39 -4
  35. package/bin/commands/resolve-review-guard.d.mts +19 -0
  36. package/bin/commands/resolve-review-guard.mjs +61 -0
  37. package/bin/commands/stack-merge-escalations.d.mts +6 -0
  38. package/bin/commands/stack-merge-escalations.mjs +17 -0
  39. package/bin/commands/stack-merge-plan.mjs +10 -6
  40. package/bin/comments/resolve.mjs +4 -4
  41. package/bin/comments/review-thread-markers.d.mts +1 -1
  42. package/bin/comments/review-thread-markers.mjs +23 -9
  43. package/bin/comments/superseded-approvals.d.mts +28 -0
  44. package/bin/comments/superseded-approvals.mjs +99 -0
  45. package/bin/config/schema.d.mts +2 -0
  46. package/bin/config/schema.mjs +1 -0
  47. package/bin/github/batch-parsers.mjs +31 -0
  48. package/bin/github/batch-raw-types.d.mts +3 -0
  49. package/bin/github/batch-viewer.d.mts +2 -2
  50. package/bin/github/batch.mjs +1 -1
  51. package/bin/github/gql/batch-pr-page.gql +8 -2
  52. package/bin/github/gql/batch-pr.gql +4 -1
  53. package/bin/github/poll-summary-review-helpers.d.mts +20 -0
  54. package/bin/github/poll-summary-review-helpers.mjs +81 -0
  55. package/bin/github/poll-summary-review.mjs +37 -46
  56. package/bin/github/poll-summary-rule-auto-resolve.mjs +1 -0
  57. package/bin/github/poll-summary-rule-items.d.mts +1 -1
  58. package/bin/github/poll-summary-rule-items.mjs +3 -2
  59. package/bin/github/rest-batch-snapshot.mjs +25 -1
  60. package/bin/github/review-unresolved-threads.d.mts +13 -0
  61. package/bin/github/review-unresolved-threads.mjs +152 -0
  62. package/bin/github/stack-handoff-page.mjs +5 -1
  63. package/bin/state/seen-comments.d.mts +3 -1
  64. package/bin/state/seen-comments.mjs +28 -2
  65. package/bin/types/escalate.d.mts +1 -0
  66. package/bin/types/github.d.mts +7 -1
  67. package/bin/types/iterate.d.mts +4 -2
  68. package/bin/types/report.d.mts +8 -0
  69. package/package.json +5 -5
  70. package/plugins/pr-shepherd/.claude-plugin/plugin.json +3 -3
  71. package/plugins/pr-shepherd/.codex-plugin/plugin.json +6 -6
  72. package/plugins/pr-shepherd/skills/setup-pr-shepherd/SKILL.md +1 -1
  73. package/plugins/pr-shepherd/skills/setup-pr-shepherd/references/classifiers.md +3 -3
  74. package/plugins/pr-shepherd/skills/setup-pr-shepherd/references/upstream-standard-rule.md +2 -2
  75. package/pr-shepherd.schema.json +4 -0
  76. package/src/classify/types.mts +9 -1
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
3
  "description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
4
- "version": "2.4.0",
4
+ "version": "2.5.0",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
8
8
  },
9
- "homepage": "https://github.com/jonathanong/pr-shepherd",
10
- "repository": "https://github.com/jonathanong/pr-shepherd",
9
+ "homepage": "https://github.com/jongleberry/pr-shepherd",
10
+ "repository": "https://github.com/jongleberry/pr-shepherd",
11
11
  "license": "MIT",
12
12
  "keywords": ["github", "pull-request", "ci", "code-review", "automation"],
13
13
  "skills": "./plugins/pr-shepherd/skills/",
@@ -11,7 +11,7 @@
11
11
  "description": "Autonomous PR CI monitor and review-comment resolver",
12
12
  "source": { "type": "local", "path": "./plugins/pr-shepherd" },
13
13
  "category": "productivity",
14
- "homepage": "https://github.com/jonathanong/pr-shepherd"
14
+ "homepage": "https://github.com/jongleberry/pr-shepherd"
15
15
  }
16
16
  ]
17
17
  }
package/README.md CHANGED
@@ -84,15 +84,15 @@ The plugin ships the skills, which drive the CLI, so install both.
84
84
 
85
85
  ```bash
86
86
  # Claude Code
87
- claude plugin marketplace add jonathanong/harness-plugins
88
- claude plugin install pr-shepherd@harness-plugins
87
+ claude plugin marketplace add jongleberry/ratchet-stack
88
+ claude plugin install pr-shepherd@ratchet-stack
89
89
 
90
90
  # Codex
91
- codex plugin marketplace add jonathanong/harness-plugins --ref main
92
- codex plugin add pr-shepherd@harness-plugins
91
+ codex plugin marketplace add jongleberry/ratchet-stack --ref main
92
+ codex plugin add pr-shepherd@ratchet-stack
93
93
 
94
94
  # Grok
95
- grok plugin marketplace add jonathanong/pr-shepherd
95
+ grok plugin marketplace add jongleberry/pr-shepherd
96
96
  grok plugin install pr-shepherd --trust
97
97
 
98
98
  # CLI, for shells and CI
@@ -119,8 +119,6 @@ Requirements:
119
119
  - [Configuration](docs/configuration.md) and [comparison with other tools](docs/comparison.md)
120
120
  - [Upgrading from 0.x](docs/migrating-to-v1.md)
121
121
 
122
- ## Harness ecosystem
122
+ ## ratchet-stack
123
123
 
124
- - [hook-harness](https://github.com/jonathanong/hook-harness): GitHub webhook relay that agents poll for events instead of polling GitHub
125
- - [agent-blackboard](https://github.com/jonathanong/agent-blackboard): session-scoped telemetry for autonomous agents
126
- - [no-mistakes](https://github.com/jonathanong/no-mistakes): deterministic AST-based codebase intelligence, test selection, and linting for agents
124
+ pr-shepherd is part of [ratchet-stack](https://github.com/jongleberry/ratchet-stack), a set of plugins and tools for autonomous coding agents.
@@ -1,14 +1,16 @@
1
- import type { BatchPrData } from "../types.mts";
1
+ import type { BatchPrData, ReviewThread } from "../types.mts";
2
2
  import type { ClassifyItem, ClassifyAction } from "./types.mts";
3
3
  import type { LoadedRule } from "./loader.mts";
4
4
  export interface ClassifyIndex {
5
5
  suppressedIds: Set<string>;
6
+ suppressedThreadReplyIds: Set<string>;
6
7
  autoResolveIds: Set<string>;
7
8
  ruleReasons: Map<string, string[]>;
8
9
  }
9
10
  export interface BatchPartition {
10
11
  suppressedCommentIds: Set<string>;
11
12
  suppressedThreadIds: Set<string>;
13
+ suppressedThreadReplyIds: Set<string>;
12
14
  suppressedReviewSummaryIds: Set<string>;
13
15
  suppressedChangesRequestedIds: Set<string>;
14
16
  ruleAutoResolveCommentIds: string[];
@@ -20,3 +22,8 @@ export interface BatchPartition {
20
22
  export declare function applyRules(rules: LoadedRule[], item: ClassifyItem): ClassifyAction;
21
23
  export declare function buildClassifyIndex(rules: LoadedRule[], batch: BatchPrData): ClassifyIndex;
22
24
  export declare function partitionBatch(index: ClassifyIndex, batch: BatchPrData): BatchPartition;
25
+ /**
26
+ * Return threads with rule-suppressed reply comments removed, leaving each thread's root comment
27
+ * intact. Threads without matching replies are returned as-is.
28
+ */
29
+ export declare function stripSuppressedThreadReplies(threads: ReviewThread[], suppressedReplyIds: ReadonlySet<string>): ReviewThread[];
@@ -1,4 +1,5 @@
1
1
  import { collectAction } from "./rule-action.mjs";
2
+ import { changesRequestedToItem, commentToItem, reviewSummaryToItem, threadReplyToItem, threadToItem, } from "./items.mjs";
2
3
  export function applyRules(rules, item) {
3
4
  const applied = collectAction(rules, item);
4
5
  return {
@@ -7,50 +8,6 @@ export function applyRules(rules, item) {
7
8
  ...(applied.reasons.length > 0 && { reason: applied.reasons.join("; ") }),
8
9
  };
9
10
  }
10
- function threadToItem(t) {
11
- return {
12
- kind: "review-thread",
13
- id: t.id,
14
- author: t.author,
15
- authorType: t.authorType,
16
- ...(t.authorAssociation !== undefined && { authorAssociation: t.authorAssociation }),
17
- body: t.body,
18
- url: t.url,
19
- path: t.path,
20
- };
21
- }
22
- function commentToItem(c) {
23
- return {
24
- kind: "pr-comment",
25
- id: c.id,
26
- author: c.author,
27
- authorType: c.authorType,
28
- ...(c.authorAssociation !== undefined && { authorAssociation: c.authorAssociation }),
29
- body: c.body,
30
- url: c.url,
31
- };
32
- }
33
- function reviewSummaryToItem(r) {
34
- return {
35
- kind: "review-summary",
36
- id: r.id,
37
- author: r.author,
38
- authorType: r.authorType,
39
- ...(r.authorAssociation !== undefined && { authorAssociation: r.authorAssociation }),
40
- body: r.body,
41
- ...(r.url ? { url: r.url } : {}),
42
- };
43
- }
44
- function changesRequestedToItem(r) {
45
- return {
46
- kind: "changes-requested",
47
- id: r.id,
48
- author: r.author,
49
- authorType: r.authorType,
50
- ...(r.authorAssociation !== undefined && { authorAssociation: r.authorAssociation }),
51
- body: r.body,
52
- };
53
- }
54
11
  function addToIndex(id, applied, suppressedIds, autoResolveIds, ruleReasons) {
55
12
  if (applied.suppress)
56
13
  suppressedIds.add(id);
@@ -60,16 +17,30 @@ function addToIndex(id, applied, suppressedIds, autoResolveIds, ruleReasons) {
60
17
  ruleReasons.set(id, applied.reasons);
61
18
  }
62
19
  function emptyIndex() {
63
- return { suppressedIds: new Set(), autoResolveIds: new Set(), ruleReasons: new Map() };
20
+ return {
21
+ suppressedIds: new Set(),
22
+ suppressedThreadReplyIds: new Set(),
23
+ autoResolveIds: new Set(),
24
+ ruleReasons: new Map(),
25
+ };
64
26
  }
65
27
  export function buildClassifyIndex(rules, batch) {
66
28
  if (rules.length === 0)
67
29
  return emptyIndex();
68
30
  const suppressedIds = new Set();
31
+ const suppressedThreadReplyIds = new Set();
69
32
  const autoResolveIds = new Set();
70
33
  const ruleReasons = new Map();
71
34
  for (const t of batch.reviewThreads) {
72
35
  addToIndex(t.id, collectAction(rules, threadToItem(t)), suppressedIds, autoResolveIds, ruleReasons);
36
+ // Replies (after the root comment) can be suppressed individually; autoResolve is not supported.
37
+ for (const reply of (t.comments ?? []).slice(1)) {
38
+ const applied = collectAction(rules, threadReplyToItem(t, reply));
39
+ if (applied.suppress)
40
+ suppressedThreadReplyIds.add(reply.id);
41
+ if (applied.reasons.length > 0)
42
+ ruleReasons.set(reply.id, applied.reasons);
43
+ }
73
44
  }
74
45
  for (const c of batch.comments) {
75
46
  addToIndex(c.id, collectAction(rules, commentToItem(c)), suppressedIds, autoResolveIds, ruleReasons);
@@ -84,10 +55,10 @@ export function buildClassifyIndex(rules, batch) {
84
55
  if (applied.reasons.length > 0)
85
56
  ruleReasons.set(r.id, applied.reasons);
86
57
  }
87
- return { suppressedIds, autoResolveIds, ruleReasons };
58
+ return { suppressedIds, suppressedThreadReplyIds, autoResolveIds, ruleReasons };
88
59
  }
89
60
  export function partitionBatch(index, batch) {
90
- const { suppressedIds, autoResolveIds } = index;
61
+ const { suppressedIds, suppressedThreadReplyIds, autoResolveIds } = index;
91
62
  const suppressedCommentIds = new Set(batch.comments.filter((c) => suppressedIds.has(c.id)).map((c) => c.id));
92
63
  const suppressedThreadIds = new Set(batch.reviewThreads.filter((t) => suppressedIds.has(t.id)).map((t) => t.id));
93
64
  const suppressedReviewSummaryIds = new Set(batch.reviewSummaries.filter((r) => suppressedIds.has(r.id)).map((r) => r.id));
@@ -104,6 +75,7 @@ export function partitionBatch(index, batch) {
104
75
  return {
105
76
  suppressedCommentIds,
106
77
  suppressedThreadIds,
78
+ suppressedThreadReplyIds: new Set(suppressedThreadReplyIds),
107
79
  suppressedReviewSummaryIds,
108
80
  suppressedChangesRequestedIds,
109
81
  ruleAutoResolveCommentIds,
@@ -112,3 +84,21 @@ export function partitionBatch(index, batch) {
112
84
  ruleReasons: index.ruleReasons,
113
85
  };
114
86
  }
87
+ /**
88
+ * Return threads with rule-suppressed reply comments removed, leaving each thread's root comment
89
+ * intact. Threads without matching replies are returned as-is.
90
+ */
91
+ export function stripSuppressedThreadReplies(threads, suppressedReplyIds) {
92
+ if (suppressedReplyIds.size === 0)
93
+ return threads;
94
+ return threads.map((thread) => {
95
+ const comments = thread.comments;
96
+ if (!comments || comments.length <= 1)
97
+ return thread;
98
+ const filtered = [
99
+ comments[0],
100
+ ...comments.slice(1).filter((reply) => !suppressedReplyIds.has(reply.id)),
101
+ ];
102
+ return filtered.length === comments.length ? thread : { ...thread, comments: filtered };
103
+ });
104
+ }
@@ -0,0 +1,7 @@
1
+ import type { PrComment, Review, ReviewThread, ReviewThreadComment } from "../types.mts";
2
+ import type { ClassifyItem } from "./types.mts";
3
+ export declare function threadToItem(t: ReviewThread): ClassifyItem;
4
+ export declare function threadReplyToItem(t: ReviewThread, reply: ReviewThreadComment): ClassifyItem;
5
+ export declare function commentToItem(c: PrComment): ClassifyItem;
6
+ export declare function reviewSummaryToItem(r: Review): ClassifyItem;
7
+ export declare function changesRequestedToItem(r: Review): ClassifyItem;
@@ -0,0 +1,57 @@
1
+ export function threadToItem(t) {
2
+ return {
3
+ kind: "review-thread",
4
+ id: t.id,
5
+ author: t.author,
6
+ authorType: t.authorType,
7
+ ...(t.authorAssociation !== undefined && { authorAssociation: t.authorAssociation }),
8
+ body: t.body,
9
+ url: t.url,
10
+ path: t.path,
11
+ };
12
+ }
13
+ export function threadReplyToItem(t, reply) {
14
+ return {
15
+ kind: "review-thread-reply",
16
+ id: reply.id,
17
+ threadId: t.id,
18
+ author: reply.author,
19
+ authorType: reply.authorType,
20
+ ...(reply.authorAssociation !== undefined && { authorAssociation: reply.authorAssociation }),
21
+ body: reply.body,
22
+ ...(reply.url ? { url: reply.url } : {}),
23
+ path: t.path,
24
+ };
25
+ }
26
+ export function commentToItem(c) {
27
+ return {
28
+ kind: "pr-comment",
29
+ id: c.id,
30
+ author: c.author,
31
+ authorType: c.authorType,
32
+ ...(c.authorAssociation !== undefined && { authorAssociation: c.authorAssociation }),
33
+ body: c.body,
34
+ url: c.url,
35
+ };
36
+ }
37
+ export function reviewSummaryToItem(r) {
38
+ return {
39
+ kind: "review-summary",
40
+ id: r.id,
41
+ author: r.author,
42
+ authorType: r.authorType,
43
+ ...(r.authorAssociation !== undefined && { authorAssociation: r.authorAssociation }),
44
+ body: r.body,
45
+ ...(r.url ? { url: r.url } : {}),
46
+ };
47
+ }
48
+ export function changesRequestedToItem(r) {
49
+ return {
50
+ kind: "changes-requested",
51
+ id: r.id,
52
+ author: r.author,
53
+ authorType: r.authorType,
54
+ ...(r.authorAssociation !== undefined && { authorAssociation: r.authorAssociation }),
55
+ body: r.body,
56
+ };
57
+ }
@@ -1,7 +1,8 @@
1
1
  import type { ClassifyRule } from "../types.mts";
2
2
  /**
3
3
  * CodeRabbit progress, rate-limit, review-skipped and draft notices, its status-only command
4
- * replies, and its zero-findings, skipped-autofix, and failed-edit status comments. If the
4
+ * replies, its zero-findings, skipped-autofix, and failed-edit status comments, and its chat
5
+ * rate-limit notices (on conversation comments and review-thread replies). If a conversation
5
6
  * comment is later edited into a PR walkthrough, its new body no longer matches and Shepherd
6
7
  * surfaces the edited minimized comment to the agent.
7
8
  */
@@ -11,6 +11,20 @@ const STATUS_COMMENTS = [
11
11
  /^<!-- This is an auto-generated comment: autofix status by CodeRabbit -->\n> \[!NOTE\]\n> Autofix is a beta feature\.[^\n]*\n\nAutofix skipped\. No unresolved CodeRabbit review comments with fix instructions found\.\n<!-- autofix-run-id: [^\n]* -->$/,
12
12
  /^> \[!CAUTION\]\n> Failed to replace \(edit\) comment\. This is likely due to insufficient permissions or the comment being deleted\.\n> \n> <details>\n> <summary>Error details<\/summary>\n> \n> ```\n> [^`\n]*\n> ```\n> \n> <\/details>$/,
13
13
  ];
14
+ const CHAT_WAIT = String.raw `\d+ (?:hours?(?:, \d+ minutes?,? and \d+ seconds?| and \d+ (?:minutes?|seconds?))?|minutes?(?: and \d+ seconds?)?|seconds?)`;
15
+ const CHAT_COUNT = String.raw `(?:\d{1,3}(?:,\d{3})+|\d+)`;
16
+ /** CodeRabbit's chat rate-limit notice, posted on review-thread replies and conversation comments. */
17
+ const CHAT_RATE_LIMIT = new RegExp(String.raw `^### Rate Limit Exceeded\n\n` +
18
+ String.raw `(?:` +
19
+ "`@[A-Za-z0-9_-]+(?:\\[bot\\])?`" +
20
+ String.raw `|@[A-Za-z0-9_-]+(?:\[bot\])?|You) (?:have|has) exceeded the limit for the number of chat messages per (?:hour|minute|day)\. ` +
21
+ String.raw `Please wait \*\*${CHAT_WAIT}\*\* before sending another message\.` +
22
+ String.raw `(?:\n\nCodeRabbit didn['’]t process this message and won['’]t process it later\. ` +
23
+ String.raw `Send it again after \*\*\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} UTC\*\*\.)?` +
24
+ String.raw `(?:\n\nYou can send ${CHAT_COUNT} chat messages an? (?:hour|minute|day) in repositories owned by ` +
25
+ "`[A-Za-z0-9_-]+`" +
26
+ String.raw `\. The whole allowance comes back at once each (?:hour|minute|day), and a burst of messages within a few seconds pauses chat for about a minute\. ` +
27
+ String.raw `\[Chat rate limits\]\(https:\/\/docs\.coderabbit\.ai\/[^\s)]*\))?$`);
14
28
  /** One "Finishing Touches" option group: a bold title and only checkbox lines with plain labels. */
15
29
  const FINISHING_TOUCH_GROUP = "<details open>\\n<summary><strong>[^<\\n]+<\\/strong><\\/summary>\\n<dl>\\n<dd>\\n\\n(?:- \\[ \\] <!-- \\{[^\\n]*\\} --> [^<\\n]+\\n)+\\n<\\/dd>\\n<\\/dl>\\n<\\/details>\\n";
16
30
  /** The finishing-touch checkbox UI, with any checkbox ids and any number of option groups. */
@@ -20,6 +34,7 @@ const AUTOPILOT_BLOCK = /\n<!-- autopilot:start -->\n- \[ \] <!-- \{[^\n]*\} -->
20
34
  /** Strips CodeRabbit's footer and header blocks so only the notice envelope remains. */
21
35
  function stripChrome(body) {
22
36
  return body
37
+ .replace(/\r\n/g, "\n")
23
38
  .trim()
24
39
  .replace(/\n<!-- tips_start -->[\s\S]*?<!-- tips_end -->$/, "")
25
40
  .trim()
@@ -58,14 +73,31 @@ function isQuotedNotice(quoted) {
58
73
  }
59
74
  /**
60
75
  * CodeRabbit progress, rate-limit, review-skipped and draft notices, its status-only command
61
- * replies, and its zero-findings, skipped-autofix, and failed-edit status comments. If the
76
+ * replies, its zero-findings, skipped-autofix, and failed-edit status comments, and its chat
77
+ * rate-limit notices (on conversation comments and review-thread replies). If a conversation
62
78
  * comment is later edited into a PR walkthrough, its new body no longer matches and Shepherd
63
79
  * surfaces the edited minimized comment to the agent.
64
80
  */
65
81
  const rule = (item) => {
82
+ if (isBotItem(item, ["coderabbitai"], ["review-thread-reply"])) {
83
+ const body = stripChrome(item.body);
84
+ if (!CHAT_RATE_LIMIT.test(body))
85
+ return null;
86
+ return {
87
+ suppress: true,
88
+ reason: "CodeRabbit chat rate-limit notice",
89
+ };
90
+ }
66
91
  if (!isBotItem(item, ["coderabbitai"], ["pr-comment"]))
67
92
  return null;
68
93
  const body = stripChrome(item.body);
94
+ if (CHAT_RATE_LIMIT.test(body)) {
95
+ return {
96
+ autoResolve: true,
97
+ suppress: true,
98
+ reason: "CodeRabbit chat rate-limit notice",
99
+ };
100
+ }
69
101
  const envelope = body.match(NOTICE_ENVELOPE)?.[2];
70
102
  const quoted = envelope === undefined ? undefined : stripReviewInfo(envelope).trim();
71
103
  const isStatus = COMMAND_REPLY.test(body) || STATUS_COMMENTS.some((notice) => notice.test(body));
@@ -1,7 +1,8 @@
1
1
  import type { ClassifyRule } from "../types.mts";
2
2
  /**
3
3
  * Bundled classification rules that `classify.standard` can enable by name.
4
- * Each rule matches conversation comments (`pr-comment`) only.
4
+ * Rules match conversation comments (`pr-comment`) only, except `coderabbit-notices` also
5
+ * suppresses CodeRabbit's chat rate-limit notice on review-thread replies (`review-thread-reply`).
5
6
  */
6
7
  export declare const STANDARD_RULES: Readonly<Record<string, ClassifyRule>>;
7
8
  export declare const STANDARD_RULE_NAMES: readonly string[];
@@ -13,7 +13,8 @@ import sourceryNotices from "./sourcery-notices.mjs";
13
13
  import sourceryReviewGuide from "./sourcery-review-guide.mjs";
14
14
  /**
15
15
  * Bundled classification rules that `classify.standard` can enable by name.
16
- * Each rule matches conversation comments (`pr-comment`) only.
16
+ * Rules match conversation comments (`pr-comment`) only, except `coderabbit-notices` also
17
+ * suppresses CodeRabbit's chat rate-limit notice on review-thread replies (`review-thread-reply`).
17
18
  */
18
19
  export const STANDARD_RULES = {
19
20
  "claude-notices": claudeNotices,
@@ -1,6 +1,6 @@
1
1
  /** Raw relationship between a comment author and the repository, as reported by GitHub. */
2
2
  export type CommentAuthorAssociation = "COLLABORATOR" | "CONTRIBUTOR" | "FIRST_TIMER" | "FIRST_TIME_CONTRIBUTOR" | "MANNEQUIN" | "MEMBER" | "NONE" | "OWNER";
3
- export type ClassifyItemKind = "review-thread" | "pr-comment" | "review-summary" | "changes-requested";
3
+ export type ClassifyItemKind = "review-thread" | "review-thread-reply" | "pr-comment" | "review-summary" | "changes-requested";
4
4
  export interface ClassifyItemBase {
5
5
  readonly kind: ClassifyItemKind;
6
6
  readonly id: string;
@@ -14,6 +14,11 @@ export interface ClassifyReviewThread extends ClassifyItemBase {
14
14
  readonly kind: "review-thread";
15
15
  readonly path?: string | null;
16
16
  }
17
+ export interface ClassifyReviewThreadReply extends ClassifyItemBase {
18
+ readonly kind: "review-thread-reply";
19
+ readonly threadId: string;
20
+ readonly path?: string | null;
21
+ }
17
22
  export interface ClassifyPrComment extends ClassifyItemBase {
18
23
  readonly kind: "pr-comment";
19
24
  }
@@ -23,9 +28,9 @@ export interface ClassifyReviewSummary extends ClassifyItemBase {
23
28
  export interface ClassifyChangesRequested extends ClassifyItemBase {
24
29
  readonly kind: "changes-requested";
25
30
  }
26
- export type ClassifyItem = ClassifyReviewThread | ClassifyPrComment | ClassifyReviewSummary | ClassifyChangesRequested;
31
+ export type ClassifyItem = ClassifyReviewThread | ClassifyReviewThreadReply | ClassifyPrComment | ClassifyReviewSummary | ClassifyChangesRequested;
27
32
  export interface ClassifyAction {
28
- /** When true, routes the item's ID to the appropriate resolve/minimize GitHub mutation. Not supported for changes-requested reviews. */
33
+ /** When true, routes the item's ID to the appropriate resolve/minimize GitHub mutation. Not supported for changes-requested reviews or review-thread replies. */
29
34
  readonly autoResolve?: boolean;
30
35
  /** When true, hides the item from agent output (seen marker is still written). */
31
36
  readonly suppress?: boolean;
@@ -185,6 +185,9 @@ export function projectIterateLean(result, opts) {
185
185
  ...(result.triage.resolveOnlyCommand && {
186
186
  resolveOnlyCommand: result.triage.resolveOnlyCommand,
187
187
  }),
188
+ ...(result.triage.dismissReviewsCommand && {
189
+ dismissReviewsCommand: result.triage.dismissReviewsCommand,
190
+ }),
188
191
  ...(result.triage.reviewItems && { reviewItems: result.triage.reviewItems }),
189
192
  ...(result.triage.deferredWork && {
190
193
  deferredWork: nonZeroCounts(result.triage.deferredWork),
@@ -68,6 +68,7 @@ export declare function renderReviewBullet(r: {
68
68
  commitsSince?: number;
69
69
  }, opts?: {
70
70
  includeBody?: boolean;
71
+ pendingInlineThreads?: boolean;
71
72
  }): string;
72
73
  export declare function renderReviewListSection(heading: string, items: {
73
74
  id: string;
@@ -118,7 +118,9 @@ export function renderReviewBullet(r, opts = {}) {
118
118
  ? " [stale — review is on an old commit, all threads resolved]"
119
119
  : "";
120
120
  if (r.staleBotCr)
121
- return `${base}${staleTag} [pending dismissal — already surfaced; include in \`--dismiss-review-ids\`]`;
121
+ return opts.pendingInlineThreads
122
+ ? `${base}${staleTag} [pending inline threads — already surfaced; dismiss once all inline threads are resolved]`
123
+ : `${base}${staleTag} [pending dismissal — already surfaced; include in \`--dismiss-review-ids\`]`;
122
124
  const humanStaleTag = r.staleReview
123
125
  ? " [stale — review is on an old commit, all threads resolved; ask reviewer to re-review or dismiss]"
124
126
  : "";
@@ -152,6 +152,8 @@ export function formatTriageResult(header, result, opts = {}) {
152
152
  sections.push(result.triage.inProgressRuns.map(renderInProgressRun).join("\n\n"));
153
153
  }
154
154
  if (result.triage.changesRequestedReviews.length > 0) {
155
+ const dismissIds = new Set(result.triage.dismissReviewsCommand?.dismissReviewIds ?? []);
156
+ const blockedByThread = new Set([...result.triage.threads, ...result.triage.resolutionOnlyThreads].flatMap((t) => t.reviewId !== undefined ? [t.reviewId] : []));
155
157
  sections.push("## Changes-requested reviews");
156
158
  for (const r of result.triage.changesRequestedReviews) {
157
159
  // A stale bot CR that already had its full body surfaced on a prior tick stays a terse
@@ -161,7 +163,10 @@ export function formatTriageResult(header, result, opts = {}) {
161
163
  // review-summary/approval sections below, so the agent actually has a body to read —
162
164
  // the bare bullet this replaced only ever rendered the reviewId, never the body.
163
165
  if (r.staleBotCr) {
164
- sections.push(renderReviewBullet(r));
166
+ const pendingInlineThreads = r.pendingInlineThreads === true ||
167
+ (!dismissIds.has(r.id) &&
168
+ (blockedByThread.has(r.id) || result.triage.reviewItems !== undefined));
169
+ sections.push(renderReviewBullet(r, { pendingInlineThreads }));
165
170
  continue;
166
171
  }
167
172
  const staleTag = r.staleReview
@@ -13,7 +13,8 @@ export function filterSuppressedActivity(activity, partition, denied) {
13
13
  case "pr-comment":
14
14
  return !hidden(item.id, partition.suppressedCommentIds);
15
15
  case "review-thread-comment":
16
- return !item.threadId || !hidden(item.threadId, partition.suppressedThreadIds);
16
+ return (!partition.suppressedThreadReplyIds.has(item.id) &&
17
+ (!item.threadId || !hidden(item.threadId, partition.suppressedThreadIds)));
17
18
  case "review-summary":
18
19
  return !hidden(item.id, partition.suppressedReviewSummaryIds);
19
20
  case "changes-requested-review":
@@ -26,6 +26,7 @@ export function reportAllowsFingerprintSkip(report) {
26
26
  report.comments.firstLook.length === 0 &&
27
27
  report.changesRequestedReviews.length === 0 &&
28
28
  report.approvedReviews.length === 0 &&
29
+ (report.supersededApprovedReviews?.length ?? 0) === 0 &&
29
30
  report.firstLookSummaries.length === 0 &&
30
31
  report.editedSummaries.length === 0 &&
31
32
  (report.ruleAutoResolveReviewSummaryIds?.length ?? 0) === 0 &&
@@ -26,13 +26,15 @@ import { annotationMarkerBody, attachAndMergeCheckAnnotations, hasCheckDrivenAct
26
26
  import { buildTerminalReport } from "./check-terminal-report.mjs";
27
27
  import { headStillSettling } from "./check-settle.mjs";
28
28
  import { isBlockedByFilteredCheck, refreshReadyMergeability, refreshUnknownMergeability, } from "./ready-mergeability.mjs";
29
- import { loadSeenMap, markSeen, classifyItem, mutationWasDenied } from "../state/seen-comments.mjs";
29
+ import { loadSeenMap, markSeen, classifyItem, mutationWasDenied, pruneResolvedReviewThreads, } from "../state/seen-comments.mjs";
30
30
  import { aliasThreadSeenMarkers } from "../github/rest-identities.mjs";
31
31
  import { conversationResolutionProven, transportReadinessGaps, } from "../github/transport-evidence.mjs";
32
32
  import { canGenerateGithubMutation } from "../github/mutation-policy.mjs";
33
33
  import { threadTranscriptBody } from "../threads/transcript.mjs";
34
34
  import { classifyThreadVisibility } from "../comments/thread-visibility.mjs";
35
35
  import { classifyReviewsForDisplay, classifyChangesRequestedReviewsForDisplay, } from "../comments/review-visibility.mjs";
36
+ import { findSupersededApprovalIds, reviewOrderingEntriesFromReviews, } from "../comments/superseded-approvals.mjs";
37
+ import { shouldMinimizeAuthor } from "../comments/minimize-policy.mjs";
36
38
  import { applySuppressedRuleAutoResolve } from "./rule-auto-resolve.mjs";
37
39
  import { applyReviewOutputBudget } from "./check-review-budget.mjs";
38
40
  import { markReviewInlineThreadMarkers } from "../comments/review-thread-markers.mjs";
@@ -40,7 +42,7 @@ import { isConfiguredBotAuthor, isHumanAuthor, normalizeBotUsernames, } from "..
40
42
  import { buildThreadMutationRouting, threadHasAuthorizedMutation, } from "./iterate/thread-mutation-routing.mjs";
41
43
  import { loadClassifyRules } from "../classify/loader.mjs";
42
44
  import { filterSuppressedActivity } from "./check-activity.mjs";
43
- import { buildClassifyIndex, partitionBatch } from "../classify/apply.mjs";
45
+ import { buildClassifyIndex, partitionBatch, stripSuppressedThreadReplies, } from "../classify/apply.mjs";
44
46
  import { EXIT, ShepherdError } from "../exit-codes.mjs";
45
47
  import { getEffectiveCwd } from "../execution-context.mjs";
46
48
  function enforceTransportReadiness(status, data) {
@@ -69,7 +71,7 @@ export async function runCheck(opts, context) {
69
71
  async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
70
72
  const config = loadConfig();
71
73
  const reuseFingerprint = opts.fingerprintCache === true;
72
- const paginateApprovedReviews = config.iterate["minimize-approvals"];
74
+ const paginateApprovedReviews = config.iterate["minimize-approvals"] || config.iterate["minimize-superseded-approvals"];
73
75
  const includeReceiptSummary = (await context?.wantsReceiptSummary(prNumber, repo)) ?? false;
74
76
  // GraphQL transport: conditional REST change detectors can replay an idle report for free.
75
77
  // Changed trunk rules invalidate a cached report; check again without reuse.
@@ -209,6 +211,7 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
209
211
  const ruleSet = await loadClassifyRules(getEffectiveCwd(), config.standardRules);
210
212
  const classifyIndex = buildClassifyIndex(ruleSet, batchData);
211
213
  const partition = partitionBatch(classifyIndex, batchData);
214
+ const reviewThreads = stripSuppressedThreadReplies(batchData.reviewThreads, partition.suppressedThreadReplyIds);
212
215
  const merged = await attachAndMergeCheckAnnotations({ passing, failing: triagedBase, skipped, filtered }, seenMap, prNumber, { stateKey, headSha: batchData.headRefOid });
213
216
  const minimizedCommentCandidates = batchData.comments.filter((c) => c.isMinimized && !partition.suppressedCommentIds.has(c.id));
214
217
  const deniedRuleAutoResolveCommentIds = new Set(partition.ruleAutoResolveCommentIds.filter((id) => !canGenerateItemMutation(id, batchData.comments.find((comment) => comment.id === id)?.body ?? "", batchData.comments.find((comment) => comment.id === id)?.viewerCanMinimize, "minimize")));
@@ -216,11 +219,11 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
216
219
  .filter((comment) => mutationWasDenied(comment.id, comment.body, seenMap))
217
220
  .map((comment) => comment.id)));
218
221
  const deniedRuleAutoResolveThreadIds = new Set(partition.ruleAutoResolveThreadIds.filter((id) => {
219
- const thread = batchData.reviewThreads.find((candidate) => candidate.id === id);
222
+ const thread = reviewThreads.find((candidate) => candidate.id === id);
220
223
  return (thread?.isResolved !== false ||
221
224
  !canGenerateItemMutation(thread.id, threadTranscriptBody(thread), thread.viewerCanResolve, "resolve"));
222
225
  }));
223
- const visibleThreadCandidates = batchData.reviewThreads.filter((t) => !partition.suppressedThreadIds.has(t.id) || deniedRuleAutoResolveThreadIds.has(t.id));
226
+ const visibleThreadCandidates = reviewThreads.filter((t) => !partition.suppressedThreadIds.has(t.id) || deniedRuleAutoResolveThreadIds.has(t.id));
224
227
  const resolveOtherHumanThreads = config.iterate["resolve-other-human-threads"] ?? "none";
225
228
  const threadMutationRouting = buildThreadMutationRouting(visibleThreadCandidates, botUsernames, partition.ruleAutoResolveThreadIds, resolveOtherHumanThreads);
226
229
  const replyThreadIds = new Set(threadMutationRouting.replyThreadIds);
@@ -260,6 +263,16 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
260
263
  .filter((review) => mutationWasDenied(review.id, review.body, seenMap))
261
264
  .map((review) => review.id)));
262
265
  const approvedReviewVisibility = classifyReviewsForDisplay(batchData.approvedReviews, seenMap);
266
+ const supersededApprovalIdSet = findSupersededApprovalIds({
267
+ reviews: reviewOrderingEntriesFromReviews(batchData),
268
+ latestReviews: batchData.latestReviews,
269
+ ...(batchData.supersededApprovalIds && {
270
+ precomputedSupersededIds: new Set(batchData.supersededApprovalIds),
271
+ }),
272
+ });
273
+ const supersededApprovedReviews = batchData.approvedReviews.filter((review) => (config.iterate["minimize-approvals"] || supersededApprovalIdSet.has(review.id)) &&
274
+ shouldMinimizeAuthor(review.authorType, config.iterate["minimize-comments"], review.author, botUsernames) &&
275
+ canGenerateItemMutation(review.id, review.body, review.viewerCanMinimize, "minimize"));
263
276
  const changesRequestedReviews = changesRequestedReviewVisibility.visible;
264
277
  const visibleChangesRequestedIds = new Set(changesRequestedReviews.map((review) => review.id));
265
278
  const changesRequestedReviewCount = batchData.changesRequestedReviews.filter((review) => {
@@ -357,7 +370,7 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
357
370
  ...batchData.comments
358
371
  .filter((c) => partition.suppressedCommentIds.has(c.id) && !deniedRuleAutoResolveCommentIds.has(c.id))
359
372
  .map((c) => markSeen(stateKey, c.id, c.body)),
360
- ...batchData.reviewThreads
373
+ ...reviewThreads
361
374
  .filter((t) => partition.suppressedThreadIds.has(t.id) && !deniedRuleAutoResolveThreadIds.has(t.id))
362
375
  .map((t) => markSeen(stateKey, t.id, threadTranscriptBody(t))),
363
376
  ...batchData.reviewSummaries
@@ -368,12 +381,16 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
368
381
  .filter((r) => partition.suppressedChangesRequestedIds.has(r.id))
369
382
  .map((r) => markSeen(stateKey, r.id, r.body)),
370
383
  ]);
371
- await markReviewInlineThreadMarkers(stateKey, batchData.reviewThreads);
384
+ await markReviewInlineThreadMarkers(stateKey, batchData.reviewThreads, [
385
+ ...batchData.changesRequestedReviews.map((review) => review.id),
386
+ ...batchData.reviewSummaries.map((review) => review.id),
387
+ ...batchData.approvedReviews.map((review) => review.id),
388
+ ]);
372
389
  }
373
390
  const authorizedPartition = {
374
391
  ...partition,
375
392
  ruleAutoResolveThreadIds: partition.ruleAutoResolveThreadIds.filter((id) => {
376
- const thread = batchData.reviewThreads.find((candidate) => candidate.id === id);
393
+ const thread = reviewThreads.find((candidate) => candidate.id === id);
377
394
  return (thread?.isResolved === false &&
378
395
  canGenerateItemMutation(id, threadTranscriptBody(thread), thread.viewerCanResolve, "resolve"));
379
396
  }),
@@ -389,13 +406,24 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
389
406
  const { threadIds: authorizedRuleAutoResolveThreadIds, commentIds: ruleAutoResolveCommentIds, reviewSummaryIds: ruleAutoResolveReviewSummaryIds, autoResolved, autoMinimized, autoResolveErrors, errorReasons, } = await applySuppressedRuleAutoResolve({
390
407
  enabled: opts.autoMinimizeSuppressed === true,
391
408
  partition: authorizedPartition,
392
- batch: batchData,
409
+ batch: { ...batchData, reviewThreads },
393
410
  });
411
+ if (opts.persistSeen !== false && autoResolved.length > 0) {
412
+ await pruneResolvedReviewThreads(stateKey, autoResolved.map((item) => item.id));
413
+ }
394
414
  const visibleMutationThreadIds = new Set([...budgeted.threads.activeThreads, ...budgeted.threads.resolutionOnlyThreads].map((thread) => thread.id));
395
415
  const ruleAutoResolveThreadIds = [
396
416
  ...authorizedRuleAutoResolveThreadIds,
397
417
  ...[...deniedRuleAutoResolveThreadIds].filter((id) => visibleMutationThreadIds.has(id)),
398
418
  ];
419
+ const autoResolvedIdSet = new Set(autoResolved.map((item) => item.id));
420
+ const unresolvedThreadReviewIds = [
421
+ ...new Set(batchData.reviewThreads
422
+ .filter((thread) => thread.isResolved === false &&
423
+ thread.reviewId !== undefined &&
424
+ !autoResolvedIdSet.has(thread.id))
425
+ .map((thread) => thread.reviewId)),
426
+ ];
399
427
  mergeStatus = withTrunkRequiredContexts(mergeStatus, unreported.requiredContexts);
400
428
  const blockedByFilteredCheck = isBlockedByFilteredCheck(mergeStatus, verdict);
401
429
  const queueCommit = batchData.isInMergeQueue
@@ -462,8 +490,10 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
462
490
  firstLookSummaries: budgeted.firstLookSummaries,
463
491
  editedSummaries: budgeted.editedSummaries,
464
492
  approvedReviews: approvedReviewVisibility.visible,
493
+ ...(supersededApprovedReviews.length > 0 && { supersededApprovedReviews }),
465
494
  ...(reviewItems && { reviewItems }),
466
495
  ...(heldThreadReviewIds && { heldThreadReviewIds }),
496
+ ...(unresolvedThreadReviewIds.length > 0 && { unresolvedThreadReviewIds }),
467
497
  ...(ruleAutoResolveReviewSummaryIds.length > 0
468
498
  ? { ruleAutoResolveReviewSummaryIds }
469
499
  : undefined),
@@ -39,6 +39,8 @@ export declare function buildRepeatedWorkflowBranchRecoveryInstructions(baseBran
39
39
  * command records each item's disposition either way.
40
40
  */
41
41
  export declare function buildResolveCommandInstruction(resolveCommand: ResolveCommand, rendered: string): string[];
42
+ /** Build the separate review-dismissal / review-hiding step once all inline items are resolved. */
43
+ export declare function buildDismissReviewsCommandInstruction(dismissReviewsCommand: ResolveCommand | undefined, rendered: string): string[];
42
44
  /** One pointer. Conclusion, rerun, and bare-check rules live in the CI playbook. */
43
45
  export declare function buildFailingCheckInstructions(checks: AgentCheck[]): string[];
44
46
  /** Update the PR branch after an external blocker merges or closes. Never rerun that job. */