pr-shepherd 2.4.0 → 2.4.1

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.4.0",
4
+ "version": "2.4.1",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
@@ -1,7 +1,7 @@
1
1
  import type { PollSummaryItem, PollSummaryResult, StackMergeScope } from "../types.mts";
2
2
  import { type ApproveCommands } from "./stack-merge-plan.mts";
3
3
  /** Keep aggregate JSON, Markdown, and MCP instructions on one projection. */
4
- export declare function withPollSummaryInstructions(result: PollSummaryResult, mergeRequested: boolean, rerunCommand?: string, scope?: StackMergeScope): PollSummaryResult;
4
+ export declare function withPollSummaryInstructions(result: PollSummaryResult, mergeRequested: boolean, rerunCommand?: string, scope?: StackMergeScope, approve?: ApproveCommands): PollSummaryResult;
5
5
  /** The projected summary, plus the idle layers when the stack plan can only wait on them. */
6
6
  export declare function planPollSummary(result: PollSummaryResult, mergeRequested: boolean, rerunCommand?: string, scope?: StackMergeScope | undefined, approve?: ApproveCommands): {
7
7
  result: PollSummaryResult;
@@ -8,8 +8,8 @@ import { aboveThroughTarget } from "./stack-merge-scope.mjs";
8
8
  import { ownershipBoundaryStep } from "./stack-ownership.mjs";
9
9
  import { appendStackRerunInstruction, onlyDraftReadinessVerification, splitStackWork, stackRerunTarget, } from "./stack-work.mjs";
10
10
  /** Keep aggregate JSON, Markdown, and MCP instructions on one projection. */
11
- export function withPollSummaryInstructions(result, mergeRequested, rerunCommand, scope) {
12
- return planPollSummary(result, mergeRequested, rerunCommand, scope).result;
11
+ export function withPollSummaryInstructions(result, mergeRequested, rerunCommand, scope, approve) {
12
+ return planPollSummary(result, mergeRequested, rerunCommand, scope, approve).result;
13
13
  }
14
14
  /** The projected summary, plus the idle layers when the stack plan can only wait on them. */
15
15
  export function planPollSummary(result, mergeRequested, rerunCommand, scope = mergeRequested ? { kind: "all" } : undefined, approve) {
@@ -259,7 +259,7 @@ function attachUsage(result, opts) {
259
259
  return withoutImpliedOwnership(enriched);
260
260
  }
261
261
  const scope = requestedMergeScope(opts);
262
- return withoutImpliedOwnership(withPollSummaryInstructions(enriched, scope !== undefined, aggregateRerunCommand(enriched.repo, enriched.selection, opts), scope));
262
+ return withoutImpliedOwnership(withPollSummaryInstructions(enriched, scope !== undefined, aggregateRerunCommand(enriched.repo, enriched.selection, opts), scope, (extra) => stackApprovalCommands(enriched.repo, enriched.selection, opts, extra)));
263
263
  }
264
264
  /** Whole-stack ownership is the default, so rows say `owned` only when the caller listed PRs. */
265
265
  function withoutImpliedOwnership(result) {
@@ -10,6 +10,12 @@ export type ApproveCommands = (extra: number[]) => {
10
10
  * with its author and title, says what merging would do, and prints the commands that approve.
11
11
  */
12
12
  export declare function unlistedEscalation(target: PollSummaryItem, unlisted: PollSummaryItem[], rerunCommand: string | undefined, approve: ApproveCommands | undefined): StackPlan;
13
+ /**
14
+ * `--merge` with listed PRs leaves unlisted layers above the merge open. The
15
+ * caller may have listed only the bottom PR of a stack it was asked to merge whole, so the step
16
+ * names those layers and prints the command that lands them in the same merge.
17
+ */
18
+ export declare function unlistedAboveStep(above: PollSummaryItem[], rerunCommand: string | undefined, approve: ApproveCommands | undefined): string | undefined;
13
19
  export declare const list: (items: PollSummaryItem[]) => string;
14
20
  /** Layers that joined the stack after the merge was requested: the request never covered them. */
15
21
  export declare function addedLayersEscalation(result: PollSummaryResult, open: PollSummaryItem[], scope: StackMergeScope, rerunCommand?: string): StackPlan | undefined;
@@ -22,6 +22,23 @@ export function unlistedEscalation(target, unlisted, rerunCommand, approve) {
22
22
  : `They either approve it, and you ${listAll}, or wait for ${owner}.`;
23
23
  return escalation(`\`unowned-stack-layers\`: merging PR #${target.pr} also merges ${describeLayers(unlisted)}, which you did not list as yours. Nothing was merged, and never merge only #${target.pr} while leaving ${them} open. If the user's request already covers ${them} (they asked for the whole stack, or for every layer up to #${target.pr}), ${listAll} now. Otherwise stop and tell the user that merging #${target.pr} also merges ${list(unlisted)}. ${approval}`);
24
24
  }
25
+ /**
26
+ * `--merge` with listed PRs leaves unlisted layers above the merge open. The
27
+ * caller may have listed only the bottom PR of a stack it was asked to merge whole, so the step
28
+ * names those layers and prints the command that lands them in the same merge.
29
+ */
30
+ export function unlistedAboveStep(above, rerunCommand, approve) {
31
+ const unlisted = above.filter((item) => !item.owned);
32
+ if (unlisted.length === 0)
33
+ return undefined;
34
+ const one = unlisted.length === 1;
35
+ const names = list(unlisted);
36
+ const commands = approve?.(unlisted.map((item) => item.pr));
37
+ const instead = commands
38
+ ? `run \`${commands.listed}\` instead (or \`${commands.whole}\`; the stack number owns every layer)`
39
+ : `rerun ${stackRerunTarget(rerunCommand)} with ${one ? "it" : "them"} listed after \`stack\` instead`;
40
+ return `${names} ${one ? "sits" : "sit"} above this merge and ${one ? "is" : "are"} not listed after \`stack\`, so the merge below leaves ${one ? "it" : "them"} open and GitHub retargets ${one ? "it" : "them"} onto the trunk, which needs another rebase and CI run. "Not listed" is about this command line, not authorship. If the user asked to merge the whole stack or ${names} too, do not run the merge below: ${instead}, which lands every layer in one command. Otherwise continue with the merge.`;
41
+ }
25
42
  export const list = (items) => items.map((i) => `#${i.pr}`).join(", ");
26
43
  /** Layers that joined the stack after the merge was requested: the request never covered them. */
27
44
  export function addedLayersEscalation(result, open, scope, rerunCommand) {
@@ -4,7 +4,7 @@ import { appendAutonomousInstructions, idleWaitPlan, appendHumanHandoffInstructi
4
4
  import { isStackLayerReady, aboveThroughTarget, closedInScope, mergeScopeLayers, openLayers, readyPrefix, stackPosition, } from "./stack-merge-scope.mjs";
5
5
  import { stackMergeFlag } from "./stack-merge-flag.mjs";
6
6
  import { MERGE_CONFLICT_NOTE, trunkPreCheck } from "./stack-merge-trunk-check.mjs";
7
- import { addedLayersEscalation, escalation, list, scopeDone, unlistedEscalation, } from "./stack-merge-escalations.mjs";
7
+ import { addedLayersEscalation, escalation, list, scopeDone, unlistedAboveStep, unlistedEscalation, } from "./stack-merge-escalations.mjs";
8
8
  import { splitStackWork, stackRerunTarget } from "./stack-work.mjs";
9
9
  const NO_PER_LAYER = "One command lands every listed layer. Do not merge the layers one at a time with `gh pr merge`, and do not rebase or push between layers; GitHub retargets the remaining layers itself.";
10
10
  /**
@@ -23,7 +23,7 @@ export function planStackMerge(result, scope, rerunCommand, approve) {
23
23
  const prefix = readyPrefix(result, true);
24
24
  const top = prefix.at(-1);
25
25
  if (top)
26
- return mergePlan(result, top, scope, rerunCommand);
26
+ return mergePlan(result, top, scope, rerunCommand, approve);
27
27
  const bottom = open.reduce((low, item) => stackPosition(item) < stackPosition(low) ? item : low);
28
28
  if (!bottom.owned && isStackLayerReady(bottom) && open.some((item) => item.owned)) {
29
29
  const above = open.filter((item) => item.owned).at(-1);
@@ -48,11 +48,11 @@ export function planStackMerge(result, scope, rerunCommand, approve) {
48
48
  if (unowned.length > 0)
49
49
  return unlistedEscalation(target, unowned, rerunCommand, approve);
50
50
  return readyPrefix(result, false).some((item) => item.pr === target.pr)
51
- ? mergePlan(result, target, scope, rerunCommand)
51
+ ? mergePlan(result, target, scope, rerunCommand, approve)
52
52
  : undefined;
53
53
  }
54
54
  /** The one merge for `top`, which lands it and every unmerged layer below it. */
55
- function mergePlan(result, top, scope, rerunCommand) {
55
+ function mergePlan(result, top, scope, rerunCommand, approve) {
56
56
  const stack = top.stack;
57
57
  const outside = aboveThroughTarget(result, scope);
58
58
  const open = openLayers(result);
@@ -78,8 +78,12 @@ function mergePlan(result, top, scope, rerunCommand) {
78
78
  const waiting = idleWaitPlan(lands);
79
79
  return { ...waiting, instructions: [`1. ${first.unavailable}`] };
80
80
  }
81
- const check = trunkPreCheck(result, top);
82
- const instructions = check ? [`1. ${check}`, `2. ${first.text}`] : [`1. ${first.text}`];
81
+ const steps = [
82
+ partial && scope.kind === "all" ? unlistedAboveStep(above, rerunCommand, approve) : undefined,
83
+ trunkPreCheck(result, top),
84
+ first.text,
85
+ ].filter((step) => step !== undefined);
86
+ const instructions = steps.map((step, index) => `${index + 1}. ${step}`);
83
87
  appendAutonomousInstructions(instructions, work.sessions, hasListedOwnership(result));
84
88
  const handoffs = findHumanHandoffs(result);
85
89
  if (handoffs)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pr-shepherd",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
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.4.0",
4
+ "version": "2.4.1",
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.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Autonomous PR CI monitor and review-comment resolver for Codex.",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",