pr-shepherd 2.2.15 → 2.2.17
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 +3 -3
- 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 +1 -1
- 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 +2 -2
- package/plugins/pr-shepherd/skills/pr-shepherd/references/create-a-pr.md +1 -1
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)).
|
|
@@ -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
|
@@ -13,9 +13,9 @@ allowed-tools: Bash(npx pr-shepherd:*), Bash(pnpm exec pr-shepherd:*), Bash(pnpm
|
|
|
13
13
|
- To make, create, or open a PR, read the "Create a PR" playbook, then pass its URL on.
|
|
14
14
|
- External shepherd: read the "Draft handoff" playbook, not an in-session loop.
|
|
15
15
|
- `$ARGUMENTS`: PR numbers, PR URLs, or `'owner/repo#N'` (quoted), or `stack PR...` / `stack owner/repo#N` (the number owns all layers), plus one optional merge flag: `--merge`, `--merge-ready`, `--merge-through PR`; reject anything else. Use `stack` only when asked or routed. With no PR, pass none. A qualified PR picks the GitHub target; this checkout supplies git and config.
|
|
16
|
-
-
|
|
16
|
+
- Add a merge flag only when the user asks to merge, land, enqueue, or requeue. A stack or PR named with no such request ("the stack", "#N", a URL) gets no merge flag: shepherd it to ready, report, and leave the merge to them. A merge flag, or a request to merge, land, enqueue, or requeue after an ejection, allows the printed merge/enqueue/dequeue commands. Run Shepherd first: never merge, enqueue or retarget with `gh` or a GitHub MCP tool before Shepherd prints that step. Run them without asking again; escalate only when the host requires it.
|
|
17
|
+
- Only when asked to merge: "merge the stack" -> `stack owner/repo#N --merge` (given only a PR, `stack PR --merge`, then on `unowned-stack-layers` run its printed stack-number command); "merge them as they're ready"/"drain" -> `--merge-ready`; "merge #N" -> one-PR `--merge`, but if they claim other layers or say "up to #N" -> `stack <claimed PRs incl. N> --merge-through N`; "ship it" -> ask.
|
|
17
18
|
- Follow printed branch-update steps without asking: rebase or merge the base, resolve conflicts, push your own PR head with `--force-with-lease`.
|
|
18
|
-
- A merge flag, or a request to merge, land, enqueue, or requeue after an ejection, allows the printed merge/enqueue/dequeue commands. Run Shepherd first: never merge, enqueue or retarget with `gh` or a GitHub MCP tool before Shepherd prints that step. Run them without asking again; escalate only when the host requires it.
|
|
19
19
|
- Run `pr-shepherd [PR ...]` or `pr-shepherd stack PR...`, plus any merge flag, with `--until-terminal` in the background only if its exit wakes you, else in the foreground ([Waiting](references/waiting.md)). Requeue commands print only under `--merge`. PRs with the same flags share one command; if the set changes, stop and rerun with the new list. Do not run `pr-shepherd iterate`, except once for a one-time status question.
|
|
20
20
|
- Print the full result and follow every `## Instructions` step with every ID it lists. When a step says `Playbook: "<name>"`, read that playbook once.
|
|
21
21
|
|
|
@@ -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.
|