@fullstackhouse/cerber 1.2.0-pr.81.58d1702 → 1.2.0-pr.81.f904d9c

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 CHANGED
@@ -165,7 +165,8 @@ need their URL pasted every time. Cerber never drafts one on its own and never
165
165
  taps you about one: press `r` when you want a self-review. Send posts it as a
166
166
  comment, since GitHub takes no approve or change request from a PR's author,
167
167
  and auto-send leaves it alone. Skip one to hide it; it leaves for good once it
168
- merges or closes.
168
+ merges or closes. PRs of yours idle for more than 30 days stay out
169
+ (`daemon.ownPrMaxAgeDays`; 0 turns that off).
169
170
 
170
171
  ### Settled means you settled it
171
172
 
@@ -148,6 +148,13 @@ export const PrInfoSchema = z.object({
148
148
  additions: z.number().int().default(0),
149
149
  deletions: z.number().int().default(0),
150
150
  changedFiles: z.number().int().default(0),
151
+ /**
152
+ * When the PR itself last changed on GitHub — not when cerber last wrote this
153
+ * file. On a row nobody has drafted, `updatedAt` is only when the poll found
154
+ * it, so this is what the queue shows and sorts by there. Optional: artifacts
155
+ * written before it existed load without it, and the poll fills it in.
156
+ */
157
+ updatedAt: z.string().optional(),
151
158
  });
152
159
  export const ArtifactStatusSchema = z.enum([
153
160
  "awaiting", // discovered, not yet reviewed by AI
@@ -53,6 +53,13 @@ export const DaemonConfigSchema = z.object({
53
53
  parallel: z.number().int().positive().default(3),
54
54
  /** Repos to watch (owner/repo). Empty = everything your gh account can see. */
55
55
  repos: z.array(z.string()).default([]),
56
+ /**
57
+ * Your own PRs with no activity for longer than this many days are left out
58
+ * of the inbox — applied in the author search itself (`updated:>=`), so they
59
+ * never arrive and never take a slot of its 50. 0 or null turns the cut off.
60
+ * Your own PRs only: a review somebody asked you for is never aged out.
61
+ */
62
+ ownPrMaxAgeDays: z.number().int().nonnegative().nullable().default(30),
56
63
  });
57
64
  export const ConfigSchema = z.object({
58
65
  /** Whose PRs may be reviewed by running code. See core/trust.ts for syntax. */
package/dist/core/gh.js CHANGED
@@ -45,7 +45,7 @@ export async function fetchPrInfo(ref) {
45
45
  "--repo",
46
46
  `${ref.owner}/${ref.repo}`,
47
47
  "--json",
48
- "title,url,author,body,baseRefName,headRefName,headRefOid,additions,deletions,changedFiles,state,isDraft",
48
+ "title,url,author,body,baseRefName,headRefName,headRefOid,additions,deletions,changedFiles,state,isDraft,updatedAt",
49
49
  ]);
50
50
  const raw = JSON.parse(out);
51
51
  return PrInfoSchema.parse({
@@ -64,6 +64,7 @@ export async function fetchPrInfo(ref) {
64
64
  additions: raw.additions ?? 0,
65
65
  deletions: raw.deletions ?? 0,
66
66
  changedFiles: raw.changedFiles ?? 0,
67
+ updatedAt: raw.updatedAt ?? undefined,
67
68
  });
68
69
  }
69
70
  /**
@@ -535,13 +536,15 @@ export async function fetchPriorRemarks(ref, people) {
535
536
  * every time. Both are the same search with one flag changed, so they cannot
536
537
  * drift apart on what "open" means or which repos are read-only.
537
538
  */
538
- export function searchPrsArgs(search, repoFilter, limit = 50) {
539
+ export function searchPrsArgs(search, repoFilter, limit = 50, updatedSince = null) {
539
540
  const args = [
540
541
  "search",
541
542
  "prs",
542
543
  // An archived repo is read-only: its PRs can never merge, close, or take a
543
544
  // review. Without this they'd sit in the inbox forever — nothing retires them.
544
545
  "archived:false",
546
+ // Only the author search is ever given one (`ownPrUpdatedSince`).
547
+ ...(updatedSince ? [`updated:>=${updatedSince}`] : []),
545
548
  `--${search}=@me`,
546
549
  "--state=open",
547
550
  "--limit",
@@ -563,10 +566,23 @@ export async function searchAwaitingMe(repoFilter, limit = 50) {
563
566
  * Open PRs the current gh user opened, drafts included. They come to the inbox
564
567
  * to be reviewed on demand and never automatically — see `isOwnPr` (`own.ts`).
565
568
  */
566
- export async function searchAuthoredByMe(repoFilter, limit = 50) {
567
- const out = await gh(searchPrsArgs("author", repoFilter, limit));
569
+ export async function searchAuthoredByMe(repoFilter, updatedSince = null, limit = 50) {
570
+ const out = await gh(searchPrsArgs("author", repoFilter, limit, updatedSince));
568
571
  return mapSearchResults(JSON.parse(out));
569
572
  }
573
+ /**
574
+ * The day your own PRs must have been active on or after to come into the
575
+ * inbox (`daemon.ownPrMaxAgeDays`), as GitHub's `updated:>=` reads it — or null
576
+ * for no cut. A PR of yours nobody has touched in months is not one you are
577
+ * about to self-review, and fifty of them would fill the search's whole page.
578
+ * A calendar day in UTC: GitHub's qualifier takes a date, and a day either way
579
+ * at the edge changes nothing anyone would notice.
580
+ */
581
+ export function ownPrUpdatedSince(days, now = new Date()) {
582
+ if (!days)
583
+ return null;
584
+ return new Date(now.getTime() - days * 86_400_000).toISOString().slice(0, 10);
585
+ }
570
586
  /**
571
587
  * Who this repo will let you put on a PR — the list behind the handoff's
572
588
  * suggestions.
@@ -2,7 +2,7 @@ import { SCHEMA_VERSION, artifactId, artifactKey } from "../core/artifact.js";
2
2
  import { evaluateAutoSend } from "../core/autosend.js";
3
3
  import { anyAutoReview, autoReviewFor, capAutoReview } from "../core/autoreview.js";
4
4
  import { loadConfig } from "../core/config.js";
5
- import { classifyReply, currentLogin, fetchConversation, fetchLastReviewRequest, fetchOwnReview, fetchPrInfo, fetchReviewRequests, lastMentionOfYou, lastWordOfYours, searchAuthoredByMe, searchAwaitingMe, stillRequested, submitReview, } from "../core/gh.js";
5
+ import { classifyReply, currentLogin, fetchConversation, fetchLastReviewRequest, fetchOwnReview, fetchPrInfo, fetchReviewRequests, lastMentionOfYou, lastWordOfYours, ownPrUpdatedSince, searchAuthoredByMe, searchAwaitingMe, stillRequested, submitReview, } from "../core/gh.js";
6
6
  import { withWriter } from "../core/history.js";
7
7
  import { isOwnPr } from "../core/own.js";
8
8
  import { pendingNews, notice, notify } from "../core/notify.js";
@@ -61,6 +61,7 @@ export function stubArtifact(ref, own = false) {
61
61
  headSha: "",
62
62
  state: "OPEN",
63
63
  isDraft: ref.isDraft,
64
+ updatedAt: ref.updatedAt,
64
65
  additions: 0,
65
66
  deletions: 0,
66
67
  changedFiles: 0,
@@ -287,13 +288,17 @@ export function startDaemon(opts) {
287
288
  * PR decides nothing — a team you are on can be requested on your own PR,
288
289
  * and `isOwnPr` reads the author either way.
289
290
  */
290
- async function discover(me) {
291
+ async function discover(me, ownPrMaxAgeDays) {
291
292
  const filters = opts.repos.length > 0 ? opts.repos : [undefined];
293
+ // Your own PRs only: a review request is never aged out. One that went
294
+ // stale leaves the search, and the reaper below drops its stub like any
295
+ // other the search stopped returning — a draft of yours stays put.
296
+ const since = ownPrUpdatedSince(ownPrMaxAgeDays);
292
297
  const [awaiting, authored] = await Promise.all([
293
298
  Promise.all(filters.map((repo) => searchAwaitingMe(repo))),
294
299
  me === null
295
300
  ? Promise.resolve(null)
296
- : Promise.all(filters.map((repo) => searchAuthoredByMe(repo))).catch((err) => {
301
+ : Promise.all(filters.map((repo) => searchAuthoredByMe(repo, since))).catch((err) => {
297
302
  log(`could not search for your own PRs: ${err instanceof Error ? err.message : String(err)}`);
298
303
  return null;
299
304
  }),
@@ -452,10 +457,22 @@ export function startDaemon(opts) {
452
457
  // predate a draft→ready flip. Refresh from it — it costs nothing, it's
453
458
  // already in hand — or the queue keeps calling a ready PR a draft until
454
459
  // something happens to re-review it.
455
- if (existing.pr.isDraft !== ref.isDraft) {
460
+ //
461
+ // The PR's last activity is refreshed only on a row nobody has drafted,
462
+ // the one place the queue reads it (`activityAt`). Every write bumps the
463
+ // artifact's own `updatedAt`, and on a drafted row that is the review's
464
+ // date: refreshing there would re-date every draft by the poll each time
465
+ // its PR saw a comment, which is the meaningless date this field exists
466
+ // to replace — and would race an open review's refresh besides.
467
+ const activity = existing.status === "awaiting" && existing.pr.updatedAt !== ref.updatedAt;
468
+ if (existing.pr.isDraft !== ref.isDraft || activity) {
456
469
  await updateArtifactByKey(artifactKey(existing.id), (a) => ({
457
470
  ...a,
458
- pr: { ...a.pr, isDraft: ref.isDraft },
471
+ pr: {
472
+ ...a.pr,
473
+ isDraft: ref.isDraft,
474
+ updatedAt: a.status === "awaiting" ? ref.updatedAt : a.pr.updatedAt,
475
+ },
459
476
  }));
460
477
  }
461
478
  continue;
@@ -844,7 +861,7 @@ export function startDaemon(opts) {
844
861
  status.lastSummary = "polling off (settings) — the queue only shows what you review by hand";
845
862
  return;
846
863
  }
847
- const { refs, ownSearched } = await discover(me);
864
+ const { refs, ownSearched } = await discover(me, knobs.ownPrMaxAgeDays);
848
865
  // Your own PRs are synced into the queue with the rest, but nobody is
849
866
  // asking you for them: they are not "awaiting" in anything the strip
850
867
  // counts, and the cockpit's open-requests tab — "GitHub still lists you
@@ -280,6 +280,9 @@ export async function buildApp(opts) {
280
280
  number: a.pr.number,
281
281
  state: a.pr.state,
282
282
  isDraft: a.pr.isDraft,
283
+ // When the PR itself last changed — what an undrafted row is dated
284
+ // and sorted by in the queue (`activityAt`).
285
+ updatedAt: a.pr.updatedAt,
283
286
  additions: a.pr.additions,
284
287
  deletions: a.pr.deletions,
285
288
  changedFiles: a.pr.changedFiles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullstackhouse/cerber",
3
- "version": "1.2.0-pr.81.58d1702",
3
+ "version": "1.2.0-pr.81.f904d9c",
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": [