@fullstackhouse/cerber 1.0.0-pr.79.dee1011 → 1.1.0-pr.80.03eb934
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/README.md +4 -2
- package/dist/cli/index.js +4 -2
- package/dist/core/autoreview.js +33 -0
- package/dist/core/config.js +20 -0
- package/dist/server/daemon.js +20 -11
- package/dist/server/index.js +36 -0
- package/package.json +1 -1
- package/web/dist/assets/{index-QI3jVGoL.js → index-CHF4kBTR.js} +63 -63
- package/web/dist/assets/{index-DC0sUP02.css → index-DPt1TcJ6.css} +1 -1
- package/web/dist/index.html +2 -2
package/README.md
CHANGED
|
@@ -86,7 +86,9 @@ npx @fullstackhouse/cerber list
|
|
|
86
86
|
Sending stays a human click. Tame it with `--no-auto-review` (list awaiting
|
|
87
87
|
PRs, review on click) or `--no-poll` (no GitHub polling at all) — or flip those
|
|
88
88
|
switches in the cockpit's Settings, which persist in `~/.cerber/config.json`
|
|
89
|
-
and apply on the next poll.
|
|
89
|
+
and apply on the next poll. Settings also takes per-repo exceptions
|
|
90
|
+
(`daemon.autoReviewRepos`): keep a busy repo to the click while the rest are
|
|
91
|
+
drafted, or draft one repo with auto-review otherwise off.
|
|
90
92
|
|
|
91
93
|
## Contents
|
|
92
94
|
|
|
@@ -200,7 +202,7 @@ into one popup when several land at once. Ready means *there is something to
|
|
|
200
202
|
read*: cerber drafts the review itself, so the tap waits for the draft and says
|
|
201
203
|
what it found — "widgets#7 draft ready · requests changes · 2 blockers" — rather
|
|
202
204
|
than walking you back to a row that says "no run yet". A PR nobody is going to
|
|
203
|
-
draft (auto-review off, or a run that failed) is announced as it arrives, since
|
|
205
|
+
draft (auto-review off for its repo, or a run that failed) is announced as it arrives, since
|
|
204
206
|
that is all the news there will be — and if a retry drafts it after all, that is
|
|
205
207
|
new news and you are told. Nothing else is: a PR whose draft you have been told
|
|
206
208
|
about stays quiet however its next re-review ends. The tap comes from the poll, so it reaches
|
package/dist/cli/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import readline from "node:readline/promises";
|
|
|
5
5
|
import { artifactId, artifactKey } from "../core/artifact.js";
|
|
6
6
|
import { listCheckouts, removeCheckout } from "../core/checkout.js";
|
|
7
7
|
import { toMarkdown } from "../core/export.js";
|
|
8
|
+
import { anyAutoReview, capAutoReview } from "../core/autoreview.js";
|
|
8
9
|
import { configPath, loadConfig, saveConfig } from "../core/config.js";
|
|
9
10
|
import { formatBlockers, isBlocking, preflight } from "../core/preflight.js";
|
|
10
11
|
import { withWriter } from "../core/history.js";
|
|
@@ -446,7 +447,7 @@ program
|
|
|
446
447
|
.option("-H, --host <host>", "host to bind (0.0.0.0 for VPS — requires --token)", "127.0.0.1")
|
|
447
448
|
.option("-t, --token <token>", "require this token on every request (env: CERBER_TOKEN)")
|
|
448
449
|
.option("--no-poll", "don't poll GitHub for PRs awaiting your review (also disables auto-review)")
|
|
449
|
-
.option("--no-auto-review", "list awaiting PRs but don't review them until you click review")
|
|
450
|
+
.option("--no-auto-review", "list awaiting PRs but don't review them until you click review (per-repo exceptions included)")
|
|
450
451
|
.option("--no-notify", "don't notify this machine when a review is ready for you")
|
|
451
452
|
.option("-d, --daemon", "(deprecated no-op — polling and auto-review are now the default)")
|
|
452
453
|
.option("-i, --interval <minutes>", "poll interval (default: config daemon.intervalMinutes, 5)")
|
|
@@ -484,7 +485,8 @@ program
|
|
|
484
485
|
const d = config.daemon;
|
|
485
486
|
// Trust means "run this PR's code". A human clicking review accepted that
|
|
486
487
|
// per PR; auto-review does it unattended, on whatever lands in the queue.
|
|
487
|
-
|
|
488
|
+
const drafting = anyAutoReview(capAutoReview(d, opts.autoReview));
|
|
489
|
+
if (opts.poll && d.poll && drafting && opts.trust && config.trust.length > 0) {
|
|
488
490
|
console.log(`⚠ ${config.trust.length} trust rule(s) in ${configPath()}: unattended reviews will run commands from ` +
|
|
489
491
|
`matching PRs, with nobody watching. Pass --no-trust to keep every review read-only, ` +
|
|
490
492
|
`or --no-auto-review to only review on click.`);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function autoReviewFor(knobs, owner, repo) {
|
|
2
|
+
const want = `${owner}/${repo}`.toLowerCase();
|
|
3
|
+
for (const [key, on] of Object.entries(knobs.autoReviewRepos)) {
|
|
4
|
+
if (key.toLowerCase() === want)
|
|
5
|
+
return on;
|
|
6
|
+
}
|
|
7
|
+
return knobs.autoReview;
|
|
8
|
+
}
|
|
9
|
+
/** Whether any repo at all is drafted unattended — what the trust warning and
|
|
10
|
+
* the strip's `trustedRuns` are about. */
|
|
11
|
+
export function anyAutoReview(knobs) {
|
|
12
|
+
return knobs.autoReview || Object.values(knobs.autoReviewRepos).some(Boolean);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What a process actually drafts: `--no-auto-review` caps the default and the
|
|
16
|
+
* exceptions alike, so the flag means "this process starts no AI runs" and the
|
|
17
|
+
* trust warning's advice to pass it holds. A `true` exception still outranks
|
|
18
|
+
* the config's own `autoReview: false` — never the flag.
|
|
19
|
+
*/
|
|
20
|
+
export function capAutoReview(knobs, flag) {
|
|
21
|
+
return flag ? knobs : { autoReview: false, autoReviewRepos: {} };
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One exception set (`true`/`false`) or removed (`null`), the rest left as they
|
|
25
|
+
* are. Any spelling of the same repo is replaced rather than kept beside it,
|
|
26
|
+
* since the match ignores case. One repo per write, so an edit made from a stale
|
|
27
|
+
* view can't take a concurrent one with it.
|
|
28
|
+
*/
|
|
29
|
+
export function setException(repos, repo, on) {
|
|
30
|
+
const want = repo.toLowerCase();
|
|
31
|
+
const rest = Object.fromEntries(Object.entries(repos).filter(([k]) => k.toLowerCase() !== want));
|
|
32
|
+
return on === null ? rest : { ...rest, [repo]: on };
|
|
33
|
+
}
|
package/dist/core/config.js
CHANGED
|
@@ -22,6 +22,26 @@ export const DaemonConfigSchema = z.object({
|
|
|
22
22
|
poll: z.boolean().default(true),
|
|
23
23
|
/** Draft an AI review for whatever lands in the queue. Never sends. */
|
|
24
24
|
autoReview: z.boolean().default(true),
|
|
25
|
+
/**
|
|
26
|
+
* Per-repo exceptions to `autoReview`, either way: `false` leaves that repo's
|
|
27
|
+
* PRs waiting for a click, `true` drafts them even with `autoReview` off.
|
|
28
|
+
* Resolved by `autoReviewFor` in core/autoreview.ts.
|
|
29
|
+
*/
|
|
30
|
+
autoReviewRepos: z
|
|
31
|
+
.record(z.string().regex(/^[\w.-]+\/[\w.-]+$/, "expected owner/repo"), z.boolean())
|
|
32
|
+
// The match ignores case, so two spellings of one repo would leave the
|
|
33
|
+
// answer to key order — refused, like any other key that can't mean one thing.
|
|
34
|
+
.superRefine((repos, ctx) => {
|
|
35
|
+
const seen = new Map();
|
|
36
|
+
for (const key of Object.keys(repos)) {
|
|
37
|
+
const first = seen.get(key.toLowerCase());
|
|
38
|
+
if (first !== undefined)
|
|
39
|
+
ctx.addIssue({ code: "custom", path: [key], message: `same repo as ${first}` });
|
|
40
|
+
else
|
|
41
|
+
seen.set(key.toLowerCase(), key);
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
.default({}),
|
|
25
45
|
/**
|
|
26
46
|
* Tap this machine's notification centre when a PR is worth coming back for
|
|
27
47
|
* — the draft landing, or the arrival itself when nothing is going to be
|
package/dist/server/daemon.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SCHEMA_VERSION, artifactId, artifactKey } from "../core/artifact.js";
|
|
2
2
|
import { evaluateAutoSend } from "../core/autosend.js";
|
|
3
|
+
import { anyAutoReview, autoReviewFor, capAutoReview } from "../core/autoreview.js";
|
|
3
4
|
import { loadConfig } from "../core/config.js";
|
|
4
5
|
import { classifyReply, currentLogin, fetchConversation, fetchLastReviewRequest, fetchOwnReview, fetchPrInfo, fetchReviewRequests, lastMentionOfYou, lastWordOfYours, searchAwaitingMe, stillRequested, submitReview, } from "../core/gh.js";
|
|
5
6
|
import { withWriter } from "../core/history.js";
|
|
@@ -220,6 +221,7 @@ export function startDaemon(opts) {
|
|
|
220
221
|
// keeps its own counsel for the few seconds that takes.
|
|
221
222
|
notify: false,
|
|
222
223
|
autoReview: opts.autoReview,
|
|
224
|
+
autoReviewRepos: {},
|
|
223
225
|
trustedRuns: false,
|
|
224
226
|
polls: 0,
|
|
225
227
|
errors: 0,
|
|
@@ -582,9 +584,9 @@ export function startDaemon(opts) {
|
|
|
582
584
|
* quiet week would announce that whole week at once — the same reason the
|
|
583
585
|
* browser bell records what it stays quiet about.
|
|
584
586
|
*/
|
|
585
|
-
async function announce(
|
|
587
|
+
async function announce(drafts, tell) {
|
|
586
588
|
const owed = (await listArtifacts()).flatMap((a) => {
|
|
587
|
-
const news = pendingNews(a,
|
|
589
|
+
const news = pendingNews(a, drafts(a.pr));
|
|
588
590
|
return news ? [{ id: a.id, news }] : [];
|
|
589
591
|
});
|
|
590
592
|
// `cockpitUrl` is where a click lands, and it is read here rather than
|
|
@@ -726,7 +728,8 @@ export function startDaemon(opts) {
|
|
|
726
728
|
*/
|
|
727
729
|
function applyKnobs(config) {
|
|
728
730
|
const knobs = config.daemon;
|
|
729
|
-
const autoReview = opts.autoReview
|
|
731
|
+
const autoReview = capAutoReview(knobs, opts.autoReview);
|
|
732
|
+
const drafts = (pr) => autoReviewFor(autoReview, pr.owner, pr.repo);
|
|
730
733
|
status.pollEnabled = knobs.poll;
|
|
731
734
|
// What the cockpit's bell defers to: a loop that isn't polling announces
|
|
732
735
|
// nothing, whatever the notify toggle says.
|
|
@@ -736,10 +739,11 @@ export function startDaemon(opts) {
|
|
|
736
739
|
// should be standing down for.
|
|
737
740
|
const announcing = () => knobs.poll && notifyOn && notifierWorks !== false;
|
|
738
741
|
status.notify = announcing();
|
|
739
|
-
status.autoReview = autoReview;
|
|
742
|
+
status.autoReview = autoReview.autoReview;
|
|
743
|
+
status.autoReviewRepos = autoReview.autoReviewRepos;
|
|
740
744
|
// Recomputed too, so a trust rule added mid-run shows up in the strip.
|
|
741
|
-
status.trustedRuns = autoReview && opts.trust !== false && config.trust.length > 0;
|
|
742
|
-
return { knobs, autoReview, notifyOn, announcing };
|
|
745
|
+
status.trustedRuns = anyAutoReview(autoReview) && opts.trust !== false && config.trust.length > 0;
|
|
746
|
+
return { knobs, drafts, drafting: anyAutoReview(autoReview), notifyOn, announcing };
|
|
743
747
|
}
|
|
744
748
|
/** Everything a poll writes is the poll's — including the reviews it starts,
|
|
745
749
|
* which stamp themselves as runs from inside this. */
|
|
@@ -756,7 +760,7 @@ export function startDaemon(opts) {
|
|
|
756
760
|
// or the knobs), so a broken file skips the tick loudly instead of
|
|
757
761
|
// proceeding on guessed defaults.
|
|
758
762
|
const config = await loadConfig();
|
|
759
|
-
const { knobs,
|
|
763
|
+
const { knobs, drafts, drafting, notifyOn, announcing } = applyKnobs(config);
|
|
760
764
|
if (!knobs.poll) {
|
|
761
765
|
// Deliberately off is not an outage — don't leave a stale error up, or
|
|
762
766
|
// a list of PRs we are no longer checking are still awaiting you.
|
|
@@ -772,11 +776,16 @@ export function startDaemon(opts) {
|
|
|
772
776
|
// A failed poll leaves the last good list up; lastPollError says so.
|
|
773
777
|
status.awaiting = await classifyAll(refs);
|
|
774
778
|
const { discovered } = await syncQueue(refs);
|
|
775
|
-
if (
|
|
776
|
-
|
|
779
|
+
if (drafting) {
|
|
780
|
+
// A repo excepted from auto-review is discovered like any other — it
|
|
781
|
+
// is in the queue above — and only its run waits for the click.
|
|
782
|
+
const toDraft = refs.filter(drafts);
|
|
783
|
+
const onClick = refs.length - toDraft.length;
|
|
784
|
+
const { reviewed, skipped, failed } = await reviewAll(toDraft);
|
|
777
785
|
status.lastSummary =
|
|
778
786
|
`${refs.length} awaiting; ${reviewed} reviewed, ${skipped} up to date` +
|
|
779
|
-
`${failed > 0 ? `, ${failed} failed` : ""}
|
|
787
|
+
`${failed > 0 ? `, ${failed} failed` : ""}` +
|
|
788
|
+
`${onClick > 0 ? `, ${onClick} waiting for a click` : ""}`;
|
|
780
789
|
}
|
|
781
790
|
else {
|
|
782
791
|
status.lastSummary = `${refs.length} awaiting${discovered.length > 0 ? `, ${discovered.length} new` : ""} (auto-review off)`;
|
|
@@ -788,7 +797,7 @@ export function startDaemon(opts) {
|
|
|
788
797
|
// for the draft — and for a PR nobody is drafting (auto-review off, or a
|
|
789
798
|
// run that failed) it goes out here all the same. `isNews` is the rule,
|
|
790
799
|
// and the cockpit's bell reads the same one.
|
|
791
|
-
await announce(
|
|
800
|
+
await announce(drafts, notifyOn);
|
|
792
801
|
// Recomputed on the spot rather than left to the next poll: that is
|
|
793
802
|
// minutes away, and the cockpit would spend them deferring to a tap that
|
|
794
803
|
// never came. Recomputed rather than only cleared, so a machine whose
|
package/dist/server/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { ArtifactStatusSchema, SCHEMA_VERSION, SeveritySchema, VerdictSchema, ar
|
|
|
11
11
|
import { toMarkdown } from "../core/export.js";
|
|
12
12
|
import { currentLogin, fetchAssignableUsers, fetchPrDiff, fetchPrInfo, handOffReview, parsePrRef, postIssueComment, postReplies, submitReview, } from "../core/gh.js";
|
|
13
13
|
import { z } from "zod";
|
|
14
|
+
import { setException } from "../core/autoreview.js";
|
|
14
15
|
import { DaemonConfigSchema, configPath, loadConfig, saveConfig } from "../core/config.js";
|
|
15
16
|
import { version } from "../core/version.js";
|
|
16
17
|
import { refreshArtifact, userOwnsStatus } from "../core/refresh.js";
|
|
@@ -164,6 +165,41 @@ export async function buildApp(opts) {
|
|
|
164
165
|
return c.json({ error: err instanceof Error ? err.message : String(err) }, 500);
|
|
165
166
|
}
|
|
166
167
|
});
|
|
168
|
+
// One per-repo auto-review exception at a time: `on` true or false sets it,
|
|
169
|
+
// null removes it. Merged into the file as it is now, not the map the cockpit
|
|
170
|
+
// loaded, so a second tab or a hand edit since then is not overwritten.
|
|
171
|
+
app.post("/api/config/auto-review-repo", async (c) => {
|
|
172
|
+
let body;
|
|
173
|
+
try {
|
|
174
|
+
body = await c.req.json();
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return c.json({ error: "body must be JSON" }, 400);
|
|
178
|
+
}
|
|
179
|
+
const { repo, on } = body;
|
|
180
|
+
if (typeof repo !== "string" || !repo.trim()) {
|
|
181
|
+
return c.json({ error: "repo is required" }, 400);
|
|
182
|
+
}
|
|
183
|
+
if (on !== null && typeof on !== "boolean") {
|
|
184
|
+
return c.json({ error: "on must be true, false or null" }, 400);
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const config = await loadConfig();
|
|
188
|
+
const daemon = DaemonConfigSchema.parse({
|
|
189
|
+
...config.daemon,
|
|
190
|
+
autoReviewRepos: setException(config.daemon.autoReviewRepos, repo.trim(), on),
|
|
191
|
+
});
|
|
192
|
+
await saveConfig({ ...config, daemon });
|
|
193
|
+
opts.daemon?.reconfigure({ ...config, daemon });
|
|
194
|
+
return c.json(configView(config.trust, daemon));
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
if (err instanceof z.ZodError) {
|
|
198
|
+
return c.json({ error: err.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ") }, 400);
|
|
199
|
+
}
|
|
200
|
+
return c.json({ error: err instanceof Error ? err.message : String(err) }, 500);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
167
203
|
app.post("/api/config/trust", async (c) => {
|
|
168
204
|
let body;
|
|
169
205
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullstackhouse/cerber",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0-pr.80.03eb934",
|
|
4
4
|
"description": "AI code-review cockpit: Claude reviews your PRs into local artifacts; nothing reaches GitHub until you say so.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|