@jagreehal/shepherd 0.12.1 → 0.13.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/package.json +1 -1
- package/skills/shepherd/SKILL.md +3 -1
- package/skills/swarm/SKILL.md +7 -3
- package/skills/swarm/references/formats.md +2 -1
- package/src/cli.ts +4 -1
- package/src/summary.ts +110 -38
- package/templates/shepherd.yml +26 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jagreehal/shepherd",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Agent skills that drive a PR to merge-ready: a review swarm, thread triage, CI repair, and a loop that hands the result to stamp.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:jagreehal/shepherd",
|
package/skills/shepherd/SKILL.md
CHANGED
|
@@ -126,7 +126,9 @@ model pushes what you hand it. An iteration then differs in six places:
|
|
|
126
126
|
each job id ci-repair wants rerun on its own line in
|
|
127
127
|
`$SHEPHERD_HANDOFF/rerun-jobs.txt`. The publish job pushes your commits,
|
|
128
128
|
sets the status on the head it pushed (`pending` whenever it pushed: those
|
|
129
|
-
commits are not reviewed yet
|
|
129
|
+
commits are not reviewed yet; with nothing pushed or rerun, `failure` in
|
|
130
|
+
place of `pending` when the round has findings above NIT), reruns the jobs,
|
|
131
|
+
and notifies. It refuses a
|
|
130
132
|
push that is not a fast-forward of `H0` or that touches a protected path
|
|
131
133
|
(workflows, hooks, package manager config, manifests, lockfiles), and sets
|
|
132
134
|
`failure` naming why.
|
package/skills/swarm/SKILL.md
CHANGED
|
@@ -480,8 +480,9 @@ then check it before you stop:
|
|
|
480
480
|
shepherd summary "$SHEPHERD_HANDOFF/round.json" --body > /dev/null
|
|
481
481
|
```
|
|
482
482
|
|
|
483
|
-
It prints every field the renderer rejects
|
|
484
|
-
until it prints nothing. The
|
|
483
|
+
It prints every field the renderer rejects on stderr, so keep stderr visible.
|
|
484
|
+
Fix `round.json` and run it again until it prints nothing. The workflow runs
|
|
485
|
+
the same check after you stop. The round is its own shape (`references/formats.md`):
|
|
485
486
|
not the Step 8 report (`posted`, `counts`, `narration`) and not the local
|
|
486
487
|
record (`stages`, `candidates`). `verdict` is `blocked`, `changes`, `nits` or
|
|
487
488
|
`good`; `verified` is the text of what the verifier checked. Then stop: the
|
|
@@ -496,7 +497,10 @@ gh api repos/<owner>/<repo>/pulls/<number>/reviews --method POST --input review.
|
|
|
496
497
|
`shepherd inline` keeps the shape a reader learns once: the tag line, a bold
|
|
497
498
|
title, the body, a suggestion block, `Verified:`, and a collapsed "Prompt for
|
|
498
499
|
AI agents". It leaves out NITs, findings with `"inline": false`, and findings
|
|
499
|
-
with no line, and posts at most 10, most severe first
|
|
500
|
+
with no line, and posts at most 10, most severe first, one per place: other
|
|
501
|
+
findings on the same lines are named under it. Run it from the reviewed
|
|
502
|
+
checkout, so it can place each `suggestion` on the lines it rewrites, at their
|
|
503
|
+
indentation. A finding on a line
|
|
500
504
|
outside the diff cannot anchor inline: keep its `line` and set
|
|
501
505
|
`"inline": false`. When `review.json` has no `comments`, skip the post.
|
|
502
506
|
Otherwise read the new threads' URLs
|
|
@@ -83,7 +83,8 @@ left, 1 or 0 a HIGH or CRITICAL standing. `effort` is how long a careful human
|
|
|
83
83
|
read takes, 1 (a minute) to 5 (an hour or more). Draw a `diagram` only when the
|
|
84
84
|
change has a flow a reader would otherwise reconstruct (a request path, a state
|
|
85
85
|
machine, data moving between modules); leave it empty for a helper function.
|
|
86
|
-
The new fields are optional: a round without them renders as before.
|
|
86
|
+
The new fields are optional: a round without them renders as before. A field
|
|
87
|
+
written as `null` reads as absent and takes its default.
|
|
87
88
|
The renderers hold the round to what they can check. A `url`, `reintroduces`
|
|
88
89
|
or still-open link that names no review comment on the PR, or is not a
|
|
89
90
|
GitHub URL, loses its link.
|
package/src/cli.ts
CHANGED
|
@@ -586,7 +586,10 @@ if (command === "install") {
|
|
|
586
586
|
|
|
587
587
|
const fanout = fanoutFile && existsSync(fanoutFile) ? orExit(() => JSON.parse(readFileSync(fanoutFile, "utf8"))) : undefined;
|
|
588
588
|
|
|
589
|
-
|
|
589
|
+
// Read from the reviewed checkout, as inline does, so both place each suggestion on the same lines.
|
|
590
|
+
const read = (p: string) => (existsSync(p) ? readFileSync(p, "utf8") : null);
|
|
591
|
+
|
|
592
|
+
process.stdout.write(orExit(() => renderSummary(input, b.emoji, opts.body ? null : b.headers.swarm, previous, fanout, reviewThreads(), read)));
|
|
590
593
|
} else if (command === "inline" && sub) {
|
|
591
594
|
// Swarm's inline review, rendered from the same round JSON: the payload for POST /pulls/<n>/reviews.
|
|
592
595
|
const input = orExit(() => JSON.parse(readFileSync(sub, "utf8")));
|
package/src/summary.ts
CHANGED
|
@@ -14,51 +14,68 @@ const THREAD_URL = /^https:\/\/github\.com\/[\w./#-]+$/;
|
|
|
14
14
|
// `changes_needed`, `skipped`, `verified: true`. Each maps onto the round's own value, so a near miss still renders.
|
|
15
15
|
const alias = (table: Record<string, string>) => (v: string) => table[v.trim().toLowerCase().replaceAll(/[\s-]+/g, "_")] ?? v;
|
|
16
16
|
|
|
17
|
+
// Models write `null` for a field they have nothing for. Null reads as absent, so the field takes its default.
|
|
18
|
+
const absent = <T extends z.ZodType>(t: T) => t.nullish().transform((v) => v ?? undefined);
|
|
19
|
+
|
|
20
|
+
const text = z.string().nullish().transform((v) => v ?? "");
|
|
21
|
+
|
|
22
|
+
const flag = (fallback: boolean) => z.boolean().nullish().transform((v) => v ?? fallback);
|
|
23
|
+
|
|
24
|
+
const EvidenceParts = z.object({ input: z.string().min(1), expected: z.string().min(1), actual: z.string().min(1) });
|
|
25
|
+
|
|
26
|
+
/** `Input: "Ada Lovelace", Expected: "Ada", Actual: "Lovelace"`, in any case and with `;` or `·` between: the three parts, or nothing. */
|
|
27
|
+
function evidenceFromLine(line: string) {
|
|
28
|
+
const m = /input:\s*(.+?)\s*[,;·]\s*expected:\s*(.+?)\s*[,;·]\s*actual:\s*(.+)$/is.exec(line.trim());
|
|
29
|
+
|
|
30
|
+
return m ? { input: m[1]!, expected: m[2]!, actual: m[3]! } : undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
17
33
|
const VERDICT_ALIAS = alias({ changes_needed: "changes", approve_with_nits: "nits", looks_good: "good", approve: "good", approved: "good" });
|
|
18
34
|
|
|
19
35
|
const STATUS_ALIAS = alias({ success: "ok", done: "ok", completed: "ok", complete: "ok", passed: "ok", error: "failed", errored: "failed", skipped: "could_not_run", not_run: "could_not_run", did_not_run: "could_not_run", missing: "could_not_run" });
|
|
20
36
|
|
|
21
37
|
const Finding = z.object({
|
|
22
|
-
file:
|
|
23
|
-
line:
|
|
24
|
-
.union([
|
|
38
|
+
file: text,
|
|
39
|
+
line: absent(
|
|
40
|
+
z.union([
|
|
25
41
|
z.number().int().positive(),
|
|
26
42
|
z
|
|
27
43
|
.string()
|
|
28
44
|
.regex(/^(?:[1-9]\d*(?:-[1-9]\d*)?|general)$/)
|
|
29
45
|
.refine((l) => !l.includes("-") || Number(l.split("-")[0]) <= Number(l.split("-")[1]), "a range runs start-end, start first"),
|
|
30
|
-
])
|
|
31
|
-
|
|
46
|
+
]),
|
|
47
|
+
),
|
|
32
48
|
severity: Severity,
|
|
33
49
|
lens: z.string(),
|
|
34
50
|
body: z.string(),
|
|
35
|
-
convergent:
|
|
51
|
+
convergent: flag(false),
|
|
36
52
|
// A reader triages by the title alone: a claim they can check, such as "`firstName` returns the second word".
|
|
37
|
-
title:
|
|
53
|
+
title: text,
|
|
38
54
|
// A thread link that is not a GitHub URL is dropped and the finding kept.
|
|
39
|
-
url: z.string().regex(THREAD_URL)
|
|
55
|
+
url: absent(z.string().regex(THREAD_URL)).catch(undefined), // the finding's inline thread, linked from the summary
|
|
40
56
|
// What the verifier checked, quoted code included. A bare `true` carries no evidence, so it reads as unverified.
|
|
41
|
-
verified: z.union([z.string(), z.boolean().transform(() => "")]).
|
|
57
|
+
verified: z.union([z.string(), z.boolean().transform(() => "")]).nullish().transform((v) => v ?? ""),
|
|
42
58
|
// The claim made checkable: an input, what the code should do on it, and what it does.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
// Also accepted as one line, `Input: …, Expected: …, Actual: …`, and split into its parts.
|
|
60
|
+
evidence: absent(z.union([EvidenceParts, z.string().transform(evidenceFromLine).pipe(EvidenceParts.optional())])),
|
|
61
|
+
suggestion: absent(z.string()), // replacement for exactly the lines the comment covers: GitHub's one-click commit
|
|
62
|
+
inline: flag(true), // false when the finding has no line in the diff to anchor on
|
|
46
63
|
// The read-only commands the reviewer or verifier ran to check it.
|
|
47
|
-
checked: z.array(z.object({ command: z.string(), result: z.string() })).
|
|
48
|
-
docs: z.array(z.object({ url: z.string().regex(/^https:\/\/[^\s()<>`]+$/), title: z.string() })).
|
|
49
|
-
reintroduces: z.string().regex(THREAD_URL)
|
|
64
|
+
checked: z.array(z.object({ command: z.string(), result: z.string() })).nullish().transform((v) => v ?? []),
|
|
65
|
+
docs: z.array(z.object({ url: z.string().regex(/^https:\/\/[^\s()<>`]+$/), title: z.string() })).nullish().transform((v) => v ?? []), // the documentation the claim rests on
|
|
66
|
+
reintroduces: absent(z.string().regex(THREAD_URL)).catch(undefined), // a resolved thread whose fix this change undoes
|
|
50
67
|
});
|
|
51
68
|
|
|
52
69
|
export const SummaryInput = z.object({
|
|
53
70
|
head_sha: z.string().regex(/^[0-9a-f]{7,40}$/),
|
|
54
71
|
verdict: z.string().transform(VERDICT_ALIAS).pipe(z.enum(["blocked", "changes", "nits", "good"])),
|
|
55
|
-
why:
|
|
56
|
-
confidence: z.number().int().min(0).max(5)
|
|
72
|
+
why: text,
|
|
73
|
+
confidence: absent(z.number().int().min(0).max(5)), // how safe to merge, 5 safest
|
|
57
74
|
findings: z.array(Finding).default([]),
|
|
58
75
|
walkthrough: z.array(z.string()).default([]), // what the PR does, a few bullets for a reader who never saw it
|
|
59
76
|
changes: z.array(z.object({ files: z.array(z.string()).min(1), summary: z.string() })).default([]),
|
|
60
|
-
effort: z.number().int().min(1).max(5)
|
|
61
|
-
diagram:
|
|
77
|
+
effort: absent(z.number().int().min(1).max(5)), // review effort, 1 trivial to 5 a long careful read
|
|
78
|
+
diagram: text, // mermaid flowchart source, when the change has a flow worth drawing
|
|
62
79
|
// Pre-merge checks: do the title, description, linked issue and scope match the diff.
|
|
63
80
|
pre_merge: z.array(z.object({ check: z.string(), status: z.enum(["pass", "warn", "fail"]), detail: z.string() })).default([]),
|
|
64
81
|
still_open: z.array(z.object({ url: z.string().regex(THREAD_URL).catch(""), title: z.string() })).default([]), // "" renders the title alone
|
|
@@ -181,7 +198,7 @@ const fromChecks = (f: { lens: string }) => f.lens.startsWith("checks/");
|
|
|
181
198
|
* input, expected and actual result is graded MEDIUM. The verdict is at least as strict as its findings. Without
|
|
182
199
|
* `threads`, links are kept as given.
|
|
183
200
|
*/
|
|
184
|
-
export function checkedRound(raw: SummaryInput, threads?: ReadonlySet<string
|
|
201
|
+
export function checkedRound(raw: SummaryInput, threads?: ReadonlySet<string>, read?: (path: string) => string | null) {
|
|
185
202
|
const s = SummaryInput.parse(raw);
|
|
186
203
|
const real = (url: string | undefined) => (url === undefined || threads === undefined || threads.has(url) ? url : undefined);
|
|
187
204
|
|
|
@@ -205,9 +222,58 @@ export function checkedRound(raw: SummaryInput, threads?: ReadonlySet<string>) {
|
|
|
205
222
|
|
|
206
223
|
for (const t of s.still_open) t.url = real(t.url) ?? "";
|
|
207
224
|
|
|
225
|
+
// With the reviewed files at hand, each suggestion is placed once, so the summary and the inline comment cite the
|
|
226
|
+
// same lines.
|
|
227
|
+
if (read) for (const f of s.findings) place(f, read);
|
|
228
|
+
|
|
208
229
|
return s;
|
|
209
230
|
}
|
|
210
231
|
|
|
232
|
+
/** A suggestion moved onto the lines it rewrites and given their indentation, or dropped when it fits nowhere near. */
|
|
233
|
+
function place(f: z.infer<typeof Finding>, read: (path: string) => string | null) {
|
|
234
|
+
if (f.suggestion === undefined) return;
|
|
235
|
+
|
|
236
|
+
const text = f.suggestion.includes("```") || !insideRepo(f.file) ? null : read(f.file);
|
|
237
|
+
const [start, end] = String(f.line).split("-").map(Number);
|
|
238
|
+
const lines = text?.split("\n") ?? [];
|
|
239
|
+
// Near the cited line first, then across the whole file, which still needs one clear best match.
|
|
240
|
+
const at = text === null || !start ? null : (anchorSuggestion(lines, start, end ?? start, f.suggestion) ?? anchorSuggestion(lines, start, end ?? start, f.suggestion, lines.length));
|
|
241
|
+
|
|
242
|
+
if (!at) {
|
|
243
|
+
f.suggestion = undefined;
|
|
244
|
+
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
f.line = end === undefined ? at.start : `${at.start}-${at.end}`;
|
|
249
|
+
// The baseline is the indentation the replaced lines share, so a block that dedents keeps its shape.
|
|
250
|
+
f.suggestion = reindent(f.suggestion, sharedIndent(lines.slice(at.start - 1, at.end)));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The suggestion at the indentation of the lines it replaces, since GitHub commits it as written. The indentation its
|
|
255
|
+
* non-blank lines share becomes `target`, in spaces or tabs, and each line keeps what it adds on top.
|
|
256
|
+
*/
|
|
257
|
+
export function reindent(suggestion: string, target: string): string {
|
|
258
|
+
const lines = suggestion.split("\n");
|
|
259
|
+
const common = sharedIndent(lines);
|
|
260
|
+
|
|
261
|
+
return lines.map((l) => (l.trim() ? target + l.slice(common.length) : l)).join("\n");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The leading whitespace every non-blank line starts with: the block's own indentation. */
|
|
265
|
+
function sharedIndent(lines: string[]): string {
|
|
266
|
+
const indents = lines.flatMap((l) => (l.trim() ? [/^[ \t]*/.exec(l)![0]] : []));
|
|
267
|
+
|
|
268
|
+
return indents.reduce((shared, own) => {
|
|
269
|
+
let n = 0;
|
|
270
|
+
|
|
271
|
+
while (n < shared.length && n < own.length && shared[n] === own[n]) n++;
|
|
272
|
+
|
|
273
|
+
return shared.slice(0, n);
|
|
274
|
+
}, indents[0] ?? "");
|
|
275
|
+
}
|
|
276
|
+
|
|
211
277
|
/** The worst severity among the findings whose tag names the lens (`correctness/data`, `correctness + security`), and how many. */
|
|
212
278
|
function lensTake(lens: string, findings: { lens: string; severity: z.infer<typeof Severity> }[]): string | undefined {
|
|
213
279
|
const mine = findings.filter((f) => f.lens.split(/[\s+/]+/).includes(lens));
|
|
@@ -223,8 +289,8 @@ const unverified = (f: z.infer<typeof Finding>) => f.severity !== "NIT" && !from
|
|
|
223
289
|
* The summary comment: the verdict heading, why, then one collapsed section per part of the round. With a null header
|
|
224
290
|
* it is the body alone, for the handoff file the publish job wraps in its own marker and header.
|
|
225
291
|
*/
|
|
226
|
-
export function renderSummary(raw: SummaryInput, emoji: Emoji, header: string | null, previous?: string, fanout?: z.input<typeof Fanout>, threads?: ReadonlySet<string
|
|
227
|
-
const s = checkedRound(raw, threads);
|
|
292
|
+
export function renderSummary(raw: SummaryInput, emoji: Emoji, header: string | null, previous?: string, fanout?: z.input<typeof Fanout>, threads?: ReadonlySet<string>, read?: (path: string) => string | null): string {
|
|
293
|
+
const s = checkedRound(raw, threads, read);
|
|
228
294
|
// A lens fanout listed for this head that the round does not report never ran as its own reviewer, so it shows
|
|
229
295
|
// as could_not_run.
|
|
230
296
|
const wave = fanout ? Fanout.parse(fanout) : null;
|
|
@@ -376,7 +442,7 @@ const AHEAD = 0.1; // how far a moved suggestion's window must lead the next mos
|
|
|
376
442
|
* rewrites. The lines named stay when they are alike enough. Otherwise it moves to the window of the same size, within
|
|
377
443
|
* five lines, that is alike enough, differs from the suggestion and leads the next most alike; with none, it is dropped.
|
|
378
444
|
*/
|
|
379
|
-
export function anchorSuggestion(lines: string[], start: number, end: number, suggestion: string): { start: number; end: number } | null {
|
|
445
|
+
export function anchorSuggestion(lines: string[], start: number, end: number, suggestion: string, near = NEAR): { start: number; end: number } | null {
|
|
380
446
|
const size = end - start + 1;
|
|
381
447
|
const flat = (t: string) => t.replace(/\s+/g, " ").trim();
|
|
382
448
|
|
|
@@ -387,10 +453,13 @@ export function anchorSuggestion(lines: string[], start: number, end: number, su
|
|
|
387
453
|
};
|
|
388
454
|
|
|
389
455
|
if (end <= lines.length && score(start) >= LIKE) return { start, end };
|
|
390
|
-
const
|
|
456
|
+
const tried: { from: number; score: number }[] = [];
|
|
391
457
|
|
|
392
|
-
|
|
393
|
-
const [
|
|
458
|
+
// A whole-file search (near >= the file's length) covers every window, wherever the cited line was.
|
|
459
|
+
const [lo, hi] = near >= lines.length ? [1, lines.length - size + 1] : [Math.max(1, start - near), Math.min(lines.length - size + 1, start + near)];
|
|
460
|
+
|
|
461
|
+
for (let from = lo; from <= hi; from++) tried.push({ from, score: score(from) });
|
|
462
|
+
const [best, next] = tried.sort((a, b) => b.score - a.score);
|
|
394
463
|
|
|
395
464
|
return best && best.score >= LIKE && best.score - (next?.score ?? 0) >= AHEAD ? { start: best.from, end: best.from + size - 1 } : null;
|
|
396
465
|
}
|
|
@@ -399,7 +468,7 @@ export function anchorSuggestion(lines: string[], start: number, end: number, su
|
|
|
399
468
|
const insideRepo = (p: string) => !p.startsWith("/") && !p.split(/[\\/]/).includes("..");
|
|
400
469
|
|
|
401
470
|
export function renderReview(raw: SummaryInput, emoji: Emoji, header: string, read: (path: string) => string | null = () => null, threads?: ReadonlySet<string>) {
|
|
402
|
-
const s = checkedRound(raw, threads);
|
|
471
|
+
const s = checkedRound(raw, threads, read);
|
|
403
472
|
const glyph = (sev: z.infer<typeof Severity>) => emoji[GLYPH[sev]];
|
|
404
473
|
|
|
405
474
|
// A line past the end of the file it names cannot anchor: GitHub rejects the whole review over one such comment.
|
|
@@ -409,20 +478,22 @@ export function renderReview(raw: SummaryInput, emoji: Emoji, header: string, re
|
|
|
409
478
|
return text === null || Number(String(f.line).split("-").at(-1)) <= text.replace(/\n$/, "").split("\n").length;
|
|
410
479
|
};
|
|
411
480
|
|
|
412
|
-
const
|
|
481
|
+
const anchored = SEVERITIES.flatMap((sev) => s.findings.filter((f) => f.severity === sev && sev !== "NIT" && f.inline && f.file && f.line !== undefined && f.line !== "general" && fits(f)));
|
|
482
|
+
// One comment per place, the most severe finding's. Others on the same lines are named under it and appear in full
|
|
483
|
+
// in the summary.
|
|
484
|
+
const at = (f: (typeof s.findings)[number]) => `${f.file}:${f.line}`;
|
|
485
|
+
const posted = anchored.filter((f, i) => anchored.findIndex((g) => at(g) === at(f)) === i).slice(0, PER_REVIEW);
|
|
413
486
|
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
// A suggestion is committed as written: it posts only when it cannot close its own fence and its lines are placed.
|
|
417
|
-
let fix = f.suggestion !== undefined && !f.suggestion.includes("```") ? f.suggestion : undefined;
|
|
418
|
-
const text = fix !== undefined && insideRepo(f.file) ? read(f.file) : null;
|
|
487
|
+
const alsoHere = (f: (typeof s.findings)[number]) => {
|
|
488
|
+
const rest = anchored.filter((g) => g !== f && at(g) === at(f));
|
|
419
489
|
|
|
420
|
-
|
|
421
|
-
|
|
490
|
+
return rest.length ? ["", `**Also here:** ${rest.map((g) => `${glyph(g.severity)} ${g.severity} ${defuse(g.title || g.body.split("\n")[0]!, true)}`).join(" · ")}`] : [];
|
|
491
|
+
};
|
|
422
492
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
493
|
+
const comments = posted.map((f) => {
|
|
494
|
+
const [start = 0, end] = String(f.line).split("-").map(Number); // `posted` kept only numeric lines and "a-b" ranges
|
|
495
|
+
// checkedRound placed the suggestion and kept it only where it fits.
|
|
496
|
+
const fix = f.suggestion;
|
|
426
497
|
|
|
427
498
|
const suggestion = fix !== undefined ? ["", "```suggestion", fix, "```"] : [];
|
|
428
499
|
const where = end === undefined ? `${start}` : `${start}-${end}`;
|
|
@@ -439,6 +510,7 @@ export function renderReview(raw: SummaryInput, emoji: Emoji, header: string, re
|
|
|
439
510
|
...evidenceBlock(f),
|
|
440
511
|
...docsLine(f),
|
|
441
512
|
...suggestion,
|
|
513
|
+
...alsoHere(f),
|
|
442
514
|
...(f.verified ? ["", `**Verified:** ${defuse(f.verified)}`] : []),
|
|
443
515
|
...(unverified(f) ? ["", "⚠️ No verifier has checked this yet."] : []),
|
|
444
516
|
...checkedBlock(f),
|
package/templates/shepherd.yml
CHANGED
|
@@ -342,11 +342,20 @@ jobs:
|
|
|
342
342
|
opencode run --auto -m "$model" --title "shepherd #$PR" "Load the shepherd skill and run exactly one iteration on PR $PR in handoff mode:
|
|
343
343
|
SHEPHERD_HANDOFF is set, so follow the skill's Handoff mode. Swarm's first wave is in $SHEPHERD_FANOUT: dispatch
|
|
344
344
|
the router and every lens listed there in one message. Write the round to $SHEPHERD_HANDOFF/round.json and check it
|
|
345
|
-
with 'shepherd summary $SHEPHERD_HANDOFF/round.json --body > /dev/null', fixing every error it prints
|
|
346
|
-
job renders and posts the inline review and the summary from it, so post neither
|
|
345
|
+
with 'shepherd summary $SHEPHERD_HANDOFF/round.json --body > /dev/null', fixing every error it prints on stderr (never
|
|
346
|
+
redirect stderr): the publish job renders and posts the inline review and the summary from it, so post neither
|
|
347
|
+
yourself. You are running in GitHub Actions on the PR branch,
|
|
347
348
|
already checked out, and you cannot push. Nobody is watching this session: never wait for an answer. Anything you
|
|
348
349
|
would ask the user is deferred, listed in the iteration summary, and named in status.json. Do not schedule further
|
|
349
350
|
iterations; the next one starts when CI or stamp finishes on the head the workflow pushes."
|
|
351
|
+
# The job checks the round itself. A round that does not render gets one short call with the exact errors.
|
|
352
|
+
round="$SHEPHERD_HANDOFF/round.json"
|
|
353
|
+
if [ -f "$round" ] && ! errors=$(shepherd summary "$round" --body 2>&1 >/dev/null); then
|
|
354
|
+
echo "::warning::round.json does not render; asking the model to fix it"
|
|
355
|
+
opencode run --auto -m "$model" --title "shepherd #$PR round.json" "The round you wrote to $round does not
|
|
356
|
+
render. Fix exactly these errors in that file and change nothing else, then run 'shepherd summary $round --body > /dev/null'
|
|
357
|
+
and repeat until it prints nothing on stderr. Errors: ${errors:0:6000}" || true
|
|
358
|
+
fi
|
|
350
359
|
- name: Bundle the commits
|
|
351
360
|
env:
|
|
352
361
|
H0: ${{ needs.gate.outputs.head }}
|
|
@@ -470,6 +479,21 @@ jobs:
|
|
|
470
479
|
state, desc = "failure", f"fixes not pushed, a person should look: {' '.join(sys.argv[3].split())}"
|
|
471
480
|
elif sys.argv[2]:
|
|
472
481
|
state, desc = "pending", f"pushed {sys.argv[2]} commit(s) for review; {desc}"
|
|
482
|
+
elif state == "pending":
|
|
483
|
+
# Nothing pushed and no CI re-run asked for: findings above NIT leave work for the author, so the status
|
|
484
|
+
# is failure and the sweep, which re-runs pending PRs every half hour, leaves the PR to them. Otherwise it
|
|
485
|
+
# stays pending: success needs stamp's approval, green CI and no open thread, which this step cannot see.
|
|
486
|
+
try:
|
|
487
|
+
reruns = open("handoff/rerun-jobs.txt").read().strip() not in ("", "[]")
|
|
488
|
+
except OSError:
|
|
489
|
+
reruns = False
|
|
490
|
+
try:
|
|
491
|
+
r = json.load(open("handoff/round.json"))
|
|
492
|
+
found = [f for f in (r.get("findings") or []) if isinstance(f, dict) and f.get("severity") != "NIT"]
|
|
493
|
+
if found and not reruns:
|
|
494
|
+
state, desc = "failure", f"{len(found)} finding(s) for the author; {desc}"
|
|
495
|
+
except Exception:
|
|
496
|
+
pass
|
|
473
497
|
print(state)
|
|
474
498
|
print(desc[:139])
|
|
475
499
|
PY
|