@staff0rd/assist 0.1067.0 → 0.1068.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.1068.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
 
@@ -29150,9 +29150,14 @@ function extractRustCommentTexts(text20) {
29150
29150
  }
29151
29151
 
29152
29152
  // src/commands/editHook/extractYamlComments.ts
29153
+ var SHA_PINNED_USES = /^\s*(?:-\s+)?uses:\s*\S+@[0-9a-f]{40}\s+$/i;
29153
29154
  function blankNonNewline2(text20) {
29154
29155
  return text20.replace(/[^\n]/g, " ");
29155
29156
  }
29157
+ function isShaPinVersionComment(work, index3) {
29158
+ const lineStart = work.lastIndexOf("\n", index3 - 1) + 1;
29159
+ return SHA_PINNED_USES.test(work.slice(lineStart, index3));
29160
+ }
29156
29161
  function extractYamlComments(text20) {
29157
29162
  const work = text20.replace(
29158
29163
  /"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g,
@@ -29160,6 +29165,8 @@ function extractYamlComments(text20) {
29160
29165
  );
29161
29166
  const comments3 = [];
29162
29167
  for (const match of work.matchAll(/(?:^|\s)(#.*)/gm)) {
29168
+ const hashIndex = match.index + match[0].length - match[1].length;
29169
+ if (isShaPinVersionComment(work, hashIndex)) continue;
29163
29170
  comments3.push(match[1]);
29164
29171
  }
29165
29172
  return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0);
@@ -29411,13 +29418,13 @@ import chalk182 from "chalk";
29411
29418
  function printCountTable(labelHeader, rows) {
29412
29419
  const labelWidth = Math.max(
29413
29420
  labelHeader.length,
29414
- ...rows.map((row3) => row3.label.length)
29421
+ ...rows.map((row2) => row2.label.length)
29415
29422
  );
29416
29423
  const header = `${labelHeader.padEnd(labelWidth)} Commits`;
29417
29424
  console.log(chalk182.dim(header));
29418
29425
  console.log(chalk182.dim("-".repeat(header.length)));
29419
- for (const row3 of rows) {
29420
- console.log(`${row3.label.padEnd(labelWidth)} ${row3.count}`);
29426
+ for (const row2 of rows) {
29427
+ console.log(`${row2.label.padEnd(labelWidth)} ${row2.count}`);
29421
29428
  }
29422
29429
  }
29423
29430
 
@@ -29747,7 +29754,7 @@ function buildFixStructurePlan(issues, options2) {
29747
29754
  tooDeep,
29748
29755
  typeChangeCount: entries.filter((entry) => entry.typeChange).length,
29749
29756
  labelRemovalCount: entries.reduce(
29750
- (total3, entry) => total3 + entry.labelRemovals.length,
29757
+ (total2, entry) => total2 + entry.labelRemovals.length,
29751
29758
  0
29752
29759
  )
29753
29760
  };
@@ -30156,8 +30163,8 @@ var VIDEO_EXTENSIONS = /* @__PURE__ */ new Set([".mp4", ".webm", ".mov"]);
30156
30163
  function cell(text20) {
30157
30164
  return text20.replaceAll("|", String.raw`\|`);
30158
30165
  }
30159
- function row(cells2) {
30160
- return `| ${cells2.join(" | ")} |`;
30166
+ function row(cells) {
30167
+ return `| ${cells.join(" | ")} |`;
30161
30168
  }
30162
30169
  function imageTable(images) {
30163
30170
  if (images.length === 0) return [];
@@ -30434,17 +30441,6 @@ function resolveIssueMilestone(target, wanted) {
30434
30441
 
30435
30442
  // src/commands/prs/shared.ts
30436
30443
  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
30444
  function isGhNotInstalled(error) {
30449
30445
  if (error instanceof Error) {
30450
30446
  const msg = error.message.toLowerCase();
@@ -30469,7 +30465,7 @@ function viewCurrentPr(fields) {
30469
30465
  const { org, repo } = getRepoInfo();
30470
30466
  return JSON.parse(
30471
30467
  execSync42(
30472
- `gh pr view ${currentPrSelector(getCurrentBranch2)} --json ${fields} -R ${org}/${repo}`,
30468
+ `gh pr view ${getCurrentBranch2()} --json ${fields} -R ${org}/${repo}`,
30473
30469
  {
30474
30470
  encoding: "utf8"
30475
30471
  }
@@ -31466,14 +31462,14 @@ async function scanUnopenedThreads(threadIds, scanThreads, onEvent = () => {
31466
31462
  // src/commands/inbox/scanInboxWithCoverage.ts
31467
31463
  async function scanInboxWithCoverage(since, listener) {
31468
31464
  const runs = [];
31469
- const total3 = () => runs.reduce(addScanUsage, emptyScanUsage());
31465
+ const total2 = () => runs.reduce(addScanUsage, emptyScanUsage());
31470
31466
  const run4 = (pass) => {
31471
31467
  const slot = runs.push(emptyScanUsage()) - 1;
31472
31468
  return runInboxScanClaude(pass, {
31473
31469
  ...listener,
31474
31470
  onUsage: (usage) => {
31475
31471
  runs[slot] = usage;
31476
- listener.onUsage?.(total3());
31472
+ listener.onUsage?.(total2());
31477
31473
  }
31478
31474
  });
31479
31475
  };
@@ -31490,7 +31486,7 @@ async function scanInboxWithCoverage(since, listener) {
31490
31486
  }),
31491
31487
  listener.onEvent
31492
31488
  );
31493
- return { messages: [...main.messages, ...followUp], usage: total3() };
31489
+ return { messages: [...main.messages, ...followUp], usage: total2() };
31494
31490
  }
31495
31491
 
31496
31492
  // src/shared/db/finishJobRun.ts
@@ -31501,8 +31497,8 @@ async function finishJobRun(db, id, result) {
31501
31497
 
31502
31498
  // src/shared/db/startJobRun.ts
31503
31499
  async function startJobRun(db, run4) {
31504
- const [row3] = await db.insert(jobRuns).values({ ...run4, status: "running" }).returning({ id: jobRuns.id });
31505
- return row3.id;
31500
+ const [row2] = await db.insert(jobRuns).values({ ...run4, status: "running" }).returning({ id: jobRuns.id });
31501
+ return row2.id;
31506
31502
  }
31507
31503
 
31508
31504
  // src/commands/inbox/withInboxScanJob.ts
@@ -34274,12 +34270,12 @@ function printPromptsTable(rows) {
34274
34270
  ].join(" ");
34275
34271
  console.log(chalk205.dim(header));
34276
34272
  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);
34273
+ for (const row2 of rows) {
34274
+ const count10 = String(row2.count).padStart(countWidth);
34275
+ const tool = row2.tool.padEnd(toolWidth);
34276
+ const command = truncate2(row2.command, 60).padEnd(commandWidth);
34281
34277
  console.log(
34282
- `${chalk205.yellow(count10)} ${tool} ${command} ${chalk205.dim(row3.repos)}`
34278
+ `${chalk205.yellow(count10)} ${tool} ${command} ${chalk205.dim(row2.repos)}`
34283
34279
  );
34284
34280
  }
34285
34281
  }
@@ -34351,17 +34347,17 @@ function getPageSlice(pullRequests, page) {
34351
34347
  const start2 = page * PAGE_SIZE2;
34352
34348
  return pullRequests.slice(start2, start2 + PAGE_SIZE2);
34353
34349
  }
34354
- function pageHeader(page, totalPages, total3) {
34350
+ function pageHeader(page, totalPages, total2) {
34355
34351
  return `
34356
- Page ${page + 1} of ${totalPages} (${total3} total)
34352
+ Page ${page + 1} of ${totalPages} (${total2} total)
34357
34353
  `;
34358
34354
  }
34359
34355
  function displayPage(pullRequests, totalPages, page) {
34360
34356
  console.log(pageHeader(page, totalPages, pullRequests.length));
34361
34357
  for (const pr of getPageSlice(pullRequests, page)) printPr(pr);
34362
34358
  }
34363
- function hasNextPage(page, total3) {
34364
- return page < total3 - 1;
34359
+ function hasNextPage(page, total2) {
34360
+ return page < total2 - 1;
34365
34361
  }
34366
34362
  var NEXT_CHOICE = { name: "Next page", value: "next" };
34367
34363
  var PREV_CHOICE = { name: "Previous page", value: "prev" };
@@ -34660,7 +34656,7 @@ function findPrForBranch(repo, branch2) {
34660
34656
  return Number.parseInt(stdout.trim(), 10);
34661
34657
  }
34662
34658
  function currentAzureDevopsPr(repo) {
34663
- const prId = getPinnedPr() ?? findPrForBranch(repo, getCurrentBranch2());
34659
+ const prId = findPrForBranch(repo, getCurrentBranch2());
34664
34660
  if (Number.isNaN(prId)) {
34665
34661
  console.error("Error: No pull request found for the current branch.");
34666
34662
  process.exit(1);
@@ -36569,11 +36565,11 @@ function parseReadBudget(value) {
36569
36565
  `Invalid budget "${value}". Use a duration like 45s, 1m30s or 2m.`
36570
36566
  );
36571
36567
  }
36572
- const total3 = Number(minutes ?? 0) * 60 + Number(seconds ?? 0);
36573
- if (total3 === 0) {
36568
+ const total2 = Number(minutes ?? 0) * 60 + Number(seconds ?? 0);
36569
+ if (total2 === 0) {
36574
36570
  throw new Error(`Invalid budget "${value}". Value must be at least 1s.`);
36575
36571
  }
36576
- return total3;
36572
+ return total2;
36577
36573
  }
36578
36574
 
36579
36575
  // src/commands/readTime/resolveReadTimeTarget.ts
@@ -36705,12 +36701,12 @@ import chalk215 from "chalk";
36705
36701
 
36706
36702
  // src/shared/createConnectionAuth.ts
36707
36703
  import chalk210 from "chalk";
36708
- function listConnections(connections, format3) {
36704
+ function listConnections(connections, format2) {
36709
36705
  if (connections.length === 0) {
36710
36706
  console.log("No connections configured.");
36711
36707
  } else {
36712
36708
  for (const c of connections) {
36713
- console.log(format3(c));
36709
+ console.log(format2(c));
36714
36710
  }
36715
36711
  }
36716
36712
  }
@@ -40830,7 +40826,7 @@ function basename24(path109) {
40830
40826
  return path109.slice(path109.lastIndexOf("/") + 1);
40831
40827
  }
40832
40828
  function sum(nodes, key) {
40833
- return nodes.reduce((total3, node) => total3 + node[key], 0);
40829
+ return nodes.reduce((total2, node) => total2 + node[key], 0);
40834
40830
  }
40835
40831
  function byName(a, b) {
40836
40832
  return a.name.localeCompare(b.name);
@@ -40874,7 +40870,7 @@ function buildHighLevelTree(files) {
40874
40870
 
40875
40871
  // src/commands/review/highLevel/buildHighLevelStructure.ts
40876
40872
  function sum2(files, key) {
40877
- return files.reduce((total3, file) => total3 + file[key], 0);
40873
+ return files.reduce((total2, file) => total2 + file[key], 0);
40878
40874
  }
40879
40875
  function countOf(files, status2) {
40880
40876
  return files.filter((file) => file.status === status2).length;
@@ -41038,7 +41034,7 @@ var EVIDENCE_PATTERNS = [
41038
41034
  ];
41039
41035
  function countEvidence(body) {
41040
41036
  return EVIDENCE_PATTERNS.reduce(
41041
- (total3, pattern2) => total3 + (body.match(pattern2)?.length ?? 0),
41037
+ (total2, pattern2) => total2 + (body.match(pattern2)?.length ?? 0),
41042
41038
  0
41043
41039
  );
41044
41040
  }
@@ -41606,12 +41602,12 @@ function visitCase(call, context) {
41606
41602
  if (!context.changed) return [toCase(call, context)];
41607
41603
  const lines2 = changedLines(call, context.changed);
41608
41604
  if (lines2.length === 0) return [];
41609
- const total3 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
41605
+ const total2 = call.getEndLineNumber() - call.getStartLineNumber() + 1;
41610
41606
  return [
41611
41607
  toCase(
41612
41608
  call,
41613
41609
  context,
41614
- lines2.length === total3 ? { change: "added" } : { change: "modified", changedLines: lines2 }
41610
+ lines2.length === total2 ? { change: "added" } : { change: "modified", changedLines: lines2 }
41615
41611
  )
41616
41612
  ];
41617
41613
  }
@@ -42388,455 +42384,6 @@ async function runHighLevelReview(number, options2 = {}) {
42388
42384
  // src/commands/review/reviewPr.ts
42389
42385
  import { basename as basename26 } from "path";
42390
42386
 
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
42387
  // src/commands/review/cachedReviewerResult.ts
42841
42388
  import { statSync as statSync12 } from "fs";
42842
42389
  function cachedReviewerResult(name, outputPath) {
@@ -42886,10 +42433,10 @@ function renderEntry(entry, frame) {
42886
42433
  }
42887
42434
 
42888
42435
  // src/commands/review/startReviewLog.ts
42889
- import { format as format2 } from "util";
42436
+ import { format } from "util";
42890
42437
 
42891
42438
  // src/commands/review/createReviewLogSink.ts
42892
- import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync30 } from "fs";
42439
+ import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync30 } from "fs";
42893
42440
  import { join as join93 } from "path";
42894
42441
  var LOG_FILE = "review.log";
42895
42442
  function createReviewLogSink() {
@@ -42902,7 +42449,7 @@ function createReviewLogSink() {
42902
42449
  buffered.push(stripped);
42903
42450
  return;
42904
42451
  }
42905
- appendFileSync4(logPath2, `${stripped}
42452
+ appendFileSync3(logPath2, `${stripped}
42906
42453
  `);
42907
42454
  },
42908
42455
  attach(reviewDir) {
@@ -42915,7 +42462,7 @@ function createReviewLogSink() {
42915
42462
  ...buffered
42916
42463
  ];
42917
42464
  buffered = [];
42918
- appendFileSync4(logPath2, `${lines2.join("\n")}
42465
+ appendFileSync3(logPath2, `${lines2.join("\n")}
42919
42466
  `);
42920
42467
  }
42921
42468
  };
@@ -42934,7 +42481,7 @@ function patch(method) {
42934
42481
  const original = console[method].bind(console);
42935
42482
  console[method] = (...args) => {
42936
42483
  original(...args);
42937
- appendReviewLog(format2(...args));
42484
+ appendReviewLog(format(...args));
42938
42485
  };
42939
42486
  }
42940
42487
  function startReviewLog() {
@@ -43631,12 +43178,12 @@ function parseCodexEvent(line) {
43631
43178
  }
43632
43179
 
43633
43180
  // src/commands/review/createCodexLineHandler.ts
43634
- function addUsage(total3, turn) {
43635
- if (!total3) return turn;
43181
+ function addUsage(total2, turn) {
43182
+ if (!total2) return turn;
43636
43183
  return {
43637
- input: total3.input + turn.input,
43638
- output: total3.output + turn.output,
43639
- cacheRead: total3.cacheRead + turn.cacheRead
43184
+ input: total2.input + turn.input,
43185
+ output: total2.output + turn.output,
43186
+ cacheRead: total2.cacheRead + turn.cacheRead
43640
43187
  };
43641
43188
  }
43642
43189
  function createCodexLineHandler(name, spinner, model) {
@@ -43778,7 +43325,138 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
43778
43325
  import { existsSync as existsSync73, unlinkSync as unlinkSync18 } from "fs";
43779
43326
 
43780
43327
  // src/commands/review/synthesise.ts
43781
- import { readFileSync as readFileSync58 } from "fs";
43328
+ import { readFileSync as readFileSync57 } from "fs";
43329
+
43330
+ // src/commands/review/carriedUnanchoredFindings.ts
43331
+ function carriedUnanchoredFindings(unanchored) {
43332
+ return unanchored.filter((finding) => finding.source !== "already-raised");
43333
+ }
43334
+
43335
+ // src/commands/review/parseFindings.ts
43336
+ var SEVERITIES = ["blocker", "major", "minor", "nit"];
43337
+ var SOURCES = [
43338
+ "confirmed",
43339
+ "disputed",
43340
+ "claude-only",
43341
+ "codex-only",
43342
+ "already-raised"
43343
+ ];
43344
+ function isSeverity(value) {
43345
+ return SEVERITIES.includes(value);
43346
+ }
43347
+ function isSource(value) {
43348
+ return SOURCES.includes(value);
43349
+ }
43350
+ function extractField(block, field) {
43351
+ const re = new RegExp(`^-\\s+${field}:\\s*(.*)$`, "im");
43352
+ const match = block.match(re);
43353
+ return match ? match[1].trim() : "";
43354
+ }
43355
+ function stripBackticks(value) {
43356
+ return value.replace(/^`+|`+$/g, "").trim();
43357
+ }
43358
+ function parseFindingBlock(block) {
43359
+ const newlineIndex = block.indexOf("\n");
43360
+ const title = newlineIndex === -1 ? block.trim() : block.slice(0, newlineIndex).trim();
43361
+ const body = newlineIndex === -1 ? "" : block.slice(newlineIndex + 1);
43362
+ const severityRaw = extractField(body, "Severity").toLowerCase();
43363
+ const sourceRaw = extractField(body, "Source").toLowerCase();
43364
+ return {
43365
+ title,
43366
+ severity: isSeverity(severityRaw) ? severityRaw : null,
43367
+ source: isSource(sourceRaw) ? sourceRaw : null,
43368
+ location: stripBackticks(extractField(body, "Location")),
43369
+ impact: extractField(body, "Impact"),
43370
+ recommendation: extractField(body, "Recommendation")
43371
+ };
43372
+ }
43373
+ function parseFindings(markdown) {
43374
+ return markdown.split(/^###\s+Finding:\s*/m).slice(1).map(parseFindingBlock);
43375
+ }
43376
+
43377
+ // src/commands/review/summariseSynthesis.ts
43378
+ var SEVERITIES2 = ["blocker", "major", "minor", "nit"];
43379
+ function isSeverity2(value) {
43380
+ return SEVERITIES2.includes(value);
43381
+ }
43382
+ function extractSummary(markdown) {
43383
+ const match = markdown.match(
43384
+ /^##\s+Summary\s*\n([\s\S]*?)(?=\n##\s|\n###\s|$)/m
43385
+ );
43386
+ if (!match) return "";
43387
+ return match[1].trim();
43388
+ }
43389
+ function countBySeverity(markdown) {
43390
+ const totals = { blocker: 0, major: 0, minor: 0, nit: 0 };
43391
+ const regex = /^-\s+Severity:\s*([a-zA-Z]+)/gm;
43392
+ for (const match of markdown.matchAll(regex)) {
43393
+ const severity = match[1].toLowerCase();
43394
+ if (isSeverity2(severity)) totals[severity]++;
43395
+ }
43396
+ return totals;
43397
+ }
43398
+ function summariseSynthesis(markdown) {
43399
+ const totals = countBySeverity(markdown);
43400
+ const findingCount = totals.blocker + totals.major + totals.minor + totals.nit;
43401
+ return { summary: extractSummary(markdown), totals, findingCount };
43402
+ }
43403
+ function formatSynthesisSummary(summary) {
43404
+ const lines2 = [];
43405
+ const { totals, findingCount } = summary;
43406
+ lines2.push(
43407
+ `Findings: ${findingCount} (blocker ${totals.blocker}, major ${totals.major}, minor ${totals.minor}, nit ${totals.nit})`
43408
+ );
43409
+ if (summary.summary) lines2.push("", summary.summary);
43410
+ return lines2.join("\n");
43411
+ }
43412
+
43413
+ // src/commands/review/buildReviewSummary.ts
43414
+ var UNANCHOR_REASONS = {
43415
+ "out-of-diff": "its line falls outside the PR diff",
43416
+ unlocated: "it has no parseable file:line",
43417
+ "comment-rejected": "GitHub rejected its line comment"
43418
+ };
43419
+ function formatFindingLine(finding) {
43420
+ const severity = finding.severity ?? "finding";
43421
+ return `- **${severity}: ${finding.title}**`;
43422
+ }
43423
+ function formatLocation(finding) {
43424
+ const location = finding.location.trim();
43425
+ if (!location || location.toLowerCase() === "n/a") return "no location";
43426
+ return `\`${location}\``;
43427
+ }
43428
+ function formatUnanchoredFinding(finding) {
43429
+ const lines2 = [
43430
+ `${formatFindingLine(finding)} \u2014 ${formatLocation(finding)}`,
43431
+ ` - Not anchored: ${UNANCHOR_REASONS[finding.reason]}`
43432
+ ];
43433
+ if (finding.impact) lines2.push(` - Impact: ${finding.impact}`);
43434
+ if (finding.recommendation)
43435
+ lines2.push(` - Recommendation: ${finding.recommendation}`);
43436
+ return lines2;
43437
+ }
43438
+ function buildReviewSummary(markdown, unanchored = []) {
43439
+ const summary = summariseSynthesis(markdown);
43440
+ const findings2 = parseFindings(markdown);
43441
+ const lines2 = ["## Code review summary", "", formatSynthesisSummary(summary)];
43442
+ if (findings2.length > 0) {
43443
+ lines2.push("", "### Findings", "");
43444
+ for (const finding of findings2) lines2.push(formatFindingLine(finding));
43445
+ }
43446
+ const carried = carriedUnanchoredFindings(unanchored);
43447
+ if (carried.length > 0) {
43448
+ lines2.push(
43449
+ "",
43450
+ "### Findings not anchored to the diff",
43451
+ "",
43452
+ "No line comment could be attached to these, so the detail is here instead.",
43453
+ ""
43454
+ );
43455
+ for (const finding of carried)
43456
+ lines2.push(...formatUnanchoredFinding(finding));
43457
+ }
43458
+ return lines2.join("\n");
43459
+ }
43782
43460
 
43783
43461
  // src/commands/review/buildSynthesisStdin.ts
43784
43462
  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 +43525,7 @@ Files:
43847
43525
 
43848
43526
  // src/commands/review/synthesise.ts
43849
43527
  function printSummary2(synthesisPath) {
43850
- const markdown = readFileSync58(synthesisPath, "utf8");
43528
+ const markdown = readFileSync57(synthesisPath, "utf8");
43851
43529
  console.log("");
43852
43530
  console.log(buildReviewSummary(markdown));
43853
43531
  console.log("");
@@ -44001,8 +43679,8 @@ async function runReviewPipeline(paths, options2) {
44001
43679
  }
44002
43680
 
44003
43681
  // src/commands/review/annotateDiffWithLineNumbers.ts
44004
- var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
44005
- var HUNK_HEADER4 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
43682
+ var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
43683
+ var HUNK_HEADER3 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
44006
43684
  var GUTTER_WIDTH = 6;
44007
43685
  function gutter(lineNumber) {
44008
43686
  const label = lineNumber === null ? "" : String(lineNumber);
@@ -44012,11 +43690,11 @@ function annotateDiffWithLineNumbers(diff3) {
44012
43690
  let inFile = false;
44013
43691
  let newLine = 0;
44014
43692
  return diff3.split("\n").map((line) => {
44015
- if (FILE_HEADER2.test(line)) {
43693
+ if (FILE_HEADER.test(line)) {
44016
43694
  inFile = true;
44017
43695
  return gutter(null) + line;
44018
43696
  }
44019
- const hunkMatch = line.match(HUNK_HEADER4);
43697
+ const hunkMatch = line.match(HUNK_HEADER3);
44020
43698
  if (hunkMatch) {
44021
43699
  newLine = Number(hunkMatch[1]);
44022
43700
  return gutter(null) + line;
@@ -44133,9 +43811,9 @@ function buildReviewPaths(repoRoot2, key) {
44133
43811
  }
44134
43812
 
44135
43813
  // src/commands/review/fetchExistingComments.ts
44136
- import { execSync as execSync59 } from "child_process";
43814
+ import { execSync as execSync58 } from "child_process";
44137
43815
  function fetchRawComments(org, repo, prNumber) {
44138
- const out = execSync59(
43816
+ const out = execSync58(
44139
43817
  `gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
44140
43818
  { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
44141
43819
  );
@@ -44198,6 +43876,35 @@ function logPriorComments(count10) {
44198
43876
  // src/commands/review/gatherContext.ts
44199
43877
  import { execSync as execSync61 } from "child_process";
44200
43878
 
43879
+ // src/commands/review/fetchPrDiff.ts
43880
+ import { execSync as execSync59 } from "child_process";
43881
+ function fetchPrDiff(prNumber, baseSha, headSha) {
43882
+ const { org, repo } = getRepoInfo();
43883
+ try {
43884
+ return execSync59(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
43885
+ encoding: "utf8",
43886
+ maxBuffer: 256 * 1024 * 1024,
43887
+ stdio: ["ignore", "pipe", "pipe"]
43888
+ });
43889
+ } catch (error) {
43890
+ if (!isDiffTooLarge(error)) throw error;
43891
+ return fetchDiffViaGit(baseSha, headSha);
43892
+ }
43893
+ }
43894
+ function isDiffTooLarge(error) {
43895
+ return error instanceof Error && (error.message.includes("too_large") || error.message.includes("maximum number of files"));
43896
+ }
43897
+ function fetchDiffViaGit(baseSha, headSha) {
43898
+ try {
43899
+ execSync59(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
43900
+ } catch {
43901
+ }
43902
+ return execSync59(`git diff ${baseSha}...${headSha}`, {
43903
+ encoding: "utf8",
43904
+ maxBuffer: 256 * 1024 * 1024
43905
+ });
43906
+ }
43907
+
44201
43908
  // src/commands/review/fetchPrDiffInfo.ts
44202
43909
  import { execSync as execSync60 } from "child_process";
44203
43910
  function getCurrentBranch3() {
@@ -44213,11 +43920,6 @@ function runGh2(command) {
44213
43920
  });
44214
43921
  }
44215
43922
  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
43923
  const parsed = JSON.parse(
44222
43924
  runGh2(
44223
43925
  `gh pr list --state open --head ${branch2} --json ${FIELDS3} -R ${org}/${repo}`
@@ -44292,7 +43994,7 @@ function gatherChangedContext() {
44292
43994
  }
44293
43995
 
44294
43996
  // src/commands/review/postReviewToPr.ts
44295
- import { readFileSync as readFileSync59 } from "fs";
43997
+ import { readFileSync as readFileSync58 } from "fs";
44296
43998
 
44297
43999
  // src/commands/review/chainAddressComments.ts
44298
44000
  function chainAddressComments(prNumber, announce) {
@@ -44352,6 +44054,13 @@ async function postFindings(findings2) {
44352
44054
  return { posted, failed: failed3 };
44353
44055
  }
44354
44056
 
44057
+ // src/commands/review/appendCiFooter.ts
44058
+ function appendCiFooter(body, ciFooter) {
44059
+ return ciFooter ? `${body}
44060
+
44061
+ ${ciFooter}` : body;
44062
+ }
44063
+
44355
44064
  // src/commands/review/buildReviewBody.ts
44356
44065
  function buildReviewBody(markdown, unanchored, ciFooter) {
44357
44066
  return appendCiFooter(
@@ -44360,6 +44069,30 @@ function buildReviewBody(markdown, unanchored, ciFooter) {
44360
44069
  );
44361
44070
  }
44362
44071
 
44072
+ // src/commands/review/runReviewSubmission.ts
44073
+ function runReviewSubmission(mutation, body) {
44074
+ try {
44075
+ const prId = getCurrentPrNodeId();
44076
+ runGhGraphql(mutation, { prId, body });
44077
+ console.log("Submitted review.");
44078
+ return true;
44079
+ } catch (error) {
44080
+ if (isGhNotInstalled(error)) {
44081
+ console.error("Error: GitHub CLI (gh) is not installed.");
44082
+ return false;
44083
+ }
44084
+ const message3 = error instanceof Error ? error.message : String(error);
44085
+ console.error(`Failed to submit review: ${message3}`);
44086
+ return false;
44087
+ }
44088
+ }
44089
+
44090
+ // src/commands/review/submitBodyOnlyReview.ts
44091
+ var MUTATION6 = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
44092
+ function submitBodyOnlyReview(body) {
44093
+ return runReviewSubmission(MUTATION6, body);
44094
+ }
44095
+
44363
44096
  // src/commands/review/submitPendingReview.ts
44364
44097
  var MUTATION7 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
44365
44098
  function submitPendingReview(body) {
@@ -44421,6 +44154,179 @@ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options2) {
44421
44154
  return { posted, submitted: false };
44422
44155
  }
44423
44156
 
44157
+ // src/commands/review/partitionFindings.ts
44158
+ function isValidLine(n) {
44159
+ return Number.isInteger(n) && n >= 1;
44160
+ }
44161
+ function toLineBound(finding) {
44162
+ if (!finding.location || finding.location.toLowerCase() === "n/a") {
44163
+ return null;
44164
+ }
44165
+ const match = finding.location.match(/^(.+):(\d+)(?:-(\d+))?$/);
44166
+ if (!match) return null;
44167
+ const startLine = Number.parseInt(match[2], 10);
44168
+ const endLine = match[3] ? Number.parseInt(match[3], 10) : startLine;
44169
+ if (!isValidLine(startLine) || !isValidLine(endLine)) return null;
44170
+ if (endLine < startLine) return null;
44171
+ const base = { ...finding, file: match[1], line: endLine };
44172
+ return startLine === endLine ? base : { ...base, startLine };
44173
+ }
44174
+ function partitionFindings(findings2) {
44175
+ const lineBound = [];
44176
+ const unlocated = [];
44177
+ const alreadyRaised = [];
44178
+ for (const finding of findings2) {
44179
+ if (finding.source === "already-raised") {
44180
+ alreadyRaised.push(finding);
44181
+ continue;
44182
+ }
44183
+ const bound = toLineBound(finding);
44184
+ if (bound) lineBound.push(bound);
44185
+ else unlocated.push(finding);
44186
+ }
44187
+ return { lineBound, unlocated, alreadyRaised };
44188
+ }
44189
+
44190
+ // src/commands/review/buildDiffLineIndex.ts
44191
+ var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
44192
+ var HUNK_HEADER4 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
44193
+ function buildDiffLineIndex(diff3) {
44194
+ const index3 = /* @__PURE__ */ new Map();
44195
+ let currentFile = null;
44196
+ let newLine = 0;
44197
+ for (const line of diff3.split("\n")) {
44198
+ const fileMatch = line.match(FILE_HEADER2);
44199
+ if (fileMatch) {
44200
+ currentFile = fileMatch[1] === "/dev/null" ? null : fileMatch[1];
44201
+ continue;
44202
+ }
44203
+ const hunkMatch = line.match(HUNK_HEADER4);
44204
+ if (hunkMatch) {
44205
+ newLine = Number(hunkMatch[1]);
44206
+ continue;
44207
+ }
44208
+ if (currentFile === null) continue;
44209
+ if (line.startsWith("-")) continue;
44210
+ if (line.startsWith("+") || line.startsWith(" ")) {
44211
+ let set = index3.get(currentFile);
44212
+ if (!set) {
44213
+ set = /* @__PURE__ */ new Set();
44214
+ index3.set(currentFile, set);
44215
+ }
44216
+ set.add(newLine);
44217
+ newLine++;
44218
+ }
44219
+ }
44220
+ return index3;
44221
+ }
44222
+
44223
+ // src/commands/review/partitionFindingsByDiff.ts
44224
+ function isWithinDiff(finding, index3) {
44225
+ const lines2 = index3.get(finding.file);
44226
+ if (!lines2) return false;
44227
+ if (!lines2.has(finding.line)) return false;
44228
+ if (finding.startLine !== void 0 && !lines2.has(finding.startLine)) {
44229
+ return false;
44230
+ }
44231
+ return true;
44232
+ }
44233
+ function partitionFindingsByDiff(findings2, index3) {
44234
+ const inDiff = [];
44235
+ const outOfDiff = [];
44236
+ for (const finding of findings2) {
44237
+ if (isWithinDiff(finding, index3)) inDiff.push(finding);
44238
+ else outOfDiff.push(finding);
44239
+ }
44240
+ return { inDiff, outOfDiff };
44241
+ }
44242
+
44243
+ // src/commands/review/warnOutOfDiff.ts
44244
+ import chalk261 from "chalk";
44245
+ function warnOutOfDiff(outOfDiff) {
44246
+ if (outOfDiff.length === 0) return;
44247
+ console.warn(
44248
+ chalk261.yellow(
44249
+ `Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
44250
+ )
44251
+ );
44252
+ for (const finding of outOfDiff) {
44253
+ const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
44254
+ console.warn(
44255
+ ` ${chalk261.yellow("\xB7")} ${finding.title} ${chalk261.dim(
44256
+ `(${finding.file}:${range})`
44257
+ )}`
44258
+ );
44259
+ }
44260
+ }
44261
+
44262
+ // src/commands/review/selectInDiffFindings.ts
44263
+ function selectInDiffFindings(lineBound, prDiff) {
44264
+ const diff3 = fetchPrDiff(prDiff.prNumber, prDiff.baseSha, prDiff.headSha);
44265
+ const { inDiff, outOfDiff } = partitionFindingsByDiff(
44266
+ lineBound,
44267
+ buildDiffLineIndex(diff3)
44268
+ );
44269
+ warnOutOfDiff(outOfDiff);
44270
+ return {
44271
+ inDiff,
44272
+ unanchored: outOfDiff.map(
44273
+ (finding) => ({
44274
+ ...finding,
44275
+ reason: "out-of-diff"
44276
+ })
44277
+ )
44278
+ };
44279
+ }
44280
+
44281
+ // src/commands/review/warnUnlocated.ts
44282
+ import chalk262 from "chalk";
44283
+ function warnUnlocated(unlocated) {
44284
+ if (unlocated.length === 0) return;
44285
+ console.warn(
44286
+ chalk262.yellow(
44287
+ `Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
44288
+ )
44289
+ );
44290
+ for (const finding of unlocated) {
44291
+ const where = finding.location || chalk262.dim("missing");
44292
+ console.warn(
44293
+ ` ${chalk262.yellow("\xB7")} ${finding.title} ${chalk262.dim(`(${where})`)}`
44294
+ );
44295
+ }
44296
+ }
44297
+
44298
+ // src/commands/review/selectPostableFindings.ts
44299
+ function selectPostableFindings(markdown, prInfo) {
44300
+ const findings2 = parseFindings(markdown);
44301
+ if (findings2.length === 0) {
44302
+ console.log("Synthesis contains no findings; nothing to post.");
44303
+ return { inDiff: [], unanchored: [] };
44304
+ }
44305
+ const { lineBound, unlocated, alreadyRaised } = partitionFindings(findings2);
44306
+ warnUnlocated(unlocated);
44307
+ if (alreadyRaised.length > 0) {
44308
+ console.log(
44309
+ `Skipped ${alreadyRaised.length} finding(s) already raised by prior comments.`
44310
+ );
44311
+ }
44312
+ const carriedUnlocated = unlocated.map(
44313
+ (finding) => ({
44314
+ ...finding,
44315
+ reason: "unlocated"
44316
+ })
44317
+ );
44318
+ if (lineBound.length === 0) {
44319
+ console.log("No line-bound findings to comment on.");
44320
+ return { inDiff: [], unanchored: carriedUnlocated };
44321
+ }
44322
+ const { inDiff, unanchored } = selectInDiffFindings(lineBound, prInfo);
44323
+ if (inDiff.length === 0)
44324
+ console.log(
44325
+ "No findings fall within the PR diff; no line comments to post."
44326
+ );
44327
+ return { inDiff, unanchored: [...carriedUnlocated, ...unanchored] };
44328
+ }
44329
+
44424
44330
  // src/commands/review/stillOnReviewedPr.ts
44425
44331
  function currentPrNumber() {
44426
44332
  try {
@@ -44474,7 +44380,7 @@ async function confirmPost(prNumber, work, options2) {
44474
44380
  return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
44475
44381
  }
44476
44382
  async function postFindingsToPr(prInfo, synthesisPath, options2) {
44477
- const markdown = readFileSync59(synthesisPath, "utf8");
44383
+ const markdown = readFileSync58(synthesisPath, "utf8");
44478
44384
  const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
44479
44385
  const carried = carriedUnanchoredFindings(unanchored);
44480
44386
  if (inDiff.length === 0 && carried.length === 0)
@@ -44620,8 +44526,7 @@ function runPostSynthesis(synthesisPath, prInfo, options2) {
44620
44526
  prompt: options2.prompt ?? true,
44621
44527
  submit: options2.submit ?? false,
44622
44528
  addressComments: options2.addressComments ?? false,
44623
- announce: options2.announce ?? false,
44624
- ciFooter: options2.ci?.footer
44529
+ announce: options2.announce ?? false
44625
44530
  });
44626
44531
  }
44627
44532
 
@@ -44632,22 +44537,9 @@ async function reviewPr(repoRoot2, options2) {
44632
44537
  attachReviewLog(paths.reviewDir);
44633
44538
  const outcome = await runReviewPipeline(paths, {
44634
44539
  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);
44540
+ job: { repo: basename26(repoRoot2), prNumber: context.prNumber }
44541
+ });
44542
+ if (outcome.ok) await runPostSynthesis(paths.synthesisPath, context, options2);
44651
44543
  console.log(`Done. Review folder: ${paths.reviewDir}`);
44652
44544
  }
44653
44545
 
@@ -44838,11 +44730,11 @@ import path88 from "path";
44838
44730
  import chalk263 from "chalk";
44839
44731
 
44840
44732
  // src/commands/rules/updateScopedRulesIndex.ts
44841
- import { existsSync as existsSync75, readFileSync as readFileSync61, writeFileSync as writeFileSync45 } from "fs";
44733
+ import { existsSync as existsSync75, readFileSync as readFileSync60, writeFileSync as writeFileSync45 } from "fs";
44842
44734
  import path87 from "path";
44843
44735
 
44844
44736
  // src/commands/rules/scopedRuleDirectories.ts
44845
- import { readFileSync as readFileSync60 } from "fs";
44737
+ import { readFileSync as readFileSync59 } from "fs";
44846
44738
  import path86 from "path";
44847
44739
 
44848
44740
  // src/commands/rules/findClaudeFiles.ts
@@ -44866,7 +44758,7 @@ function findClaudeFiles(dir) {
44866
44758
  // src/commands/rules/scopedRuleDirectories.ts
44867
44759
  function scopedRuleDirectories(root2) {
44868
44760
  return findClaudeFiles(root2).filter(
44869
- (file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync60(file, "utf8")).length > 0
44761
+ (file) => path86.dirname(file) !== root2 && parseRulesSection(readFileSync59(file, "utf8")).length > 0
44870
44762
  ).map(
44871
44763
  (file) => `${path86.relative(root2, path86.dirname(file)).split(path86.sep).join("/")}/`
44872
44764
  ).sort();
@@ -44908,7 +44800,7 @@ function upsertScopedRulesPointer(content, directories) {
44908
44800
  function updateScopedRulesIndex(root2) {
44909
44801
  const directories = scopedRuleDirectories(root2);
44910
44802
  const rootFile = path87.join(root2, "CLAUDE.md");
44911
- const before = existsSync75(rootFile) ? readFileSync61(rootFile, "utf8") : "";
44803
+ const before = existsSync75(rootFile) ? readFileSync60(rootFile, "utf8") : "";
44912
44804
  const after = upsertScopedRulesPointer(before, directories);
44913
44805
  if (after !== before) writeFileSync45(rootFile, after);
44914
44806
  return directories;
@@ -44961,7 +44853,7 @@ function listRules(target, options2 = {}) {
44961
44853
  }
44962
44854
 
44963
44855
  // src/commands/rules/addRule.ts
44964
- import { existsSync as existsSync77, readFileSync as readFileSync63, writeFileSync as writeFileSync46 } from "fs";
44856
+ import { existsSync as existsSync77, readFileSync as readFileSync62, writeFileSync as writeFileSync46 } from "fs";
44965
44857
  import path91 from "path";
44966
44858
  import chalk265 from "chalk";
44967
44859
 
@@ -44986,11 +44878,11 @@ function insertRuleBullet(content, rule) {
44986
44878
  }
44987
44879
 
44988
44880
  // src/commands/rules/nextRuleCode.ts
44989
- import { readFileSync as readFileSync62 } from "fs";
44881
+ import { readFileSync as readFileSync61 } from "fs";
44990
44882
  var CODE_PREFIX = "R";
44991
44883
  function nextRuleCode(root2) {
44992
44884
  const numbers = findClaudeFiles(root2).flatMap(
44993
- (file) => parseRulesSection(readFileSync62(file, "utf8")).map(
44885
+ (file) => parseRulesSection(readFileSync61(file, "utf8")).map(
44994
44886
  (rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
44995
44887
  )
44996
44888
  );
@@ -45017,7 +44909,7 @@ function resolveRuleScope(target) {
45017
44909
 
45018
44910
  // src/commands/rules/addRule.ts
45019
44911
  function read3(file) {
45020
- return existsSync77(file) ? readFileSync63(file, "utf8") : "";
44912
+ return existsSync77(file) ? readFileSync62(file, "utf8") : "";
45021
44913
  }
45022
44914
  function addRule(text20, options2) {
45023
44915
  const rule = text20.trim();
@@ -45247,12 +45139,12 @@ function mapDataToEvents(data) {
45247
45139
  const levelIdx = col("Level");
45248
45140
  const exIdx = col("Exception");
45249
45141
  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,
45142
+ return data.Rows.map((row2) => ({
45143
+ Timestamp: ticksToIso(row2[tsIdx]),
45144
+ Level: String(row2[levelIdx] ?? ""),
45145
+ Exception: row2[exIdx] != null ? String(row2[exIdx]) : void 0,
45254
45146
  Properties: [],
45255
- MessageTemplateTokens: [{ Text: String(row3[msgIdx] ?? "") }]
45147
+ MessageTemplateTokens: [{ Text: String(row2[msgIdx] ?? "") }]
45256
45148
  }));
45257
45149
  }
45258
45150
 
@@ -45540,7 +45432,7 @@ function findShownSessionFiles(body, writtenPaths, locations) {
45540
45432
  }
45541
45433
 
45542
45434
  // src/commands/show/sessionWrittenPaths.ts
45543
- import { readFileSync as readFileSync64 } from "fs";
45435
+ import { readFileSync as readFileSync63 } from "fs";
45544
45436
 
45545
45437
  // src/commands/sessions/shared/asRecord.ts
45546
45438
  function asRecord(value) {
@@ -45568,7 +45460,7 @@ function writtenFilePaths(entry) {
45568
45460
  function sessionWrittenPaths(transcriptPath2) {
45569
45461
  let text20;
45570
45462
  try {
45571
- text20 = readFileSync64(transcriptPath2, "utf8");
45463
+ text20 = readFileSync63(transcriptPath2, "utf8");
45572
45464
  } catch {
45573
45465
  return [];
45574
45466
  }
@@ -45687,12 +45579,12 @@ import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync48 } from "fs";
45687
45579
  import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync47 } from "fs";
45688
45580
 
45689
45581
  // src/commands/slack/readSlackParts.ts
45690
- import { readFileSync as readFileSync65 } from "fs";
45582
+ import { readFileSync as readFileSync64 } from "fs";
45691
45583
  function readSlackParts(files) {
45692
45584
  return files.map((file) => {
45693
45585
  let contents;
45694
45586
  try {
45695
- contents = readFileSync65(file, "utf8");
45587
+ contents = readFileSync64(file, "utf8");
45696
45588
  } catch {
45697
45589
  console.error(`Error: Part file not found: ${file}`);
45698
45590
  process.exit(1);
@@ -45912,8 +45804,8 @@ function printTable(rows) {
45912
45804
  const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
45913
45805
  console.log(chalk276.dim(header));
45914
45806
  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(" ");
45807
+ for (const row2 of rows) {
45808
+ const line = columns.map((c, i) => formatCell(row2[c]).padEnd(widths[i])).join(" ");
45917
45809
  console.log(line);
45918
45810
  }
45919
45811
  console.log(chalk276.dim(`
@@ -46352,13 +46244,13 @@ function syncCodexHooks(sourcePath) {
46352
46244
  // src/commands/sync/syncCodex.ts
46353
46245
  function syncCodex(claudeDir, options2) {
46354
46246
  if (!isHarnessAvailable("codex")) return;
46355
- const { total: total3, names } = installHarnessCommands(
46247
+ const { total: total2, names } = installHarnessCommands(
46356
46248
  claudeDir,
46357
46249
  harnesses.codex,
46358
46250
  commandToSkill
46359
46251
  );
46360
46252
  syncCodexHooks(path98.join(claudeDir, "..", "codex", "config.toml"));
46361
- console.log(`Synced ${total3} skill(s) to ~/.codex/skills`);
46253
+ console.log(`Synced ${total2} skill(s) to ~/.codex/skills`);
46362
46254
  if (!options2?.prune) return;
46363
46255
  const force = options2.force ?? false;
46364
46256
  reportPrune(
@@ -46806,9 +46698,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
46806
46698
  }
46807
46699
 
46808
46700
  // src/commands/transcript/convert/readCleanedCues.ts
46809
- import { readFileSync as readFileSync70 } from "fs";
46701
+ import { readFileSync as readFileSync69 } from "fs";
46810
46702
  function readCleanedCues(inputPath) {
46811
- return deduplicateCues(parseVtt(readFileSync70(inputPath, "utf8")));
46703
+ return deduplicateCues(parseVtt(readFileSync69(inputPath, "utf8")));
46812
46704
  }
46813
46705
 
46814
46706
  // src/commands/transcript/clean.ts
@@ -46816,21 +46708,21 @@ var FORMATS = ["md", "vtt"];
46816
46708
  function isCleanFormat(value) {
46817
46709
  return FORMATS.includes(value);
46818
46710
  }
46819
- function serialise(cues, format3, timestamps) {
46820
- return format3 === "vtt" ? formatVtt(cues) : formatChatLog(cuesToChatMessages(cues), { timestamps });
46711
+ function serialise(cues, format2, timestamps) {
46712
+ return format2 === "vtt" ? formatVtt(cues) : formatChatLog(cuesToChatMessages(cues), { timestamps });
46821
46713
  }
46822
46714
  function clean(file, options2 = {}) {
46823
- const format3 = options2.format ?? "md";
46824
- if (!isCleanFormat(format3)) {
46715
+ const format2 = options2.format ?? "md";
46716
+ if (!isCleanFormat(format2)) {
46825
46717
  console.error(
46826
- `Error: --format must be one of: ${FORMATS.join(", ")} (got: ${format3})`
46718
+ `Error: --format must be one of: ${FORMATS.join(", ")} (got: ${format2})`
46827
46719
  );
46828
46720
  process.exit(1);
46829
46721
  }
46830
46722
  const timestamps = options2.timestamps ?? false;
46831
- if (timestamps && format3 !== "md") {
46723
+ if (timestamps && format2 !== "md") {
46832
46724
  console.error(
46833
- `Error: --timestamps applies only to --format md (got: ${format3})`
46725
+ `Error: --timestamps applies only to --format md (got: ${format2})`
46834
46726
  );
46835
46727
  process.exit(1);
46836
46728
  }
@@ -46843,7 +46735,7 @@ function clean(file, options2 = {}) {
46843
46735
  console.error(`Error: no cues found in: ${file}`);
46844
46736
  process.exit(1);
46845
46737
  }
46846
- console.log(serialise(cues, format3, timestamps));
46738
+ console.log(serialise(cues, format2, timestamps));
46847
46739
  }
46848
46740
 
46849
46741
  // src/commands/transcript/shared.ts
@@ -47588,7 +47480,7 @@ function configKeys2() {
47588
47480
  }
47589
47481
 
47590
47482
  // src/commands/verify/forbiddenStrings.ts
47591
- import { existsSync as existsSync86, readFileSync as readFileSync71 } from "fs";
47483
+ import { existsSync as existsSync86, readFileSync as readFileSync70 } from "fs";
47592
47484
 
47593
47485
  // src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
47594
47486
  import { minimatch as minimatch10 } from "minimatch";
@@ -47635,7 +47527,7 @@ function forbiddenStrings() {
47635
47527
  }
47636
47528
  let parsed;
47637
47529
  try {
47638
- parsed = JSON.parse(readFileSync71(file, "utf8"));
47530
+ parsed = JSON.parse(readFileSync70(file, "utf8"));
47639
47531
  } catch (error) {
47640
47532
  console.log(`Could not parse ${file}: ${error.message}`);
47641
47533
  process.exit(1);
@@ -47707,7 +47599,7 @@ Total: ${lines2.length} hardcoded color(s)`);
47707
47599
  }
47708
47600
 
47709
47601
  // src/commands/verify/migrations.ts
47710
- import { readFileSync as readFileSync72 } from "fs";
47602
+ import { readFileSync as readFileSync71 } from "fs";
47711
47603
  import path105 from "path";
47712
47604
 
47713
47605
  // src/commands/verify/migrations/checkAppendOnly.ts
@@ -47872,7 +47764,7 @@ function migrations2() {
47872
47764
  if (ref) {
47873
47765
  const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
47874
47766
  const current2 = new Map(
47875
- files.map((file) => [file, readFileSync72(path105.join(dir, file), "utf8")])
47767
+ files.map((file) => [file, readFileSync71(path105.join(dir, file), "utf8")])
47876
47768
  );
47877
47769
  for (const finding of checkAppendOnly(baseline, current2)) {
47878
47770
  problems.push(
@@ -48830,7 +48722,7 @@ function registerWatch(program) {
48830
48722
 
48831
48723
  // src/commands/roam/postRoamActivity.ts
48832
48724
  import { execFileSync as execFileSync31 } from "child_process";
48833
- import { readdirSync as readdirSync26, readFileSync as readFileSync73, statSync as statSync14 } from "fs";
48725
+ import { readdirSync as readdirSync26, readFileSync as readFileSync72, statSync as statSync14 } from "fs";
48834
48726
  import { join as join109 } from "path";
48835
48727
  function findPortFile(roamDir) {
48836
48728
  let entries;
@@ -48861,7 +48753,7 @@ function postRoamActivity(app, event) {
48861
48753
  if (!portFile) return;
48862
48754
  let port;
48863
48755
  try {
48864
- port = readFileSync73(portFile, "utf8").trim();
48756
+ port = readFileSync72(portFile, "utf8").trim();
48865
48757
  } catch {
48866
48758
  return;
48867
48759
  }
@@ -49482,11 +49374,11 @@ function applyLine(result, pending, line) {
49482
49374
  }
49483
49375
 
49484
49376
  // src/commands/sessions/daemon/readDaemonPidFile.ts
49485
- import { readFileSync as readFileSync74 } from "fs";
49377
+ import { readFileSync as readFileSync73 } from "fs";
49486
49378
  function readDaemonPidFile() {
49487
49379
  try {
49488
49380
  const pid = Number.parseInt(
49489
- readFileSync74(daemonPaths.pid, "utf8").trim(),
49381
+ readFileSync73(daemonPaths.pid, "utf8").trim(),
49490
49382
  10
49491
49383
  );
49492
49384
  return Number.isInteger(pid) ? pid : void 0;
@@ -49705,8 +49597,8 @@ function createActivityThrottle(onActivity) {
49705
49597
  import { eq as eq57 } from "drizzle-orm";
49706
49598
  var INBOX_LAST_RUN_KEY = "inbox.lastRun";
49707
49599
  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;
49600
+ const [row2] = await orm.select().from(metadata).where(eq57(metadata.key, INBOX_LAST_RUN_KEY));
49601
+ return row2 ? JSON.parse(row2.value) : void 0;
49710
49602
  }
49711
49603
 
49712
49604
  // src/commands/sessions/daemon/inbox/loadScanRun.ts
@@ -50329,7 +50221,7 @@ function sendResizeSnapshot(s, send) {
50329
50221
  }
50330
50222
 
50331
50223
  // src/commands/sessions/daemon/viewerSize.ts
50332
- import { readFileSync as readFileSync75, writeFileSync as writeFileSync59 } from "fs";
50224
+ import { readFileSync as readFileSync74, writeFileSync as writeFileSync59 } from "fs";
50333
50225
  var DEFAULT_SIZE = { cols: 120, rows: 30 };
50334
50226
  var remembered;
50335
50227
  function rememberViewerSize(cols, rows) {
@@ -50351,7 +50243,7 @@ function viewerSize() {
50351
50243
  function readSavedSize() {
50352
50244
  try {
50353
50245
  const { cols, rows } = JSON.parse(
50354
- readFileSync75(daemonPaths.viewerSize, "utf8")
50246
+ readFileSync74(daemonPaths.viewerSize, "utf8")
50355
50247
  );
50356
50248
  if (typeof cols === "number" && typeof rows === "number" && cols > 0)
50357
50249
  return { cols, rows };
@@ -51229,14 +51121,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
51229
51121
  }
51230
51122
 
51231
51123
  // src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
51232
- import { readFileSync as readFileSync76, writeFileSync as writeFileSync61 } from "fs";
51124
+ import { readFileSync as readFileSync75, writeFileSync as writeFileSync61 } from "fs";
51233
51125
  var KEEP_TAIL = 256 * 1024;
51234
51126
  var MAX_LOG_SIZE = 4 * 1024 * 1024;
51235
51127
  function trimWatcherLog(cwd) {
51236
51128
  const path109 = watcherLogPath(cwd);
51237
51129
  let log2;
51238
51130
  try {
51239
- log2 = readFileSync76(path109, "utf8");
51131
+ log2 = readFileSync75(path109, "utf8");
51240
51132
  } catch {
51241
51133
  return;
51242
51134
  }
@@ -51246,13 +51138,13 @@ function trimWatcherLog(cwd) {
51246
51138
  }
51247
51139
 
51248
51140
  // src/commands/sessions/daemon/worktree/appendWatcherLog.ts
51249
- import { appendFileSync as appendFileSync5, mkdirSync as mkdirSync41 } from "fs";
51141
+ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
51250
51142
  import { dirname as dirname50 } from "path";
51251
51143
  function appendWatcherLog(cwd, data) {
51252
51144
  try {
51253
51145
  const path109 = watcherLogPath(cwd);
51254
51146
  mkdirSync41(dirname50(path109), { recursive: true });
51255
- appendFileSync5(path109, data);
51147
+ appendFileSync4(path109, data);
51256
51148
  } catch {
51257
51149
  }
51258
51150
  }
@@ -52059,7 +51951,7 @@ function pidList(pids) {
52059
51951
  }
52060
51952
 
52061
51953
  // src/commands/sessions/daemon/worktree/readOccupant.ts
52062
- import { readFileSync as readFileSync77 } from "fs";
51954
+ import { readFileSync as readFileSync76 } from "fs";
52063
51955
  var VSCODE_PATHS = [
52064
51956
  "/.vscode-server/",
52065
51957
  "/.vscode-server-insiders/",
@@ -52094,7 +51986,7 @@ function parentPid(stat5) {
52094
51986
  }
52095
51987
  function readProc(procRoot, pid, file) {
52096
51988
  try {
52097
- return readFileSync77(`${procRoot}/${pid}/${file}`, "utf8");
51989
+ return readFileSync76(`${procRoot}/${pid}/${file}`, "utf8");
52098
51990
  } catch {
52099
51991
  return void 0;
52100
51992
  }
@@ -52948,10 +52840,10 @@ function applyReviewPause(session, activity2) {
52948
52840
  // src/shared/db/getPhaseActiveMs.ts
52949
52841
  import { and as and26, eq as eq58 } from "drizzle-orm";
52950
52842
  async function getPhaseActiveMs(db, itemId2, phaseIdx) {
52951
- const [row3] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
52843
+ const [row2] = await db.select({ activeMs: phaseUsage.activeMs }).from(phaseUsage).where(
52952
52844
  and26(eq58(phaseUsage.itemId, itemId2), eq58(phaseUsage.phaseIdx, phaseIdx))
52953
52845
  );
52954
- return row3?.activeMs ?? 0;
52846
+ return row2?.activeMs ?? 0;
52955
52847
  }
52956
52848
 
52957
52849
  // src/commands/sessions/daemon/loadPhaseActiveMs.ts
@@ -58301,7 +58193,7 @@ function handleConnection(socket, manager) {
58301
58193
  import { unlinkSync as unlinkSync21, writeFileSync as writeFileSync63 } from "fs";
58302
58194
 
58303
58195
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
58304
- import { readFileSync as readFileSync78 } from "fs";
58196
+ import { readFileSync as readFileSync77 } from "fs";
58305
58197
  var WATCHDOG_INTERVAL_MS = 5e3;
58306
58198
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
58307
58199
  const timer = setInterval(() => {
@@ -58312,7 +58204,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
58312
58204
  }
58313
58205
  function ownsPidFile() {
58314
58206
  try {
58315
- return readFileSync78(daemonPaths.pid, "utf8").trim() === String(process.pid);
58207
+ return readFileSync77(daemonPaths.pid, "utf8").trim() === String(process.pid);
58316
58208
  } catch {
58317
58209
  return false;
58318
58210
  }