pr-shepherd 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +7 -1
- package/bin/cli/display-body.d.mts +8 -0
- package/bin/cli/display-body.mjs +157 -0
- package/bin/cli/list-formatters.mjs +4 -2
- 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/SKILL.md +1 -0
package/README.md
CHANGED
|
@@ -113,6 +113,11 @@ Waiting is where most quota goes, and where Shepherd saves the most. By default
|
|
|
113
113
|
|
|
114
114
|
Fewer requests help on both tiers. The GitHub MCP server issues one or more REST requests per tool call, so unbatched calls drain `core` and the per-minute pool faster.
|
|
115
115
|
|
|
116
|
+
Two optional setups take most of the remaining spend off your token. They are independent and combine:
|
|
117
|
+
|
|
118
|
+
- **[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, except that 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
|
+
- **[hook-harness events](docs/hook-harness.md):** a poll waits for a GitHub webhook event about the PR instead of sleeping a fixed interval. 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, but never sooner than `poll.interval-seconds` after the previous tick began, so up to about a minute at the default interval. Events never make ticks more frequent than plain polling.
|
|
120
|
+
|
|
116
121
|
Per session, assumed and deterministic, from the [token bench](evals/tokens/README.md):
|
|
117
122
|
|
|
118
123
|
| Session | GraphQL points: Shepherd / `gh` / MCP | REST core: Shepherd / `gh` / MCP |
|
|
@@ -211,6 +216,7 @@ Leave out the PR number to use the current branch.
|
|
|
211
216
|
| Features, workflow assumptions, limits | [docs/features.md](docs/features.md) |
|
|
212
217
|
| Commands, flags, stacks, polling | [docs/cli-usage.md](docs/cli-usage.md) |
|
|
213
218
|
| GitHub App auth (separate rate limit) | [docs/github-app.md](docs/github-app.md) |
|
|
219
|
+
| Event-driven waits (hook-harness) | [docs/hook-harness.md](docs/hook-harness.md) |
|
|
214
220
|
| Actions and exit codes | [docs/actions.md](docs/actions.md), [docs/exit-codes.md](docs/exit-codes.md) |
|
|
215
221
|
| Configuration and classification rules | [docs/configuration.md](docs/configuration.md), [examples/classification/](examples/classification/) |
|
|
216
222
|
| Journal, library API | [docs/api.md](docs/api.md) |
|
|
@@ -219,7 +225,7 @@ Leave out the PR number to use the current branch.
|
|
|
219
225
|
|
|
220
226
|
## Harness ecosystem
|
|
221
227
|
|
|
222
|
-
- [
|
|
228
|
+
- [hook-harness](https://github.com/jonathanong/hook-harness): GitHub webhook relay that agents poll for events instead of polling GitHub
|
|
223
229
|
- [agent-blackboard](https://github.com/jonathanong/agent-blackboard): session-scoped telemetry for autonomous agents
|
|
224
230
|
- [pr-shepherd](https://github.com/jonathanong/pr-shepherd): autonomous pull request shepherd
|
|
225
231
|
- [no-mistakes](https://github.com/jonathanong/no-mistakes): deterministic AST-based codebase intelligence, test selection, and linting for agents
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The visible text of a GitHub Markdown body, for Markdown output: closed HTML comments,
|
|
3
|
+
* `<picture>` image wrappers, and links left empty by them are dropped, because GitHub does not
|
|
4
|
+
* display them. Fenced and indented code and inline code spans are kept verbatim. Blank runs
|
|
5
|
+
* collapse to one; a body with no visible text is returned unchanged. JSON and `--verbose` keep
|
|
6
|
+
* the raw body.
|
|
7
|
+
*/
|
|
8
|
+
export declare function displayBody(body: string): string;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const COMMENT_OPEN = "<!--";
|
|
2
|
+
const COMMENT_CLOSE = "-->";
|
|
3
|
+
const PICTURE_RE = /<picture>[\s\S]*?<\/picture>/g;
|
|
4
|
+
const IMG_RE = /<img\s[^>]*>/;
|
|
5
|
+
// A link left with no visible content after the pictures inside it are dropped.
|
|
6
|
+
const EMPTY_ANCHOR_RE = /<a\s[^>]*>\s*<\/a>/g;
|
|
7
|
+
function fenceMarker(line) {
|
|
8
|
+
const match = /^ {0,3}(`{3,}|~{3,})/.exec(line);
|
|
9
|
+
return match ? match[1] : null;
|
|
10
|
+
}
|
|
11
|
+
function closesFence(line, fence) {
|
|
12
|
+
const trimmed = line.trim();
|
|
13
|
+
return trimmed.length >= fence.length && [...trimmed].every((c) => c === fence[0]);
|
|
14
|
+
}
|
|
15
|
+
const isIndented = (line) => /^(?: {4}|\t)/.test(line);
|
|
16
|
+
// Blockquote and list markers are containers: code inside a quote or list item is still code.
|
|
17
|
+
const containerContent = (line) => line.replace(/^(?: {0,3}(?:> ?|(?:[-*+]|\d{1,9}[.)])(?: |$)))+/, "");
|
|
18
|
+
const attribute = (tag, name) => new RegExp(`\\s${name}="([^"]*)"`).exec(tag)?.[1];
|
|
19
|
+
/**
|
|
20
|
+
* A `<picture>` as Markdown image text. An image whose `alt` is explicitly empty is decorative
|
|
21
|
+
* (CodeRabbit's severity icons) and is dropped; any other keeps its alt text and source.
|
|
22
|
+
*/
|
|
23
|
+
function pictureText(picture) {
|
|
24
|
+
const img = IMG_RE.exec(picture)?.[0];
|
|
25
|
+
if (img === undefined)
|
|
26
|
+
return "";
|
|
27
|
+
const alt = attribute(img, "alt");
|
|
28
|
+
if (alt === "")
|
|
29
|
+
return "";
|
|
30
|
+
const src = attribute(img, "src");
|
|
31
|
+
return src === undefined ? (alt ?? "") : ``;
|
|
32
|
+
}
|
|
33
|
+
const isBlank = (line) => line.trim() === "";
|
|
34
|
+
/**
|
|
35
|
+
* Marks lines GitHub renders as code: fenced blocks and indented blocks (which start after a
|
|
36
|
+
* blank line and continue through indented or blank lines).
|
|
37
|
+
*/
|
|
38
|
+
function codeLines(lines) {
|
|
39
|
+
const code = [];
|
|
40
|
+
let fence = null;
|
|
41
|
+
let indented = false;
|
|
42
|
+
const content = lines.map(containerContent);
|
|
43
|
+
for (let i = 0; i < content.length; i++) {
|
|
44
|
+
const line = content[i];
|
|
45
|
+
if (fence) {
|
|
46
|
+
code.push(true);
|
|
47
|
+
if (closesFence(line, fence))
|
|
48
|
+
fence = null;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
fence = fenceMarker(line);
|
|
52
|
+
// A blank line ends `indented`, but the next indented line restarts it (blank line before).
|
|
53
|
+
indented = isIndented(line) && (indented || i === 0 || isBlank(content[i - 1]));
|
|
54
|
+
code.push(fence !== null || (indented && !isBlank(line)));
|
|
55
|
+
}
|
|
56
|
+
return code;
|
|
57
|
+
}
|
|
58
|
+
/** Index just past the inline code span opening at `i`, or -1 when its backticks never close. */
|
|
59
|
+
function codeSpanEnd(text, i) {
|
|
60
|
+
let n = 0;
|
|
61
|
+
while (text[i + n] === "`")
|
|
62
|
+
n++;
|
|
63
|
+
const run = "`".repeat(n);
|
|
64
|
+
let at = text.indexOf(run, i + n);
|
|
65
|
+
while (at !== -1) {
|
|
66
|
+
let len = 0;
|
|
67
|
+
while (text[at + len] === "`")
|
|
68
|
+
len++;
|
|
69
|
+
if (len === n)
|
|
70
|
+
return at + n;
|
|
71
|
+
at = text.indexOf(run, at + len);
|
|
72
|
+
}
|
|
73
|
+
return -1;
|
|
74
|
+
}
|
|
75
|
+
const dropImageMarkup = (text) => text.replace(PICTURE_RE, pictureText).replace(EMPTY_ANCHOR_RE, "");
|
|
76
|
+
/**
|
|
77
|
+
* Removes closed `<!-- … -->` comments, `<picture>` wrappers, and links left empty, all outside
|
|
78
|
+
* inline code spans; unclosed comment openers stay literal.
|
|
79
|
+
*/
|
|
80
|
+
function stripHiddenMarkup(text) {
|
|
81
|
+
let out = "";
|
|
82
|
+
let plain = "";
|
|
83
|
+
let i = 0;
|
|
84
|
+
while (i < text.length) {
|
|
85
|
+
if (text[i] === "`") {
|
|
86
|
+
let n = 0;
|
|
87
|
+
while (text[i + n] === "`")
|
|
88
|
+
n++;
|
|
89
|
+
const end = codeSpanEnd(text, i);
|
|
90
|
+
const next = end === -1 ? i + n : end;
|
|
91
|
+
if (end === -1) {
|
|
92
|
+
plain += text.slice(i, next);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
out += dropImageMarkup(plain) + text.slice(i, next);
|
|
96
|
+
plain = "";
|
|
97
|
+
}
|
|
98
|
+
i = next;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (text.startsWith(COMMENT_OPEN, i)) {
|
|
102
|
+
const close = text.indexOf(COMMENT_CLOSE, i + COMMENT_OPEN.length);
|
|
103
|
+
if (close !== -1) {
|
|
104
|
+
i = close + COMMENT_CLOSE.length;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
plain += text[i];
|
|
109
|
+
i++;
|
|
110
|
+
}
|
|
111
|
+
return out + dropImageMarkup(plain);
|
|
112
|
+
}
|
|
113
|
+
/** Strips one run of non-code lines and returns its lines. */
|
|
114
|
+
function visibleLines(run) {
|
|
115
|
+
return stripHiddenMarkup(run.join("\n"))
|
|
116
|
+
.split("\n")
|
|
117
|
+
.map((line) => line.trimEnd());
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The visible text of a GitHub Markdown body, for Markdown output: closed HTML comments,
|
|
121
|
+
* `<picture>` image wrappers, and links left empty by them are dropped, because GitHub does not
|
|
122
|
+
* display them. Fenced and indented code and inline code spans are kept verbatim. Blank runs
|
|
123
|
+
* collapse to one; a body with no visible text is returned unchanged. JSON and `--verbose` keep
|
|
124
|
+
* the raw body.
|
|
125
|
+
*/
|
|
126
|
+
export function displayBody(body) {
|
|
127
|
+
const lines = body.replace(/\r\n?/g, "\n").split("\n");
|
|
128
|
+
const code = codeLines(lines);
|
|
129
|
+
const out = [];
|
|
130
|
+
const push = (line) => {
|
|
131
|
+
if (isBlank(line) && (out.length === 0 || isBlank(out[out.length - 1])))
|
|
132
|
+
return;
|
|
133
|
+
out.push(line);
|
|
134
|
+
};
|
|
135
|
+
let run = [];
|
|
136
|
+
const flush = () => {
|
|
137
|
+
if (run.length === 0)
|
|
138
|
+
return;
|
|
139
|
+
for (const line of visibleLines(run))
|
|
140
|
+
push(line);
|
|
141
|
+
run = [];
|
|
142
|
+
};
|
|
143
|
+
lines.forEach((line, i) => {
|
|
144
|
+
if (code[i]) {
|
|
145
|
+
flush();
|
|
146
|
+
out.push(line);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
run.push(line);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
flush();
|
|
153
|
+
while (out.length > 0 && isBlank(out[out.length - 1]))
|
|
154
|
+
out.pop();
|
|
155
|
+
// A body with no visible text (only comments) stays raw rather than rendering as nothing.
|
|
156
|
+
return out.length > 0 ? out.join("\n") : body;
|
|
157
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { renderLineRange, renderSuggestionBlock } from "./suggestion-renderer.mjs";
|
|
2
2
|
import { threadComments } from "../threads/transcript.mjs";
|
|
3
3
|
import { truncateBody, BODY_TRUNCATE_MAX_CHARS, NESTED_BODY_TRUNCATE_MAX_CHARS, } from "./body-truncate.mjs";
|
|
4
|
+
import { displayBody } from "./display-body.mjs";
|
|
4
5
|
const BODY_PREVIEW_MAX = 100;
|
|
5
6
|
export function renderAuthor(author, authorType, authorAssociation, viewerDidAuthor) {
|
|
6
7
|
// `User` is the default author type; only `Bot` and `Unknown` are worth a label.
|
|
@@ -10,7 +11,7 @@ export function renderAuthor(author, authorType, authorAssociation, viewerDidAut
|
|
|
10
11
|
.join(" · ");
|
|
11
12
|
}
|
|
12
13
|
export function renderBodyPreview(body) {
|
|
13
|
-
const normalizedBody = body
|
|
14
|
+
const normalizedBody = displayBody(body);
|
|
14
15
|
const firstLine = normalizedBody.split("\n")[0]?.trim() ?? "";
|
|
15
16
|
return firstLine.slice(0, BODY_PREVIEW_MAX);
|
|
16
17
|
}
|
|
@@ -69,7 +70,8 @@ export function renderThreadConversation(t, verbose = false) {
|
|
|
69
70
|
.join("\n\n");
|
|
70
71
|
}
|
|
71
72
|
export function blockquote(body, maxChars, url) {
|
|
72
|
-
|
|
73
|
+
// Capped review bodies show only GitHub-visible text; uncapped (`--verbose`, annotations) stay raw.
|
|
74
|
+
const text = maxChars === undefined ? body : truncateBody(displayBody(body), maxChars, url);
|
|
73
75
|
return text
|
|
74
76
|
.replace(/\r\n/g, "\n")
|
|
75
77
|
.split("\n")
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"name": "pr-shepherd-plugin",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"pr-shepherd": "1.
|
|
10
|
+
"pr-shepherd": "1.6.0"
|
|
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": "1.
|
|
893
|
-
"resolved": "https://registry.npmjs.org/pr-shepherd/-/pr-shepherd-1.
|
|
894
|
-
"integrity": "sha512-
|
|
892
|
+
"version": "1.6.0",
|
|
893
|
+
"resolved": "https://registry.npmjs.org/pr-shepherd/-/pr-shepherd-1.6.0.tgz",
|
|
894
|
+
"integrity": "sha512-a9ezqE7mFrXXrYwgvWPBRhaaetQxEGXkgFqgLzL44QWZPzuPvzrmwwGaHYv5jZscdpuv8jIrXmVgSJh/Q4VbrA==",
|
|
895
895
|
"license": "MIT",
|
|
896
896
|
"dependencies": {
|
|
897
897
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
@@ -25,6 +25,7 @@ allowed-tools: mcp__plugin_pr-shepherd_pr-shepherd, Bash(npx pr-shepherd:*), Bas
|
|
|
25
25
|
- `[TRIAGE]` is always non-terminal: decide each item yourself, fixing or rejecting it with a reason, without asking. Only `[ESCALATE]` hands work to a human. `[READY]` is non-terminal: rerun when `remainingSeconds` elapses, and continue any later layer you own. A parent of several stacks delegates the wait to its worker.
|
|
26
26
|
- After a push or `rerun:`, do not wait for CI to finish; fetching check logs is fine.
|
|
27
27
|
- Shepherd is the only poller. Never write a loop, watcher, or background job around `gh`, `gh api`, `curl`, `sleep`, or `pr-shepherd` (except a backgrounded `--until-terminal`), and never poll with `gh pr checks`, `gh pr watch`, `gh run watch`, or MCP waiters. `--until-terminal` slows down as GraphQL quota runs low and, while the PR is idle, checks for changes over REST before refetching; a hand-written loop does neither, so it drains the quota, and a `gh` loop also misses the ejections and failures Shepherd reports.
|
|
28
|
+
- Never pipe Shepherd through `head`, `tail`, `grep`, `cut` or `tee`, and read every line, even from a file: `## Instructions` is last, the exit code is the action, and review bodies show once.
|
|
28
29
|
- If Shepherd cannot do what was asked, tell the user what is missing instead of building a substitute.
|
|
29
30
|
|
|
30
31
|
### Untrusted review input
|