pr-shepherd 2.1.0 → 2.2.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.
Files changed (184) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +28 -22
  3. package/bin/api.d.mts +10 -2
  4. package/bin/api.mjs +30 -6
  5. package/bin/checks/pending-deployments.d.mts +10 -0
  6. package/bin/checks/pending-deployments.mjs +66 -0
  7. package/bin/checks/run-workflow-paths.d.mts +7 -0
  8. package/bin/checks/run-workflow-paths.mjs +19 -0
  9. package/bin/checks/triage.mjs +3 -2
  10. package/bin/checks/unreported-required.d.mts +11 -1
  11. package/bin/checks/unreported-required.mjs +8 -3
  12. package/bin/checks/workflow-concurrency.d.mts +9 -0
  13. package/bin/checks/workflow-concurrency.mjs +84 -0
  14. package/bin/checks/workflow-path.d.mts +2 -0
  15. package/bin/checks/workflow-path.mjs +4 -0
  16. package/bin/cli/arg-flags.mjs +3 -0
  17. package/bin/cli/clean-handler.mjs +1 -1
  18. package/bin/cli/default-poll.mjs +1 -0
  19. package/bin/cli/handlers.mjs +2 -0
  20. package/bin/cli/help-command-pages.d.mts +5 -4
  21. package/bin/cli/help-command-pages.mjs +2 -1
  22. package/bin/cli/help-iterate-poll-pages.d.mts +3 -3
  23. package/bin/cli/help-iterate-poll-pages.mjs +10 -2
  24. package/bin/cli/help-top-page.d.mts +1 -1
  25. package/bin/cli/help-top-page.mjs +2 -2
  26. package/bin/cli/help.d.mts +6 -5
  27. package/bin/cli/in-progress-run-format.d.mts +3 -0
  28. package/bin/cli/in-progress-run-format.mjs +14 -0
  29. package/bin/cli/iterate-activity-formatter.d.mts +2 -0
  30. package/bin/cli/iterate-activity-formatter.mjs +11 -0
  31. package/bin/cli/iterate-flags.d.mts +3 -0
  32. package/bin/cli/iterate-flags.mjs +18 -1
  33. package/bin/cli/iterate-formatter.mjs +2 -1
  34. package/bin/cli/iterate-lean.mjs +2 -0
  35. package/bin/cli/pending-deployments-format.d.mts +5 -0
  36. package/bin/cli/pending-deployments-format.mjs +19 -0
  37. package/bin/cli/poll-handler.d.mts +1 -1
  38. package/bin/cli/poll-handler.mjs +33 -10
  39. package/bin/cli/poll-targets.mjs +2 -0
  40. package/bin/cli/stack-merge-args.d.mts +10 -0
  41. package/bin/cli/stack-merge-args.mjs +27 -0
  42. package/bin/cli/stack-overview.d.mts +1 -0
  43. package/bin/cli/stack-overview.mjs +5 -1
  44. package/bin/cli/stalled-check-format.d.mts +3 -0
  45. package/bin/cli/stalled-check-format.mjs +23 -0
  46. package/bin/cli/suggestion-renderer.mjs +6 -0
  47. package/bin/cli/triage-formatter.mjs +14 -0
  48. package/bin/commands/check.mjs +7 -2
  49. package/bin/commands/clean.d.mts +1 -1
  50. package/bin/commands/clean.mjs +7 -0
  51. package/bin/commands/iterate/check-follow-up.d.mts +9 -0
  52. package/bin/commands/iterate/check-follow-up.mjs +34 -0
  53. package/bin/commands/iterate/ci-start-stall.d.mts +23 -0
  54. package/bin/commands/iterate/ci-start-stall.mjs +33 -0
  55. package/bin/commands/iterate/duration-approx.d.mts +2 -0
  56. package/bin/commands/iterate/duration-approx.mjs +8 -0
  57. package/bin/commands/iterate/escalate.d.mts +8 -17
  58. package/bin/commands/iterate/escalate.mjs +19 -48
  59. package/bin/commands/iterate/helpers.mjs +1 -0
  60. package/bin/commands/iterate/in-progress-runs.d.mts +10 -0
  61. package/bin/commands/iterate/in-progress-runs.mjs +120 -0
  62. package/bin/commands/iterate/index.mjs +12 -6
  63. package/bin/commands/iterate/merge-plan.d.mts +2 -0
  64. package/bin/commands/iterate/merge-plan.mjs +2 -1
  65. package/bin/commands/iterate/merge-state.d.mts +2 -0
  66. package/bin/commands/iterate/merge-state.mjs +8 -21
  67. package/bin/commands/iterate/native-stack-rebase.d.mts +3 -2
  68. package/bin/commands/iterate/native-stack-rebase.mjs +32 -11
  69. package/bin/commands/iterate/queue-removal.d.mts +19 -0
  70. package/bin/commands/iterate/queue-removal.mjs +64 -0
  71. package/bin/commands/iterate/render.d.mts +2 -1
  72. package/bin/commands/iterate/render.mjs +4 -1
  73. package/bin/commands/iterate/stack-boundary.d.mts +17 -0
  74. package/bin/commands/iterate/stack-boundary.mjs +95 -0
  75. package/bin/commands/iterate/stall-repair.d.mts +17 -0
  76. package/bin/commands/iterate/stall-repair.mjs +25 -0
  77. package/bin/commands/iterate/stall.d.mts +1 -1
  78. package/bin/commands/iterate/stall.mjs +27 -18
  79. package/bin/commands/iterate/state-unavailable.d.mts +8 -0
  80. package/bin/commands/iterate/state-unavailable.mjs +23 -0
  81. package/bin/commands/iterate/triage-loop-instruction.mjs +1 -1
  82. package/bin/commands/iterate/triage.mjs +41 -74
  83. package/bin/commands/iterate/unreported-required.d.mts +5 -2
  84. package/bin/commands/iterate/unreported-required.mjs +13 -8
  85. package/bin/commands/iterate/workflow-files.d.mts +27 -0
  86. package/bin/commands/iterate/workflow-files.mjs +85 -0
  87. package/bin/commands/poll-summary-explicit-instructions.mjs +15 -1
  88. package/bin/commands/poll-summary-instructions.d.mts +4 -3
  89. package/bin/commands/poll-summary-instructions.mjs +60 -22
  90. package/bin/commands/poll-summary.mjs +38 -10
  91. package/bin/commands/poll.mjs +4 -2
  92. package/bin/commands/stack-drain.d.mts +4 -4
  93. package/bin/commands/stack-drain.mjs +19 -113
  94. package/bin/commands/stack-handoffs.d.mts +3 -3
  95. package/bin/commands/stack-handoffs.mjs +8 -8
  96. package/bin/commands/stack-lower-ready-note.d.mts +6 -0
  97. package/bin/commands/stack-lower-ready-note.mjs +35 -0
  98. package/bin/commands/stack-merge-escalations.d.mts +17 -0
  99. package/bin/commands/stack-merge-escalations.mjs +57 -0
  100. package/bin/commands/stack-merge-plan.d.mts +10 -0
  101. package/bin/commands/stack-merge-plan.mjs +132 -0
  102. package/bin/commands/stack-merge-scope.d.mts +42 -0
  103. package/bin/commands/stack-merge-scope.mjs +113 -0
  104. package/bin/commands/stack-ownership.d.mts +25 -0
  105. package/bin/commands/stack-ownership.mjs +85 -0
  106. package/bin/commands/stack-stall.d.mts +2 -0
  107. package/bin/commands/stack-stall.mjs +25 -3
  108. package/bin/commands/stack-targets-error.d.mts +16 -0
  109. package/bin/commands/stack-targets-error.mjs +44 -0
  110. package/bin/commands/stack-targets.d.mts +30 -0
  111. package/bin/commands/stack-targets.mjs +121 -0
  112. package/bin/commands/stack-work.d.mts +4 -3
  113. package/bin/commands/stack-work.mjs +7 -4
  114. package/bin/commands/tick.mjs +14 -2
  115. package/bin/config/renames.mjs +1 -1
  116. package/bin/config/schema.d.mts +4 -0
  117. package/bin/config/schema.mjs +2 -0
  118. package/bin/github/batch-parse-suites.d.mts +4 -1
  119. package/bin/github/batch-parse-suites.mjs +15 -3
  120. package/bin/github/batch-raw-types.d.mts +6 -0
  121. package/bin/github/gql/commit-check-suites.gql +6 -0
  122. package/bin/github/gql/poll-summary-fragment.gql +6 -0
  123. package/bin/github/graphql-http.mjs +8 -6
  124. package/bin/github/graphql-tolerated-errors.d.mts +3 -0
  125. package/bin/github/graphql-tolerated-errors.mjs +20 -0
  126. package/bin/github/poll-summary-command.d.mts +15 -1
  127. package/bin/github/poll-summary-command.mjs +39 -3
  128. package/bin/github/poll-summary-projector.d.mts +1 -1
  129. package/bin/github/poll-summary-projector.mjs +1 -4
  130. package/bin/github/poll-summary-raw.d.mts +6 -0
  131. package/bin/github/poll-summary-route.mjs +4 -1
  132. package/bin/github/poll-summary.mjs +10 -3
  133. package/bin/github/rest-batch-read.mjs +17 -6
  134. package/bin/github/rest-batch-snapshot.d.mts +2 -2
  135. package/bin/github/rest-batch-snapshot.mjs +3 -0
  136. package/bin/github/rest-check-read.d.mts +1 -18
  137. package/bin/github/rest-check-read.mjs +1 -2
  138. package/bin/github/rest-stack-read.d.mts +9 -0
  139. package/bin/github/rest-stack-read.mjs +40 -0
  140. package/bin/github/rest-suite-types.d.mts +23 -0
  141. package/bin/github/rest-suite-types.mjs +1 -0
  142. package/bin/github/rest-summary-read.mjs +2 -0
  143. package/bin/mcp/server.mjs +29 -3
  144. package/bin/pr-reference.d.mts +2 -0
  145. package/bin/pr-reference.mjs +1 -1
  146. package/bin/reporters/agent.mjs +3 -0
  147. package/bin/state/check-follow-up.d.mts +30 -0
  148. package/bin/state/check-follow-up.mjs +51 -0
  149. package/bin/state/ci-start-follow-up.d.mts +14 -0
  150. package/bin/state/ci-start-follow-up.mjs +21 -0
  151. package/bin/state/queue-removal-follow-up.d.mts +20 -0
  152. package/bin/state/queue-removal-follow-up.mjs +23 -0
  153. package/bin/state/signature-marker.d.mts +10 -0
  154. package/bin/state/signature-marker.mjs +28 -0
  155. package/bin/state/stack-merge-approval.d.mts +26 -0
  156. package/bin/state/stack-merge-approval.mjs +39 -0
  157. package/bin/state/stall-repair.d.mts +16 -0
  158. package/bin/state/stall-repair.mjs +47 -0
  159. package/bin/types/activity.d.mts +2 -1
  160. package/bin/types/escalate.d.mts +9 -2
  161. package/bin/types/github.d.mts +18 -0
  162. package/bin/types/in-progress-run.d.mts +20 -0
  163. package/bin/types/in-progress-run.mjs +1 -0
  164. package/bin/types/iterate.d.mts +22 -1
  165. package/bin/types/poll-summary.d.mts +18 -1
  166. package/bin/types/report.d.mts +5 -1
  167. package/bin/types.d.mts +1 -0
  168. package/bin/types.mjs +1 -0
  169. package/package.json +2 -2
  170. package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
  171. package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
  172. package/plugins/pr-shepherd/.codex.mcp.json +1 -1
  173. package/plugins/pr-shepherd/.mcp.json +1 -1
  174. package/plugins/pr-shepherd/package-lock.json +4 -4
  175. package/plugins/pr-shepherd/package.json +1 -1
  176. package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +8 -7
  177. package/plugins/pr-shepherd/skills/pr-shepherd/references/check-follow-up.md +14 -0
  178. package/plugins/pr-shepherd/skills/pr-shepherd/references/ci-failure-triage.md +6 -5
  179. package/plugins/pr-shepherd/skills/pr-shepherd/references/ci-start-stall.md +15 -0
  180. package/plugins/pr-shepherd/skills/pr-shepherd/references/create-a-pr.md +4 -1
  181. package/plugins/pr-shepherd/skills/pr-shepherd/references/mcp-fallback.md +1 -1
  182. package/plugins/pr-shepherd/skills/pr-shepherd/references/merge-queue-ejection.md +6 -5
  183. package/plugins/pr-shepherd/skills/pr-shepherd/references/required-checks-unreported.md +16 -0
  184. package/pr-shepherd.schema.json +11 -0
@@ -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.1.0",
4
+ "version": "2.2.1",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com"
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # pr-shepherd
2
2
 
3
- Drive a pull request to merge-ready with a coding agent. It works with Claude Code, Codex, Grok, and any stdio MCP client.
3
+ Take pull requests from scratch to merge-ready with a coding agent. It works with Claude Code, Codex, Grok, and any stdio MCP client.
4
4
 
5
- **Modeled per PR session: about 30% lower LLM cost than `gh` at a 60k-token context (27–33% across 40k–100k) and about 74% lower than the GitHub MCP server, both assuming a warm prompt cache. While waiting on CI: ~60 GraphQL points an hour vs. ~360 for `gh pr checks --watch`.**
5
+ **Modeled per PR session: about 36% lower LLM cost than `gh` at a 60k-token context (31–39% across 40k–100k) and about 76% lower than the GitHub MCP server, both assuming a warm prompt cache. GitHub quota per PR session: 33 GraphQL points and 4 REST requests, vs. 96 and 15 for `gh` and 11 and 82 for the MCP server.**
6
6
 
7
7
  ## What it does
8
8
 
@@ -34,7 +34,7 @@ $ pr-shepherd 123
34
34
  1. Fix each warranted item.
35
35
  2. Triage `## Failing checks`. Playbook: "CI failure triage".
36
36
  3. Optional: If you reject a code review suggestion, journal why: `pr-shepherd apply journal 123 '- <reason>'`.
37
- 4. Commit and push any changes.
37
+ 4. Commit and push any changes to the PR head.
38
38
  5. `$CHANGE_MESSAGE`: one sentence on what changed. Run even if no code changed: `pr-shepherd apply review 123 --reply-thread-ids PRRT_kwDOSGizTs58XB1L --message "$CHANGE_MESSAGE" --require-sha HEAD`
39
39
  6. Rerun Shepherd now.
40
40
  ```
@@ -43,14 +43,14 @@ More features are in [docs/features.md](docs/features.md).
43
43
 
44
44
  ## Outcomes
45
45
 
46
- | Outcome | Headline | Evidence |
47
- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
48
- | [Context and correctness](#context-and-correctness) | 63 GitHub edge cases cataloged, backed by 181 scenario fixtures | [Handled cases](docs/handled-cases.md) |
49
- | [Fewer tokens, lower cost](#fewer-tokens-and-lower-cost) | Modeled cost ~−30% vs. `gh` and ~−74% vs. MCP per PR session; turns −17% / −68% | [Token bench](evals/tokens/README.md) |
50
- | [Clearer agent direction](#clearer-agent-direction) | Across 33 PR states, 1.00 with the plugin vs. 0.55 with `gh` + GitHub MCP, Δ +0.45 [+0.40, +0.49] (2026-11-12) | [Outcome evals](evals/README.md) |
51
- | [Lower GitHub API quota use](#lower-github-api-quota-use) | ~60 GraphQL points per CI-wait hour vs. ~360 for `gh`; ~4 when idle. REST core per PR session 4.8 vs. 15 (`gh`), 82 (MCP) | [GitHub API](docs/github-api.md), [GraphQL usage](docs/graphql-usage.md) |
52
- | [Safe by construction](#safe-by-construction) | 0 git mutations; human handoff limited to 10 escalation triggers for a single PR | [Escalations](docs/escalations.md) |
53
- | [Works across agents and stacks](#works-across-agents-and-environments) | 3 agent plugins plus any stdio MCP client; GraphQL and REST transports; native stacked PRs | [MCP](docs/mcp.md), [cloud](docs/cloud.md) |
46
+ | Outcome | Headline | Evidence |
47
+ | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
48
+ | [Context and correctness](#context-and-correctness) | 72 GitHub edge cases cataloged, backed by 198 scenario fixtures | [Handled cases](docs/handled-cases.md) |
49
+ | [Fewer tokens, lower cost](#fewer-tokens-and-lower-cost) | Modeled cost ~−36% vs. `gh` and ~−76% vs. MCP per PR session; turns −20% / −69% | [Token bench](evals/tokens/README.md) |
50
+ | [Clearer agent direction](#clearer-agent-direction) | Across 56 PR states, 0.97 with the plugin vs. 0.47 with `gh` + GitHub MCP, Δ +0.50 (2026-11-15) | [Outcome evals](evals/README.md) |
51
+ | [Lower GitHub API quota use](#lower-github-api-quota-use) | Per PR session: GraphQL points 33 vs. 96 (`gh`), 11 (MCP); REST core 3.8 vs. 15, 82 | [GitHub API](docs/github-api.md), [GraphQL usage](docs/graphql-usage.md) |
52
+ | [Safe by construction](#safe-by-construction) | 0 git mutations; human handoff limited to 9 escalation triggers for a single PR | [Escalations](docs/escalations.md) |
53
+ | [Works across agents and stacks](#works-across-agents-and-environments) | 3 agent plugins plus any stdio MCP client; GraphQL and REST transports; native stacked PRs | [MCP](docs/mcp.md), [cloud](docs/cloud.md) |
54
54
 
55
55
  **[jongleberry.com/pr-shepherd](https://jongleberry.com/pr-shepherd/)** covers the why and the design principles.
56
56
 
@@ -67,7 +67,7 @@ One `iterate` call returns everything the agent needs about the PR:
67
67
 
68
68
  One exception: a `COMMENTED` review that was already minimized before the first tick is not fetched. [docs/handled-cases.md](docs/handled-cases.md) catalogs the GitHub edge cases this covers.
69
69
 
70
- In the [outcome evals](evals/README.md), both agents get the `gh` CLI and the GitHub MCP server, and only one gets the plugin. These PR states separated them most (score with the plugin vs. with `gh` + MCP, 2026-11-12; 95% interval of the difference excludes 0):
70
+ In the [outcome evals](evals/README.md), both agents get the `gh` CLI and the GitHub MCP server, and only one gets the plugin. These PR states separated them most (score with the plugin vs. with `gh` + MCP, 2026-11-15; 95% interval of the difference excludes 0):
71
71
 
72
72
  | PR state | Plugin | gh/MCP |
73
73
  | ------------------------------------------------------------------------ | -----: | -----: |
@@ -82,10 +82,10 @@ Batching, noise filtering, fingerprint skips, seen markers, and lean output cut
82
82
 
83
83
  | Session | Cost vs. `gh` | Cost vs. GitHub MCP |
84
84
  | --------- | ------------: | ------------------: |
85
- | Single PR | **−30%** | **−74%** |
85
+ | Single PR | **−36%** | **−76%** |
86
86
  | PR stack | **−40%** | **−60%** |
87
87
 
88
- These are modeled, not measured billing. The model replays a hand-weighted PR session (a CI wait, a failing log, review rounds, marking a draft ready, a merge) against scripted `gh` and MCP agents that never retry or fail a step. The figures above use a 60k-token context, Claude Code's 1-hour cache-write price, and about 190 output tokens per turn, thinking included, as measured in [Sonnet 5.5 eval traces](evals/HISTORY.md#2026-11-12-output-and-spend-in-the-outcome-eval-traces). They assume a warm prompt cache. At a 40k context the single-PR saving vs. `gh` is 33%, and at 100k it is 27%. A wait past the cache's one-hour lifetime re-writes the context. One such expiry cuts the saving vs. `gh` to 16–19% and vs. MCP to 57–61% ([realism sweep](evals/tokens/REPORT.md#realism-sweep)).
88
+ These are modeled, not measured billing. The model replays a hand-weighted PR session (a CI wait, a failing log, review rounds, marking a draft ready, a merge) against scripted `gh` and MCP agents that never retry or fail a step. The figures above use a 60k-token context, Claude Code's 1-hour cache-write price, and about 190 output tokens per turn, thinking included, as measured in [Sonnet 5.5 eval traces](evals/HISTORY.md#2026-11-12-output-and-spend-in-the-outcome-eval-traces). They assume a warm prompt cache. At a 40k context the single-PR saving vs. `gh` is 39%, and at 100k it is 31%. A wait past the cache's one-hour lifetime re-writes the context. One such expiry cuts the saving vs. `gh` to 18–23% and vs. MCP to 58–62% ([realism sweep](evals/tokens/REPORT.md#realism-sweep)).
89
89
 
90
90
  Where the saving comes from, and where it does not:
91
91
 
@@ -99,7 +99,7 @@ Where the saving comes from, and where it does not:
99
99
 
100
100
  For a single PR, each tick returns exactly one action: `WAIT`, `READY`, `MARK_READY`, `TRIAGE`, `MERGE`, `CANCEL`, or `ESCALATE`. A `stack` poll can also return `SHEPHERD`, which starts one-PR sessions for owned layers. Every action except `CANCEL` comes with numbered `## Instructions` and exact commands, so the agent does not invent policy.
101
101
 
102
- In the [outcome evals](evals/README.md) (Sonnet 5.5, 33 PR states, 2026-11-12), the agent scores **1.00** with the plugin and **0.55** with `gh` + the GitHub MCP server, a Δ of **+0.45** [+0.40, +0.49]. That is the latest run of each scenario; failing scenarios were rerun after fixes. Every category favors the plugin, from CI (+0.07) to stacks (+0.63) and the merge queue (+1.00). The output contract is in [docs/actions.md](docs/actions.md).
102
+ In the [outcome evals](evals/README.md) (Sonnet 5.5, 56 PR states, one full run on 2026-11-15), the agent scores **0.97** with the plugin and **0.47** with `gh` + the GitHub MCP server, a Δ of **+0.50**. Three scenarios come from reruns. No scenario favors `gh` + MCP. Every category favors the plugin, from review feedback (+0.21) to stacks (+0.73) and the merge queue (+1.00). The output contract is in [docs/actions.md](docs/actions.md).
103
103
 
104
104
  ### Lower GitHub API quota use
105
105
 
@@ -108,10 +108,10 @@ GitHub meters two tiers ([details](docs/github-api.md#github-metering)):
108
108
  - Primary hourly budgets: GraphQL points and REST `core` requests.
109
109
  - Secondary limits: per-minute points (a GraphQL query or REST `GET` costs 1, a mutation 5), plus concurrency and content-creation limits.
110
110
 
111
- Waiting is where most quota goes. By default `gh pr checks --watch` refreshes every 10 seconds at 1 GraphQL point each. That is about 360 points an hour per watched PR, so a few agents waiting on CI can drain the shared 5,000-point hourly budget. Shepherd polls every 60 seconds by default:
111
+ Waiting is where most quota goes. `gh pr checks --watch` refreshes every 10 seconds by default, at 1 GraphQL point each. That is about 360 points an hour per watched PR, so a few agents waiting on CI can drain the shared 5,000-point hourly budget. Agents rarely change it: of 599 `--watch` calls in the maintainer's agent transcripts, 17 set `--interval`. Shepherd polls every 60 seconds by default:
112
112
 
113
113
  - A typical tick is one batched GraphQL query (1 point). Large or paginated PRs add supplement queries. When nothing changed, the fingerprint skip returns the stored report from that same query.
114
- - While CI runs, that is about 60 points an hour for a typical PR. The token bench models `gh` refreshing every 60 seconds, which ties Shepherd at 60 ([report](evals/tokens/REPORT.md)).
114
+ - While CI runs, that is about 60 points an hour for a typical PR. A `gh` agent that passes `--interval 60` ties it ([sensitivity](evals/tokens/REPORT.md#gh-watch-interval-sensitivity)).
115
115
  - When no check is running, conditional REST change detectors run first. A `304` consumes no primary quota, so an hour of unchanged idle waiting costs about 4 GraphQL points instead of 60 ([graphql-usage.md](docs/graphql-usage.md)). Native-stack layers, `READY` reports, incomplete snapshots, and detector failures still run the batched query each tick ([graphql.md](docs/graphql.md#idle-wait-change-detectors)).
116
116
 
117
117
  The GitHub MCP server issues one or more REST requests per tool call, so unbatched calls drain `core` and the per-minute pool faster.
@@ -121,23 +121,23 @@ Two optional setups take most of the remaining spend off your token. They are in
121
121
  - **[GitHub App](docs/github-app.md):** reads whose answer does not depend on who asks go to an app installation, which has its own budget. On a live PR, one tick's user-token GraphQL dropped from a 3,135-node read to a 4-node viewer read, and a tick that reuses the stored report spends none (a native-stack layer still reads `PollStackTopology` on your token). Six ticks went from 7 user-token requests (21,945 nodes) to 2 (8 nodes). READY-receipt reads, stack summaries, and ticks while the app's quota is spent stay on your token ([details](docs/github-app.md#the-batchpr-viewer-split)).
122
122
  - **[hook-harness events](docs/hook-harness.md):** a poll waits for a GitHub webhook event about the PR instead of sleeping. A quiet PR ticks every 5 minutes (`events.fallback-interval-seconds`) instead of every minute. A push or check result wakes it after a 10-second settle, never sooner than `poll.interval-seconds` after the previous tick began. Events never make ticks more frequent than plain polling.
123
123
 
124
- Per session, assumed and deterministic, from the [token bench](evals/tokens/README.md):
124
+ Per session, assumed and deterministic, from the same weighted scenarios as the [token bench](evals/tokens/README.md)'s cost figures. The PR session includes a 6-minute CI wait, with `gh` on its default `--watch` refresh:
125
125
 
126
126
  | Session | GraphQL points: Shepherd / `gh` / MCP | REST core: Shepherd / `gh` / MCP |
127
127
  | --------- | ------------------------------------: | -------------------------------: |
128
- | Single PR | 33.3 / 36.2 / 11.4 | 4.8 / 15 / 82 |
128
+ | Single PR | 33.3 / 96.2 / 11.4 | 3.8 / 15 / 82 |
129
129
  | PR stack | 11 / 27 / 12 | 2 / 6 / 74 |
130
130
 
131
- - On the default GraphQL transport, Shepherd spends fewer GraphQL points than `gh` and fewer REST requests than `gh` or MCP.
131
+ - On the default GraphQL transport, Shepherd spends fewer GraphQL points than `gh` and fewer REST requests than `gh` or MCP. A `gh` agent on `--watch --interval 60` spends 36.2 points, still more than Shepherd.
132
132
  - On a single PR, MCP spends fewer GraphQL points but about 17× the REST requests.
133
- - The REST transport used in cloud sessions spends no GraphQL points. It spends more `core` requests than `gh` or MCP (201.7 single PR, 432 stack).
133
+ - The REST transport used in cloud sessions spends no GraphQL points. It spends more `core` requests than `gh` or MCP (200.7 single PR, 432 stack).
134
134
 
135
135
  See [docs/graphql-usage.md](docs/graphql-usage.md) and [docs/rest-usage.md](docs/rest-usage.md).
136
136
 
137
137
  ### Safe by construction
138
138
 
139
139
  - The CLI runs read-only git only. It emits patches and commit commands for the agent to run ([AGENTS.md](AGENTS.md#git-operations)).
140
- - Shepherd never merges by itself. With `--merge`, it emits a merge or queue command for the agent to run, head-pinned for a single PR and guarded by READY receipts for a stack.
140
+ - Shepherd never merges by itself. With `--merge`, it emits a merge or queue command for the agent to run, head-pinned for a single PR and guarded by READY receipts for a stack. `stack` merges only the layers you list (or all of them by stack number), and `--merge`, `--merge-ready`, or `--merge-through` escalate rather than land a layer you did not approve.
141
141
  - Human handoff is a [finite escalation list](docs/escalations.md).
142
142
  - The shipped skill tells the agent to treat review titles, comments, and CI logs as untrusted data. Shell and other MCP callers must apply that rule themselves.
143
143
  - A denied reply or resolve is a one-look skip, not a retry loop.
@@ -199,6 +199,12 @@ Requirements:
199
199
 
200
200
  ## Quick start
201
201
 
202
+ `/pr-shepherd:pr-shepherd` takes work from scratch to mergeable. The three everyday workflows:
203
+
204
+ - **"make PRs, /pr-shepherd:pr-shepherd"** makes one PR per change that can be reviewed alone. It stacks a PR on an earlier one when it needs that PR's code or edits the same lines, and shepherds every PR until it is mergeable. Independent changes become separate PRs on the default branch.
205
+ - **`/pr-shepherd <PR>`** takes a PR, including a draft, to mergeable. It does not merge.
206
+ - **`/pr-shepherd --merge <PR>`** takes the PR to mergeable and merges it. A PR owns only itself, so for a stack layer with open layers below it, Shepherd hands those layers back to you instead of merging them. `/pr-shepherd --merge stack owner/repo#N` lands the whole stack.
207
+
202
208
  ```text
203
209
  /goal /pr-shepherd:pr-shepherd 42 # Claude Code
204
210
  /goal $pr-shepherd 42 # Codex
package/bin/api.d.mts CHANGED
@@ -38,9 +38,17 @@ export type MultiIterateInput = IterateOptions & {
38
38
  pr?: never;
39
39
  };
40
40
  export type IterateInput = SingleIterateInput | MultiIterateInput;
41
- /** One aggregate tick over the native stack containing `pr`. */
41
+ /**
42
+ * One aggregate tick over one native stack. `refs` is one stack number (or `owner/repo#N` naming
43
+ * one), which the caller owns entirely; or one or more PRs of one stack, which select it and own only
44
+ * those PRs (a single PR owns only itself). `merge` lands every owned layer,
45
+ * `mergeReady` the ready owned prefix, and `mergeThrough` the owned layers up to that PR; they are
46
+ * mutually exclusive.
47
+ */
42
48
  export type StackInput = IterateOptions & {
43
- pr: PrReference;
49
+ refs: PrReference[];
50
+ mergeReady?: boolean;
51
+ mergeThrough?: PrReference;
44
52
  };
45
53
  export interface ReviewMutationsOperation {
46
54
  type: "review_mutations";
package/bin/api.mjs CHANGED
@@ -4,6 +4,7 @@ import { createGithubTransportRunner } from "./github/transport.mjs";
4
4
  import { runApplyMerge, validateApplyMergeOptions, } from "./commands/apply-merge.mjs";
5
5
  import { runSuggestionPatches } from "./commands/suggestion-patches.mjs";
6
6
  import { runIterateTick, runPollSummaryTick } from "./commands/tick.mjs";
7
+ import { resolveStackTarget, stackMergeScope, } from "./commands/stack-targets.mjs";
7
8
  import { applyCheckBlocker, } from "./commands/apply-check-blocker.mjs";
8
9
  import { parseBlockedByRef } from "./commands/check-blocker-ref.mjs";
9
10
  import { runJournal } from "./commands/journal/index.mjs";
@@ -72,15 +73,32 @@ export function createPrShepherd(options = {}) {
72
73
  iterate,
73
74
  stack(input) {
74
75
  return runInClient(input ?? {}, async () => {
75
- if (!input || input.pr === undefined) {
76
- throw new PrShepherdValidationError("stack requires a PR reference");
76
+ if (!input || !Array.isArray(input.refs) || input.refs.length === 0) {
77
+ throw new PrShepherdValidationError("stack requires at least one reference");
77
78
  }
78
- const { pr, ...options } = input;
79
- const { numbers, repository } = await resolveSameRepositoryRefs([pr], "stack.pr");
79
+ const { refs, mergeReady, mergeThrough, ...options } = input;
80
+ const flags = [
81
+ ...(options.merge ? ["merge"] : []),
82
+ ...(mergeReady ? ["ready"] : []),
83
+ ...(mergeThrough !== undefined ? ["through"] : []),
84
+ ];
85
+ if (flags.length > 1) {
86
+ throw new PrShepherdValidationError("merge, mergeReady, and mergeThrough are mutually exclusive");
87
+ }
88
+ const target = await resolveStackTarget({
89
+ refs: refs.map(parseStackRef),
90
+ ...(mergeThrough !== undefined && { through: parseStackRef(mergeThrough) }),
91
+ ...(flags[0] && { merge: flags[0] }),
92
+ tool: true,
93
+ });
94
+ const scope = stackMergeScope(flags[0], target.through);
80
95
  return runPollSummaryTick({
81
96
  ...options,
82
- stackPrNumber: numbers[0],
83
- targetRepository: repository,
97
+ merge: scope !== undefined,
98
+ ...(scope && { stackMerge: scope }),
99
+ stackPrNumber: target.anchor,
100
+ ...(target.owned && { stackOwned: target.owned }),
101
+ targetRepository: target.targetRepository,
84
102
  });
85
103
  });
86
104
  },
@@ -228,6 +246,12 @@ async function resolveSameRepositoryRefs(refs, label) {
228
246
  }
229
247
  return { numbers, repository: repository };
230
248
  }
249
+ function parseStackRef(ref) {
250
+ const parsed = parsePrReference(ref);
251
+ if (!parsed?.number)
252
+ throw new PrShepherdValidationError(`Invalid reference: ${String(ref)}`);
253
+ return parsed;
254
+ }
231
255
  function validateApplyInput(input) {
232
256
  if (!input || !Array.isArray(input.operations) || input.operations.length === 0) {
233
257
  throw new PrShepherdValidationError("apply requires a non-empty operations array");
@@ -0,0 +1,10 @@
1
+ import type { RepoInfo } from "../github/client.mts";
2
+ import type { StateKey } from "../state/rest-cache.mts";
3
+ import type { CheckRun } from "../types.mts";
4
+ import { TriageBudget } from "./triage-budget.mts";
5
+ /**
6
+ * Attaches the raw pending-deployment data to checks whose run may be waiting on an environment
7
+ * approval. One conditional REST read per distinct run, and none when no such check exists. A
8
+ * failed read leaves the check as it was; an empty answer (fork gate) adds nothing.
9
+ */
10
+ export declare function attachPendingDeployments<T extends CheckRun>(checks: T[], repo: RepoInfo, stateKey?: StateKey, budget?: TriageBudget): Promise<T[]>;
@@ -0,0 +1,66 @@
1
+ import { restWithRateLimit } from "../github/http.mjs";
2
+ import { mapPool } from "../util/pool.mjs";
3
+ import { TriageBudget } from "./triage-budget.mjs";
4
+ /**
5
+ * A run can be held by an environment protection rule. GitHub reports it as a check with status
6
+ * `WAITING`; the "approve and run" gate for fork or first-time contributors reports
7
+ * `ACTION_REQUIRED` instead. Either may have pending deployments, so both are asked.
8
+ */
9
+ function mayHavePendingDeployments(check) {
10
+ return (check.runId !== null && (check.status === "WAITING" || check.conclusion === "ACTION_REQUIRED"));
11
+ }
12
+ function toPendingDeployments(raw) {
13
+ return raw.flatMap((item) => {
14
+ const environment = item.environment?.name;
15
+ if (!environment)
16
+ return [];
17
+ const reviewers = (item.reviewers ?? []).flatMap((r) => {
18
+ const name = r.reviewer?.login ?? r.reviewer?.slug;
19
+ if (!name)
20
+ return [];
21
+ return r.type === "User" || r.type === "Team" ? [{ type: r.type, name }] : [];
22
+ });
23
+ return [
24
+ {
25
+ environment,
26
+ currentUserCanApprove: item.current_user_can_approve === true,
27
+ ...(reviewers.length > 0 && { reviewers }),
28
+ ...(typeof item.wait_timer === "number" &&
29
+ item.wait_timer > 0 && { waitTimerMinutes: item.wait_timer }),
30
+ },
31
+ ];
32
+ });
33
+ }
34
+ async function fetchRunPendingDeployments(runId, repo, stateKey, budget) {
35
+ if (!budget.canScheduleOptional())
36
+ return [];
37
+ try {
38
+ const { data, rateLimit } = await restWithRateLimit("GET", `/repos/${repo.owner}/${repo.name}/actions/runs/${runId}/pending_deployments`, undefined, stateKey
39
+ ? { conditional: { key: stateKey, name: `pending-deployments-run-${runId}` } }
40
+ : undefined);
41
+ budget.observe(rateLimit);
42
+ return Array.isArray(data) ? toPendingDeployments(data) : [];
43
+ }
44
+ catch (error) {
45
+ budget.observeError(error);
46
+ return [];
47
+ }
48
+ }
49
+ /**
50
+ * Attaches the raw pending-deployment data to checks whose run may be waiting on an environment
51
+ * approval. One conditional REST read per distinct run, and none when no such check exists. A
52
+ * failed read leaves the check as it was; an empty answer (fork gate) adds nothing.
53
+ */
54
+ export async function attachPendingDeployments(checks, repo, stateKey, budget = new TriageBudget()) {
55
+ const runIds = [...new Set(checks.filter(mayHavePendingDeployments).map((c) => c.runId))];
56
+ if (runIds.length === 0)
57
+ return checks;
58
+ const byRun = new Map();
59
+ await mapPool(runIds, 4, async (runId) => {
60
+ byRun.set(runId, await fetchRunPendingDeployments(runId, repo, stateKey, budget));
61
+ });
62
+ return checks.map((check) => {
63
+ const pending = check.runId === null ? undefined : byRun.get(check.runId);
64
+ return pending && pending.length > 0 ? { ...check, pendingDeployments: pending } : check;
65
+ });
66
+ }
@@ -0,0 +1,7 @@
1
+ import type { CheckRun } from "../types.mts";
2
+ import type { WorkflowSuiteSnapshot } from "./unreported-required.mts";
3
+ /**
4
+ * Names the workflow file on checks whose Actions run has not finished, so `triage` can read its
5
+ * `concurrency`. A finished suite is left alone: a stuck check keeps no file line.
6
+ */
7
+ export declare function withRunWorkflowPaths(checks: readonly CheckRun[], suites: readonly WorkflowSuiteSnapshot[]): CheckRun[];
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Names the workflow file on checks whose Actions run has not finished, so `triage` can read its
3
+ * `concurrency`. A finished suite is left alone: a stuck check keeps no file line.
4
+ */
5
+ export function withRunWorkflowPaths(checks, suites) {
6
+ const paths = new Map();
7
+ for (const suite of suites) {
8
+ const run = suite.workflowRun;
9
+ if (suite.status === "COMPLETED" || !run?.path || run.databaseId == null)
10
+ continue;
11
+ paths.set(String(run.databaseId), run.path);
12
+ }
13
+ return checks.map((check) => {
14
+ const workflowPath = check.runId === null ? undefined : paths.get(check.runId);
15
+ return workflowPath !== undefined && check.status !== "COMPLETED"
16
+ ? { ...check, workflowPath }
17
+ : check;
18
+ });
19
+ }
@@ -5,6 +5,7 @@ import { pickFailedStep } from "./jobs-types.mjs";
5
5
  import { pickRelatedFailedJobs, fetchRelatedJobs } from "./related-jobs.mjs";
6
6
  import { TriageBudget } from "./triage-budget.mjs";
7
7
  import { mapPool } from "../util/pool.mjs";
8
+ import { normalizeWorkflowPath } from "./workflow-path.mjs";
8
9
  const STARTUP_FAILURE_STATUS = "startup_failure";
9
10
  export async function triageFailingChecks(failingChecks, repo, stateKey, budget = new TriageBudget(),
10
11
  /** Non-failing checks (ignored, filtered, superseded, …) whose jobs must not resurface as related jobs. */
@@ -122,7 +123,7 @@ async function fetchStartupFailureChecksUncached(repo, headSha, prNumber, stateK
122
123
  return checks;
123
124
  }
124
125
  function workflowRunToCheckRun(run) {
125
- const summary = run.display_title?.trim() || undefined;
126
+ const workflowPath = normalizeWorkflowPath(run.path);
126
127
  const runAttempt = normalizeRunAttempt(run.run_attempt);
127
128
  return {
128
129
  name: run.name?.trim() || `workflow run ${run.id}`,
@@ -133,7 +134,7 @@ function workflowRunToCheckRun(run) {
133
134
  event: run.event,
134
135
  runId: String(run.id),
135
136
  ...(runAttempt !== undefined && { runAttempt }),
136
- ...(summary !== undefined && { summary }),
137
+ ...(workflowPath !== undefined && { workflowPath }),
137
138
  };
138
139
  }
139
140
  function normalizeRunAttempt(value) {
@@ -4,8 +4,16 @@ export interface WorkflowSuiteSnapshot {
4
4
  conclusion?: string | null;
5
5
  workflowRun?: {
6
6
  event?: string | null;
7
+ /** Run id and workflow file, read to find an unfinished run's `concurrency`. */
8
+ databaseId?: number | null;
9
+ path?: string | null;
10
+ } | null;
11
+ app?: {
12
+ slug?: string | null;
7
13
  } | null;
8
14
  }
15
+ /** The GitHub Actions app, which creates a suite before its workflow run exists. */
16
+ export declare const ACTIONS_APP_SLUG = "github-actions";
9
17
  /** Required context names that have no check run and no status context. */
10
18
  export declare function unreportedRequiredContexts(required: readonly string[], reported: ReadonlySet<string>): string[];
11
19
  /** Every check or status name on the head. A later success and an older cancel share one name. */
@@ -14,7 +22,9 @@ export declare function reportedCheckNames(checks: readonly {
14
22
  }[]): Set<string>;
15
23
  /**
16
24
  * True when a relevant Actions workflow has not finished.
17
- * Suites with no workflow run stay queued at third-party apps and do not count.
25
+ * A suite with no run yet counts only when the Actions app owns it and it is not COMPLETED:
26
+ * Actions creates suites a few seconds before their runs. Third-party apps leave suites queued
27
+ * forever with no run, so those do not count.
18
28
  */
19
29
  export declare function actionsWorkflowInProgress(suites: readonly WorkflowSuiteSnapshot[], relevantEvents: ReadonlySet<string>): boolean;
20
30
  /**
@@ -1,3 +1,5 @@
1
+ /** The GitHub Actions app, which creates a suite before its workflow run exists. */
2
+ export const ACTIONS_APP_SLUG = "github-actions";
1
3
  /** Required context names that have no check run and no status context. */
2
4
  export function unreportedRequiredContexts(required, reported) {
3
5
  const seen = new Set();
@@ -23,13 +25,16 @@ export function reportedCheckNames(checks) {
23
25
  }
24
26
  /**
25
27
  * True when a relevant Actions workflow has not finished.
26
- * Suites with no workflow run stay queued at third-party apps and do not count.
28
+ * A suite with no run yet counts only when the Actions app owns it and it is not COMPLETED:
29
+ * Actions creates suites a few seconds before their runs. Third-party apps leave suites queued
30
+ * forever with no run, so those do not count.
27
31
  */
28
32
  export function actionsWorkflowInProgress(suites, relevantEvents) {
29
33
  return suites.some((suite) => {
30
34
  const run = suite.workflowRun;
31
- if (!run)
32
- return false;
35
+ if (!run) {
36
+ return (suite.app?.slug === ACTIONS_APP_SLUG && suite.status != null && suite.status !== "COMPLETED");
37
+ }
33
38
  const event = run.event ?? null;
34
39
  if (event !== null && event !== "" && !relevantEvents.has(event))
35
40
  return false;
@@ -0,0 +1,9 @@
1
+ /** A workflow's top-level `concurrency.cancel-in-progress`, raw. */
2
+ export interface WorkflowConcurrency {
3
+ /** Raw display value, e.g. `cancel-in-progress=true` or `none`. */
4
+ raw: string;
5
+ /** True only for the YAML boolean `true`; an expression is never treated as true. */
6
+ cancelInProgress: boolean;
7
+ }
8
+ /** Reads the workflow file's top-level `concurrency`. Returns `undefined` when it does not parse. */
9
+ export declare function parseWorkflowConcurrency(text: string): WorkflowConcurrency | undefined;
@@ -0,0 +1,84 @@
1
+ import { parse } from "yaml";
2
+ /** Context values that stay the same across pushes to one pull request. */
3
+ const STABLE_CONTEXT = new Set([
4
+ "github.workflow",
5
+ "github.ref",
6
+ "github.head_ref",
7
+ "github.base_ref",
8
+ "github.event_name",
9
+ "github.repository",
10
+ "github.event.number",
11
+ "github.event.pull_request.number",
12
+ ]);
13
+ const EXPRESSION_WORDS = new Set(["true", "false", "null", "format", "contains", "join"]);
14
+ /**
15
+ * True only for a literal group, or one whose expressions use known push-stable context values.
16
+ * Anything else (SHA, run id, index syntax, unknown values) is unverified, so no cancel is printed.
17
+ */
18
+ function groupIsStable(group) {
19
+ const expressions = [...group.matchAll(/\$\{\{([\s\S]*?)\}\}/g)].map((match) => match[1]);
20
+ return expressions.every((expression) => {
21
+ const code = expression.replace(/'(?:[^']|'')*'/g, "");
22
+ if (/[[\]]/.test(code))
23
+ return false;
24
+ const names = code.match(/[A-Za-z_][\w.-]*/g) ?? [];
25
+ return names.every((name) => STABLE_CONTEXT.has(name) || EXPRESSION_WORDS.has(name));
26
+ });
27
+ }
28
+ /**
29
+ * False when any `pull_request` / `pull_request_target` trigger lists `types` without
30
+ * `synchronize`, or filters by `paths`: the run in progress may be of that event, and a fix push then starts no
31
+ * replacement run of it. Conservative: an unverified event withholds the cancel.
32
+ */
33
+ function pushRetriggers(on) {
34
+ if (on === null || typeof on !== "object" || Array.isArray(on))
35
+ return true;
36
+ const triggers = ["pull_request", "pull_request_target"]
37
+ .map((name) => on[name])
38
+ .filter((trigger) => trigger !== undefined);
39
+ if (triggers.length === 0)
40
+ return true;
41
+ return triggers.every((trigger) => {
42
+ const config = trigger !== null && typeof trigger === "object" ? trigger : {};
43
+ // A path filter is evaluated against the whole PR diff, so a fix push may not match it.
44
+ if (config["paths"] !== undefined || config["paths-ignore"] !== undefined)
45
+ return false;
46
+ const types = config["types"];
47
+ return !Array.isArray(types) || types.includes("synchronize");
48
+ });
49
+ }
50
+ function scalar(value) {
51
+ return typeof value === "string" ? value : JSON.stringify(value);
52
+ }
53
+ /** Reads the workflow file's top-level `concurrency`. Returns `undefined` when it does not parse. */
54
+ export function parseWorkflowConcurrency(text) {
55
+ let doc;
56
+ try {
57
+ doc = parse(text);
58
+ }
59
+ catch {
60
+ return undefined;
61
+ }
62
+ if (doc === null || typeof doc !== "object" || Array.isArray(doc))
63
+ return undefined;
64
+ const concurrency = doc["concurrency"];
65
+ if (concurrency === undefined || concurrency === null) {
66
+ return { raw: "none", cancelInProgress: false };
67
+ }
68
+ const value = typeof concurrency === "object" && !Array.isArray(concurrency)
69
+ ? concurrency["cancel-in-progress"]
70
+ : undefined;
71
+ if (value === undefined)
72
+ return { raw: "cancel-in-progress=unset", cancelInProgress: false };
73
+ const group = concurrency["group"];
74
+ if (value === true && (typeof group !== "string" || !groupIsStable(group))) {
75
+ return { raw: "cancel-in-progress=true (group not verified stable)", cancelInProgress: false };
76
+ }
77
+ if (value === true && !pushRetriggers(doc["on"])) {
78
+ return {
79
+ raw: "cancel-in-progress=true (a push may not retrigger it)",
80
+ cancelInProgress: false,
81
+ };
82
+ }
83
+ return { raw: `cancel-in-progress=${scalar(value)}`, cancelInProgress: value === true };
84
+ }
@@ -0,0 +1,2 @@
1
+ /** Workflow file path without a REST `@<ref>` suffix, or undefined when blank. */
2
+ export declare function normalizeWorkflowPath(path: string | null | undefined): string | undefined;
@@ -0,0 +1,4 @@
1
+ /** Workflow file path without a REST `@<ref>` suffix, or undefined when blank. */
2
+ export function normalizeWorkflowPath(path) {
3
+ return path?.split("@")[0]?.trim() || undefined;
4
+ }
@@ -3,11 +3,13 @@
3
3
  export const FLAGS_WITH_VALUES = new Set([
4
4
  "--transport",
5
5
  "--merge-action",
6
+ "--merge-through",
6
7
  "--method",
7
8
  "--format",
8
9
  "--ready-delay",
9
10
  "--stall-timeout",
10
11
  "--instructions",
12
+ "--layers",
11
13
  "--require-sha",
12
14
  "--message",
13
15
  "--description",
@@ -37,6 +39,7 @@ export const BOOLEAN_FLAGS = new Set([
37
39
  "--no-quiet-status",
38
40
  "--until-terminal",
39
41
  "--merge",
42
+ "--merge-ready",
40
43
  "--dry-run",
41
44
  "--verbose",
42
45
  "--clear",
@@ -2,7 +2,7 @@ import { runClean } from "../commands/clean.mjs";
2
2
  import { EXIT } from "../exit-codes.mjs";
3
3
  import { USAGE } from "./help.mjs";
4
4
  import { formatCleanResult } from "./formatters.mjs";
5
- const CLEAN_VARIANTS = new Set(["pr", "branch", "current", "repo", "all"]);
5
+ const CLEAN_VARIANTS = new Set(["pr", "stack", "branch", "current", "repo", "all"]);
6
6
  export async function handleClean(args) {
7
7
  const command = "admin clean";
8
8
  const usage = USAGE["admin clean"];
@@ -9,6 +9,7 @@ export const DEFAULT_POLL_FLAGS_WITH_VALUES = new Set([
9
9
  "--ready-delay",
10
10
  "--stall-timeout",
11
11
  "--instructions",
12
+ "--layers",
12
13
  "--interval",
13
14
  "--timeout",
14
15
  "--debounce",
@@ -40,6 +40,7 @@ const ITERATE_FLAGS = [
40
40
  "--no-auto-mark-ready",
41
41
  "--merge",
42
42
  "--instructions",
43
+ "--layers",
43
44
  ];
44
45
  /** `iterate [PR...]`: one tick for one PR, or one aggregate tick for several. */
45
46
  export async function handleIterate(args) {
@@ -78,6 +79,7 @@ export async function handleIterate(args) {
78
79
  noAutoMarkReady: flags.noAutoMarkReady,
79
80
  merge: flags.merge,
80
81
  instructions: flags.instructions ?? undefined,
82
+ ...(flags.stackLayers && { stackLayers: flags.stackLayers }),
81
83
  });
82
84
  emitIterateResult(result, {
83
85
  format: globalOpts.format,