@jagreehal/shepherd 0.15.0 → 0.17.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/AGENTS.md +3 -3
- package/README.md +40 -27
- package/THIRD_PARTY_NOTICES.md +2 -0
- package/gate/.shepherd/gate.schema.json +657 -0
- package/gate/.shepherd/gate.yml +123 -0
- package/gate/.shepherd/review-guidance.md +95 -0
- package/gate/src/actions.ts +32 -0
- package/gate/src/cli.ts +1046 -0
- package/gate/src/config.ts +102 -0
- package/gate/src/delta.ts +29 -0
- package/gate/src/env.ts +30 -0
- package/gate/src/eval.ts +292 -0
- package/gate/src/familiarity.ts +461 -0
- package/gate/src/github.ts +761 -0
- package/gate/src/inline.ts +59 -0
- package/gate/src/isolated-cli.ts +281 -0
- package/gate/src/leads.ts +257 -0
- package/gate/src/llm.ts +647 -0
- package/gate/src/notify.ts +57 -0
- package/gate/src/policy.ts +1313 -0
- package/gate/src/prices.ts +62 -0
- package/gate/src/provider-errors.ts +80 -0
- package/gate/src/retention.ts +86 -0
- package/gate/src/reviewer.ts +739 -0
- package/gate/src/signals.ts +105 -0
- package/gate/src/smoke-live.ts +64 -0
- package/gate/src/stack.ts +87 -0
- package/gate/src/stories.ts +297 -0
- package/gate/templates/policy-strict.yml +128 -0
- package/gate/templates/reviewer.Dockerfile +8 -0
- package/gate/templates/rules/observability/SKILL.md +33 -0
- package/gate/templates/shepherd-gate-actions.yml +35 -0
- package/gate/templates/shepherd-gate-edited.yml +29 -0
- package/gate/templates/shepherd-gate.yml +111 -0
- package/lenses/dotnet/SKILL.md +1 -1
- package/lenses/go/SKILL.md +1 -1
- package/lenses/java/SKILL.md +1 -1
- package/lenses/nextjs/SKILL.md +1 -1
- package/lenses/node-api/SKILL.md +1 -1
- package/lenses/nx-monorepo/SKILL.md +1 -1
- package/lenses/observability/SKILL.md +1 -1
- package/lenses/owasp-asvs/SKILL.md +1 -1
- package/lenses/owasp-llm/SKILL.md +1 -1
- package/lenses/pstack/SKILL.md +1 -1
- package/lenses/python/SKILL.md +1 -1
- package/lenses/react/SKILL.md +1 -1
- package/lenses/rust/SKILL.md +1 -1
- package/package.json +21 -7
- package/schema/config.json +1 -1
- package/skills/branch-review/SKILL.md +123 -0
- package/skills/ci-repair/SKILL.md +79 -35
- package/skills/garden/SKILL.md +8 -8
- package/skills/garden/references/telemetry.md +4 -4
- package/skills/incident/SKILL.md +9 -9
- package/skills/lens-import/SKILL.md +7 -7
- package/skills/review-slop/SKILL.md +1 -1
- package/skills/shepherd/SKILL.md +43 -41
- package/skills/shepherd/references/degradation.md +3 -3
- package/skills/shepherd/references/dispatch.md +1 -1
- package/skills/shepherd/references/formats.md +5 -5
- package/skills/shepherd/references/models.md +2 -2
- package/skills/shepherd/references/policy.md +9 -9
- package/skills/swarm/SKILL.md +21 -17
- package/skills/swarm/references/custom-lenses.md +2 -2
- package/skills/swarm/references/formats.md +1 -1
- package/skills/triage/SKILL.md +10 -10
- package/src/bin.ts +10 -0
- package/src/cli.ts +285 -42
- package/src/config.ts +26 -25
- package/src/doctor.ts +31 -18
- package/src/garden-traces.ts +13 -13
- package/src/garden.ts +4 -4
- package/src/lens.ts +19 -7
- package/src/setup.ts +72 -0
- package/src/stack.ts +2 -2
- package/src/status.ts +80 -0
- package/src/summary.ts +52 -9
- package/src/trace.ts +4 -4
- package/src/working.ts +30 -0
- package/templates/shepherd-audit.yml +7 -15
- package/templates/shepherd-incident.yml +7 -12
- package/templates/shepherd.yml +39 -40
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Outbound notifications. Off until SHEPHERD_NOTIFY_WEBHOOK is set. A Slack Incoming Webhook URL gets a
|
|
2
|
+
// Slack message; any other URL gets the event as JSON, so Discord relays, Teams, n8n, Zapier or an
|
|
3
|
+
// agent platform's trigger can take it from there. People answer on the PR, where gate re-reviews.
|
|
4
|
+
import type { Verdict } from "./github.ts";
|
|
5
|
+
|
|
6
|
+
export type NotifyEvent = {
|
|
7
|
+
event: "gate.verdict";
|
|
8
|
+
repo: string;
|
|
9
|
+
pr: number;
|
|
10
|
+
url: string;
|
|
11
|
+
title: string;
|
|
12
|
+
head_sha: string;
|
|
13
|
+
verdict: Verdict;
|
|
14
|
+
/** True when the gates held the PR for a person before any review: nothing to fix, someone has to look. */
|
|
15
|
+
held: boolean;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Verdicts that notify unless notify.on says otherwise. Approvals land in the digest. */
|
|
20
|
+
export const NOTIFY_DEFAULT: Verdict[] = ["REFUSED", "ESCALATE", "ERROR"];
|
|
21
|
+
|
|
22
|
+
const VERDICTS: Verdict[] = ["APPROVED", "REFUSED", "ESCALATE", "ERROR"];
|
|
23
|
+
|
|
24
|
+
export function notifyOn(raw: string | undefined): Verdict[] {
|
|
25
|
+
const asked = new Set((raw ?? "").split(",").map((s) => s.trim().toUpperCase()));
|
|
26
|
+
const list = VERDICTS.filter((v) => asked.has(v));
|
|
27
|
+
|
|
28
|
+
return list.length ? list : NOTIFY_DEFAULT;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// PR titles and model reasoning are untrusted; Slack reads <...> as links and mentions (<!channel>).
|
|
32
|
+
export const slackEscape = (t: string) => t.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
33
|
+
|
|
34
|
+
export const isSlack = (url: string) => url.startsWith("https://hooks.slack.com/services/");
|
|
35
|
+
|
|
36
|
+
export function slackText(e: NotifyEvent): string {
|
|
37
|
+
const reason = e.reason.split("\n").find((l) => l.trim()) ?? "";
|
|
38
|
+
|
|
39
|
+
return `*gate ${e.held ? "needs a person" : e.verdict.toLowerCase()}* <${e.url}|${e.repo}#${e.pr} ${slackEscape(e.title)}>\n${slackEscape(reason.slice(0, 300))}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function payload(url: string, e: NotifyEvent): string {
|
|
43
|
+
return JSON.stringify(isSlack(url) ? { text: slackText(e) } : { ...e, reason: e.reason.slice(0, 2000) });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Posts the event. Never throws: a notification must not change a verdict. */
|
|
47
|
+
export async function notify(url: string | undefined, e: NotifyEvent, on: Verdict[], post: typeof fetch = fetch): Promise<void> {
|
|
48
|
+
if (!url || !on.includes(e.verdict)) return;
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const res = await post(url, { method: "POST", headers: { "content-type": "application/json" }, body: payload(url, e), signal: AbortSignal.timeout(10_000) });
|
|
52
|
+
|
|
53
|
+
if (!res.ok) console.error(`notify webhook returned ${res.status}`);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.error(`notify webhook failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
56
|
+
}
|
|
57
|
+
}
|