pr-shepherd 2.2.7 → 2.2.8

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.
@@ -1,7 +1,7 @@
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.2.7",
4
+ "version": "2.2.8",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
@@ -0,0 +1,9 @@
1
+ import type { ClassifyRule } from "../types.mts";
2
+ /**
3
+ * The `@claude` mention bot's in-progress placeholder comment (claude-code-action). The action
4
+ * edits this same comment into its result, so the rule only suppresses it and never auto-resolves:
5
+ * minimizing the placeholder would leave the finished review minimized. Once the comment is
6
+ * edited its body no longer matches, and Shepherd surfaces it as an edited comment.
7
+ */
8
+ declare const rule: ClassifyRule;
9
+ export default rule;
@@ -0,0 +1,26 @@
1
+ import { isBotItem } from "./author.mjs";
2
+ /** The title line, with the optional inline spinner image the action appends. */
3
+ const TITLE = "Claude Code is working…(?: <img [^>\\n]*>)?";
4
+ /** The to-do list the action shows while it works: a heading and only checkbox lines. */
5
+ const TODO_LIST = "#{2,4} To-?[Dd]o [Ll]ist:?\\n(?:\\n?- \\[[ xX]\\] [^\\n]+)+";
6
+ /** The run link the action appends: `[View job run](…/actions/runs/N)`. */
7
+ const JOB_LINK = "\\[View job(?: run)?\\]\\(https:\\/\\/[^\\s)]+\\/actions\\/runs\\/\\d+[^\\s)]*\\)";
8
+ /**
9
+ * The whole comment is the title, then optionally the intro sentence, the to-do list and a rule
10
+ * line, then optionally the run link. Any other text, such as the finished review, does not match.
11
+ */
12
+ const PLACEHOLDER = new RegExp(`^${TITLE}(?:\\n\\n(?:I'll analyze this and get back to you\\.|${TODO_LIST}))*(?:\\n\\n---)?(?:\\n\\n${JOB_LINK})?$`);
13
+ /**
14
+ * The `@claude` mention bot's in-progress placeholder comment (claude-code-action). The action
15
+ * edits this same comment into its result, so the rule only suppresses it and never auto-resolves:
16
+ * minimizing the placeholder would leave the finished review minimized. Once the comment is
17
+ * edited its body no longer matches, and Shepherd surfaces it as an edited comment.
18
+ */
19
+ const rule = (item) => {
20
+ if (!isBotItem(item, ["claude", "github-actions"], ["pr-comment"]))
21
+ return null;
22
+ if (!PLACEHOLDER.test(item.body.trim()))
23
+ return null;
24
+ return { suppress: true, reason: "Claude Code in-progress placeholder (edited into its result)" };
25
+ };
26
+ export default rule;
@@ -1,3 +1,4 @@
1
+ import claudeNotices from "./claude-notices.mjs";
1
2
  import coderabbitNotices from "./coderabbit-notices.mjs";
2
3
  import codecovReport from "./codecov-report.mjs";
3
4
  import codexNotices from "./codex-notices.mjs";
@@ -14,6 +15,7 @@ import sourceryNotices from "./sourcery-notices.mjs";
14
15
  * Each rule matches conversation comments (`pr-comment`) only.
15
16
  */
16
17
  export const STANDARD_RULES = {
18
+ "claude-notices": claudeNotices,
17
19
  "coderabbit-notices": coderabbitNotices,
18
20
  "codecov-report": codecovReport,
19
21
  "codex-notices": codexNotices,
@@ -45,6 +45,7 @@ export function projectIterateLean(result, opts) {
45
45
  pr: result.pr,
46
46
  repo: result.repo || undefined,
47
47
  ...(result.transport && { transport: result.transport }),
48
+ ...(result.transportReason && { transportReason: result.transportReason }),
48
49
  ...(result.transportUnavailable?.length && {
49
50
  transportUnavailable: result.transportUnavailable,
50
51
  }),
@@ -1,8 +1,10 @@
1
1
  import { loadConfig } from "../config/load.mjs";
2
- import { getGithubTransport } from "../github/transport.mjs";
2
+ import { getGithubTransportMode } from "../github/transport.mjs";
3
3
  /** Every emitted pr-shepherd command starts with the configured `cli-command` launcher. */
4
4
  export function buildPrShepherdCommand(args) {
5
- const transport = getGithubTransport() === "rest" &&
5
+ const transport =
6
+ // Only an explicit request propagates; an auto fallback is not the caller's choice and stays local.
7
+ getGithubTransportMode() === "rest" &&
6
8
  !args.some((arg) => arg === "--transport" || arg.startsWith("--transport="))
7
9
  ? ["--transport", "rest"]
8
10
  : [];
@@ -4,6 +4,8 @@ import { type StackLayerView } from "./stack-layer-view.mts";
4
4
  import type { NextCheck } from "../types/next-check.mts";
5
5
  export interface StackOverview {
6
6
  transport?: "rest";
7
+ /** Why REST is in use; present only with `transport`. */
8
+ transportReason?: string;
7
9
  transportUnavailable?: Array<{
8
10
  field: string;
9
11
  reason: string;
@@ -1,6 +1,6 @@
1
1
  import { stackLayerBlockReason } from "../commands/stack-layer-readiness.mjs";
2
2
  import { formatApiUsage, formatQuotaWarning } from "./api-usage-formatter.mjs";
3
- import { formatTransportEvidence } from "./transport-formatter.mjs";
3
+ import { formatTransportEvidence, projectTransportEvidence } from "./transport-formatter.mjs";
4
4
  import { removalDetail, trunkDetail } from "./stack-layer-view.mjs";
5
5
  import { formatNextCheckLines } from "./next-check-format.mjs";
6
6
  import { formatPrUrl } from "../pr-reference.mjs";
@@ -15,10 +15,7 @@ export function projectStackOverview(result) {
15
15
  return {
16
16
  mode: "summary",
17
17
  repo: result.repo,
18
- ...(result.transport && { transport: result.transport }),
19
- ...(result.transportUnavailable?.length && {
20
- transportUnavailable: result.transportUnavailable,
21
- }),
18
+ ...projectTransportEvidence(result),
22
19
  selection,
23
20
  reason: result.reason,
24
21
  ...(result.stackMergeable && { stackMergeable: true }),
@@ -1,9 +1,13 @@
1
1
  interface TransportEvidence {
2
2
  transport?: "rest";
3
+ /** Why REST is in use; present only with `transport`. */
4
+ transportReason?: string;
3
5
  transportUnavailable?: Array<{
4
6
  field: string;
5
7
  reason: string;
6
8
  }>;
7
9
  }
8
10
  export declare function formatTransportEvidence(value: TransportEvidence): string[];
11
+ /** The JSON counterpart of `formatTransportEvidence`: only the fields that carry information. */
12
+ export declare function projectTransportEvidence(value: TransportEvidence): TransportEvidence;
9
13
  export {};
@@ -1,6 +1,10 @@
1
1
  export function formatTransportEvidence(value) {
2
2
  return [
3
- ...(value.transport ? [`**transport** \`${value.transport}\``] : []),
3
+ ...(value.transport
4
+ ? [
5
+ `**transport** \`${value.transport}\`${value.transportReason ? ` (${value.transportReason})` : ""}`,
6
+ ]
7
+ : []),
4
8
  ...(value.transportUnavailable?.length
5
9
  ? [
6
10
  "",
@@ -11,3 +15,11 @@ export function formatTransportEvidence(value) {
11
15
  : []),
12
16
  ];
13
17
  }
18
+ /** The JSON counterpart of `formatTransportEvidence`: only the fields that carry information. */
19
+ export function projectTransportEvidence(value) {
20
+ return {
21
+ ...(value.transport && { transport: value.transport }),
22
+ ...(value.transportReason && { transportReason: value.transportReason }),
23
+ ...(value.transportUnavailable?.length && { transportUnavailable: value.transportUnavailable }),
24
+ };
25
+ }
@@ -1,3 +1,4 @@
1
+ import { transportReasonField } from "../github/transport-evidence.mjs";
1
2
  /** A merged PR answered from its first REST pull read never read reviews, threads or rules. */
2
3
  const requirementsUnread = (batchData) => (batchData.transportUnavailable ?? []).some(({ field }) => field === "mergeRequirements");
3
4
  function withoutRequirements(mergeStatus) {
@@ -9,6 +10,7 @@ export function buildTerminalReport(prNumber, repo, batchData, mergeStatus, stat
9
10
  pr: prNumber,
10
11
  nodeId: batchData.nodeId,
11
12
  ...(batchData.transport && { transport: batchData.transport }),
13
+ ...(batchData.transport && transportReasonField()),
12
14
  ...(batchData.transportUnavailable?.length && {
13
15
  transportUnavailable: batchData.transportUnavailable,
14
16
  }),
@@ -13,6 +13,7 @@ import { classifyChecks, getCiVerdict } from "../checks/classify.mjs";
13
13
  import { mergeStartupFailureChecks } from "../checks/startup-failures.mjs";
14
14
  import { withRunWorkflowPaths } from "../checks/run-workflow-paths.mjs";
15
15
  import { fetchStartupFailureChecks, triageFailingChecks } from "../checks/triage.mjs";
16
+ import { transportReasonField } from "../github/transport-evidence.mjs";
16
17
  import { TriageBudget } from "../checks/triage-budget.mjs";
17
18
  import { attachPendingDeployments } from "../checks/pending-deployments.mjs";
18
19
  import { deriveMergeStatus } from "../merge-status/derive.mjs";
@@ -393,6 +394,7 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
393
394
  pr: prNumber,
394
395
  nodeId: batchData.nodeId,
395
396
  ...(batchData.transport && { transport: batchData.transport }),
397
+ ...(batchData.transport && transportReasonField()),
396
398
  ...(batchData.transportUnavailable && {
397
399
  transportUnavailable: batchData.transportUnavailable,
398
400
  }),
@@ -6,6 +6,7 @@ export function buildIterateBase(report, readyState) {
6
6
  pr: report.pr,
7
7
  repo: report.repo,
8
8
  ...(report.transport && { transport: report.transport }),
9
+ ...(report.transportReason && { transportReason: report.transportReason }),
9
10
  ...(report.transportUnavailable?.length && {
10
11
  transportUnavailable: report.transportUnavailable,
11
12
  }),
@@ -29,6 +29,7 @@ export function buildTerminalCancelResult(report) {
29
29
  pr: report.pr,
30
30
  repo: report.repo,
31
31
  ...(report.transport && { transport: report.transport }),
32
+ ...(report.transportReason && { transportReason: report.transportReason }),
32
33
  ...(report.transportUnavailable?.length && {
33
34
  transportUnavailable: report.transportUnavailable,
34
35
  }),
@@ -3,6 +3,7 @@ import { loadConfig } from "../config/load.mjs";
3
3
  import { ShepherdError } from "../exit-codes.mjs";
4
4
  import { getRepoInfo } from "../github/client.mjs";
5
5
  import { getGithubTransport } from "../github/transport.mjs";
6
+ import { transportReasonField } from "../github/transport-evidence.mjs";
6
7
  import { withApiTelemetryScope, summarizeApiTelemetry } from "../github/api-telemetry.mjs";
7
8
  import { aggregateRerunCommand, stackApprovalCommands } from "../github/poll-summary-command.mjs";
8
9
  import { fetchPollSummary } from "../github/poll-summary.mjs";
@@ -70,6 +71,7 @@ async function readPollSummaryTick(opts) {
70
71
  selection: fetched.selection,
71
72
  reason: allTerminal ? "all_terminal" : actionable ? "actionable" : "waiting",
72
73
  prs: fetched.prs,
74
+ ...restReason(),
73
75
  ...(fetched.stackAncestry?.length && { stackAncestry: fetched.stackAncestry }),
74
76
  ...(fetched.allowedMergeMethods && { allowedMergeMethods: fetched.allowedMergeMethods }),
75
77
  };
@@ -261,3 +263,8 @@ function withoutImpliedOwnership(result) {
261
263
  return result;
262
264
  return { ...result, prs: result.prs.map(({ owned: _owned, ...item }) => item) };
263
265
  }
266
+ /** The summary says why Shepherd moved to REST on its own; a requested REST run says nothing. */
267
+ function restReason() {
268
+ const { transportReason } = transportReasonField();
269
+ return transportReason ? { transport: "rest", transportReason } : {};
270
+ }
@@ -1,3 +1,7 @@
1
+ /** `{ transportReason }` while REST is in use, so a result says why it is not on GraphQL. */
2
+ export declare function transportReasonField(): {
3
+ transportReason?: string;
4
+ };
1
5
  interface TransportEvidence {
2
6
  transport?: "rest";
3
7
  transportUnavailable?: Array<{
@@ -1,3 +1,9 @@
1
+ import { getGithubTransportReason } from "./transport.mjs";
2
+ /** `{ transportReason }` while REST is in use, so a result says why it is not on GraphQL. */
3
+ export function transportReasonField() {
4
+ const transportReason = getGithubTransportReason();
5
+ return transportReason ? { transportReason } : {};
6
+ }
1
7
  /** A future GitHub state cannot prove readiness through a negative blocker list. */
2
8
  export function isKnownMergeStateStatus(status) {
3
9
  return [
@@ -1,6 +1,13 @@
1
1
  import { type GithubTransport } from "./transport-mode.mts";
2
2
  export type { GithubTransport } from "./transport-mode.mts";
3
3
  export declare function getGithubTransport(): "graphql" | "rest";
4
+ /** The mode the caller selected (`--transport`, library option, or config), before any auto fallback. */
5
+ export declare function getGithubTransportMode(): GithubTransport;
6
+ /**
7
+ * Why Shepherd chose REST on its own; undefined on GraphQL and when the caller requested REST
8
+ * (that needs no explanation). Evidence for output, never a decision input.
9
+ */
10
+ export declare function getGithubTransportReason(): string | undefined;
4
11
  /** Cloud-session marker or the specific GraphQL refusal observed by this client. */
5
12
  export declare function isCcrTransport(): boolean;
6
13
  /** Each client retains its auto fallback without sharing state with other clients. */
@@ -20,6 +20,21 @@ export function getGithubTransport() {
20
20
  ? "rest"
21
21
  : "graphql";
22
22
  }
23
+ /** The mode the caller selected (`--transport`, library option, or config), before any auto fallback. */
24
+ export function getGithubTransportMode() {
25
+ return context.getStore()?.mode ?? configuredMode();
26
+ }
27
+ /**
28
+ * Why Shepherd chose REST on its own; undefined on GraphQL and when the caller requested REST
29
+ * (that needs no explanation). Evidence for output, never a decision input.
30
+ */
31
+ export function getGithubTransportReason() {
32
+ if (getGithubTransport() !== "rest" || getGithubTransportMode() === "rest")
33
+ return undefined;
34
+ if (process.env["CLAUDE_CODE_REMOTE"] === "true")
35
+ return "Claude Code cloud session (`CLAUDE_CODE_REMOTE=true`) starts on REST";
36
+ return context.getStore()?.state.reason;
37
+ }
23
38
  /** Cloud-session marker or the specific GraphQL refusal observed by this client. */
24
39
  export function isCcrTransport() {
25
40
  return process.env["CLAUDE_CODE_REMOTE"] === "true" || context.getStore()?.state.ccr === true;
@@ -51,6 +66,16 @@ function responseMessage(error) {
51
66
  catch { }
52
67
  return raw.trim();
53
68
  }
69
+ const FALLBACK_DESCRIPTION = {
70
+ refused: "GraphQL primary rate limit exhausted",
71
+ ccr: "Claude Code proxy refused GraphQL (HTTP 403)",
72
+ ambiguous: "GraphQL outage (server or network error after bounded retries)",
73
+ probe: "GraphQL primary rate limit exhausted",
74
+ };
75
+ function fallbackExplanation(name, reason, error) {
76
+ const detail = error instanceof Error ? ` (${error.message.replace(/\s+/g, " ").trim().slice(0, 160)})` : "";
77
+ return `auto switched to REST after GraphQL ${name}: ${FALLBACK_DESCRIPTION[reason]}${detail}`;
78
+ }
54
79
  function fallbackReason(error) {
55
80
  if (isTransportError(error))
56
81
  return "ambiguous";
@@ -110,6 +135,7 @@ export async function githubOperation(name, graphql, rest, options) {
110
135
  reason = "refused";
111
136
  }
112
137
  if (!current.state.fallback) {
138
+ current.state.reason = fallbackExplanation(name, reason, error);
113
139
  const message = `pr-shepherd: GitHub transport switched to REST after ${name} (${reason}).\n`;
114
140
  appendEntry(message);
115
141
  if (current.verbose)
@@ -19,6 +19,8 @@ export interface IterateResultSummary {
19
19
  }
20
20
  export interface IterateResultBase {
21
21
  transport?: "rest";
22
+ /** Why REST is in use; present only with `transport`. */
23
+ transportReason?: string;
22
24
  transportUnavailable?: Array<{
23
25
  field: string;
24
26
  reason: string;
@@ -133,6 +133,8 @@ export type StackMergeScope = {
133
133
  export type StackNextAction = "shepherd" | "wait" | "merge" | "cancel" | "escalate";
134
134
  export interface PollSummaryResult {
135
135
  transport?: "rest";
136
+ /** Why REST is in use; present only with `transport`. */
137
+ transportReason?: string;
136
138
  transportUnavailable?: Array<{
137
139
  field: string;
138
140
  reason: string;
@@ -38,6 +38,8 @@ export type EditedComment = PrComment & {
38
38
  export type ShepherdStatus = "MERGED" | "CLOSED" | "READY" | "FAILING" | "PENDING" | "IN_PROGRESS" | "UNRESOLVED_COMMENTS" | "UNKNOWN";
39
39
  export interface ShepherdReport {
40
40
  transport?: "rest";
41
+ /** Why REST is in use; present only with `transport`. */
42
+ transportReason?: string;
41
43
  transportUnavailable?: Array<{
42
44
  field: string;
43
45
  reason: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
5
5
  "keywords": [
6
6
  "automation",
@@ -1,7 +1,7 @@
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.2.7",
4
+ "version": "2.2.8",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for Codex.",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
@@ -2,7 +2,7 @@
2
2
 
3
3
  Use a classification rule when the unwanted item has a recognizable author and message pattern. Inspect a representative item first so the rule does not hide other feedback from the same bot. Prefer an existing settings control for polling- or output-wide behavior.
4
4
 
5
- Check the bundled rules first. Under `classify.standard` in the active config file, `all: true` enables every rule, and a named boolean such as `codecov-report: false` overrides `all`. They cover vendor bot notices on conversation comments only: `coderabbit-notices`, `codecov-report`, `codex-notices`, `dependabot-notices`, `dependency-review-no-issues`, `gemini-notices`, `kilo-no-issues`, `snyk-no-issues`, `socket-reports`, `sonarqube-gate-passed`, and `sourcery-notices`. They do not match review summaries or inline review comments. Write a custom rule only when no bundled rule fits. If a name here is rejected as unknown, this list is stale for the installed version; trust the error.
5
+ Check the bundled rules first. Under `classify.standard` in the active config file, `all: true` enables every rule, and a named boolean such as `codecov-report: false` overrides `all`. They cover vendor bot notices on conversation comments only: `claude-notices`, `coderabbit-notices`, `codecov-report`, `codex-notices`, `dependabot-notices`, `dependency-review-no-issues`, `gemini-notices`, `kilo-no-issues`, `snyk-no-issues`, `socket-reports`, `sonarqube-gate-passed`, and `sourcery-notices`. They do not match review summaries or inline review comments. Write a custom rule only when no bundled rule fits. If a name here is rejected as unknown, this list is stale for the installed version; trust the error.
6
6
 
7
7
  Place an `.mjs` file in `.pr-shepherd/classification/` in the project. Shepherd uses the first classification directory on the working directory's ancestor chain; it stops at the home directory if reached, otherwise at the filesystem root. A home-level rule directory is not discovered when the project is outside the home tree. Rule directories do not merge. Files ending in `.ts`, `.mts`, `.mjs`, or `.js` load, except names beginning with `_` or `.`. Prefer `.mjs`; an `.mts` rule also works if it uses only erasable TypeScript syntax.
8
8
 
@@ -361,6 +361,7 @@
361
361
  "type": "string",
362
362
  "enum": [
363
363
  "all",
364
+ "claude-notices",
364
365
  "coderabbit-notices",
365
366
  "codecov-report",
366
367
  "codex-notices",