@staff0rd/assist 0.1067.0 → 0.1069.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/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.1067.0",
9
+ version: "0.1069.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -2419,23 +2419,23 @@ function phaseUsageTotals(orm) {
2419
2419
  }
2420
2420
 
2421
2421
  // src/commands/backlog/rowToItemSummary.ts
2422
- function rowToItemSummary(row3) {
2422
+ function rowToItemSummary(row2) {
2423
2423
  return {
2424
- id: row3.id,
2425
- origin: row3.origin,
2426
- type: row3.type,
2427
- name: row3.name,
2428
- status: row3.status,
2429
- starred: row3.starred,
2430
- jiraKey: row3.jiraKey ?? void 0,
2431
- githubIssue: row3.githubIssue ?? void 0,
2432
- currentPhase: row3.currentPhase ?? void 0,
2433
- totalPhases: (row3.planPhaseCount || 1) + 1,
2434
- usageTotal: row3.tokensUp == null ? void 0 : {
2435
- tokensUp: Number(row3.tokensUp),
2436
- tokensDown: Number(row3.tokensDown),
2437
- activeMs: Number(row3.activeMs),
2438
- peakContextPct: Number(row3.peakContextPct ?? 0)
2424
+ id: row2.id,
2425
+ origin: row2.origin,
2426
+ type: row2.type,
2427
+ name: row2.name,
2428
+ status: row2.status,
2429
+ starred: row2.starred,
2430
+ jiraKey: row2.jiraKey ?? void 0,
2431
+ githubIssue: row2.githubIssue ?? void 0,
2432
+ currentPhase: row2.currentPhase ?? void 0,
2433
+ totalPhases: (row2.planPhaseCount || 1) + 1,
2434
+ usageTotal: row2.tokensUp == null ? void 0 : {
2435
+ tokensUp: Number(row2.tokensUp),
2436
+ tokensDown: Number(row2.tokensDown),
2437
+ activeMs: Number(row2.activeMs),
2438
+ peakContextPct: Number(row2.peakContextPct ?? 0)
2439
2439
  }
2440
2440
  };
2441
2441
  }
@@ -2573,9 +2573,9 @@ function itemColumns(item, origin) {
2573
2573
 
2574
2574
  // src/commands/backlog/insertItem.ts
2575
2575
  async function insertItem(db, item, origin) {
2576
- const [row3] = await db.insert(items).values(itemColumns(item, origin)).returning({ id: items.id });
2577
- if (!row3) throw new Error("Failed to insert backlog item");
2578
- return row3.id;
2576
+ const [row2] = await db.insert(items).values(itemColumns(item, origin)).returning({ id: items.id });
2577
+ if (!row2) throw new Error("Failed to insert backlog item");
2578
+ return row2.id;
2579
2579
  }
2580
2580
 
2581
2581
  // src/commands/backlog/insertPlan.ts
@@ -2667,10 +2667,10 @@ import { asc as asc3, eq as eq2 } from "drizzle-orm";
2667
2667
  // src/commands/backlog/groupByItem.ts
2668
2668
  function groupByItem(rows) {
2669
2669
  const map = /* @__PURE__ */ new Map();
2670
- for (const row3 of rows) {
2671
- const bucket = map.get(row3.itemId);
2672
- if (bucket) bucket.push(row3);
2673
- else map.set(row3.itemId, [row3]);
2670
+ for (const row2 of rows) {
2671
+ const bucket = map.get(row2.itemId);
2672
+ if (bucket) bucket.push(row2);
2673
+ else map.set(row2.itemId, [row2]);
2674
2674
  }
2675
2675
  return map;
2676
2676
  }
@@ -2767,11 +2767,11 @@ function attachSessions(item, rel, id) {
2767
2767
  // src/commands/backlog/sumPhaseUsage.ts
2768
2768
  function sumPhaseUsage(usage) {
2769
2769
  return usage.reduce(
2770
- (total3, u) => ({
2771
- tokensUp: total3.tokensUp + u.tokensUp,
2772
- tokensDown: total3.tokensDown + u.tokensDown,
2773
- activeMs: total3.activeMs + u.activeMs,
2774
- peakContextPct: Math.max(total3.peakContextPct, u.peakContextPct)
2770
+ (total2, u) => ({
2771
+ tokensUp: total2.tokensUp + u.tokensUp,
2772
+ tokensDown: total2.tokensDown + u.tokensDown,
2773
+ activeMs: total2.activeMs + u.activeMs,
2774
+ peakContextPct: Math.max(total2.peakContextPct, u.peakContextPct)
2775
2775
  }),
2776
2776
  { tokensUp: 0, tokensDown: 0, activeMs: 0, peakContextPct: 0 }
2777
2777
  );
@@ -2832,23 +2832,23 @@ function rowToComment(c) {
2832
2832
  function rowToLink(l) {
2833
2833
  return { type: l.type, targetId: l.targetId };
2834
2834
  }
2835
- function assignOptionalColumns(item, row3) {
2836
- if (row3.description != null) item.description = row3.description;
2837
- if (row3.currentPhase != null) item.currentPhase = row3.currentPhase;
2838
- if (row3.jiraKey != null) item.jiraKey = row3.jiraKey;
2839
- if (row3.githubIssue != null) item.githubIssue = row3.githubIssue;
2835
+ function assignOptionalColumns(item, row2) {
2836
+ if (row2.description != null) item.description = row2.description;
2837
+ if (row2.currentPhase != null) item.currentPhase = row2.currentPhase;
2838
+ if (row2.jiraKey != null) item.jiraKey = row2.jiraKey;
2839
+ if (row2.githubIssue != null) item.githubIssue = row2.githubIssue;
2840
2840
  }
2841
- function baseItem(row3) {
2841
+ function baseItem(row2) {
2842
2842
  const item = {
2843
- id: row3.id,
2844
- type: row3.type,
2845
- name: row3.name,
2846
- acceptanceCriteria: JSON.parse(row3.acceptanceCriteria),
2847
- status: row3.status,
2848
- starred: row3.starred,
2849
- origin: row3.origin
2850
- };
2851
- assignOptionalColumns(item, row3);
2843
+ id: row2.id,
2844
+ type: row2.type,
2845
+ name: row2.name,
2846
+ acceptanceCriteria: JSON.parse(row2.acceptanceCriteria),
2847
+ status: row2.status,
2848
+ starred: row2.starred,
2849
+ origin: row2.origin
2850
+ };
2851
+ assignOptionalColumns(item, row2);
2852
2852
  return item;
2853
2853
  }
2854
2854
  function attachComments(item, rel, id) {
@@ -2863,14 +2863,14 @@ function attachPlan(item, rel, id) {
2863
2863
  const phases = rel.phases.get(id) ?? [];
2864
2864
  if (phases.length > 0) item.plan = buildPlan(phases, rel.tasks.get(id) ?? []);
2865
2865
  }
2866
- function rowToItem(row3, rel) {
2867
- const item = baseItem(row3);
2868
- attachComments(item, rel, row3.id);
2869
- attachLinks(item, rel, row3.id);
2870
- attachPlan(item, rel, row3.id);
2871
- attachUsage(item, rel, row3.id);
2872
- attachSessions(item, rel, row3.id);
2873
- attachGitRefs(item, rel, row3.id);
2866
+ function rowToItem(row2, rel) {
2867
+ const item = baseItem(row2);
2868
+ attachComments(item, rel, row2.id);
2869
+ attachLinks(item, rel, row2.id);
2870
+ attachPlan(item, rel, row2.id);
2871
+ attachUsage(item, rel, row2.id);
2872
+ attachSessions(item, rel, row2.id);
2873
+ attachGitRefs(item, rel, row2.id);
2874
2874
  return item;
2875
2875
  }
2876
2876
 
@@ -2883,7 +2883,7 @@ async function loadAllItems(orm, origin) {
2883
2883
  rows.map((r) => r.id),
2884
2884
  { includeComments: false, includeTasks: false }
2885
2885
  );
2886
- return rows.map((row3) => rowToItem(row3, rel));
2886
+ return rows.map((row2) => rowToItem(row2, rel));
2887
2887
  }
2888
2888
 
2889
2889
  // src/commands/backlog/parseBacklogJsonl.ts
@@ -3556,7 +3556,7 @@ async function readAppliedIds(exec3) {
3556
3556
  const rows = await exec3.query(
3557
3557
  `SELECT id FROM ${APPLIED_MIGRATIONS_TABLE} ORDER BY id`
3558
3558
  );
3559
- return new Set(rows.map((row3) => Number(row3.id)));
3559
+ return new Set(rows.map((row2) => Number(row2.id)));
3560
3560
  }
3561
3561
  async function applyMigrations(exec3) {
3562
3562
  await exec3.exec(CREATE_APPLIED_MIGRATIONS);
@@ -3597,7 +3597,7 @@ async function readAppliedIds2(exec3) {
3597
3597
  const rows = await exec3.query(
3598
3598
  `SELECT id FROM ${APPLIED_MIGRATIONS_TABLE} ORDER BY id`
3599
3599
  );
3600
- return rows.map((row3) => Number(row3.id));
3600
+ return rows.map((row2) => Number(row2.id));
3601
3601
  }
3602
3602
  async function getMigrationStatus(exec3) {
3603
3603
  return compareMigrations(await readAppliedIds2(exec3));
@@ -3731,8 +3731,8 @@ async function closeDb() {
3731
3731
  // src/commands/backlog/deleteItem.ts
3732
3732
  import { eq as eq5 } from "drizzle-orm";
3733
3733
  async function deleteItem(orm, id) {
3734
- const [row3] = await orm.delete(items).where(eq5(items.id, id)).returning({ name: items.name });
3735
- return row3?.name;
3734
+ const [row2] = await orm.delete(items).where(eq5(items.id, id)).returning({ name: items.name });
3735
+ return row2?.name;
3736
3736
  }
3737
3737
 
3738
3738
  // src/commands/backlog/formatItemId.ts
@@ -3784,13 +3784,13 @@ function getBacklogDir() {
3784
3784
  // src/commands/backlog/loadItem.ts
3785
3785
  import { eq as eq6 } from "drizzle-orm";
3786
3786
  async function loadItem(orm, id) {
3787
- const [row3] = await orm.select().from(items).where(eq6(items.id, id));
3788
- if (!row3) return void 0;
3787
+ const [row2] = await orm.select().from(items).where(eq6(items.id, id));
3788
+ if (!row2) return void 0;
3789
3789
  const rel = await loadRelations(orm, [id], {
3790
3790
  includeUsage: true,
3791
3791
  includeGitRefs: true
3792
3792
  });
3793
- return rowToItem(row3, rel);
3793
+ return rowToItem(row2, rel);
3794
3794
  }
3795
3795
 
3796
3796
  // src/commands/backlog/saveAllItems.ts
@@ -4037,10 +4037,10 @@ async function queueDocsRefresh(orm, origin, threshold) {
4037
4037
 
4038
4038
  // src/commands/backlog/updateStatus.ts
4039
4039
  async function updateStatus(orm, id, status2) {
4040
- const [row3] = await orm.update(items).set({ status: status2 }).where(eq15(items.id, id)).returning({ name: items.name, origin: items.origin, type: items.type });
4041
- if (row3 && status2 === "done" && row3.type === "story")
4042
- await maybeQueueDocsRefresh(orm, row3.origin);
4043
- return row3?.name;
4040
+ const [row2] = await orm.update(items).set({ status: status2 }).where(eq15(items.id, id)).returning({ name: items.name, origin: items.origin, type: items.type });
4041
+ if (row2 && status2 === "done" && row2.type === "story")
4042
+ await maybeQueueDocsRefresh(orm, row2.origin);
4043
+ return row2?.name;
4044
4044
  }
4045
4045
  async function maybeQueueDocsRefresh(orm, origin) {
4046
4046
  const threshold = docsRefreshAfter();
@@ -4438,8 +4438,8 @@ async function postNoteSession(req, res) {
4438
4438
  // src/commands/backlog/updateStarred.ts
4439
4439
  import { eq as eq16 } from "drizzle-orm";
4440
4440
  async function updateStarred(orm, id, starred) {
4441
- const [row3] = await orm.update(items).set({ starred }).where(eq16(items.id, id)).returning({ name: items.name });
4442
- return row3?.name;
4441
+ const [row2] = await orm.update(items).set({ starred }).where(eq16(items.id, id)).returning({ name: items.name });
4442
+ return row2?.name;
4443
4443
  }
4444
4444
 
4445
4445
  // src/commands/backlog/loadBacklogSummaries.ts
@@ -4845,10 +4845,10 @@ async function listCommitRefs(db, itemId2) {
4845
4845
  title: itemGitRefs.title,
4846
4846
  url: itemGitRefs.url
4847
4847
  }).from(itemGitRefs).where(and7(eq18(itemGitRefs.itemId, itemId2), eq18(itemGitRefs.kind, "commit"))).orderBy(asc8(itemGitRefs.createdAt), asc8(itemGitRefs.ref));
4848
- return rows.map((row3) => ({
4849
- sha: row3.ref,
4850
- ...row3.title ? { title: row3.title } : {},
4851
- ...row3.url ? { url: row3.url } : {}
4848
+ return rows.map((row2) => ({
4849
+ sha: row2.ref,
4850
+ ...row2.title ? { title: row2.title } : {},
4851
+ ...row2.url ? { url: row2.url } : {}
4852
4852
  }));
4853
4853
  }
4854
4854
 
@@ -7696,9 +7696,9 @@ async function gitStatus(req, res) {
7696
7696
  // src/commands/backlog/deleteComment.ts
7697
7697
  import { and as and8, eq as eq19 } from "drizzle-orm";
7698
7698
  async function deleteComment(orm, itemId2, commentId) {
7699
- const [row3] = await orm.select({ type: comments.type }).from(comments).where(and8(eq19(comments.id, commentId), eq19(comments.itemId, itemId2)));
7700
- if (!row3) return "not-found";
7701
- if (row3.type === "summary") return "is-summary";
7699
+ const [row2] = await orm.select({ type: comments.type }).from(comments).where(and8(eq19(comments.id, commentId), eq19(comments.itemId, itemId2)));
7700
+ if (!row2) return "not-found";
7701
+ if (row2.type === "summary") return "is-summary";
7702
7702
  await orm.delete(comments).where(and8(eq19(comments.id, commentId), eq19(comments.itemId, itemId2)));
7703
7703
  return "deleted";
7704
7704
  }
@@ -9012,8 +9012,8 @@ async function historySearch(req, res) {
9012
9012
  import { eq as eq21 } from "drizzle-orm";
9013
9013
  var INBOX_LAST_SCAN_KEY = "inbox.lastScanAt";
9014
9014
  async function readInboxLastScan(orm) {
9015
- const [row3] = await orm.select().from(metadata).where(eq21(metadata.key, INBOX_LAST_SCAN_KEY));
9016
- return row3 ? new Date(row3.value) : void 0;
9015
+ const [row2] = await orm.select().from(metadata).where(eq21(metadata.key, INBOX_LAST_SCAN_KEY));
9016
+ return row2 ? new Date(row2.value) : void 0;
9017
9017
  }
9018
9018
 
9019
9019
  // src/commands/sessions/web/inbox/inboxStatus.ts
@@ -9051,13 +9051,13 @@ async function listInbox(_req, res) {
9051
9051
  respondJson(
9052
9052
  res,
9053
9053
  200,
9054
- rows.map((row3) => ({
9055
- id: inboxMessageKey(row3.source, row3.messageId),
9056
- source: row3.source,
9057
- sender: row3.sender,
9058
- summary: row3.summary,
9059
- link: row3.link,
9060
- receivedAt: (row3.receivedAt ?? row3.flaggedAt).toISOString()
9054
+ rows.map((row2) => ({
9055
+ id: inboxMessageKey(row2.source, row2.messageId),
9056
+ source: row2.source,
9057
+ sender: row2.sender,
9058
+ summary: row2.summary,
9059
+ link: row2.link,
9060
+ receivedAt: (row2.receivedAt ?? row2.flaggedAt).toISOString()
9061
9061
  }))
9062
9062
  );
9063
9063
  }
@@ -10197,8 +10197,8 @@ function listScopedRules(req, res) {
10197
10197
  // src/shared/db/countUsagePeaks.ts
10198
10198
  import { count, eq as eq22 } from "drizzle-orm";
10199
10199
  async function countUsagePeaks(db, window) {
10200
- const [row3] = await db.select({ value: count() }).from(usagePeaks).where(window ? eq22(usagePeaks.window, window) : void 0);
10201
- return row3?.value ?? 0;
10200
+ const [row2] = await db.select({ value: count() }).from(usagePeaks).where(window ? eq22(usagePeaks.window, window) : void 0);
10201
+ return row2?.value ?? 0;
10202
10202
  }
10203
10203
 
10204
10204
  // src/shared/db/listUsagePeaks.ts
@@ -10290,11 +10290,11 @@ function listUsageHistory(req, res) {
10290
10290
  return respondPagedRows(req, res, async (range, params) => {
10291
10291
  const window = parseWindow(params.get("window"));
10292
10292
  const db = await getDb();
10293
- const [rows, total3] = await Promise.all([
10293
+ const [rows, total2] = await Promise.all([
10294
10294
  listUsagePeaks(db, { ...range, window }),
10295
10295
  countUsagePeaks(db, window)
10296
10296
  ]);
10297
- return { rows, total: total3 };
10297
+ return { rows, total: total2 };
10298
10298
  });
10299
10299
  }
10300
10300
 
@@ -10303,7 +10303,7 @@ import { asc as asc9, desc as desc5, eq as eq24, sql as sql20 } from "drizzle-or
10303
10303
  async function countItemUsageByOrigin(db) {
10304
10304
  const count10 = sql20`count(distinct ${phaseUsage.itemId})::int`;
10305
10305
  const rows = await db.select({ origin: items.origin, count: count10 }).from(items).innerJoin(phaseUsage, eq24(phaseUsage.itemId, items.id)).groupBy(items.origin).orderBy(desc5(count10), asc9(items.origin));
10306
- return rows.map((row3) => ({ origin: row3.origin, count: Number(row3.count) }));
10306
+ return rows.map((row2) => ({ origin: row2.origin, count: Number(row2.count) }));
10307
10307
  }
10308
10308
 
10309
10309
  // src/shared/db/itemUsageWhere.ts
@@ -10350,7 +10350,7 @@ function median(value) {
10350
10350
  async function itemUsageStats(db, options2) {
10351
10351
  const totals = phaseUsageTotals(db);
10352
10352
  const planned = planPhaseCounts(db);
10353
- const [row3] = await db.select({
10353
+ const [row2] = await db.select({
10354
10354
  itemCount: sql21`count(*)::int`,
10355
10355
  doneCount: sql21`count(*) filter (where ${items.status} = 'done')::int`,
10356
10356
  repoCount: sql21`count(distinct ${items.origin})::int`,
@@ -10361,12 +10361,12 @@ async function itemUsageStats(db, options2) {
10361
10361
  medianTokens: median(sql21`${totals.tokensUp} + ${totals.tokensDown}`)
10362
10362
  }).from(items).innerJoin(totals, eq26(totals.itemId, items.id)).leftJoin(planned, eq26(planned.itemId, items.id)).where(itemUsageWhere(options2));
10363
10363
  return {
10364
- itemCount: Number(row3?.itemCount ?? 0),
10365
- doneCount: Number(row3?.doneCount ?? 0),
10366
- repoCount: Number(row3?.repoCount ?? 0),
10367
- medianPhases: Number(row3?.medianPhases ?? 0),
10368
- medianActiveMs: Number(row3?.medianActiveMs ?? 0),
10369
- medianTokens: Number(row3?.medianTokens ?? 0)
10364
+ itemCount: Number(row2?.itemCount ?? 0),
10365
+ doneCount: Number(row2?.doneCount ?? 0),
10366
+ repoCount: Number(row2?.repoCount ?? 0),
10367
+ medianPhases: Number(row2?.medianPhases ?? 0),
10368
+ medianActiveMs: Number(row2?.medianActiveMs ?? 0),
10369
+ medianTokens: Number(row2?.medianTokens ?? 0)
10370
10370
  };
10371
10371
  }
10372
10372
 
@@ -10401,16 +10401,16 @@ function lastPhaseActivity(db) {
10401
10401
  }
10402
10402
 
10403
10403
  // src/shared/db/toItemUsageSummary.ts
10404
- function toItemUsageSummary(row3) {
10404
+ function toItemUsageSummary(row2) {
10405
10405
  return {
10406
- ...row3,
10407
- phaseCount: row3.phaseCount ?? 0,
10408
- recordedPhases: Number(row3.recordedPhases),
10409
- tokensUp: Number(row3.tokensUp),
10410
- tokensDown: Number(row3.tokensDown),
10411
- activeMs: Number(row3.activeMs),
10412
- peakContextPct: Number(row3.peakContextPct),
10413
- lastPhaseAt: row3.lastPhaseAt ?? null
10406
+ ...row2,
10407
+ phaseCount: row2.phaseCount ?? 0,
10408
+ recordedPhases: Number(row2.recordedPhases),
10409
+ tokensUp: Number(row2.tokensUp),
10410
+ tokensDown: Number(row2.tokensDown),
10411
+ activeMs: Number(row2.activeMs),
10412
+ peakContextPct: Number(row2.peakContextPct),
10413
+ lastPhaseAt: row2.lastPhaseAt ?? null
10414
10414
  };
10415
10415
  }
10416
10416
 
@@ -10480,8 +10480,8 @@ async function jobRunTotals(db, since) {
10480
10480
  db.select({ kind: jobRuns.kind, startedAt: jobRuns.startedAt }).from(jobRuns).where(and12(inWindow, eq28(jobRuns.status, "failed"))).orderBy(desc7(jobRuns.startedAt)).limit(1)
10481
10481
  ]);
10482
10482
  return {
10483
- runs: byKind.reduce((sum3, row3) => sum3 + row3.runs, 0),
10484
- runsByKind: Object.fromEntries(byKind.map((row3) => [row3.kind, row3.runs])),
10483
+ runs: byKind.reduce((sum3, row2) => sum3 + row2.runs, 0),
10484
+ runsByKind: Object.fromEntries(byKind.map((row2) => [row2.kind, row2.runs])),
10485
10485
  ...sums,
10486
10486
  lastFailure: lastFailure ?? null
10487
10487
  };
@@ -10494,11 +10494,11 @@ async function listJobRuns(db, range, filters = {}) {
10494
10494
  filters.kind ? eq29(jobRuns.kind, filters.kind) : void 0,
10495
10495
  filters.trigger ? eq29(jobRuns.trigger, filters.trigger) : void 0
10496
10496
  );
10497
- const [rows, [{ total: total3 }]] = await Promise.all([
10497
+ const [rows, [{ total: total2 }]] = await Promise.all([
10498
10498
  db.select().from(jobRuns).where(where).orderBy(desc8(jobRuns.startedAt), desc8(jobRuns.id)).limit(range.limit).offset(range.offset),
10499
10499
  db.select({ total: count3() }).from(jobRuns).where(where)
10500
10500
  ]);
10501
- return { rows, total: total3 };
10501
+ return { rows, total: total2 };
10502
10502
  }
10503
10503
 
10504
10504
  // src/shared/db/failStaleJobRuns.ts
@@ -12675,7 +12675,7 @@ function globalOnlyRepoKeyError(key, verb) {
12675
12675
  // src/shared/db/listRepoConfigs.ts
12676
12676
  async function listRepoConfigs(orm) {
12677
12677
  const rows = await orm.select().from(repoConfigs);
12678
- return Object.fromEntries(rows.map((row3) => [row3.repoKey, row3.config]));
12678
+ return Object.fromEntries(rows.map((row2) => [row2.repoKey, row2.config]));
12679
12679
  }
12680
12680
 
12681
12681
  // src/shared/resolveNamedRepoWriteLabel.ts
@@ -12725,8 +12725,8 @@ async function saveRepoConfig(orm, repoKey, config) {
12725
12725
 
12726
12726
  // src/shared/db/readUserConfig.ts
12727
12727
  async function readUserConfig(orm) {
12728
- const [row3] = await orm.select().from(userConfig);
12729
- return row3?.config ?? {};
12728
+ const [row2] = await orm.select().from(userConfig);
12729
+ return row2?.config ?? {};
12730
12730
  }
12731
12731
 
12732
12732
  // src/shared/writeRepoConfigCache.ts
@@ -12776,8 +12776,8 @@ async function applySharedRepoConfigSet(key, coerced, repoName, cwd = process.cw
12776
12776
  import { eq as eq32 } from "drizzle-orm";
12777
12777
  async function updateUserConfig(orm, update4) {
12778
12778
  return orm.transaction(async (tx) => {
12779
- const [row3] = await tx.select().from(userConfig).where(eq32(userConfig.id, 1)).for("update");
12780
- const outcome = update4(row3?.config ?? {});
12779
+ const [row2] = await tx.select().from(userConfig).where(eq32(userConfig.id, 1)).for("update");
12780
+ const outcome = update4(row2?.config ?? {});
12781
12781
  if (!outcome.ok) return outcome;
12782
12782
  if (Object.keys(outcome.config).length === 0) {
12783
12783
  await tx.delete(userConfig).where(eq32(userConfig.id, 1));
@@ -15465,19 +15465,19 @@ function printMeasureTable(records, totalMs) {
15465
15465
  const nameWidth = Math.max(
15466
15466
  "Command".length,
15467
15467
  "TOTAL".length,
15468
- ...rows.map((row3) => row3.name.length)
15468
+ ...rows.map((row2) => row2.name.length)
15469
15469
  );
15470
15470
  const durationWidth = Math.max(
15471
15471
  "Duration".length,
15472
15472
  formatDuration(totalMs).length,
15473
- ...rows.map((row3) => row3.duration.length)
15473
+ ...rows.map((row2) => row2.duration.length)
15474
15474
  );
15475
15475
  const line = (status2, name, duration) => ` ${status2.padEnd(6)} ${name.padEnd(nameWidth)} ${duration.padStart(durationWidth)}`;
15476
15476
  const separator = ` ${" ".repeat(6)} ${"\u2500".repeat(nameWidth)} ${"\u2500".repeat(durationWidth)}`;
15477
15477
  console.log();
15478
15478
  console.log(line("Status", "Command", "Duration"));
15479
- for (const row3 of rows) {
15480
- console.log(line(row3.status, row3.name, row3.duration));
15479
+ for (const row2 of rows) {
15480
+ console.log(line(row2.status, row2.name, row2.duration));
15481
15481
  }
15482
15482
  console.log(separator);
15483
15483
  console.log(line("", "TOTAL", formatDuration(totalMs)));
@@ -16045,9 +16045,9 @@ async function activity(options2) {
16045
16045
  console.log("Not enough data points to chart.");
16046
16046
  return;
16047
16047
  }
16048
- const total3 = data.reduce((sum3, d) => sum3 + d.count, 0);
16048
+ const total2 = data.reduce((sum3, d) => sum3 + d.count, 0);
16049
16049
  const activeDays = data.filter((d) => d.count > 0).length;
16050
- console.log(`${total3} commits across ${activeDays} active days.`);
16050
+ console.log(`${total2} commits across ${activeDays} active days.`);
16051
16051
  const weekly = /* @__PURE__ */ new Map();
16052
16052
  for (const { date, count: count10 } of data) {
16053
16053
  const d = new Date(date);
@@ -18249,10 +18249,10 @@ var IDENTITY_SQL = `
18249
18249
  `;
18250
18250
  async function introspectIdentityColumns(client) {
18251
18251
  const { rows } = await client.query(IDENTITY_SQL);
18252
- return rows.map((row3) => ({
18253
- table: row3.table,
18254
- column: row3.column,
18255
- rawColumn: row3.raw_column
18252
+ return rows.map((row2) => ({
18253
+ table: row2.table,
18254
+ column: row2.column,
18255
+ rawColumn: row2.raw_column
18256
18256
  }));
18257
18257
  }
18258
18258
  function resyncIdentitySql(col) {
@@ -18306,10 +18306,10 @@ async function importBacklog(file, options2 = {}) {
18306
18306
  return;
18307
18307
  }
18308
18308
  await restore(client, parsed);
18309
- const total3 = incoming.reduce((sum3, n) => sum3 + n, 0);
18309
+ const total2 = incoming.reduce((sum3, n) => sum3 + n, 0);
18310
18310
  console.error(
18311
18311
  chalk54.green(
18312
- `Imported backlog: ${total3} rows restored across ${tables.length} tables.`
18312
+ `Imported backlog: ${total2} rows restored across ${tables.length} tables.`
18313
18313
  )
18314
18314
  );
18315
18315
  });
@@ -21350,8 +21350,8 @@ async function adjustCurrentPhase(db, item, removedIdx) {
21350
21350
  return;
21351
21351
  }
21352
21352
  if (removedIdx !== currentIdx) return;
21353
- const [row3] = await db.select({ cnt: count6() }).from(planPhases).where(eq46(planPhases.itemId, item.id));
21354
- const cnt = row3?.cnt ?? 0;
21353
+ const [row2] = await db.select({ cnt: count6() }).from(planPhases).where(eq46(planPhases.itemId, item.id));
21354
+ const cnt = row2?.cnt ?? 0;
21355
21355
  await db.update(items).set({ currentPhase: cnt === 0 ? null : Math.min(currentPhase, cnt) }).where(eq46(items.id, item.id));
21356
21356
  }
21357
21357
 
@@ -21404,8 +21404,8 @@ async function movePhase(id, from, to) {
21404
21404
  if (!found) return;
21405
21405
  const { orm, item } = found;
21406
21406
  const itemId2 = item.id;
21407
- const [row3] = await orm.select({ cnt: count7() }).from(planPhases).where(eq48(planPhases.itemId, itemId2));
21408
- const phaseCount = row3?.cnt ?? 0;
21407
+ const [row2] = await orm.select({ cnt: count7() }).from(planPhases).where(eq48(planPhases.itemId, itemId2));
21408
+ const phaseCount = row2?.cnt ?? 0;
21409
21409
  const fromIdx = toIndex2(from, phaseCount);
21410
21410
  if (fromIdx === void 0) return;
21411
21411
  const toIdx = toIndex2(to, phaseCount);
@@ -21460,8 +21460,8 @@ async function findPhase(id, phase) {
21460
21460
  const { orm, item } = found;
21461
21461
  const itemId2 = item.id;
21462
21462
  const phaseIdx = Number.parseInt(phase, 10) - 1;
21463
- const [row3] = await orm.select({ cnt: count8() }).from(planPhases).where(and22(eq50(planPhases.itemId, itemId2), eq50(planPhases.idx, phaseIdx)));
21464
- if (!row3 || row3.cnt === 0) {
21463
+ const [row2] = await orm.select({ cnt: count8() }).from(planPhases).where(and22(eq50(planPhases.itemId, itemId2), eq50(planPhases.idx, phaseIdx)));
21464
+ if (!row2 || row2.cnt === 0) {
21465
21465
  console.log(
21466
21466
  chalk101.red(
21467
21467
  `Phase ${phaseIdx + 1} not found on item ${formatItemId(itemId2)}.`
@@ -22412,7 +22412,7 @@ import { and as and25, eq as eq54 } from "drizzle-orm";
22412
22412
  import { and as and24, eq as eq53, notInArray as notInArray2, sql as sql26 } from "drizzle-orm";
22413
22413
  async function hasOpenPhaseUnlock(itemId2, kind) {
22414
22414
  const orm = await getDb();
22415
- const [row3] = await orm.select({ itemId: itemGitRefs.itemId }).from(itemGitRefs).innerJoin(items, eq53(items.id, itemGitRefs.itemId)).where(
22415
+ const [row2] = await orm.select({ itemId: itemGitRefs.itemId }).from(itemGitRefs).innerJoin(items, eq53(items.id, itemGitRefs.itemId)).where(
22416
22416
  and24(
22417
22417
  eq53(itemGitRefs.itemId, itemId2),
22418
22418
  eq53(itemGitRefs.kind, kind),
@@ -22423,14 +22423,14 @@ async function hasOpenPhaseUnlock(itemId2, kind) {
22423
22423
  notInArray2(items.status, ["done", "wontdo"])
22424
22424
  )
22425
22425
  ).limit(1);
22426
- return row3 !== void 0;
22426
+ return row2 !== void 0;
22427
22427
  }
22428
22428
 
22429
22429
  // src/commands/backlog/isDocsLocked.ts
22430
22430
  async function isDocsRefreshItem(itemId2) {
22431
22431
  const orm = await getDb();
22432
- const [row3] = await orm.select({ itemId: links.itemId }).from(links).where(and25(eq54(links.itemId, itemId2), eq54(links.type, "docs-refresh"))).limit(1);
22433
- return row3 !== void 0;
22432
+ const [row2] = await orm.select({ itemId: links.itemId }).from(links).where(and25(eq54(links.itemId, itemId2), eq54(links.type, "docs-refresh"))).limit(1);
22433
+ return row2 !== void 0;
22434
22434
  }
22435
22435
  async function isDocsLocked() {
22436
22436
  if (docsRefreshAfter() === void 0) return false;
@@ -25623,10 +25623,10 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
25623
25623
  const color = exceedsThreshold ? chalk130.red : chalk130.white;
25624
25624
  console.log(`${color(file)} \u2192 ${chalk130.cyan(lines2)} lines`);
25625
25625
  }
25626
- const total3 = results.reduce((sum3, r) => sum3 + r.lines, 0);
25626
+ const total2 = results.reduce((sum3, r) => sum3 + r.lines, 0);
25627
25627
  console.log(
25628
25628
  chalk130.dim(`
25629
- Total: ${total3} lines across ${files.length} files`)
25629
+ Total: ${total2} lines across ${files.length} files`)
25630
25630
  );
25631
25631
  if (hasViolation) {
25632
25632
  process.exit(1);
@@ -26023,8 +26023,8 @@ function matching(filter) {
26023
26023
  const needle = filter.toLowerCase();
26024
26024
  return (leaf) => leaf.key.toLowerCase().includes(needle);
26025
26025
  }
26026
- function headline(shown, total3, filter) {
26027
- return filter ? chalk140.bold(`${shown} of ${total3} config keys matching "${filter}"`) : chalk140.bold(`${total3} config keys`);
26026
+ function headline(shown, total2, filter) {
26027
+ return filter ? chalk140.bold(`${shown} of ${total2} config keys matching "${filter}"`) : chalk140.bold(`${total2} config keys`);
26028
26028
  }
26029
26029
  function formatLeaf(leaf, help) {
26030
26030
  const meta = [typeText(leaf), `default: ${formatConfigDefault(leaf)}`];
@@ -26261,15 +26261,15 @@ function registerConfig(program) {
26261
26261
  import chalk148 from "chalk";
26262
26262
 
26263
26263
  // src/commands/browser/formatInspectMatches.ts
26264
- function formatInspectMatches({ matches, total: total3 }, query) {
26265
- if (total3 === 0) return [`no elements match ${query}`];
26264
+ function formatInspectMatches({ matches, total: total2 }, query) {
26265
+ if (total2 === 0) return [`no elements match ${query}`];
26266
26266
  const lines2 = matches.flatMap((match, index3) => [
26267
- `[${index3 + 1}/${total3}] ${match.width}\xD7${match.height} ${JSON.stringify(match.text)}`,
26267
+ `[${index3 + 1}/${total2}] ${match.width}\xD7${match.height} ${JSON.stringify(match.text)}`,
26268
26268
  ...match.chain.map((step3) => ` ${step3}`)
26269
26269
  ]);
26270
- if (total3 > matches.length)
26270
+ if (total2 > matches.length)
26271
26271
  lines2.push(
26272
- `showing the first ${matches.length} of ${total3} matches; narrow the query to see the rest`
26272
+ `showing the first ${matches.length} of ${total2} matches; narrow the query to see the rest`
26273
26273
  );
26274
26274
  return lines2;
26275
26275
  }
@@ -26793,8 +26793,8 @@ async function findRetiredTables(exec3) {
26793
26793
  [RETIRED_TABLES]
26794
26794
  );
26795
26795
  const found = [];
26796
- for (const row3 of present) {
26797
- const name = String(row3.table_name);
26796
+ for (const row2 of present) {
26797
+ const name = String(row2.table_name);
26798
26798
  const [count10] = await exec3.query(
26799
26799
  `SELECT count(*)::int AS rows FROM "${name}"`
26800
26800
  );
@@ -27532,9 +27532,9 @@ function colorStatus(status2) {
27532
27532
  if (status2 === "outdated") return chalk165.yellow(status2);
27533
27533
  return chalk165.green(status2);
27534
27534
  }
27535
- function formatRow(row3, nameWidth) {
27536
- const week = (row3.lastWeek ?? "-").padEnd(9);
27537
- return `${row3.name.padEnd(nameWidth)} ${row3.lastPush} ${week} ${colorStatus(row3.status)}`;
27535
+ function formatRow(row2, nameWidth) {
27536
+ const week = (row2.lastWeek ?? "-").padEnd(9);
27537
+ return `${row2.name.padEnd(nameWidth)} ${row2.lastPush} ${week} ${colorStatus(row2.status)}`;
27538
27538
  }
27539
27539
  function printReposTable(rows) {
27540
27540
  const nameWidth = Math.max(4, ...rows.map((r) => r.name.length));
@@ -27546,8 +27546,8 @@ function printReposTable(rows) {
27546
27546
  ].join(" ");
27547
27547
  console.log(chalk165.dim(header));
27548
27548
  console.log(chalk165.dim("-".repeat(header.length)));
27549
- for (const row3 of rows) {
27550
- console.log(formatRow(row3, nameWidth));
27549
+ for (const row2 of rows) {
27550
+ console.log(formatRow(row2, nameWidth));
27551
27551
  }
27552
27552
  }
27553
27553
 
@@ -28614,25 +28614,49 @@ function commentWords(comment3) {
28614
28614
  return comment3.toLowerCase().split(/[^a-z0-9]+/).filter((word) => word.length > 0);
28615
28615
  }
28616
28616
 
28617
+ // src/commands/editHook/widenToLines.ts
28618
+ function widenToLines(content, oldString, newString) {
28619
+ const start2 = oldString === "" ? -1 : content.indexOf(oldString);
28620
+ if (start2 < 0) return { removed: oldString, added: newString };
28621
+ const end = start2 + oldString.length;
28622
+ const lineStart = content.lastIndexOf("\n", start2 - 1) + 1;
28623
+ const newline = content.indexOf("\n", end);
28624
+ const lineEnd = newline === -1 ? content.length : newline;
28625
+ const prefix2 = content.slice(lineStart, start2);
28626
+ const suffix = content.slice(end, lineEnd);
28627
+ return {
28628
+ removed: prefix2 + oldString + suffix,
28629
+ added: prefix2 + newString + suffix
28630
+ };
28631
+ }
28632
+
28617
28633
  // src/commands/editHook/partitionStrings.ts
28618
28634
  function defined(values) {
28619
28635
  return values.filter((value) => value != null);
28620
28636
  }
28637
+ function widenEdits(edits, existingContent) {
28638
+ let content = existingContent;
28639
+ const pairs = [];
28640
+ for (const { old_string, new_string } of edits) {
28641
+ if (content == null || old_string == null || new_string == null) {
28642
+ pairs.push({ removed: old_string, added: new_string });
28643
+ continue;
28644
+ }
28645
+ pairs.push(widenToLines(content, old_string, new_string));
28646
+ content = content.replace(old_string, () => new_string);
28647
+ }
28648
+ return {
28649
+ added: defined(pairs.map((p) => p.added)),
28650
+ removed: defined(pairs.map((p) => p.removed))
28651
+ };
28652
+ }
28621
28653
  function partitionStrings(input, existingContent) {
28622
28654
  const { tool_name, tool_input } = input;
28623
28655
  switch (tool_name) {
28624
28656
  case "Edit":
28625
- return {
28626
- added: defined([tool_input.new_string]),
28627
- removed: defined([tool_input.old_string])
28628
- };
28629
- case "MultiEdit": {
28630
- const edits = tool_input.edits ?? [];
28631
- return {
28632
- added: defined(edits.map((e) => e.new_string)),
28633
- removed: defined(edits.map((e) => e.old_string))
28634
- };
28635
- }
28657
+ return widenEdits([tool_input], existingContent);
28658
+ case "MultiEdit":
28659
+ return widenEdits(tool_input.edits ?? [], existingContent);
28636
28660
  case "Write":
28637
28661
  return {
28638
28662
  added: defined([tool_input.content]),
@@ -29150,9 +29174,14 @@ function extractRustCommentTexts(text20) {
29150
29174
  }
29151
29175
 
29152
29176
  // src/commands/editHook/extractYamlComments.ts
29177
+ var SHA_PINNED_USES = /^\s*(?:-\s+)?uses:\s*\S+@[0-9a-f]{40}\s+$/i;
29153
29178
  function blankNonNewline2(text20) {
29154
29179
  return text20.replace(/[^\n]/g, " ");
29155
29180
  }
29181
+ function isShaPinVersionComment(work, index3) {
29182
+ const lineStart = work.lastIndexOf("\n", index3 - 1) + 1;
29183
+ return SHA_PINNED_USES.test(work.slice(lineStart, index3));
29184
+ }
29156
29185
  function extractYamlComments(text20) {
29157
29186
  const work = text20.replace(
29158
29187
  /"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g,
@@ -29160,6 +29189,8 @@ function extractYamlComments(text20) {
29160
29189
  );
29161
29190
  const comments3 = [];
29162
29191
  for (const match of work.matchAll(/(?:^|\s)(#.*)/gm)) {
29192
+ const hashIndex = match.index + match[0].length - match[1].length;
29193
+ if (isShaPinVersionComment(work, hashIndex)) continue;
29163
29194
  comments3.push(match[1]);
29164
29195
  }
29165
29196
  return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0);
@@ -29291,7 +29322,7 @@ function readExisting(filePath) {
29291
29322
  async function editHook() {
29292
29323
  const input = tryParseInput2(await readStdin());
29293
29324
  if (!input) return;
29294
- const existing = input.tool_name === "Write" ? readExisting(input.tool_input.file_path) : void 0;
29325
+ const existing = readExisting(input.tool_input.file_path);
29295
29326
  const reason4 = decideOverrideGuard(input, existing) ?? decideCommentGuard(input, existing) ?? await decideSchemaGuard(input) ?? await decideDocsGuard(input);
29296
29327
  if (!reason4) return;
29297
29328
  console.log(
@@ -29411,13 +29442,13 @@ import chalk182 from "chalk";
29411
29442
  function printCountTable(labelHeader, rows) {
29412
29443
  const labelWidth = Math.max(
29413
29444
  labelHeader.length,
29414
- ...rows.map((row3) => row3.label.length)
29445
+ ...rows.map((row2) => row2.label.length)
29415
29446
  );
29416
29447
  const header = `${labelHeader.padEnd(labelWidth)} Commits`;
29417
29448
  console.log(chalk182.dim(header));
29418
29449
  console.log(chalk182.dim("-".repeat(header.length)));
29419
- for (const row3 of rows) {
29420
- console.log(`${row3.label.padEnd(labelWidth)} ${row3.count}`);
29450
+ for (const row2 of rows) {
29451
+ console.log(`${row2.label.padEnd(labelWidth)} ${row2.count}`);
29421
29452
  }
29422
29453
  }
29423
29454
 
@@ -29747,7 +29778,7 @@ function buildFixStructurePlan(issues, options2) {
29747
29778
  tooDeep,
29748
29779
  typeChangeCount: entries.filter((entry) => entry.typeChange).length,
29749
29780
  labelRemovalCount: entries.reduce(
29750
- (total3, entry) => total3 + entry.labelRemovals.length,
29781
+ (total2, entry) => total2 + entry.labelRemovals.length,
29751
29782
  0
29752
29783
  )
29753
29784
  };
@@ -30156,8 +30187,8 @@ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".webm", ".mov"]);
30156
30187
  function cell(text20) {
30157
30188
  return text20.replaceAll("|", String.raw`\|`);
30158
30189
  }
30159
- function row(cells2) {
30160
- return `| ${cells2.join(" | ")} |`;
30190
+ function row(cells) {
30191
+ return `| ${cells.join(" | ")} |`;
30161
30192
  }
30162
30193
  function imageTable(images) {
30163
30194
  if (images.length === 0) return [];
@@ -30434,17 +30465,6 @@ function resolveIssueMilestone(target, wanted) {
30434
30465
 
30435
30466
  // src/commands/prs/shared.ts
30436
30467
  import { execSync as execSync42 } from "child_process";
30437
-
30438
- // src/commands/prs/pinCurrentPr.ts
30439
- var pinnedPr;
30440
- function getPinnedPr() {
30441
- return pinnedPr;
30442
- }
30443
- function currentPrSelector(currentBranch7) {
30444
- return pinnedPr === void 0 ? currentBranch7() : String(pinnedPr);
30445
- }
30446
-
30447
- // src/commands/prs/shared.ts
30448
30468
  function isGhNotInstalled(error) {
30449
30469
  if (error instanceof Error) {
30450
30470
  const msg = error.message.toLowerCase();
@@ -30469,7 +30489,7 @@ function viewCurrentPr(fields) {
30469
30489
  const { org, repo } = getRepoInfo();
30470
30490
  return JSON.parse(
30471
30491
  execSync42(
30472
- `gh pr view ${currentPrSelector(getCurrentBranch2)} --json ${fields} -R ${org}/${repo}`,
30492
+ `gh pr view ${getCurrentBranch2()} --json ${fields} -R ${org}/${repo}`,
30473
30493
  {
30474
30494
  encoding: "utf8"
30475
30495
  }
@@ -31466,14 +31486,14 @@ async function scanUnopenedThreads(threadIds, scanThreads, onEvent = () => {
31466
31486
  // src/commands/inbox/scanInboxWithCoverage.ts
31467
31487
  async function scanInboxWithCoverage(since, listener) {
31468
31488
  const runs = [];
31469
- const total3 = () => runs.reduce(addScanUsage, emptyScanUsage());
31489
+ const total2 = () => runs.reduce(addScanUsage, emptyScanUsage());
31470
31490
  const run4 = (pass) => {
31471
31491
  const slot = runs.push(emptyScanUsage()) - 1;
31472
31492
  return runInboxScanClaude(pass, {
31473
31493
  ...listener,
31474
31494
  onUsage: (usage) => {
31475
31495
  runs[slot] = usage;
31476
- listener.onUsage?.(total3());
31496
+ listener.onUsage?.(total2());
31477
31497
  }
31478
31498
  });
31479
31499
  };
@@ -31490,7 +31510,7 @@ async function scanInboxWithCoverage(since, listener) {
31490
31510
  }),
31491
31511
  listener.onEvent
31492
31512
  );
31493
- return { messages: [...main.messages, ...followUp], usage: total3() };
31513
+ return { messages: [...main.messages, ...followUp], usage: total2() };
31494
31514
  }
31495
31515
 
31496
31516
  // src/shared/db/finishJobRun.ts
@@ -31501,8 +31521,8 @@ async function finishJobRun(db, id, result) {
31501
31521
 
31502
31522
  // src/shared/db/startJobRun.ts
31503
31523
  async function startJobRun(db, run4) {
31504
- const [row3] = await db.insert(jobRuns).values({ ...run4, status: "running" }).returning({ id: jobRuns.id });
31505
- return row3.id;
31524
+ const [row2] = await db.insert(jobRuns).values({ ...run4, status: "running" }).returning({ id: jobRuns.id });
31525
+ return row2.id;
31506
31526
  }
31507
31527
 
31508
31528
  // src/commands/inbox/withInboxScanJob.ts
@@ -34274,12 +34294,12 @@ function printPromptsTable(rows) {
34274
34294
  ].join(" ");
34275
34295
  console.log(chalk205.dim(header));
34276
34296
  console.log(chalk205.dim("-".repeat(header.length)));
34277
- for (const row3 of rows) {
34278
- const count10 = String(row3.count).padStart(countWidth);
34279
- const tool = row3.tool.padEnd(toolWidth);
34280
- const command = truncate2(row3.command, 60).padEnd(commandWidth);
34297
+ for (const row2 of rows) {
34298
+ const count10 = String(row2.count).padStart(countWidth);
34299
+ const tool = row2.tool.padEnd(toolWidth);
34300
+ const command = truncate2(row2.command, 60).padEnd(commandWidth);
34281
34301
  console.log(
34282
- `${chalk205.yellow(count10)} ${tool} ${command} ${chalk205.dim(row3.repos)}`
34302
+ `${chalk205.yellow(count10)} ${tool} ${command} ${chalk205.dim(row2.repos)}`
34283
34303
  );
34284
34304
  }
34285
34305
  }
@@ -34351,17 +34371,17 @@ function getPageSlice(pullRequests, page) {
34351
34371
  const start2 = page * PAGE_SIZE2;
34352
34372
  return pullRequests.slice(start2, start2 + PAGE_SIZE2);
34353
34373
  }
34354
- function pageHeader(page, totalPages, total3) {
34374
+ function pageHeader(page, totalPages, total2) {
34355
34375
  return `
34356
- Page ${page + 1} of ${totalPages} (${total3} total)
34376
+ Page ${page + 1} of ${totalPages} (${total2} total)
34357
34377
  `;
34358
34378
  }
34359
34379
  function displayPage(pullRequests, totalPages, page) {
34360
34380
  console.log(pageHeader(page, totalPages, pullRequests.length));
34361
34381
  for (const pr of getPageSlice(pullRequests, page)) printPr(pr);
34362
34382
  }
34363
- function hasNextPage(page, total3) {
34364
- return page < total3 - 1;
34383
+ function hasNextPage(page, total2) {
34384
+ return page < total2 - 1;
34365
34385
  }
34366
34386
  var NEXT_CHOICE = { name: "Next page", value: "next" };
34367
34387
  var PREV_CHOICE = { name: "Previous page", value: "prev" };
@@ -34660,7 +34680,7 @@ function findPrForBranch(repo, branch2) {
34660
34680
  return Number.parseInt(stdout.trim(), 10);
34661
34681
  }
34662
34682
  function currentAzureDevopsPr(repo) {
34663
- const prId = getPinnedPr() ?? findPrForBranch(repo, getCurrentBranch2());
34683
+ const prId = findPrForBranch(repo, getCurrentBranch2());
34664
34684
  if (Number.isNaN(prId)) {
34665
34685
  console.error("Error: No pull request found for the current branch.");
34666
34686
  process.exit(1);
@@ -36569,11 +36589,11 @@ function parseReadBudget(value) {
36569
36589
  `Invalid budget "${value}". Use a duration like 45s, 1m30s or 2m.`
36570
36590
  );
36571
36591
  }
36572
- const total3 = Number(minutes ?? 0) * 60 + Number(seconds ?? 0);
36573
- if (total3 === 0) {
36592
+ const total2 = Number(minutes ?? 0) * 60 + Number(seconds ?? 0);
36593
+ if (total2 === 0) {
36574
36594
  throw new Error(`Invalid budget "${value}". Value must be at least 1s.`);
36575
36595
  }
36576
- return total3;
36596
+ return total2;
36577
36597
  }
36578
36598
 
36579
36599
  // src/commands/readTime/resolveReadTimeTarget.ts
@@ -36705,12 +36725,12 @@ import chalk215 from "chalk";
36705
36725
 
36706
36726
  // src/shared/createConnectionAuth.ts
36707
36727
  import chalk210 from "chalk";
36708
- function listConnections(connections, format3) {
36728
+ function listConnections(connections, format2) {
36709
36729
  if (connections.length === 0) {
36710
36730
  console.log("No connections configured.");
36711
36731
  } else {
36712
36732
  for (const c of connections) {
36713
- console.log(format3(c));
36733
+ console.log(format2(c));
36714
36734
  }
36715
36735
  }
36716
36736
  }
@@ -40830,7 +40850,7 @@ function basename24(path109) {
40830
40850
  return path109.slice(path109.lastIndexOf("/") + 1);
40831
40851
  }
40832
40852
  function sum(nodes, key) {
40833
- return nodes.reduce((total3, node) => total3 + node[key], 0);
40853
+ return nodes.reduce((total2, node) => total2 + node[key], 0);
40834
40854
  }
40835
40855
  function byName(a, b) {
40836
40856
  return a.name.localeCompare(b.name);
@@ -40874,7 +40894,7 @@ function buildHighLevelTree(files) {
40874
40894
 
40875
40895
  // src/commands/review/highLevel/buildHighLevelStructure.ts
40876
40896
  function sum2(files, key) {
40877
- return files.reduce((total3, file) => total3 + file[key], 0);
40897
+ return files.reduce((total2, file) => total2 + file[key], 0);
40878
40898
  }
40879
40899
  function countOf(files, status2) {
40880
40900
  return files.filter((file) => file.status === status2).length;
@@ -41038,7 +41058,7 @@ var EVIDENCE_PATTERNS = [
41038
41058
  ];
41039
41059
  function countEvidence(body) {
41040
41060
  return EVIDENCE_PATTERNS.reduce(
41041
- (total3, pattern2) => total3 + (body.match(pattern2)?.length ?? 0),
41061
+ (total2, pattern2) => total2 + (body.match(pattern2)?.length ?? 0),
41042
41062
  0
41043
41063
  );
41044
41064
  }
@@ -41606,12 +41626,12 @@ function visitCase(call, context) {
41606
41626
  if (!context.changed) return [toCase(call, context)];
41607
41627
  const lines2 = changedLines(call, context.changed);
41608
41628
  if (lines2.length === 0) return [];
41609
- const total3 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
41629
+ const total2 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
41610
41630
  return [
41611
41631
  toCase(
41612
41632
  call,
41613
41633
  context,
41614
- lines2.length === total3 ? { change: "added" } : { change: "modified", changedLines: lines2 }
41634
+ lines2.length === total2 ? { change: "added" } : { change: "modified", changedLines: lines2 }
41615
41635
  )
41616
41636
  ];
41617
41637
  }
@@ -42388,455 +42408,6 @@ async function runHighLevelReview(number, options2 = {}) {
42388
42408
  // src/commands/review/reviewPr.ts
42389
42409
  import { basename as basename26 } from "path";
42390
42410
 
42391
- // src/commands/review/ci/writeJobSummary.ts
42392
- import { appendFileSync as appendFileSync3, readFileSync as readFileSync57 } from "fs";
42393
-
42394
- // src/commands/review/carriedUnanchoredFindings.ts
42395
- function carriedUnanchoredFindings(unanchored) {
42396
- return unanchored.filter((finding) => finding.source !== "already-raised");
42397
- }
42398
-
42399
- // src/commands/review/parseFindings.ts
42400
- var SEVERITIES = ["blocker", "major", "minor", "nit"];
42401
- var SOURCES = [
42402
- "confirmed",
42403
- "disputed",
42404
- "claude-only",
42405
- "codex-only",
42406
- "already-raised"
42407
- ];
42408
- function isSeverity(value) {
42409
- return SEVERITIES.includes(value);
42410
- }
42411
- function isSource(value) {
42412
- return SOURCES.includes(value);
42413
- }
42414
- function extractField(block, field) {
42415
- const re = new RegExp(`^-\\s+${field}:\\s*(.*)$`, "im");
42416
- const match = block.match(re);
42417
- return match ? match[1].trim() : "";
42418
- }
42419
- function stripBackticks(value) {
42420
- return value.replace(/^`+|`+$/g, "").trim();
42421
- }
42422
- function parseFindingBlock(block) {
42423
- const newlineIndex = block.indexOf("\n");
42424
- const title = newlineIndex === -1 ? block.trim() : block.slice(0, newlineIndex).trim();
42425
- const body = newlineIndex === -1 ? "" : block.slice(newlineIndex + 1);
42426
- const severityRaw = extractField(body, "Severity").toLowerCase();
42427
- const sourceRaw = extractField(body, "Source").toLowerCase();
42428
- return {
42429
- title,
42430
- severity: isSeverity(severityRaw) ? severityRaw : null,
42431
- source: isSource(sourceRaw) ? sourceRaw : null,
42432
- location: stripBackticks(extractField(body, "Location")),
42433
- impact: extractField(body, "Impact"),
42434
- recommendation: extractField(body, "Recommendation")
42435
- };
42436
- }
42437
- function parseFindings(markdown) {
42438
- return markdown.split(/^###\s+Finding:\s*/m).slice(1).map(parseFindingBlock);
42439
- }
42440
-
42441
- // src/commands/review/summariseSynthesis.ts
42442
- var SEVERITIES2 = ["blocker", "major", "minor", "nit"];
42443
- function isSeverity2(value) {
42444
- return SEVERITIES2.includes(value);
42445
- }
42446
- function extractSummary(markdown) {
42447
- const match = markdown.match(
42448
- /^##\s+Summary\s*\n([\s\S]*?)(?=\n##\s|\n###\s|$)/m
42449
- );
42450
- if (!match) return "";
42451
- return match[1].trim();
42452
- }
42453
- function countBySeverity(markdown) {
42454
- const totals = { blocker: 0, major: 0, minor: 0, nit: 0 };
42455
- const regex = /^-\s+Severity:\s*([a-zA-Z]+)/gm;
42456
- for (const match of markdown.matchAll(regex)) {
42457
- const severity = match[1].toLowerCase();
42458
- if (isSeverity2(severity)) totals[severity]++;
42459
- }
42460
- return totals;
42461
- }
42462
- function summariseSynthesis(markdown) {
42463
- const totals = countBySeverity(markdown);
42464
- const findingCount = totals.blocker + totals.major + totals.minor + totals.nit;
42465
- return { summary: extractSummary(markdown), totals, findingCount };
42466
- }
42467
- function formatSynthesisSummary(summary) {
42468
- const lines2 = [];
42469
- const { totals, findingCount } = summary;
42470
- lines2.push(
42471
- `Findings: ${findingCount} (blocker ${totals.blocker}, major ${totals.major}, minor ${totals.minor}, nit ${totals.nit})`
42472
- );
42473
- if (summary.summary) lines2.push("", summary.summary);
42474
- return lines2.join("\n");
42475
- }
42476
-
42477
- // src/commands/review/buildReviewSummary.ts
42478
- var UNANCHOR_REASONS = {
42479
- "out-of-diff": "its line falls outside the PR diff",
42480
- unlocated: "it has no parseable file:line",
42481
- "comment-rejected": "GitHub rejected its line comment"
42482
- };
42483
- function formatFindingLine(finding) {
42484
- const severity = finding.severity ?? "finding";
42485
- return `- **${severity}: ${finding.title}**`;
42486
- }
42487
- function formatLocation(finding) {
42488
- const location = finding.location.trim();
42489
- if (!location || location.toLowerCase() === "n/a") return "no location";
42490
- return `\`${location}\``;
42491
- }
42492
- function formatUnanchoredFinding(finding) {
42493
- const lines2 = [
42494
- `${formatFindingLine(finding)} \u2014 ${formatLocation(finding)}`,
42495
- ` - Not anchored: ${UNANCHOR_REASONS[finding.reason]}`
42496
- ];
42497
- if (finding.impact) lines2.push(` - Impact: ${finding.impact}`);
42498
- if (finding.recommendation)
42499
- lines2.push(` - Recommendation: ${finding.recommendation}`);
42500
- return lines2;
42501
- }
42502
- function buildReviewSummary(markdown, unanchored = []) {
42503
- const summary = summariseSynthesis(markdown);
42504
- const findings2 = parseFindings(markdown);
42505
- const lines2 = ["## Code review summary", "", formatSynthesisSummary(summary)];
42506
- if (findings2.length > 0) {
42507
- lines2.push("", "### Findings", "");
42508
- for (const finding of findings2) lines2.push(formatFindingLine(finding));
42509
- }
42510
- const carried = carriedUnanchoredFindings(unanchored);
42511
- if (carried.length > 0) {
42512
- lines2.push(
42513
- "",
42514
- "### Findings not anchored to the diff",
42515
- "",
42516
- "No line comment could be attached to these, so the detail is here instead.",
42517
- ""
42518
- );
42519
- for (const finding of carried)
42520
- lines2.push(...formatUnanchoredFinding(finding));
42521
- }
42522
- return lines2.join("\n");
42523
- }
42524
-
42525
- // src/commands/review/partitionFindings.ts
42526
- function isValidLine(n) {
42527
- return Number.isInteger(n) && n >= 1;
42528
- }
42529
- function toLineBound(finding) {
42530
- if (!finding.location || finding.location.toLowerCase() === "n/a") {
42531
- return null;
42532
- }
42533
- const match = finding.location.match(/^(.+):(\d+)(?:-(\d+))?$/);
42534
- if (!match) return null;
42535
- const startLine = Number.parseInt(match[2], 10);
42536
- const endLine = match[3] ? Number.parseInt(match[3], 10) : startLine;
42537
- if (!isValidLine(startLine) || !isValidLine(endLine)) return null;
42538
- if (endLine < startLine) return null;
42539
- const base = { ...finding, file: match[1], line: endLine };
42540
- return startLine === endLine ? base : { ...base, startLine };
42541
- }
42542
- function partitionFindings(findings2) {
42543
- const lineBound = [];
42544
- const unlocated = [];
42545
- const alreadyRaised = [];
42546
- for (const finding of findings2) {
42547
- if (finding.source === "already-raised") {
42548
- alreadyRaised.push(finding);
42549
- continue;
42550
- }
42551
- const bound = toLineBound(finding);
42552
- if (bound) lineBound.push(bound);
42553
- else unlocated.push(finding);
42554
- }
42555
- return { lineBound, unlocated, alreadyRaised };
42556
- }
42557
-
42558
- // src/commands/review/buildDiffLineIndex.ts
42559
- var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
42560
- var HUNK_HEADER3 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
42561
- function buildDiffLineIndex(diff3) {
42562
- const index3 = /* @__PURE__ */ new Map();
42563
- let currentFile = null;
42564
- let newLine = 0;
42565
- for (const line of diff3.split("\n")) {
42566
- const fileMatch = line.match(FILE_HEADER);
42567
- if (fileMatch) {
42568
- currentFile = fileMatch[1] === "/dev/null" ? null : fileMatch[1];
42569
- continue;
42570
- }
42571
- const hunkMatch = line.match(HUNK_HEADER3);
42572
- if (hunkMatch) {
42573
- newLine = Number(hunkMatch[1]);
42574
- continue;
42575
- }
42576
- if (currentFile === null) continue;
42577
- if (line.startsWith("-")) continue;
42578
- if (line.startsWith("+") || line.startsWith(" ")) {
42579
- let set = index3.get(currentFile);
42580
- if (!set) {
42581
- set = /* @__PURE__ */ new Set();
42582
- index3.set(currentFile, set);
42583
- }
42584
- set.add(newLine);
42585
- newLine++;
42586
- }
42587
- }
42588
- return index3;
42589
- }
42590
-
42591
- // src/commands/review/fetchPrDiff.ts
42592
- import { execSync as execSync58 } from "child_process";
42593
- function fetchPrDiff(prNumber, baseSha, headSha) {
42594
- const { org, repo } = getRepoInfo();
42595
- try {
42596
- return execSync58(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
42597
- encoding: "utf8",
42598
- maxBuffer: 256 * 1024 * 1024,
42599
- stdio: ["ignore", "pipe", "pipe"]
42600
- });
42601
- } catch (error) {
42602
- if (!isDiffTooLarge(error)) throw error;
42603
- return fetchDiffViaGit(baseSha, headSha);
42604
- }
42605
- }
42606
- function isDiffTooLarge(error) {
42607
- return error instanceof Error && (error.message.includes("too_large") || error.message.includes("maximum number of files"));
42608
- }
42609
- function fetchDiffViaGit(baseSha, headSha) {
42610
- try {
42611
- execSync58(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
42612
- } catch {
42613
- }
42614
- return execSync58(`git diff ${baseSha}...${headSha}`, {
42615
- encoding: "utf8",
42616
- maxBuffer: 256 * 1024 * 1024
42617
- });
42618
- }
42619
-
42620
- // src/commands/review/partitionFindingsByDiff.ts
42621
- function isWithinDiff(finding, index3) {
42622
- const lines2 = index3.get(finding.file);
42623
- if (!lines2) return false;
42624
- if (!lines2.has(finding.line)) return false;
42625
- if (finding.startLine !== void 0 && !lines2.has(finding.startLine)) {
42626
- return false;
42627
- }
42628
- return true;
42629
- }
42630
- function partitionFindingsByDiff(findings2, index3) {
42631
- const inDiff = [];
42632
- const outOfDiff = [];
42633
- for (const finding of findings2) {
42634
- if (isWithinDiff(finding, index3)) inDiff.push(finding);
42635
- else outOfDiff.push(finding);
42636
- }
42637
- return { inDiff, outOfDiff };
42638
- }
42639
-
42640
- // src/commands/review/warnOutOfDiff.ts
42641
- import chalk261 from "chalk";
42642
- function warnOutOfDiff(outOfDiff) {
42643
- if (outOfDiff.length === 0) return;
42644
- console.warn(
42645
- chalk261.yellow(
42646
- `Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
42647
- )
42648
- );
42649
- for (const finding of outOfDiff) {
42650
- const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
42651
- console.warn(
42652
- ` ${chalk261.yellow("\xB7")} ${finding.title} ${chalk261.dim(
42653
- `(${finding.file}:${range})`
42654
- )}`
42655
- );
42656
- }
42657
- }
42658
-
42659
- // src/commands/review/selectInDiffFindings.ts
42660
- function selectInDiffFindings(lineBound, prDiff) {
42661
- const diff3 = fetchPrDiff(prDiff.prNumber, prDiff.baseSha, prDiff.headSha);
42662
- const { inDiff, outOfDiff } = partitionFindingsByDiff(
42663
- lineBound,
42664
- buildDiffLineIndex(diff3)
42665
- );
42666
- warnOutOfDiff(outOfDiff);
42667
- return {
42668
- inDiff,
42669
- unanchored: outOfDiff.map(
42670
- (finding) => ({
42671
- ...finding,
42672
- reason: "out-of-diff"
42673
- })
42674
- )
42675
- };
42676
- }
42677
-
42678
- // src/commands/review/warnUnlocated.ts
42679
- import chalk262 from "chalk";
42680
- function warnUnlocated(unlocated) {
42681
- if (unlocated.length === 0) return;
42682
- console.warn(
42683
- chalk262.yellow(
42684
- `Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
42685
- )
42686
- );
42687
- for (const finding of unlocated) {
42688
- const where = finding.location || chalk262.dim("missing");
42689
- console.warn(
42690
- ` ${chalk262.yellow("\xB7")} ${finding.title} ${chalk262.dim(`(${where})`)}`
42691
- );
42692
- }
42693
- }
42694
-
42695
- // src/commands/review/selectPostableFindings.ts
42696
- function selectPostableFindings(markdown, prInfo) {
42697
- const findings2 = parseFindings(markdown);
42698
- if (findings2.length === 0) {
42699
- console.log("Synthesis contains no findings; nothing to post.");
42700
- return { inDiff: [], unanchored: [] };
42701
- }
42702
- const { lineBound, unlocated, alreadyRaised } = partitionFindings(findings2);
42703
- warnUnlocated(unlocated);
42704
- if (alreadyRaised.length > 0) {
42705
- console.log(
42706
- `Skipped ${alreadyRaised.length} finding(s) already raised by prior comments.`
42707
- );
42708
- }
42709
- const carriedUnlocated = unlocated.map(
42710
- (finding) => ({
42711
- ...finding,
42712
- reason: "unlocated"
42713
- })
42714
- );
42715
- if (lineBound.length === 0) {
42716
- console.log("No line-bound findings to comment on.");
42717
- return { inDiff: [], unanchored: carriedUnlocated };
42718
- }
42719
- const { inDiff, unanchored } = selectInDiffFindings(lineBound, prInfo);
42720
- if (inDiff.length === 0)
42721
- console.log(
42722
- "No findings fall within the PR diff; no line comments to post."
42723
- );
42724
- return { inDiff, unanchored: [...carriedUnlocated, ...unanchored] };
42725
- }
42726
-
42727
- // src/commands/review/ci/buildTokenUsageTable.ts
42728
- var SLOT_LABELS = ["Reviewer 1", "Reviewer 2", "Synthesis"];
42729
- var DASH = "\u2014";
42730
- function format(value) {
42731
- return value === void 0 ? DASH : value.toLocaleString("en-US");
42732
- }
42733
- function cells(usage) {
42734
- if (!usage) return [DASH, DASH, DASH, DASH];
42735
- return [
42736
- format(usage.input),
42737
- format(usage.output),
42738
- format(usage.cacheRead),
42739
- format(usage.cacheWrite)
42740
- ];
42741
- }
42742
- function sumOf(reported, pick3) {
42743
- const values = reported.map(pick3).filter((v) => v !== void 0);
42744
- return values.length === 0 ? void 0 : values.reduce((a, b) => a + b, 0);
42745
- }
42746
- function total2(usages) {
42747
- const reported = usages.filter((u) => u !== void 0);
42748
- return [
42749
- format(sumOf(reported, (u) => u.input)),
42750
- format(sumOf(reported, (u) => u.output)),
42751
- format(sumOf(reported, (u) => u.cacheRead)),
42752
- format(sumOf(reported, (u) => u.cacheWrite))
42753
- ];
42754
- }
42755
- function row2(label, values) {
42756
- return `| ${label} | ${values.join(" | ")} |`;
42757
- }
42758
- function buildTokenUsageTable(usages) {
42759
- return [
42760
- "## Token usage",
42761
- "",
42762
- "| Slot | Input | Output | Cache read | Cache write |",
42763
- "| --- | ---: | ---: | ---: | ---: |",
42764
- ...usages.map(
42765
- (usage, i) => row2(SLOT_LABELS[i] ?? `Slot ${i + 1}`, cells(usage))
42766
- ),
42767
- row2("**Total**", total2(usages))
42768
- ].join("\n");
42769
- }
42770
-
42771
- // src/commands/review/ci/writeJobSummary.ts
42772
- function writeJobSummary(synthesisPath, prInfo, summaryPath, slots) {
42773
- if (!summaryPath) return;
42774
- const markdown = readFileSync57(synthesisPath, "utf8");
42775
- const { unanchored } = selectPostableFindings(markdown, prInfo);
42776
- const usageTable = buildTokenUsageTable(slots.map((slot) => slot.usage));
42777
- appendFileSync3(
42778
- summaryPath,
42779
- `${buildReviewSummary(markdown, unanchored)}
42780
-
42781
- ${usageTable}
42782
- `
42783
- );
42784
- }
42785
-
42786
- // src/commands/review/appendCiFooter.ts
42787
- function appendCiFooter(body, ciFooter) {
42788
- return ciFooter ? `${body}
42789
-
42790
- ${ciFooter}` : body;
42791
- }
42792
-
42793
- // src/commands/review/runReviewSubmission.ts
42794
- function runReviewSubmission(mutation, body) {
42795
- try {
42796
- const prId = getCurrentPrNodeId();
42797
- runGhGraphql(mutation, { prId, body });
42798
- console.log("Submitted review.");
42799
- return true;
42800
- } catch (error) {
42801
- if (isGhNotInstalled(error)) {
42802
- console.error("Error: GitHub CLI (gh) is not installed.");
42803
- return false;
42804
- }
42805
- const message3 = error instanceof Error ? error.message : String(error);
42806
- console.error(`Failed to submit review: ${message3}`);
42807
- return false;
42808
- }
42809
- }
42810
-
42811
- // src/commands/review/submitBodyOnlyReview.ts
42812
- var MUTATION6 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
42813
- function submitBodyOnlyReview(body) {
42814
- return runReviewSubmission(MUTATION6, body);
42815
- }
42816
-
42817
- // src/commands/review/submitFailedReview.ts
42818
- function describeFailures(failures) {
42819
- if (failures.length === 0) return "The review did not complete.";
42820
- const steps = failures.map((f) => f.name.replace("-", " ")).join(" and ");
42821
- return `The review did not complete: ${steps} failed.`;
42822
- }
42823
- function submitFailedReview(failures, ciFooter, runUrl) {
42824
- const lines2 = [
42825
- "## Code review failed",
42826
- "",
42827
- `${describeFailures(failures)} No findings were posted.`
42828
- ];
42829
- if (runUrl) lines2.push("", `See the [workflow run](${runUrl}) for details.`);
42830
- submitBodyOnlyReview(appendCiFooter(lines2.join("\n"), ciFooter));
42831
- }
42832
-
42833
- // src/commands/review/exitFailedCiReview.ts
42834
- function exitFailedCiReview(failures, ci) {
42835
- console.error("Review failed; no findings were posted.");
42836
- submitFailedReview(failures, ci.footer, ci.runUrl);
42837
- process.exit(1);
42838
- }
42839
-
42840
42411
  // src/commands/review/cachedReviewerResult.ts
42841
42412
  import { statSync as statSync12 } from "fs";
42842
42413
  function cachedReviewerResult(name, outputPath) {
@@ -42886,10 +42457,10 @@ function renderEntry(entry, frame) {
42886
42457
  }
42887
42458
 
42888
42459
  // src/commands/review/startReviewLog.ts
42889
- import { format as format2 } from "util";
42460
+ import { format } from "util";
42890
42461
 
42891
42462
  // src/commands/review/createReviewLogSink.ts
42892
- import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync30 } from "fs";
42463
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync30 } from "fs";
42893
42464
  import { join as join93 } from "path";
42894
42465
  var LOG_FILE = "review.log";
42895
42466
  function createReviewLogSink() {
@@ -42902,7 +42473,7 @@ function createReviewLogSink() {
42902
42473
  buffered.push(stripped);
42903
42474
  return;
42904
42475
  }
42905
- appendFileSync4(logPath2, `${stripped}
42476
+ appendFileSync3(logPath2, `${stripped}
42906
42477
  `);
42907
42478
  },
42908
42479
  attach(reviewDir) {
@@ -42915,7 +42486,7 @@ function createReviewLogSink() {
42915
42486
  ...buffered
42916
42487
  ];
42917
42488
  buffered = [];
42918
- appendFileSync4(logPath2, `${lines2.join("\n")}
42489
+ appendFileSync3(logPath2, `${lines2.join("\n")}
42919
42490
  `);
42920
42491
  }
42921
42492
  };
@@ -42934,7 +42505,7 @@ function patch(method) {
42934
42505
  const original = console[method].bind(console);
42935
42506
  console[method] = (...args) => {
42936
42507
  original(...args);
42937
- appendReviewLog(format2(...args));
42508
+ appendReviewLog(format(...args));
42938
42509
  };
42939
42510
  }
42940
42511
  function startReviewLog() {
@@ -43049,10 +42620,9 @@ async function ensureCodexAvailable() {
43049
42620
  }
43050
42621
 
43051
42622
  // src/commands/review/planCodexReviewer.ts
43052
- async function planCodexReviewer(codexPath, slotAssigned) {
42623
+ async function planCodexReviewer(codexPath) {
43053
42624
  const cached2 = cachedReviewerResult("codex", codexPath);
43054
42625
  if (cached2) return { kind: "cached", cached: cached2 };
43055
- if (slotAssigned) return { kind: "run" };
43056
42626
  const status2 = await ensureCodexAvailable();
43057
42627
  if (status2 === "available") return { kind: "run" };
43058
42628
  return { kind: "skipped" };
@@ -43187,16 +42757,6 @@ async function recordReviewerRuns(fresh, target, startedAt, openDb = getDb) {
43187
42757
  }
43188
42758
  }
43189
42759
 
43190
- // src/commands/review/reviewerLabel.ts
43191
- function reviewerLabel(name, model) {
43192
- return model ? `${name} (${model})` : name;
43193
- }
43194
-
43195
- // src/commands/review/buildCodexModelArgs.ts
43196
- function buildCodexModelArgs() {
43197
- return buildLitellmCodexArgs(loadConfig().review?.codexModel);
43198
- }
43199
-
43200
42760
  // src/commands/review/runClaudeReviewer.ts
43201
42761
  import { writeFileSync as writeFileSync43 } from "fs";
43202
42762
 
@@ -43278,6 +42838,11 @@ function formatToolText(name, tool, summary) {
43278
42838
  return `${name} \u2014 ${tool}${suffix}`;
43279
42839
  }
43280
42840
 
42841
+ // src/commands/review/reviewerLabel.ts
42842
+ function reviewerLabel(name, model) {
42843
+ return model ? `${name} (${model})` : name;
42844
+ }
42845
+
43281
42846
  // src/commands/review/reportReviewerToolUse.ts
43282
42847
  function reportReviewerToolUse(name, use, spinner, model) {
43283
42848
  const label = reviewerLabel(name, model);
@@ -43290,13 +42855,13 @@ function reportReviewerToolUse(name, use, spinner, model) {
43290
42855
  }
43291
42856
 
43292
42857
  // src/commands/review/createClaudeLineHandler.ts
43293
- function createClaudeLineHandler(name, spinner, model) {
42858
+ function createClaudeLineHandler(name, spinner) {
43294
42859
  const state = { finalText: "" };
43295
42860
  const onLine = (line) => {
43296
42861
  const event = parseClaudeEvent(line);
43297
42862
  if (event.kind === "tool_uses") {
43298
42863
  for (const use of event.toolUses)
43299
- reportReviewerToolUse(name, use, spinner, model);
42864
+ reportReviewerToolUse(name, use, spinner);
43300
42865
  return;
43301
42866
  }
43302
42867
  if (event.kind === "final") {
@@ -43556,41 +43121,47 @@ function runStreamingChild(spec) {
43556
43121
 
43557
43122
  // src/commands/review/runClaudeReviewer.ts
43558
43123
  async function runClaudeReviewer(spec) {
43559
- const { spinner, override } = spec;
43124
+ const { spinner } = spec;
43560
43125
  const command = "claude";
43561
- const { state, onLine } = createClaudeLineHandler(
43562
- spec.name,
43563
- spinner,
43564
- override?.model
43565
- );
43126
+ const { state, onLine } = createClaudeLineHandler(spec.name, spinner);
43566
43127
  const result = await runStreamingChild({
43567
43128
  name: spec.name,
43568
43129
  command,
43569
- model: override?.model,
43570
43130
  args: [
43571
43131
  "-p",
43572
43132
  "--add-dir",
43573
43133
  spec.reviewDir,
43574
43134
  "--output-format",
43575
43135
  "stream-json",
43576
- "--verbose",
43577
- ...override?.args ?? []
43136
+ "--verbose"
43578
43137
  ],
43579
43138
  stdin: spec.stdin,
43580
43139
  quiet: Boolean(spinner),
43581
- ...override ? { env: override.env } : {},
43582
43140
  onLine
43583
43141
  });
43584
43142
  if (result.exitCode === 0 && state.finalText)
43585
43143
  writeFileSync43(spec.outputPath, state.finalText);
43586
- const finalised = finaliseReviewerRun(
43587
- { ...spec, command, model: override?.model },
43588
- spinner,
43589
- result
43590
- );
43144
+ const finalised = finaliseReviewerRun({ ...spec, command }, spinner, result);
43591
43145
  return state.usage ? { ...finalised, usage: state.usage } : finalised;
43592
43146
  }
43593
43147
 
43148
+ // src/commands/review/resolveClaude.ts
43149
+ function resolveClaude(args) {
43150
+ if (args.cached) return Promise.resolve(args.cached);
43151
+ return runClaudeReviewer({
43152
+ name: "claude",
43153
+ reviewDir: args.reviewDir,
43154
+ stdin: args.stdin,
43155
+ outputPath: args.claudePath,
43156
+ spinner: args.multi?.create("claude \u2014 starting")
43157
+ });
43158
+ }
43159
+
43160
+ // src/commands/review/buildCodexModelArgs.ts
43161
+ function buildCodexModelArgs() {
43162
+ return buildLitellmCodexArgs(loadConfig().review?.codexModel);
43163
+ }
43164
+
43594
43165
  // src/commands/review/runCodexReviewer.ts
43595
43166
  import { existsSync as existsSync72, unlinkSync as unlinkSync17 } from "fs";
43596
43167
 
@@ -43631,12 +43202,12 @@ function parseCodexEvent(line) {
43631
43202
  }
43632
43203
 
43633
43204
  // src/commands/review/createCodexLineHandler.ts
43634
- function addUsage(total3, turn) {
43635
- if (!total3) return turn;
43205
+ function addUsage(total2, turn) {
43206
+ if (!total2) return turn;
43636
43207
  return {
43637
- input: total3.input + turn.input,
43638
- output: total3.output + turn.output,
43639
- cacheRead: total3.cacheRead + turn.cacheRead
43208
+ input: total2.input + turn.input,
43209
+ output: total2.output + turn.output,
43210
+ cacheRead: total2.cacheRead + turn.cacheRead
43640
43211
  };
43641
43212
  }
43642
43213
  function createCodexLineHandler(name, spinner, model) {
@@ -43697,50 +43268,18 @@ async function runCodexReviewer(spec) {
43697
43268
  return state.usage ? { ...finalised, usage: state.usage } : finalised;
43698
43269
  }
43699
43270
 
43700
- // src/commands/review/runSlot.ts
43701
- function runSlot(harness, spec) {
43702
- if (harness === "claude") return runClaudeReviewer(spec);
43703
- return runCodexReviewer({
43704
- name: spec.name,
43705
- stdin: spec.stdin,
43706
- outputPath: spec.outputPath,
43707
- spinner: spec.spinner,
43708
- override: spec.override ?? buildCodexModelArgs()
43709
- });
43710
- }
43711
-
43712
- // src/commands/review/resolveClaude.ts
43713
- function resolveClaude(args) {
43714
- if (args.cached) return Promise.resolve(args.cached);
43715
- const name = args.slot?.label ?? "claude";
43716
- const override = args.slot?.override;
43717
- const spinner = args.multi?.create(
43718
- `${reviewerLabel(name, override?.model)} \u2014 starting`
43719
- );
43720
- return runSlot(args.slot?.harness ?? "claude", {
43721
- name,
43722
- reviewDir: args.reviewDir,
43723
- stdin: args.stdin,
43724
- outputPath: args.claudePath,
43725
- spinner,
43726
- override
43727
- });
43728
- }
43729
-
43730
43271
  // src/commands/review/resolveCodex.ts
43731
43272
  function resolveCodex(args) {
43732
43273
  if (args.plan.kind === "cached") return Promise.resolve(args.plan.cached);
43733
43274
  if (args.plan.kind === "skipped") {
43734
43275
  return Promise.resolve(skippedCodexResult(args.codexPath));
43735
43276
  }
43736
- const name = args.slot?.label ?? "codex";
43737
- const override = args.slot?.override ?? buildCodexModelArgs();
43277
+ const override = buildCodexModelArgs();
43738
43278
  const spinner = args.multi?.create(
43739
- `${reviewerLabel(name, override.model)} \u2014 starting`
43279
+ `${reviewerLabel("codex", override.model)} \u2014 starting`
43740
43280
  );
43741
- return runSlot(args.slot?.harness ?? "codex", {
43742
- name,
43743
- reviewDir: args.reviewDir,
43281
+ return runCodexReviewer({
43282
+ name: "codex",
43744
43283
  stdin: args.stdin,
43745
43284
  outputPath: args.codexPath,
43746
43285
  spinner,
@@ -43755,16 +43294,13 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
43755
43294
  claudePath,
43756
43295
  stdin: stdinPrompt,
43757
43296
  cached: options2.cachedClaude,
43758
- multi: options2.multi,
43759
- slot: options2.models.claude
43297
+ multi: options2.multi
43760
43298
  });
43761
43299
  const codexPromise = resolveCodex({
43762
- reviewDir,
43763
43300
  codexPath,
43764
43301
  stdin: stdinPrompt,
43765
43302
  plan: options2.codexPlan,
43766
- multi: options2.multi,
43767
- slot: options2.models.codex
43303
+ multi: options2.multi
43768
43304
  });
43769
43305
  const results = await Promise.all([claudePromise, codexPromise]);
43770
43306
  const anyFresh = options2.cachedClaude === null || options2.codexPlan.kind !== "cached";
@@ -43778,7 +43314,138 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
43778
43314
  import { existsSync as existsSync73, unlinkSync as unlinkSync18 } from "fs";
43779
43315
 
43780
43316
  // src/commands/review/synthesise.ts
43781
- import { readFileSync as readFileSync58 } from "fs";
43317
+ import { readFileSync as readFileSync57 } from "fs";
43318
+
43319
+ // src/commands/review/carriedUnanchoredFindings.ts
43320
+ function carriedUnanchoredFindings(unanchored) {
43321
+ return unanchored.filter((finding) => finding.source !== "already-raised");
43322
+ }
43323
+
43324
+ // src/commands/review/parseFindings.ts
43325
+ var SEVERITIES = ["blocker", "major", "minor", "nit"];
43326
+ var SOURCES = [
43327
+ "confirmed",
43328
+ "disputed",
43329
+ "claude-only",
43330
+ "codex-only",
43331
+ "already-raised"
43332
+ ];
43333
+ function isSeverity(value) {
43334
+ return SEVERITIES.includes(value);
43335
+ }
43336
+ function isSource(value) {
43337
+ return SOURCES.includes(value);
43338
+ }
43339
+ function extractField(block, field) {
43340
+ const re = new RegExp(`^-\\s+${field}:\\s*(.*)$`, "im");
43341
+ const match = block.match(re);
43342
+ return match ? match[1].trim() : "";
43343
+ }
43344
+ function stripBackticks(value) {
43345
+ return value.replace(/^`+|`+$/g, "").trim();
43346
+ }
43347
+ function parseFindingBlock(block) {
43348
+ const newlineIndex = block.indexOf("\n");
43349
+ const title = newlineIndex === -1 ? block.trim() : block.slice(0, newlineIndex).trim();
43350
+ const body = newlineIndex === -1 ? "" : block.slice(newlineIndex + 1);
43351
+ const severityRaw = extractField(body, "Severity").toLowerCase();
43352
+ const sourceRaw = extractField(body, "Source").toLowerCase();
43353
+ return {
43354
+ title,
43355
+ severity: isSeverity(severityRaw) ? severityRaw : null,
43356
+ source: isSource(sourceRaw) ? sourceRaw : null,
43357
+ location: stripBackticks(extractField(body, "Location")),
43358
+ impact: extractField(body, "Impact"),
43359
+ recommendation: extractField(body, "Recommendation")
43360
+ };
43361
+ }
43362
+ function parseFindings(markdown) {
43363
+ return markdown.split(/^###\s+Finding:\s*/m).slice(1).map(parseFindingBlock);
43364
+ }
43365
+
43366
+ // src/commands/review/summariseSynthesis.ts
43367
+ var SEVERITIES2 = ["blocker", "major", "minor", "nit"];
43368
+ function isSeverity2(value) {
43369
+ return SEVERITIES2.includes(value);
43370
+ }
43371
+ function extractSummary(markdown) {
43372
+ const match = markdown.match(
43373
+ /^##\s+Summary\s*\n([\s\S]*?)(?=\n##\s|\n###\s|$)/m
43374
+ );
43375
+ if (!match) return "";
43376
+ return match[1].trim();
43377
+ }
43378
+ function countBySeverity(markdown) {
43379
+ const totals = { blocker: 0, major: 0, minor: 0, nit: 0 };
43380
+ const regex = /^-\s+Severity:\s*([a-zA-Z]+)/gm;
43381
+ for (const match of markdown.matchAll(regex)) {
43382
+ const severity = match[1].toLowerCase();
43383
+ if (isSeverity2(severity)) totals[severity]++;
43384
+ }
43385
+ return totals;
43386
+ }
43387
+ function summariseSynthesis(markdown) {
43388
+ const totals = countBySeverity(markdown);
43389
+ const findingCount = totals.blocker + totals.major + totals.minor + totals.nit;
43390
+ return { summary: extractSummary(markdown), totals, findingCount };
43391
+ }
43392
+ function formatSynthesisSummary(summary) {
43393
+ const lines2 = [];
43394
+ const { totals, findingCount } = summary;
43395
+ lines2.push(
43396
+ `Findings: ${findingCount} (blocker ${totals.blocker}, major ${totals.major}, minor ${totals.minor}, nit ${totals.nit})`
43397
+ );
43398
+ if (summary.summary) lines2.push("", summary.summary);
43399
+ return lines2.join("\n");
43400
+ }
43401
+
43402
+ // src/commands/review/buildReviewSummary.ts
43403
+ var UNANCHOR_REASONS = {
43404
+ "out-of-diff": "its line falls outside the PR diff",
43405
+ unlocated: "it has no parseable file:line",
43406
+ "comment-rejected": "GitHub rejected its line comment"
43407
+ };
43408
+ function formatFindingLine(finding) {
43409
+ const severity = finding.severity ?? "finding";
43410
+ return `- **${severity}: ${finding.title}**`;
43411
+ }
43412
+ function formatLocation(finding) {
43413
+ const location = finding.location.trim();
43414
+ if (!location || location.toLowerCase() === "n/a") return "no location";
43415
+ return `\`${location}\``;
43416
+ }
43417
+ function formatUnanchoredFinding(finding) {
43418
+ const lines2 = [
43419
+ `${formatFindingLine(finding)} \u2014 ${formatLocation(finding)}`,
43420
+ ` - Not anchored: ${UNANCHOR_REASONS[finding.reason]}`
43421
+ ];
43422
+ if (finding.impact) lines2.push(` - Impact: ${finding.impact}`);
43423
+ if (finding.recommendation)
43424
+ lines2.push(` - Recommendation: ${finding.recommendation}`);
43425
+ return lines2;
43426
+ }
43427
+ function buildReviewSummary(markdown, unanchored = []) {
43428
+ const summary = summariseSynthesis(markdown);
43429
+ const findings2 = parseFindings(markdown);
43430
+ const lines2 = ["## Code review summary", "", formatSynthesisSummary(summary)];
43431
+ if (findings2.length > 0) {
43432
+ lines2.push("", "### Findings", "");
43433
+ for (const finding of findings2) lines2.push(formatFindingLine(finding));
43434
+ }
43435
+ const carried = carriedUnanchoredFindings(unanchored);
43436
+ if (carried.length > 0) {
43437
+ lines2.push(
43438
+ "",
43439
+ "### Findings not anchored to the diff",
43440
+ "",
43441
+ "No line comment could be attached to these, so the detail is here instead.",
43442
+ ""
43443
+ );
43444
+ for (const finding of carried)
43445
+ lines2.push(...formatUnanchoredFinding(finding));
43446
+ }
43447
+ return lines2.join("\n");
43448
+ }
43782
43449
 
43783
43450
  // src/commands/review/buildSynthesisStdin.ts
43784
43451
  var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
@@ -43847,7 +43514,7 @@ Files:
43847
43514
 
43848
43515
  // src/commands/review/synthesise.ts
43849
43516
  function printSummary2(synthesisPath) {
43850
- const markdown = readFileSync58(synthesisPath, "utf8");
43517
+ const markdown = readFileSync57(synthesisPath, "utf8");
43851
43518
  console.log("");
43852
43519
  console.log(buildReviewSummary(markdown));
43853
43520
  console.log("");
@@ -43858,12 +43525,8 @@ async function synthesise(paths, options2) {
43858
43525
  printSummary2(paths.synthesisPath);
43859
43526
  return cached2;
43860
43527
  }
43861
- const { multi, slot } = options2;
43862
- const override = slot?.override;
43863
- const spinner = multi?.create(
43864
- `${reviewerLabel("synthesis", override?.model)} \u2014 starting`
43865
- );
43866
- const result = await runSlot(slot?.harness ?? "claude", {
43528
+ const spinner = options2.multi?.create("synthesis \u2014 starting");
43529
+ const result = await runClaudeReviewer({
43867
43530
  name: "synthesis",
43868
43531
  reviewDir: paths.reviewDir,
43869
43532
  stdin: buildSynthesisStdin(
@@ -43872,8 +43535,7 @@ async function synthesise(paths, options2) {
43872
43535
  paths.codexPath
43873
43536
  ),
43874
43537
  outputPath: paths.synthesisPath,
43875
- spinner,
43876
- override
43538
+ spinner
43877
43539
  });
43878
43540
  if (result.exitCode === 0) printSummary2(paths.synthesisPath);
43879
43541
  return result;
@@ -43885,10 +43547,7 @@ async function synthesiseAfterReviewers(input) {
43885
43547
  if (input.anyFresh && existsSync73(paths.synthesisPath)) {
43886
43548
  unlinkSync18(paths.synthesisPath);
43887
43549
  }
43888
- const synthesisResult = await synthesise(paths, {
43889
- multi: input.multi,
43890
- slot: input.slot
43891
- });
43550
+ const synthesisResult = await synthesise(paths, { multi: input.multi });
43892
43551
  if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
43893
43552
  return {
43894
43553
  ok: synthesisResult.exitCode === 0,
@@ -43898,11 +43557,9 @@ async function synthesiseAfterReviewers(input) {
43898
43557
  }
43899
43558
 
43900
43559
  // src/commands/review/skipReason.ts
43901
- function skipReason(results, failures, strict) {
43560
+ function skipReason(results, failures) {
43902
43561
  if (failures.length === results.length)
43903
43562
  return "Both reviewers failed; skipping synthesis.";
43904
- if (strict && failures.length > 0)
43905
- return "A reviewer failed; skipping synthesis.";
43906
43563
  return void 0;
43907
43564
  }
43908
43565
 
@@ -43921,13 +43578,12 @@ async function runAndSynthesise(args) {
43921
43578
  {
43922
43579
  multi,
43923
43580
  codexPlan: args.codexPlan,
43924
- cachedClaude: args.cachedClaude,
43925
- models: args.models
43581
+ cachedClaude: args.cachedClaude
43926
43582
  }
43927
43583
  );
43928
43584
  if (args.job) await recordReviewerRuns(fresh, args.job, startedAt);
43929
43585
  const failures = failed2(results);
43930
- const reason4 = skipReason(results, failures, args.strict);
43586
+ const reason4 = skipReason(results, failures);
43931
43587
  if (reason4) {
43932
43588
  console.error(reason4);
43933
43589
  return { ok: false, failures, slots: results };
@@ -43937,8 +43593,7 @@ async function runAndSynthesise(args) {
43937
43593
  results,
43938
43594
  failures,
43939
43595
  anyFresh,
43940
- multi,
43941
- slot: args.models.synthesis
43596
+ multi
43942
43597
  });
43943
43598
  }
43944
43599
 
@@ -43976,10 +43631,7 @@ function finishUi(ui, ok) {
43976
43631
  }
43977
43632
  async function runReviewPipeline(paths, options2) {
43978
43633
  const cachedClaude = cachedReviewerResult("claude", paths.claudePath);
43979
- const codexPlan = await planCodexReviewer(
43980
- paths.codexPath,
43981
- options2.models?.codex !== void 0
43982
- );
43634
+ const codexPlan = await planCodexReviewer(paths.codexPath);
43983
43635
  const ui = createUi(useSpinnerUi(options2.verbose));
43984
43636
  try {
43985
43637
  const outcome = await runAndSynthesise({
@@ -43987,8 +43639,6 @@ async function runReviewPipeline(paths, options2) {
43987
43639
  cachedClaude,
43988
43640
  codexPlan,
43989
43641
  multi: ui.multi,
43990
- models: options2.models ?? {},
43991
- strict: options2.strict ?? false,
43992
43642
  job: options2.job
43993
43643
  });
43994
43644
  finishUi(ui, outcome.ok);
@@ -44001,8 +43651,8 @@ async function runReviewPipeline(paths, options2) {
44001
43651
  }
44002
43652
 
44003
43653
  // src/commands/review/annotateDiffWithLineNumbers.ts
44004
- var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
44005
- var HUNK_HEADER4 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
43654
+ var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
43655
+ var HUNK_HEADER3 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
44006
43656
  var GUTTER_WIDTH = 6;
44007
43657
  function gutter(lineNumber) {
44008
43658
  const label = lineNumber === null ? "" : String(lineNumber);
@@ -44012,11 +43662,11 @@ function annotateDiffWithLineNumbers(diff3) {
44012
43662
  let inFile = false;
44013
43663
  let newLine = 0;
44014
43664
  return diff3.split("\n").map((line) => {
44015
- if (FILE_HEADER2.test(line)) {
43665
+ if (FILE_HEADER.test(line)) {
44016
43666
  inFile = true;
44017
43667
  return gutter(null) + line;
44018
43668
  }
44019
- const hunkMatch = line.match(HUNK_HEADER4);
43669
+ const hunkMatch = line.match(HUNK_HEADER3);
44020
43670
  if (hunkMatch) {
44021
43671
  newLine = Number(hunkMatch[1]);
44022
43672
  return gutter(null) + line;
@@ -44133,9 +43783,9 @@ function buildReviewPaths(repoRoot2, key) {
44133
43783
  }
44134
43784
 
44135
43785
  // src/commands/review/fetchExistingComments.ts
44136
- import { execSync as execSync59 } from "child_process";
43786
+ import { execSync as execSync58 } from "child_process";
44137
43787
  function fetchRawComments(org, repo, prNumber) {
44138
- const out = execSync59(
43788
+ const out = execSync58(
44139
43789
  `gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
44140
43790
  { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
44141
43791
  );
@@ -44198,6 +43848,35 @@ function logPriorComments(count10) {
44198
43848
  // src/commands/review/gatherContext.ts
44199
43849
  import { execSync as execSync61 } from "child_process";
44200
43850
 
43851
+ // src/commands/review/fetchPrDiff.ts
43852
+ import { execSync as execSync59 } from "child_process";
43853
+ function fetchPrDiff(prNumber, baseSha, headSha) {
43854
+ const { org, repo } = getRepoInfo();
43855
+ try {
43856
+ return execSync59(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
43857
+ encoding: "utf8",
43858
+ maxBuffer: 256 * 1024 * 1024,
43859
+ stdio: ["ignore", "pipe", "pipe"]
43860
+ });
43861
+ } catch (error) {
43862
+ if (!isDiffTooLarge(error)) throw error;
43863
+ return fetchDiffViaGit(baseSha, headSha);
43864
+ }
43865
+ }
43866
+ function isDiffTooLarge(error) {
43867
+ return error instanceof Error && (error.message.includes("too_large") || error.message.includes("maximum number of files"));
43868
+ }
43869
+ function fetchDiffViaGit(baseSha, headSha) {
43870
+ try {
43871
+ execSync59(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
43872
+ } catch {
43873
+ }
43874
+ return execSync59(`git diff ${baseSha}...${headSha}`, {
43875
+ encoding: "utf8",
43876
+ maxBuffer: 256 * 1024 * 1024
43877
+ });
43878
+ }
43879
+
44201
43880
  // src/commands/review/fetchPrDiffInfo.ts
44202
43881
  import { execSync as execSync60 } from "child_process";
44203
43882
  function getCurrentBranch3() {
@@ -44213,11 +43892,6 @@ function runGh2(command) {
44213
43892
  });
44214
43893
  }
44215
43894
  function fetchRawPr(org, repo, branch2) {
44216
- const pinned = getPinnedPr();
44217
- if (pinned !== void 0)
44218
- return JSON.parse(
44219
- runGh2(`gh pr view ${pinned} --json ${FIELDS3} -R ${org}/${repo}`)
44220
- );
44221
43895
  const parsed = JSON.parse(
44222
43896
  runGh2(
44223
43897
  `gh pr list --state open --head ${branch2} --json ${FIELDS3} -R ${org}/${repo}`
@@ -44292,7 +43966,7 @@ function gatherChangedContext() {
44292
43966
  }
44293
43967
 
44294
43968
  // src/commands/review/postReviewToPr.ts
44295
- import { readFileSync as readFileSync59 } from "fs";
43969
+ import { readFileSync as readFileSync58 } from "fs";
44296
43970
 
44297
43971
  // src/commands/review/chainAddressComments.ts
44298
43972
  function chainAddressComments(prNumber, announce) {
@@ -44353,11 +44027,32 @@ async function postFindings(findings2) {
44353
44027
  }
44354
44028
 
44355
44029
  // src/commands/review/buildReviewBody.ts
44356
- function buildReviewBody(markdown, unanchored, ciFooter) {
44357
- return appendCiFooter(
44358
- sanitiseReviewerNames(buildReviewSummary(markdown, unanchored)),
44359
- ciFooter
44360
- );
44030
+ function buildReviewBody(markdown, unanchored) {
44031
+ return sanitiseReviewerNames(buildReviewSummary(markdown, unanchored));
44032
+ }
44033
+
44034
+ // src/commands/review/runReviewSubmission.ts
44035
+ function runReviewSubmission(mutation, body) {
44036
+ try {
44037
+ const prId = getCurrentPrNodeId();
44038
+ runGhGraphql(mutation, { prId, body });
44039
+ console.log("Submitted review.");
44040
+ return true;
44041
+ } catch (error) {
44042
+ if (isGhNotInstalled(error)) {
44043
+ console.error("Error: GitHub CLI (gh) is not installed.");
44044
+ return false;
44045
+ }
44046
+ const message3 = error instanceof Error ? error.message : String(error);
44047
+ console.error(`Failed to submit review: ${message3}`);
44048
+ return false;
44049
+ }
44050
+ }
44051
+
44052
+ // src/commands/review/submitBodyOnlyReview.ts
44053
+ var MUTATION6 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
44054
+ function submitBodyOnlyReview(body) {
44055
+ return runReviewSubmission(MUTATION6, body);
44361
44056
  }
44362
44057
 
44363
44058
  // src/commands/review/submitPendingReview.ts
@@ -44405,22 +44100,193 @@ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
44405
44100
  console.log(`Posted ${posted} comment(s)${failedSuffix}.`);
44406
44101
  const withRejected = withRejectedFindings(unanchored, failed3);
44407
44102
  const carried = carriedUnanchoredFindings(withRejected);
44408
- if (posted === 0 && carried.length === 0 && !options2.ciFooter)
44103
+ if (posted === 0 && carried.length === 0)
44409
44104
  return { posted: 0, submitted: false };
44410
44105
  const shouldSubmit = await decideSubmit(options2);
44411
44106
  if (shouldSubmit) {
44412
- const submitted = submitReview(
44413
- buildReviewBody(markdown, withRejected, options2.ciFooter),
44414
- { posted, failed: failed3.length }
44415
- );
44416
- if (!submitted && options2.ciFooter)
44417
- throw new Error("the review could not be submitted to the PR");
44107
+ const submitted = submitReview(buildReviewBody(markdown, withRejected), {
44108
+ posted,
44109
+ failed: failed3.length
44110
+ });
44418
44111
  return { posted, submitted };
44419
44112
  }
44420
44113
  console.log("Leaving the review unsubmitted.");
44421
44114
  return { posted, submitted: false };
44422
44115
  }
44423
44116
 
44117
+ // src/commands/review/partitionFindings.ts
44118
+ function isValidLine(n) {
44119
+ return Number.isInteger(n) && n >= 1;
44120
+ }
44121
+ function toLineBound(finding) {
44122
+ if (!finding.location || finding.location.toLowerCase() === "n/a") {
44123
+ return null;
44124
+ }
44125
+ const match = finding.location.match(/^(.+):(\d+)(?:-(\d+))?$/);
44126
+ if (!match) return null;
44127
+ const startLine = Number.parseInt(match[2], 10);
44128
+ const endLine = match[3] ? Number.parseInt(match[3], 10) : startLine;
44129
+ if (!isValidLine(startLine) || !isValidLine(endLine)) return null;
44130
+ if (endLine < startLine) return null;
44131
+ const base = { ...finding, file: match[1], line: endLine };
44132
+ return startLine === endLine ? base : { ...base, startLine };
44133
+ }
44134
+ function partitionFindings(findings2) {
44135
+ const lineBound = [];
44136
+ const unlocated = [];
44137
+ const alreadyRaised = [];
44138
+ for (const finding of findings2) {
44139
+ if (finding.source === "already-raised") {
44140
+ alreadyRaised.push(finding);
44141
+ continue;
44142
+ }
44143
+ const bound = toLineBound(finding);
44144
+ if (bound) lineBound.push(bound);
44145
+ else unlocated.push(finding);
44146
+ }
44147
+ return { lineBound, unlocated, alreadyRaised };
44148
+ }
44149
+
44150
+ // src/commands/review/buildDiffLineIndex.ts
44151
+ var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
44152
+ var HUNK_HEADER4 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
44153
+ function buildDiffLineIndex(diff3) {
44154
+ const index3 = /* @__PURE__ */ new Map();
44155
+ let currentFile = null;
44156
+ let newLine = 0;
44157
+ for (const line of diff3.split("\n")) {
44158
+ const fileMatch = line.match(FILE_HEADER2);
44159
+ if (fileMatch) {
44160
+ currentFile = fileMatch[1] === "/dev/null" ? null : fileMatch[1];
44161
+ continue;
44162
+ }
44163
+ const hunkMatch = line.match(HUNK_HEADER4);
44164
+ if (hunkMatch) {
44165
+ newLine = Number(hunkMatch[1]);
44166
+ continue;
44167
+ }
44168
+ if (currentFile === null) continue;
44169
+ if (line.startsWith("-")) continue;
44170
+ if (line.startsWith("+") || line.startsWith(" ")) {
44171
+ let set = index3.get(currentFile);
44172
+ if (!set) {
44173
+ set = /* @__PURE__ */ new Set();
44174
+ index3.set(currentFile, set);
44175
+ }
44176
+ set.add(newLine);
44177
+ newLine++;
44178
+ }
44179
+ }
44180
+ return index3;
44181
+ }
44182
+
44183
+ // src/commands/review/partitionFindingsByDiff.ts
44184
+ function isWithinDiff(finding, index3) {
44185
+ const lines2 = index3.get(finding.file);
44186
+ if (!lines2) return false;
44187
+ if (!lines2.has(finding.line)) return false;
44188
+ if (finding.startLine !== void 0 && !lines2.has(finding.startLine)) {
44189
+ return false;
44190
+ }
44191
+ return true;
44192
+ }
44193
+ function partitionFindingsByDiff(findings2, index3) {
44194
+ const inDiff = [];
44195
+ const outOfDiff = [];
44196
+ for (const finding of findings2) {
44197
+ if (isWithinDiff(finding, index3)) inDiff.push(finding);
44198
+ else outOfDiff.push(finding);
44199
+ }
44200
+ return { inDiff, outOfDiff };
44201
+ }
44202
+
44203
+ // src/commands/review/warnOutOfDiff.ts
44204
+ import chalk261 from "chalk";
44205
+ function warnOutOfDiff(outOfDiff) {
44206
+ if (outOfDiff.length === 0) return;
44207
+ console.warn(
44208
+ chalk261.yellow(
44209
+ `Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
44210
+ )
44211
+ );
44212
+ for (const finding of outOfDiff) {
44213
+ const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
44214
+ console.warn(
44215
+ ` ${chalk261.yellow("\xB7")} ${finding.title} ${chalk261.dim(
44216
+ `(${finding.file}:${range})`
44217
+ )}`
44218
+ );
44219
+ }
44220
+ }
44221
+
44222
+ // src/commands/review/selectInDiffFindings.ts
44223
+ function selectInDiffFindings(lineBound, prDiff) {
44224
+ const diff3 = fetchPrDiff(prDiff.prNumber, prDiff.baseSha, prDiff.headSha);
44225
+ const { inDiff, outOfDiff } = partitionFindingsByDiff(
44226
+ lineBound,
44227
+ buildDiffLineIndex(diff3)
44228
+ );
44229
+ warnOutOfDiff(outOfDiff);
44230
+ return {
44231
+ inDiff,
44232
+ unanchored: outOfDiff.map(
44233
+ (finding) => ({
44234
+ ...finding,
44235
+ reason: "out-of-diff"
44236
+ })
44237
+ )
44238
+ };
44239
+ }
44240
+
44241
+ // src/commands/review/warnUnlocated.ts
44242
+ import chalk262 from "chalk";
44243
+ function warnUnlocated(unlocated) {
44244
+ if (unlocated.length === 0) return;
44245
+ console.warn(
44246
+ chalk262.yellow(
44247
+ `Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
44248
+ )
44249
+ );
44250
+ for (const finding of unlocated) {
44251
+ const where = finding.location || chalk262.dim("missing");
44252
+ console.warn(
44253
+ ` ${chalk262.yellow("\xB7")} ${finding.title} ${chalk262.dim(`(${where})`)}`
44254
+ );
44255
+ }
44256
+ }
44257
+
44258
+ // src/commands/review/selectPostableFindings.ts
44259
+ function selectPostableFindings(markdown, prInfo) {
44260
+ const findings2 = parseFindings(markdown);
44261
+ if (findings2.length === 0) {
44262
+ console.log("Synthesis contains no findings; nothing to post.");
44263
+ return { inDiff: [], unanchored: [] };
44264
+ }
44265
+ const { lineBound, unlocated, alreadyRaised } = partitionFindings(findings2);
44266
+ warnUnlocated(unlocated);
44267
+ if (alreadyRaised.length > 0) {
44268
+ console.log(
44269
+ `Skipped ${alreadyRaised.length} finding(s) already raised by prior comments.`
44270
+ );
44271
+ }
44272
+ const carriedUnlocated = unlocated.map(
44273
+ (finding) => ({
44274
+ ...finding,
44275
+ reason: "unlocated"
44276
+ })
44277
+ );
44278
+ if (lineBound.length === 0) {
44279
+ console.log("No line-bound findings to comment on.");
44280
+ return { inDiff: [], unanchored: carriedUnlocated };
44281
+ }
44282
+ const { inDiff, unanchored } = selectInDiffFindings(lineBound, prInfo);
44283
+ if (inDiff.length === 0)
44284
+ console.log(
44285
+ "No findings fall within the PR diff; no line comments to post."
44286
+ );
44287
+ return { inDiff, unanchored: [...carriedUnlocated, ...unanchored] };
44288
+ }
44289
+
44424
44290
  // src/commands/review/stillOnReviewedPr.ts
44425
44291
  function currentPrNumber() {
44426
44292
  try {
@@ -44441,24 +44307,6 @@ function stillOnReviewedPr(prNumber) {
44441
44307
  return false;
44442
44308
  }
44443
44309
 
44444
- // src/commands/review/submitNoFindingsReview.ts
44445
- function submitNoFindingsReview(markdown, ciFooter) {
44446
- const body = sanitiseReviewerNames(
44447
- `${buildReviewSummary(markdown)}
44448
-
44449
- No findings were raised.`
44450
- );
44451
- return submitBodyOnlyReview(appendCiFooter(body, ciFooter));
44452
- }
44453
-
44454
- // src/commands/review/postNoFindingsReview.ts
44455
- function postNoFindingsReview(markdown, ciFooter) {
44456
- if (!ciFooter) return { posted: 0, submitted: false };
44457
- if (!submitNoFindingsReview(markdown, ciFooter))
44458
- throw new Error("the review could not be submitted to the PR");
44459
- return { posted: 0, submitted: true };
44460
- }
44461
-
44462
44310
  // src/commands/review/describeWork.ts
44463
44311
  function describeWork(comments3, carried) {
44464
44312
  const parts = [];
@@ -44474,11 +44322,10 @@ async function confirmPost(prNumber, work, options2) {
44474
44322
  return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
44475
44323
  }
44476
44324
  async function postFindingsToPr(prInfo, synthesisPath, options2) {
44477
- const markdown = readFileSync59(synthesisPath, "utf8");
44325
+ const markdown = readFileSync58(synthesisPath, "utf8");
44478
44326
  const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
44479
44327
  const carried = carriedUnanchoredFindings(unanchored);
44480
- if (inDiff.length === 0 && carried.length === 0)
44481
- return postNoFindingsReview(markdown, options2.ciFooter);
44328
+ if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
44482
44329
  const work = describeWork(inDiff.length, carried.length);
44483
44330
  console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
44484
44331
  const confirmed = await confirmPost(prInfo.prNumber, work, options2);
@@ -44602,8 +44449,7 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
44602
44449
  prompt: options2.prompt,
44603
44450
  submit: options2.submit,
44604
44451
  addressComments: options2.addressComments,
44605
- announce: options2.announce,
44606
- ciFooter: options2.ciFooter
44452
+ announce: options2.announce
44607
44453
  });
44608
44454
  return;
44609
44455
  }
@@ -44620,8 +44466,7 @@ function runPostSynthesis(synthesisPath, prInfo, options2) {
44620
44466
  prompt: options2.prompt ?? true,
44621
44467
  submit: options2.submit ?? false,
44622
44468
  addressComments: options2.addressComments ?? false,
44623
- announce: options2.announce ?? false,
44624
- ciFooter: options2.ci?.footer
44469
+ announce: options2.announce ?? false
44625
44470
  });
44626
44471
  }
44627
44472
 
@@ -44632,22 +44477,9 @@ async function reviewPr(repoRoot2, options2) {
44632
44477
  attachReviewLog(paths.reviewDir);
44633
44478
  const outcome = await runReviewPipeline(paths, {
44634
44479
  verbose: options2.verbose ?? false,
44635
- models: options2.ci?.models,
44636
- strict: options2.ci !== void 0,
44637
- job: options2.ci ? void 0 : { repo: basename26(repoRoot2), prNumber: context.prNumber }
44638
- });
44639
- const synthesisOk = outcome.ok;
44640
- if (!synthesisOk && options2.ci)
44641
- exitFailedCiReview(outcome.failures, options2.ci);
44642
- if (synthesisOk && options2.ci)
44643
- writeJobSummary(
44644
- paths.synthesisPath,
44645
- context,
44646
- options2.ci.summaryPath,
44647
- outcome.slots
44648
- );
44649
- if (synthesisOk)
44650
- await runPostSynthesis(paths.synthesisPath, context, options2);
44480
+ job: { repo: basename26(repoRoot2), prNumber: context.prNumber }
44481
+ });
44482
+ if (outcome.ok) await runPostSynthesis(paths.synthesisPath, context, options2);
44651
44483
  console.log(`Done. Review folder: ${paths.reviewDir}`);
44652
44484
  }
44653
44485
 
@@ -44838,11 +44670,11 @@ import path88 from "path";
44838
44670
  import chalk263 from "chalk";
44839
44671
 
44840
44672
  // src/commands/rules/updateScopedRulesIndex.ts
44841
- import { existsSync as existsSync75, readFileSync as readFileSync61, writeFileSync as writeFileSync45 } from "fs";
44673
+ import { existsSync as existsSync75, readFileSync as readFileSync60, writeFileSync as writeFileSync45 } from "fs";
44842
44674
  import path87 from "path";
44843
44675
 
44844
44676
  // src/commands/rules/scopedRuleDirectories.ts
44845
- import { readFileSync as readFileSync60 } from "fs";
44677
+ import { readFileSync as readFileSync59 } from "fs";
44846
44678
  import path86 from "path";
44847
44679
 
44848
44680
  // src/commands/rules/findClaudeFiles.ts
@@ -44866,7 +44698,7 @@ function findClaudeFiles(dir) {
44866
44698
  // src/commands/rules/scopedRuleDirectories.ts
44867
44699
  function scopedRuleDirectories(root2) {
44868
44700
  return findClaudeFiles(root2).filter(
44869
- (file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync60(file, "utf8")).length > 0
44701
+ (file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync59(file, "utf8")).length > 0
44870
44702
  ).map(
44871
44703
  (file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
44872
44704
  ).sort();
@@ -44908,7 +44740,7 @@ function upsertScopedRulesPointer(content, directories) {
44908
44740
  function updateScopedRulesIndex(root2) {
44909
44741
  const directories = scopedRuleDirectories(root2);
44910
44742
  const rootFile = path87.join(root2, "CLAUDE.md");
44911
- const before = existsSync75(rootFile) ? readFileSync61(rootFile, "utf8") : "";
44743
+ const before = existsSync75(rootFile) ? readFileSync60(rootFile, "utf8") : "";
44912
44744
  const after = upsertScopedRulesPointer(before, directories);
44913
44745
  if (after !== before) writeFileSync45(rootFile, after);
44914
44746
  return directories;
@@ -44961,7 +44793,7 @@ function listRules(target, options2 = {}) {
44961
44793
  }
44962
44794
 
44963
44795
  // src/commands/rules/addRule.ts
44964
- import { existsSync as existsSync77, readFileSync as readFileSync63, writeFileSync as writeFileSync46 } from "fs";
44796
+ import { existsSync as existsSync77, readFileSync as readFileSync62, writeFileSync as writeFileSync46 } from "fs";
44965
44797
  import path91 from "path";
44966
44798
  import chalk265 from "chalk";
44967
44799
 
@@ -44986,11 +44818,11 @@ function insertRuleBullet(content, rule) {
44986
44818
  }
44987
44819
 
44988
44820
  // src/commands/rules/nextRuleCode.ts
44989
- import { readFileSync as readFileSync62 } from "fs";
44821
+ import { readFileSync as readFileSync61 } from "fs";
44990
44822
  var CODE_PREFIX = "R";
44991
44823
  function nextRuleCode(root2) {
44992
44824
  const numbers = findClaudeFiles(root2).flatMap(
44993
- (file) => parseRulesSection(readFileSync62(file, "utf8")).map(
44825
+ (file) => parseRulesSection(readFileSync61(file, "utf8")).map(
44994
44826
  (rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
44995
44827
  )
44996
44828
  );
@@ -45017,7 +44849,7 @@ function resolveRuleScope(target) {
45017
44849
 
45018
44850
  // src/commands/rules/addRule.ts
45019
44851
  function read3(file) {
45020
- return existsSync77(file) ? readFileSync63(file, "utf8") : "";
44852
+ return existsSync77(file) ? readFileSync62(file, "utf8") : "";
45021
44853
  }
45022
44854
  function addRule(text20, options2) {
45023
44855
  const rule = text20.trim();
@@ -45247,12 +45079,12 @@ function mapDataToEvents(data) {
45247
45079
  const levelIdx = col("Level");
45248
45080
  const exIdx = col("Exception");
45249
45081
  const msgIdx = col("Message");
45250
- return data.Rows.map((row3) => ({
45251
- Timestamp: ticksToIso(row3[tsIdx]),
45252
- Level: String(row3[levelIdx] ?? ""),
45253
- Exception: row3[exIdx] != null ? String(row3[exIdx]) : void 0,
45082
+ return data.Rows.map((row2) => ({
45083
+ Timestamp: ticksToIso(row2[tsIdx]),
45084
+ Level: String(row2[levelIdx] ?? ""),
45085
+ Exception: row2[exIdx] != null ? String(row2[exIdx]) : void 0,
45254
45086
  Properties: [],
45255
- MessageTemplateTokens: [{ Text: String(row3[msgIdx] ?? "") }]
45087
+ MessageTemplateTokens: [{ Text: String(row2[msgIdx] ?? "") }]
45256
45088
  }));
45257
45089
  }
45258
45090
 
@@ -45540,7 +45372,7 @@ function findShownSessionFiles(body, writtenPaths, locations) {
45540
45372
  }
45541
45373
 
45542
45374
  // src/commands/show/sessionWrittenPaths.ts
45543
- import { readFileSync as readFileSync64 } from "fs";
45375
+ import { readFileSync as readFileSync63 } from "fs";
45544
45376
 
45545
45377
  // src/commands/sessions/shared/asRecord.ts
45546
45378
  function asRecord(value) {
@@ -45568,7 +45400,7 @@ function writtenFilePaths(entry) {
45568
45400
  function sessionWrittenPaths(transcriptPath2) {
45569
45401
  let text20;
45570
45402
  try {
45571
- text20 = readFileSync64(transcriptPath2, "utf8");
45403
+ text20 = readFileSync63(transcriptPath2, "utf8");
45572
45404
  } catch {
45573
45405
  return [];
45574
45406
  }
@@ -45687,12 +45519,12 @@ import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync48 } from "fs";
45687
45519
  import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync47 } from "fs";
45688
45520
 
45689
45521
  // src/commands/slack/readSlackParts.ts
45690
- import { readFileSync as readFileSync65 } from "fs";
45522
+ import { readFileSync as readFileSync64 } from "fs";
45691
45523
  function readSlackParts(files) {
45692
45524
  return files.map((file) => {
45693
45525
  let contents;
45694
45526
  try {
45695
- contents = readFileSync65(file, "utf8");
45527
+ contents = readFileSync64(file, "utf8");
45696
45528
  } catch {
45697
45529
  console.error(`Error: Part file not found: ${file}`);
45698
45530
  process.exit(1);
@@ -45912,8 +45744,8 @@ function printTable(rows) {
45912
45744
  const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
45913
45745
  console.log(chalk276.dim(header));
45914
45746
  console.log(chalk276.dim("-".repeat(header.length)));
45915
- for (const row3 of rows) {
45916
- const line = columns.map((c, i) => formatCell(row3[c]).padEnd(widths[i])).join(" ");
45747
+ for (const row2 of rows) {
45748
+ const line = columns.map((c, i) => formatCell(row2[c]).padEnd(widths[i])).join(" ");
45917
45749
  console.log(line);
45918
45750
  }
45919
45751
  console.log(chalk276.dim(`
@@ -46352,13 +46184,13 @@ function syncCodexHooks(sourcePath) {
46352
46184
  // src/commands/sync/syncCodex.ts
46353
46185
  function syncCodex(claudeDir, options2) {
46354
46186
  if (!isHarnessAvailable("codex")) return;
46355
- const { total: total3, names } = installHarnessCommands(
46187
+ const { total: total2, names } = installHarnessCommands(
46356
46188
  claudeDir,
46357
46189
  harnesses.codex,
46358
46190
  commandToSkill
46359
46191
  );
46360
46192
  syncCodexHooks(path98.join(claudeDir, "..", "codex", "config.toml"));
46361
- console.log(`Synced ${total3} skill(s) to ~/.codex/skills`);
46193
+ console.log(`Synced ${total2} skill(s) to ~/.codex/skills`);
46362
46194
  if (!options2?.prune) return;
46363
46195
  const force = options2.force ?? false;
46364
46196
  reportPrune(
@@ -46806,9 +46638,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
46806
46638
  }
46807
46639
 
46808
46640
  // src/commands/transcript/convert/readCleanedCues.ts
46809
- import { readFileSync as readFileSync70 } from "fs";
46641
+ import { readFileSync as readFileSync69 } from "fs";
46810
46642
  function readCleanedCues(inputPath) {
46811
- return deduplicateCues(parseVtt(readFileSync70(inputPath, "utf8")));
46643
+ return deduplicateCues(parseVtt(readFileSync69(inputPath, "utf8")));
46812
46644
  }
46813
46645
 
46814
46646
  // src/commands/transcript/clean.ts
@@ -46816,21 +46648,21 @@ var FORMATS = ["md", "vtt"];
46816
46648
  function isCleanFormat(value) {
46817
46649
  return FORMATS.includes(value);
46818
46650
  }
46819
- function serialise(cues, format3, timestamps) {
46820
- return format3 === "vtt" ? formatVtt(cues) : formatChatLog(cuesToChatMessages(cues), { timestamps });
46651
+ function serialise(cues, format2, timestamps) {
46652
+ return format2 === "vtt" ? formatVtt(cues) : formatChatLog(cuesToChatMessages(cues), { timestamps });
46821
46653
  }
46822
46654
  function clean(file, options2 = {}) {
46823
- const format3 = options2.format ?? "md";
46824
- if (!isCleanFormat(format3)) {
46655
+ const format2 = options2.format ?? "md";
46656
+ if (!isCleanFormat(format2)) {
46825
46657
  console.error(
46826
- `Error: --format must be one of: ${FORMATS.join(", ")} (got: ${format3})`
46658
+ `Error: --format must be one of: ${FORMATS.join(", ")} (got: ${format2})`
46827
46659
  );
46828
46660
  process.exit(1);
46829
46661
  }
46830
46662
  const timestamps = options2.timestamps ?? false;
46831
- if (timestamps && format3 !== "md") {
46663
+ if (timestamps && format2 !== "md") {
46832
46664
  console.error(
46833
- `Error: --timestamps applies only to --format md (got: ${format3})`
46665
+ `Error: --timestamps applies only to --format md (got: ${format2})`
46834
46666
  );
46835
46667
  process.exit(1);
46836
46668
  }
@@ -46843,7 +46675,7 @@ function clean(file, options2 = {}) {
46843
46675
  console.error(`Error: no cues found in: ${file}`);
46844
46676
  process.exit(1);
46845
46677
  }
46846
- console.log(serialise(cues, format3, timestamps));
46678
+ console.log(serialise(cues, format2, timestamps));
46847
46679
  }
46848
46680
 
46849
46681
  // src/commands/transcript/shared.ts
@@ -47588,7 +47420,7 @@ function configKeys2() {
47588
47420
  }
47589
47421
 
47590
47422
  // src/commands/verify/forbiddenStrings.ts
47591
- import { existsSync as existsSync86, readFileSync as readFileSync71 } from "fs";
47423
+ import { existsSync as existsSync86, readFileSync as readFileSync70 } from "fs";
47592
47424
 
47593
47425
  // src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
47594
47426
  import { minimatch as minimatch10 } from "minimatch";
@@ -47635,7 +47467,7 @@ function forbiddenStrings() {
47635
47467
  }
47636
47468
  let parsed;
47637
47469
  try {
47638
- parsed = JSON.parse(readFileSync71(file, "utf8"));
47470
+ parsed = JSON.parse(readFileSync70(file, "utf8"));
47639
47471
  } catch (error) {
47640
47472
  console.log(`Could not parse ${file}: ${error.message}`);
47641
47473
  process.exit(1);
@@ -47707,7 +47539,7 @@ Total: ${lines2.length} hardcoded color(s)`);
47707
47539
  }
47708
47540
 
47709
47541
  // src/commands/verify/migrations.ts
47710
- import { readFileSync as readFileSync72 } from "fs";
47542
+ import { readFileSync as readFileSync71 } from "fs";
47711
47543
  import path105 from "path";
47712
47544
 
47713
47545
  // src/commands/verify/migrations/checkAppendOnly.ts
@@ -47872,7 +47704,7 @@ function migrations2() {
47872
47704
  if (ref) {
47873
47705
  const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
47874
47706
  const current2 = new Map(
47875
- files.map((file) => [file, readFileSync72(path105.join(dir, file), "utf8")])
47707
+ files.map((file) => [file, readFileSync71(path105.join(dir, file), "utf8")])
47876
47708
  );
47877
47709
  for (const finding of checkAppendOnly(baseline, current2)) {
47878
47710
  problems.push(
@@ -48347,10 +48179,6 @@ var rules = [
48347
48179
  matches: (path109) => path109.startsWith("claude/skills/"),
48348
48180
  reason: "claude/skills changed"
48349
48181
  },
48350
- {
48351
- matches: (path109) => path109.startsWith("src/commands/review/"),
48352
- reason: "review-ci bundle sources changed"
48353
- },
48354
48182
  {
48355
48183
  matches: (path109) => path109 === "claude/settings.json",
48356
48184
  reason: "claude/settings.json changed"
@@ -48830,7 +48658,7 @@ function registerWatch(program) {
48830
48658
 
48831
48659
  // src/commands/roam/postRoamActivity.ts
48832
48660
  import { execFileSync as execFileSync31 } from "child_process";
48833
- import { readdirSync as readdirSync26, readFileSync as readFileSync73, statSync as statSync14 } from "fs";
48661
+ import { readdirSync as readdirSync26, readFileSync as readFileSync72, statSync as statSync14 } from "fs";
48834
48662
  import { join as join109 } from "path";
48835
48663
  function findPortFile(roamDir) {
48836
48664
  let entries;
@@ -48861,7 +48689,7 @@ function postRoamActivity(app, event) {
48861
48689
  if (!portFile) return;
48862
48690
  let port;
48863
48691
  try {
48864
- port = readFileSync73(portFile, "utf8").trim();
48692
+ port = readFileSync72(portFile, "utf8").trim();
48865
48693
  } catch {
48866
48694
  return;
48867
48695
  }
@@ -49482,11 +49310,11 @@ function applyLine(result, pending, line) {
49482
49310
  }
49483
49311
 
49484
49312
  // src/commands/sessions/daemon/readDaemonPidFile.ts
49485
- import { readFileSync as readFileSync74 } from "fs";
49313
+ import { readFileSync as readFileSync73 } from "fs";
49486
49314
  function readDaemonPidFile() {
49487
49315
  try {
49488
49316
  const pid = Number.parseInt(
49489
- readFileSync74(daemonPaths.pid, "utf8").trim(),
49317
+ readFileSync73(daemonPaths.pid, "utf8").trim(),
49490
49318
  10
49491
49319
  );
49492
49320
  return Number.isInteger(pid) ? pid : void 0;
@@ -49705,8 +49533,8 @@ function createActivityThrottle(onActivity) {
49705
49533
  import { eq as eq57 } from "drizzle-orm";
49706
49534
  var INBOX_LAST_RUN_KEY = "inbox.lastRun";
49707
49535
  async function readInboxLastRun(orm) {
49708
- const [row3] = await orm.select().from(metadata).where(eq57(metadata.key, INBOX_LAST_RUN_KEY));
49709
- return row3 ? JSON.parse(row3.value) : void 0;
49536
+ const [row2] = await orm.select().from(metadata).where(eq57(metadata.key, INBOX_LAST_RUN_KEY));
49537
+ return row2 ? JSON.parse(row2.value) : void 0;
49710
49538
  }
49711
49539
 
49712
49540
  // src/commands/sessions/daemon/inbox/loadScanRun.ts
@@ -50329,7 +50157,7 @@ function sendResizeSnapshot(s, send) {
50329
50157
  }
50330
50158
 
50331
50159
  // src/commands/sessions/daemon/viewerSize.ts
50332
- import { readFileSync as readFileSync75, writeFileSync as writeFileSync59 } from "fs";
50160
+ import { readFileSync as readFileSync74, writeFileSync as writeFileSync59 } from "fs";
50333
50161
  var DEFAULT_SIZE = { cols: 120, rows: 30 };
50334
50162
  var remembered;
50335
50163
  function rememberViewerSize(cols, rows) {
@@ -50351,7 +50179,7 @@ function viewerSize() {
50351
50179
  function readSavedSize() {
50352
50180
  try {
50353
50181
  const { cols, rows } = JSON.parse(
50354
- readFileSync75(daemonPaths.viewerSize, "utf8")
50182
+ readFileSync74(daemonPaths.viewerSize, "utf8")
50355
50183
  );
50356
50184
  if (typeof cols === "number" && typeof rows === "number" && cols > 0)
50357
50185
  return { cols, rows };
@@ -51229,14 +51057,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
51229
51057
  }
51230
51058
 
51231
51059
  // src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
51232
- import { readFileSync as readFileSync76, writeFileSync as writeFileSync61 } from "fs";
51060
+ import { readFileSync as readFileSync75, writeFileSync as writeFileSync61 } from "fs";
51233
51061
  var KEEP_TAIL = 256 * 1024;
51234
51062
  var MAX_LOG_SIZE = 4 * 1024 * 1024;
51235
51063
  function trimWatcherLog(cwd) {
51236
51064
  const path109 = watcherLogPath(cwd);
51237
51065
  let log2;
51238
51066
  try {
51239
- log2 = readFileSync76(path109, "utf8");
51067
+ log2 = readFileSync75(path109, "utf8");
51240
51068
  } catch {
51241
51069
  return;
51242
51070
  }
@@ -51246,13 +51074,13 @@ function trimWatcherLog(cwd) {
51246
51074
  }
51247
51075
 
51248
51076
  // src/commands/sessions/daemon/worktree/appendWatcherLog.ts
51249
- import { appendFileSync as appendFileSync5, mkdirSync as mkdirSync41 } from "fs";
51077
+ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
51250
51078
  import { dirname as dirname50 } from "path";
51251
51079
  function appendWatcherLog(cwd, data) {
51252
51080
  try {
51253
51081
  const path109 = watcherLogPath(cwd);
51254
51082
  mkdirSync41(dirname50(path109), { recursive: true });
51255
- appendFileSync5(path109, data);
51083
+ appendFileSync4(path109, data);
51256
51084
  } catch {
51257
51085
  }
51258
51086
  }
@@ -52059,7 +51887,7 @@ function pidList(pids) {
52059
51887
  }
52060
51888
 
52061
51889
  // src/commands/sessions/daemon/worktree/readOccupant.ts
52062
- import { readFileSync as readFileSync77 } from "fs";
51890
+ import { readFileSync as readFileSync76 } from "fs";
52063
51891
  var VSCODE_PATHS = [
52064
51892
  "/.vscode-server/",
52065
51893
  "/.vscode-server-insiders/",
@@ -52094,7 +51922,7 @@ function parentPid(stat5) {
52094
51922
  }
52095
51923
  function readProc(procRoot, pid, file) {
52096
51924
  try {
52097
- return readFileSync77(`${procRoot}/${pid}/${file}`, "utf8");
51925
+ return readFileSync76(`${procRoot}/${pid}/${file}`, "utf8");
52098
51926
  } catch {
52099
51927
  return void 0;
52100
51928
  }
@@ -52948,10 +52776,10 @@ function applyReviewPause(session, activity2) {
52948
52776
  // src/shared/db/getPhaseActiveMs.ts
52949
52777
  import { and as and26, eq as eq58 } from "drizzle-orm";
52950
52778
  async function getPhaseActiveMs(db, itemId2, phaseIdx) {
52951
- const [row3] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
52779
+ const [row2] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
52952
52780
  and26(eq58(phaseUsage.itemId, itemId2), eq58(phaseUsage.phaseIdx, phaseIdx))
52953
52781
  );
52954
- return row3?.activeMs ?? 0;
52782
+ return row2?.activeMs ?? 0;
52955
52783
  }
52956
52784
 
52957
52785
  // src/commands/sessions/daemon/loadPhaseActiveMs.ts
@@ -58301,7 +58129,7 @@ function handleConnection(socket, manager) {
58301
58129
  import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync63 } from "fs";
58302
58130
 
58303
58131
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
58304
- import { readFileSync as readFileSync78 } from "fs";
58132
+ import { readFileSync as readFileSync77 } from "fs";
58305
58133
  var WATCHDOG_INTERVAL_MS = 5e3;
58306
58134
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
58307
58135
  const timer = setInterval(() => {
@@ -58312,7 +58140,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
58312
58140
  }
58313
58141
  function ownsPidFile() {
58314
58142
  try {
58315
- return readFileSync78(daemonPaths.pid, "utf8").trim() === String(process.pid);
58143
+ return readFileSync77(daemonPaths.pid, "utf8").trim() === String(process.pid);
58316
58144
  } catch {
58317
58145
  return false;
58318
58146
  }