pr-shepherd 2.6.1 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/classify/standard/coderabbit-walkthrough.d.mts +10 -0
  3. package/bin/classify/standard/coderabbit-walkthrough.mjs +21 -0
  4. package/bin/classify/standard/devin-no-issues.d.mts +7 -0
  5. package/bin/classify/standard/devin-no-issues.mjs +18 -0
  6. package/bin/classify/standard/index.d.mts +2 -1
  7. package/bin/classify/standard/index.mjs +6 -1
  8. package/bin/cli/apply-merge-handler.mjs +2 -0
  9. package/bin/cli/body-truncate.d.mts +7 -0
  10. package/bin/cli/body-truncate.mjs +8 -4
  11. package/bin/cli/help-command-pages.d.mts +4 -2
  12. package/bin/cli/help-command-pages.mjs +4 -1
  13. package/bin/cli/help-iterate-poll-pages.d.mts +1 -1
  14. package/bin/cli/help-iterate-poll-pages.mjs +1 -1
  15. package/bin/cli/help-top-page.d.mts +1 -1
  16. package/bin/cli/help-top-page.mjs +3 -1
  17. package/bin/cli/help-watch-status-page.d.mts +1 -0
  18. package/bin/cli/help-watch-status-page.mjs +21 -0
  19. package/bin/cli/help.d.mts +5 -3
  20. package/bin/cli/help.mjs +2 -0
  21. package/bin/cli/iterate-lean.d.mts +0 -5
  22. package/bin/cli/iterate-lean.mjs +9 -2
  23. package/bin/cli/poll-summary-formatter.mjs +2 -1
  24. package/bin/cli/review-body-cap.d.mts +10 -0
  25. package/bin/cli/review-body-cap.mjs +84 -0
  26. package/bin/cli/stack-layer-view.d.mts +2 -0
  27. package/bin/cli/stack-layer-view.mjs +8 -0
  28. package/bin/cli/stack-overview.mjs +4 -5
  29. package/bin/cli/triage-formatter.mjs +4 -1
  30. package/bin/cli/watch-status-handler.d.mts +2 -0
  31. package/bin/cli/watch-status-handler.mjs +56 -0
  32. package/bin/cli-parser.mjs +7 -0
  33. package/bin/commands/apply-merge-default-route.d.mts +56 -0
  34. package/bin/commands/apply-merge-default-route.mjs +149 -0
  35. package/bin/commands/apply-merge-output.d.mts +2 -0
  36. package/bin/commands/apply-merge-output.mjs +8 -0
  37. package/bin/commands/apply-merge-pull.d.mts +3 -0
  38. package/bin/commands/apply-merge-resume.d.mts +2 -3
  39. package/bin/commands/apply-merge-resume.mjs +74 -32
  40. package/bin/commands/apply-merge-stack-membership.d.mts +27 -0
  41. package/bin/commands/apply-merge-stack-membership.mjs +85 -0
  42. package/bin/commands/apply-merge-submit.d.mts +20 -0
  43. package/bin/commands/apply-merge-submit.mjs +47 -0
  44. package/bin/commands/apply-merge-supersede.d.mts +17 -0
  45. package/bin/commands/apply-merge-supersede.mjs +30 -0
  46. package/bin/commands/apply-merge-sync-fallback.d.mts +16 -0
  47. package/bin/commands/apply-merge-sync-fallback.mjs +55 -0
  48. package/bin/commands/apply-merge.d.mts +2 -0
  49. package/bin/commands/apply-merge.mjs +65 -41
  50. package/bin/commands/check-review-budget.mjs +12 -1
  51. package/bin/commands/check.d.mts +2 -0
  52. package/bin/commands/check.mjs +9 -1
  53. package/bin/commands/iterate/escalate.mjs +5 -0
  54. package/bin/commands/iterate/index.mjs +34 -4
  55. package/bin/commands/iterate/merge-plan.d.mts +2 -0
  56. package/bin/commands/iterate/merge-plan.mjs +1 -1
  57. package/bin/commands/iterate/merge.mjs +7 -3
  58. package/bin/commands/iterate/stack-boundary.mjs +6 -6
  59. package/bin/commands/iterate/triage.mjs +19 -6
  60. package/bin/commands/poll-events.d.mts +1 -1
  61. package/bin/commands/poll-events.mjs +8 -3
  62. package/bin/commands/poll-seen-options.d.mts +7 -0
  63. package/bin/commands/poll-seen-options.mjs +9 -0
  64. package/bin/commands/poll-summary-instructions.d.mts +1 -0
  65. package/bin/commands/poll-summary-instructions.mjs +17 -7
  66. package/bin/commands/poll-summary.mjs +8 -4
  67. package/bin/commands/poll.mjs +2 -2
  68. package/bin/commands/rest-stack-merge-readiness.d.mts +6 -2
  69. package/bin/commands/rest-stack-merge-readiness.mjs +59 -7
  70. package/bin/commands/stack-drain.d.mts +7 -1
  71. package/bin/commands/stack-drain.mjs +30 -6
  72. package/bin/commands/stack-lower-heads.d.mts +32 -0
  73. package/bin/commands/stack-lower-heads.mjs +53 -0
  74. package/bin/commands/stack-merge-escalations.d.mts +2 -1
  75. package/bin/commands/stack-merge-plan.mjs +35 -41
  76. package/bin/commands/stack-merge-trunk-check.d.mts +0 -2
  77. package/bin/commands/stack-merge-trunk-check.mjs +0 -2
  78. package/bin/commands/stack-ownership.mjs +3 -3
  79. package/bin/commands/stack-stall.d.mts +1 -0
  80. package/bin/commands/stack-stall.mjs +6 -2
  81. package/bin/commands/stack-trunk-behind.d.mts +1 -1
  82. package/bin/commands/stack-trunk-behind.mjs +1 -1
  83. package/bin/commands/stack-work.mjs +1 -1
  84. package/bin/config/merge-command-args.d.mts +2 -0
  85. package/bin/config/merge-command-args.mjs +13 -0
  86. package/bin/config/merge-method.d.mts +0 -5
  87. package/bin/config/merge-method.mjs +0 -6
  88. package/bin/config/schema.d.mts +2 -0
  89. package/bin/config/schema.mjs +2 -13
  90. package/bin/github/batch-parser-helpers.d.mts +5 -0
  91. package/bin/github/batch-parser-helpers.mjs +7 -2
  92. package/bin/github/batch-parsers.mjs +6 -2
  93. package/bin/github/errors.d.mts +2 -0
  94. package/bin/github/errors.mjs +1 -1
  95. package/bin/github/poll-summary-annotation-probe.d.mts +1 -1
  96. package/bin/github/poll-summary-annotation-probe.mjs +2 -2
  97. package/bin/github/poll-summary-command.d.mts +3 -2
  98. package/bin/github/poll-summary-command.mjs +6 -4
  99. package/bin/github/poll-summary-projector.mjs +16 -14
  100. package/bin/github/poll-summary-readiness.d.mts +4 -0
  101. package/bin/github/poll-summary-readiness.mjs +22 -0
  102. package/bin/github/poll-summary-rest-queue.d.mts +13 -0
  103. package/bin/github/poll-summary-rest-queue.mjs +21 -0
  104. package/bin/github/poll-summary-review-helpers.mjs +8 -4
  105. package/bin/state/merge-method-cache.d.mts +19 -0
  106. package/bin/state/merge-method-cache.mjs +27 -0
  107. package/bin/state/merge-request-claim.d.mts +23 -0
  108. package/bin/state/merge-request-claim.mjs +44 -0
  109. package/bin/state/merge-request-clear.d.mts +24 -0
  110. package/bin/state/merge-request-clear.mjs +36 -0
  111. package/bin/state/merge-request-lock.d.mts +13 -0
  112. package/bin/state/merge-request-lock.mjs +136 -0
  113. package/bin/state/merge-request-stack-heads.d.mts +2 -0
  114. package/bin/state/merge-request-stack-heads.mjs +8 -0
  115. package/bin/state/merge-request.d.mts +23 -6
  116. package/bin/state/merge-request.mjs +29 -29
  117. package/bin/state/ready-receipts.d.mts +11 -0
  118. package/bin/state/ready-receipts.mjs +7 -0
  119. package/bin/state/watch-lock.d.mts +10 -0
  120. package/bin/state/watch-lock.mjs +38 -3
  121. package/bin/types/poll-summary.d.mts +2 -0
  122. package/package.json +12 -5
  123. package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
  124. package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
  125. package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +1 -1
  126. package/plugins/pr-shepherd/skills/pr-shepherd/references/create-a-pr.md +2 -2
  127. package/plugins/pr-shepherd/skills/pr-shepherd/references/waiting.md +1 -1
  128. package/plugins/pr-shepherd/skills/setup-pr-shepherd/references/classifiers.md +1 -1
  129. package/pr-shepherd.schema.json +8 -0
  130. package/bin/commands/stack-merge-flag.d.mts +0 -7
  131. package/bin/commands/stack-merge-flag.mjs +0 -6
@@ -15,6 +15,8 @@ export interface MergePlanInput {
15
15
  allowedMergeMethods?: readonly MergeMethod[];
16
16
  /** Branch policy requires linear history, so merge commits are excluded. */
17
17
  linearHistory?: boolean;
18
+ /** The direct method used when none is configured and the repository allows it; `merge` when omitted. */
19
+ fallbackMethod?: MergeMethod;
18
20
  /** Attach a REST equivalent of the GraphQL merge commands, for when `gh` reports a GraphQL rate limit. */
19
21
  restFallback?: boolean;
20
22
  expectedStack?: RestMergeStackGuard;
@@ -23,7 +23,7 @@ export function buildMergeCommandPlan(input) {
23
23
  const decision = chooseMergeMethod({
24
24
  allowed: input.allowedMergeMethods,
25
25
  configured,
26
- fallback: "merge",
26
+ fallback: input.fallbackMethod ?? "merge",
27
27
  linearHistory: input.linearHistory,
28
28
  });
29
29
  if ("unavailable" in decision)
@@ -79,9 +79,13 @@ function removedQueueRecoveryAvailable(report, checks, merge) {
79
79
  !report.nodeId ||
80
80
  !checks.some((check) => check.scope === "merge_group" && check.commitOid === removedCommit))
81
81
  return false;
82
- return checks
83
- .filter((check) => check.scope === "merge_group" && check.commitOid === removedCommit)
84
- .every(hasQueueRecoveryEvidence);
82
+ const removed = checks.filter((check) => check.scope === "merge_group" && check.commitOid === removedCommit);
83
+ // A paused approval gate on the queue commit needs a human; recovery would later drop it.
84
+ if (removed.some((check) => check.conclusion === "ACTION_REQUIRED"))
85
+ return false;
86
+ // Rollup and cancelled jobs on the queue commit carry no evidence of their own; one failure
87
+ // with evidence is enough to judge the ejection.
88
+ return removed.some(hasQueueRecoveryEvidence);
85
89
  }
86
90
  export function unavailableMergeResult(base, report, unavailable) {
87
91
  const escalateBase = {
@@ -63,16 +63,16 @@ export function boundedStackRebase(stackNumber, playbook, rest = false) {
63
63
  const p = plan();
64
64
  if (!p)
65
65
  return undefined;
66
- const lead = `Unowned ${p.unowned.length === 1 ? "layer" : "layers"} ${names(p.unowned)} in native stack #${stackNumber} must not be rebased or pushed, and a whole-stack update (\`gh stack rebase\`, \`gh stack push\`) would rewrite ${p.unowned.length === 1 ? "it" : "them"}, so do not run one.`;
66
+ const lead = `${names(p.unowned)} in native stack #${stackNumber} ${p.unowned.length === 1 ? "was" : "were"} not listed by the \`stack\` command that started this session, so ${p.unowned.length === 1 ? "it" : "they"} must not be rebased or pushed, and a whole-stack update (\`gh stack rebase\`, \`gh stack push\`) would rewrite ${p.unowned.length === 1 ? "it" : "them"}, so do not run one.`;
67
67
  if (!p.me) {
68
- return `${lead} This session cannot tell which layers are owned; do not update any branch of the stack, and report that to the caller. ${playbook}`;
68
+ return `${lead} This session cannot tell which layers were listed; do not update any branch of the stack, and report that to the caller. ${playbook}`;
69
69
  }
70
70
  if (p.blockedBy) {
71
- return `${lead} ${names(p.blockedBy)} sits below this PR, so no branch of this PR can be restacked without rewriting ${p.blockedBy.length === 1 ? "it" : "them"}. Do not rebase or push; report that PR #${p.me.pr} waits on ${p.blockedBy.length === 1 ? "that layer's" : "those layers'"} owner. ${playbook}`;
71
+ return `${lead} ${names(p.blockedBy)} sits below this PR, so no branch of this PR can be restacked without rewriting ${p.blockedBy.length === 1 ? "it" : "them"}. Do not rebase or push; report that PR #${p.me.pr} waits on ${p.blockedBy.length === 1 ? "that layer" : "those layers"}, which the \`stack\` command did not list. ${playbook}`;
72
72
  }
73
73
  const above = p.unowned.filter((layer) => layer.position > p.me.position);
74
74
  const stale = above.length > 0
75
- ? ` ${names(above)} will be stale afterwards: tell the user its owner must restack ${above.length === 1 ? "it" : "them"}.`
75
+ ? ` ${names(above)} will be stale afterwards: tell the user ${above.length === 1 ? "it needs" : "they need"} a restack by whoever shepherds ${above.length === 1 ? "it" : "them"}.`
76
76
  : "";
77
77
  const update = rest
78
78
  ? `Instead, update only PR #${p.me.pr} (\`${p.me.branch}\`) and the layers below it, using the repository's stack-update procedure.`
@@ -88,8 +88,8 @@ export function boundedStackPush() {
88
88
  if (!p)
89
89
  return undefined;
90
90
  if (p.pushable.length === 0) {
91
- return "do not push the stack: `gh stack push` would publish unowned layers, and this PR has no branch it can restack alone";
91
+ return "do not push the stack: `gh stack push` would publish unlisted layers, and this PR has no branch it can restack alone";
92
92
  }
93
93
  const branches = p.pushable.map((layer) => `\`${layer.branch}\``).join(", ");
94
- return `push only the owned branches (${branches}) with \`git push --force-with-lease <push-remote> <branch>\` ${PUSH_REMOTE}; do not run \`gh stack push\`, which would also publish unowned layers (${names(p.unowned)})`;
94
+ return `push only the listed branches (${branches}) with \`git push --force-with-lease <push-remote> <branch>\` ${PUSH_REMOTE}; do not run \`gh stack push\`, which would also publish unlisted layers (${names(p.unowned)})`;
95
95
  }
@@ -200,7 +200,24 @@ async function handleTriageTick(ctx) {
200
200
  const { "behind-base-hint": behindBaseHint, instructions: configuredInstructions } = loadConfig().iterate;
201
201
  const commentMinimizeIds = report.comments.minimizeIds ?? actionableComments.map((c) => c.id);
202
202
  const belongsToActiveWorkflowRun = (check) => check.runId !== null && inProgressWorkflowRunIds.has(check.runId);
203
+ const recovery = buildRemovedQueueRecovery(report, failingAgentChecks, opts.merge);
204
+ const requeue = recovery && !("unavailable" in recovery) ? recovery : undefined;
205
+ const acknowledgmentRecovery = buildStackQueueRemovalAcknowledgment(report, failingAgentChecks);
206
+ const queueRemovalAcknowledgment = acknowledgmentRecovery && !("unavailable" in acknowledgmentRecovery)
207
+ ? acknowledgmentRecovery
208
+ : undefined;
209
+ // A queue ejection that prints a requeue or a stack acknowledgment already judged the removed commit's failures;
210
+ // rollups and cancellations on it carry no evidence of their own and need no investigation.
211
+ const requeueCommit = requeue || queueRemovalAcknowledgment
212
+ ? report.mergeQueue?.latestRemoval?.beforeCommitOid
213
+ : undefined;
214
+ const recoveredQueueCheck = (check) => requeueCommit !== undefined &&
215
+ check.scope === "merge_group" &&
216
+ check.commitOid === requeueCommit &&
217
+ // A paused approval gate needs a human whatever the requeue judged.
218
+ check.conclusion !== "ACTION_REQUIRED";
203
219
  const manualFollowUpChecks = failingAgentChecks.filter((check) => !releasedCheckNames.has(check.name) &&
220
+ !recoveredQueueCheck(check) &&
204
221
  !belongsToActiveWorkflowRun(check) &&
205
222
  checkFollowUp(check) !== undefined);
206
223
  const exhaustedAttempts = failingAgentChecks.filter((check) => check.runAttempt !== undefined && check.runAttempt > 1);
@@ -208,6 +225,7 @@ async function handleTriageTick(ctx) {
208
225
  const hasBehindBaseRecovery = isBehind && manualExhaustedAttempts.length > 0;
209
226
  const activeFailures = activeRunFailures(failingAgentChecks, inProgressWorkflowRunIds, releasedCheckNames);
210
227
  const evidenceChecks = failingAgentChecks.filter((check) => !releasedCheckNames.has(check.name) &&
228
+ !recoveredQueueCheck(check) &&
211
229
  !belongsToActiveWorkflowRun(check) &&
212
230
  !activeFailures.includes(check) &&
213
231
  isEvidenceFollowUpCheck(check, Boolean(report.mergeQueue?.inQueue)));
@@ -228,6 +246,7 @@ async function handleTriageTick(ctx) {
228
246
  report.reviewItems !== undefined ||
229
247
  checks.some((check) => (check.annotations?.length ?? 0) > 0) ||
230
248
  failingAgentChecks.some((check) => !activeFailures.includes(check) &&
249
+ !recoveredQueueCheck(check) &&
231
250
  (releasedCheckNames.has(check.name) ||
232
251
  belongsToActiveWorkflowRun(check) ||
233
252
  (checkFollowUp(check) === undefined && !evidenceChecks.includes(check))));
@@ -325,12 +344,6 @@ async function handleTriageTick(ctx) {
325
344
  bottomPr: report.stackBottomPr,
326
345
  })
327
346
  : undefined;
328
- const recovery = buildRemovedQueueRecovery(report, failingAgentChecks, opts.merge);
329
- const requeue = recovery && !("unavailable" in recovery) ? recovery : undefined;
330
- const acknowledgmentRecovery = buildStackQueueRemovalAcknowledgment(report, failingAgentChecks);
331
- const queueRemovalAcknowledgment = acknowledgmentRecovery && !("unavailable" in acknowledgmentRecovery)
332
- ? acknowledgmentRecovery
333
- : undefined;
334
347
  const ejectionCommit = currentEjectionCommit(report, failingAgentChecks);
335
348
  const queueEjection = !ejectionCommit
336
349
  ? undefined
@@ -17,7 +17,7 @@ interface WaitTickInput {
17
17
  }
18
18
  export interface PollEvents {
19
19
  engaged(targets: readonly WatchTarget[]): boolean;
20
- /** Wait for the next tick. Returns true when the poll window elapsed with no event. */
20
+ /** Wait for the next tick. Returns true when the poll window elapsed, with or without an event. */
21
21
  waitTick(input: WaitTickInput): Promise<boolean>;
22
22
  close(): void;
23
23
  }
@@ -63,8 +63,11 @@ function createPollEvents(verbose) {
63
63
  input.deadlineAt !== undefined &&
64
64
  Date.now() + TIMER_DRIFT_TOLERANCE_MS >= input.deadlineAt;
65
65
  note(`[${input.label}] woke on ${atDeadline ? `${input.deadlineReason ?? "time-based"} deadline` : describe(wake, degraded)}`);
66
- return (wake.kind === "timer" &&
67
- Date.now() - waitStart + TIMER_DRIFT_TOLERANCE_MS >= input.remainingMs);
66
+ // An event whose settle or minimum gap runs into the end of the window is clamped to that
67
+ // end by the waiter; the window is over then, so no tick starts after `--timeout`. Only a
68
+ // timer wake gets the drift tolerance: an event wake earlier than the clamp is a real tick.
69
+ const tolerance = wake.kind === "timer" ? TIMER_DRIFT_TOLERANCE_MS : 0;
70
+ return Date.now() - waitStart + tolerance >= input.remainingMs;
68
71
  },
69
72
  };
70
73
  }
@@ -90,12 +93,14 @@ export async function pauseBeforeNextTick(input) {
90
93
  if (remainingMs <= 0 || (!viaEvents && remainingMs + TIMER_DRIFT_TOLERANCE_MS < sleepMs)) {
91
94
  return true;
92
95
  }
96
+ const announcedAt = Date.now();
93
97
  announce(viaEvents);
94
98
  if (!events || !viaEvents) {
95
99
  await sleep(sleepMs);
96
100
  return false;
97
101
  }
98
- return events.waitTick(wait);
102
+ // Time spent announcing counts against the poll window, so the wait never outlasts `--timeout`.
103
+ return events.waitTick({ ...wait, remainingMs: remainingMs - (Date.now() - announcedAt) });
99
104
  }
100
105
  /** The one PR a single-PR tick watched; head SHA and ref come from that tick's batch data. */
101
106
  export function onePrTargets(result, head) {
@@ -6,3 +6,10 @@ export declare function pollTickSeenOptions(debounceSeconds: number, pastDebounc
6
6
  persistSeen: boolean;
7
7
  deferEditedCommentMarkers: boolean;
8
8
  };
9
+ /**
10
+ * When a TRIAGE settle window that starts now ends. A bounded poll's `--timeout` covers the
11
+ * debounce, so the window never runs past the poll deadline (pass `Infinity` for
12
+ * `--until-terminal`). A window cut to nothing still runs the one tick that persists seen
13
+ * markers, so that tick can start at the deadline, as the last WAIT tick can.
14
+ */
15
+ export declare function debounceDeadline(debounceMs: number, pollStartedAt: number, timeoutMs: number): number;
@@ -5,3 +5,12 @@
5
5
  export function pollTickSeenOptions(debounceSeconds, pastDebounce) {
6
6
  return { persistSeen: debounceSeconds === 0 || pastDebounce, deferEditedCommentMarkers: true };
7
7
  }
8
+ /**
9
+ * When a TRIAGE settle window that starts now ends. A bounded poll's `--timeout` covers the
10
+ * debounce, so the window never runs past the poll deadline (pass `Infinity` for
11
+ * `--until-terminal`). A window cut to nothing still runs the one tick that persists seen
12
+ * markers, so that tick can start at the deadline, as the last WAIT tick can.
13
+ */
14
+ export function debounceDeadline(debounceMs, pollStartedAt, timeoutMs) {
15
+ return Math.min(Date.now() + debounceMs, pollStartedAt + timeoutMs);
16
+ }
@@ -6,4 +6,5 @@ export declare function withPollSummaryInstructions(result: PollSummaryResult, m
6
6
  export declare function planPollSummary(result: PollSummaryResult, mergeRequested: boolean, rerunCommand?: string, scope?: StackMergeScope | undefined, approve?: ApproveCommands): {
7
7
  result: PollSummaryResult;
8
8
  idle?: PollSummaryItem[];
9
+ claims?: string[];
9
10
  };
@@ -107,6 +107,7 @@ export function planPollSummary(result, mergeRequested, rerunCommand, scope = me
107
107
  instructions,
108
108
  },
109
109
  ...(planned.idle && { idle: planned.idle }),
110
+ ...(planned.claims && { claims: planned.claims }),
110
111
  };
111
112
  }
112
113
  function planStack(result, mergeRequested, rerunCommand, scope, approve) {
@@ -132,7 +133,7 @@ function planStack(result, mergeRequested, rerunCommand, scope, approve) {
132
133
  const handoffs = findHumanHandoffs(result);
133
134
  if (handoffs) {
134
135
  const instructions = [];
135
- appendAutonomousInstructions(instructions, runnableCandidates, partial);
136
+ appendAutonomousInstructions(instructions, runnableCandidates, partial, approve, mergeRequested);
136
137
  const stop = !ownedWork;
137
138
  appendHumanHandoffInstructions(instructions, handoffs, stop);
138
139
  for (const item of missingCommands) {
@@ -157,7 +158,7 @@ function planStack(result, mergeRequested, rerunCommand, scope, approve) {
157
158
  if (!stackMergeable) {
158
159
  if (missingCommands.length > 0) {
159
160
  const instructions = [];
160
- appendAutonomousInstructions(instructions, runnableCandidates, partial);
161
+ appendAutonomousInstructions(instructions, runnableCandidates, partial, approve, mergeRequested);
161
162
  for (const item of missingCommands) {
162
163
  instructions.push(`${instructions.length + 1}. PR #${item.pr} needs a one-PR session, but Shepherd could not produce its command. ${ownedWork ? "After autonomous shepherding, ask" : "Stop and ask"} for direction.`);
163
164
  }
@@ -179,7 +180,7 @@ function planStack(result, mergeRequested, rerunCommand, scope, approve) {
179
180
  return idleWaitPlan([...work.idle, ...unverified]);
180
181
  }
181
182
  const instructions = [];
182
- appendAutonomousInstructions(instructions, work.sessions, partial);
183
+ appendAutonomousInstructions(instructions, work.sessions, partial, approve, mergeRequested);
183
184
  if (onlyDraftReadinessVerification(work.sessions, [...work.idle, ...unverified]) &&
184
185
  work.sessions.every((item) => item.owned)) {
185
186
  instructions.push(`${instructions.length + 1}. If every listed one-PR probe returns \`[CANCEL]\` with reason \`auto-mark-ready-disabled\`, stop shepherding this stack and leave those drafts unchanged. If any probe returns \`[ESCALATE]\`, report that handoff and stop after the other probes finish. Otherwise follow each probe's instructions and rerun ${again} when that work completes.`);
@@ -208,7 +209,7 @@ function planStack(result, mergeRequested, rerunCommand, scope, approve) {
208
209
  if (!mergeRequested) {
209
210
  const instructions = [];
210
211
  const sessions = open.filter((item) => item.action !== "cancel");
211
- appendAutonomousInstructions(instructions, sessions, partial);
212
+ appendAutonomousInstructions(instructions, sessions, partial, approve, mergeRequested);
212
213
  const action = appendStackRerunInstruction(instructions, sessions, `After the selected one-PR sessions, rerun ${again}.`);
213
214
  return sessionsPlan(action, sessions, stackMergeable, instructions);
214
215
  }
@@ -222,7 +223,16 @@ function closedDependency(items, pr) {
222
223
  }
223
224
  /** Routed sessions, or an idle wait (under the stack stall timer) when every one is another author's. */
224
225
  function sessionsPlan(action, layers, stackMergeable, instructions) {
225
- return action === "wait"
226
- ? { action, stackMergeable, waiting: true, idle: layers, instructions }
227
- : { action, stackMergeable, instructions };
226
+ if (action !== "wait")
227
+ return { action, stackMergeable, instructions };
228
+ // The closing wait step is last; every step before it claims an unlisted layer.
229
+ const claims = instructions.slice(0, -1);
230
+ return {
231
+ action,
232
+ stackMergeable,
233
+ waiting: true,
234
+ idle: layers,
235
+ ...(claims.length > 0 && { claims }),
236
+ instructions,
237
+ };
228
238
  }
@@ -20,6 +20,7 @@ import { stackRerunTarget } from "./stack-work.mjs";
20
20
  import { withTrunkBehind } from "./stack-trunk-behind.mjs";
21
21
  import { requestedMergeScope, stackAddedLayers } from "./stack-merge-scope.mjs";
22
22
  import { aggregateDeadline } from "./stall-deadline.mjs";
23
+ import { debounceDeadline } from "./poll-seen-options.mjs";
23
24
  import { aggregateTargets, pauseBeforeNextTick, withPollEvents, } from "./poll-events.mjs";
24
25
  const MAX_TIMER_MS = 2 ** 31 - 1;
25
26
  export function runPollSummary(opts) {
@@ -85,7 +86,7 @@ async function readPollSummaryTick(opts) {
85
86
  }
86
87
  const addedLayers = await stackAddedLayers(summary, scope, rerunCommand);
87
88
  const withBehind = await withTrunkBehind(summary, scope);
88
- const planned = planPollSummary({ ...withBehind, ...(addedLayers.length > 0 && { addedLayers }) }, scope !== undefined, rerunCommand, scope, (extra) => stackApprovalCommands(`${repo.owner}/${repo.name}`, fetched.selection, opts, extra));
89
+ const planned = planPollSummary({ ...withBehind, ...(addedLayers.length > 0 && { addedLayers }) }, scope !== undefined, rerunCommand, scope, (extra, shepherdOnly) => stackApprovalCommands(`${repo.owner}/${repo.name}`, fetched.selection, opts, extra, shepherdOnly));
89
90
  const result = await applyStackStallGuard(planned, repo, opts.stallTimeoutSeconds ?? loadConfig().iterate["stall-timeout-minutes"] * 60);
90
91
  return { result, repo, ...(fetched.handoffSource && { handoffSource: fetched.handoffSource }) };
91
92
  }
@@ -188,7 +189,8 @@ async function runAggregatePollCore(options, events) {
188
189
  }, opts);
189
190
  }
190
191
  if (hasFix) {
191
- if (debounceMs === 0 || Date.now() >= (debounceUntil ??= Date.now() + debounceMs)) {
192
+ debounceUntil ??= debounceDeadline(debounceMs, start, opts.untilTerminal ? Infinity : timeoutMs);
193
+ if (debounceMs === 0 || Date.now() >= debounceUntil) {
192
194
  await handOffRoutedLayers(lastTick);
193
195
  return attachUsage({
194
196
  ...last,
@@ -219,7 +221,9 @@ async function runAggregatePollCore(options, events) {
219
221
  intervalMs,
220
222
  label: `aggregate poll tick ${tick} / +${Math.round(elapsedMs / 1000)}s`,
221
223
  tickStartedAt,
222
- remainingMs: opts.untilTerminal || debounceUntil !== null ? Infinity : timeoutMs - elapsedMs,
224
+ // Re-read the clock after the awaited deadline read, as poll.mts does, so the event wait
225
+ // never gets more window than is really left before --timeout.
226
+ remainingMs: opts.untilTerminal || debounceUntil !== null ? Infinity : timeoutMs - (Date.now() - start),
223
227
  announce: () => {
224
228
  const statusSignature = summaryStatusSignature(last);
225
229
  if (!opts.quietStatus || hasFix || statusSignature !== lastStatusSignature) {
@@ -259,7 +263,7 @@ function attachUsage(result, opts) {
259
263
  return withoutImpliedOwnership(enriched);
260
264
  }
261
265
  const scope = requestedMergeScope(opts);
262
- return withoutImpliedOwnership(withPollSummaryInstructions(enriched, scope !== undefined, aggregateRerunCommand(enriched.repo, enriched.selection, opts), scope, (extra) => stackApprovalCommands(enriched.repo, enriched.selection, opts, extra)));
266
+ return withoutImpliedOwnership(withPollSummaryInstructions(enriched, scope !== undefined, aggregateRerunCommand(enriched.repo, enriched.selection, opts), scope, (extra, shepherdOnly) => stackApprovalCommands(enriched.repo, enriched.selection, opts, extra, shepherdOnly)));
263
267
  }
264
268
  /** Whole-stack ownership is the default, so rows say `owned` only when the caller listed PRs. */
265
269
  function withoutImpliedOwnership(result) {
@@ -1,5 +1,5 @@
1
1
  import { runIterate } from "./iterate/index.mjs";
2
- import { pollTickSeenOptions } from "./poll-seen-options.mjs";
2
+ import { debounceDeadline, pollTickSeenOptions } from "./poll-seen-options.mjs";
3
3
  import { markEditedCommentsSeen } from "./iterate/edited-comment-markers.mjs";
4
4
  import { sleep } from "../util/sleep.mjs";
5
5
  import { withPollApiUsage } from "./poll-run.mjs";
@@ -150,7 +150,7 @@ async function runPollCore(opts, events) {
150
150
  }
151
151
  if (lastResult.action === "triage" && debounceSeconds > 0 && !pastDebounce) {
152
152
  writeRuleAutoResolveProgress(lastResult);
153
- debounceUntil ??= Date.now() + debounceMs;
153
+ debounceUntil ??= debounceDeadline(debounceMs, start, untilTerminal ? Infinity : timeoutMs);
154
154
  const remainingMs = debounceUntil - Date.now();
155
155
  if (remainingMs > 0) {
156
156
  writeDebounceProgress(tick, Date.now() - start, remainingMs);
@@ -1,4 +1,8 @@
1
1
  import type { RepoInfo } from "../github/client.mts";
2
2
  import { type RestMergeStackGuard } from "../github/rest-merge-stack-guard.mts";
3
- /** Validate the exact current native prefix before requesting a stack merge. */
4
- export declare function validateRestStackMergeReadiness(pr: number, repo: RepoInfo, sha: string, expectedStack?: RestMergeStackGuard): Promise<void>;
3
+ import type { StackLayerHead } from "./stack-lower-heads.mts";
4
+ /**
5
+ * Validate the exact current native prefix before requesting a stack merge. Returns each prefix
6
+ * layer's validated head, or undefined when the PR is not in a native stack.
7
+ */
8
+ export declare function validateRestStackMergeReadiness(pr: number, repo: RepoInfo, sha: string, expectedStack?: RestMergeStackGuard): Promise<StackLayerHead[] | undefined>;
@@ -4,14 +4,19 @@ import { fetchRawSummaryPr } from "../github/poll-summary.mjs";
4
4
  import { summarizePollSummaryPr } from "../github/poll-summary-projector.mjs";
5
5
  import { stackAncestryGaps } from "../github/stack-read.mjs";
6
6
  import { mapPool } from "../util/pool.mjs";
7
+ import { sanitizeBody } from "../github/http-utils.mjs";
8
+ import { runWithGithubTransport } from "../github/transport.mjs";
7
9
  import { restMergeStackGuardKey, } from "../github/rest-merge-stack-guard.mjs";
8
- /** Validate the exact current native prefix before requesting a stack merge. */
10
+ /**
11
+ * Validate the exact current native prefix before requesting a stack merge. Returns each prefix
12
+ * layer's validated head, or undefined when the PR is not in a native stack.
13
+ */
9
14
  export async function validateRestStackMergeReadiness(pr, repo, sha, expectedStack) {
10
15
  const initialMembership = await readRestStackMembership(pr, repo);
11
16
  if (!initialMembership) {
12
17
  if (expectedStack)
13
18
  fail("Expected native stack is no longer present");
14
- return;
19
+ return undefined;
15
20
  }
16
21
  if (expectedStack &&
17
22
  (initialMembership.number !== expectedStack.number ||
@@ -43,11 +48,12 @@ export async function validateRestStackMergeReadiness(pr, repo, sha, expectedSta
43
48
  if (stackAncestryGaps(prefix).length > 0)
44
49
  fail("Stack prefix has stale parent boundaries");
45
50
  await mapPool(open, 4, async (member) => {
46
- const raw = await fetchRawSummaryPr(member.number, repo);
47
- const summary = await summarizePollSummaryPr(raw, repo, { stackPrNumber: pr });
48
- if (raw.headRefOid !== member.headRefOid ||
49
- raw.baseRefOid !== member.baseRefOid ||
50
- summary.readyReceipt !== true)
51
+ const receipt = await readReadyReceipt(member, pr, repo);
52
+ if (receipt.status === "unverified")
53
+ fail(`PR #${member.number} READY receipt could not be verified because the GraphQL re-read failed (${receipt.error}); wait for the rate limit or outage to clear, or check API access`);
54
+ if (receipt.status === "changed")
55
+ fail(receipt.message);
56
+ if (receipt.status === "missing")
51
57
  fail(`PR #${member.number} has no current Shepherd READY receipt`);
52
58
  });
53
59
  const latest = await readRestStackTopology(pr, repo);
@@ -60,6 +66,52 @@ export async function validateRestStackMergeReadiness(pr, repo, sha, expectedSta
60
66
  latest.stackNumber !== topology.stackNumber ||
61
67
  JSON.stringify(latest.ordered) !== JSON.stringify(topology.ordered))
62
68
  fail("Native stack changed while validating merge readiness");
69
+ return prefix.map((member) => ({ pr: member.number, headRefOid: member.headRefOid }));
70
+ }
71
+ /**
72
+ * A READY receipt hashes the evidence its one-PR session read, and REST and GraphQL snapshots of
73
+ * the same PR hash differently. This command always runs over REST, but a stack whose layers were
74
+ * shepherded over GraphQL earned GraphQL receipts, so a layer the REST snapshot cannot match is
75
+ * read once more over GraphQL. A refused or failed GraphQL read leaves the layer unproven, which
76
+ * stays a refusal but is reported as unverified with the error rather than as a missing receipt.
77
+ */
78
+ async function readReadyReceipt(member, stackPr, repo) {
79
+ const read = async () => {
80
+ const raw = await fetchRawSummaryPr(member.number, repo);
81
+ const moved = [];
82
+ if (raw.headRefOid !== member.headRefOid)
83
+ moved.push(`head: stack read ${short(member.headRefOid)}, now ${short(raw.headRefOid)}`);
84
+ if (raw.baseRefOid !== member.baseRefOid)
85
+ moved.push(`base: stack read ${short(member.baseRefOid)}, now ${short(raw.baseRefOid)}`);
86
+ if (moved.length > 0)
87
+ return {
88
+ kind: "changed",
89
+ message: `PR #${member.number} changed head or base while validating merge readiness (${moved.join("; ")})`,
90
+ };
91
+ const summary = await summarizePollSummaryPr(raw, repo, { stackPrNumber: stackPr });
92
+ return { kind: summary.readyReceipt === true ? "ready" : "no-receipt" };
93
+ };
94
+ const toStatus = (result) => result.kind === "changed"
95
+ ? { status: "changed", message: result.message }
96
+ : { status: result.kind === "ready" ? "ready" : "missing" };
97
+ const first = await read();
98
+ if (first.kind !== "no-receipt")
99
+ return toStatus(first);
100
+ return runWithGithubTransport("graphql", read).then(toStatus, (error) => ({
101
+ status: "unverified",
102
+ error: oneLineError(error),
103
+ }));
104
+ }
105
+ /** Upstream error text goes to stderr: keep it on one line, redacted and bounded. */
106
+ function oneLineError(error) {
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ // C0/C1 controls, Unicode line/paragraph separators, and bidi formatting marks.
109
+ // oxlint-disable-next-line no-control-regex -- stripping control characters is the point
110
+ const unsafe = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200e\u200f\u202a-\u202e\u2066-\u2069]+/g;
111
+ return sanitizeBody(message.replace(unsafe, " ").trim());
112
+ }
113
+ function short(sha) {
114
+ return sha.slice(0, 8);
63
115
  }
64
116
  function guardMember(member) {
65
117
  return {
@@ -1,5 +1,6 @@
1
1
  export { findHumanHandoffs, appendHumanHandoffInstructions } from "./stack-handoffs.mts";
2
2
  import type { PollSummaryItem, PollSummaryResult, StackNextAction } from "../types.mts";
3
+ import type { ApproveCommands } from "./stack-merge-escalations.mts";
3
4
  export { isStackLayerReady, stackPosition } from "./stack-merge-scope.mts";
4
5
  export interface StackPlan {
5
6
  action: StackNextAction;
@@ -7,6 +8,11 @@ export interface StackPlan {
7
8
  waiting?: boolean;
8
9
  /** Set only by {@link idleWaitPlan}: the layers whose one-PR probes could only report waiting. */
9
10
  idle?: PollSummaryItem[];
11
+ /**
12
+ * Set with {@link StackPlan.idle} when unlisted layers have work: their claim steps, which an
13
+ * until-terminal poll never returns while it waits, so the stall escalation carries them.
14
+ */
15
+ claims?: string[];
10
16
  instructions: string[];
11
17
  }
12
18
  /**
@@ -19,4 +25,4 @@ export declare function idleWaitPlan(idle: PollSummaryItem[]): StackPlan;
19
25
  export declare function describeIdleLayers(idle: PollSummaryItem[]): string;
20
26
  /** True when the caller listed its own PRs, so rows carry `owned` and others are not theirs. */
21
27
  export declare function hasListedOwnership(result: PollSummaryResult): boolean;
22
- export declare function appendAutonomousInstructions(instructions: string[], candidates: PollSummaryItem[], partial?: boolean): void;
28
+ export declare function appendAutonomousInstructions(instructions: string[], candidates: PollSummaryItem[], partial?: boolean, approve?: ApproveCommands, merging?: boolean): void;
@@ -31,8 +31,6 @@ export function idleWaitPlan(idle) {
31
31
  };
32
32
  }
33
33
  function sessionInstruction(item) {
34
- if (!item.owned)
35
- return ` PR #${item.pr} is not owned. Do not run a session for it.`;
36
34
  const removal = item.queueRemoval
37
35
  ? ` PR #${item.pr} was removed from the merge queue (\`${item.queueRemoval.reason ?? "unknown reason"}\`${item.queueRemoval.actor ? ` by @${item.queueRemoval.actor}` : ""}).`
38
36
  : "";
@@ -54,14 +52,40 @@ export function describeIdleLayers(idle) {
54
52
  export function hasListedOwnership(result) {
55
53
  return result.selection.kind === "stack" && result.selection.owned !== undefined;
56
54
  }
57
- export function appendAutonomousInstructions(instructions, candidates, partial = false) {
55
+ /**
56
+ * Layers with work that the caller did not list after `stack`. "Not listed" is about the command
57
+ * line: the GitHub author cannot tell an agent from the person it pushes as, so the step prints
58
+ * the command that lists it too and lets the caller decide whether it is its work. One step per
59
+ * layer, so a caller that opened only some of them lists only those, and each command names PRs
60
+ * explicitly (never the stack number, which would also pick up a layer added later). The printed
61
+ * command never carries a merge flag: shepherding a layer is not approval to merge it, and under
62
+ * a merge flag it runs only after this command's own merge steps, which still settle any request.
63
+ */
64
+ function unlistedStep(item, approve, merging) {
65
+ const command = approve?.([item.pr], true).listed;
66
+ const rerun = command
67
+ ? `\`${command}\``
68
+ : `this \`stack\` command with #${item.pr} listed after \`stack\`${merging ? " and no merge flag" : ""}`;
69
+ const claim = merging
70
+ ? `first finish this command's steps (its merge request, resuming a pending request, and its rerun); then run ${rerun} to shepherd it. That command has no merge flag; list #${item.pr} in a merge command only if the user's merge request covers it.`
71
+ : `run ${rerun} instead and follow that output rather than the steps below.`;
72
+ return ` #${item.pr} has work but is not listed after \`stack\`, so this command starts no session for it. "Not listed" is about this command line, not authorship. If you opened #${item.pr}, or the user asked you to shepherd it, ${claim} Otherwise do not run a session for it.`;
73
+ }
74
+ export function appendAutonomousInstructions(instructions, candidates, partial = false, approve, merging = false) {
58
75
  if (candidates.length === 0)
59
76
  return;
60
- const separate = candidates.some(onlyLacksReceipt)
77
+ const unlisted = partial ? candidates.filter((item) => !item.owned) : [];
78
+ const listed = partial ? candidates.filter((item) => item.owned) : candidates;
79
+ for (const item of unlisted) {
80
+ instructions.push(`${instructions.length + 1}.${unlistedStep(item, approve, merging)}`);
81
+ }
82
+ if (listed.length === 0)
83
+ return;
84
+ const separate = listed.some(onlyLacksReceipt)
61
85
  ? " Run each command as its own session: one multi-PR `pr-shepherd <PR> <PR>` poll records no READY receipts."
62
86
  : "";
63
- instructions.push(`${instructions.length + 1}. ${partial ? "Start one concurrent one-PR session per command below, only for `owned` rows; none for layers without one." : "Start one concurrent one-PR session per command below; none for layers without one."}${separate}`);
64
- for (const item of candidates) {
87
+ instructions.push(`${instructions.length + 1}. Start one concurrent one-PR session per command below; none for layers without one.${separate}`);
88
+ for (const item of listed) {
65
89
  instructions.push(`${instructions.length + 1}.${sessionInstruction(item)}`);
66
90
  }
67
91
  }
@@ -0,0 +1,32 @@
1
+ import type { RepoInfo } from "../github/client.mts";
2
+ /** A stack layer and the head commit the caller validated for it. */
3
+ export interface StackLayerHead {
4
+ pr: number;
5
+ headRefOid: string;
6
+ }
7
+ /** How the stack's layers below the merged PR differ from the validated set. */
8
+ export interface StackDrift {
9
+ /** Validated layers whose head is no longer the validated one. */
10
+ moved: number[];
11
+ /** Layers now below the merged PR that were never validated. */
12
+ added: number[];
13
+ /** Validated layers GitHub no longer lists (only reported when `strict`). */
14
+ missing: number[];
15
+ }
16
+ /**
17
+ * GitHub's `merge-async` request binds only the requested (top) PR's head SHA. Re-read the stack
18
+ * and report layers below it that moved or were added since validation, so a push or a new layer
19
+ * is caught before submission and on each `pending` resume. After submission, a layer GitHub no
20
+ * longer lists is tolerated, because a request that is already merging lower layers removes them;
21
+ * before submission (`strict`) a vanished layer or stack is drift too.
22
+ */
23
+ export declare function movedStackLayerHeads(pr: number, repo: RepoInfo, expected: readonly StackLayerHead[], options?: {
24
+ strict?: boolean;
25
+ }): Promise<StackDrift>;
26
+ /** One sentence naming each kind of drift, or undefined when there is none. */
27
+ export declare function describeStackDrift(drift: StackDrift): string | undefined;
28
+ /**
29
+ * The refusal message when the stack drifted since validation; undefined when unchanged. A
30
+ * re-read that fails throws, so nothing is recorded and the same command can be rerun.
31
+ */
32
+ export declare function stackHeadDrift(pr: number, repo: RepoInfo, heads: readonly StackLayerHead[]): Promise<string | undefined>;
@@ -0,0 +1,53 @@
1
+ import { EXIT, ShepherdError } from "../exit-codes.mjs";
2
+ import { readRestStackMembership, readRestStackTopology } from "../github/rest-stack-read.mjs";
3
+ /**
4
+ * GitHub's `merge-async` request binds only the requested (top) PR's head SHA. Re-read the stack
5
+ * and report layers below it that moved or were added since validation, so a push or a new layer
6
+ * is caught before submission and on each `pending` resume. After submission, a layer GitHub no
7
+ * longer lists is tolerated, because a request that is already merging lower layers removes them;
8
+ * before submission (`strict`) a vanished layer or stack is drift too.
9
+ */
10
+ export async function movedStackLayerHeads(pr, repo, expected, options = {}) {
11
+ const known = new Set(expected.map((layer) => layer.pr));
12
+ if (!(await readRestStackMembership(pr, repo)))
13
+ return { moved: [], added: [], missing: options.strict ? [...known] : [] };
14
+ const topology = await readRestStackTopology(pr, repo);
15
+ const current = new Map(topology.ordered.map((member) => [member.number, member.headRefOid]));
16
+ const below = topology.ordered
17
+ .slice(0, Math.max(0, topology.ordered.findIndex((member) => member.number === pr)))
18
+ .map((member) => member.number);
19
+ return {
20
+ moved: expected
21
+ .filter((layer) => current.has(layer.pr) && current.get(layer.pr) !== layer.headRefOid)
22
+ .map((layer) => layer.pr),
23
+ added: below.filter((number) => !known.has(number)),
24
+ missing: options.strict ? [...known].filter((number) => !current.has(number)) : [],
25
+ };
26
+ }
27
+ const list = (prs) => prs.map((n) => `#${n}`).join(", ");
28
+ /** One sentence naming each kind of drift, or undefined when there is none. */
29
+ export function describeStackDrift(drift) {
30
+ const parts = [
31
+ drift.moved.length > 0 && `Stack layers ${list(drift.moved)} changed head after validation`,
32
+ drift.added.length > 0 && `Stack layers ${list(drift.added)} were added after validation`,
33
+ drift.missing.length > 0 &&
34
+ `Stack layers ${list(drift.missing)} left the stack after validation`,
35
+ ].filter(Boolean);
36
+ return parts.length > 0 ? parts.join("; ") : undefined;
37
+ }
38
+ /**
39
+ * The refusal message when the stack drifted since validation; undefined when unchanged. A
40
+ * re-read that fails throws, so nothing is recorded and the same command can be rerun.
41
+ */
42
+ export async function stackHeadDrift(pr, repo, heads) {
43
+ let drift;
44
+ try {
45
+ drift = await movedStackLayerHeads(pr, repo, heads, { strict: true });
46
+ }
47
+ catch (error) {
48
+ throw new ShepherdError(`Stack layer heads could not be re-read (${error instanceof Error ? error.message : String(error)}); no merge request was submitted. Rerun this command.`, EXIT.UNAVAILABLE, { cause: error });
49
+ }
50
+ const message = describeStackDrift(drift);
51
+ return (message &&
52
+ `${message}; no merge request was submitted. Rerun \`pr-shepherd stack <PR> --merge\`.`);
53
+ }
@@ -1,7 +1,8 @@
1
1
  import type { PollSummaryItem, PollSummaryResult, StackMergeScope } from "../types.mts";
2
2
  import type { StackPlan } from "./stack-drain.mts";
3
3
  /** Commands that approve unlisted layers: list them as well, or name the stack number. */
4
- export type ApproveCommands = (extra: number[]) => {
4
+ /** With `shepherdOnly`, both commands drop the merge flag, so listing a layer never merges it. */
5
+ export type ApproveCommands = (extra: number[], shepherdOnly?: boolean) => {
5
6
  listed: string;
6
7
  whole: string;
7
8
  };