pr-shepherd 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +41 -32
- package/bin/api.d.mts +10 -2
- package/bin/api.mjs +30 -6
- package/bin/checks/pending-deployments.d.mts +10 -0
- package/bin/checks/pending-deployments.mjs +66 -0
- package/bin/checks/run-workflow-paths.d.mts +7 -0
- package/bin/checks/run-workflow-paths.mjs +19 -0
- package/bin/checks/triage.mjs +3 -2
- package/bin/checks/unreported-required.d.mts +11 -1
- package/bin/checks/unreported-required.mjs +8 -3
- package/bin/checks/workflow-concurrency.d.mts +9 -0
- package/bin/checks/workflow-concurrency.mjs +84 -0
- package/bin/checks/workflow-path.d.mts +2 -0
- package/bin/checks/workflow-path.mjs +4 -0
- package/bin/classify/standard/dependency-review-no-issues.d.mts +4 -0
- package/bin/classify/standard/dependency-review-no-issues.mjs +16 -0
- package/bin/classify/standard/index.mjs +8 -0
- package/bin/classify/standard/snyk-no-issues.d.mts +7 -0
- package/bin/classify/standard/snyk-no-issues.mjs +27 -0
- package/bin/classify/standard/socket-reports.d.mts +4 -0
- package/bin/classify/standard/socket-reports.mjs +18 -0
- package/bin/classify/standard/sonarqube-gate-passed.d.mts +7 -0
- package/bin/classify/standard/sonarqube-gate-passed.mjs +41 -0
- package/bin/cli/arg-flags.mjs +3 -0
- package/bin/cli/clean-handler.mjs +1 -1
- package/bin/cli/default-poll.mjs +1 -0
- package/bin/cli/handlers.mjs +2 -0
- package/bin/cli/help-command-pages.d.mts +5 -4
- package/bin/cli/help-command-pages.mjs +2 -1
- package/bin/cli/help-iterate-poll-pages.d.mts +3 -3
- package/bin/cli/help-iterate-poll-pages.mjs +10 -2
- package/bin/cli/help-top-page.d.mts +1 -1
- package/bin/cli/help-top-page.mjs +2 -2
- package/bin/cli/help.d.mts +6 -5
- package/bin/cli/in-progress-run-format.d.mts +3 -0
- package/bin/cli/in-progress-run-format.mjs +14 -0
- package/bin/cli/iterate-activity-formatter.d.mts +2 -0
- package/bin/cli/iterate-activity-formatter.mjs +11 -0
- package/bin/cli/iterate-flags.d.mts +3 -0
- package/bin/cli/iterate-flags.mjs +18 -1
- package/bin/cli/iterate-formatter.mjs +2 -1
- package/bin/cli/iterate-lean.mjs +2 -0
- package/bin/cli/pending-deployments-format.d.mts +5 -0
- package/bin/cli/pending-deployments-format.mjs +19 -0
- package/bin/cli/poll-handler.d.mts +1 -1
- package/bin/cli/poll-handler.mjs +33 -10
- package/bin/cli/poll-targets.mjs +2 -0
- package/bin/cli/stack-merge-args.d.mts +10 -0
- package/bin/cli/stack-merge-args.mjs +27 -0
- package/bin/cli/stack-overview.d.mts +1 -0
- package/bin/cli/stack-overview.mjs +5 -1
- package/bin/cli/stalled-check-format.d.mts +3 -0
- package/bin/cli/stalled-check-format.mjs +23 -0
- package/bin/cli/suggestion-renderer.mjs +6 -0
- package/bin/cli/triage-formatter.mjs +14 -0
- package/bin/commands/check.mjs +7 -2
- package/bin/commands/clean.d.mts +1 -1
- package/bin/commands/clean.mjs +7 -0
- package/bin/commands/iterate/check-follow-up.d.mts +9 -0
- package/bin/commands/iterate/check-follow-up.mjs +34 -0
- package/bin/commands/iterate/ci-start-stall.d.mts +23 -0
- package/bin/commands/iterate/ci-start-stall.mjs +33 -0
- package/bin/commands/iterate/duration-approx.d.mts +2 -0
- package/bin/commands/iterate/duration-approx.mjs +8 -0
- package/bin/commands/iterate/escalate.d.mts +8 -17
- package/bin/commands/iterate/escalate.mjs +19 -48
- package/bin/commands/iterate/helpers.mjs +1 -0
- package/bin/commands/iterate/in-progress-runs.d.mts +10 -0
- package/bin/commands/iterate/in-progress-runs.mjs +120 -0
- package/bin/commands/iterate/index.mjs +12 -6
- package/bin/commands/iterate/merge-plan.d.mts +2 -0
- package/bin/commands/iterate/merge-plan.mjs +2 -1
- package/bin/commands/iterate/merge-state.d.mts +2 -0
- package/bin/commands/iterate/merge-state.mjs +8 -21
- package/bin/commands/iterate/native-stack-rebase.d.mts +3 -2
- package/bin/commands/iterate/native-stack-rebase.mjs +32 -11
- package/bin/commands/iterate/queue-removal.d.mts +19 -0
- package/bin/commands/iterate/queue-removal.mjs +64 -0
- package/bin/commands/iterate/render.d.mts +2 -1
- package/bin/commands/iterate/render.mjs +4 -1
- package/bin/commands/iterate/stack-boundary.d.mts +17 -0
- package/bin/commands/iterate/stack-boundary.mjs +95 -0
- package/bin/commands/iterate/stall-repair.d.mts +17 -0
- package/bin/commands/iterate/stall-repair.mjs +25 -0
- package/bin/commands/iterate/stall.d.mts +1 -1
- package/bin/commands/iterate/stall.mjs +27 -18
- package/bin/commands/iterate/state-unavailable.d.mts +8 -0
- package/bin/commands/iterate/state-unavailable.mjs +23 -0
- package/bin/commands/iterate/triage-loop-instruction.mjs +1 -1
- package/bin/commands/iterate/triage.mjs +41 -74
- package/bin/commands/iterate/unreported-required.d.mts +5 -2
- package/bin/commands/iterate/unreported-required.mjs +13 -8
- package/bin/commands/iterate/workflow-files.d.mts +27 -0
- package/bin/commands/iterate/workflow-files.mjs +85 -0
- package/bin/commands/poll-summary-explicit-instructions.mjs +15 -1
- package/bin/commands/poll-summary-instructions.d.mts +4 -3
- package/bin/commands/poll-summary-instructions.mjs +60 -22
- package/bin/commands/poll-summary.mjs +38 -10
- package/bin/commands/poll.mjs +4 -2
- package/bin/commands/stack-drain.d.mts +4 -4
- package/bin/commands/stack-drain.mjs +19 -113
- package/bin/commands/stack-handoffs.d.mts +3 -3
- package/bin/commands/stack-handoffs.mjs +8 -8
- package/bin/commands/stack-lower-ready-note.d.mts +6 -0
- package/bin/commands/stack-lower-ready-note.mjs +35 -0
- package/bin/commands/stack-merge-escalations.d.mts +17 -0
- package/bin/commands/stack-merge-escalations.mjs +57 -0
- package/bin/commands/stack-merge-plan.d.mts +10 -0
- package/bin/commands/stack-merge-plan.mjs +132 -0
- package/bin/commands/stack-merge-scope.d.mts +42 -0
- package/bin/commands/stack-merge-scope.mjs +113 -0
- package/bin/commands/stack-ownership.d.mts +25 -0
- package/bin/commands/stack-ownership.mjs +85 -0
- package/bin/commands/stack-stall.d.mts +2 -0
- package/bin/commands/stack-stall.mjs +25 -3
- package/bin/commands/stack-targets-error.d.mts +16 -0
- package/bin/commands/stack-targets-error.mjs +44 -0
- package/bin/commands/stack-targets.d.mts +30 -0
- package/bin/commands/stack-targets.mjs +121 -0
- package/bin/commands/stack-work.d.mts +4 -3
- package/bin/commands/stack-work.mjs +7 -4
- package/bin/commands/tick.mjs +14 -2
- package/bin/config/renames.mjs +1 -1
- package/bin/config/schema.d.mts +4 -0
- package/bin/config/schema.mjs +2 -0
- package/bin/github/batch-parse-suites.d.mts +4 -1
- package/bin/github/batch-parse-suites.mjs +15 -3
- package/bin/github/batch-raw-types.d.mts +6 -0
- package/bin/github/gql/commit-check-suites.gql +6 -0
- package/bin/github/gql/poll-summary-fragment.gql +6 -0
- package/bin/github/poll-summary-command.d.mts +15 -1
- package/bin/github/poll-summary-command.mjs +39 -3
- package/bin/github/poll-summary-projector.d.mts +1 -1
- package/bin/github/poll-summary-projector.mjs +1 -4
- package/bin/github/poll-summary-raw.d.mts +6 -0
- package/bin/github/poll-summary-route.mjs +4 -1
- package/bin/github/poll-summary.mjs +10 -3
- package/bin/github/rest-batch-read.mjs +17 -6
- package/bin/github/rest-batch-snapshot.d.mts +2 -2
- package/bin/github/rest-batch-snapshot.mjs +3 -0
- package/bin/github/rest-check-read.d.mts +1 -18
- package/bin/github/rest-check-read.mjs +1 -2
- package/bin/github/rest-stack-read.d.mts +9 -0
- package/bin/github/rest-stack-read.mjs +40 -0
- package/bin/github/rest-suite-types.d.mts +23 -0
- package/bin/github/rest-suite-types.mjs +1 -0
- package/bin/github/rest-summary-read.mjs +2 -0
- package/bin/mcp/server.mjs +29 -3
- package/bin/pr-reference.d.mts +2 -0
- package/bin/pr-reference.mjs +1 -1
- package/bin/reporters/agent.mjs +3 -0
- package/bin/state/check-follow-up.d.mts +30 -0
- package/bin/state/check-follow-up.mjs +51 -0
- package/bin/state/ci-start-follow-up.d.mts +14 -0
- package/bin/state/ci-start-follow-up.mjs +21 -0
- package/bin/state/queue-removal-follow-up.d.mts +20 -0
- package/bin/state/queue-removal-follow-up.mjs +23 -0
- package/bin/state/signature-marker.d.mts +10 -0
- package/bin/state/signature-marker.mjs +28 -0
- package/bin/state/stack-merge-approval.d.mts +26 -0
- package/bin/state/stack-merge-approval.mjs +39 -0
- package/bin/state/stall-repair.d.mts +16 -0
- package/bin/state/stall-repair.mjs +47 -0
- package/bin/types/activity.d.mts +2 -1
- package/bin/types/escalate.d.mts +9 -2
- package/bin/types/github.d.mts +18 -0
- package/bin/types/in-progress-run.d.mts +20 -0
- package/bin/types/in-progress-run.mjs +1 -0
- package/bin/types/iterate.d.mts +22 -1
- package/bin/types/poll-summary.d.mts +18 -1
- package/bin/types/report.d.mts +5 -1
- package/bin/types.d.mts +1 -0
- package/bin/types.mjs +1 -0
- package/package.json +2 -2
- 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/hooks/poll-guard-args.mjs +49 -0
- package/plugins/pr-shepherd/hooks/poll-guard-detect.mjs +134 -26
- package/plugins/pr-shepherd/hooks/poll-guard-shell.mjs +192 -0
- package/plugins/pr-shepherd/package-lock.json +7 -7
- package/plugins/pr-shepherd/package.json +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/SKILL.md +8 -7
- package/plugins/pr-shepherd/skills/pr-shepherd/references/check-follow-up.md +14 -0
- package/plugins/pr-shepherd/skills/pr-shepherd/references/ci-failure-triage.md +6 -5
- package/plugins/pr-shepherd/skills/pr-shepherd/references/ci-start-stall.md +15 -0
- package/plugins/pr-shepherd/skills/pr-shepherd/references/create-a-pr.md +4 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/references/mcp-fallback.md +1 -1
- package/plugins/pr-shepherd/skills/pr-shepherd/references/merge-queue-ejection.md +6 -5
- package/plugins/pr-shepherd/skills/pr-shepherd/references/required-checks-unreported.md +16 -0
- package/plugins/pr-shepherd/skills/reduce-pr-noise/references/classifiers.md +1 -1
- package/pr-shepherd.schema.json +15 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# pr-shepherd
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
**
|
|
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
|
|
47
|
-
| ----------------------------------------------------------------------- |
|
|
48
|
-
| [Context and correctness](#context-and-correctness) |
|
|
49
|
-
| [Fewer tokens, lower cost](#fewer-tokens-and-lower-cost) |
|
|
50
|
-
| [Clearer agent direction](#clearer-agent-direction) | Across
|
|
51
|
-
| [Lower GitHub API quota use](#lower-github-api-quota-use) |
|
|
52
|
-
| [Safe by construction](#safe-by-construction) | 0 git mutations; human handoff limited to
|
|
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
|
|
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,14 +67,14 @@ 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-
|
|
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
|
-
| PR state
|
|
73
|
-
|
|
|
74
|
-
| A maintainer removed the PR from the merge queue: don't requeue or merge
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
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
78
|
|
|
79
79
|
### Fewer tokens and lower cost
|
|
80
80
|
|
|
@@ -82,13 +82,16 @@ 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 | **−
|
|
86
|
-
| PR stack | **−
|
|
85
|
+
| Single PR | **−36%** | **−76%** |
|
|
86
|
+
| PR stack | **−40%** | **−60%** |
|
|
87
87
|
|
|
88
|
-
These are
|
|
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
|
-
|
|
91
|
-
|
|
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)).
|
|
92
95
|
|
|
93
96
|
[docs/token-counts.md](docs/token-counts.md) counts the skill and per-tick text.
|
|
94
97
|
|
|
@@ -96,7 +99,7 @@ These are offline estimates at 3.5 characters per token over recorded sessions,
|
|
|
96
99
|
|
|
97
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.
|
|
98
101
|
|
|
99
|
-
In the [outcome evals](evals/README.md) (Sonnet 5.5,
|
|
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).
|
|
100
103
|
|
|
101
104
|
### Lower GitHub API quota use
|
|
102
105
|
|
|
@@ -105,10 +108,10 @@ GitHub meters two tiers ([details](docs/github-api.md#github-metering)):
|
|
|
105
108
|
- Primary hourly budgets: GraphQL points and REST `core` requests.
|
|
106
109
|
- Secondary limits: per-minute points (a GraphQL query or REST `GET` costs 1, a mutation 5), plus concurrency and content-creation limits.
|
|
107
110
|
|
|
108
|
-
Waiting is where most quota goes.
|
|
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:
|
|
109
112
|
|
|
110
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.
|
|
111
|
-
- While CI runs, that is about 60 points an hour for a typical PR.
|
|
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)).
|
|
112
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)).
|
|
113
116
|
|
|
114
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,23 +121,23 @@ Two optional setups take most of the remaining spend off your token. They are in
|
|
|
118
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)).
|
|
119
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.
|
|
120
123
|
|
|
121
|
-
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:
|
|
122
125
|
|
|
123
126
|
| Session | GraphQL points: Shepherd / `gh` / MCP | REST core: Shepherd / `gh` / MCP |
|
|
124
127
|
| --------- | ------------------------------------: | -------------------------------: |
|
|
125
|
-
| Single PR | 33.3 /
|
|
128
|
+
| Single PR | 33.3 / 96.2 / 11.4 | 3.8 / 15 / 82 |
|
|
126
129
|
| PR stack | 11 / 27 / 12 | 2 / 6 / 74 |
|
|
127
130
|
|
|
128
|
-
- On the default GraphQL transport, Shepherd spends fewer GraphQL points than `gh` and fewer REST requests than `gh` or MCP.
|
|
129
|
-
- On a single PR, MCP spends fewer GraphQL points but about
|
|
130
|
-
- The REST transport used in cloud sessions spends no GraphQL points. It spends more `core` 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
|
+
- 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).
|
|
131
134
|
|
|
132
135
|
See [docs/graphql-usage.md](docs/graphql-usage.md) and [docs/rest-usage.md](docs/rest-usage.md).
|
|
133
136
|
|
|
134
137
|
### Safe by construction
|
|
135
138
|
|
|
136
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)).
|
|
137
|
-
- 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.
|
|
138
141
|
- Human handoff is a [finite escalation list](docs/escalations.md).
|
|
139
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.
|
|
140
143
|
- A denied reply or resolve is a one-look skip, not a retry loop.
|
|
@@ -196,6 +199,12 @@ Requirements:
|
|
|
196
199
|
|
|
197
200
|
## Quick start
|
|
198
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
|
+
|
|
199
208
|
```text
|
|
200
209
|
/goal /pr-shepherd:pr-shepherd 42 # Claude Code
|
|
201
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
|
-
/**
|
|
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
|
-
|
|
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.
|
|
76
|
-
throw new PrShepherdValidationError("stack requires
|
|
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 {
|
|
79
|
-
const
|
|
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
|
-
|
|
83
|
-
|
|
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
|
+
}
|
package/bin/checks/triage.mjs
CHANGED
|
@@ -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
|
|
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
|
-
...(
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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,16 @@
|
|
|
1
|
+
import { isBotItem } from "./author.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* actions/dependency-review-action's comment when it found nothing: the pass line, an optional
|
|
4
|
+
* OpenSSF Scorecard table, and the scanned-file list. Any other section (snapshot warnings, denied
|
|
5
|
+
* or deprecated packages) or a failure summary keeps it visible.
|
|
6
|
+
*/
|
|
7
|
+
const PASSED = /^<h1>Dependency Review<\/h1>\n✅ No vulnerabilities or license issues(?: or OpenSSF Scorecard issues)? found\.(?:<h2>OpenSSF Scorecard<\/h2>\n<table>(?:(?!<h[12]>)[\s\S])*?<\/table>)?<h2>Scanned Files<\/h2>\n(?:None|<ul>(?:<li>[^<\n]*<\/li>)*<\/ul>)\n*<!-- dependency-review-pr-comment-marker -->$/;
|
|
8
|
+
/** The dependency-review action's no-issues comment, posted as the Actions bot. */
|
|
9
|
+
const rule = (item) => {
|
|
10
|
+
if (!isBotItem(item, ["github-actions"], ["pr-comment"]))
|
|
11
|
+
return null;
|
|
12
|
+
if (!PASSED.test(item.body.trim()))
|
|
13
|
+
return null;
|
|
14
|
+
return { autoResolve: true, suppress: true, reason: "Dependency Review no-issues comment" };
|
|
15
|
+
};
|
|
16
|
+
export default rule;
|
|
@@ -2,8 +2,12 @@ import coderabbitNotices from "./coderabbit-notices.mjs";
|
|
|
2
2
|
import codecovReport from "./codecov-report.mjs";
|
|
3
3
|
import codexNotices from "./codex-notices.mjs";
|
|
4
4
|
import dependabotNotices from "./dependabot-notices.mjs";
|
|
5
|
+
import dependencyReviewNoIssues from "./dependency-review-no-issues.mjs";
|
|
5
6
|
import geminiNotices from "./gemini-notices.mjs";
|
|
6
7
|
import kiloNoIssues from "./kilo-no-issues.mjs";
|
|
8
|
+
import snykNoIssues from "./snyk-no-issues.mjs";
|
|
9
|
+
import socketReports from "./socket-reports.mjs";
|
|
10
|
+
import sonarqubeGatePassed from "./sonarqube-gate-passed.mjs";
|
|
7
11
|
import sourceryNotices from "./sourcery-notices.mjs";
|
|
8
12
|
/**
|
|
9
13
|
* Bundled classification rules that `classify.standard` can enable by name.
|
|
@@ -14,8 +18,12 @@ export const STANDARD_RULES = {
|
|
|
14
18
|
"codecov-report": codecovReport,
|
|
15
19
|
"codex-notices": codexNotices,
|
|
16
20
|
"dependabot-notices": dependabotNotices,
|
|
21
|
+
"dependency-review-no-issues": dependencyReviewNoIssues,
|
|
17
22
|
"gemini-notices": geminiNotices,
|
|
18
23
|
"kilo-no-issues": kiloNoIssues,
|
|
24
|
+
"snyk-no-issues": snykNoIssues,
|
|
25
|
+
"socket-reports": socketReports,
|
|
26
|
+
"sonarqube-gate-passed": sonarqubeGatePassed,
|
|
19
27
|
"sourcery-notices": sourceryNotices,
|
|
20
28
|
};
|
|
21
29
|
export const STANDARD_RULE_NAMES = Object.keys(STANDARD_RULES);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ClassifyRule } from "../types.mts";
|
|
2
|
+
/**
|
|
3
|
+
* Snyk's PR-check summary when every scan passed with zero issues. Any other header, a row with a
|
|
4
|
+
* non-zero count, or a line outside the table and the IDE-plugin footer keeps it visible.
|
|
5
|
+
*/
|
|
6
|
+
declare const rule: ClassifyRule;
|
|
7
|
+
export default rule;
|