co-maintainer 0.7.8-beta.1 → 0.7.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.7.8-beta.1",
3
+ "version": "0.7.8",
4
4
  "description": "An imitator of yours, A PR review tool like co-maintainer.",
5
5
  "keywords": [
6
6
  "ai",
@@ -406,7 +406,16 @@ async function editReviewGuides(provider, repo, ai, model, concurrency, facts, m
406
406
  return FULL;
407
407
  }
408
408
  const queue = new AiBatch(provider, repo, Math.max(1, concurrency), `${ai}:v3:${model}:guide`);
409
- const response = await uncut(queue, request, usage);
409
+ // An edit call that fails, for example on a context limit the size
410
+ // estimate missed, is not a failed sync: the guide is rewritten in full.
411
+ let response;
412
+ try {
413
+ response = await uncut(queue, request, usage);
414
+ }
415
+ catch (error) {
416
+ log("ai", `edit_guide failed (${error instanceof Error ? error.message : String(error)}), rewriting the guide in full`);
417
+ return FULL;
418
+ }
410
419
  if (response === CUT || !response) {
411
420
  log("ai", "edit_guide gave no usable answer, rewriting the guide in full");
412
421
  return FULL;
@@ -23,7 +23,7 @@ import { resolveConcurrency } from "./concurrency.js";
23
23
  import { closeAppDb, isAppDbOpen, openAppDb } from "../store/app_db.js";
24
24
  import { getRepo, markKnowledgeBuilt, registerCliRepo, } from "../store/repos.js";
25
25
  import { nowIso } from "../util/time.js";
26
- import { mkdir, readTextFile, remove, stat } from "../util/runtime.js";
26
+ import { isNotFound, mkdir, readTextFile, remove, stat, } from "../util/runtime.js";
27
27
  import { applyWatchNotes, withMaintainerNotes } from "./watch_notes.js";
28
28
  import { addResponseCost, emptyTally } from "../util/cost.js";
29
29
  import { costLabel } from "../util/run_summary.js";
@@ -304,16 +304,28 @@ export async function guideEditInput(options, previous, rules) {
304
304
  if (!findings || !rules)
305
305
  return undefined;
306
306
  const directory = `${reposDir()}/${options.repo}`;
307
- const read = (name) => readTextFile(`${directory}/${name}`).catch(() => undefined);
307
+ // Only a missing file means "no such guide". Any other read error rewrites
308
+ // in full, so the two guides are never edited apart.
309
+ const UNREADABLE = Symbol("unreadable");
310
+ const read = (name) => readTextFile(`${directory}/${name}`).catch((error) => isNotFound(error) ? undefined : UNREADABLE);
308
311
  const [guide, detailed] = await Promise.all([
309
312
  read("PR_REVIEW_GUIDE.md"),
310
313
  read("PR_REVIEW_DETAILED_GUIDE.md"),
311
314
  ]);
312
- if (!guide)
315
+ if (!guide || guide === UNREADABLE || detailed === UNREADABLE) {
313
316
  return undefined;
317
+ }
318
+ // The last build wrote a detailed guide that is gone now: rewrite in full.
319
+ const hadDetailed = Object.values(rules).some((rule) => rule.file === "PR_REVIEW_DETAILED_GUIDE.md");
320
+ if (hadDetailed && detailed === undefined)
321
+ return undefined;
322
+ // An empty guide file is not a guide to edit.
323
+ if (!guide.trim() || (detailed !== undefined && !detailed.trim())) {
324
+ return undefined;
325
+ }
314
326
  return {
315
327
  guide,
316
- ...(detailed ? { detailed } : {}),
328
+ ...(detailed !== undefined ? { detailed } : {}),
317
329
  rules,
318
330
  findings,
319
331
  ...(rewriteIfChanged ? { rewriteIfChanged: true } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "co-maintainer",
3
- "version": "0.7.8-beta.1",
3
+ "version": "0.7.8",
4
4
  "description": "An imitator of yours, A PR review tool like co-maintainer.",
5
5
  "keywords": [
6
6
  "ai",