pr-shepherd 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +59 -167
- package/bin/commands/iterate/check-follow-up.d.mts +9 -0
- package/bin/commands/iterate/check-follow-up.mjs +22 -0
- package/bin/commands/iterate/escalate.mjs +1 -1
- package/bin/commands/iterate/run-failure-wait.d.mts +16 -0
- package/bin/commands/iterate/run-failure-wait.mjs +32 -0
- package/bin/commands/iterate/triage.mjs +50 -13
- package/bin/state/check-follow-up.d.mts +14 -1
- package/bin/state/check-follow-up.mjs +34 -6
- package/package.json +1 -1
- package/plugins/pr-shepherd/.claude-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex-plugin/plugin.json +1 -1
- package/plugins/pr-shepherd/.codex.mcp.json +1 -1
- package/plugins/pr-shepherd/.mcp.json +1 -1
- package/plugins/pr-shepherd/package-lock.json +4 -4
- package/plugins/pr-shepherd/package.json +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/references/check-follow-up.md +1 -1
package/README.md
CHANGED
|
@@ -1,174 +1,84 @@
|
|
|
1
1
|
# pr-shepherd
|
|
2
2
|
|
|
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.
|
|
3
|
+
Take pull requests from scratch to merge-ready with a coding agent as a [Code Mode-style](https://code.claude.com/docs/en/code-mode) plugin. It works with Claude Code, Codex, Grok, and any stdio MCP client.
|
|
4
|
+
|
|
5
|
+
## Benefits
|
|
6
|
+
|
|
7
|
+
- **Better decisions:** across 56 PR states, the agent scores 0.97 with the plugin vs. 0.47 with `gh` + the GitHub MCP server ([outcome evals](evals/README.md), 2026-11-15).
|
|
8
|
+
- **Lower cost:** modeled cost per PR session is about 36% lower than `gh` and 76% lower than the GitHub MCP server, with 20% / 69% fewer turns ([token bench](evals/tokens/README.md); assumes a warm prompt cache).
|
|
9
|
+
- **More PRs on one GitHub quota:** 65% fewer GraphQL points than `gh` per PR session. While CI runs, one 5,000-point hourly budget covers about 80 waiting PRs, vs. about 13 with `gh pr checks --watch` ([GitHub API](docs/github-api.md), [GraphQL usage](docs/graphql-usage.md)). A [GitHub App](docs/github-app.md) and [webhook events](docs/hook-harness.md) cut it further.
|
|
10
|
+
- **72 GitHub edge cases handled:** for example, outdated or resolved threads are still shown once, comments edited after the agent read them come back, and conflicts that GraphQL reports as `CLEAN` are caught ([handled cases](docs/handled-cases.md)).
|
|
11
|
+
- **Tidy PRs:** bot and outdated comments are triaged and resolved, human reviews get replies, and known bot noise is minimized.
|
|
12
|
+
- **Review hygiene:** Shepherd never answers its own replies, skips a denied reply once instead of retrying, hands a repeatedly rejected fix to a human, and never minimizes human comments ([comments and reviews](docs/handled-cases.md#comments-and-reviews)).
|
|
13
|
+
- **Less context:** resolved comments and configured bot noise are filtered out before they reach the agent.
|
|
14
|
+
- **CI failures, pre-read:** each failing check comes with its failed step, summary, and a log excerpt, so the agent can usually skip fetching logs. Superseded runs, required checks that never started, and approval gates are recognized ([failing checks](docs/actions.md#failing-checks-and-reruns), [CI cases](docs/handled-cases.md#ci-checks)).
|
|
15
|
+
- **Cheaper CI:** names the in-progress runs a fix push would cancel anyway, so the agent cancels them early.
|
|
16
|
+
- **Why a PR can't merge:** reads branch protection and rulesets and prints the actual requirements, such as `Approvals: None [Required]` ([merge requirements](docs/merge-status.md#merge-requirements)). Merges are pinned to the head the agent checked, review nits wait so a push doesn't eject a queued PR, and a PR a maintainer pulled from the queue is not requeued ([merge and queue](docs/handled-cases.md#merge-and-queue)).
|
|
17
|
+
- **Full flow:** from scratch to draft, mergeable, and through the merge queue, including stacked PRs.
|
|
18
|
+
- **Review suggestions:** applies suggested changes as commits that credit the reviewer.
|
|
19
|
+
- **Safe by construction:** the CLI never mutates git or merges by itself, and human handoff is limited to a [short escalation list](docs/escalations.md).
|
|
4
20
|
|
|
5
|
-
|
|
21
|
+
## Use cases
|
|
22
|
+
|
|
23
|
+
- **Autonomous agents.** An agent opens a PR and drives it to merge-ready, or merged when you allow it. Nobody has to watch CI and reviews.
|
|
24
|
+
- **Exhaustive AI code review.** Some PRs get many bot reviews (CodeRabbit, Codex, Copilot, and others). Shepherd shows every thread and comment once and tracks first-look, edited, and outdated items. It pre-filters comments, batches the replies, resolves, and minimizes.
|
|
25
|
+
- **High-velocity teams.** Supports stacked PRs, merge queues, and merge queue ejections, and directs agents to rebase or stack as needed, so work keeps moving even with many conflicts.
|
|
26
|
+
|
|
27
|
+
## How to use
|
|
28
|
+
|
|
29
|
+
[Install](#install) the plugin, then ask your agent:
|
|
30
|
+
|
|
31
|
+
- **"make PRs, /pr-shepherd:pr-shepherd"** makes one PR per change that can be reviewed alone, 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.
|
|
32
|
+
- **`/pr-shepherd <PR>`** takes a PR, including a draft, to mergeable. It does not merge. Leave out the PR to use the current branch.
|
|
33
|
+
- **`/pr-shepherd <PR1> <PR2>`** shepherds several PRs and returns when any has an actionable step.
|
|
34
|
+
- **`/pr-shepherd --merge <PR>`** takes the PR to mergeable and merges it.
|
|
35
|
+
- **`/pr-shepherd stack <stack#> --merge`** shepherds a native stack and merges it all at once when it is ready. Use `--merge-through <PR>` instead to merge up to that layer, or `--merge-ready` to merge the bottom layers as they become ready. Listing PR numbers instead of the stack number owns only those layers.
|
|
36
|
+
|
|
37
|
+
In Codex, use `$pr-shepherd`. In a shell or CI, run `pr-shepherd <PR>`. `/goal` is generally not needed.
|
|
38
|
+
|
|
39
|
+
Then configure `.pr-shepherdrc.yml` ([configuration](docs/configuration.md)):
|
|
40
|
+
|
|
41
|
+
- turn on the bundled classification rules to hide known bot comments;
|
|
42
|
+
- add your own [classification rules](examples/classification/);
|
|
43
|
+
- list code-review workflows in `checks.never-cancel` so they always finish.
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
version: 1
|
|
47
|
+
classify:
|
|
48
|
+
standard:
|
|
49
|
+
all: true
|
|
50
|
+
checks:
|
|
51
|
+
never-cancel:
|
|
52
|
+
- "*review*"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Optionally, write your policy ("reply instead of fixing nits", "never merge") into a skill that wraps the shipped one ([skills](docs/skills.md)).
|
|
6
56
|
|
|
7
57
|
## What it does
|
|
8
58
|
|
|
9
|
-
|
|
10
|
-
- Returns one action with numbered instructions and exact commands. `CANCEL` ends the loop and carries none.
|
|
11
|
-
- Never mutates git. The agent edits, commits, pushes, and decides what each comment deserves.
|
|
59
|
+
Shepherd gathers the full PR context (reviews, CI failures, merge requirements) in one call and returns one action with numbered instructions and exact commands. The agent spends fewer reasoning tokens, tool calls, and turns, and rarely has to investigate on its own.
|
|
12
60
|
|
|
13
61
|
```text
|
|
14
62
|
$ pr-shepherd 123
|
|
15
63
|
|
|
16
64
|
# PR #123 [TRIAGE]
|
|
17
65
|
|
|
18
|
-
**status** `UNRESOLVED_COMMENTS` · **repo** `owner/repo`
|
|
19
|
-
**summary** 3 passing
|
|
20
|
-
|
|
21
66
|
## Review threads
|
|
22
67
|
|
|
23
68
|
### `threadId=PRRT_kwDOSGizTs58XB1L` — `src/commands/iterate/index.mts:42` (@alice · MEMBER)
|
|
24
69
|
|
|
25
70
|
> The variable name is misleading.
|
|
26
71
|
|
|
27
|
-
## Failing checks
|
|
28
|
-
|
|
29
|
-
- `24697658766` — `CI › lint / typecheck / test (22.x)` [conclusion: FAILURE]
|
|
30
|
-
> oxfmt
|
|
31
|
-
|
|
32
72
|
## Instructions
|
|
33
73
|
|
|
34
74
|
1. Fix each warranted item.
|
|
35
|
-
2.
|
|
36
|
-
3.
|
|
37
|
-
4.
|
|
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
|
-
6. Rerun Shepherd now.
|
|
75
|
+
2. Commit and push any changes to the PR head.
|
|
76
|
+
3. `$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`
|
|
77
|
+
4. Rerun Shepherd now.
|
|
40
78
|
```
|
|
41
79
|
|
|
42
80
|
More features are in [docs/features.md](docs/features.md).
|
|
43
81
|
|
|
44
|
-
## Outcomes
|
|
45
|
-
|
|
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
|
-
|
|
55
|
-
**[jongleberry.com/pr-shepherd](https://jongleberry.com/pr-shepherd/)** covers the why and the design principles.
|
|
56
|
-
|
|
57
|
-
## Outcome details
|
|
58
|
-
|
|
59
|
-
### Context and correctness
|
|
60
|
-
|
|
61
|
-
One `iterate` call returns everything the agent needs about the PR:
|
|
62
|
-
|
|
63
|
-
- review threads with replies, PR comments, and review summaries;
|
|
64
|
-
- each CI failure, with its failed step and a log excerpt when triage can fetch them;
|
|
65
|
-
- mergeability and the actual merge requirements;
|
|
66
|
-
- first-look, outdated, and edited items, and stack topology.
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
| PR state | Plugin | gh/MCP |
|
|
73
|
-
| ------------------------------------------------------------------------ | -----: | -----: |
|
|
74
|
-
| A maintainer removed the PR from the merge queue: don't requeue or merge | 1.00 | 0.00 |
|
|
75
|
-
| Merge conflicts: update from base and resolve them without handing off | 1.00 | 0.00 |
|
|
76
|
-
| Bot changes-requested reviews block merge: fix, push, and dismiss both | 1.00 | 0.00 |
|
|
77
|
-
| Lower stack layers merged: rebase the whole stack so upper layers follow | 1.00 | 0.00 |
|
|
78
|
-
|
|
79
|
-
### Fewer tokens and lower cost
|
|
80
|
-
|
|
81
|
-
Batching, noise filtering, fingerprint skips, seen markers, and lean output cut tokens and agent turns. Estimated cost per session from the [token bench](evals/tokens/README.md) ([report](evals/tokens/REPORT.md)):
|
|
82
|
-
|
|
83
|
-
| Session | Cost vs. `gh` | Cost vs. GitHub MCP |
|
|
84
|
-
| --------- | ------------: | ------------------: |
|
|
85
|
-
| Single PR | **−36%** | **−76%** |
|
|
86
|
-
| PR stack | **−40%** | **−60%** |
|
|
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 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
|
-
|
|
90
|
-
Where the saving comes from, and where it does not:
|
|
91
|
-
|
|
92
|
-
- It comes from steps that re-read review history or CI logs, and from CI waits. Without those steps, pr-shepherd costs slightly more than `gh`.
|
|
93
|
-
- A single fresh read-and-reply tick costs about the same as `gh`, or slightly more. In the single-state outcome evals, the plugin arm's own spend per run was about 11–17% higher ([HISTORY](evals/HISTORY.md#2026-11-12-output-and-spend-in-the-outcome-eval-traces)).
|
|
94
|
-
- Confirming an already-merged PR costs about 2–6% more ([report](evals/tokens/REPORT.md)).
|
|
95
|
-
|
|
96
|
-
[docs/token-counts.md](docs/token-counts.md) counts the skill and per-tick text.
|
|
97
|
-
|
|
98
|
-
### Clearer agent direction
|
|
99
|
-
|
|
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
|
-
|
|
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
|
-
|
|
104
|
-
### Lower GitHub API quota use
|
|
105
|
-
|
|
106
|
-
GitHub meters two tiers ([details](docs/github-api.md#github-metering)):
|
|
107
|
-
|
|
108
|
-
- Primary hourly budgets: GraphQL points and REST `core` requests.
|
|
109
|
-
- Secondary limits: per-minute points (a GraphQL query or REST `GET` costs 1, a mutation 5), plus concurrency and content-creation limits.
|
|
110
|
-
|
|
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
|
-
|
|
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. A `gh` agent that passes `--interval 60` ties it ([sensitivity](evals/tokens/REPORT.md#gh-watch-interval-sensitivity)).
|
|
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
|
-
|
|
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.
|
|
118
|
-
|
|
119
|
-
Two optional setups take most of the remaining spend off your token. They are independent and combine:
|
|
120
|
-
|
|
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
|
-
- **[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
|
-
|
|
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
|
-
|
|
126
|
-
| Session | GraphQL points: Shepherd / `gh` / MCP | REST core: Shepherd / `gh` / MCP |
|
|
127
|
-
| --------- | ------------------------------------: | -------------------------------: |
|
|
128
|
-
| Single PR | 33.3 / 96.2 / 11.4 | 3.8 / 15 / 82 |
|
|
129
|
-
| PR stack | 11 / 27 / 12 | 2 / 6 / 74 |
|
|
130
|
-
|
|
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
|
-
- 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 (200.7 single PR, 432 stack).
|
|
134
|
-
|
|
135
|
-
See [docs/graphql-usage.md](docs/graphql-usage.md) and [docs/rest-usage.md](docs/rest-usage.md).
|
|
136
|
-
|
|
137
|
-
### Safe by construction
|
|
138
|
-
|
|
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. `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
|
-
- Human handoff is a [finite escalation list](docs/escalations.md).
|
|
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
|
-
- A denied reply or resolve is a one-look skip, not a retry loop.
|
|
144
|
-
|
|
145
|
-
### Works across agents and environments
|
|
146
|
-
|
|
147
|
-
- The plugin ships [skills](docs/skills.md) for Claude Code, Codex, and Grok.
|
|
148
|
-
- Cursor and other stdio clients use the [MCP server](docs/mcp.md).
|
|
149
|
-
- Shell and CI use the [CLI](docs/cli-usage.md).
|
|
150
|
-
- In Claude Code cloud sessions, Shepherd switches to the [REST transport](docs/rest.md) and [single ticks](docs/cloud.md).
|
|
151
|
-
- Optional [event-driven waiting](docs/hook-harness.md) wakes a poll on GitHub webhook events.
|
|
152
|
-
- `stack` reports every layer of a native GitHub stacked PR and shepherds the layers you own.
|
|
153
|
-
|
|
154
|
-
## Use cases
|
|
155
|
-
|
|
156
|
-
- **Autonomous agents.** An agent opens a PR and drives it to merge-ready, or merged when you allow it. Nobody has to watch CI and reviews.
|
|
157
|
-
- **Exhaustive AI code review.** Some PRs get many bot reviews (CodeRabbit, Codex, Copilot, and others). Shepherd shows every thread and comment once and tracks first-look, edited, and outdated items. It batches the replies, resolves, and minimizes.
|
|
158
|
-
|
|
159
|
-
## How to use
|
|
160
|
-
|
|
161
|
-
1. **Install the MCP server and the CLI.** See [Install](#install) below.
|
|
162
|
-
2. **Write your policy into a skill or agent instruction.** Examples: "skip non-blocking review comments", "reply instead of fixing nits", "never merge". Shepherd reports state and the next action. Your instructions decide how the agent treats each comment. The shipped `pr-shepherd` skill is a thin dispatcher you can wrap ([docs/skills.md](docs/skills.md)).
|
|
163
|
-
3. **Configure Shepherd.** In `.pr-shepherdrc.yml`, turn on the bundled classification rules. They drop known bot noise before it reaches the agent, which saves more tokens and tool calls. With the default `actions.auto-minimize-suppressed: true`, several rules also minimize matching comments on GitHub and surface the mutation result without editing the PR body. See [docs/configuration.md](docs/configuration.md#classifystandard--default-).
|
|
164
|
-
|
|
165
|
-
```yaml
|
|
166
|
-
version: 1
|
|
167
|
-
classify:
|
|
168
|
-
standard:
|
|
169
|
-
all: true
|
|
170
|
-
```
|
|
171
|
-
|
|
172
82
|
## Install
|
|
173
83
|
|
|
174
84
|
The plugin starts the version-matched `pr-shepherd-mcp` server automatically.
|
|
@@ -186,9 +96,11 @@ grok plugin marketplace add jonathanong/pr-shepherd
|
|
|
186
96
|
grok plugin install pr-shepherd --trust
|
|
187
97
|
|
|
188
98
|
# CLI, for shells and CI
|
|
189
|
-
|
|
99
|
+
pnpm i -g pr-shepherd
|
|
190
100
|
```
|
|
191
101
|
|
|
102
|
+
Use one package manager for global installs, because a second global copy shadows the first (`which -a pr-shepherd` lists every copy).
|
|
103
|
+
|
|
192
104
|
For the MCP server without the plugin, or a local checkout, see [docs/mcp.md](docs/mcp.md).
|
|
193
105
|
|
|
194
106
|
Requirements:
|
|
@@ -197,26 +109,6 @@ Requirements:
|
|
|
197
109
|
- `git`
|
|
198
110
|
- A GitHub token or an authenticated `gh` CLI with [the required access](docs/authentication.md)
|
|
199
111
|
|
|
200
|
-
## Quick start
|
|
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
|
-
|
|
208
|
-
```text
|
|
209
|
-
/goal /pr-shepherd:pr-shepherd 42 # Claude Code
|
|
210
|
-
/goal $pr-shepherd 42 # Codex
|
|
211
|
-
/pr-shepherd 42 # Grok
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
```sh
|
|
215
|
-
pr-shepherd 42 # shell: poll for work (270s cap; --until-terminal removes it)
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
Leave out the PR number to use the current branch.
|
|
219
|
-
|
|
220
112
|
## Documentation
|
|
221
113
|
|
|
222
114
|
[docs/README.md](docs/README.md) indexes every doc. Start with:
|
|
@@ -7,3 +7,12 @@ export type CheckFollowUp = "approval" | "investigate";
|
|
|
7
7
|
export declare function checkFollowUp(check: AgentCheck): CheckFollowUp | undefined;
|
|
8
8
|
/** The one investigation tick: raw facts, the playbook, and the bounded outcome. */
|
|
9
9
|
export declare function buildCheckFollowUpInstructions(checks: AgentCheck[], repo: string, actionsRunIds: ReadonlySet<string>): string[];
|
|
10
|
+
/**
|
|
11
|
+
* A failing check with evidence (an excerpt, or an external details URL) but no rerun and no
|
|
12
|
+
* further automatic path: an external status, a later attempt, or a merge-group failure once the
|
|
13
|
+
* PR left the queue. The caller can fix a cause in the PR; otherwise it gets one investigation
|
|
14
|
+
* tick before `check-follow-up-unavailable`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isEvidenceFollowUpCheck(check: AgentCheck, queued: boolean): boolean;
|
|
17
|
+
/** The investigation step for evidence-bearing checks: the evidence stays in the failing checks. */
|
|
18
|
+
export declare function buildEvidenceFollowUpInstruction(): string;
|
|
@@ -32,3 +32,25 @@ export function buildCheckFollowUpInstructions(checks, repo, actionsRunIds) {
|
|
|
32
32
|
"If the cause is within this PR, fix it and push. Otherwise make no change and keep what you found; do not rerun or retrigger these checks. If these checks are unchanged on the next poll, Shepherd escalates with `check-follow-up-unavailable`; report that diagnosis then.",
|
|
33
33
|
];
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* A failing check with evidence (an excerpt, or an external details URL) but no rerun and no
|
|
37
|
+
* further automatic path: an external status, a later attempt, or a merge-group failure once the
|
|
38
|
+
* PR left the queue. The caller can fix a cause in the PR; otherwise it gets one investigation
|
|
39
|
+
* tick before `check-follow-up-unavailable`.
|
|
40
|
+
*/
|
|
41
|
+
export function isEvidenceFollowUpCheck(check, queued) {
|
|
42
|
+
if (check.rerunCommand || checkFollowUp(check) !== undefined)
|
|
43
|
+
return false;
|
|
44
|
+
// A still-queued merge-group entry waits for GitHub to report its removal.
|
|
45
|
+
if (check.scope === "merge_group" && queued)
|
|
46
|
+
return false;
|
|
47
|
+
if (check.runId === null)
|
|
48
|
+
return Boolean(check.detailsUrl?.trim());
|
|
49
|
+
if (!hasLogEvidence(check))
|
|
50
|
+
return false;
|
|
51
|
+
return (check.runAttempt ?? 1) > 1 || (check.scope === "merge_group" && !queued);
|
|
52
|
+
}
|
|
53
|
+
/** The investigation step for evidence-bearing checks: the evidence stays in the failing checks. */
|
|
54
|
+
export function buildEvidenceFollowUpInstruction() {
|
|
55
|
+
return `Some checks under \`## Failing checks\` have no rerun Shepherd can offer. ${playbookPointer("Check follow-up")}`;
|
|
56
|
+
}
|
|
@@ -216,7 +216,7 @@ export function buildEscalateHumanMessage(escalate, pr, opts) {
|
|
|
216
216
|
export function buildEscalateSuggestion(triggers, detail) {
|
|
217
217
|
if (triggers.includes("check-follow-up-unavailable")) {
|
|
218
218
|
if (detail === "investigated") {
|
|
219
|
-
return "The failing checks below
|
|
219
|
+
return "The failing checks below have no rerun Shepherd can offer. After one investigation tick they are unchanged on this head. Report what the investigation found. What remains is a repository, CI-configuration, or workflow-permission change, or waiting out a GitHub incident; each is a human decision.";
|
|
220
220
|
}
|
|
221
221
|
return "One or more failing checks have no autonomous follow-up available. Use the displayed conclusion, run or URL, and included evidence to handle them manually.";
|
|
222
222
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { checkFollowUpKeys, sameCheckFollowUp } from "../../state/check-follow-up.mts";
|
|
2
|
+
import type { AgentCheck, IterateResult, IterateResultBase } from "../../types.mts";
|
|
3
|
+
/**
|
|
4
|
+
* Failing checks that can still change because CI is still running: an Actions check whose own
|
|
5
|
+
* run is in progress (no rerun is possible yet), and an external status with a details URL (no run
|
|
6
|
+
* id, e.g. coverage) while any workflow run is in progress, since such statuses often flip once CI
|
|
7
|
+
* finishes. They are shown once and then waited on. Queue checks and external approval gates
|
|
8
|
+
* (`ACTION_REQUIRED`, which escalate at once) are never held back.
|
|
9
|
+
*/
|
|
10
|
+
export declare function activeRunFailures(failing: readonly AgentCheck[], activeRunIds: ReadonlySet<string>, released: ReadonlySet<string>): AgentCheck[];
|
|
11
|
+
/** Identity of a shown failure set: name, run id, and attempt. */
|
|
12
|
+
export declare const runFailureKeys: typeof checkFollowUpKeys;
|
|
13
|
+
/** True when this head and check set were already shown on a presented tick. */
|
|
14
|
+
export declare const runFailuresShown: typeof sameCheckFollowUp;
|
|
15
|
+
/** The WAIT that replaces a repeated TRIAGE for already-shown failures in a running run. */
|
|
16
|
+
export declare function buildRunFailureWait(base: IterateResultBase, checks: readonly AgentCheck[]): IterateResult;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { checkFollowUpKeys, sameCheckFollowUp } from "../../state/check-follow-up.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Failing checks that can still change because CI is still running: an Actions check whose own
|
|
4
|
+
* run is in progress (no rerun is possible yet), and an external status with a details URL (no run
|
|
5
|
+
* id, e.g. coverage) while any workflow run is in progress, since such statuses often flip once CI
|
|
6
|
+
* finishes. They are shown once and then waited on. Queue checks and external approval gates
|
|
7
|
+
* (`ACTION_REQUIRED`, which escalate at once) are never held back.
|
|
8
|
+
*/
|
|
9
|
+
export function activeRunFailures(failing, activeRunIds, released) {
|
|
10
|
+
return failing.filter((check) => !released.has(check.name) &&
|
|
11
|
+
check.scope !== "merge_group" &&
|
|
12
|
+
(check.runId === null
|
|
13
|
+
? Boolean(check.detailsUrl) &&
|
|
14
|
+
check.conclusion !== "ACTION_REQUIRED" &&
|
|
15
|
+
activeRunIds.size > 0
|
|
16
|
+
: activeRunIds.has(check.runId)));
|
|
17
|
+
}
|
|
18
|
+
/** Identity of a shown failure set: name, run id, and attempt. */
|
|
19
|
+
export const runFailureKeys = checkFollowUpKeys;
|
|
20
|
+
/** True when this head and check set were already shown on a presented tick. */
|
|
21
|
+
export const runFailuresShown = sameCheckFollowUp;
|
|
22
|
+
/** The WAIT that replaces a repeated TRIAGE for already-shown failures in a running run. */
|
|
23
|
+
export function buildRunFailureWait(base, checks) {
|
|
24
|
+
const runIds = [...new Set(checks.filter((c) => c.runId !== null).map((c) => c.runId))];
|
|
25
|
+
const external = checks.filter((c) => c.runId === null).map((c) => c.name);
|
|
26
|
+
const waiting = [...runIds.map((id) => `run ${id}`), ...external].join(", ");
|
|
27
|
+
return {
|
|
28
|
+
...base,
|
|
29
|
+
action: "wait",
|
|
30
|
+
log: `WAIT: PR #${base.pr} failing checks already shown; their workflow run is still running (${waiting}) — waiting for it to complete`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -8,8 +8,9 @@ import { buildThreadMutationRouting, threadHasAuthorizedMutation, } from "./thre
|
|
|
8
8
|
import { buildFixInstructions } from "./render.mjs";
|
|
9
9
|
import { buildCancelRunsInstruction, buildInProgressRuns } from "./in-progress-runs.mjs";
|
|
10
10
|
import { buildRemovedQueueRecovery, buildStackQueueRemovalAcknowledgment } from "./merge.mjs";
|
|
11
|
-
import { buildCheckFollowUpInstructions, checkFollowUp } from "./check-follow-up.mjs";
|
|
12
|
-
import { checkFollowUpKeys, readCheckFollowUp, sameCheckFollowUp, writeCheckFollowUp, } from "../../state/check-follow-up.mjs";
|
|
11
|
+
import { buildCheckFollowUpInstructions, buildEvidenceFollowUpInstruction, checkFollowUp, isEvidenceFollowUpCheck, } from "./check-follow-up.mjs";
|
|
12
|
+
import { checkFollowUpKeys, readCheckFollowUp, readShownRunFailures, sameCheckFollowUp, writeCheckFollowUp, writeShownRunFailures, } from "../../state/check-follow-up.mjs";
|
|
13
|
+
import { activeRunFailures, buildRunFailureWait, runFailureKeys, runFailuresShown, } from "./run-failure-wait.mjs";
|
|
13
14
|
import { currentEjectionCommit, } from "./queue-recovery-instructions.mjs";
|
|
14
15
|
import { buildReleasedBlockerInstruction, buildReviewSubsetInstruction, } from "./check-instructions.mjs";
|
|
15
16
|
import { buildNativeStackLayerRebase } from "./native-stack-rebase.mjs";
|
|
@@ -199,7 +200,14 @@ async function handleTriageTick(ctx) {
|
|
|
199
200
|
const exhaustedAttempts = failingAgentChecks.filter((check) => check.runAttempt !== undefined && check.runAttempt > 1);
|
|
200
201
|
const manualExhaustedAttempts = exhaustedAttempts.filter((check) => manualFollowUpChecks.includes(check));
|
|
201
202
|
const hasBehindBaseRecovery = isBehind && manualExhaustedAttempts.length > 0;
|
|
202
|
-
const
|
|
203
|
+
const activeFailures = activeRunFailures(failingAgentChecks, inProgressWorkflowRunIds, releasedCheckNames);
|
|
204
|
+
const evidenceChecks = failingAgentChecks.filter((check) => !releasedCheckNames.has(check.name) &&
|
|
205
|
+
!belongsToActiveWorkflowRun(check) &&
|
|
206
|
+
!activeFailures.includes(check) &&
|
|
207
|
+
isEvidenceFollowUpCheck(check, Boolean(report.mergeQueue?.inQueue)));
|
|
208
|
+
const hasOtherAutonomousWork = hasConflicts ||
|
|
209
|
+
// The branch-update step is emitted only with a configured hint; uncounted work cannot loop.
|
|
210
|
+
(isBehind && behindBaseHint.trim() !== "" && evidenceChecks.length > 0) ||
|
|
203
211
|
hasBehindBaseRecovery ||
|
|
204
212
|
threads.length > 0 ||
|
|
205
213
|
resolutionOnlyThreads.length > 0 ||
|
|
@@ -213,20 +221,27 @@ async function handleTriageTick(ctx) {
|
|
|
213
221
|
report.comments.firstLook.length > 0 ||
|
|
214
222
|
report.reviewItems !== undefined ||
|
|
215
223
|
checks.some((check) => (check.annotations?.length ?? 0) > 0) ||
|
|
216
|
-
failingAgentChecks.some((check) =>
|
|
217
|
-
|
|
218
|
-
|
|
224
|
+
failingAgentChecks.some((check) => !activeFailures.includes(check) &&
|
|
225
|
+
(releasedCheckNames.has(check.name) ||
|
|
226
|
+
belongsToActiveWorkflowRun(check) ||
|
|
227
|
+
(checkFollowUp(check) === undefined && !evidenceChecks.includes(check))));
|
|
228
|
+
const hasAutonomousWork = hasOtherAutonomousWork || activeFailures.length > 0;
|
|
219
229
|
// Only a gate a human must grant escalates at once; every other manual-only check gets one
|
|
220
230
|
// investigation tick for this head and check set before it escalates.
|
|
221
231
|
const needsApproval = manualFollowUpChecks.some((check) => checkFollowUp(check) === "approval");
|
|
222
|
-
const
|
|
232
|
+
const terminalChecks = [...manualFollowUpChecks, ...evidenceChecks];
|
|
233
|
+
const followUpKeys = checkFollowUpKeys(terminalChecks);
|
|
223
234
|
const investigated = needsApproval || sameCheckFollowUp(await readCheckFollowUp(stallKey), headSha, followUpKeys);
|
|
224
|
-
const investigate = manualFollowUpChecks.length > 0 &&
|
|
225
|
-
|
|
235
|
+
const investigate = manualFollowUpChecks.length > 0 &&
|
|
236
|
+
evidenceChecks.length === 0 &&
|
|
237
|
+
!hasAutonomousWork &&
|
|
238
|
+
!investigated;
|
|
239
|
+
if (terminalChecks.length > 0 && !hasAutonomousWork && investigated) {
|
|
226
240
|
const { resolveCommand, resolveOnlyCommand } = buildReviewCommands(failingAgentChecks);
|
|
227
241
|
const pending = pendingReviewCommands(resolveCommand, resolveOnlyCommand);
|
|
228
|
-
const
|
|
229
|
-
|
|
242
|
+
const terminalExhausted = exhaustedAttempts.filter((check) => terminalChecks.includes(check));
|
|
243
|
+
const checkSuggestion = terminalExhausted.length > 0
|
|
244
|
+
? `GitHub reports a later workflow attempt (${terminalExhausted
|
|
230
245
|
.map((check) => `${check.runId ?? check.name}: attempt ${check.runAttempt}`)
|
|
231
246
|
.join(", ")}), so Shepherd's single rerun allowance is exhausted. ${needsApproval ? "Use the included evidence to handle the repeated failure manually before resuming." : buildEscalateSuggestion(["check-follow-up-unavailable"], "investigated")}`
|
|
232
247
|
: buildEscalateSuggestion(["check-follow-up-unavailable"], needsApproval ? undefined : "investigated");
|
|
@@ -237,7 +252,7 @@ async function handleTriageTick(ctx) {
|
|
|
237
252
|
changesRequestedReviews,
|
|
238
253
|
...(firstLookSummaries.length > 0 && { firstLookSummaries }),
|
|
239
254
|
...(editedSummaries.length > 0 && { editedSummaries }),
|
|
240
|
-
checks:
|
|
255
|
+
checks: terminalChecks,
|
|
241
256
|
...(pending && { pendingReviewCommands: pending }),
|
|
242
257
|
suggestion: checkSuggestion,
|
|
243
258
|
};
|
|
@@ -252,6 +267,20 @@ async function handleTriageTick(ctx) {
|
|
|
252
267
|
},
|
|
253
268
|
};
|
|
254
269
|
}
|
|
270
|
+
// Failures in a still-running run cannot be rerun yet. Show them once, then wait for the run.
|
|
271
|
+
// Keyed from the classified checks: the agent projection omits `runAttempt` on a first attempt.
|
|
272
|
+
const activeNames = new Set(activeFailures.map((check) => check.name));
|
|
273
|
+
const shownKeys = runFailureKeys(failingChecks.filter((check) => activeNames.has(check.name)));
|
|
274
|
+
if (activeFailures.length > 0 &&
|
|
275
|
+
!hasOtherAutonomousWork &&
|
|
276
|
+
manualFollowUpChecks.length === 0 &&
|
|
277
|
+
// New evidence checks are shown on a TRIAGE tick; once shown, the run's wait covers them too.
|
|
278
|
+
(evidenceChecks.length === 0 || investigated) &&
|
|
279
|
+
!isBehind &&
|
|
280
|
+
!repairInstructions?.length &&
|
|
281
|
+
runFailuresShown(await readShownRunFailures(stallKey), headSha, shownKeys)) {
|
|
282
|
+
return applyStallGuard(stallKey, stallTimeoutSeconds, headSha, base, prNumber, buildRunFailureWait(base, activeFailures), report, reviewSummaryIds, opts.stallDeadlineSink, opts.persistSeen !== false);
|
|
283
|
+
}
|
|
255
284
|
// Push access to the PR head branch is a usage precondition. Build review mutations for
|
|
256
285
|
// conflict ticks normally so the caller can push and complete the same triage cycle.
|
|
257
286
|
const { resolveCommand, resolveOnlyCommand } = buildReviewCommands(failingAgentChecks);
|
|
@@ -318,6 +347,11 @@ async function handleTriageTick(ctx) {
|
|
|
318
347
|
const triageStep = instructions.findIndex((step) => step.startsWith("Triage `## Failing checks`."));
|
|
319
348
|
instructions.splice(triageStep, 1, ...buildCheckFollowUpInstructions(manualFollowUpChecks, report.repo, actionsRunIds));
|
|
320
349
|
}
|
|
350
|
+
if (evidenceChecks.length > 0) {
|
|
351
|
+
const triageStep = instructions.findIndex((step) => step.startsWith("Triage `## Failing checks`."));
|
|
352
|
+
if (triageStep >= 0)
|
|
353
|
+
instructions.splice(triageStep + 1, 0, buildEvidenceFollowUpInstruction());
|
|
354
|
+
}
|
|
321
355
|
if (recovery && "unavailable" in recovery)
|
|
322
356
|
instructions.unshift(recovery.unavailable);
|
|
323
357
|
if (acknowledgmentRecovery && "unavailable" in acknowledgmentRecovery)
|
|
@@ -409,8 +443,11 @@ async function handleTriageTick(ctx) {
|
|
|
409
443
|
const result = await applyStallGuard(stallKey, stallTimeoutSeconds, headSha, base, prNumber, prospectiveResult, report, reviewSummaryIds, undefined, opts.persistSeen !== false);
|
|
410
444
|
if (result.action === "triage" && opts.persistSeen !== false) {
|
|
411
445
|
await writeFixAttempts({ owner: repoOwner, repo: repoName, pr: prNumber }, { headSha, threadAttempts, threadBodyHashes });
|
|
412
|
-
if (investigate)
|
|
446
|
+
if (investigate || evidenceChecks.length > 0)
|
|
413
447
|
await writeCheckFollowUp(stallKey, { headSha, checks: followUpKeys });
|
|
448
|
+
if (activeFailures.length > 0) {
|
|
449
|
+
await writeShownRunFailures(stallKey, { headSha, checks: shownKeys });
|
|
450
|
+
}
|
|
414
451
|
// A queued conflict's annotation fixes are path (a); waiting keeps them unseen.
|
|
415
452
|
if (!queuedConflict)
|
|
416
453
|
await Promise.allSettled(result.triage.checks.flatMap((ch) => (ch.annotations ?? []).map((a) => markSeen(stallKey, a.id, annotationMarkerBody(a)))));
|
|
@@ -15,16 +15,29 @@ interface StateKey {
|
|
|
15
15
|
repo: string;
|
|
16
16
|
pr: number;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Stable identity for a failing check: name, run, attempt, queue commit, and (for a status with no
|
|
20
|
+
* run) its details URL, so a fresh queue execution or result is not mistaken for an old one.
|
|
21
|
+
* Sorted so order never matters.
|
|
22
|
+
*/
|
|
19
23
|
export declare function checkFollowUpKeys(checks: ReadonlyArray<{
|
|
20
24
|
name: string;
|
|
21
25
|
runId: string | null;
|
|
22
26
|
runAttempt?: number;
|
|
27
|
+
commitOid?: string;
|
|
28
|
+
detailsUrl?: string | null;
|
|
23
29
|
}>): string[];
|
|
24
30
|
/** The stored head and check set, or undefined when no usable marker exists. */
|
|
25
31
|
export declare function readCheckFollowUp(key: StateKey): Promise<CheckFollowUpMarker | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* The head and failing checks of a still-running workflow run that were already shown, kept in
|
|
34
|
+
* `run-failures-shown.json`. The next presented tick with the same head and checks waits instead.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readShownRunFailures(key: StateKey): Promise<CheckFollowUpMarker | undefined>;
|
|
26
37
|
/** Remember that the one investigation instruction was returned for this head and check set. */
|
|
27
38
|
export declare function writeCheckFollowUp(key: StateKey, record: CheckFollowUpMarker): Promise<void>;
|
|
39
|
+
/** Remember that these still-running-run failures were shown for this head. */
|
|
40
|
+
export declare function writeShownRunFailures(key: StateKey, record: CheckFollowUpMarker): Promise<void>;
|
|
28
41
|
/** True when the investigation instruction was already returned for this head and check set. */
|
|
29
42
|
export declare function sameCheckFollowUp(record: CheckFollowUpMarker | undefined, headSha: string, checks: readonly string[]): boolean;
|
|
30
43
|
export {};
|
|
@@ -9,14 +9,35 @@
|
|
|
9
9
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
10
10
|
import { dirname } from "node:path";
|
|
11
11
|
import { resolvePrStatePath } from "./base.mjs";
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Stable identity for a failing check: name, run, attempt, queue commit, and (for a status with no
|
|
14
|
+
* run) its details URL, so a fresh queue execution or result is not mistaken for an old one.
|
|
15
|
+
* Sorted so order never matters.
|
|
16
|
+
*/
|
|
13
17
|
export function checkFollowUpKeys(checks) {
|
|
14
|
-
return checks
|
|
18
|
+
return checks
|
|
19
|
+
.map((c) => {
|
|
20
|
+
const base = `${c.name}#${c.runId ?? ""}#${c.runAttempt ?? ""}`;
|
|
21
|
+
const commit = c.commitOid ? `@${c.commitOid}` : "";
|
|
22
|
+
const url = c.runId === null && c.detailsUrl ? `|${c.detailsUrl}` : "";
|
|
23
|
+
return base + commit + url;
|
|
24
|
+
})
|
|
25
|
+
.sort();
|
|
15
26
|
}
|
|
16
27
|
/** The stored head and check set, or undefined when no usable marker exists. */
|
|
17
|
-
export
|
|
28
|
+
export function readCheckFollowUp(key) {
|
|
29
|
+
return readMarker(key, "check-follow-up.json");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The head and failing checks of a still-running workflow run that were already shown, kept in
|
|
33
|
+
* `run-failures-shown.json`. The next presented tick with the same head and checks waits instead.
|
|
34
|
+
*/
|
|
35
|
+
export function readShownRunFailures(key) {
|
|
36
|
+
return readMarker(key, "run-failures-shown.json");
|
|
37
|
+
}
|
|
38
|
+
async function readMarker(key, file) {
|
|
18
39
|
try {
|
|
19
|
-
const parsed = JSON.parse(await readFile(resolvePrStatePath(key,
|
|
40
|
+
const parsed = JSON.parse(await readFile(resolvePrStatePath(key, file), "utf8"));
|
|
20
41
|
if (parsed === null || typeof parsed !== "object")
|
|
21
42
|
return undefined;
|
|
22
43
|
const { headSha, checks } = parsed;
|
|
@@ -31,9 +52,16 @@ export async function readCheckFollowUp(key) {
|
|
|
31
52
|
}
|
|
32
53
|
}
|
|
33
54
|
/** Remember that the one investigation instruction was returned for this head and check set. */
|
|
34
|
-
export
|
|
55
|
+
export function writeCheckFollowUp(key, record) {
|
|
56
|
+
return writeMarker(key, "check-follow-up.json", record);
|
|
57
|
+
}
|
|
58
|
+
/** Remember that these still-running-run failures were shown for this head. */
|
|
59
|
+
export function writeShownRunFailures(key, record) {
|
|
60
|
+
return writeMarker(key, "run-failures-shown.json", record);
|
|
61
|
+
}
|
|
62
|
+
async function writeMarker(key, file, record) {
|
|
35
63
|
try {
|
|
36
|
-
const path = resolvePrStatePath(key,
|
|
64
|
+
const path = resolvePrStatePath(key, file);
|
|
37
65
|
await mkdir(dirname(path), { recursive: true });
|
|
38
66
|
await writeFile(path, JSON.stringify({ headSha: record.headSha, checks: [...record.checks].sort() }));
|
|
39
67
|
}
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"name": "pr-shepherd-plugin",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"pr-shepherd": "2.2.
|
|
10
|
+
"pr-shepherd": "2.2.2"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"node_modules/@hono/node-server": {
|
|
@@ -889,9 +889,9 @@
|
|
|
889
889
|
}
|
|
890
890
|
},
|
|
891
891
|
"node_modules/pr-shepherd": {
|
|
892
|
-
"version": "2.2.
|
|
893
|
-
"resolved": "https://registry.npmjs.org/pr-shepherd/-/pr-shepherd-2.2.
|
|
894
|
-
"integrity": "sha512-
|
|
892
|
+
"version": "2.2.2",
|
|
893
|
+
"resolved": "https://registry.npmjs.org/pr-shepherd/-/pr-shepherd-2.2.2.tgz",
|
|
894
|
+
"integrity": "sha512-1QaWs/sVvnr0IeCUsYQlgraCIM41r3O5WbkBVzoFHPQCy5nwq9mIC/tYL6TyMEQZUFgGgDqBIkInzzzZLNB2pA==",
|
|
895
895
|
"license": "MIT",
|
|
896
896
|
"dependencies": {
|
|
897
897
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Check follow-up
|
|
2
2
|
|
|
3
|
-
Apply when a step says `Playbook: "Check follow-up"`. A check failed, was cancelled, or never started, and Shepherd has no rerun
|
|
3
|
+
Apply when a step says `Playbook: "Check follow-up"`. A check failed, was cancelled, or never started, and Shepherd has no rerun to offer. Start from any excerpt or annotations it printed; without them, find out why before acting. Follow the evidence.
|
|
4
4
|
|
|
5
5
|
- The run: `gh run view <runId> -R <owner/repo>` lists its jobs and annotations, which often say why a job never got a runner; add `--log-failed` for logs.
|
|
6
6
|
- `STARTUP_FAILURE`: workflow syntax, an unresolved reusable workflow or action, missing permissions, secrets or environments.
|