pr-shepherd 2.2.14 → 2.2.16
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/.claude-plugin/plugin.json +1 -1
- package/README.md +8 -7
- package/bin/classify/standard/index.mjs +2 -0
- package/bin/classify/standard/sourcery-notices.d.mts +1 -1
- package/bin/classify/standard/sourcery-notices.mjs +6 -2
- package/bin/classify/standard/sourcery-review-guide.d.mts +9 -0
- package/bin/classify/standard/sourcery-review-guide.mjs +21 -0
- package/bin/commands/check-fingerprint.mjs +3 -0
- package/bin/commands/check-settle.d.mts +11 -0
- package/bin/commands/check-settle.mjs +19 -0
- package/bin/commands/check.mjs +12 -1
- package/bin/commands/iterate/fresh-summary-regression.d.mts +12 -0
- package/bin/commands/iterate/fresh-summary-regression.mjs +24 -0
- package/bin/commands/iterate/index.mjs +20 -7
- package/bin/github/batch-parsers.mjs +9 -0
- package/bin/github/batch-raw-types.d.mts +2 -0
- package/bin/github/gql/batch-pr.gql +1 -0
- package/bin/github/gql/commit-check-suites.gql +1 -0
- package/bin/github/head-freshness.d.mts +14 -0
- package/bin/github/head-freshness.mjs +23 -0
- package/bin/github/rest-batch-snapshot.mjs +6 -0
- package/bin/github/rest-pr-core.d.mts +1 -0
- package/bin/types/github.d.mts +5 -0
- package/bin/types/report.d.mts +5 -0
- package/package.json +5 -6
- package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/references/create-a-pr.md +1 -1
- package/plugins/pr-shepherd/skills/setup-pr-shepherd/references/classifiers.md +1 -1
- package/pr-shepherd.schema.json +2 -1
- package/.agents/plugins/marketplace.json +0 -20
- package/.claude-plugin/marketplace.json +0 -18
package/README.md
CHANGED
|
@@ -4,10 +4,10 @@ Take pull requests from scratch to merge-ready with a coding agent, as a [Code M
|
|
|
4
4
|
|
|
5
5
|
## Benefits
|
|
6
6
|
|
|
7
|
-
- **Better decisions:** across
|
|
8
|
-
- **Lower cost:** modeled cost per PR session is about
|
|
7
|
+
- **Better decisions:** across 71 PR states, it scores 0.95 with the plugin vs. 0.57 with `gh` + the GitHub MCP server ([outcome evals](evals/README.md), 2026-11-23).
|
|
8
|
+
- **Lower cost:** modeled cost per PR session is about 34% lower than `gh` and 75% lower than the GitHub MCP server, with 18% / 69% fewer turns ([token bench](evals/tokens/README.md); assumes a warm prompt cache).
|
|
9
9
|
- **More PRs on one GitHub quota:** 65% fewer GraphQL points than `gh` per PR session. While CI runs, a 5,000-point hourly budget covers about 80 waiting PRs, vs. about 13 with `gh pr checks --watch` ([GitHub API](docs/github-api.md), [GraphQL usage](docs/graphql-usage.md)). A [GitHub App](docs/github-app.md) and [webhook events](docs/hook-harness.md) cut it more.
|
|
10
|
-
- **
|
|
10
|
+
- **76 GitHub edge cases handled:** outdated or resolved threads are still shown once, edited comments come back, and conflicts that GraphQL reports as `CLEAN` are caught ([handled cases](docs/handled-cases.md)).
|
|
11
11
|
- **Tidy PRs, less context:** bot and outdated comments are triaged and resolved, human reviews get replies, and known bot noise is minimized and filtered out before it reaches the agent.
|
|
12
12
|
- **Review hygiene:** it never answers its own replies or minimizes human comments, skips a denied reply once, and hands a repeatedly rejected fix to a human ([comments and reviews](docs/handled-cases.md#comments-and-reviews)).
|
|
13
13
|
- **CI failures, pre-read:** each failing check comes with its failed step, summary, and log excerpt, so the agent rarely fetches logs. Superseded runs, unstarted required checks, and approval gates are recognized ([failing checks](docs/actions.md#failing-checks-and-reruns), [CI cases](docs/handled-cases.md#ci-checks)).
|
|
@@ -82,11 +82,12 @@ The plugin ships the skills, which drive the CLI, so install both.
|
|
|
82
82
|
|
|
83
83
|
```bash
|
|
84
84
|
# Claude Code
|
|
85
|
-
claude
|
|
86
|
-
claude
|
|
85
|
+
claude plugin marketplace add jonathanong/harness-plugins
|
|
86
|
+
claude plugin install pr-shepherd@harness-plugins
|
|
87
87
|
|
|
88
|
-
# Codex
|
|
89
|
-
codex plugin marketplace add jonathanong/
|
|
88
|
+
# Codex
|
|
89
|
+
codex plugin marketplace add jonathanong/harness-plugins --ref main
|
|
90
|
+
codex plugin add pr-shepherd@harness-plugins
|
|
90
91
|
|
|
91
92
|
# Grok
|
|
92
93
|
grok plugin marketplace add jonathanong/pr-shepherd
|
|
@@ -10,6 +10,7 @@ import snykNoIssues from "./snyk-no-issues.mjs";
|
|
|
10
10
|
import socketReports from "./socket-reports.mjs";
|
|
11
11
|
import sonarqubeGatePassed from "./sonarqube-gate-passed.mjs";
|
|
12
12
|
import sourceryNotices from "./sourcery-notices.mjs";
|
|
13
|
+
import sourceryReviewGuide from "./sourcery-review-guide.mjs";
|
|
13
14
|
/**
|
|
14
15
|
* Bundled classification rules that `classify.standard` can enable by name.
|
|
15
16
|
* Each rule matches conversation comments (`pr-comment`) only.
|
|
@@ -27,5 +28,6 @@ export const STANDARD_RULES = {
|
|
|
27
28
|
"socket-reports": socketReports,
|
|
28
29
|
"sonarqube-gate-passed": sonarqubeGatePassed,
|
|
29
30
|
"sourcery-notices": sourceryNotices,
|
|
31
|
+
"sourcery-review-guide": sourceryReviewGuide,
|
|
30
32
|
};
|
|
31
33
|
export const STANDARD_RULE_NAMES = Object.keys(STANDARD_RULES);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ClassifyRule } from "../types.mts";
|
|
2
|
-
/** Complete Sourcery private-repo upsell
|
|
2
|
+
/** Complete Sourcery private-repo upsell, weekly rate-limit, and review-budget notices. */
|
|
3
3
|
declare const rule: ClassifyRule;
|
|
4
4
|
export default rule;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { isBotItem } from "./author.mjs";
|
|
2
2
|
const NO_ACCESS = /^Hi @[A-Za-z0-9-]+! 👋\n\nYour private repo does not have access to Sourcery\.\n\nPlease \[upgrade\]\(https:\/\/app\.sourcery\.ai\/[^\s)]*\) to continue using Sourcery ✨$/;
|
|
3
3
|
const RATE_LIMIT = /^Sorry @[A-Za-z0-9-]+, you have reached your weekly rate limit for Sourcery\. Please try again later\.$/;
|
|
4
|
-
|
|
4
|
+
const WAIT = String.raw `\d+ (?:days? and \d+ hours?|days?|hours? and \d+ minutes?|hours?|minutes?)`;
|
|
5
|
+
const REVIEW_BUDGET = new RegExp(String.raw `^Sorry @[A-Za-z0-9-]+, you've used your own review budget of \d{1,3}(?:,\d{3})* diff characters for the last \d+ days?\.` +
|
|
6
|
+
String.raw `\n\nYou can request another review in ${WAIT} by commenting \`@sourcery-ai review\`\. ` +
|
|
7
|
+
String.raw `\[Upgrade\]\(https:\/\/app\.sourcery\.ai\/[^\s)]*\) to get a review now\.$`);
|
|
8
|
+
/** Complete Sourcery private-repo upsell, weekly rate-limit, and review-budget notices. */
|
|
5
9
|
const rule = (item) => {
|
|
6
10
|
if (!isBotItem(item, ["sourcery-ai"], ["pr-comment"]))
|
|
7
11
|
return null;
|
|
@@ -9,7 +13,7 @@ const rule = (item) => {
|
|
|
9
13
|
if (NO_ACCESS.test(body)) {
|
|
10
14
|
return { autoResolve: true, suppress: true, reason: "Sourcery no-access upsell" };
|
|
11
15
|
}
|
|
12
|
-
if (RATE_LIMIT.test(body)) {
|
|
16
|
+
if (RATE_LIMIT.test(body) || REVIEW_BUDGET.test(body)) {
|
|
13
17
|
return { autoResolve: true, suppress: true, reason: "Sourcery rate-limit notice" };
|
|
14
18
|
}
|
|
15
19
|
return null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassifyRule } from "../types.mts";
|
|
2
|
+
/**
|
|
3
|
+
* Sourcery's "Reviewer's Guide" conversation comment: a summary of the PR's own diff with a tips
|
|
4
|
+
* section, edited in place on each push. The whole body must be one guide, framed by its start and
|
|
5
|
+
* end markers. Any content outside them, a second guide, or a marker of another kind (such as the
|
|
6
|
+
* linked-issues report, which can list unmet requirements) keeps it visible.
|
|
7
|
+
*/
|
|
8
|
+
declare const rule: ClassifyRule;
|
|
9
|
+
export default rule;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isBotItem } from "./author.mjs";
|
|
2
|
+
const START = "<!-- Generated by sourcery-ai[bot]: start review_guide -->";
|
|
3
|
+
const END = "<!-- Generated by sourcery-ai[bot]: end review_guide -->";
|
|
4
|
+
const ANY_MARKER = /<!-- Generated by sourcery-ai\[bot\]: [^>]*-->/g;
|
|
5
|
+
/**
|
|
6
|
+
* Sourcery's "Reviewer's Guide" conversation comment: a summary of the PR's own diff with a tips
|
|
7
|
+
* section, edited in place on each push. The whole body must be one guide, framed by its start and
|
|
8
|
+
* end markers. Any content outside them, a second guide, or a marker of another kind (such as the
|
|
9
|
+
* linked-issues report, which can list unmet requirements) keeps it visible.
|
|
10
|
+
*/
|
|
11
|
+
const rule = (item) => {
|
|
12
|
+
if (!isBotItem(item, ["sourcery-ai"], ["pr-comment"]))
|
|
13
|
+
return null;
|
|
14
|
+
const body = item.body.trim();
|
|
15
|
+
if (!body.startsWith(START) || !body.endsWith(END))
|
|
16
|
+
return null;
|
|
17
|
+
if ([...body.matchAll(ANY_MARKER)].length !== 2)
|
|
18
|
+
return null;
|
|
19
|
+
return { autoResolve: true, suppress: true, reason: "Sourcery Reviewer's Guide" };
|
|
20
|
+
};
|
|
21
|
+
export default rule;
|
|
@@ -14,6 +14,9 @@ export function reportAllowsFingerprintSkip(report) {
|
|
|
14
14
|
return false;
|
|
15
15
|
if (report.mergeQueue?.removalAcknowledged === true)
|
|
16
16
|
return false;
|
|
17
|
+
// The settle window ends with the clock, not with any change a fingerprint could see.
|
|
18
|
+
if (report.awaitingCheckRegistration === true)
|
|
19
|
+
return false;
|
|
17
20
|
return (report.threads.actionable.length === 0 &&
|
|
18
21
|
report.threads.resolutionOnly.length === 0 &&
|
|
19
22
|
report.threads.firstLook.length === 0 &&
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True while a head with no relevant check and no running Actions suite is younger than the
|
|
3
|
+
* settle window. `headFreshAtUnix` is when the head last reached GitHub; without it the head is
|
|
4
|
+
* treated as settled, so an unknown age never holds a PR back.
|
|
5
|
+
*/
|
|
6
|
+
export declare function headStillSettling(input: {
|
|
7
|
+
hasChecks: boolean;
|
|
8
|
+
actionsWorkflowInProgress: boolean;
|
|
9
|
+
headFreshAtUnix?: number | undefined;
|
|
10
|
+
nowUnix: number;
|
|
11
|
+
}): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seconds after a head reaches GitHub during which a PR with no relevant check cannot be READY.
|
|
3
|
+
* Apps and Actions register their checks a few seconds after the push, and GitHub reports
|
|
4
|
+
* `CLEAN` with an empty rollup until they do. A constant, not a config key: it is internal
|
|
5
|
+
* tuning with a safe value, and a repository with no CI still finishes once the window passes.
|
|
6
|
+
*/
|
|
7
|
+
const CHECK_SETTLE_SECONDS = 60;
|
|
8
|
+
/**
|
|
9
|
+
* True while a head with no relevant check and no running Actions suite is younger than the
|
|
10
|
+
* settle window. `headFreshAtUnix` is when the head last reached GitHub; without it the head is
|
|
11
|
+
* treated as settled, so an unknown age never holds a PR back.
|
|
12
|
+
*/
|
|
13
|
+
export function headStillSettling(input) {
|
|
14
|
+
if (input.hasChecks || input.actionsWorkflowInProgress)
|
|
15
|
+
return false;
|
|
16
|
+
if (input.headFreshAtUnix === undefined)
|
|
17
|
+
return false;
|
|
18
|
+
return input.nowUnix - input.headFreshAtUnix < CHECK_SETTLE_SECONDS;
|
|
19
|
+
}
|
package/bin/commands/check.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { withHeadOid } from "./review-commit.mjs";
|
|
|
23
23
|
import { computeStatus } from "./check-status.mjs";
|
|
24
24
|
import { annotationMarkerBody, attachAndMergeCheckAnnotations, hasCheckDrivenActionableWork, isQueuedConflict, } from "./check-annotations.mjs";
|
|
25
25
|
import { buildTerminalReport } from "./check-terminal-report.mjs";
|
|
26
|
+
import { headStillSettling } from "./check-settle.mjs";
|
|
26
27
|
import { isBlockedByFilteredCheck, refreshReadyMergeability, refreshUnknownMergeability, } from "./ready-mergeability.mjs";
|
|
27
28
|
import { loadSeenMap, markSeen, classifyItem, mutationWasDenied } from "../state/seen-comments.mjs";
|
|
28
29
|
import { aliasThreadSeenMarkers } from "../github/rest-identities.mjs";
|
|
@@ -267,8 +268,17 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
|
|
|
267
268
|
canGenerateItemMutation(review.id, review.body, batchData.viewerAuthorization?.viewerCanAdminister, "dismiss") ||
|
|
268
269
|
visibleChangesRequestedIds.has(review.id));
|
|
269
270
|
}).length;
|
|
271
|
+
// A head that reached GitHub moments ago has no checks yet because they are not registered,
|
|
272
|
+
// not because the repository has none; hold READY until the settle window passes.
|
|
273
|
+
const settling = headStillSettling({
|
|
274
|
+
hasChecks: verdict.hasChecks,
|
|
275
|
+
actionsWorkflowInProgress: unreported.actionsWorkflowInProgress === true,
|
|
276
|
+
headFreshAtUnix: batchData.headFreshAtUnix,
|
|
277
|
+
nowUnix: Math.floor(Date.now() / 1000),
|
|
278
|
+
});
|
|
270
279
|
const awaitingChecks = unreported.hasUnreportedRequired ||
|
|
271
|
-
(!verdict.hasChecks && unreported.actionsWorkflowInProgress === true)
|
|
280
|
+
(!verdict.hasChecks && unreported.actionsWorkflowInProgress === true) ||
|
|
281
|
+
settling;
|
|
272
282
|
let status = computeStatus(verdict, threadVisibility.activeThreads.length + threadVisibility.resolutionOnlyThreads.length, visibleCommentClassification.actionable.length, mergeStatus, changesRequestedReviewCount, awaitingChecks);
|
|
273
283
|
status = enforceTransportReadiness(status, batchData);
|
|
274
284
|
// Resolve any pending mergeability refresh (and the resulting MERGED/CLOSED short-circuit)
|
|
@@ -497,6 +507,7 @@ async function runScopedCheck(opts, context, repo, prNumber, stateKey) {
|
|
|
497
507
|
...(unreported.actionsWorkflowInProgress && {
|
|
498
508
|
actionsWorkflowInProgress: true,
|
|
499
509
|
}),
|
|
510
|
+
...(settling && { awaitingCheckRegistration: true }),
|
|
500
511
|
...(unreported.stackBottomPr !== undefined && {
|
|
501
512
|
stackBottomPr: unreported.stackBottomPr,
|
|
502
513
|
}),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PollSummaryChecks } from "../../types.mts";
|
|
2
|
+
import type { RawSummaryPr } from "../../github/poll-summary-raw.mts";
|
|
3
|
+
/**
|
|
4
|
+
* Why the fresh read taken just before a READY is certified contradicts that READY report, or
|
|
5
|
+
* `undefined` when it does not. Only evidence the next full check will also see counts: a
|
|
6
|
+
* relevant check still running, a running Actions suite with no relevant check, or a merge
|
|
7
|
+
* state that changed to `UNSTABLE`, `DIRTY` or `BEHIND`. Failing checks, unreported required
|
|
8
|
+
* checks and a transient `UNKNOWN` are left to the next full check, and so is anything the
|
|
9
|
+
* summary cannot confirm (an unavailable read, incomplete pages), so a summary that merely
|
|
10
|
+
* disagrees with the one-PR check cannot hold a PR until the stall timeout.
|
|
11
|
+
*/
|
|
12
|
+
export declare function freshSummaryRegression(raw: RawSummaryPr, checks: PollSummaryChecks, reportMergeStateStatus: string): string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { hasNoRelevantChecks } from "../../github/poll-summary-unreported.mjs";
|
|
2
|
+
/** Merge states that show the PR left the state its READY report saw. */
|
|
3
|
+
const LEFT_CLEAN_STATES = new Set(["UNSTABLE", "DIRTY", "BEHIND"]);
|
|
4
|
+
/**
|
|
5
|
+
* Why the fresh read taken just before a READY is certified contradicts that READY report, or
|
|
6
|
+
* `undefined` when it does not. Only evidence the next full check will also see counts: a
|
|
7
|
+
* relevant check still running, a running Actions suite with no relevant check, or a merge
|
|
8
|
+
* state that changed to `UNSTABLE`, `DIRTY` or `BEHIND`. Failing checks, unreported required
|
|
9
|
+
* checks and a transient `UNKNOWN` are left to the next full check, and so is anything the
|
|
10
|
+
* summary cannot confirm (an unavailable read, incomplete pages), so a summary that merely
|
|
11
|
+
* disagrees with the one-PR check cannot hold a PR until the stall timeout.
|
|
12
|
+
*/
|
|
13
|
+
export function freshSummaryRegression(raw, checks, reportMergeStateStatus) {
|
|
14
|
+
if ((checks.inProgress ?? 0) > 0)
|
|
15
|
+
return "a relevant check is queued or in progress";
|
|
16
|
+
if (checks.actionsWorkflowInProgress === true && hasNoRelevantChecks(checks)) {
|
|
17
|
+
return "an Actions workflow suite is still running";
|
|
18
|
+
}
|
|
19
|
+
if (raw.mergeStateStatus !== reportMergeStateStatus &&
|
|
20
|
+
LEFT_CLEAN_STATES.has(raw.mergeStateStatus)) {
|
|
21
|
+
return `the merge state changed to ${raw.mergeStateStatus}`;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
@@ -23,6 +23,7 @@ import { summarizePollSummaryPr } from "../../github/poll-summary-projector.mjs"
|
|
|
23
23
|
import { annotationProbeUnavailable } from "../../github/poll-summary-annotation-probe.mjs";
|
|
24
24
|
import { fingerprintRawSummaryPr } from "../../github/poll-summary-fingerprint.mjs";
|
|
25
25
|
import { currentQueueRemovalEvent } from "../../github/poll-summary-queue-removal.mjs";
|
|
26
|
+
import { freshSummaryRegression } from "./fresh-summary-regression.mjs";
|
|
26
27
|
import { isCurrentSummaryReady } from "../../github/poll-summary-readiness.mjs";
|
|
27
28
|
import { clearReadyReceipt, isReadyReceiptCurrent, readReadyReceipt, writeReadyReceipt, } from "../../state/ready-receipts.mjs";
|
|
28
29
|
import { withStackBoundary } from "./stack-boundary.mjs";
|
|
@@ -327,13 +328,14 @@ async function runIterateCore(opts, tick) {
|
|
|
327
328
|
// still holds it, but without --merge its one-PR session ends like a
|
|
328
329
|
// single PR's instead of waiting for a stall-timeout.
|
|
329
330
|
const stackLayer = report.mergeStatus.mergeRequirements?.stack !== undefined;
|
|
330
|
-
if (stackLayer &&
|
|
331
|
-
(outcome.status === "failed" || (outcome.status === "blocked" && opts.merge)))
|
|
331
|
+
if ((stackLayer &&
|
|
332
|
+
(outcome.status === "failed" || (outcome.status === "blocked" && opts.merge))) ||
|
|
333
|
+
(outcome.status === "failed" && outcome.regressed)) {
|
|
332
334
|
const receiptWait = {
|
|
333
335
|
...base,
|
|
334
336
|
action: "wait",
|
|
335
337
|
shouldCancel: false,
|
|
336
|
-
log: receiptWaitLog(base.pr, outcome),
|
|
338
|
+
log: receiptWaitLog(base.pr, outcome, stackLayer),
|
|
337
339
|
};
|
|
338
340
|
return annotateBlockedWait(await applyStallGuard(stallKey, stallTimeoutSeconds, headSha, base, prNumber, receiptWait, reportForWork, reviewSummaryIds, opts.stallDeadlineSink, opts.persistSeen !== false), blockerGate);
|
|
339
341
|
}
|
|
@@ -375,10 +377,13 @@ async function runIterateCore(opts, tick) {
|
|
|
375
377
|
const short = (oid) => oid.slice(0, 7);
|
|
376
378
|
const failed = (reason) => ({ status: "failed", reason });
|
|
377
379
|
const errMessage = (e) => (e instanceof Error ? e.message : String(e));
|
|
378
|
-
function receiptWaitLog(pr, outcome) {
|
|
380
|
+
function receiptWaitLog(pr, outcome, stackLayer) {
|
|
379
381
|
const head = `WAIT: PR #${pr} reached ready-delay but`;
|
|
380
382
|
if (outcome.status === "blocked")
|
|
381
383
|
return `${head} GitHub reports BLOCKED, so its stack readiness receipt was not certified`;
|
|
384
|
+
if (outcome.regressed && !stackLayer) {
|
|
385
|
+
return `WAIT: PR #${pr} looked ready but a fresh read shows ${outcome.reason}`;
|
|
386
|
+
}
|
|
382
387
|
if (outcome.persistFailure)
|
|
383
388
|
return `${head} its stack readiness receipt could not be persisted: ${outcome.reason}`;
|
|
384
389
|
return `${head} its stack readiness receipt was not certified: ${outcome.reason}`;
|
|
@@ -406,9 +411,11 @@ async function recordReadyReceipt(key, report, context) {
|
|
|
406
411
|
if (raw.isDraft)
|
|
407
412
|
return failed("fresh summary shows PR as a draft");
|
|
408
413
|
if (raw.headRefOid !== report.headSha)
|
|
409
|
-
return
|
|
410
|
-
|
|
411
|
-
|
|
414
|
+
return {
|
|
415
|
+
status: "failed",
|
|
416
|
+
reason: `the head moved (report ${short(report.headSha)}, fresh ${short(raw.headRefOid)})`,
|
|
417
|
+
regressed: true,
|
|
418
|
+
};
|
|
412
419
|
// Summarize hydrates annotation totals onto the snapshot; hash only after,
|
|
413
420
|
// so the stored hash matches the stack side's (which hashes hydrated evidence).
|
|
414
421
|
summary = await summarizePollSummaryPr(raw, { owner: key.owner, name: key.repo }, { stackPrNumber: report.pr });
|
|
@@ -426,6 +433,12 @@ async function recordReadyReceipt(key, report, context) {
|
|
|
426
433
|
return failed("annotation probe unavailable");
|
|
427
434
|
const checks = summary.checks ?? {};
|
|
428
435
|
const review = summary.review ?? {};
|
|
436
|
+
const regression = freshSummaryRegression(raw, checks, report.mergeStatus.mergeStateStatus);
|
|
437
|
+
if (regression)
|
|
438
|
+
return { status: "failed", reason: regression, regressed: true };
|
|
439
|
+
// After the regression check: a base move alongside queued CI must still wait.
|
|
440
|
+
if (raw.baseRefOid !== report.baseRefOid)
|
|
441
|
+
return failed(`base moved (report ${short(report.baseRefOid)}, fresh ${short(raw.baseRefOid)})`);
|
|
429
442
|
if (!isCurrentSummaryReady(raw, checks, review)) {
|
|
430
443
|
const onlyBlocked = raw.mergeStateStatus === "BLOCKED" &&
|
|
431
444
|
!raw.isInMergeQueue &&
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mapAuthorType, parseCreatedAt, latestApprovedLogins, isReviewStale, } from "./batch-parser-helpers.mjs";
|
|
2
2
|
import { parseCheckNodes } from "./batch-parse-checks.mjs";
|
|
3
|
+
import { headFreshAtUnix } from "./head-freshness.mjs";
|
|
3
4
|
import { headPushUnixFromCheckNodes } from "./queue-removal-freshness.mjs";
|
|
4
5
|
import { requireContextNodes } from "./batch-response.mjs";
|
|
5
6
|
import { buildPrActivitySummary } from "./activity.mjs";
|
|
@@ -113,6 +114,13 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
|
|
|
113
114
|
? requireContextNodes(queueHead.statusCheckRollup.contexts.nodes)
|
|
114
115
|
: undefined, queueHead?.oid);
|
|
115
116
|
const headPushedAtUnix = headPushUnixFromCheckNodes(rawCheckNodes);
|
|
117
|
+
const headForcePushedAt = raw.headRefForcePushes?.nodes[0]?.createdAt;
|
|
118
|
+
const freshAtUnix = headFreshAtUnix({
|
|
119
|
+
suiteCreatedAts: (raw.commits.nodes[0]?.commit.checkSuites?.nodes ?? []).map((suite) => suite.createdAt),
|
|
120
|
+
...(headForcePushedAt && { forcePushedAtUnix: parseCreatedAt(headForcePushedAt) }),
|
|
121
|
+
prCreatedAt: raw.createdAt,
|
|
122
|
+
committedAt: raw.commits.nodes[0]?.commit.committedDate,
|
|
123
|
+
});
|
|
116
124
|
const removedMergeQueueChecks = parseCheckNodes(removedQueueHead?.statusCheckRollup
|
|
117
125
|
? requireContextNodes(removedQueueHead.statusCheckRollup.contexts.nodes)
|
|
118
126
|
: undefined, removedQueueHead?.oid);
|
|
@@ -127,6 +135,7 @@ export function parseRawPr(raw, rawThreadPages, rawCommentNodes, rawReviewNodes,
|
|
|
127
135
|
reviewDecision: (raw.reviewDecision ?? null),
|
|
128
136
|
headRefOid: raw.headRefOid,
|
|
129
137
|
...(headPushedAtUnix !== undefined && { headPushedAtUnix }),
|
|
138
|
+
...(freshAtUnix !== undefined && { headFreshAtUnix: freshAtUnix }),
|
|
130
139
|
...(raw.headRefForcePushes?.nodes[0] && {
|
|
131
140
|
headForcePushedAtUnix: Math.floor(Date.parse(raw.headRefForcePushes.nodes[0].createdAt) / 1000),
|
|
132
141
|
}),
|
|
@@ -18,6 +18,7 @@ export interface RawBatchResponse {
|
|
|
18
18
|
export interface RawPr extends RawPrMergeFields {
|
|
19
19
|
id: string;
|
|
20
20
|
number: number;
|
|
21
|
+
createdAt?: string;
|
|
21
22
|
updatedAt?: string;
|
|
22
23
|
state: string;
|
|
23
24
|
isDraft: boolean;
|
|
@@ -131,6 +132,7 @@ interface RawCheckSuites {
|
|
|
131
132
|
};
|
|
132
133
|
nodes: Array<{
|
|
133
134
|
id?: string;
|
|
135
|
+
createdAt?: string | null;
|
|
134
136
|
status?: string | null;
|
|
135
137
|
conclusion: string | null;
|
|
136
138
|
app?: {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When the current head most recently reached GitHub, as the newest of three signals:
|
|
3
|
+
* any check suite on the head (apps create theirs at push time, whatever their app), the latest
|
|
4
|
+
* head-ref force-push, the head commit's committer date, and the PR's own creation. The
|
|
5
|
+
* committer date only ever raises the result: an old one (a long-local commit) adds nothing,
|
|
6
|
+
* while a fresh one dates an ordinary push to an old PR that has no suite yet. Omitted when no
|
|
7
|
+
* signal is known, and the caller must then treat the head as settled.
|
|
8
|
+
*/
|
|
9
|
+
export declare function headFreshAtUnix(input: {
|
|
10
|
+
suiteCreatedAts: ReadonlyArray<string | null | undefined>;
|
|
11
|
+
forcePushedAtUnix?: number | undefined;
|
|
12
|
+
prCreatedAt?: string | null | undefined;
|
|
13
|
+
committedAt?: string | null | undefined;
|
|
14
|
+
}): number | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseCreatedAt } from "./batch-parser-helpers.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* When the current head most recently reached GitHub, as the newest of three signals:
|
|
4
|
+
* any check suite on the head (apps create theirs at push time, whatever their app), the latest
|
|
5
|
+
* head-ref force-push, the head commit's committer date, and the PR's own creation. The
|
|
6
|
+
* committer date only ever raises the result: an old one (a long-local commit) adds nothing,
|
|
7
|
+
* while a fresh one dates an ordinary push to an old PR that has no suite yet. Omitted when no
|
|
8
|
+
* signal is known, and the caller must then treat the head as settled.
|
|
9
|
+
*/
|
|
10
|
+
export function headFreshAtUnix(input) {
|
|
11
|
+
const times = [
|
|
12
|
+
...input.suiteCreatedAts,
|
|
13
|
+
...(input.prCreatedAt ? [input.prCreatedAt] : []),
|
|
14
|
+
...(input.committedAt ? [input.committedAt] : []),
|
|
15
|
+
].flatMap((raw) => {
|
|
16
|
+
const at = raw ? parseCreatedAt(raw) : 0;
|
|
17
|
+
return at > 0 ? [at] : [];
|
|
18
|
+
});
|
|
19
|
+
if (input.forcePushedAtUnix !== undefined && input.forcePushedAtUnix > 0) {
|
|
20
|
+
times.push(input.forcePushedAtUnix);
|
|
21
|
+
}
|
|
22
|
+
return times.length > 0 ? Math.max(...times) : undefined;
|
|
23
|
+
}
|
|
@@ -10,6 +10,7 @@ import { parseBranchRules } from "./batch-parsers-rules.mjs";
|
|
|
10
10
|
import { isReviewStale } from "./batch-parser-helpers.mjs";
|
|
11
11
|
import { readRest as rest, restRepoPath, restObject, restString } from "./rest-reader-core.mjs";
|
|
12
12
|
import { restLatestReviews, restPendingReviews } from "./rest-review-read.mjs";
|
|
13
|
+
import { headFreshAtUnix } from "./head-freshness.mjs";
|
|
13
14
|
import { REST_BATCH_UNAVAILABLE } from "./rest-batch-unavailable.mjs";
|
|
14
15
|
export async function readRestSnapshot(pull, repo, context, knownViewerLogin) {
|
|
15
16
|
const [feedback, checks, rules, stack] = await Promise.all([
|
|
@@ -36,8 +37,13 @@ export async function readRestSnapshot(pull, repo, context, knownViewerLogin) {
|
|
|
36
37
|
...rules.unavailable,
|
|
37
38
|
...REST_BATCH_UNAVAILABLE,
|
|
38
39
|
];
|
|
40
|
+
const freshAtUnix = headFreshAtUnix({
|
|
41
|
+
suiteCreatedAts: checks.suites.map((suite) => suite.created_at),
|
|
42
|
+
prCreatedAt: pull.created_at,
|
|
43
|
+
});
|
|
39
44
|
const data = {
|
|
40
45
|
nodeId: pull.node_id,
|
|
46
|
+
...(freshAtUnix !== undefined && { headFreshAtUnix: freshAtUnix }),
|
|
41
47
|
...(feedback.viewerLogin && { viewerLogin: feedback.viewerLogin }),
|
|
42
48
|
...restPullRefs(pull),
|
|
43
49
|
state: restPullRefs(pull).state,
|
package/bin/types/github.d.mts
CHANGED
|
@@ -207,6 +207,11 @@ export interface BatchPrData extends BatchPrMergeFields {
|
|
|
207
207
|
* that signal is unavailable; queue-removal freshness then uses committer time.
|
|
208
208
|
*/
|
|
209
209
|
headPushedAtUnix?: number;
|
|
210
|
+
/**
|
|
211
|
+
* Newest of the head's check-suite creation times (any app), its latest force-push, and the
|
|
212
|
+
* PR's creation: when the head last reached GitHub. Omitted when none is known.
|
|
213
|
+
*/
|
|
214
|
+
headFreshAtUnix?: number;
|
|
210
215
|
/** Unix times of the last 10 merge-queue removals, oldest first. */
|
|
211
216
|
mergeQueueRemovalTimesUnix?: number[];
|
|
212
217
|
/** Unix time of the latest head-ref force-push, when GitHub reports one. */
|
package/bin/types/report.d.mts
CHANGED
|
@@ -139,6 +139,11 @@ export interface ShepherdReport {
|
|
|
139
139
|
baseBehindBy?: number;
|
|
140
140
|
/** A relevant Actions workflow suite on the head has not completed. */
|
|
141
141
|
actionsWorkflowInProgress?: true;
|
|
142
|
+
/**
|
|
143
|
+
* The head reached GitHub under a minute ago with no relevant check yet, so READY is held
|
|
144
|
+
* while checks register. Omitted otherwise.
|
|
145
|
+
*/
|
|
146
|
+
awaitingCheckRegistration?: true;
|
|
142
147
|
/** Bottom open layer of this PR's native stack. Starts a trunk rebase. */
|
|
143
148
|
stackBottomPr?: number;
|
|
144
149
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pr-shepherd",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.16",
|
|
4
4
|
"description": "Autonomous PR CI monitor and review-comment resolver for agentic coding tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"plugins/**/.codex-plugin/**",
|
|
34
34
|
".claude-plugin/**",
|
|
35
35
|
".grok-plugin/**",
|
|
36
|
-
".agents/plugins/marketplace.json",
|
|
37
36
|
"marketplace.json",
|
|
38
37
|
"pr-shepherd.schema.json",
|
|
39
38
|
"README.md",
|
|
@@ -66,9 +65,9 @@
|
|
|
66
65
|
"knip": "knip",
|
|
67
66
|
"knip:production": "knip --production",
|
|
68
67
|
"lint:dead-code": "npm run --silent knip && npm run --silent knip:production",
|
|
69
|
-
"lint": "oxlint src/ test-helpers/ fixtures/*.mts test-cases/ plugins/
|
|
70
|
-
"format": "oxfmt src/ test-helpers/ fixtures/*.mts test-cases/*.mts plugins/
|
|
71
|
-
"format:check": "oxfmt --check src/ test-helpers/ fixtures/*.mts test-cases/*.mts plugins/
|
|
68
|
+
"lint": "oxlint src/ test-helpers/ fixtures/*.mts test-cases/ plugins/ site/build.mjs site/serve.mjs site/lib/ && npm run --silent lint:dead-code",
|
|
69
|
+
"format": "oxfmt src/ test-helpers/ fixtures/*.mts test-cases/*.mts plugins/ docs/ README.md site/build.mjs site/serve.mjs site/lib/",
|
|
70
|
+
"format:check": "oxfmt --check src/ test-helpers/ fixtures/*.mts test-cases/*.mts plugins/ docs/ README.md site/build.mjs site/serve.mjs site/lib/",
|
|
72
71
|
"test": "vitest run",
|
|
73
72
|
"test:coverage": "vitest run --coverage && node scripts/strip-lcov-branches.mjs",
|
|
74
73
|
"test:watch": "vitest",
|
|
@@ -89,7 +88,7 @@
|
|
|
89
88
|
"husky": "^9.1.7",
|
|
90
89
|
"knip": "^6.14.1",
|
|
91
90
|
"marked": "^18.0.11",
|
|
92
|
-
"oxfmt": "^0.
|
|
91
|
+
"oxfmt": "^0.78.0",
|
|
93
92
|
"oxlint": "^1.60.0",
|
|
94
93
|
"typescript": "^7.0.2",
|
|
95
94
|
"vitest": "^5.0.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pr-shepherd
|
|
3
|
-
description: 'Create, iterate, watch, or merge a GitHub pull request with pr-shepherd. Use for "make a PR and use pr-shepherd", "iterate PR #123", "tell me when #123 merges", and any PR status, CI, merge queue, or ejection question, instead of gh or custom polling scripts.'
|
|
3
|
+
description: 'Create, iterate, watch, or merge a GitHub pull request with pr-shepherd. Use for "make a PR and use pr-shepherd", "iterate PR #123", "tell me when #123 merges", and any PR status, CI, merge queue, or ejection question, instead of gh or custom polling scripts. Also use as soon as a merge or enqueue is refused or blocked (HTTP 405, a failing required check, "merge queue required"), or a PR turns out to have been removed or ejected from the merge queue.'
|
|
4
4
|
user-invocable: true
|
|
5
5
|
argument-hint: "[PR | stack PR...] [--merge|--merge-ready|--merge-through PR]"
|
|
6
6
|
allowed-tools: Bash(npx pr-shepherd:*), Bash(pnpm exec pr-shepherd:*), Bash(pnpm dlx pr-shepherd:*), Bash(bunx pr-shepherd:*), Bash(pr-shepherd:*)
|
|
@@ -9,5 +9,5 @@ Apply when the user asks to make, create, or open a PR, before dispatching.
|
|
|
9
9
|
- Rebasing your own PR head onto its base and pushing it with `--force-with-lease` is also part of this workflow. Do not ask first.
|
|
10
10
|
- Bare `--force`, pushes to any other branch, remote or credential changes, unrelated changes, and ambiguous targets stay outside this workflow.
|
|
11
11
|
- Creating or opening a PR without merge intent leaves `--merge` off.
|
|
12
|
-
- To stack, create a GitHub native stack with `gh stack` instead of pointing branches at each other by hand: `gh extension install github/gh-stack`, `gh stack init <branch>`, `gh stack add <branch>`, `gh stack submit --auto`.
|
|
12
|
+
- To stack, create a GitHub native stack with `gh stack` instead of pointing branches at each other by hand: `gh extension install github/gh-stack`, `gh stack init <branch>`, `gh stack add <branch>`, `gh stack submit --auto`. When the earlier PR is already open, add the new branch with `gh stack link <earlier PR> <new branch>` (or `gh stack link <stack number> <new branch>` when it is already in a stack), not `gh pr create --base <earlier branch>`. If GitHub reports that stacks are unavailable for the repository (not when one `gh stack` subcommand fails or is unknown; use another `gh stack` route), open separate PRs on the default branch and merge them in order.
|
|
13
13
|
- Merge a native stack with one `gh stack merge <top PR>` (or the merge Shepherd prints), which lands every layer below it; do not `gh pr merge` layer by layer and rebase between merges.
|
|
@@ -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: `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-
|
|
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`, `sourcery-notices`, and `sourcery-review-guide`. 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
|
|
package/pr-shepherd.schema.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pr-shepherd",
|
|
3
|
-
"interface": {
|
|
4
|
-
"displayName": "pr-shepherd"
|
|
5
|
-
},
|
|
6
|
-
"plugins": [
|
|
7
|
-
{
|
|
8
|
-
"name": "pr-shepherd",
|
|
9
|
-
"source": {
|
|
10
|
-
"source": "local",
|
|
11
|
-
"path": "./plugins/pr-shepherd"
|
|
12
|
-
},
|
|
13
|
-
"policy": {
|
|
14
|
-
"installation": "AVAILABLE",
|
|
15
|
-
"authentication": "ON_INSTALL"
|
|
16
|
-
},
|
|
17
|
-
"category": "Coding"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
|
|
3
|
-
"name": "pr-shepherd",
|
|
4
|
-
"description": "Autonomous PR CI monitor and review-comment resolver",
|
|
5
|
-
"owner": {
|
|
6
|
-
"name": "Jonathan Ong",
|
|
7
|
-
"email": "jonathanrichardong@gmail.com"
|
|
8
|
-
},
|
|
9
|
-
"plugins": [
|
|
10
|
-
{
|
|
11
|
-
"name": "pr-shepherd",
|
|
12
|
-
"description": "Autonomous PR CI monitor and review-comment resolver",
|
|
13
|
-
"source": "./plugins/pr-shepherd",
|
|
14
|
-
"category": "productivity",
|
|
15
|
-
"homepage": "https://github.com/jonathanong/pr-shepherd"
|
|
16
|
-
}
|
|
17
|
-
]
|
|
18
|
-
}
|