@fullstackhouse/cerber 1.1.0-pr.80.e038e96 → 1.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/dist/cli/index.js CHANGED
@@ -5,7 +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 } from "../core/autoreview.js";
8
+ import { anyAutoReview, capAutoReview } from "../core/autoreview.js";
9
9
  import { configPath, loadConfig, saveConfig } from "../core/config.js";
10
10
  import { formatBlockers, isBlocking, preflight } from "../core/preflight.js";
11
11
  import { withWriter } from "../core/history.js";
@@ -447,7 +447,7 @@ program
447
447
  .option("-H, --host <host>", "host to bind (0.0.0.0 for VPS — requires --token)", "127.0.0.1")
448
448
  .option("-t, --token <token>", "require this token on every request (env: CERBER_TOKEN)")
449
449
  .option("--no-poll", "don't poll GitHub for PRs awaiting your review (also disables auto-review)")
450
- .option("--no-auto-review", "list awaiting PRs but don't review them until you click review (repos set to true in daemon.autoReviewRepos still draft)")
450
+ .option("--no-auto-review", "list awaiting PRs but don't review them until you click review (per-repo exceptions included)")
451
451
  .option("--no-notify", "don't notify this machine when a review is ready for you")
452
452
  .option("-d, --daemon", "(deprecated no-op — polling and auto-review are now the default)")
453
453
  .option("-i, --interval <minutes>", "poll interval (default: config daemon.intervalMinutes, 5)")
@@ -485,7 +485,7 @@ program
485
485
  const d = config.daemon;
486
486
  // Trust means "run this PR's code". A human clicking review accepted that
487
487
  // per PR; auto-review does it unattended, on whatever lands in the queue.
488
- const drafting = anyAutoReview({ autoReview: opts.autoReview && d.autoReview, autoReviewRepos: d.autoReviewRepos });
488
+ const drafting = anyAutoReview(capAutoReview(d, opts.autoReview));
489
489
  if (opts.poll && d.poll && drafting && opts.trust && config.trust.length > 0) {
490
490
  console.log(`⚠ ${config.trust.length} trust rule(s) in ${configPath()}: unattended reviews will run commands from ` +
491
491
  `matching PRs, with nobody watching. Pass --no-trust to keep every review read-only, ` +
@@ -11,3 +11,23 @@ export function autoReviewFor(knobs, owner, repo) {
11
11
  export function anyAutoReview(knobs) {
12
12
  return knobs.autoReview || Object.values(knobs.autoReviewRepos).some(Boolean);
13
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
+ }
@@ -29,6 +29,18 @@ export const DaemonConfigSchema = z.object({
29
29
  */
30
30
  autoReviewRepos: z
31
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
+ })
32
44
  .default({}),
33
45
  /**
34
46
  * Tap this machine's notification centre when a PR is worth coming back for
@@ -1,6 +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 } from "../core/autoreview.js";
3
+ import { anyAutoReview, autoReviewFor, capAutoReview } from "../core/autoreview.js";
4
4
  import { loadConfig } from "../core/config.js";
5
5
  import { classifyReply, currentLogin, fetchConversation, fetchLastReviewRequest, fetchOwnReview, fetchPrInfo, fetchReviewRequests, lastMentionOfYou, lastWordOfYours, searchAwaitingMe, stillRequested, submitReview, } from "../core/gh.js";
6
6
  import { withWriter } from "../core/history.js";
@@ -728,10 +728,7 @@ export function startDaemon(opts) {
728
728
  */
729
729
  function applyKnobs(config) {
730
730
  const knobs = config.daemon;
731
- const autoReview = {
732
- autoReview: opts.autoReview && knobs.autoReview,
733
- autoReviewRepos: knobs.autoReviewRepos,
734
- };
731
+ const autoReview = capAutoReview(knobs, opts.autoReview);
735
732
  const drafts = (pr) => autoReviewFor(autoReview, pr.owner, pr.repo);
736
733
  status.pollEnabled = knobs.poll;
737
734
  // What the cockpit's bell defers to: a loop that isn't polling announces
@@ -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.1.0-pr.80.e038e96",
3
+ "version": "1.2.0",
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": [